﻿/* =====================================================================
   dm-components.css - the components this product adds on top of the
   ported design system.

   dm-theme.css and dm-primitives.css are verbatim copies of the source
   product and must stay that way: their palette is measured and their
   comments record the ratios. Anything invented here therefore lives in
   this file instead, and is built ONLY from their tokens - no new colour
   literals, because a hand-picked hex silently breaks a contrast
   guarantee that someone measured on purpose.

   Everything is scoped under body.dm-themed, so none of it can reach a
   screen still rendering through _Layout.cshtml.
   ===================================================================== */

/* ---- Impersonation banner -------------------------------------------
   _ImpersonationBanner.cshtml is shared with _Layout.cshtml, where
   Bootstrap's .alert-danger styles it. This layout loads no Bootstrap, so
   without these rules the banner is unstyled text on a dark ground - and
   a vendor admin who cannot see the banner cannot find "Stop
   impersonation", which is the one thing it exists for. -------------- */
body.dm-themed .dm-banner {
    position: sticky; top: 0; z-index: 1080;
    display: flex; flex-wrap: wrap; gap: 12px;
    align-items: center; justify-content: space-between;
    padding: 10px 16px;
    background: var(--danger-soft);
    border-bottom: 1px solid var(--danger);
    color: var(--text);
    font-size: 14px;
}
body.dm-themed .dm-banner strong { color: var(--danger); }
body.dm-themed .dm-banner form { margin: 0; }
body.dm-themed .dm-banner button {
    padding: 6px 14px; min-height: 32px;
    border-radius: 16px;
    background: var(--surface);
    border: 1px solid var(--danger);
    color: var(--text);
    font-size: 13px; font-weight: 600;
    cursor: pointer;
}
body.dm-themed .dm-banner button:hover { background: var(--surface-2); }

/* ---- Entity chip ----------------------------------------------------
   Sits in the top bar rather than the drawer because the active entity
   decides which customers every screen is showing. ------------------- */
body.dm-themed .dm-entity { position: relative; }
body.dm-themed .dm-entity-chip {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 8px 14px; min-height: 40px;
    border-radius: 20px;
    background: var(--surface);
    border: 1px solid var(--border-strong);
    color: var(--text);
    font-size: 13.5px; font-weight: 600;
    cursor: pointer;
    transition: background-color 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
}
body.dm-themed .dm-entity-chip:hover {
    background: var(--surface-2);
    border-color: var(--accent-line);
    box-shadow: 0 0 0 3px var(--accent-soft);
}
/* The building glyph is the one place orange is doing its job: marking,
   not carrying text. */
body.dm-themed .dm-entity-chip .fa-building { color: var(--accent); }
body.dm-themed .dm-entity-chip .fa-chevron-down { font-size: 11px; color: var(--text-muted); }

/* ---- Small menu -----------------------------------------------------
   Replaces the Bootstrap dropdown this layout does not load. --------- */
body.dm-themed .dm-menu {
    position: absolute; top: calc(100% + 8px); left: 0;
    min-width: 240px;
    padding: 6px;
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-overlay);
    z-index: 1060;
}
/* Explicit, and load-bearing. dm-preflight.css already has
   `body.dm-themed [hidden] { display: none }`, but that selector and
   `body.dm-themed .dm-menu` have EQUAL specificity, so the later file wins -
   and this file loads after the preflight. Without this rule the menu would
   ignore its own hidden attribute and sit open on every page load. */
body.dm-themed .dm-menu[hidden] { display: none; }
body.dm-themed .dm-menu-head {
    padding: 8px 10px 6px;
    font-size: 11px; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.05em;
    color: var(--text-muted);
}
/* The LIST scrolls, not the whole menu, so the "Switch entity" heading stays
   put while a tenant with many entities is scrolled through. This is also the
   rule that was missing: the markup carries .dm-menu-body and nothing defined
   it, which a cross-check caught before it shipped. */
body.dm-themed .dm-menu-body { max-height: 46vh; overflow-y: auto; }
body.dm-themed .dm-menu-item {
    display: block; width: 100%; text-align: left;
    padding: 9px 10px; border-radius: 8px;
    background: none; border: none;
    color: var(--text); font-size: 14px;
    cursor: pointer;
}
body.dm-themed .dm-menu-item:hover { background: var(--hover); }
body.dm-themed .dm-menu-empty {
    display: block; padding: 9px 10px;
    color: var(--text-dim); font-size: 13px;
}

/* ---- Tenant logo ----------------------------------------------------
   Height-bounded so an oversized upload cannot push the top bar apart.
   The upload is capped at 512 KB but nothing constrains its dimensions,
   which is exactly why this is bounded here rather than server-side. - */
body.dm-themed .dm-brand-logo {
    height: 28px; width: auto; max-width: 150px;
    object-fit: contain;
}

/* ---- Drawer above the banner ----------------------------------------
   dm-theme.css gives the drawer z-index 1050 and its overlay 1040, which is
   right in the source product - that product has no impersonation banner. Here
   the banner is sticky at top:0 with z-index 1080 and is ~56px tall, and the
   drawer is fixed at top:0 too, so the banner covered the drawer's heading and
   its close button.

   The drawer wins while it is open. That does hide "Stop impersonation" behind
   the overlay for as long as the drawer is up, which is the right trade: the
   drawer is modal and one Escape away, whereas a close button you cannot reach
   is a dead end. ------------------------------------------------------- */
body.dm-themed .dm-drawer { z-index: 1090; }
body.dm-themed .dm-drawer-overlay { z-index: 1085; }

/* ---- Panels and notices used by migrated screens ------------------- */
body.dm-themed .dm-card {
    padding: 18px 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-card);
}
body.dm-themed .dm-card-head {
    display: flex; flex-wrap: wrap; gap: 12px;
    align-items: flex-start; justify-content: space-between;
    margin-bottom: 14px;
}
body.dm-themed .dm-alert {
    margin-bottom: 14px; padding: 10px 14px;
    border-radius: 8px;
    background: var(--panel-tint);
    border: 1px solid var(--border-strong);
    color: var(--text); font-size: 14px;
}
/* --info, not --accent: this is informational, and orange has a job. */
body.dm-themed .dm-alert-info {
    background: var(--info-soft);
    border-color: var(--info);
}

body.dm-themed .dm-inline { display: inline-block; }
body.dm-themed .dm-text-end { text-align: right; }

/* =====================================================================
   UNIT B - the vocabulary the remaining screens need.

   Everything below is added for unit B's screen migrations. The screens
   still on _Layout.cshtml are Bootstrap: .form-control, .form-label,
   .form-text, .form-check, .nav-tabs, .alert-success, .card, .row/.col.
   _LayoutShell loads no Bootstrap, so each of those needs a dm-*
   counterpart before a screen can move. Defining them once here is why
   the per-screen migrations that follow are small.

   Same two rules as the rest of this file: scoped under body.dm-themed,
   and built only from dm-theme.css's tokens. No colour literals.
   ===================================================================== */

/* ---- Alert variants -------------------------------------------------
   dm-alert + dm-alert-info shipped with unit A; the screens below also
   need success, warning and danger. --warning-soft / --danger-soft /
   --success-soft are all measured tints from dm-theme.css. ----------- */
body.dm-themed .dm-alert-success { background: var(--success-soft); border-color: var(--success); }
body.dm-themed .dm-alert-warning { background: var(--warning-soft); border-color: var(--warning); }
body.dm-themed .dm-alert-danger  { background: var(--danger-soft);  border-color: var(--danger);  }
/* A quiet, un-toned notice - "this feature is not configured", not a problem. */
body.dm-themed .dm-alert-muted   { background: var(--surface-2); border-color: var(--border); color: var(--text-muted); }

/* ---- Forms ----------------------------------------------------------
   dm-preflight.css already re-tokenises the field chrome (@tailwindcss/
   forms, re-coloured), but it deliberately leaves border-radius: 0 and
   sets no text colour, because it is a normalizer and not a component.
   These classes are the component: the radius, the colour, the width
   behaviour and the disabled state. ---------------------------------- */
body.dm-themed .dm-field { margin-bottom: 14px; }
body.dm-themed .dm-label {
    display: block; margin-bottom: 6px;
    font-size: 12px; font-weight: 600;
    letter-spacing: 0.03em;
    color: var(--text-muted);
}
body.dm-themed .dm-input,
body.dm-themed .dm-select,
body.dm-themed .dm-textarea {
    display: block; width: 100%;
    padding: 9px 12px;
    border-radius: 8px;
    border: 1px solid var(--border-strong);
    background: var(--surface-2);
    color: var(--text);
    font-size: 14px; line-height: 1.4;
    transition: border-color 160ms ease, box-shadow 160ms ease;
}
body.dm-themed .dm-textarea { min-height: 96px; resize: vertical; }
body.dm-themed .dm-input:focus,
body.dm-themed .dm-select:focus,
body.dm-themed .dm-textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}
body.dm-themed .dm-input:disabled,
body.dm-themed .dm-select:disabled,
body.dm-themed .dm-textarea:disabled {
    opacity: 0.6; cursor: not-allowed; background: var(--surface);
}
/* The native arrow is drawn by the OS in the OS's colour, which on the dark
   theme is a dark glyph on a dark field. appearance:none in the preflight
   already removed it, so the chevron has to be drawn here. */
body.dm-themed .dm-select {
    padding-right: 32px;
    background-image: linear-gradient(45deg, transparent 50%, currentColor 50%),
                      linear-gradient(135deg, currentColor 50%, transparent 50%);
    background-position: calc(100% - 17px) calc(50% + 1px), calc(100% - 12px) calc(50% + 1px);
    background-size: 5px 5px, 5px 5px;
    background-repeat: no-repeat;
}
/* A field that should not stretch to the container - a sort order, a count. */
body.dm-themed .dm-input-narrow { width: 7rem; }
body.dm-themed .dm-help { margin-top: 5px; font-size: 12px; color: var(--text-dim); }
body.dm-themed .dm-error { margin-top: 5px; font-size: 12px; color: var(--danger); }

/* A form that reads as a column of fields, capped so a single-column form
   does not stretch one line of input across a 27-inch monitor. */
body.dm-themed .dm-form { max-width: 34rem; }
body.dm-themed .dm-form-wide { max-width: 56rem; }
/* Fields side by side, wrapping on narrow viewports. Replaces Bootstrap's
   .row.g-2 + .col-auto, which this layout has no grid for. */
body.dm-themed .dm-form-row {
    display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end;
}
body.dm-themed .dm-form-row > .dm-field { margin-bottom: 0; flex: 1 1 12rem; }
body.dm-themed .dm-form-row > .dm-field-auto { flex: 0 0 auto; }
body.dm-themed .dm-form-actions {
    display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
    margin-top: 18px;
}

/* Checkbox / radio on a line with its label. The control keeps the native
   appearance (the preflight does not strip it for checkboxes) and only
   gets the accent colour, so it stays a real, keyboard-operable control. */
body.dm-themed .dm-check-line {
    display: flex; align-items: center; gap: 9px;
    margin-bottom: 10px;
    color: var(--text); font-size: 14px;
}
body.dm-themed .dm-check-line input[type="checkbox"],
body.dm-themed .dm-check-line input[type="radio"] {
    width: 16px; height: 16px;
    accent-color: var(--accent);
    flex-shrink: 0; cursor: pointer;
}
body.dm-themed .dm-check-line label { cursor: pointer; margin: 0; }

/* File inputs: ::file-selector-button is a separate shadow element and
   inherits none of the field styling above, so it is styled explicitly or
   it renders as an OS-grey button on the themed ground. */
body.dm-themed .dm-file {
    display: block; width: 100%;
    padding: 8px; border-radius: 8px;
    border: 1px dashed var(--border-strong);
    background: var(--surface-2);
    color: var(--text); font-size: 13px;
}
body.dm-themed .dm-file::file-selector-button {
    margin-right: 12px; padding: 7px 14px;
    border-radius: 16px; border: 1px solid var(--border-strong);
    background: var(--surface); color: var(--text);
    font-size: 13px; font-weight: 500; cursor: pointer;
}
body.dm-themed .dm-file::file-selector-button:hover { background: var(--hover); border-color: var(--accent-line); }

/* ---- Tabs -----------------------------------------------------------
   Replaces Bootstrap's .nav-tabs on the admin console's _AdminNav. ---- */
body.dm-themed .dm-tabs {
    display: flex; flex-wrap: wrap; gap: 4px;
    margin: 0 0 18px; padding: 0 0 2px;
    list-style: none;
    border-bottom: 1px solid var(--border);
}
body.dm-themed .dm-tabs li { margin: 0; }
body.dm-themed .dm-tab {
    display: inline-flex; align-items: center; gap: 7px;
    padding: 9px 16px;
    border: 1px solid transparent;
    border-bottom: none;
    border-radius: 8px 8px 0 0;
    background: none;
    color: var(--text-muted);
    font-size: 14px; font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    margin-bottom: -3px;
}
body.dm-themed .dm-tab:hover { background: var(--hover); color: var(--text); }
/* The active tab is marked by an accent underline rather than a filled
   ground: orange is 2.71:1 on white and cannot carry text, but as a 2px
   rule under the label it is marking, not labelling - which is the one
   thing dm-theme.css's header comment says it may do. */
body.dm-themed .dm-tab.active {
    color: var(--text);
    background: var(--surface);
    border-color: var(--border);
    box-shadow: inset 0 -2px 0 var(--accent);
}

/* ---- Table header ---------------------------------------------------
   dm-theme.css styles .dm-table's td but never its th - the ported grid
   draws its header as a separate bar of divs (.dm-header-bar), so a real
   <thead> never came up there. Every screen below has one. ----------- */
body.dm-themed .dm-table th {
    padding: 8px 14px;
    text-align: left;
    color: var(--text-muted);
    font-size: 11px; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.05em;
    white-space: nowrap;
    background: none;
    border: none;
}
/* dm-primitives.css's .dm-th sets colour from --color-text-secondary, a
   light-theme literal from the pre-token era, which is near-invisible on
   the dark ground. The markup keeps the class (it is the ported name);
   this re-points it at the theme token, which flips. */
body.dm-themed .dm-table th.dm-th { color: var(--text-muted); }
/* A row that is present but inactive - a disabled entity, a retired
   template. Dimmed rather than hidden, because it is still actionable. */
body.dm-themed .dm-table tr.dm-row-muted td { opacity: 0.55; }
/* The grid rows are clickable on Home, so dm-theme.css sets
   cursor: pointer on every .dm-table row. On the screens below a row is
   just a row, and a pointer cursor over inert text invites a click that
   does nothing. */
body.dm-themed .dm-table.dm-table-static tbody tr { cursor: default; }
body.dm-themed .dm-table-responsive { width: 100%; overflow-x: auto; }

/* ---- Page furniture -------------------------------------------------- */
body.dm-themed .dm-h2 { font-size: 18px; font-weight: 600; color: var(--text); margin: 0 0 6px; }
body.dm-themed .dm-h3 { font-size: 15px; font-weight: 600; color: var(--text); margin: 0 0 6px; }
body.dm-themed .dm-lede { margin: 0 0 16px; color: var(--text-muted); font-size: 13.5px; line-height: 1.5; }
body.dm-themed .dm-muted { color: var(--text-muted); }
body.dm-themed .dm-dim { color: var(--text-dim); }
body.dm-themed .dm-small { font-size: 12px; }
body.dm-themed .dm-center { text-align: center; }
body.dm-themed .dm-nowrap { white-space: nowrap; }
body.dm-themed .dm-divider { border: none; border-top: 1px solid var(--border); margin: 24px 0; }
/* Vertical rhythm between cards/sections on a page that stacks several. */
body.dm-themed .dm-stack > * + * { margin-top: 18px; }
/* A horizontal group of controls - buttons in a row, a chip beside a label. */
body.dm-themed .dm-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
body.dm-themed .dm-spread { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; }
/* Inline monospace - a tenant code, a location id, a connection string. */
body.dm-themed .dm-code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.92em;
    padding: 1px 6px; border-radius: 5px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--text);
}
body.dm-themed a { color: var(--accent); }
body.dm-themed a:hover { color: var(--accent); text-decoration: underline; }
/* Links inside chrome that already carries its own colour must not turn
   orange: the drawer's nav, table action buttons, tabs and the brand. */
body.dm-themed .dm-drawer a,
body.dm-themed .dm-brand,
body.dm-themed .dm-tab,
body.dm-themed .dm-btn,
body.dm-themed .dm-menu-item { color: inherit; }
body.dm-themed .dm-btn:hover, body.dm-themed .dm-tab:hover { text-decoration: none; }
body.dm-themed .dm-btn-primary { color: var(--on-primary); }
body.dm-themed .dm-btn-danger  { color: var(--danger); }

/* ---- Badge variants -------------------------------------------------
   dm-primitives.css ships dm-badge--active/inactive/pending/sent/failed/
   posted/logged as light-theme literals (it predates the tokens). These
   four are the statuses the admin console reports and are token-built so
   they flip with the theme. ------------------------------------------ */
body.dm-themed .dm-badge--healthy { background: var(--success-soft); color: var(--success); }
body.dm-themed .dm-badge--danger  { background: var(--danger-soft);  color: var(--danger);  }
body.dm-themed .dm-badge--neutral { background: var(--surface-2);    color: var(--text-muted); }
body.dm-themed .dm-badge--info    { background: var(--info-soft);    color: var(--info);    }

/* ---- Definition list - "label: value" metadata blocks ---------------- */
body.dm-themed .dm-dl { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; margin: 0; }
body.dm-themed .dm-dl dt { color: var(--text-muted); font-size: 12.5px; }
body.dm-themed .dm-dl dd { margin: 0; color: var(--text); font-size: 13.5px; }

/* A warning-toned button: suspending a tenant, discarding a draft. Outlined
   rather than filled for the same reason dm-btn-danger is - --warning is a
   mark colour and cannot take text on a solid fill in the light theme. */
body.dm-themed .dm-btn-warning {
    background: transparent; color: var(--warning);
    border: 1px solid var(--warning); border-radius: 8px;
    padding: 9px 16px; cursor: pointer; min-height: 40px;
}
body.dm-themed .dm-btn-warning:hover { background: var(--warning-soft); }

/* A file input sitting inside a table row, where the full-width dashed
   dropzone above would blow the column out. */
body.dm-themed .dm-file-sm {
    display: inline-block; width: auto;
    padding: 5px 8px; font-size: 12px;
    border-style: solid;
}
body.dm-themed .dm-file-sm::file-selector-button { margin-right: 8px; padding: 4px 10px; font-size: 12px; }

/* Text that is itself the alarm - an "effective template: None" cell that
   means this row cannot send at all. */
body.dm-themed .dm-text-danger { color: var(--danger); }
body.dm-themed .dm-text-warning { color: var(--warning); }
body.dm-themed .dm-text-success { color: var(--success); }

/* ---- Segmented control ----------------------------------------------
   Replaces Bootstrap's .btn-group + .btn-check radio pattern on the two
   signature/layout editors. The radios stay real radios - visually hidden,
   not display:none, so they keep their name/value, still post, and are
   still reachable by keyboard with arrow keys. ----------------------- */
body.dm-themed .dm-segmented {
    display: inline-flex;
    padding: 3px;
    border-radius: 22px;
    background: var(--surface-2);
    border: 1px solid var(--border-strong);
}
body.dm-themed .dm-segmented input[type="radio"] {
    position: absolute; width: 1px; height: 1px;
    padding: 0; margin: -1px; overflow: hidden;
    clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
body.dm-themed .dm-segmented label {
    display: inline-flex; align-items: center; gap: 7px;
    padding: 8px 18px; min-height: 34px;
    border-radius: 19px;
    color: var(--text-muted);
    font-size: 14px; font-weight: 500;
    cursor: pointer;
    transition: background-color 160ms ease, color 160ms ease;
}
body.dm-themed .dm-segmented label:hover { color: var(--text); }
body.dm-themed .dm-segmented input:checked + label {
    background: var(--primary);
    color: var(--on-primary);
    font-weight: 600;
}
/* Focus lands on the hidden input, so the ring has to be drawn on its label. */
body.dm-themed .dm-segmented input:focus-visible + label {
    outline: 2px solid var(--accent); outline-offset: 2px;
}

/* ---- Two-column split ------------------------------------------------
   Replaces .row + .col-md-6. Collapses to one column below 900px rather
   than at Bootstrap's md breakpoint - these panes are an editor beside its
   preview and stop being useful side by side well before 768px. ------- */
body.dm-themed .dm-split {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
    align-items: start;
}
@media (max-width: 900px) {
    body.dm-themed .dm-split { grid-template-columns: 1fr; }
}

/* A rich-text editing surface: same chrome as .dm-input but sized for a
   block of content rather than one line. */
body.dm-themed .dm-editor {
    min-height: 320px; max-height: 60vh;
    overflow: auto;
    padding: 12px;
    border-radius: 8px;
    border: 1px solid var(--border-strong);
    background: var(--surface-2);
    color: var(--text);
    font-size: 14px;
}
body.dm-themed .dm-editor:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

/* The preview iframe renders tenant-authored email HTML, which assumes a
   white mail-client ground. It keeps a white background in BOTH themes on
   purpose - showing it on the dark surface would preview a document that
   does not exist. */
body.dm-themed .dm-preview-frame {
    width: 100%; height: 420px;
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    background: #fff;
}

body.dm-themed .dm-mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

/* dm-preflight.css strips list markers and padding from every ul/ol (it is
   Tailwind's preflight), so a list that is genuinely a list has to ask. */
body.dm-themed .dm-list { margin: 0 0 12px; padding-left: 22px; list-style: disc; color: var(--text); }
body.dm-themed .dm-list li { margin: 3px 0; }

/* A header that stays put while the rows scroll under it. The old Details and
   Home screens both solved this by drawing the header as a separate bar of
   divs outside the scroll container (.dm-header-bar / .table-header-bar), which
   works but means the header columns and the body columns are two independent
   grids that have to be kept in step by hand. A sticky <thead> is one grid.

   The background is explicit: .dm-table sets border-spacing, so without a
   ground of its own the sticky header would have rows visible through the gaps
   as they pass beneath it. */
body.dm-themed .dm-table-sticky thead th {
    position: sticky; top: 0; z-index: 2;
    background: var(--bg-mid);
    box-shadow: inset 0 -1px 0 var(--border);
}

/* A scroll area that fills what is left of the viewport. The page's own scroll
   is untouched -- this is for a screen whose single table is the whole content
   and which should not make the reader scroll twice. */
body.dm-themed .dm-table-fill {
    overflow-y: auto;
    max-height: calc(100vh - 260px);
    min-height: 180px;
    scrollbar-color: var(--border-strong) transparent;
    scrollbar-width: thin;
}
body.dm-themed .dm-table-fill::-webkit-scrollbar { width: 6px; height: 6px; }
body.dm-themed .dm-table-fill::-webkit-scrollbar-track { background: transparent; }
body.dm-themed .dm-table-fill::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 4px; }
body.dm-themed .dm-table-fill::-webkit-scrollbar-thumb:hover { background: var(--accent); }

/* A checkbox in a table cell: the native control, in the accent colour, sized to
   sit on a row of 14px text. Left native rather than replaced by a custom disc
   (as the Home grid does) because nothing here selects on its appearance. */
body.dm-themed .dm-table input[type="checkbox"] {
    width: 16px; height: 16px;
    accent-color: var(--accent);
    cursor: pointer;
}

/* ---- Rich-text toolbar ----------------------------------------------
   The Feedback capture note is a contenteditable with a document.execCommand
   toolbar above it. The buttons are square icon-buttons rather than .dm-btn
   pills: a row of ten pills reads as ten separate actions, a row of squares
   reads as one control. -------------------------------------------- */
body.dm-themed .dm-toolbar {
    display: flex; align-items: center; flex-wrap: wrap; gap: 4px;
    padding: 6px;
    border: 1px solid var(--border-strong);
    border-bottom: none;
    border-radius: 8px 8px 0 0;
    background: var(--surface);
}
body.dm-themed .dm-toolbar button {
    min-width: 32px; height: 30px;
    padding: 0 9px;
    border-radius: 6px;
    border: 1px solid transparent;
    background: none;
    color: var(--text-muted);
    font-size: 13px;
    cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center;
}
body.dm-themed .dm-toolbar button:hover { background: var(--hover); color: var(--text); }
/* .active is what document.queryCommandState toggles, so the name is fixed. */
body.dm-themed .dm-toolbar button.active {
    background: var(--accent-soft);
    border-color: var(--accent-line);
    color: var(--accent);
}
body.dm-themed .dm-toolbar-sep {
    width: 1px; height: 18px; margin: 0 4px;
    background: var(--border-strong);
}
/* Square off the editor under a toolbar so the two read as one control. */
body.dm-themed .dm-toolbar + .dm-editor { border-radius: 0 0 8px 8px; }

/* ---- Aside + main split ----------------------------------------------
   A fixed-width column of controls beside a pane that takes everything
   else - an editor next to its preview. Differs from .dm-split, which is
   two equal halves: here the controls gain nothing from extra width and
   the preview gains everything, so every pixel past the breakpoint goes to
   the preview. Override the aside's width with --dm-aside. ---------- */
body.dm-themed .dm-split-aside {
    display: grid;
    grid-template-columns: 1fr;
    gap: 18px;
    align-items: start;
}
@media (min-width: 1024px) {
    body.dm-themed .dm-split-aside {
        grid-template-columns: var(--dm-aside, 360px) minmax(0, 1fr);
    }
}

/* ---- Inline status line ----------------------------------------------
   "Saving…", "Saved.", "Save failed - could not reach the server." Every
   screen that saves over fetch needs one, and every one of them used to
   set the colour with an inline style from a hard-coded hex. A class per
   state instead, so the colours come from the tokens and flip with the
   theme.

   Three states and not two, deliberately: a save that stored the value but
   has a caveat is amber, because showing it in red reads as a failure and
   sends people hunting for a problem that may not exist. ------------- */
body.dm-themed .dm-status-line { font-size: 12px; color: var(--text-muted); line-height: 1.5; }
body.dm-themed .dm-status-line.is-ok   { color: var(--success); }
body.dm-themed .dm-status-line.is-warn { color: var(--warning); }
body.dm-themed .dm-status-line.is-bad  { color: var(--danger); }

/* The subject bar sitting on top of an email preview frame, squared off
   against it so the two read as one window. */
body.dm-themed .dm-preview-subject {
    padding: 9px 13px;
    border: 1px solid var(--border-strong);
    border-bottom: none;
    border-radius: 8px 8px 0 0;
    background: var(--surface-2);
    color: var(--text-muted);
    font-size: 13px;
}
body.dm-themed .dm-preview-subject strong { color: var(--text); }
body.dm-themed .dm-preview-subject + .dm-preview-frame { border-radius: 0 0 8px 8px; }

/* Settings tab panes. dm-preflight.css already defines [hidden]{display:none},
   so the pane just needs the class as a selector for the tab switcher to find
   them all without listing their ids. */
body.dm-themed .dm-settings-pane { display: block; }
body.dm-themed .dm-settings-pane[hidden] { display: none; }

/* Link tab strips: a .dm-pagetabs made of <a class="tab"> links rather than client-side
   panes (the admin tenant screen's _TenantTabs, the Email screens' _EmailTabs). The colour
   rules in dm-theme.css already beat the global `a` colour, but `a:hover` also underlines,
   so that is switched off here, and a keyboard user gets a visible focus ring. */
body.dm-themed .dm-pagetabs a.tab:hover { text-decoration: none; }
body.dm-themed .dm-pagetabs a.tab:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Vendor admin tenant screen (Admin/Tenant, Entities, TenantTemplates). Seven tabs
   overflow a phone, so this strip wraps (overflow-x:auto would clip the active tab's
   -1px underline). The panes restate [hidden] for the same reason the Settings panes
   do: the preflight rule has zero specificity. */
body.dm-themed .dm-tenant-tabs { flex-wrap: wrap; margin: 4px 0 18px; }
body.dm-themed .dm-tenant-pane { display: block; }
body.dm-themed .dm-tenant-pane[hidden] { display: none; }

/* Email screens (Message, Layouts, Signatures, Font & style) - the _EmailTabs strip. Wraps
   on a phone for the same reason as the tenant strip. */
body.dm-themed .dm-email-tabs { flex-wrap: wrap; margin-bottom: 16px; }

/* A right-aligned column has to align its HEADING too. `.dm-table th` above
   sets text-align:left at (0,2,2), which outweighs both `.dm-text-end` (0,2,1)
   and `.dm-num` — so without these the numeric headings sat left while their
   cells sat right, and the column read as misaligned. Found by opening the
   admin tenants list, not by the cross-check: both classes resolve, and one
   of them was simply losing. */
body.dm-themed .dm-table th.dm-text-end,
body.dm-themed .dm-table th.dm-num { text-align: right; }
body.dm-themed .dm-table th.dm-center { text-align: center; }

/* ---------------------------------------------------------------------------
   App frame  --  every _LayoutShell screen (body.dm-frame)

   The DOCUMENT never scrolls. The banner and the top bar keep their natural
   height, <main class="dm-page"> takes what is left and is the one scroll
   region, and a view's  @section Footer  renders as .dm-page-footer under it,
   pinned. A screen's buttons therefore never sit below the fold: they go in
   the top bar (TopActions), the footer, or a component's own fixed head/foot.

   100vh is the fallback; 100dvh tracks a mobile browser's collapsing URL bar,
   which 100vh does not, so the footer is not pushed under it.

   The older per-screen opt-ins (:has(.dm-home-page), .dm-fb-page, .dm-et-page,
   .dm-ir-page, .dm-xs-page in dm-theme.css / dm-excel-statements.css) still
   apply on top of this -- they turn .dm-page into a flex column with
   overflow:hidden, which is "fill" mode under another name.
   --------------------------------------------------------------------------- */
body.dm-themed.dm-frame {
    height: 100vh;
    height: 100dvh;
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

body.dm-themed.dm-frame > .dm-banner,
body.dm-themed.dm-frame > .dm-top-section,
body.dm-themed.dm-frame > .dm-page-footer { flex: 0 0 auto; }

/* The sticky header is pointless once the document cannot scroll, and sticky
   inside a flex column can leave a gap at the top. */
body.dm-themed.dm-frame > .dm-top-section,
body.dm-themed.dm-frame > .dm-banner { position: static !important; }

/* min-height:0 is load-bearing: without it a flex item refuses to shrink below
   its content, the page grows past the viewport and the document scrolls after
   all -- which is the whole thing this frame exists to stop. */
body.dm-themed.dm-frame > .dm-page {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-color: var(--border-strong) transparent;
    scrollbar-width: thin;
}
body.dm-themed.dm-frame > .dm-page::-webkit-scrollbar { width: 6px; }
body.dm-themed.dm-frame > .dm-page::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 4px; }

/* ---- Pinned action bar ----------------------------------------------------
   A plain flex row. Buttons are right-aligned by default; a view that wants a
   left group (Back) and a right group (Save) uses .dm-footer-start for the
   left one. A <button> that submits a form living in the scroll region names
   it with form="..." -- the footer is outside every form by construction. */
body.dm-themed .dm-page-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px 20px;
    border-top: 1px solid var(--border);
    background: var(--bg-dark);
}
/* A footer whose only content sat behind an @if renders as an empty bar. */
body.dm-themed .dm-page-footer:not(:has(*)) { display: none; }
body.dm-themed .dm-page-footer .dm-footer-start {
    display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
    margin-right: auto;
}
body.dm-themed .dm-page-footer .dm-footer-note {
    margin-right: auto; color: var(--text-muted); font-size: 13px;
}

/* ---- Fill mode  --  ViewData["PageMode"] = "fill" ---------------------------
   <main> stops scrolling and hands its remaining height to the element marked
   .dm-fill-body, which owns its own scrolling (a table, a chat feed).

   The fill element marks ITSELF. Deliberately not `:last-child` -- a view's
   last child is usually a <script>, which is display:none and would swallow
   the flex growth, leaving the real content unsized.

   height/min-height are reset because the ported .chat-shell carries
   `height: calc(100vh - 188px)` and `min-height: 580px`; the second would still
   overflow a short window even once the first is neutralised. */
/* overflow-y:auto, not hidden: on a window too short for the fixed rows plus
   the fill element's floor, <main> scrolls as a last resort instead of
   clipping the bottom of the component where nobody can reach it. */
body.dm-themed.dm-fill > .dm-page {
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}
body.dm-themed.dm-fill > .dm-page > * { flex: 0 0 auto; }
body.dm-themed.dm-fill .dm-fill-body {
    flex: 1 1 auto;
    min-height: 180px;
    height: auto;
    margin-bottom: 0;
}

/* A card that fills: a column whose scrolling child takes the slack. Any
   direct child marked .dm-fill-scroll (or the usual .dm-table-fill) is that
   child; the card's other rows (a toolbar, a pager) keep their height. */
body.dm-themed.dm-fill .dm-fill-body.dm-card,
body.dm-themed.dm-fill .dm-fill-col {
    display: flex;
    flex-direction: column;
}
body.dm-themed.dm-fill .dm-fill-body.dm-card > *,
body.dm-themed.dm-fill .dm-fill-col > * { flex: 0 0 auto; }
body.dm-themed.dm-fill .dm-fill-body > .dm-table-fill,
body.dm-themed.dm-fill .dm-fill-body > .dm-fill-scroll,
body.dm-themed.dm-fill .dm-fill-col > .dm-table-fill,
body.dm-themed.dm-fill .dm-fill-col > .dm-fill-scroll {
    flex: 1 1 auto;
    min-height: 0;
    max-height: none;
    overflow: auto;
}


/* ---------------------------------------------------------------------------
   Notification bell  --  unit C2

   dm-theme.css already carries .dm-bell, .dm-bell-badge, .dm-notif-pop/-head/
   -body/-item/-empty, ported with the rest of the design system in unit A.
   What follows is only the part that file does NOT have: the three-tab strip,
   the per-row dismiss button, and the mention toast.

   The source product injects these from JavaScript. They live here instead.
   class-crosscheck.sh scans stylesheets, so an injected rule reads to it as a
   class nobody styles -- and "the check is wrong, ignore it" is how a real
   missing rule gets waved through later. One mechanism, one place to look.
   --------------------------------------------------------------------------- */
body.dm-themed .dm-bell.has-unread i { color: var(--accent); }
body.dm-themed .dm-bell.has-unread { animation: dmBellWiggle 1.1s ease 1; }

@keyframes dmBellWiggle {
    0%, 100% { transform: rotate(0); }
    20%      { transform: rotate(12deg); }
    40%      { transform: rotate(-10deg); }
    60%      { transform: rotate(6deg); }
    80%      { transform: rotate(-4deg); }
}

body.dm-themed .dm-notif-tabs {
    display: flex; gap: 2px; padding: 0 8px;
    border-bottom: 1px solid var(--border);
}
body.dm-themed .dm-notif-tab {
    flex: 1; background: none; border: 0; padding: 9px 6px;
    font: inherit; font-size: 12px; color: var(--text-muted);
    cursor: pointer; border-bottom: 2px solid transparent;
    transition: color .15s, border-color .15s;
}
body.dm-themed .dm-notif-tab.is-active {
    color: var(--text); border-bottom-color: var(--accent);
}

body.dm-themed .dm-notif-item { position: relative; }
body.dm-themed .dm-notif-dismiss {
    position: absolute; top: 8px; right: 8px;
    width: 24px; height: 24px;
    display: inline-flex; align-items: center; justify-content: center;
    padding: 0; border: 0; border-radius: 50%;
    background: transparent; color: var(--text-muted);
    cursor: pointer; font-size: 11px;
    opacity: 0; transition: opacity .12s, background .12s, color .12s;
}
/* Revealed on hover, but ALWAYS on keyboard focus - otherwise the control is
   invisible and unreachable to anyone not using a mouse. */
body.dm-themed .dm-notif-item:hover .dm-notif-dismiss,
body.dm-themed .dm-notif-dismiss:focus-visible { opacity: 1; }
body.dm-themed .dm-notif-dismiss:hover {
    background: var(--accent-soft); color: var(--accent);
}

/* Mention toast. Fixed to the viewport, so it is deliberately not scoped to
   .dm-page - it has to survive the page fill mode above. */
#dm-mention-toasts {
    position: fixed; top: 72px; right: 18px; z-index: 2000;
    display: flex; flex-direction: column; gap: 10px; max-width: 330px;
}
.dm-mention-toast {
    display: flex; gap: 11px; align-items: flex-start;
    background: var(--surface);
    border: 1px solid var(--accent-line);
    border-left: 3px solid var(--accent);
    border-radius: 12px; padding: 12px 14px;
    box-shadow: 0 18px 40px -16px rgba(0, 0, 0, .6);
    cursor: pointer;
    opacity: 0; transform: translateX(20px); transition: .3s;
}
.dm-mention-toast.show { opacity: 1; transform: none; }
.dm-mention-toast i { color: var(--accent); margin-top: 2px; }
.dm-mention-toast .t { font-weight: 600; font-size: 13.5px; color: var(--text); }
.dm-mention-toast .b { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* Section strips (2026-11-06 drawer condense): _SettingsTabs and _InsightsTabs. The primary
   navigation for a group of screens that share one drawer entry. Deliberately NOT .dm-pagetabs:
   several of these pages carry their own client-side .dm-pagetabs strip as a second level, and
   those scripts select '.dm-pagetabs .tab'. Wraps on a phone rather than scrolling, so the active
   tab's underline is never clipped. */
body.dm-themed .dm-sectiontabs {
    display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
    margin: 4px 0 16px; border-bottom: 1px solid var(--border);
}
body.dm-themed .dm-sectiontab {
    display: inline-flex; align-items: center; gap: 7px; padding: 9px 14px;
    font-size: 14px; font-weight: 600; color: var(--text-muted);
    border-bottom: 2px solid transparent; margin-bottom: -1px;
    transition: color .2s, border-color .2s; text-decoration: none;
}
body.dm-themed .dm-sectiontab:hover { color: var(--text); text-decoration: none; }
body.dm-themed .dm-sectiontab.active { color: var(--accent); border-bottom-color: var(--accent); }
body.dm-themed .dm-sectiontab:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Second-level strips under a section strip (the Email screens' _EmailTabs): pills, so the two
   levels never read as one row. */
body.dm-themed .dm-sectiontabs + .dm-email-tabs { border-bottom: 0; gap: 4px; margin-top: -4px; }
body.dm-themed .dm-sectiontabs + .dm-email-tabs a.tab {
    border: 1px solid var(--border); border-radius: 999px; padding: 5px 12px; font-size: 13px; margin-bottom: 0;
}
body.dm-themed .dm-sectiontabs + .dm-email-tabs a.tab.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* Header icon links sitting beside the theme toggle (What's new). */
body.dm-themed a.dm-header-icon { color: var(--text); text-decoration: none; }

/* Settings screens have no page-title band (the section strip names the screen), so the strip
   needs a little air under the header. A heading's trailing context ("entity 200"). */
body.dm-themed .dm-page > .dm-sectiontabs:first-child { margin-top: 12px; }
body.dm-themed .dm-h2-note { font-size: 12.5px; font-weight: 500; margin-left: 8px; }
