/* ============================================================
   DESIGN TOKENS
   ------------------------------------------------------------
   Every colour, size, radius and shadow in this file should come
   from here. Before these existed the file carried 167 distinct
   hex values, 36 font sizes, 13 radii and 20 shadows -- six ways
   to write "the border colour", eight ways to write "the blue".
   That inconsistency, not any individual page, is what made the
   app look unfinished.

   Rules:
   - Never write a raw hex in a component rule. Add a token, or
     use the nearest one.
   - Type and space come off the scales below. If a value is not
     on the scale, it is wrong, not special.
   - The legacy aliases at the bottom (--bg, --text, --accent...)
     exist because ~200 existing rules reference them. They are
     defined in terms of the ramps, so there is exactly one
     source of truth. Prefer the ramp names in new code.
   ============================================================ */
:root {
    color-scheme: light;

    /* --- brand ------------------------------------------------ */
    --brand-700: #4643a5;
    --brand-600: #5752c7;   /* primary actions, links */
    --brand-500: #6964dd;
    --brand-400: #8d89ea;
    --brand-100: #ecebfd;   /* selected row / active nav fill */
    --brand-50:  #f7f6ff;   /* hover fill */

    /* --- ink (text) ------------------------------------------- */
    --ink-900: #172033;     /* page headings */
    --ink-800: #202b3f;     /* strong text, figures */
    --ink-700: #344055;     /* panel titles */
    --ink-600: #4b5870;
    --ink-500: #637087;     /* body */
    --ink-400: #7e899b;     /* muted / captions */
    --ink-300: #a0a9b8;     /* faint / meta */

    /* --- surfaces & lines ------------------------------------- */
    --canvas:    #f7f8fb;   /* page ground */
    --surface-1: #ffffff;   /* cards, panels */
    --surface-2: #fafbfc;   /* table heads, subtle fills */
    --surface-3: #f1f3f7;   /* filter bands, callouts */
    --line:      #e5e8ef;   /* default border */
    --line-strong: #ccd3df; /* form controls */
    --line-soft: #f0f2f6;   /* dividers inside a card */

    /* --- semantic --------------------------------------------- */
    --success:    #1a7a3f;
    --success-bg: #e6f7ec;
    --danger:     #c43d45;
    --danger-fg:  #8c2626;
    --danger-bg:  #fdeaea;
    --danger-line:#e5a3a3;
    --warning:    #b45309;
    --warning-bg: #fff8e6;
    --warning-line:#e6d08a;

    /* Data colours: what a figure MEANS. Only ever on the datum
       itself (a number, a bar, a slice) -- never on chrome. */
    --data-won:      #2f9e63;
    --data-progress: #33bcd0;
    --data-lost:     #e0393f;

    /* Ordered pipeline ramp: one hue, deepening as a deal approaches close. */
    --pipeline-stage-1: #a7a4f2;
    --pipeline-stage-2: #8580e6;
    --pipeline-stage-3: #6762d7;
    --pipeline-stage-4: #4d49b4;

    /* Text/icons sitting ON a saturated fill. Stays white in both
       themes, because the fills it sits on stay dark in both. */
    --on-accent: #ffffff;

    /* Tinted outlines for won / lost / at-risk chips and stage steps.
       Alpha rather than a flat tint so they hold on any surface. */
    --success-line: #1a7a3f44;
    --danger-line-soft: #8c262644;
    --warning-line-soft: #d03b3b44;

    /* The one non-blue accent in the app (individual-contact badge,
       field-change timeline markers). Named so it stays the only one. */
    --accent-purple: #7655a7;
    --accent-purple-strong: #5b3f8c;
    --accent-purple-bg: #f6f1fb;

    /* Module colours identify where you are. Each is paired with one
       very pale wash; saturated colour is reserved for icons and rails. */
    --module-company: #0f9888;
    --module-company-soft: #e8f8f4;
    --module-person: #7959d6;
    --module-person-soft: #f1edff;
    --module-lead: #df6b45;
    --module-lead-soft: #fff0e9;
    --module-work: #c68b18;
    --module-work-soft: #fff7df;
    --module-activity: #198e5a;
    --module-activity-soft: #eaf8f0;
    --module-opportunity: #1689b3;
    --module-opportunity-soft: #e9f7fc;
    --module-case: #cd5573;
    --module-case-soft: #fff0f4;
    --module-campaign: #dc7a28;
    --module-campaign-soft: #fff3e8;
    --module-report: #426fbd;
    --module-report-soft: #edf3fc;

    /* Form accents make editable CRM data easy to pick out without
       colouring the whole application chrome. */
    --field-accent: #5752c7;
    --field-accent-soft: #efefff;
    --field-accent-hover: #dedcff;
    --field-label: #514f7c;
    --section-accent: var(--module-company);
    --section-accent-soft: var(--module-company-soft);

    /* Navigation rail: a cool indigo shell with brighter, purpose-built
       icon colours. These are intentionally separate from the module colours
       used on white content surfaces, where the same values would be loud. */
    --nav-top: #191a37;
    --nav-mid: #302e69;
    --nav-bottom: #504b9c;
    --nav-icon-home: #b8c4ff;
    --nav-icon-company: #55e0cb;
    --nav-icon-person: #d3b1ff;
    --nav-icon-lead: #ff9b72;
    --nav-icon-work: #ffd166;
    --nav-icon-calendar: #6ed6ff;
    --nav-icon-activity: #69e6a6;
    --nav-icon-opportunity: #55ddef;
    --nav-icon-case: #ff86a8;
    --nav-icon-campaign: #ffae61;
    --nav-icon-library: #f2ba5c;
    --nav-icon-report: #83b6ff;
    --nav-icon-inbox: #c9a8ff;
    --nav-icon-import: #5ce0a1;
    --nav-icon-setup: #d1c9dc;

    /* --- type scale (16px root: 11 12 13 14 15 16 18 22 28) ---- */
    --text-2xs: .6875rem;
    --text-xs:  .75rem;
    --text-sm:  .8125rem;
    --text-md:  .875rem;    /* body default */
    --text-lg:  .9375rem;
    --text-xl:  1rem;
    --text-2xl: 1.125rem;
    --text-3xl: 1.375rem;
    --text-4xl: 1.75rem;

    /* The one monospace stack. Two rules (.merge-field code and
       .policy-grid textarea) already asked for --font-mono with a bare
       'monospace' fallback and never got it, because nothing defined
       the token -- so they silently rendered in whatever the browser
       picked. Everything that shows a key, a code or a CIDR block reads
       from here. */
    --font-mono: ui-monospace, "Cascadia Mono", "SF Mono", Menlo, Consolas, monospace;

    /* --- space scale (4px base) -------------------------------- */
    --space-0: .125rem;
    --space-1: .25rem;
    --space-2: .5rem;
    --space-3: .75rem;
    --space-4: 1rem;
    --space-5: 1.5rem;
    --space-6: 2rem;

    /* --- radius ------------------------------------------------ */
    --radius-sm: 6px;
    --radius-md: 9px;
    --radius-lg: 14px;
    --radius-pill: 999px;

    --font-sans: Inter, "Segoe UI Variable", "Segoe UI", system-ui, -apple-system, sans-serif;

    /* --- elevation --------------------------------------------
       Layered, not single. A tight "contact" shadow says the edge is
       touching the surface; a wider, softer one says it is above it.
       One blurry shadow gives neither and just looks smudged.
       --highlight-top is the other half: a 1px inset light line on the
       top edge, which is what actually reads as a raised object rather
       than a rectangle with a shadow under it. */
    --shadow-sm:
        0 1px 1px rgba(20, 35, 80, .04),
        0 1px 2px rgba(20, 35, 80, .06);
    --shadow-md:
        0 1px 2px rgba(20, 35, 80, .06),
        0 2px 6px rgba(20, 35, 80, .06),
        0 8px 16px -6px rgba(20, 35, 80, .08);
    --shadow-lg:
        0 1px 3px rgba(20, 35, 80, .08),
        0 8px 20px -4px rgba(20, 35, 80, .10),
        0 24px 44px -12px rgba(20, 35, 80, .14);
    /* Hover/active lift, paired with a 1px translate. */
    --shadow-raise:
        0 1px 2px rgba(20, 35, 80, .07),
        0 6px 12px -2px rgba(20, 35, 80, .10),
        0 16px 28px -10px rgba(20, 35, 80, .12);
    --highlight-top: inset 0 1px 0 rgba(255, 255, 255, .75);
    --shadow-press: inset 0 2px 4px rgba(20, 35, 80, .16);

    /* --- legacy aliases (see header) --------------------------- */
    --bg: var(--canvas);
    --surface: var(--surface-1);
    --border: var(--line);
    --text: var(--ink-800);
    --muted: var(--ink-400);
    --accent: var(--brand-600);
    --crm-primary: var(--brand-600);
    --error-bg: var(--danger-bg);
    --error-border: var(--danger-line);
    --error-text: var(--danger-fg);
    --warn-bg: var(--warning-bg);
    --warn-border: var(--warning-line);
    --warn-text: #6b5410;
}

.skip-to-content { position: fixed; left: .75rem; top: .5rem; z-index: 3000; transform: translateY(-180%); padding: .65rem 1rem; border-radius: .35rem; background: var(--brand-600); color: #fff !important; font-weight: 600; transition: transform .15s ease; }
.skip-to-content:focus { transform: translateY(0); }

/* Persisted appearance mode. The indigo-violet brand remains recognisable
   while neutral charcoal surfaces keep the dark workspace calm. */
html.theme-dark {
  color-scheme: dark;

  /* Redefine the RAMPS, not each component. Anything styled through
     a token is dark-mode correct for free; the per-component
     html.theme-dark rules further down are legacy and can go as
     their components move onto tokens. */
  /* The brand ramp is NOT inverted. These steps are fills as often as
     they are text, and --on-accent (white) sits on them -- lightening
     them would put white text on pale blue. Only the two tint steps,
     which are backgrounds, move. Link text in dark is handled by the
     html.theme-dark a rule further down. */
  --brand-700: #514db9;
  --brand-600: #5d5bd4;
  --brand-500: #706de1;
  --brand-400: #9895ef;
  --brand-100: #302f59;
  --brand-50:  #26263f;

  --ink-900: #f2f6ff;
  --ink-800: #e7eefb;
  --ink-700: #dbe4f4;
  --ink-600: #c4d1e6;
  --ink-500: #b3c0d6;
  --ink-400: #a8b6cc;
  --ink-300: #8f9cb3;

  --canvas:    #11131e;
  --surface-1: #1a1d2b;
  --surface-2: #222638;
  --surface-3: #292d43;
  --field-accent: #9895ef;
  --field-accent-soft: #302f55;
  --field-accent-hover: #3c396b;
  --field-label: #b7b4ef;
  --section-accent: #54d6c4;
  --section-accent-soft: #173d45;
  --line:      #383e58;
  --line-strong: #4a5270;
  --line-soft: #30354b;

  --success:    #57c98d;
  --success-bg: #15271e;
  --danger:     #f08a8f;
  --danger-fg:  #f3a3a7;
  --danger-bg:  #331d1e;
  --danger-line:#6d3538;
  --warning:    #e0a85c;
  --warning-bg: #2c2416;
  --warning-line:#5c4a24;

  /* Data colours lift slightly so they hold on a dark ground. */
  --data-won:      #4dc07f;
  --data-progress: #4fd3e6;
  --data-lost:     #f0605f;

  /* Depth on a dark ground comes mostly from the highlight, not the
     shadow -- a black shadow on near-black reads as nothing. */
  --shadow-sm:
      0 1px 1px rgba(0, 0, 0, .3),
      0 1px 3px rgba(0, 0, 0, .35);
  --shadow-md:
      0 1px 2px rgba(0, 0, 0, .35),
      0 3px 8px rgba(0, 0, 0, .38),
      0 10px 20px -8px rgba(0, 0, 0, .45);
  --shadow-lg:
      0 2px 4px rgba(0, 0, 0, .4),
      0 10px 24px -4px rgba(0, 0, 0, .45),
      0 28px 48px -14px rgba(0, 0, 0, .55);
  --shadow-raise:
      0 2px 4px rgba(0, 0, 0, .4),
      0 8px 16px -2px rgba(0, 0, 0, .45),
      0 20px 32px -12px rgba(0, 0, 0, .5);
  --highlight-top: inset 0 1px 0 rgba(255, 255, 255, .07);
  --shadow-press: inset 0 2px 5px rgba(0, 0, 0, .5);

  --warn-text: #e2c98c;

  /* Legacy names still referenced by ~40 rules below. */
  --crm-bg: var(--canvas);
  --crm-surface: var(--surface-1);
  --crm-surface-raised: var(--surface-2);
  --crm-text: var(--ink-800);
  --crm-muted: var(--ink-400);
  --crm-line: var(--line);

  /* --- MudBlazor -------------------------------------------------
     MudBlazor has its OWN dark mode, switched by IsDarkMode on
     MudThemeProvider -- a component parameter. MainLayout renders
     statically (see App.razor), so nothing can set that flag without a
     circuit, and the result was half a dark mode: our CSS went dark
     while the app bar stayed white and the navigation drawer went LIGHTER.

     MudBlazor styles everything from these custom properties, so
     redefining them here puts its components under the same class
     toggle as the rest of the app. One switch, one dark mode. */
  --mud-palette-black: #05070d;
  --mud-palette-white: var(--ink-900);
  --mud-palette-background: var(--canvas);
  --mud-palette-background-gray: var(--surface-2);
  --mud-palette-surface: var(--surface-1);
  --mud-palette-drawer-background: #191a37;
  --mud-palette-drawer-text: var(--ink-700);
  --mud-palette-drawer-icon: var(--ink-500);
  --mud-palette-appbar-background: var(--surface-1);
  --mud-palette-appbar-text: var(--ink-800);
  --mud-palette-text-primary: var(--ink-800);
  --mud-palette-text-secondary: var(--ink-400);
  --mud-palette-text-disabled: var(--ink-300);
  --mud-palette-action-default: var(--ink-400);
  --mud-palette-action-default-hover: rgba(255, 255, 255, .06);
  --mud-palette-action-disabled: var(--ink-300);
  --mud-palette-action-disabled-background: var(--surface-3);
  --mud-palette-divider: var(--line);
  --mud-palette-divider-light: var(--line-soft);
  --mud-palette-lines-default: var(--line);
  --mud-palette-lines-inputs: var(--line-strong);
  --mud-palette-table-lines: var(--line);
  --mud-palette-table-striped: var(--surface-2);
  --mud-palette-table-hover: var(--surface-3);
  --mud-palette-primary: var(--brand-600);
  --mud-palette-primary-text: var(--on-accent);
  --mud-palette-primary-hover: rgba(93, 91, 212, .14);
  --mud-palette-secondary: #3ecbb0;
  --mud-palette-tertiary: #a78bfa;
  --mud-palette-success: var(--success);
  --mud-palette-error: var(--danger);
  --mud-palette-warning: var(--warning);
  --mud-palette-info: var(--brand-400);
}
html.theme-dark body { background: var(--crm-bg); color: var(--crm-text); }
html.theme-dark .mud-layout,
html.theme-dark .main-content,
html.theme-dark .mud-main-content { background: var(--crm-bg); color: var(--crm-text); }

/* Keep keyboard focus visible across native controls and MudBlazor links.
   Several compact toolbar buttons intentionally remove their default
   browser outline; this restores one consistent, high-contrast indicator. */
:where(a, button, input, select, textarea):focus-visible {
    outline:2px solid var(--crm-primary, #5752c7);
    outline-offset: 2px;
}
html.theme-dark .mud-paper,
html.theme-dark .mud-card,
html.theme-dark .mud-dialog,
html.theme-dark .mud-table-container,
html.theme-dark .report-builder,
html.theme-dark .workqueue-card,
html.theme-dark .dashboard-panel { background: var(--crm-surface); color: var(--crm-text); }
.sr-only { position:absolute; width:1px; height:1px; padding:0; margin:-1px; overflow:hidden; clip:rect(0,0,0,0); white-space:nowrap; border:0; }
html.theme-dark input,
html.theme-dark textarea,
html.theme-dark select,
html.theme-dark .mud-input-slot { background: var(--crm-surface-raised); color: var(--crm-text); }
html.theme-dark input::placeholder,
html.theme-dark textarea::placeholder { color: var(--crm-muted); }
html.theme-dark .mud-table th,
html.theme-dark .mud-table td,
html.theme-dark .detail-section,
html.theme-dark .record-summary { border-color: var(--crm-line); }
html.theme-dark a { color:var(--brand-400); }
html.theme-dark .theme-toggle { color: var(--crm-text); }
.theme-toggle { border: 0; background: transparent; color: inherit; cursor: pointer; font-size: 1.2rem; line-height: 1; padding: .45rem .65rem; border-radius: .35rem; }
.theme-toggle:hover, .theme-toggle:focus-visible { background: rgba(255,255,255,.14); outline: 2px solid currentColor; outline-offset: 2px; }
html.theme-dark .mud-typography-color-text-secondary,
html.theme-dark .muted { color: var(--crm-muted) !important; }

/* A #anchor jump (SectionJumpNav.razor) should glide, not snap --
   respects the user's own OS/browser reduced-motion setting, which
   auto-disables smooth scrolling regardless of this rule. */
html { scroll-behavior: smooth; }

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
    font-size: 15px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
}

h1 { font-size: 1.5rem; margin: 0 0 1rem; }
code { font-family: Consolas, "Courier New", monospace; font-size: .9em; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }

/* --- login ------------------------------------------------------- */
.login-shell {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.login-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 2rem;
    width: 100%;
    max-width: 380px;
    box-shadow: var(--shadow-sm);
}

.login-card .workspace {
    margin: -.5rem 0 1.5rem;
    color: var(--muted);
}

/* --- single sign-on ------------------------------------------------ */
.sso-button {
    display: block;
    width: 100%;
    margin-top: var(--space-5);
    text-align: center;
}

/* A rule with the word "or" sitting on it, so the two ways in read as
   alternatives rather than as steps. */
.sso-divider {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    margin: var(--space-5) 0 0;
    color: var(--muted);
    font-size: var(--text-sm);
}

.sso-divider::before,
.sso-divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--line);
}

/* --- two-step verification --------------------------------------
   Both of these hold strings that get read off a screen and typed
   somewhere else, so they are set in a monospace face with generous
   letter-spacing: the whole job here is telling 5 from S and 8 from B
   at a glance. */
.setup-key {
    font-family: var(--font-mono);
    font-size: var(--text-2xl);
    letter-spacing: .08em;
    word-break: break-all;
    background: var(--surface-3);
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    padding: var(--space-3);
    margin: var(--space-3) 0;
    text-align: center;
}

.recovery-codes {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-2);
    list-style: none;
    padding: var(--space-3);
    margin: var(--space-4) 0;
    background: var(--surface-3);
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    font-family: var(--font-mono);
    font-size: var(--text-lg);
    letter-spacing: .04em;
    text-align: center;
}

/* One column on a narrow screen: a ten-character code wrapping
   mid-string is worse than a longer list. */
@media (max-width: 30rem) {
    .recovery-codes { grid-template-columns: 1fr; }
}

label {
    display: block;
    margin: 1rem 0 .25rem;
    font-weight: 600;
    font-size: .875rem;
}

input[type=text], input[type=email], input[type=password] {
    width: 100%;
    padding: var(--space-2) .625rem;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-md);
    font-size: var(--text-md);
    font-family: inherit;
    background: var(--surface-1);
    /* The inverse of a button: a field is a hole, not a lump. A faint
       inset shadow at the top edge is what makes it read as recessed
       next to a raised control. */
    box-shadow: inset 0 1px 2px rgba(20, 35, 80, .07);
}

input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
input:disabled { background:var(--surface-2); color: var(--muted); }

/* :not(.mud-button-root) matters. This is an element selector, so
   without it every MudButton rendered as type=submit is repainted as a
   filled primary button regardless of its Variant -- which is why the
   app bar's "Sign out" (declared Variant.Text, Color.Inherit) came out
   as a saturated blue block and was the loudest thing on every screen.
   Component-library markup is not ours to restyle by element. */
button[type=submit]:not(.mud-button-root), .button {
    display: inline-block;
    margin-top: var(--space-5);
    padding: var(--space-2) var(--space-4);
    background: var(--accent);
    color:var(--on-accent);
    border: 0;
    border-radius: var(--radius-md);
    font-size: var(--text-md);
    font-family: inherit;
    cursor: pointer;
    text-decoration: none;
    /* A control should feel pressable: sitting slightly proud at rest,
       lifting on hover, and sinking under the pointer. The inset
       highlight on the top edge is what sells it -- without it this is
       a coloured rectangle with a shadow. */
    box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255,255,255,.18);
    transition: box-shadow .14s ease, transform .14s ease, background .14s ease;
}

button[type=submit]:not(.mud-button-root):hover:not(:disabled), .button:hover:not(:disabled) {
    box-shadow: var(--shadow-raise), inset 0 1px 0 rgba(255,255,255,.18);
    transform: translateY(-1px);
}

button[type=submit]:not(.mud-button-root):active:not(:disabled), .button:active:not(:disabled) {
    box-shadow: var(--shadow-press);
    transform: translateY(1px);
}

button[type=submit]:not(.mud-button-root):disabled, .button:disabled {
    background: var(--ink-300); cursor: not-allowed; box-shadow: none;
}

@media (prefers-reduced-motion: reduce) {
    button[type=submit]:not(.mud-button-root), .button, .sid-kpi { transition: none; }
    button[type=submit]:not(.mud-button-root):hover, .button:hover,
    .sid-kpi:hover { transform: none; }
}

button.link {
    background: none;
    border: 0;
    color: var(--accent);
    cursor: pointer;
    font: inherit;
    padding: 0;
    text-decoration: underline;
}

.alert {
    padding: .625rem .75rem;
    border-radius: 4px;
    margin-bottom: 1rem;
    font-size: .9rem;
}

.alert.error { background: var(--error-bg); border: 1px solid var(--error-border); color: var(--error-text); }
.alert.warning { background: var(--warn-bg); border: 1px solid var(--warn-border); color: var(--warn-text); }
.alert.success { background:var(--success-bg); border:1px solid var(--success-line); color:var(--success); }
.alert.success a { color: inherit; font-weight: 600; }

.validation-message { color: var(--error-text); font-size: .8rem; display: block; margin-top: .25rem; }

/* --- app --------------------------------------------------------- */
.page { max-width: 900px; margin: 0 auto; padding: 0 1rem 3rem; }

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    padding: 1rem 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 2rem;
}

/* --- global search (top nav) -------------------------------------- */
.global-search { flex: 0 1 12rem; display: flex; }
.global-search input[type=search] {
    width: 100%;
    padding: .375rem .625rem;
    border: 1px solid var(--border);
    border-right: 0;
    border-radius: 4px 0 0 4px;
    font-size: .875rem;
    font-family: inherit;
}
.global-search button {
    padding: .375rem .625rem;
    border: 1px solid var(--border);
    border-radius: 0 4px 4px 0;
    background: var(--surface);
    color: var(--muted);
    cursor: pointer;
    font: inherit;
}
.global-search button:hover { color: var(--accent); border-color: var(--accent); }

/* --- MudBlazor app bar search --------------------------------------
   Plain HTML, styled to sit inside the app bar -- see MainLayout.razor's
   own comment on why this isn't a MudTextField. A light grey pill on a
   white bar (Salesforce Lightning's own search-bar treatment), not the
   translucent-on-colour style this had when the bar itself was solid
   blue -- kept in sync with CrmTheme's AppbarBackground being white now. */
.appbar-search {
    display: flex; align-items: center; gap: .375rem;
    background:var(--surface-2); border-radius: 999px;
    padding: .5rem 1rem; width: 22rem; max-width: 34vw;
}
.appbar-search-icon { color:var(--mud-palette-text-secondary, var(--ink-400)) !important; flex-shrink: 0; }
.appbar-search input[type=search] {
    background: none; border: 0; outline: 0; color:var(--mud-palette-text-primary, var(--ink-900));
    font: inherit; font-size: .875rem; width: 100%;
}
.appbar-search input[type=search]::placeholder { color:var(--mud-palette-text-secondary, var(--ink-400)); }
.appbar-search-kbd {
    font-family: "IBM Plex Mono", monospace; font-size: .6875rem;
    color:var(--mud-palette-text-secondary, var(--ink-400)); background:var(--surface-2);
    border-radius: 4px; padding: .0625rem .3125rem; flex-shrink: 0;
}

/* --- page content area, inside MudMainContent -----------------------
   padding-top deliberately omitted: MudMainContent already sets its own
   top offset (via --mud-appbar-height) to clear the fixed MudAppBar --
   a same-specificity rule here, loaded after MudBlazor's own
   stylesheet, silently wins the cascade and overrides it, which is
   exactly what put "Welcome, Graeme" invisibly behind the app bar the
   first time this was tried (found live in the browser, not by
   re-reading the CSS -- the accessibility tree had the heading, the
   screenshot didn't). */
.main-content {
    padding-left: 2rem;
    padding-right: 2rem;
    padding-bottom: 3rem;
    padding-top: calc(var(--mud-appbar-height, 64px) + 1.5rem);
    min-width: 0;
}
.mud-main-content { min-width: 0; }
.main-content .page { max-width: none; margin: 0; padding: 0; }
.clickable-row { cursor: pointer; }
.clickable-row:focus-visible { outline:2px solid var(--crm-primary,#5752c7); outline-offset: -2px; }
.calendar-more { border:0; background:transparent; cursor:pointer; padding:.15rem .25rem; text-align:left; }
.calendar-more:hover, .calendar-more:focus-visible { color:var(--crm-primary,var(--brand-500)); text-decoration:underline; }
.route-error { display:flex; flex-direction:column; align-items:center; justify-content:center; min-height:50vh; gap:.75rem; text-align:center; padding:2rem; }
.route-error p { color:var(--muted,var(--ink-500)); margin:0; }
.activity-subject-link { color: inherit; text-decoration: none; }
.activity-subject-link:hover, .activity-subject-link:focus-visible { color:var(--crm-primary, var(--brand-500)); text-decoration: underline; }

/* Softer shadows and a readable active link on the deep indigo drawer
   rail. MudBlazor stays the component substrate (see CrmTheme.cs's own
   comment); these are the finishing touches a theme/radius change alone
   doesn't reach.

   The pill override (.mud-button-filled { border-radius: 999px }) is
   gone on purpose: fully round buttons next to 4-10px panels and inputs
   read as two different products, and MudBlazor now takes --radius-md
   from the theme like everything else. */
.mud-elevation-1 { box-shadow: var(--shadow-sm) !important; }

.mud-drawer .mud-nav-link.active,
.mud-drawer a.active {
    background: linear-gradient(90deg, rgba(112,132,220,.32), rgba(112,132,220,.12)) !important;
    color:var(--on-accent) !important;
}
.mud-drawer .mud-nav-link.active .mud-icon-root,
.mud-drawer a.active .mud-icon-root {
    color:var(--on-accent) !important;
}

/* Cool indigo workspace rail, inspired by the supplied reference while
   leaving the working canvas intentionally light. The gradient belongs
   only to navigation; forms, record cards, tables and text inputs keep
   --surface (#fff) so data entry remains crisp and high contrast. */
.mud-drawer {
    background:
        radial-gradient(circle at 0 0, rgba(154, 151, 255, .16), transparent 25rem),
        linear-gradient(180deg, var(--nav-top) 0%, var(--nav-mid) 48%, var(--nav-bottom) 100%) !important;
}
.mud-drawer .mud-nav-link,
.mud-drawer .mud-navgroup .mud-nav-link,
.mud-drawer .mud-nav-link .mud-icon-root,
.mud-drawer .mud-navgroup .mud-icon-root {
    color: rgba(247,249,255,.92) !important;
}
.mud-drawer .mud-nav-link:hover,
.mud-drawer .mud-navgroup .mud-nav-link:hover {
    background: rgba(255,255,255,.09) !important;
    color:var(--on-accent) !important;
}
.mud-drawer .mud-navgroup .mud-nav-link-text,
.mud-drawer .mud-nav-link-text { font-weight: 500; }

/* Small module colour cues make scanning the purple rail easier without
   changing the calm data-entry surfaces in the rest of the CRM. */
.mud-drawer .nav-home .mud-icon-root { color: #b8ccff !important; }
.mud-drawer .nav-company .mud-icon-root { color: #65d7ca !important; }
.mud-drawer .nav-person .mud-icon-root { color: #c8b6ff !important; }
.mud-drawer .nav-lead .mud-icon-root { color: #ffb38a !important; }
.mud-drawer .nav-work .mud-icon-root { color: #ffd166 !important; }
.mud-drawer .nav-calendar .mud-icon-root { color: #8fd3ff !important; }
.mud-drawer .nav-activity .mud-icon-root { color: #7ee0a7 !important; }
.mud-drawer .nav-opportunity .mud-icon-root { color: #56d4e6 !important; }
.mud-drawer .nav-case .mud-icon-root { color: #f5a3b5 !important; }
.mud-drawer .nav-campaign .mud-icon-root { color: #ffbd7a !important; }
.mud-drawer .nav-library .mud-icon-root { color: #d7c6a2 !important; }
.mud-drawer .nav-report .mud-icon-root { color: #84d1f3 !important; }
.mud-drawer .nav-inbox .mud-icon-root { color: #c7b9ff !important; }
.mud-drawer .nav-import .mud-icon-root { color: #8fdea3 !important; }
.mud-drawer .nav-setup .mud-icon-root { color: #b7c5da !important; }

/* --- sidebar collapse-to-icons (NavMenu.razor) -----------------------
   The drawer's own width is a MudBlazor default (240px, --mud-drawer-
   width-left) set nowhere in our own code -- rather than fighting it
   with a Blazor Width parameter that MainLayout would have to own and
   somehow learn NavMenu's collapse state to set, :has() lets the
   width live purely in CSS, reacting to a class NavMenu only ever
   toggles on itself. */
.nav-collapse-toggle {
    display: flex; align-items: center; justify-content: center;
    width: 1.75rem; height: 1.75rem; margin: .5rem 0 .25rem auto;
    background: none; border: 1px solid rgba(255,255,255,.18); border-radius: 6px;
    color: rgba(255,255,255,.7); cursor: pointer;
}
.nav-collapse-toggle:hover { background: rgba(255,255,255,.1); color:var(--on-accent); }
.nav-collapsed .nav-collapse-toggle { margin-right: 0; }

.mud-layout:has(.nav-collapsed) { --mud-drawer-width-left: 3.5rem !important; }
.mud-drawer:has(.nav-collapsed) { width: 3.5rem !important; min-width: 3.5rem !important; }
.mud-drawer-container:has(.nav-collapsed) .mud-drawer { width: 3.5rem !important; min-width: 3.5rem !important; }
/* MudMainContent normally gets its left offset from MudBlazor's drawer
   width variable. Keep an explicit sibling rule as well: older MudBlazor
   builds calculate the offset inline before the nested NavMenu class is
   rendered, which leaves a 240px blank gutter beside the icon rail. */
.mud-drawer:has(.nav-collapsed) ~ .mud-main-content {
    margin-left: 3.5rem !important;
    width: calc(100% - 3.5rem) !important;
}
/* MudBlazor has used both a direct drawer sibling and a drawer container
   wrapper across releases. Apply the same offset at the layout level so a
   collapsed rail never leaves the former full-width gutter behind. */
.mud-layout:has(.nav-collapsed) .mud-main-content {
    margin-left: 3.5rem !important;
    width: calc(100% - 3.5rem) !important;
}
.mud-drawer-container:has(.nav-collapsed) ~ .mud-main-content {
    margin-left: 3.5rem !important;
    width: calc(100% - 3.5rem) !important;
}
.nav-collapsed .mud-nav-link-text,
.nav-collapsed .mud-navgroup-text { display: none; }
.nav-collapsed .mud-nav-link { justify-content: center; padding-left: 0; padding-right: 0; }
.nav-collapsed .mud-nav-link-icon { margin-right: 0 !important; }
/* Icon rail only, same reasoning Zoho's own collapsed sidebar follows
   -- a nested Admin submenu has nowhere legible to render at 56px
   wide without a flyout, which is a bigger feature than the collapse
   toggle itself. */
.nav-collapsed .mud-navgroup .mud-collapse-container { display: none !important; }

/* A white app bar needs a hairline to separate it from the page --
   the colour bar it replaced didn't, its own solid fill did that job. */
.mud-appbar { border-bottom:1px solid var(--line); }

/* Keep the working canvas usable beside the compact rail on laptops and
   split-screen browser windows. The wide desktop gutters are helpful at
   full width, but become wasted horizontal space once the viewport is
   narrow; the page itself already provides card-level spacing. */
@media (max-width: 1100px) {
    .main-content {
        padding-left: 1rem;
        padding-right: 1rem;
    }
}
@media (max-width: 700px) {
    .main-content {
        padding-left: .625rem;
        padding-right: .625rem;
    }
}

/* Respect the operating system's accessibility preference. The CRM has
   drag/drop cards, drawer transitions and button hover effects, but none
   of those should override a user's reduced-motion setting. */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        scroll-behavior: auto !important;
        transition-duration: .01ms !important;
    }
}

/* --- command palette (CommandPalette.razor) -------------------------
   Plain markup, not a MudBlazor popover component -- see that
   component's own top comment for why. Fixed positioning so it sits
   above the app shell (drawer, app bar) regardless of which page
   mounted it. */
.cmdk-overlay {
    position: fixed; inset: 0; background: rgba(15,15,25,.45);
    z-index: 2000; display: flex; align-items: flex-start; justify-content: center;
    padding-top: 12vh;
}
.cmdk {
    width: 34rem; max-width: 92vw; background:var(--mud-palette-surface, var(--surface-1));
    border-radius: 14px; box-shadow: var(--shadow-lg); overflow: hidden;
}
.cmdk-input {
    display: flex; align-items: center; gap: .625rem; padding: .875rem 1.125rem;
    border-bottom:1px solid var(--mud-palette-lines-default, #e6e6ec);
}
.cmdk-input input {
    border: 0; outline: 0; font: inherit; font-size: 1rem; flex: 1; background: none;
    color:var(--mud-palette-text-primary, var(--ink-900));
}
.cmdk-input kbd {
    font-family: "IBM Plex Mono", monospace; font-size: .75rem;
    color: var(--mud-palette-text-secondary); background:var(--mud-palette-background, var(--surface-2));
    border-radius: 4px; padding: .0625rem .375rem;
}
.cmdk-list { padding: .5rem; max-height: 22rem; overflow-y: auto; }
.cmdk-section {
    font-size: .6875rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
    color: var(--mud-palette-text-secondary); padding: .625rem .625rem .375rem;
}
.cmdk-item {
    display: flex; align-items: center; gap: .625rem; padding: .625rem .75rem; border-radius: 8px;
    font-size: .875rem; cursor: pointer;
}
.cmdk-item.sel, .cmdk-item:hover { background: var(--mud-palette-action-default-hover); }
.cmdk-ic {
    width: 1.75rem; height: 1.75rem; border-radius: 7px; flex-shrink: 0;
    background:var(--mud-palette-background, var(--brand-50)); color: var(--mud-palette-primary);
    display: flex; align-items: center; justify-content: center; font-size: .8125rem; font-weight: 700;
}
.cmdk-meta { margin-left: auto; color: var(--mud-palette-text-secondary); font-size: .75rem; }
.cmdk-empty { padding: .875rem .75rem; color: var(--mud-palette-text-secondary); font-size: .875rem; }

/* --- Opportunities: Table/Board view toggle + kanban board ---------- */
.view-toggle {
    display: flex; border-radius: 999px; overflow: hidden;
    border:1px solid var(--mud-palette-lines-default, #e0e0e6);
}
.view-toggle button {
    font: inherit; font-size: .8125rem; font-weight: 600; padding: .375rem .875rem; border: 0; cursor: pointer;
    display: flex; align-items: center; gap: .3125rem;
    background:var(--mud-palette-surface, var(--surface-1)); color: var(--mud-palette-text-secondary);
}
.view-toggle button.active { background: var(--mud-palette-primary); color:var(--on-accent); }

.board-columns { display: flex; gap: 1rem; overflow-x: auto; padding-bottom: .75rem; align-items: flex-start; }
.board-column { width: 16rem; flex-shrink: 0; border-radius: 10px; transition: background-color .1s; }
.board-column-dragover { background: var(--mud-palette-primary-hover, rgba(31,95,169,.06)); outline: 2px dashed var(--mud-palette-primary); outline-offset: -2px; }
.board-col-head {
    display: flex; flex-direction: column; gap: .1875rem;
    padding: .5rem .75rem; border-radius: 8px; margin-bottom: .625rem; color:var(--on-accent);
}
.board-col-head .line1 { display: flex; align-items: baseline; justify-content: space-between; gap: .5rem; }
.board-col-head .name { font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; }
.board-col-head .meta { font-size: .6875rem; font-weight: 600; opacity: .85; white-space: nowrap; }
.board-col-head .amt { font-size: .8125rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.board-col-empty, .board-col-more {
    font-size: .8125rem; color: var(--mud-palette-text-secondary); padding: .375rem .5rem;
}
.board-card {
    background:var(--mud-palette-surface, var(--surface-1)); border-radius: 10px; border-top: 3px solid;
    box-shadow: var(--shadow-sm), var(--highlight-top);
    padding: .75rem .875rem; margin-bottom: .625rem; cursor: pointer;
    transition: box-shadow .15s, transform .15s;
}
.board-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.board-card-dragging { opacity: .4; }
.board-card .title { font-size: .875rem; font-weight: 600; margin-bottom: .25rem; }
.board-card .company { font-size: .75rem; color: var(--mud-palette-text-secondary); margin-bottom: .5rem; }
.board-card .company:has(+ .contact) { margin-bottom: .125rem; }
.board-card .contact { font-size: .75rem; color: var(--mud-palette-primary); margin-bottom: .5rem; }
.board-card .foot { display: flex; align-items: flex-end; justify-content: space-between; gap: .5rem; }
.board-card .money { display: flex; flex-direction: column; gap: .125rem; min-width: 0; }
.board-card .amt { font-size: .8125rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.board-card .closedate { font-size: .6875rem; color: var(--mud-palette-text-secondary); white-space: nowrap; }
.board-card .closedate-overdue { color: var(--mud-palette-error); font-weight: 600; }
.board-card .owner {
    width: 1.375rem; height: 1.375rem; border-radius: 50%; background:var(--mud-palette-background, var(--surface-3));
    color: var(--mud-palette-primary); font-size: .625rem; font-weight: 700;
    display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.pipeline-tile { border-top: 3px solid var(--mud-palette-primary); }
.pipeline-tile.stage-qualify { border-top-color: #4c8bf5; background: #f5f8ff; }
.pipeline-tile.stage-analysis { border-top-color: #8a68d8; background: #f9f7ff; }
.pipeline-tile.stage-proposal { border-top-color: #d98a35; background: #fff9f1; }
.pipeline-tile.stage-review { border-top-color: #1a9f91; background: #f2fbfa; }
.pipeline-tile.stage-open { border-top-color: #4c8bf5; background: #f5f8ff; }
.pipeline-tile.stage-won { border-top-color: #168a58; background: #f2fcf7; }
.pipeline-tile.stage-lost { border-top-color: #d85d6d; background: #fff6f7; }
.pipeline-tile-active { border-color: var(--mud-palette-primary) !important; box-shadow: inset 0 0 0 1px var(--mud-palette-primary); }

.record-cell { display: flex; align-items: center; gap: .625rem; min-width: 0; }
.record-cell > div:last-child { min-width: 0; }
.record-heading { display: flex; align-items: center; gap: 1rem; min-width: 0; }
.record-avatar {
    width: 2rem; height: 2rem; flex: 0 0 2rem; display: grid; place-items: center;
    border-radius: .625rem; font-size: .6875rem; font-weight: 750; letter-spacing: .025em;
}
.record-avatar-company { color: #08786e; background: #dff7f3; }
.record-avatar-person { color: #6842b7; background: #eee8ff; }
.record-avatar-large { width: 3.5rem; height: 3.5rem; flex-basis: 3.5rem; border-radius: .75rem; font-size: .95rem; }
.record-avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: inherit; display: block; }
.record-avatar-company img { object-fit: contain; padding: .22rem; background: #fff; }
.record-avatar-person.record-avatar-large { border-radius: 50%; }
.avatar-menu { position: relative; z-index: 4; flex: 0 0 auto; }
.avatar-menu-details { position: relative; }
.avatar-menu-trigger { display: block; cursor: pointer; list-style: none; border-radius: .8rem; outline-offset: 3px; }
.avatar-menu-trigger::-webkit-details-marker { display: none; }
.avatar-menu-trigger .record-avatar { box-shadow: 0 0 0 3px #fff, 0 1px 5px rgba(18, 40, 78, .18); transition: transform .15s ease, box-shadow .15s ease; }
.avatar-menu-trigger:hover .record-avatar, .avatar-menu-details[open] .record-avatar { transform: translateY(-1px); box-shadow: 0 0 0 3px #fff, 0 4px 12px rgba(18, 40, 78, .22); }
.avatar-menu-popover { position: absolute; top: calc(100% + .5rem); left: 0; width: 9.75rem; overflow: hidden; border: 1px solid #d7deea; border-radius: .55rem; background: #fff; box-shadow: 0 9px 20px rgba(20, 36, 66, .2); }
.avatar-menu-popover > a, .avatar-menu-action { display: flex; align-items: center; width: 100%; min-height: 2.5rem; padding: .55rem .75rem; border: 0; border-bottom: 1px solid #e5eaf2; background: #fff; color: #34425a; font: inherit; font-size: .8rem; font-weight: 500; text-align: left; text-decoration: none; cursor: pointer; }
.avatar-menu-popover > a:hover, .avatar-menu-action:hover { background: #f5f7fb; color: #1d3152; }
.avatar-menu-remove { color: #b4232c; }
.avatar-menu-remove:hover { background: #fff3f3; color: #941d27; }
.avatar-upload-error { display: block; padding: .5rem .75rem; color: #b4232c; background: #fff5f5; font-size: .7rem; line-height: 1.3; }
.crm-empty-state { min-height: 15rem; display: grid; place-content: center; justify-items: center; gap: .5rem; text-align: center; }
.crm-empty-state .mud-icon-root { color: var(--section-accent); font-size: 2.25rem; padding: .75rem; border-radius: 50%; background: #e8f8f6; }
.hotlist-row-overdue { border-left: 3px solid var(--mud-palette-error); }
.hotlist-row:hover { background: var(--mud-palette-action-default-hover); }
.search-result-link {
    display: flex; align-items: baseline; gap: .5rem; flex-wrap: wrap;
    width: 100%; text-decoration: none; color: inherit;
}

.topbar .muted { margin-left: .5rem; font-size: .875rem; }

.facts {
    display: grid;
    grid-template-columns: 10rem 1fr;
    gap: .5rem 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 1.25rem;
    margin: 1.5rem 0;
}

.facts dt { font-weight: 600; color: var(--muted); }
.facts dd { margin: 0; }

@media (max-width: 520px) {
    .facts { grid-template-columns: 1fr; gap: 0 0; }
    .facts dd { margin-bottom: .75rem; }
}

#blazor-error-ui {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background:var(--danger-bg);
    border-top: 1px solid var(--error-border);
    padding: .75rem 1rem;
    z-index: 1000;
}

/* --- navigation --------------------------------------------------- */
.brand { display: flex; align-items: baseline; gap: 1.5rem; }
.brand nav { display: flex; gap: 1rem; }
.brand nav a { color: var(--accent); text-decoration: none; font-size: .9375rem; }
.brand nav a:hover { text-decoration: underline; }
.topbar .user { display: flex; align-items: center; gap: 1rem; }

/* --- home cards --------------------------------------------------- */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; margin: 1.5rem 0; }
.card {
    display: block;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 1.25rem;
    text-decoration: none;
    color: inherit;
}
.card:hover { border-color: var(--accent); }
.card h2 { margin: 0 0 .25rem; font-size: 1.0625rem; color: var(--accent); }
.card p { margin: 0; }

/* --- list views --------------------------------------------------- */
.list-header { display: flex; align-items: baseline; gap: .75rem; }
.list-header h1 { margin-bottom: .5rem; }

.searchbar { display: flex; align-items: center; gap: .75rem; margin: 0 0 1rem; }
.searchbar input[type=search] {
    flex: 1;
    max-width: 460px;
    padding: .5rem .75rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: .9375rem;
    font-family: inherit;
}

/* --- saved views (Favourite Lists) --------------------------------- */
[hidden] { display: none !important; }
.saved-views { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; margin: 0 0 1rem; }
.saved-views select {
    padding: .375rem .625rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: .875rem;
    font-family: inherit;
    background: var(--surface);
}
.saved-views input[type=text] {
    padding: .375rem .625rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: .875rem;
    font-family: inherit;
    max-width: 220px;
}
.saved-views .button.small { margin-top: 0; }

/* Wide tables scroll inside their own container so the page never
   scrolls sideways on a narrow screen. */
.table-scroll { overflow-x: auto; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); }
.table-scroll .column-layout-table { min-width: max-content; }
.table-scroll .column-layout-table table { width: max-content; min-width: 100%; table-layout: fixed; }
.table-scroll .column-layout-table th,
.table-scroll .column-layout-table td { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Keeping both axes inside a viewport-height list makes the horizontal
   scrollbar available immediately, not after hundreds of result rows. */
.company-list-scroll { max-height: calc(100vh - 13rem); overflow: auto; }

/* Column setup is a compact layout editor, not a stack of forms. */
.modal.column-setup-modal { width: min(54rem, calc(100vw - 2rem)); max-width: 54rem; }
.column-setup-heading { display:flex; justify-content:space-between; align-items:flex-start; gap:1rem; margin-bottom:1rem; }
.column-setup-heading h2 { margin:0; }
.column-setup-heading p { margin:.25rem 0 0; }
.column-count { flex:0 0 auto; padding:.3rem .6rem; border-radius:999px; background:var(--surface-2); color:var(--muted); font-size:.8rem; }
.column-setup-labels, .column-setup-row { display:grid; grid-template-columns:minmax(0, 1fr) 8rem 5rem 2rem; gap:.75rem; align-items:center; }
.column-setup-labels { padding:0 .75rem .35rem; color:var(--muted); font-size:.72rem; font-weight:700; letter-spacing:.04em; text-transform:uppercase; }
.column-setup-list { max-height:min(46vh, 32rem); overflow:auto; border:1px solid var(--border); border-radius:8px; background:var(--surface); }
.column-setup-row { min-height:3.3rem; padding:.5rem .75rem; border-bottom:1px solid var(--border); }
.column-setup-row:last-child { border-bottom:0; }
.column-setup-row:hover { background:var(--surface-2); }
.column-setup-name { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; font-weight:500; }
.column-width-input { display:flex; align-items:center; gap:.35rem; color:var(--muted); font-size:.8rem; }
.column-width-input input { width:5.1rem; margin:0; padding:.35rem .45rem; }
.column-order-actions { display:flex; gap:.2rem; }
.icon-action { width:2rem; height:2rem; border:1px solid var(--border); border-radius:5px; background:var(--surface); color:var(--ink-800); cursor:pointer; }
.icon-action:hover:not(:disabled) { border-color:var(--primary); color:var(--primary); background:var(--surface-2); }
.icon-action:disabled { opacity:.38; cursor:default; }
.remove-column { color:var(--danger); }
.column-add-section { margin-top:1rem; }
.column-add-section > label { display:block; margin-bottom:.45rem; }
.column-add-list { max-height:8.8rem; overflow:auto; display:flex; flex-wrap:wrap; gap:.4rem; padding:.15rem; }
.column-add-button { border:1px solid var(--border); background:var(--surface-2); color:var(--primary); padding:.35rem .55rem; border-radius:5px; font:inherit; font-size:.82rem; cursor:pointer; }
.column-add-button:hover { border-color:var(--primary); background:var(--surface); }
.column-setup-actions { margin-top:1rem; }
@media (max-width: 640px) {
  .column-setup-labels { display:none; }
  .column-setup-row { grid-template-columns:minmax(0,1fr) 7rem 4.5rem 2rem; gap:.4rem; padding:.5rem; }
  .column-setup-heading { align-items:center; }
}

table.grid { border-collapse: collapse; width: 100%; font-size: .9375rem; }
table.grid th, table.grid td { padding: .5rem .75rem; text-align: left; white-space: nowrap; }
table.grid th {
    background:var(--surface-2);
    border-bottom: 1px solid var(--border);
    font-size: .8125rem;
    text-transform: uppercase;
    letter-spacing: .02em;
    color: var(--muted);
    position: sticky;
    top: 0;
}
table.grid tbody tr + tr td { border-top:1px solid var(--line-soft); }
table.grid tbody tr:hover { background:var(--surface-2); }
table.grid .num { text-align: right; }
table.grid tr.inactive-row { color: var(--muted); }
table.grid tr.inactive-row td:first-child { font-style: italic; }
.row-actions { display: flex; gap: .5rem; white-space: nowrap; }

.member-checklist {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr));
    gap: .375rem .75rem; margin: .5rem 0 1rem;
    max-height: 10rem; overflow-y: auto;
    border: 1px solid var(--border); border-radius: 4px; padding: .625rem .75rem;
}

.badge {
    display: inline-block;
    padding: .0625rem .375rem;
    border-radius: 3px;
    font-size: .75rem;
    font-weight: 600;
    background:var(--surface-2);
    color: var(--muted);
}
.badge.contact { background:var(--brand-100); color:var(--brand-600); }
.badge.individual { background:var(--accent-purple-bg); color:var(--accent-purple-strong); }
.badge.warn { background: var(--warn-bg); color: var(--warn-text); margin-left: .375rem; }
.badge.success { background:var(--success-bg); color:var(--success); }
.opted-out { text-decoration: line-through; color: var(--muted); }

.empty {
    background: var(--surface);
    border: 1px dashed var(--border);
    border-radius: 6px;
    padding: 2.5rem 1.5rem;
    text-align: center;
}
.empty p { margin: 0 0 .375rem; }

.pager { display: flex; align-items: center; gap: 1rem; margin-top: 1rem; }
.pager button {
    padding: .375rem .75rem;
    border: 1px solid var(--border);
    background: var(--surface);
    border-radius: 4px;
    cursor: pointer;
    font: inherit;
}
.pager button:disabled { color: var(--muted); cursor: not-allowed; }

/* --- list header actions ------------------------------------------ */
.list-header { display: flex; align-items: baseline; gap: .75rem; flex-wrap: wrap; }
.list-header .button.small { margin-left: auto; }
.button.small { padding: .375rem .75rem; font-size: .875rem; margin-top: 0; }
tr.row-link { cursor: pointer; }

/* --- detail pages --------------------------------------------------- */
.detail-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
    padding-bottom: .9rem;
    border-bottom:1px solid var(--line);
}
/* Keep record actions in view while a long edit form is being completed. */
.detail-header:has(~ .detail-grid) {
    position: sticky;
    top: 0;
    z-index: 20;
    padding: .75rem 0;
    margin-top: -.75rem;
    background: color-mix(in srgb, var(--surface-1) 94%, transparent);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid transparent;
}
.detail-header:has(~ .detail-grid) .detail-actions { flex-wrap: wrap; }
.back-link { display: inline-block; margin-bottom: .5rem; color: var(--accent); text-decoration: none; font-size: .875rem; }
.back-link:hover { text-decoration: underline; }
.detail-header h1 { margin: 0 0 .2rem; font-size: clamp(1.45rem, 2.2vw, 2rem); letter-spacing: -.015em; }
.detail-actions { display: flex; align-items: center; gap: .75rem; }
.record-tabs { display: flex; gap: .25rem; margin: 0 0 1rem; padding: .35rem; border:1px solid var(--line); border-radius: 999px; background:var(--surface-3); width: fit-content; }
.record-tabs button { background: none; border: 0; border-bottom: 2px solid transparent; margin-bottom: -1px; padding: .625rem .125rem; color: var(--muted); cursor: pointer; font: inherit; font-size: .875rem; }
.record-tabs button:hover { color: var(--text); }
.record-tabs button { border-radius: 999px; padding: .45rem 1rem; margin: 0; }
.record-tabs button.active { border-bottom-color: transparent; background:var(--surface-1); color: var(--accent); font-weight: 600; box-shadow: var(--shadow-sm); }
.alert.inline { padding: .25rem .625rem; margin: 0; font-size: .8125rem; }

/* Zoho's own record shape (researched off the real frames): a narrow
   "Related List" rail down the left, and ONE main column holding the
   record's fields and every related section at full width.

   This replaced a [form 2fr | panels 1fr] split, which was the real
   "doesn't flow right" problem Graeme reported -- Notes, Documents,
   Related Entries and Timeline were all crammed into a ~260px column,
   stacked five deep, so each got a sliver of the page and the record
   became an endless scroll. Same panels, same data; the layout is what
   was wrong.

   :has() rather than a modifier class so a NEW record -- which renders
   no rail, because there are no related sections until it's saved --
   falls back to a single full-width column automatically, with no
   per-page flag to remember to pass. */
.detail-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: .85rem; align-items: start; }
/* Related sections live in a horizontal row, matching Overview and
   Timeline, so record content always gets the full usable width. */
.detail-grid:has(.record-rail) { grid-template-columns:minmax(0, 1fr); }
@media (max-width: 860px) {
    .detail-grid, .detail-grid:has(.record-rail) { grid-template-columns: 1fr; }
}

.detail-form {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 1.25rem 1.5rem 1.5rem;
    align-content: start;
}
.detail-form h2 {
    font-size: .9375rem;
    text-transform: uppercase;
    letter-spacing: .02em;
    color: var(--muted);
    margin: 1.35rem -1.5rem .7rem;
    padding: .65rem 1.5rem;
    border-top: 1px solid var(--border);
    border-bottom:1px solid var(--line-soft);
    background:linear-gradient(90deg, var(--field-accent-soft), var(--surface-2) 72%);
    color:var(--ink-800);
    font-size: .8rem;
    letter-spacing: .08em;
    box-shadow:inset 4px 0 0 var(--section-accent);
}
.detail-form h2:first-child { margin-top: -.25rem; padding-top: .65rem; border-top: 0; }

.detail-form > label { display: block; margin: .95rem 0 .3rem; font-weight: 600; font-size: .8125rem; color: var(--muted); }
.detail-form input[type=text], .detail-form input:not([type]), .detail-form textarea, .detail-form select {
    width: 100%;
    padding: .5rem .625rem;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-md);
    font-size: .9375rem;
    font-family: inherit;
    background:var(--surface-1);
    box-shadow: 0 1px 2px color-mix(in srgb, var(--ink-900) 7%, transparent);
    transition: border-color .15s ease, box-shadow .15s ease, background-color .15s ease;
}
.detail-form input[type=text]:hover, .detail-form input:not([type]):hover, .detail-form textarea:hover, .detail-form select:hover {
    border-color: var(--field-accent);
    background: var(--field-accent-soft);
}
.detail-form input:focus, .detail-form textarea:focus, .detail-form select:focus {
    outline: none;
    border-color:var(--field-accent);
    background:var(--surface-1);
    box-shadow: 0 0 0 3px var(--field-accent-hover), 0 2px 5px color-mix(in srgb, var(--field-accent) 20%, transparent);
}
.detail-form textarea { resize: vertical; }

/* Existing edit pages use label/input pairs. On wide screens, lay those
   pairs out like Zoho: two balanced field groups per row. Explicit field
   rows and editors remain full-width components. */
@media (min-width: 980px) {
    .detail-form {
        display: grid;
        grid-template-columns: minmax(7rem, 10rem) minmax(0, 1fr) minmax(7rem, 10rem) minmax(0, 1fr);
        column-gap: 1.25rem;
        align-items: center;
    }
    .detail-form > h2,
    .detail-form > .field-row,
    /* A form is a block of its own label/input pairs, so it must span
       the card rather than being packed into one of the four columns.
       Without this it became a ~100px-wide grid item: the Account page's
       password fields and every button in them had been squeezed to a
       stub for as long as this grid has existed, which is how a
       six-digit code box ended up 41px wide. */
    .detail-form > form,
    .detail-form > textarea,
    .detail-form > .contact-method-editor,
    .detail-form > .address-editor,
    .detail-form > .udf-fields-editor { grid-column: 1 / -1; }
    .detail-form > label { margin: .45rem 0; text-align: right; }
    .detail-form > label + input,
    .detail-form > label + select { margin: .35rem 0; }
    .detail-form > label + input + label { margin-left: 0; }
}
/* A card that holds a single column of prose, forms and lists
   rather than label/input pairs. Without this it inherits the
   four-column field grid above, which packs a paragraph into one
   ~100px column and a list of recovery codes into the next -- the
   grid is right for an edit form and wrong for everything else. */
.detail-form.stacked { display: block; }

@media (max-width: 700px) {
    .detail-form { padding: 1.25rem; }
    .detail-form h2 { margin-left: -1.25rem; margin-right: -1.25rem; padding-left: 1.25rem; padding-right: 1.25rem; }
}
/* RecordFieldGrid uses the same outer card class for the read-only view,
   but its definition list owns its own two-column layout. Never apply the
   edit form's four-column label/input grid to that view. */
.detail-form.record-view { display: block; }
.detail-form.record-view dl { margin: 0; }

/* Record edit forms use balanced field groups rather than the legacy
   label/control grid.  The latter is useful for compact admin forms but
   squeezes long CRM controls (company pickers, names and addresses) into
   narrow columns.  Keep every grid track shrink-safe and let editors span
   the card when they contain multiple controls. */
.detail-form.record-edit-form {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    column-gap: 1.25rem;
    row-gap: .15rem;
    min-width: 0;
}
.record-edit-form > h2,
.record-edit-form > .field-row,
.record-edit-form > .form-field-full,
.record-edit-form > .contact-method-editor,
.record-edit-form > .address-editor,
.record-edit-form > .udf-fields-editor { grid-column: 1 / -1; }
.record-edit-form > h2 { min-width: 0; }
.record-edit-form .field-row,
.record-edit-form .form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    min-width: 0;
    gap: 1rem 1.25rem;
    margin: .25rem 0 1rem;
}
.record-edit-form .field-row.three,
.record-edit-form .form-grid.three {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}
.record-edit-form .field-row > div,
.record-edit-form .form-field {
    min-width: 0;
    display: grid;
    gap: .35rem;
    align-content: start;
}
.record-edit-form .form-field-full { grid-column: 1 / -1; }
.record-edit-form .field-row label,
.record-edit-form .form-field > label {
    margin: 0;
    text-align: left;
    font-size: .8125rem;
    font-weight: 600;
    color: var(--field-label);
    letter-spacing: .01em;
}
.record-edit-form input:not([type="checkbox"]):not([type="radio"]),
.record-edit-form select,
.record-edit-form textarea,
.record-edit-form .company-picker,
.record-edit-form .locked-record-reference {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
}
.record-edit-form .muted.small { margin: .15rem 0 0; line-height: 1.45; }
.record-edit-form .contact-method-editor,
.record-edit-form .address-editor,
.record-edit-form .udf-fields-editor { margin-top: .25rem; min-width: 0; }
.record-edit-form .udf-fields-editor {
    display:grid;
    grid-template-columns:repeat(2, minmax(0, 1fr));
    gap:.45rem 1.1rem;
    padding:.8rem 1rem 1rem;
    border:1px solid color-mix(in srgb, var(--field-accent) 30%, var(--line));
    border-radius:var(--radius-lg);
    background:linear-gradient(135deg, var(--field-accent-soft), var(--surface-1) 48%);
}
.record-edit-form .udf-fields-editor > h2,
.record-edit-form .udf-fields-editor > .muted,
.record-edit-form .udf-fields-editor > p { grid-column:1 / -1; }
.record-edit-form .udf-fields-editor > h2 {
    margin:-.8rem -1rem .3rem;
    padding:.65rem 1rem;
    box-shadow:inset 4px 0 0 var(--field-accent);
}
.record-edit-form .udf-fields-editor > label {
    margin:.25rem 0 0;
    color:var(--field-label);
    font-size:.8125rem;
    font-weight:600;
}
.record-edit-form .udf-fields-editor > label.checkbox-row { grid-column:span 1; }
.record-edit-form .udf-fields-editor > label + input,
.record-edit-form .udf-fields-editor > label + select,
.record-edit-form .udf-fields-editor > label + textarea { margin-top:-.25rem; }
.record-edit-form h2 + .contact-method-editor,
.record-edit-form h2 + .address-editor,
.record-edit-form h2 + .udf-fields-editor { margin-bottom: .5rem; }
@media (max-width: 900px) {
    .detail-form.record-edit-form { grid-template-columns: 1fr; }
    .record-edit-form .field-row,
    .record-edit-form .field-row.three,
    .record-edit-form .form-grid,
    .record-edit-form .form-grid.three { grid-template-columns: 1fr; }
    .record-edit-form .form-field-full { grid-column: auto; }
    .record-edit-form .udf-fields-editor { grid-template-columns:1fr; }
}

/* The list table in the left column is wrapped in .table-scroll only so a
   wide table can't bleed sideways into the side panel. The .detail-form card
   already frames it, so drop the wrapper's own border/background here. */
.detail-form .table-scroll { border: 0; border-radius: 0; background: none; }

.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.field-row.three { grid-template-columns: 1fr 1fr 1fr; }
@media (max-width: 560px) { .field-row, .field-row.three { grid-template-columns: 1fr; } }

.checkbox-row { display: flex; align-items: center; gap: .5rem; font-weight: 400; color: var(--text); }
.checkbox-row input { width: auto; }

/* The main column: the record's own fields, then every related section
   under them, each at full width with real room to work in. */
.detail-main { display: flex; flex-direction: column; gap: 1.5rem; min-width: 0; }

/* Record-header facts, modelled on Zoho's compact Overview summary.
   They deliberately complement rather than duplicate the complete grid below. */
.record-summary {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 1px;
    background: var(--border); border: 1px solid var(--border); border-radius: 6px; overflow: hidden;
}
.record-summary-field { min-width: 0; padding: .75rem .875rem; background: var(--surface); }
.record-summary-field span { display: block; margin-bottom: .2rem; color: var(--muted); font-size: .6875rem; font-weight: 700; letter-spacing: .03em; text-transform: uppercase; }
.record-summary-field strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .875rem; font-weight: 600; }

/* The older [form | narrow aside] shape, still used by the Activity and
   Admin pages. Those asides hold a short helper panel (a picker, a
   preview), not a stack of five related-record sections, so the split
   that was wrong for a CRM record is right for them -- left as-is
   rather than churned for consistency's sake. */
.detail-grid:has(.detail-side) { grid-template-columns: minmax(0, 2fr) minmax(260px, 1fr); }
.detail-side { display: flex; flex-direction: column; gap: 1.5rem; }

/* --- related-record tabs (SectionJumpNav.razor) -----------------------
   The old sticky left rail squeezed the record content and hid useful
   space. These sit across the top, styled as the same quiet pills as the
   Overview / Timeline control. */
.record-rail {
    display:flex; flex-wrap:wrap; align-items:center; gap:.35rem;
    padding:.45rem;
    background:var(--surface-3);
    border:1px solid var(--line);
    border-radius:var(--radius-lg);
    min-width:0;
}
.record-rail h3 {
    font-size: .6875rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
    color:var(--field-label); margin:0 .2rem 0 .1rem;
}
.record-rail button,
.record-rail a {
    display:inline-flex; align-items:center; width:auto; box-sizing:border-box; text-align:left !important;
    padding:.38rem .72rem; border-radius:var(--radius-pill);
    font-size: .8125rem; font-family: inherit; color: var(--text);
    background:none; border:1px solid transparent; cursor:pointer; white-space:nowrap;
}
.record-rail a { text-decoration: none; }
.record-rail a:hover, .record-rail button:hover { background:var(--surface-1); border-color:var(--field-accent); color:var(--accent); box-shadow:var(--shadow-sm); }
.detail-grid:has(.record-rail) .detail-main { min-width:0; }
@media (max-width: 620px) {
    .record-rail { flex-wrap:nowrap; overflow-x:auto; }
    .record-rail h3 { position:sticky; left:0; background:var(--surface-3); padding-right:.25rem; }
}

/* --- timeline history -------------------------------------------------
   A compact, date-grouped history rather than a generic notes list. The
   time, marker and event text sit on fixed tracks, so a busy record can
   still be scanned from top to bottom without the visual zig-zag. */
.timeline-panel { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 1.25rem; }
.timeline-panel-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1.5rem; }
.timeline-panel-head h2 { margin: 0; font-size: 1.05rem; }
.timeline-panel-actions { display: flex; align-items: center; gap: .6rem; }
.timeline-history { max-width: 56rem; }
.timeline-day + .timeline-day { margin-top: 1.75rem; }
.timeline-date { display: inline-block; padding: .3rem 1rem; border:1px solid var(--line); border-radius: 5px; background:var(--surface-2); color:var(--ink-500); font-weight: 600; font-size: .8125rem; }
.timeline-events { position: relative; margin-top: 1.25rem; }
.timeline-events::before { content: ""; position: absolute; left: 9.2rem; top: .5rem; bottom: .5rem; width: 1px; background:var(--line); }
.timeline-event { display: grid; grid-template-columns: 7.3rem 3.8rem minmax(0, 1fr); column-gap: .65rem; position: relative; min-height: 5rem; }
.timeline-event time { color:var(--ink-500); font-size: .875rem; text-align: right; padding-top: .65rem; font-variant-numeric: tabular-nums; }
.timeline-marker { z-index: 1; width: 2.75rem; height: 2.75rem; display: grid; place-items: center; border:1px solid var(--line); border-radius: 50%; background:var(--surface-1); color:var(--ink-500); }
.timeline-marker-note { color:var(--brand-600); background:var(--surface-3); }
.timeline-marker-activity { color:var(--warning); background:var(--warning-bg); }
.timeline-marker-document { color:var(--success); background:var(--success-bg); }
.timeline-marker-field_change { color:var(--accent-purple); background:var(--accent-purple-bg); }
.timeline-copy { padding: .55rem 0 1.25rem; }
.timeline-title { color: var(--text); font-weight: 600; font-size: .9375rem; }
.timeline-detail { margin-top: .25rem; color:var(--ink-600); white-space: pre-wrap; }
.timeline-meta { margin-top: .25rem; color:var(--ink-500); font-size: .8125rem; }
@media (max-width: 640px) {
    .timeline-panel-head { align-items: flex-start; flex-direction: column; }
    .timeline-panel-actions { width: 100%; justify-content: space-between; }
    .timeline-events::before { left: 1.35rem; }
    .timeline-event { grid-template-columns: 2.75rem minmax(0, 1fr); }
    .timeline-event time { grid-column: 2; grid-row: 1; text-align: left; padding: 0; }
    .timeline-marker { grid-column: 1; grid-row: 1 / span 2; }
    .timeline-copy { grid-column: 2; grid-row: 2; padding-top: .25rem; }
}

/* A contact created from a company is intentionally not a free-form
   company picker: show the inherited relationship plainly and reserve
   white input fields for values the user is actually allowed to edit. */
.locked-record-reference { display: flex; align-items: center; gap: .625rem; min-height: 2.5rem; padding: .5rem .75rem; border:1px solid var(--line-strong); border-radius: 6px; background:var(--surface-3); color:var(--ink-800); }
.locked-record-reference span { color:var(--ink-500); font-size: .8125rem; }

/* --- related-record sections (RelatedRecordsPanel.razor) -------------
   Zoho's Deals / Cases / Activities blocks on a record. The count sits
   in the heading (so you know what's there without reading the table)
   and the "+ New" sits opposite it, the same pairing Zoho uses. */
.related-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; margin-bottom: .75rem; }
.related-head h2 { margin: 0; }
.related-count {
    display: inline-block; margin-left: .375rem; padding: .0625rem .375rem;
    background:var(--surface-3); color: var(--muted); border-radius: 999px;
    font-size: .75rem; font-weight: 600; font-variant-numeric: tabular-nums;
}
.related-panel .related-grid { width: 100%; border-collapse: collapse; font-size: .875rem; }
.related-panel .related-grid th {
    text-align: left; font-size: .6875rem; text-transform: uppercase; letter-spacing: .03em;
    color: var(--muted); font-weight: 700; padding: 0 .5rem .375rem; border-bottom: 1px solid var(--border);
}
.related-panel .related-grid td { padding: .5rem; border-bottom:1px solid var(--line-soft); }
.related-panel .related-grid tr:last-child td { border-bottom: 0; }
.related-panel .related-grid tbody tr:hover { background:var(--surface-2); }
.related-panel .overdue { color: var(--error-text); font-weight: 600; }

/* Status/stage chip inside a related table -- neutral by default, with
   the same green/red this app already uses for won/closed everywhere
   else rather than a chip palette of its own. */
.pill {
    display: inline-block; padding: .0625rem .5rem; border-radius: 999px;
    background:var(--surface-3); color: var(--muted); font-size: .75rem; font-weight: 600; white-space: nowrap;
}
.pill-won { background:var(--success-bg); color:var(--success); }
.pill-lost { background: var(--error-bg); color: var(--error-text); }

/* --- contact method editor ----------------------------------------- */
.cm-editor { margin-top: .5rem; }
.cm-group { margin-bottom: 1rem; }
.cm-group h3 { font-size: .8125rem; font-weight: 600; color: var(--muted); margin: 0 0 .375rem; }
.cm-row { display: grid; grid-template-columns: 7rem 1fr auto auto auto; gap: .5rem; align-items: center; margin-bottom: .375rem; }
.cm-row input { padding: .375rem .5rem; border: 1px solid var(--border); border-radius: 4px; font-size: .875rem; }
.cm-primary { display: flex; align-items: center; gap: .25rem; font-size: .8125rem; color: var(--muted); white-space: nowrap; font-weight: 400; margin: 0; }
.cm-primary input { width: auto; }
.cm-remove {
    background: none; border: 1px solid var(--border); border-radius: 4px;
    width: 1.75rem; height: 1.75rem; cursor: pointer; color: var(--muted); font-size: 1rem; line-height: 1;
}
.cm-remove:hover { border-color: var(--error-border); color: var(--error-text); }
.cm-add { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: .5rem; }
.cm-add-btn {
    background: none; border: 1px dashed var(--border); border-radius: 4px;
    padding: .375rem .75rem; font-size: .8125rem; color: var(--accent); cursor: pointer;
}
.cm-add-btn:hover { border-color: var(--accent); background:var(--brand-50); }

.cm-row .cm-ext { max-width: 5.5rem; }

/* --- address editor --------------------------------------------------
   One block per address (Maximizer: "+ Add new address"), each with its
   own type + primary marker -- addr-block reuses .field-row from the
   surrounding form so its inputs line up with every other field. */
.addr-editor { margin-top: .5rem; }
.addr-block {
    border: 1px solid var(--border); border-radius: 6px;
    padding: .6rem .75rem; margin-bottom: .6rem;
}
.addr-block-head { display: flex; align-items: center; gap: .75rem; margin-bottom: .5rem; }
.addr-type {
    padding: .3125rem .5rem; border: 1px solid var(--border); border-radius: 4px;
    font-size: .8125rem; font-weight: 600; color: var(--text);
}
.addr-block .field-row { margin-top: 0; }
.addr-block label { margin: .5rem 0 .1875rem; }
.addr-block .field-row { gap: .65rem; }
.addr-block .field-row + .field-row { margin-top: .1rem; }

/* Keep the repeatable editors visually subordinate to the primary record
   fields, as in Zoho's compact related-field blocks. */
.detail-form .addr-editor,
.detail-form .cm-editor { font-size: .875rem; }
.detail-form .addr-editor input,
.detail-form .addr-editor select,
.detail-form .cm-editor input,
.detail-form .cm-editor select { padding: .42rem .55rem; min-height: 2.25rem; }

/* --- company typeahead picker --------------------------------------- */
.company-picker { position: relative; }
.company-picker .chip {
    display: inline-flex; align-items: center; gap: .375rem;
    background:var(--brand-100); color:var(--brand-600); border-radius: 4px;
    padding: .25rem .5rem; font-size: .875rem; margin-top: .25rem;
}
.company-picker .chip button {
    background: none; border: 0; color: inherit; cursor: pointer; font-size: 1rem; line-height: 1; padding: 0;
}
.typeahead {
    position: absolute; z-index: 10; top: 100%; left: 0; right: 0;
    background: var(--surface); border: 1px solid var(--border); border-radius: 4px;
    margin: .25rem 0 0; padding: .25rem 0; list-style: none;
    max-height: 220px; overflow-y: auto;
    box-shadow: var(--shadow-md);
}
.typeahead li { padding: .5rem .75rem; cursor: pointer; font-size: .9375rem; }
.typeahead li:hover { background:var(--surface-2); }
.typeahead li.typeahead-add { color: var(--accent); border-top: 1px solid var(--border); font-weight: 500; }

/* --- notes panel ----------------------------------------------------- */
.notes-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 1.25rem;
}
.notes-panel h2 { font-size: .9375rem; margin: 0 0 .75rem; }
.notes-panel textarea {
    width: 100%; padding: .5rem .625rem; border: 1px solid var(--border);
    border-radius: 4px; font-family: inherit; font-size: .875rem; resize: vertical;
}
/* Text inputs match the panel's textarea. MudBlazor's reset zeroes every
   input border, and unlike .detail-form the panel had no rule restoring one,
   so bare <input> fields (e.g. the admin add/edit "Name" box) rendered with
   no visible outline. */
.notes-panel input:not([type=checkbox]):not([type=radio]) {
    width: 100%; padding: .5rem .625rem; border: 1px solid var(--border);
    border-radius: 4px; font-family: inherit; font-size: .875rem;
}
.notes-panel .button { margin-top: .5rem; }
.macro-picker {
    display: block; width: 100%; margin: 0 0 .5rem; padding: .375rem .625rem;
    border: 1px solid var(--border); border-radius: 4px; font-size: .8125rem;
    font-family: inherit; background: var(--surface); color: var(--muted);
}
.note-list { list-style: none; margin: 1.25rem 0 0; padding: 0; display: flex; flex-direction: column; gap: .875rem; }
.note-list li { border-top:1px solid var(--line-soft); padding-top: .875rem; }
.note-list li:first-child { border-top: none; padding-top: 0; }
.note-list li p { margin: 0 0 .25rem; font-size: .9375rem; white-space: pre-wrap; }
.note-list li.pinned { background:var(--warning-bg); margin: 0 -.5rem; padding: .875rem .5rem; border-radius: 4px; border-top: none; }

/* Internal notes: Zendesk's own convention is a warm, slightly urgent
   tint that reads as "careful, this is staff-only" -- distinct from
   pinned's neutral cream so the two never look like the same thing. */
.note-list li.note-internal { background:var(--warning-bg); margin: 0 -.5rem; padding: .875rem .5rem; border-radius: 4px; border-top: none; border-left:3px solid var(--warning); }
.note-internal-badge {
    display: inline-block; font-size: .6875rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: .04em; color:var(--warning); background:var(--warning-bg); border-radius: 3px;
    padding: .0625rem .375rem; margin-bottom: .25rem;
}

/* Timeline -- one small uppercase kind badge per entry, same shape as
   note-internal-badge above, three colours so a scan down the feed
   tells notes/activities/documents apart without reading every line. */
.timeline-kind {
    display: inline-block; font-size: .6875rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: .04em; border-radius: 3px; padding: .0625rem .375rem; margin-right: .375rem;
}
.timeline-kind-note { color:var(--brand-500); background:var(--brand-100); }
.timeline-kind-activity { color:var(--warning); background:var(--warning-bg); }
.timeline-kind-document { color:var(--success); background:var(--success-bg); }

/* --- documents --------------------------------------------------------- */
.documents-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 1.25rem;
    margin-top: 1.25rem;
}
.documents-panel h2 { font-size: .9375rem; margin: 0 0 .75rem; }
.file-input { display: block; font-size: .8125rem; margin-bottom: .5rem; }
.document-list { list-style: none; margin: 1rem 0 0; padding: 0; display: flex; flex-direction: column; gap: .625rem; }
.document-list li { border-top:1px solid var(--line-soft); padding-top: .625rem; display: flex; flex-direction: column; gap: .125rem; }
.document-list li:first-child { border-top: none; padding-top: 0; }
.document-list a { font-size: .9375rem; font-weight: 600; }
.document-row { display: flex; align-items: baseline; justify-content: space-between; gap: .75rem; }
.document-row .link-btn { margin-right: 0; }

.library-upload {
    display: flex; align-items: center; gap: .75rem; flex-wrap: wrap;
    background: var(--surface); border: 1px solid var(--border); border-radius: 6px;
    padding: .875rem 1rem; margin: 1rem 0 1.25rem;
}
.library-upload input[type="text"], .library-upload input:not([type]) { max-width: 16rem; }

/* --- import wizard --------------------------------------------------- */
.import-steps { display: flex; gap: 1.5rem; margin: 1.5rem 0; border-bottom: 1px solid var(--border); padding-bottom: .75rem; }
.import-steps .step { color: var(--muted); font-size: .875rem; }
.import-steps .step.current { color: var(--accent); font-weight: 600; }
.import-steps .step.done { color: var(--text); }

.import-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 1.5rem;
    max-width: 100%;
}
.import-panel label { display: block; margin: 1rem 0 .375rem; font-weight: 600; font-size: .875rem; }
.import-panel label:first-child { margin-top: 0; }
.import-panel select {
    padding: .5rem .625rem; border: 1px solid var(--border); border-radius: 4px; font-size: .9375rem; font-family: inherit;
}
.import-panel input[type=file] { display: block; margin-top: .25rem; }

.import-actions { display: flex; gap: .75rem; margin-top: 1.5rem; }

.import-progress { margin-top: 1rem; max-width: 34rem; }
.import-progress-label { margin-bottom: .35rem; font-weight: 600; }
.import-progress progress { width: 100%; height: .65rem; accent-color:var(--crm-primary, var(--brand-500)); }
.button.secondary { background: var(--surface); color: var(--accent); border: 1px solid var(--accent); }

.mapping-table select { width: 100%; }
.mapping-table td { vertical-align: middle; }

.preview-summary { display: flex; gap: .75rem; margin-bottom: 1rem; flex-wrap: wrap; }
.pill { padding: .25rem .625rem; border-radius: 999px; font-size: .8125rem; font-weight: 600; }
.pill.create { background:var(--success-bg); color:var(--success); }
.pill.update { background:var(--brand-100); color:var(--brand-600); }
.pill.invalid { background: var(--error-bg); color: var(--error-text); }

.preview-table { max-height: 420px; overflow-y: auto; margin-top: 1rem; }
tr.invalid-row { background: var(--error-bg); }

.result-list { list-style: none; padding: 0; display: flex; gap: 1.5rem; font-size: 1.0625rem; margin: 1rem 0 1.5rem; }

/* --- delete confirmation modal --------------------------------------- */
.button.danger { background: var(--surface); color: var(--error-text); border: 1px solid var(--error-border); }
.button.danger:hover:not(:disabled) { background: var(--error-bg); }
.button.danger:disabled { color: var(--muted); border-color: var(--border); }

.modal-backdrop {
    position: fixed; inset: 0; background: rgba(20,22,26,.4);
    display: flex; align-items: center; justify-content: center;
    z-index: 100; padding: 1rem;
}
.modal {
    background: var(--surface); border-radius: 8px; padding: 1.5rem;
    max-width: 420px; width: 100%; box-shadow: var(--shadow-lg);
}
.modal h2 { margin: 0 0 .75rem; font-size: 1.125rem; }
.modal p { margin: 0 0 1.25rem; color: var(--muted); font-size: .9375rem; }
.modal-actions { display: flex; justify-content: flex-end; gap: .75rem; }

/* --- opportunities: pipeline summary bar ------------------------------ */
.pipeline-bar { display: flex; gap: .5rem; margin: 1rem 0 1.25rem; flex-wrap: wrap; align-items: stretch; }
.pipeline-stage {
    display: flex; flex-direction: column; gap: .125rem;
    background: var(--surface); border: 1px solid var(--border); border-radius: 6px;
    padding: .5rem .875rem; cursor: pointer; font: inherit; text-align: left;
    min-width: 7.5rem;
}
.pipeline-stage:hover { border-color: var(--accent); }
.pipeline-stage.active { border-color: var(--accent); background:var(--brand-50); box-shadow: inset 0 0 0 1px var(--accent); }
.pipeline-stage.won { border-color:var(--success-line); }
.pipeline-stage.lost { border-color:var(--danger-line-soft); opacity: .75; }
.pipeline-stage-name { font-size: .75rem; text-transform: uppercase; letter-spacing: .02em; color: var(--muted); }
.pipeline-stage-count { font-size: 1.125rem; font-weight: 700; }
.pipeline-stage-amount { font-size: .8125rem; color: var(--muted); }
.pipeline-clear {
    align-self: center; background: none; border: 0; color: var(--accent);
    cursor: pointer; font-size: .875rem; text-decoration: underline;
}

.searchbar .checkbox-row.small { margin-left: 1rem; font-size: .875rem; }

.badge.won { background:var(--success-bg); color:var(--success); }
.badge.lost { background: var(--error-bg); color: var(--error-text); }

/* --- opportunity stage tracker ---------------------------------------- */
.stage-tracker { display: flex; gap: .5rem; margin: 0 0 1.5rem; flex-wrap: wrap; }
.stage-step {
    background: var(--surface); border: 1px solid var(--border); border-radius: 999px;
    padding: .375rem .875rem; font-size: .8125rem; cursor: pointer; color: var(--muted);
}
.stage-step:hover:not(:disabled) { border-color: var(--accent); color: var(--text); }
.stage-step.current { background: var(--accent); border-color: var(--accent); color:var(--on-accent); font-weight: 600; }
.stage-step.won.current { background:var(--success); border-color:var(--success); }
.stage-step.lost.current { background:var(--danger-fg); border-color:var(--danger-fg); }
.stage-step:disabled { cursor: default; }
/* A tracker built from <span> rather than <button> (leads: status changes
   through the field below, not by clicking a step) reads the same but
   isn't interactive, so it shouldn't look it. */
span.stage-step { cursor: default; }
span.stage-step:hover { border-color: var(--border); color: var(--muted); }
span.stage-step.current:hover { border-color: var(--accent); color:var(--on-accent); }

/* --- leads: status filter bar ------------------------------------------ */
.status-filter-bar { display: flex; gap: .5rem; margin: 1rem 0 1.25rem; flex-wrap: wrap; align-items: center; }
.status-chip {
    background: var(--surface); border: 1px solid var(--border); border-radius: 999px;
    padding: .375rem .875rem; font-size: .8125rem; cursor: pointer; color: var(--muted); font: inherit;
}
.status-chip:hover { border-color: var(--accent); color: var(--text); }
.status-chip.active { border-color: var(--accent); background:var(--brand-50); color: var(--text); box-shadow: inset 0 0 0 1px var(--accent); }
.status-chip.won { border-color:var(--success-line); }
.status-chip.lost { border-color:var(--danger-line-soft); opacity: .75; }

.history-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .625rem; }
.history-list li { display: flex; justify-content: space-between; gap: .75rem; font-size: .875rem; }

/* --- hotlist ----------------------------------------------------------- */
.hotlist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .5rem; }
.hotlist-item {
    display: flex; align-items: center; gap: .75rem;
    background: var(--surface); border: 1px solid var(--border); border-radius: 6px;
    padding: .625rem .875rem;
}
.hotlist-item.overdue { border-left:3px solid var(--danger-fg); }
.hotlist-done {
    flex-shrink: 0; width: 1.75rem; height: 1.75rem; border-radius: 50%;
    border: 1px solid var(--border); background: var(--surface); color: var(--muted);
    cursor: pointer; font-size: .875rem; line-height: 1;
}
.hotlist-done:hover { border-color:var(--success); color:var(--success); background:var(--success-bg); }
.hotlist-body { flex: 1; display: flex; align-items: center; gap: .5rem; cursor: pointer; min-width: 0; flex-wrap: wrap; }
.hotlist-subject { font-weight: 600; }
.hotlist-date { flex-shrink: 0; font-size: .875rem; color: var(--muted); }
.hotlist-date.overdue { color:var(--danger-fg); font-weight: 600; }

.badge.priority-high { background: var(--error-bg); color: var(--error-text); }
.badge.priority-normal { background:var(--surface-2); color: var(--muted); }
.badge.priority-low { background:var(--surface-2); color: var(--muted); }

td.overdue { color:var(--danger-fg); font-weight: 600; }

/* --- dashboard: KPI row --------------------------------------------- */
.kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem; margin: 1.5rem 0; }
.stat-tile {
    background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
    padding: 1rem 1.125rem; display: flex; flex-direction: column; gap: .25rem;
}
.stat-tile.stat-tile-warn { border-color:var(--warning-line-soft); }
.stat-label { font-size: .8125rem; color: var(--muted); }
.stat-value { font-size: 1.75rem; font-weight: 600; line-height: 1.1; font-variant-numeric: proportional-nums; }
.stat-sub { font-size: .8125rem; }
.stat-sub.stat-overdue { color:var(--danger); font-weight: 600; }

/* --- dashboard: panels ----------------------------------------------- */
.panel {
    background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
    padding: 1.25rem 1.5rem; margin-bottom: 1.5rem;
}
.panel h2 { font-size: .9375rem; text-transform: uppercase; letter-spacing: .02em; color: var(--muted); margin: 0 0 1rem; }
.panel-link { display: inline-block; margin-top: .875rem; font-size: .875rem; color: var(--accent); text-decoration: none; }
.panel-link:hover { text-decoration: underline; }

.dashboard-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
@media (max-width: 720px) { .dashboard-columns { grid-template-columns: 1fr; } }

/* --- dashboard: pipeline funnel bar chart ----------------------------
   Mark spec: bars <=24px thick, 4px rounded data-end square at the
   baseline, one sequential hue (blue), darker = closer to close. */
.funnel { display: flex; flex-direction: column; gap: .625rem; }
.funnel-row { display: grid; grid-template-columns: 9rem 1fr 5.5rem 2.5rem; align-items: center; gap: .75rem; }
.funnel-label { font-size: .875rem; color: var(--text); }
.funnel-track { background: var(--bg); border-radius: 4px; height: 20px; overflow: hidden; }
.funnel-bar {
    height: 20px; min-width: 4px;
    border-radius: 0 4px 4px 0;   /* 4px rounded data-end, square at the baseline (left) */
}
.funnel-value { font-size: .875rem; font-weight: 600; text-align: right; font-variant-numeric: proportional-nums; }
.funnel-count { font-size: .8125rem; text-align: right; }

/* --- dashboard: preview lists (upcoming, hotlist) --------------------- */
.preview-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0; }
.preview-list li {
    display: flex; align-items: center; gap: .625rem; padding: .625rem 0;
    border-top:1px solid var(--line-soft); cursor: pointer; flex-wrap: wrap;
}
.preview-list li:first-child { border-top: none; }
.preview-list li:hover { background:var(--surface-2); margin: 0 -.5rem; padding-left: .5rem; padding-right: .5rem; border-radius: 4px; }
.preview-when { font-size: .8125rem; color: var(--muted); flex-shrink: 0; min-width: 5.5rem; }
.preview-when.overdue { color:var(--danger); font-weight: 600; }
.preview-subject { font-weight: 500; }

/* --- custom fields admin ---------------------------------------------- */
.admin-tabs { display: flex; gap: .5rem; margin: 1rem 0 1.5rem; border-bottom: 1px solid var(--border); }
.admin-tab {
    background: none; border: 0; border-bottom: 2px solid transparent;
    padding: .625rem .25rem; margin-right: 1.25rem; font: inherit; font-size: .9375rem;
    color: var(--muted); cursor: pointer;
}
.admin-tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.admin-tab:hover:not(.active) { color: var(--text); }

/* Setup editors contain tables and lists, not record label/control pairs.
   Keeping them block-layout prevents the record form's four-column grid
   from shrinking a table into its first track (the broken Fields screen). */
.setup-admin-card { min-width: 0; }
.setup-admin-card > .table-scroll { width: 100%; }
.setup-admin-card .setup-table,
.setup-admin-card > .table-scroll > .grid { min-width: 42rem; }
.setup-editor-grid { display:grid; grid-template-columns:minmax(0,1.45fr) minmax(22rem,.8fr); gap:1rem; align-items:start; }
.setup-editor-grid.single { grid-template-columns:minmax(0,1fr); }
.security-flow { display:flex; align-items:center; flex-wrap:wrap; gap:.55rem; margin:0 0 1rem; padding:.75rem 1rem; border:1px solid var(--line); border-radius:var(--radius-lg); background:linear-gradient(90deg,var(--brand-50),var(--surface-1)); color:var(--ink-600); }
.security-flow strong { margin-right:.35rem; color:var(--ink-800); }
.security-flow span { padding:.28rem .55rem; border:1px solid var(--line); border-radius:var(--radius-pill); background:var(--surface-1); font-size:var(--text-sm); }
.security-member-list,.access-group-list { display:grid; gap:.35rem; max-height:18rem; overflow:auto; padding:.6rem; border:1px solid var(--line); border-radius:var(--radius-md); background:var(--surface-2); }
.security-member-list .checkbox-row,.access-group-list .checkbox-row { padding:.45rem .5rem; border-radius:var(--radius-sm); background:var(--surface-1); }
.security-member-list span,.access-group-list span { display:grid; }
.security-member-list small,.access-group-list small { color:var(--ink-400); font-weight:400; }
.access-subhead { margin:1.1rem 0 .25rem; color:var(--ink-800); font-size:var(--text-md); }
.access-dialog > label { display:block; margin:.8rem 0 .3rem; font-weight:650; }
.access-dialog > select { width:100%; padding:.55rem .65rem; border:1px solid var(--line-strong); border-radius:var(--radius-md); background:var(--surface-1); }
.modal.record-access-dialog { width:min(58rem, calc(100vw - 2rem)); max-width:58rem; max-height:min(49rem, calc(100vh - 2rem)); overflow:auto; padding:0; }
.record-access-fields { display:grid; gap:.55rem; margin:.8rem 0 1rem; padding:.85rem 1rem; border:1px solid var(--line); border-radius:var(--radius-lg); background:var(--surface-1); box-shadow:var(--shadow-sm); }
.record-access-field-row { display:grid; grid-template-columns:8rem minmax(0,1fr); gap:.75rem; align-items:center; }
.record-access-field-label { color:var(--ink-700); font-size:.8rem; font-weight:750; }
.record-access-value { display:flex; align-items:center; flex-wrap:wrap; gap:.35rem; min-height:2.55rem; padding:.35rem .45rem; border:1px solid var(--line-strong); border-radius:var(--radius-md); background:var(--surface-1); color:var(--ink-800); cursor:pointer; text-align:left; }
.record-access-value:hover { border-color:var(--brand-400); box-shadow:0 0 0 2px color-mix(in srgb,var(--brand-400) 12%,transparent); }
.record-access-chip { display:inline-flex; align-items:center; gap:.4rem; max-width:15rem; padding:.3rem .55rem; border-radius:var(--radius-sm); background:var(--surface-3); color:var(--ink-700); font-size:.78rem; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.record-access-chip.public { background:color-mix(in srgb,var(--success) 12%,var(--surface-1)); color:var(--success); }
.record-access-chip.group { background:var(--brand-100); color:var(--brand-700); }
.record-access-chip b { font-size:1rem; line-height:.7; font-weight:500; }
.record-access-edit { margin-left:auto; padding:.2rem .45rem; color:var(--brand-700); font-size:.75rem; font-weight:700; }
.record-context-overlay { position:fixed; inset:0; z-index:1200; }
.record-context-menu { position:fixed; width:min(18rem,calc(100vw - 1rem)); padding:.35rem; border:1px solid var(--line-strong); border-radius:var(--radius-md); background:var(--surface-1); box-shadow:var(--shadow-lg); }
.record-context-title { padding:.55rem .7rem; color:var(--ink-500); font-size:.72rem; font-weight:750; letter-spacing:.04em; text-transform:uppercase; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.record-context-menu a,.record-context-menu button { display:block; width:100%; padding:.55rem .7rem; border:0; border-radius:var(--radius-sm); background:transparent; color:var(--ink-800); font:inherit; font-size:.86rem; text-align:left; text-decoration:none; cursor:pointer; }
.record-context-menu a:hover,.record-context-menu button:hover { background:var(--brand-50); color:var(--brand-700); }
.record-context-separator { height:1px; margin:.3rem .25rem; background:var(--line); }
.record-access-head { display:grid; grid-template-columns:auto 1fr auto; gap:.8rem; align-items:center; padding:1.25rem 1.4rem; border-bottom:1px solid var(--line); background:linear-gradient(100deg,var(--brand-50),var(--surface-1)); }
.record-access-head h2 { margin:0 0 .15rem; font-size:1.25rem; color:var(--ink-900); }
.record-access-head p { margin:0; font-size:.85rem; }
.record-access-head-icon { display:grid; place-items:center; width:2.6rem; height:2.6rem; border-radius:var(--radius-md); background:var(--brand-600); color:white; font-size:1.15rem; box-shadow:var(--shadow-sm); }
.modal-close { border:0; background:transparent; color:var(--ink-400); font-size:1.7rem; cursor:pointer; }
.record-access-public-grid { display:grid; grid-template-columns:1fr 1fr; gap:.8rem; padding:1rem 1.4rem .75rem; }
.record-access-public-card { display:grid; grid-template-columns:auto auto 1fr; align-items:center; gap:.7rem; min-height:4.5rem; padding:.75rem; border:1px solid var(--line); border-radius:var(--radius-lg); background:var(--surface-1); cursor:pointer; }
.record-access-public-card.selected { border-color:var(--brand-400); background:var(--brand-50); box-shadow:0 0 0 2px color-mix(in srgb,var(--brand-400) 14%,transparent); }
.record-access-public-card > span:last-child,.record-access-person-row > span:last-child { display:grid; }
.record-access-public-card small,.record-access-person-row small { color:var(--ink-400); font-weight:400; }
.access-card-icon { display:grid; place-items:center; width:2rem; height:2rem; border-radius:50%; background:var(--surface-3); }
.record-access-search { display:flex; align-items:center; gap:.55rem; margin:0 1.4rem .8rem; padding:0 .75rem; border:1px solid var(--line-strong); border-radius:var(--radius-md); background:var(--surface-1); }
.record-access-search input { flex:1; border:0; outline:0; padding:.7rem 0; background:transparent; }
.record-access-columns { display:grid; grid-template-columns:1fr 1fr; gap:.8rem; padding:0 1.4rem 1rem; }
.record-access-columns > section { min-width:0; border:1px solid var(--line); border-radius:var(--radius-lg); background:var(--surface-2); overflow:hidden; }
.record-access-section-head { display:flex; justify-content:space-between; align-items:center; padding:.75rem .85rem; border-bottom:1px solid var(--line); background:var(--surface-1); }
.record-access-section-head h3,.record-access-section-head p { margin:0; }
.record-access-section-head p { font-size:.75rem; }
.record-access-section-head > span { padding:.22rem .5rem; border-radius:var(--radius-pill); background:var(--brand-100); color:var(--brand-700); font-size:.72rem; font-weight:700; }
.record-access-list { max-height:18rem; overflow:auto; padding:.45rem; }
.record-access-person-row { display:grid; grid-template-columns:auto auto 1fr; align-items:center; gap:.55rem; padding:.5rem; margin:.15rem 0; border:1px solid transparent; border-radius:var(--radius-md); background:var(--surface-1); cursor:pointer; }
.record-access-person-row:hover { border-color:var(--brand-200); }
.record-access-person-row.selected { border-color:var(--brand-300); background:var(--brand-50); }
.access-identity-icon { display:grid; place-items:center; width:1.85rem; height:1.85rem; border-radius:50%; background:var(--module-person-soft); color:var(--module-person); font-size:.68rem; font-weight:800; }
.access-identity-icon.group { background:var(--brand-100); color:var(--brand-700); }
.record-access-footer { display:flex; align-items:center; justify-content:space-between; gap:1rem; padding:.9rem 1.4rem; border-top:1px solid var(--line); background:var(--surface-2); }
.record-access-footer p { margin:0; font-size:.78rem; }
@media (max-width: 700px) {
    .record-access-columns,.record-access-public-grid { grid-template-columns:1fr; }
    .record-access-field-row { grid-template-columns:1fr; gap:.25rem; }
    .record-access-footer { align-items:flex-start; flex-direction:column; }
}
@media (max-width: 900px) { .setup-editor-grid { grid-template-columns:1fr; } }

.link-btn {
    background: none; border: 0; color: var(--accent); cursor: pointer;
    font-size: .8125rem; padding: 0; margin-right: .75rem; text-decoration: underline;
}
.link-btn.danger { color: var(--error-text); }

/* --- Reports library ------------------------------------------------- */
.report-library, .report-result { max-width: 1320px; margin: 0 auto; }
.report-library-header, .report-result > header { display:flex; justify-content:space-between; align-items:flex-start; gap:1rem; margin-bottom:1.5rem; }
.report-library h1, .report-result h1 { margin:0; font-size:2rem; font-weight:600; color:var(--text); }
.report-library-header p, .report-result header p { margin:.35rem 0 0; color:var(--muted); }
.report-library-toolbar { display:flex; align-items:center; gap:.75rem; padding:.9rem 1rem; background:var(--surface-1); border:1px solid var(--line); border-bottom:0; border-radius:10px 10px 0 0; }
.report-dashboard-callout { display:flex; align-items:center; justify-content:space-between; gap:1rem; margin:.75rem 0; padding:1rem 1.1rem; border:1px solid var(--line-strong); border-radius:10px; background:linear-gradient(110deg,var(--brand-50),var(--surface-1)); color:var(--ink-800); }
.report-dashboard-callout div { display:flex; flex-direction:column; gap:.2rem; }
.report-dashboard-callout span { color:var(--ink-500); font-size:.9rem; }
.sales-dashboard { max-width:1400px; margin:0 auto; padding:1.5rem; background:var(--surface-3); min-height:calc(100vh - 80px); }
.sales-dashboard-header { display:flex; align-items:flex-end; justify-content:space-between; margin-bottom:1.25rem; }
.sales-dashboard-header h1 { margin:.35rem 0; font-size:2rem; color:var(--ink-900); }
.sales-dashboard-header p { margin:0; color:var(--ink-400); }
.dashboard-controls { display:flex; align-items:end; gap:.65rem; margin-bottom:1rem; }.dashboard-controls label { display:grid; gap:.25rem; color:var(--ink-400); font-size:.75rem; text-transform:uppercase; }.dashboard-controls input { border:1px solid var(--line-strong); border-radius:6px; padding:.45rem .55rem; color:var(--ink-800); }
.sales-dashboard-grid { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:1rem; }
.dashboard-panel { min-width:0; background:var(--surface-1); border:1px solid var(--line); border-radius:12px; box-shadow:var(--shadow-sm), var(--highlight-top); overflow:hidden; }
.dashboard-panel.wide { grid-column:span 2; }
.dashboard-panel > header { display:flex; align-items:center; justify-content:space-between; padding:.8rem 1rem; border-bottom:1px solid var(--line-soft); }
.dashboard-panel h2 { margin:0; font-size:1rem; color:var(--ink-800); }
.dashboard-panel > header span { color:var(--ink-400); font-size:.78rem; }
.dashboard-empty { min-height:150px; display:flex; flex-direction:column; align-items:center; justify-content:center; gap:.35rem; padding:1.25rem; color:var(--ink-400); text-align:center; }
.dashboard-empty strong { color:var(--ink-700); font-size:.95rem; }
.dashboard-empty span { font-size:.82rem; }
.dashboard-bars { padding:1rem; display:grid; gap:.7rem; }
.dashboard-bar { display:grid; grid-template-columns:130px 1fr 28px; gap:.6rem; align-items:center; font-size:.82rem; color:var(--ink-600); }
.dashboard-bar i { height:10px; background:var(--surface-3); border-radius:6px; overflow:hidden; }
.dashboard-bar b { display:block; height:100%; background:linear-gradient(90deg,var(--brand-400),var(--data-progress)); border-radius:6px; }
.dashboard-bar strong { text-align:right; color:var(--ink-800); }
.dashboard-table { overflow:hidden; }
.dashboard-table table { width:100%; border-collapse:collapse; font-size:.78rem; }
.dashboard-table th { text-align:left; color:var(--ink-400); font-size:.7rem; text-transform:uppercase; letter-spacing:.04em; padding:.65rem .75rem; background:var(--surface-2); white-space:nowrap; }
.dashboard-table td { padding:.65rem .75rem; border-top:1px solid var(--line-soft); color:var(--ink-700); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; max-width:180px; }
.dashboard-table th { overflow:hidden; text-overflow:ellipsis; }
.dashboard-table td.status-good { color:var(--success); font-weight:600; }.dashboard-table td.status-bad { color:var(--danger); font-weight:600; }.dashboard-table td.status-warn { color:var(--warning); font-weight:600; }
.report-share-check { display:flex; align-items:center; gap:.45rem; margin:.6rem 0; color:var(--ink-600); font-size:.85rem; }
.workqueue-page { display:grid; grid-template-columns:300px minmax(0,1fr); min-height:calc(100vh - 80px); background:var(--surface-2); gap:1rem; padding:1rem; }.workqueue-sidebar { background:var(--surface-1); border:1px solid var(--line); border-radius:10px; padding:1rem; }.workqueue-sidebar h2 { margin:0 0 .75rem; font-size:1rem; }.workqueue-sidebar select { width:100%; padding:.55rem; border:1px solid var(--line-strong); border-radius:6px; margin-bottom:.75rem; }.workqueue-sidebar a { display:flex; justify-content:space-between; padding:.65rem .55rem; color:var(--ink-800); text-decoration:none; border-radius:6px; }.workqueue-sidebar a.active,.workqueue-sidebar a:hover { background:var(--brand-100); color:var(--brand-500); }.workqueue-sidebar hr { border:0; border-top:1px solid var(--line-soft); margin:1rem 0; }.workqueue-sidebar h3 { font-size:.85rem; margin:.5rem; }.workqueue-header { display:flex; justify-content:space-between; align-items:center; background:var(--surface-1); padding:1rem 1.25rem; border:1px solid var(--line); border-radius:10px; }.workqueue-header h1 { margin:0; color:var(--ink-800); }.workqueue-empty { margin-top:1rem; background:var(--surface-1); border:1px solid var(--line); border-radius:10px; min-height:380px; display:grid; place-content:center; text-align:center; color:var(--ink-400); }.workqueue-empty h2 { color:var(--ink-800); }
.dashboard-kpis { display:grid; grid-template-columns:repeat(4,1fr); gap:1rem; margin-bottom:1rem; }.dashboard-kpis div { background:var(--surface-1); border:1px solid var(--line); border-radius:10px; padding:1rem; box-shadow:var(--shadow-sm), var(--highlight-top); }.dashboard-kpis strong { display:block; font-size:1.65rem; color:var(--brand-500); }.dashboard-kpis span { color:var(--ink-400); font-size:.8rem; }.dashboard-kpi-link { display:flex; flex-direction:column; gap:.35rem; background:var(--surface-1); border:1px solid var(--line); border-radius:10px; padding:1rem; box-shadow:var(--shadow-sm), var(--highlight-top); color:inherit; text-decoration:none; transition:transform .15s ease,box-shadow .15s ease,border-color .15s ease; }.dashboard-kpi-link:hover,.dashboard-kpi-link:focus-visible { transform:translateY(-1px); border-color:var(--brand-500); box-shadow:var(--shadow-raise); outline:none; }.dashboard-kpi-link strong { display:block; font-size:1.65rem; color:var(--brand-500); }.dashboard-kpi-link span { color:var(--ink-400); font-size:.8rem; }.dashboard-funnel { padding:1rem; display:flex; flex-direction:column; align-items:center; gap:3px; }.funnel-segment { color:var(--on-accent); text-align:center; padding:.55rem .4rem; font-size:.75rem; clip-path:polygon(5% 0,95% 0,82% 100%,18% 100%); }.dashboard-donut-wrap { display:flex; align-items:center; justify-content:center; gap:1.25rem; padding:1.25rem; }.dashboard-donut { width:130px; height:130px; border-radius:50%; display:grid; place-items:center; color:var(--ink-800); font-weight:700; font-size:1.3rem; box-shadow:inset 0 0 0 28px var(--surface-1); }.dashboard-legend { display:grid; gap:.4rem; font-size:.78rem; color:var(--ink-600); }
@media (max-width:900px) { .sales-dashboard-grid { grid-template-columns:repeat(2,minmax(0,1fr)); }.dashboard-panel.wide { grid-column:span 2; } }
@media (max-width:600px) { .sales-dashboard { padding:.75rem; }.sales-dashboard-header { align-items:flex-start; flex-direction:column; gap:.75rem; }.sales-dashboard-grid { grid-template-columns:1fr; }.dashboard-panel.wide { grid-column:span 1; }.dashboard-bar { grid-template-columns:100px 1fr 22px; } }

/* --- Sales Intelligence dashboards (/reports/dashboards) -------------
   Built on the rep-dashboard's own .sales-dashboard / .dashboard-panel
   shell so the two read the same. New here: the left rail, the shared
   filter bar, and semantic KPI tones (won / in progress / lost) -- the
   one thing borrowed from Maximizer's look. */
.sid { max-width:1600px; margin:0 auto; padding:1rem 1.5rem 2rem; }
.sid-header { display:flex; align-items:baseline; justify-content:space-between; gap:1rem; flex-wrap:wrap; }
.sid-header h1 { margin:0; font-size:1.4rem; font-weight:600; color:var(--ink-900); letter-spacing:-.01em; }
.sid-header-actions { display:flex; align-items:center; gap:1rem; }
.sid-header-link { color:var(--brand-600); font-size:.82rem; text-decoration:none; }
.sid-header-link:hover { text-decoration:underline; }

/* Sync line + report actions, between the filter band and the panels. */
.sid-meta { display:flex; align-items:center; justify-content:space-between; gap:1rem; padding:.15rem .15rem .8rem; }
.sid-sync { color:var(--ink-400); font-size:.78rem; font-variant-numeric:tabular-nums; }
.sid-meta-action { border:1px solid var(--line); background:var(--surface-1); color:var(--ink-500); border-radius:4px; width:1.9rem; height:1.9rem; font-size:.95rem; line-height:1; }
.sid-meta-action:hover:not(:disabled) { border-color:var(--brand-500); color:var(--brand-600); }
.sid-meta-action:disabled { opacity:.5; cursor:wait; }

/* The tab strip is the dashboard picker -- full width, no sidebar. */
.sid-tabs { display:flex; gap:.15rem; overflow-x:auto; margin:.85rem 0 0; border-bottom:1px solid var(--line); scrollbar-width:thin; }
.sid-tabs a { flex:0 0 auto; padding:.6rem 1.05rem; color:var(--ink-500); font-size:.875rem; font-weight:500; text-decoration:none; border-bottom:2px solid transparent; white-space:nowrap; }
.sid-tabs a:hover { color:var(--brand-600); background:var(--brand-50); }
.sid-tabs a.active { color:var(--brand-700); font-weight:600; border-bottom-color:var(--brand-600); background:var(--brand-50); }

.sid-loading { display:flex; flex-direction:column; align-items:center; gap:.5rem; padding:4rem 1rem; color:var(--ink-400); font-size:.85rem; }
.sid-loading strong { color:var(--ink-700); font-size:1rem; font-weight:600; }
.sid-spinner { width:26px; height:26px; border:3px solid var(--line); border-top-color:var(--brand-600); border-radius:50%; animation:sid-spin .8s linear infinite; }
@keyframes sid-spin { to { transform:rotate(360deg); } }
@media (prefers-reduced-motion:reduce) { .sid-spinner { animation-duration:2.4s; } }

/* A flat band, not a floating card -- it belongs to the tab strip above
   it, the way Maximizer's own filter row does. */
.sid-filter-bar { display:flex; flex-wrap:wrap; align-items:end; gap:1.1rem; padding:.7rem 1rem; margin-bottom:1rem; background:var(--surface-3); border:1px solid var(--line); border-top:0; border-radius:0 0 8px 8px; }
.sid-filter { position:relative; display:grid; gap:.25rem; }
.sid-filter-label { color:var(--ink-400); font-size:.68rem; text-transform:uppercase; letter-spacing:.04em; }
.sid-filter-control { min-height:2.3rem; min-width:9rem; padding:.4rem .6rem; border:1px solid var(--line-strong); border-radius:6px; background:var(--surface-1); color:var(--ink-800); font:inherit; text-align:left; display:inline-flex; align-items:center; justify-content:space-between; gap:.5rem; }
.sid-owner-menu { position:absolute; top:100%; left:0; z-index:20; margin-top:.25rem; width:16rem; max-height:16rem; overflow:auto; padding:.5rem; background:var(--surface-1); border:1px solid var(--line-strong); border-radius:8px; box-shadow:var(--shadow-lg); }
.sid-owner-menu-actions { display:flex; gap:.5rem; padding:.15rem .15rem .4rem; border-bottom:1px solid var(--line-soft); margin-bottom:.35rem; }
.sid-owner-menu-actions button { flex:1; border:0; background:var(--brand-50); color:var(--brand-600); border-radius:5px; padding:.35rem; font-size:.75rem; }
.sid-owner-option { display:flex; align-items:center; gap:.45rem; padding:.32rem .3rem; font-size:.84rem; color:var(--ink-700); }
.sid-owner-option input { width:auto; }
.sid-filter-reset { align-self:end; border:0; background:transparent; color:var(--brand-600); font-size:.82rem; padding:.5rem .25rem; }

/* KPI tiles -- Maximizer's anatomy: plain title top-left, a centred
   caption over an oversized light-weight figure, and a label/value
   footer line. The card is neutral; only the figure carries the
   won / in-progress / lost colour, because only the figure means one. */
.sid-kpis { display:grid; grid-template-columns:repeat(auto-fit,minmax(260px,1fr)); gap:.85rem; margin:0 0 .85rem; }
.sid-kpi { display:flex; flex-direction:column; background:var(--surface-1); border:1px solid var(--line); border-radius:var(--radius-md); padding:.9rem 1.1rem 0; box-shadow:var(--shadow-sm), var(--highlight-top); transition:box-shadow .16s ease, transform .16s ease; }
.sid-kpi:hover { box-shadow:var(--shadow-raise), var(--highlight-top); transform:translateY(-1px); }
.sid-kpi-title { margin:0; font-size:.95rem; font-weight:400; color:var(--ink-700); }
.sid-kpi-title a { color:inherit; text-decoration:none; }
.sid-kpi-title a:hover { color:var(--brand-600); text-decoration:underline; }
.sid-kpi-body { display:flex; flex-direction:column; align-items:center; gap:.1rem; padding:.55rem 0 .7rem; }
.sid-kpi-caption { color:var(--ink-400); font-size:.85rem; }
.sid-kpi-figure { font-size:2.3rem; font-weight:300; line-height:1.15; letter-spacing:-.01em; font-variant-numeric:tabular-nums; }
.sid-kpi-figure.tone-positive { color:var(--data-won); }
.sid-kpi-figure.tone-in-progress { color:var(--data-progress); }
.sid-kpi-figure.tone-negative { color:var(--data-lost); }
.sid-kpi-figure.tone-neutral { color:var(--brand-600); }
.sid-kpi-foot { display:flex; align-items:center; justify-content:space-between; gap:.75rem; padding:.45rem 0; border-top:1px solid var(--line-soft); color:var(--ink-300); font-size:.72rem; min-height:1.9rem; }
.sid-kpi-foot span:last-child { color:var(--ink-500); font-variant-numeric:tabular-nums; }

/* Panels -- flat bordered cards, plain titles, dense content. */
.sid .sales-dashboard-grid { display:grid; grid-template-columns:repeat(auto-fit,minmax(360px,1fr)); gap:.85rem; }
.sid-panel { min-width:0; background:var(--surface-1); border:1px solid var(--line); border-radius:var(--radius-md); overflow:hidden; box-shadow:var(--shadow-sm), var(--highlight-top); }
.sid-panel.wide { grid-column:span 2; }
.sid-panel-head { display:flex; align-items:baseline; gap:.6rem; padding:.85rem 1.1rem .3rem; }
.sid-panel-head h2 { margin:0; font-size:.95rem; font-weight:400; color:var(--ink-700); }
.sid-panel-subtitle { color:var(--ink-300); font-size:.75rem; }
.sid-panel-link { margin-left:auto; color:var(--brand-600); font-size:.76rem; text-decoration:none; white-space:nowrap; }
.sid-panel-link:hover { text-decoration:underline; }

/* Bordered data grid, like Maximizer's own report tables. */
.sid-panel .dashboard-table { padding:.6rem 1.1rem 1rem; }
.sid-panel .dashboard-table table { border:1px solid var(--line); }
.sid-panel .dashboard-table th { background:var(--surface-2); border:1px solid var(--line); color:var(--ink-500); font-size:.75rem; font-weight:600; text-transform:none; letter-spacing:0; padding:.5rem .65rem; }
.sid-panel .dashboard-table td { border:1px solid var(--line-soft); padding:.5rem .65rem; font-size:.8rem; }
/* Wide tables scroll inside their own panel rather than being clipped
   by the next panel in the grid -- the first build cut the amount and
   close-date columns off entirely. */
.sid .dashboard-table { overflow-x:auto; }

/* The shared .dashboard-bar grid gives its value column a fixed 28px,
   which suited the rep dashboard's two-digit counts but clipped
   "ZAR5.19M" to "ZAR5.1". Size it to the content instead, and let the
   label truncate rather than the figure -- the number is the point. */
.sid .dashboard-bar { grid-template-columns:minmax(0,120px) 1fr auto; }
.sid .dashboard-bar > span { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.sid .dashboard-bar strong { min-width:4.5rem; font-variant-numeric:tabular-nums; }
.sid-group-row th { background:var(--surface-1) !important; border-left:1px solid var(--line) !important; border-right:1px solid var(--line) !important; color:var(--ink-700) !important; font-weight:700 !important; text-align:left; }
.sid-table-pager { display:flex; align-items:center; gap:.6rem; padding:0 1.1rem 1rem; color:var(--ink-300); font-size:.76rem; }
.sid-table-pager .button.small { padding:.28rem .6rem; font-size:.74rem; }

.report-dashboard-strip { display:grid; grid-template-columns:repeat(auto-fit,minmax(220px,1fr)); gap:.85rem; margin:.75rem 0; }
.report-dashboard-card { display:flex; flex-direction:column; gap:.3rem; padding:1rem 1.1rem; border:1px solid var(--line-strong); border-radius:10px; background:linear-gradient(110deg,var(--brand-50),var(--surface-1)); color:var(--ink-800); text-decoration:none; transition:transform .15s ease,box-shadow .15s ease; }
.report-dashboard-card:hover, .report-dashboard-card:focus-visible { transform:translateY(-1px); box-shadow:var(--shadow-raise); outline:none; }
.report-dashboard-card span { color:var(--ink-500); font-size:.83rem; line-height:1.35; }

html.theme-dark .sid-filter-bar,
html.theme-dark .sid-kpi,
html.theme-dark .sid-panel,
html.theme-dark .sid-meta-action,
html.theme-dark .sid-owner-menu { background:var(--crm-surface); border-color:var(--crm-line); color:var(--crm-text); }
html.theme-dark .sid-header h1,
html.theme-dark .sid-kpi-title,
html.theme-dark .sid-panel-head h2 { color:var(--crm-text); }
/* The blanket `html.theme-dark a` rule below outranks
   `.sid-kpi-title a { color: inherit }` on specificity, so every KPI
   heading turned link-blue in dark mode. */
html.theme-dark .sid-kpi-title a { color:inherit; }
html.theme-dark .sid-kpi-foot { border-top-color:var(--crm-line); }
html.theme-dark .sid-panel .dashboard-table table,
html.theme-dark .sid-panel .dashboard-table th,
html.theme-dark .sid-panel .dashboard-table td { border-color:var(--crm-line); }
html.theme-dark .sid-panel .dashboard-table th { background:var(--crm-surface-raised); color:var(--crm-muted); }
html.theme-dark .sid-group-row th { background:var(--crm-surface) !important; color:var(--crm-text) !important; }
html.theme-dark .sid-tabs { border-bottom-color:var(--crm-line); }
html.theme-dark .sid-tabs a { color:var(--crm-muted); }
html.theme-dark .sid-tabs a:hover, html.theme-dark .sid-tabs a.active { background:var(--crm-surface-raised); color:var(--brand-400); }
html.theme-dark .sid-loading strong { color:var(--crm-text); }
/* No dark override for .sid-kpi-figure on purpose: its colour comes
   from the --data-* tokens via the tone classes, which already have
   dark variants. Forcing --crm-text here turned every figure white and
   threw away the won / in-progress / lost meaning. */
html.theme-dark .sid-filter-control { background:var(--crm-surface-raised); color:var(--crm-text); border-color:var(--crm-line); }
html.theme-dark .report-dashboard-card { background:var(--crm-surface); border-color:var(--crm-line); color:var(--crm-text); }

@media (max-width:1100px) { .sid-panel.wide { grid-column:span 1; } }
@media (max-width:700px) { .sid { padding:.75rem; } .sid-header { flex-direction:column; align-items:flex-start; gap:.4rem; } }
.report-search { display:flex; gap:.55rem; align-items:center; flex:1; max-width:480px; border:1px solid var(--line); border-radius:5px; padding:0 .7rem; color:var(--muted); }
.report-search input { width:100%; border:0; outline:0; padding:.56rem 0; background:transparent; }
.report-library-toolbar select { min-width:150px; }
.report-count { color:var(--muted); font-size:.875rem; white-space:nowrap; }
.report-library-body { display:grid; grid-template-columns:210px minmax(0, 1fr); min-height:470px; background:var(--surface-1); border:1px solid var(--line); border-radius:0 0 10px 10px; overflow:hidden; }
.report-library-nav { padding:1rem 0; border-right:1px solid var(--line); background:var(--surface-2); }
.report-library-nav p { margin:.3rem 1rem .45rem; color:var(--ink-400); font-size:.7rem; font-weight:700; letter-spacing:.07em; }
.report-table-head button { border:0; background:transparent; color:inherit; font:inherit; font-weight:700; letter-spacing:inherit; text-align:left; padding:0; cursor:pointer; }
.report-table-head button:hover { color:var(--brand-600); }
.report-library-nav button { width:100%; text-align:left; padding:.55rem 1rem; border:0; background:transparent; color:var(--ink-700); font-size:.9rem; }
.report-library-nav button:hover, .report-library-nav button.active { background:var(--brand-100); color:var(--brand-600); font-weight:600; }
.report-library-nav .report-starter-install { color:var(--crm-primary,var(--brand-600)); font-weight:600; border:1px dashed var(--line-strong); background:var(--surface-3); }
.report-library-nav .report-starter-install:hover:not(:disabled) { background:var(--brand-100); border-color:var(--brand-600); }
.report-library-nav .report-starter-install:disabled { opacity:.65; cursor:wait; }
.report-starter-message { margin:.35rem 1rem .5rem; color:var(--ink-500); font-size:.75rem; line-height:1.35; }
.report-library-main { min-width:0; }
.report-table-head, .report-row { display:grid; grid-template-columns:minmax(260px,2.25fr) minmax(120px,.9fr) minmax(120px,.9fr) 100px minmax(190px,1.3fr); gap:1rem; align-items:center; }
.report-table-head { padding:.8rem 1.25rem; border-bottom:1px solid var(--line); color:var(--ink-400); font-size:.7rem; font-weight:700; letter-spacing:.04em; }
.report-row { padding:1rem 1.25rem; border-bottom:1px solid var(--line-soft); font-size:.875rem; color:var(--ink-500); }
.report-row:hover { background:var(--surface-2); }
.report-name { border:0; background:transparent; padding:0; color:var(--brand-600); font-size:.94rem; font-weight:600; text-align:left; }
.report-name:hover { text-decoration:underline; }
.report-row p { margin:.25rem 0 0; color:var(--ink-400); font-size:.78rem; line-height:1.35; }
.report-folder { display:inline-flex; width:max-content; background:var(--surface-3); color:var(--ink-500); border-radius:12px; padding:.22rem .55rem; font-size:.75rem; }
.report-actions { display:flex; justify-content:flex-end; gap:.25rem; }
.report-actions button { border:0; background:transparent; color:var(--brand-600); font-size:.78rem; padding:.25rem; }
.report-actions button.danger { color:var(--error-text); }
.report-empty { text-align:center; padding:4.5rem 1.5rem; color:var(--muted); }
.report-empty h2 { margin:.8rem 0 .3rem; color:var(--text); font-size:1.08rem; }.report-empty p { margin:0 0 1.25rem; }.report-empty-icon { display:inline-flex; width:42px; height:42px; align-items:center; justify-content:center; border-radius:50%; background:var(--brand-100); color:var(--brand-600); font-size:1.4rem; }
.report-result { background:var(--surface-1); border:1px solid var(--line); border-radius:10px; padding:1.5rem; }
.report-result > header { border-bottom:1px solid var(--line); padding-bottom:1.2rem; }.report-result > header > div:last-child { display:flex; gap:.6rem; }.back-link { border:0; background:transparent; color:var(--brand-600); padding:0; margin-bottom:.5rem; }.report-result-meta { display:flex; gap:1.25rem; color:var(--ink-500); font-size:.85rem; padding:1rem 0; }.report-result-meta span:not(:last-child)::after { content:""; border-right:1px solid var(--line); margin-left:1.25rem; }
.report-data-table { width:100%; border-collapse:collapse; font-size:.9rem; }.report-data-table th { background:var(--surface-2); padding:.7rem .85rem; color:var(--ink-500); font-size:.72rem; letter-spacing:.03em; text-align:left; }.report-data-table td { padding:.75rem .85rem; border-bottom:1px solid var(--line-soft); color:var(--ink-700); }
.report-view-tabs { display:flex; gap:1rem; border-bottom:1px solid var(--line); margin-bottom:1.35rem; }.report-view-tabs button { padding:.55rem .2rem; border:0; border-bottom:2px solid transparent; background:transparent; color:var(--ink-500); font-weight:600; }.report-view-tabs button.active { color:var(--brand-600); border-bottom-color:var(--brand-600); }.report-bars { padding:.5rem .5rem 1.1rem; max-width:850px; }.report-bar-row { display:grid; grid-template-columns:180px minmax(120px,1fr) 45px; gap:.8rem; align-items:center; margin:.85rem 0; color:var(--ink-600); font-size:.86rem; }.report-bar-row > span { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; text-align:right; }.report-bar-row > div { height:22px; background:var(--surface-3); border-radius:4px; overflow:hidden; }.report-bar-row i { display:block; height:100%; min-width:5px; background:linear-gradient(90deg,var(--brand-600),var(--brand-400)); border-radius:4px; }.report-bar-row strong { color:var(--ink-800); font-size:.82rem; }.report-donut-layout { display:flex; align-items:center; justify-content:center; gap:3rem; padding:1.5rem 1rem; }.report-donut { position:relative; width:230px; height:230px; border-radius:50%; display:grid; place-items:center; }.report-donut::after { content:""; position:absolute; width:138px; height:138px; border-radius:50%; background:var(--surface-1); }.report-donut span { position:relative; z-index:1; text-align:center; color:var(--ink-800); font-size:1.5rem; font-weight:700; line-height:1.1; }.report-donut small { color:var(--ink-400); font-size:.75rem; font-weight:500; }.report-chart-legend { min-width:240px; max-width:380px; }.report-chart-legend div { display:grid; grid-template-columns:12px 1fr auto; gap:.55rem; align-items:center; padding:.43rem 0; border-bottom:1px solid var(--line-soft); color:var(--ink-500); font-size:.85rem; }.report-chart-legend i { width:10px; height:10px; border-radius:2px; }.report-chart-legend strong { color:var(--ink-800); }
.report-step { color:var(--brand-600); font-size:.72rem; font-weight:700; letter-spacing:.07em; margin-bottom:.5rem; }.report-create-step { width:min(510px, calc(100vw - 2rem)); }.report-create-step h3, .report-builder h3 { margin:0 0 .45rem; font-size:1rem; }.modal.report-builder { width:min(1040px, calc(100vw - 2rem)); max-width:min(1040px, calc(100vw - 2rem)); min-width:0; max-height:calc(100vh - 2rem); overflow:auto; resize:both; }.report-builder-grid { display:grid; grid-template-columns:minmax(0, .9fr) minmax(0, 1.4fr); gap:1.75rem; border-top:1px solid var(--line); border-bottom:1px solid var(--line); padding:1.25rem 0; }.report-builder-grid > section { min-width:0; }.report-builder-grid > section + section { border-left:1px solid var(--line); padding-left:1.75rem; }.report-builder label, .report-create-step label { display:block; margin:.7rem 0 .3rem; font-size:.8rem; color:var(--ink-600); font-weight:600; }.report-builder input:not([type=checkbox]), .report-builder textarea, .report-builder select, .report-create-step input, .report-create-step select { width:100%; min-width:0; min-height:2.5rem; padding:.55rem .7rem; border:1px solid var(--border); border-radius:5px; background:var(--surface-1); color:var(--text); font:inherit; }.report-builder textarea { resize:vertical; }.report-builder .report-name-input { min-height:3rem; font-size:1.05rem; border-color:var(--line-strong); box-shadow:0 0 0 2px var(--brand-100); }.report-builder .required { color:var(--error-text); }.report-fields { display:grid; grid-template-columns:1fr 1fr; gap:.2rem .75rem; }.report-field { font-weight:400!important; color:var(--ink-700)!important; margin:.15rem 0!important; }.report-field input { width:auto; margin-right:.25rem; }.report-date-row { display:grid; grid-template-columns:1fr 1fr; gap:.75rem; }
@media (max-width: 800px) { .report-dashboard-callout { align-items:flex-start; flex-direction:column; }.report-library-body { grid-template-columns:1fr; }.report-library-nav { display:flex; gap:.2rem; overflow:auto; border-right:0; border-bottom:1px solid var(--line); padding:.45rem; }.report-library-nav p { display:none; }.report-library-nav button { width:auto; white-space:nowrap; }.report-table-head { display:none; }.report-row { grid-template-columns:1fr; gap:.45rem; }.report-actions { justify-content:flex-start; }.report-library-toolbar { flex-wrap:wrap; }.report-builder-grid { grid-template-columns:1fr; }.report-builder-grid > section + section { border-left:0; border-top:1px solid var(--line); padding:1rem 0 0; }.report-library-header, .report-result > header { flex-direction:column; }.report-result > header > div:last-child { width:100%; }.report-result > header > div:last-child .button { flex:1; } }

/* --- calendar ----------------------------------------------------------
   Mark spec, kept consistent with the rest of the app's badge/pill
   language rather than inventing a new one: task items get the same
   neutral chip as the Hotlist priority badge, appointments get the
   blue used for the "contact" badge elsewhere -- identity by fixed
   colour per type, not per record. */
.calendar-toolbar { display: flex; gap: .5rem; margin: 0 0 1.25rem; }

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 1px;
    background: var(--border);
    border: 1px solid var(--border);
    border-radius: 6px;
    overflow: hidden;
}

.calendar-weekday {
    background:var(--surface-2);
    color: var(--muted);
    font-size: .75rem;
    text-transform: uppercase;
    letter-spacing: .02em;
    text-align: center;
    padding: .5rem 0;
}

.calendar-day {
    background: var(--surface);
    min-height: 6.5rem;
    padding: .375rem;
    display: flex;
    flex-direction: column;
    gap: .25rem;
}
.calendar-day-outside { background:var(--surface-2); }
.calendar-day-outside .calendar-day-number { color: var(--muted); }
.calendar-day-today { box-shadow: inset 0 0 0 2px var(--accent); }
.calendar-day-today .calendar-day-number { color: var(--accent); }

.calendar-day-header { display: flex; justify-content: space-between; align-items: center; }
.calendar-day-number { font-size: .8125rem; font-weight: 600; }

.calendar-day-add {
    background: none; border: 0; color: var(--muted); cursor: pointer;
    font-size: .9375rem; line-height: 1; padding: 0 .25rem; visibility: hidden;
}
.calendar-day:hover .calendar-day-add { visibility: visible; }
.calendar-day-add:hover { color: var(--accent); }

.calendar-day-items { display: flex; flex-direction: column; gap: .125rem; overflow: hidden; }

.calendar-item {
    display: flex; align-items: baseline; gap: .25rem;
    padding: .0625rem .25rem; border-radius: 3px; font-size: .75rem;
    cursor: pointer; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
}
.calendar-item-task { background:var(--surface-2); color: var(--text); }
.calendar-item-appointment { background:var(--brand-100); color:var(--brand-600); }
.calendar-item-done { opacity: .55; text-decoration: line-through; }
.calendar-item-time { font-weight: 600; flex-shrink: 0; }
.calendar-item-subject { overflow: hidden; text-overflow: ellipsis; }
.calendar-item:hover { filter: brightness(0.95); }

.calendar-more { padding: 0 .25rem; }
.sales-inbox-page .module-page-header { margin-bottom:1rem; }
.email-inbox-toolbar { display:flex; gap:.6rem; align-items:center; margin:0 0 .75rem; }
.email-inbox-toolbar input { flex:1; min-width:12rem; border:1px solid var(--border); border-radius:.45rem; padding:.65rem .8rem; background:var(--surface); color:var(--text); }
.email-inbox-toolbar select { min-height:2.45rem; border:1px solid var(--border); border-radius:.45rem; padding:.35rem .65rem; background:var(--surface); color:var(--text); }
.email-inbox { display:grid; grid-template-columns:minmax(18rem,30rem) minmax(0,1fr); min-height:34rem; border:1px solid var(--border); border-radius:.65rem; overflow:hidden; background:var(--surface); box-shadow:0 6px 20px rgba(20,30,80,.06); }
.email-thread-list { display:flex; flex-direction:column; overflow:auto; border-right:1px solid var(--border); background:var(--surface-2); }
.email-thread { display:flex; flex-direction:column; gap:.25rem; width:100%; border:0; border-bottom:1px solid var(--border); padding:.8rem 1rem; text-align:left; background:transparent; color:var(--text); cursor:pointer; }
.email-thread:hover,.email-thread.selected { background:var(--brand-100); }
.email-thread strong { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; color:var(--text-strong,var(--text)); }
.email-thread span,.email-thread small { color:var(--muted); font-size:.8rem; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.email-conversation { min-width:0; padding:1.25rem; overflow:auto; }
.email-conversation > .mud-typography-h5 { margin-bottom:.2rem; }
.email-message { margin-top:1rem; padding:1rem; border:1px solid var(--border); border-radius:.55rem; background:var(--surface); }
.email-message > div { display:flex; justify-content:space-between; gap:1rem; padding-bottom:.55rem; border-bottom:1px solid var(--border); }
.email-message small { color:var(--muted); white-space:nowrap; }.email-message p { white-space:pre-wrap; line-height:1.55; margin:.8rem 0 0; }
.mail-folder-tabs{display:flex;gap:.25rem;margin-bottom:.7rem;border-bottom:1px solid var(--border)}
.mail-folder-tabs button{border:0;background:transparent;padding:.65rem 1rem;color:var(--muted);font-weight:650;cursor:pointer;border-bottom:3px solid transparent}
.mail-folder-tabs button.active{color:var(--brand-600);border-bottom-color:var(--brand-500)}
.email-conversation-header{display:flex;align-items:flex-start;justify-content:space-between;gap:1rem;padding-bottom:1rem;border-bottom:1px solid var(--border)}
.email-conversation-header h2{margin:0 0 .2rem}.email-conversation-header span{color:var(--muted)}.email-header-actions{display:flex;gap:.5rem}
.email-message header{display:grid;grid-template-columns:auto minmax(0,1fr) auto;align-items:center;gap:.7rem;padding-bottom:.65rem;border-bottom:1px solid var(--border)}
.email-message header>div:nth-child(2){display:flex;flex-direction:column}.email-message h3{font-size:1rem;margin:.8rem 0 .3rem}.email-message header small{white-space:normal}
.mail-direction{font-size:.72rem;font-weight:750;border-radius:999px;padding:.25rem .5rem}.mail-direction.inbound{background:#e5f7ef;color:#08775b}.mail-direction.outbound{background:#eeeaff;color:#5c45c7}
.message-actions{display:flex!important;flex-direction:row!important;align-items:center;gap:.55rem}.message-actions a,.message-actions button{border:0;background:transparent;color:var(--brand-600);font:inherit;font-weight:650;cursor:pointer}.filed-badge{font-size:.72rem;color:#08775b;background:#e5f7ef;border-radius:999px;padding:.25rem .5rem}
.message-attachments{display:flex;flex-wrap:wrap;gap:.45rem;margin-top:.8rem}.message-attachments span{font-size:.8rem;padding:.35rem .55rem;border:1px solid var(--border);border-radius:.4rem;background:var(--surface-2)}
.email-thread em{font-style:normal;color:#08775b;background:#e5f7ef;border-radius:999px;padding:.1rem .35rem;margin-left:.35rem}
.email-filing-dialog{width:min(46rem,calc(100vw - 2rem));max-width:none;padding:0;overflow:hidden}.email-filing-dialog>header{display:flex;justify-content:space-between;gap:1rem;padding:1.25rem 1.4rem;background:linear-gradient(135deg,#f0edff,#f8fbff);border-bottom:1px solid var(--border)}
.email-filing-dialog h2{margin:0}.email-filing-dialog header p{margin:.25rem 0 0;color:var(--muted)}.email-filing-dialog>label{display:block;font-weight:700;margin:1.2rem 1.4rem .45rem}
.record-search-box{display:flex;align-items:center;gap:.5rem;margin:0 1.4rem;border:1px solid var(--brand-300);border-radius:.6rem;padding:0 .75rem;background:var(--surface)}.record-search-box input{width:100%;border:0;outline:0;padding:.75rem 0;background:transparent;color:var(--text)}
.email-record-results{max-height:20rem;overflow:auto;margin:.75rem 1.4rem;border:1px solid var(--border);border-radius:.6rem}.email-record-results button{display:grid;grid-template-columns:6.5rem minmax(0,1fr) auto;align-items:center;gap:.75rem;width:100%;padding:.7rem;border:0;border-bottom:1px solid var(--border);background:var(--surface);text-align:left;color:var(--text);cursor:pointer}.email-record-results button:hover{background:var(--brand-100)}.email-record-results button>span:nth-child(2){display:flex;flex-direction:column}.email-record-results small{color:var(--muted)}
.record-kind{display:inline-flex;justify-content:center;border-radius:999px;padding:.2rem .45rem;font-size:.72rem;font-weight:750;background:var(--surface-2)}.record-kind.company{color:#08775b}.record-kind.person{color:#6a43c7}.record-kind.case{color:#bd3f62}.record-kind.opportunity{color:#0875a5}.record-kind.lead{color:#b15814}
.no-record-match{display:flex;flex-direction:column;margin:.8rem 1.4rem;padding:1rem;border-radius:.55rem;background:var(--surface-2)}.no-record-match span{color:var(--muted)}.create-record-strip{display:flex;flex-wrap:wrap;gap:.55rem;align-items:center;margin:1rem 1.4rem;padding-top:1rem;border-top:1px solid var(--border)}.create-record-strip a{font-weight:650}.email-filing-dialog footer{display:flex;justify-content:flex-end;padding:.8rem 1.4rem;border-top:1px solid var(--border)}
.email-interactions-panel{border:1px solid var(--border);border-radius:.75rem;background:var(--surface);overflow:hidden}.interaction-panel-heading{display:flex;justify-content:space-between;align-items:center;padding:1.1rem 1.25rem;background:linear-gradient(90deg,#f0edff,#f2fbf8)}.interaction-panel-heading h2{margin:0}.interaction-panel-heading p{margin:.2rem 0 0;color:var(--muted)}
.interaction-list{display:flex;flex-direction:column}.interaction-row{display:grid;grid-template-columns:2rem minmax(0,1fr) 11rem;gap:.8rem;align-items:center;border:0;border-bottom:1px solid var(--border);background:var(--surface);padding:.85rem 1.1rem;text-align:left;color:var(--text);cursor:pointer}.interaction-row:hover{background:var(--surface-2)}.interaction-row>span:nth-child(2),.interaction-meta{display:flex;flex-direction:column}.interaction-row small{color:var(--muted)}.interaction-meta{text-align:right}.interaction-direction{display:grid;place-items:center;width:1.8rem;height:1.8rem;border-radius:50%;font-weight:800}.interaction-direction.inbound{background:#e5f7ef;color:#08775b}.interaction-direction.outbound{background:#eeeaff;color:#5c45c7}
.email-viewer{width:min(62rem,calc(100vw - 2rem));max-width:none;max-height:88vh;overflow:auto;padding:0}.email-viewer-actions{display:flex;gap:.5rem;align-items:center;padding:.7rem 1rem;background:#394257}.email-viewer-actions .icon-button{margin-left:auto;color:white}.email-viewer>h2{padding:1rem 1.25rem;margin:0;border-bottom:1px solid var(--border)}.email-headers{display:grid;grid-template-columns:4rem 1fr;gap:.35rem .75rem;padding:1rem 1.25rem;margin:0;border-bottom:1px solid var(--border)}.email-headers dt{font-weight:700}.email-headers dd{margin:0}.email-viewer-body{padding:1.25rem;white-space:pre-wrap;line-height:1.55;min-height:12rem}.email-attachments{display:flex;flex-wrap:wrap;gap:.6rem;padding:1rem 1.25rem;border-top:1px solid var(--border)}.email-attachments strong{width:100%}.email-attachments a{padding:.45rem .65rem;border:1px solid var(--border);border-radius:.45rem;background:var(--surface-2)}
@media (max-width:850px) { .email-inbox { grid-template-columns:1fr; }.email-thread-list { max-height:20rem; border-right:0; border-bottom:1px solid var(--border); }.email-inbox-toolbar { align-items:stretch; flex-direction:column; } }
.calendar-toolbar { display:flex; justify-content:space-between; align-items:center; gap:1rem; margin:0 0 1rem; }
.calendar-nav,.calendar-view-switch { display:flex; gap:.35rem; align-items:center; }
.calendar-agenda { display:flex; flex-direction:column; gap:.5rem; }
.calendar-agenda-day { display:grid; grid-template-columns:10rem 1fr; min-height:4.75rem; border:1px solid var(--border); border-radius:.5rem; background:var(--surface); overflow:hidden; }
.calendar-agenda-date { display:flex; align-items:center; gap:.5rem; padding:.75rem 1rem; background:var(--surface-2); color:var(--text); }
.calendar-agenda-date span { color:var(--muted); }
.calendar-agenda-items { display:flex; flex-wrap:wrap; align-content:center; gap:.35rem; padding:.6rem .75rem; }
.calendar-access-card { max-width:70rem; background:var(--surface); border:1px solid var(--border); border-radius:.75rem; padding:1.5rem; box-shadow:0 8px 24px rgba(20,30,80,.08); }
.calendar-access-columns { display:grid; grid-template-columns:1fr 1fr; gap:1rem; margin:1.25rem 0 1.5rem; }
.calendar-access-columns>div { border:1px solid var(--border); border-radius:.6rem; padding:1rem; background:var(--surface-2); }
.calendar-access-card h3,.calendar-access-card h4 { margin:.1rem 0 .5rem; }
.access-public { display:flex; align-items:center; gap:.5rem; font-weight:600; }
.calendar-principal-list { border:1px solid var(--border); border-radius:.5rem; overflow:hidden; margin:.75rem 0 1.5rem; }
.calendar-principal { display:grid; grid-template-columns:1fr 10rem 10rem; align-items:center; gap:1rem; padding:.65rem .8rem; border-bottom:1px solid var(--border); }
.calendar-principal:last-child { border-bottom:0; }
.calendar-principal span { display:flex; flex-direction:column; }.calendar-principal small { color:var(--muted); text-transform:capitalize; }
.calendar-defaults { display:flex; flex-wrap:wrap; gap:1rem; align-items:end; padding-top:1rem; border-top:1px solid var(--border); }.calendar-defaults label { display:flex; flex-direction:column; gap:.3rem; }
.calendar-defaults select,.calendar-defaults input { min-height:2.25rem; border:1px solid var(--border); border-radius:.35rem; padding:.3rem .5rem; }
.form-actions { display:flex; justify-content:flex-end; gap:.6rem; margin-top:1.5rem; }
@media (max-width:700px) { .calendar-access-columns,.calendar-principal { grid-template-columns:1fr; }.calendar-toolbar { align-items:flex-start; flex-direction:column; }.calendar-agenda-day { grid-template-columns:1fr; } }

@media (max-width: 640px) {
    .calendar-day { min-height: 4rem; }
    .calendar-weekday { font-size: .625rem; }
}

/* --- record read view (RecordFieldGrid.razor) ------------------------
   Zoho's Overview tab: a two-column label/value grid, label right-
   aligned against its value so the eye has a single seam to scan down
   rather than a ragged left edge. Two pairs per row on a wide screen,
   one on a narrow one -- the fields themselves are short, so a single
   column wastes most of the width the layout rework just freed up. */
.record-view .field-grid {
    display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: .125rem 2.5rem; margin: 0 0 .5rem;
}
@media (max-width: 700px) { .record-view .field-grid { grid-template-columns: minmax(0, 1fr); } }

.record-view .field-grid-row {
    display: grid; grid-template-columns: minmax(6rem, 10rem) minmax(0, 1fr);
    gap: 1rem; align-items: baseline; padding: .5rem .6rem;
    border-bottom:1px solid var(--line-soft); border-radius:var(--radius-sm);
    transition:background-color .15s ease;
}
.record-view .field-grid-row:hover { background:var(--field-accent-soft); }
.record-view dt { text-align: right; font-size: .8125rem; color: var(--field-label); }
.record-view dd { margin: 0; font-size: .9375rem; color: var(--text); overflow-wrap: anywhere; font-weight:500; }
/* The global .empty class is a large empty-state card. A missing property
   in a record overview is only a value placeholder and must not inherit
   that card's padding/border (the old rule created giant dashed boxes). */
.record-view dd.empty {
    color: var(--ink-300);
    background: transparent;
    border: 0;
    border-radius: 0;
    padding: 0;
    text-align: left;
}
.record-view dd a { color: var(--accent); text-decoration: none; }
.record-view dd a:hover { text-decoration: underline; }

/* The read view carries its own section rhythm -- .detail-form's h2
   rule assumes a form's taller field spacing above it. */
.record-view h2 { margin-top: 1.5rem; padding-top: 1rem; }
.record-view h2:first-child { margin-top: 0; padding-top: 0; }
.layout-admin-grid { display:grid; grid-template-columns:minmax(0,1fr) minmax(22rem, .8fr); gap:1rem; align-items:start; }
.layout-list { display:grid; gap:.5rem; }
.layout-list-item { display:flex; justify-content:space-between; align-items:center; gap:.75rem; padding:.75rem; border:1px solid var(--line); border-radius:8px; background:var(--surface-1); }
.layout-list-item > div:first-child { display:grid; gap:.2rem; }
.layout-list-actions { display:flex; align-items:center; gap:.5rem; flex-wrap:wrap; justify-content:flex-end; }
.layout-assignment { display:grid; grid-template-columns:minmax(0,1fr) minmax(10rem, 15rem); gap:.75rem; align-items:center; padding:.5rem 0; border-bottom:1px solid var(--line-soft); }
.layout-assignment select { width:100%; }
.layout-section-editor { border:1px solid var(--line); border-radius:8px; padding:.75rem; margin:.75rem 0; background:var(--surface-1); }
.layout-section-editor h3 { margin:0 0 .5rem; font-size:.9rem; color:var(--ink-800); }
.layout-field-check { justify-content:flex-start; padding:.25rem 0; }
.form-actions { display:flex; gap:.6rem; margin-top:1rem; }
@media (max-width: 900px) { .layout-admin-grid { grid-template-columns:1fr; } }
.workqueue-view-settings { display:flex; flex-wrap:wrap; align-items:center; gap:.75rem 1rem; margin-top:.65rem; padding:.7rem 1rem; background:var(--surface-1); border:1px solid var(--line); border-radius:8px; color:var(--ink-600); font-size:.85rem; }.workqueue-view-settings label { display:flex; align-items:center; gap:.3rem; }
.workqueue-link { display:flex; justify-content:space-between; align-items:center; width:100%; box-sizing:border-box; padding:.65rem .55rem; background:transparent; border:0; border-radius:6px; font:inherit; text-align:left; cursor:pointer; color:var(--ink-800); }
.workqueue-link:hover,.workqueue-link.active { background:var(--brand-100); color:var(--brand-500); }
.workqueue-table { margin-top:1rem; background:var(--surface-1); border:1px solid var(--line); border-radius:10px; }
.workqueue-actions { display:flex; align-items:center; gap:.65rem; }.workqueue-actions input { min-width:13rem; padding:.5rem .7rem; border:1px solid var(--line-strong); border-radius:6px; font:inherit; }
.workqueue-module-link-bar { display:flex; justify-content:space-between; align-items:center; gap:.75rem; margin-top:.65rem; padding:.55rem .8rem; background:var(--brand-100); border:1px solid var(--line-strong); border-radius:8px; color:var(--ink-600); font-size:.82rem; }.workqueue-module-link-bar a { color:var(--brand-600); font-weight:600; text-decoration:none; }.workqueue-module-link-bar a:hover { text-decoration:underline; }
.workqueue-pagination,.report-pagination { display:flex; align-items:center; justify-content:flex-end; gap:.75rem; padding:.75rem 1rem; color:var(--ink-400); font-size:.85rem; background:var(--surface-1); border:1px solid var(--line); border-top:0; border-radius:0 0 10px 10px; }.workqueue-pagination label,.report-pagination label { display:flex; align-items:center; gap:.35rem; }.workqueue-pagination select,.report-pagination select { padding:.35rem .5rem; border:1px solid var(--line-strong); border-radius:5px; background:var(--surface-1); }
.table-sort-button { border:0; background:transparent; padding:0; color:inherit; font:inherit; font-weight:600; cursor:pointer; text-align:left; }.table-sort-button:hover { color:var(--brand-600); }
@media (max-width: 900px) { .workqueue-page { grid-template-columns:1fr; } .workqueue-sidebar { display:flex; flex-wrap:wrap; gap:.35rem; } .workqueue-sidebar h2,.workqueue-sidebar h3,.workqueue-sidebar hr,.workqueue-sidebar select { width:100%; } .workqueue-actions { flex-wrap:wrap; } .workqueue-actions input { min-width:0; flex:1 1 12rem; } }
/* Additional report visualisations */
.report-line-chart { padding:1.25rem 1rem 1rem; max-width:900px; }
.report-line-chart svg { display:block; width:100%; height:260px; overflow:visible; background:linear-gradient(to bottom,transparent 24%,var(--surface-3) 25%,transparent 26%,transparent 49%,var(--surface-3) 50%,transparent 51%,transparent 74%,var(--surface-3) 75%,transparent 76%); border-bottom:1px solid var(--line); }
.report-line-labels { display:grid; grid-template-columns:repeat(auto-fit,minmax(0,1fr)); gap:.4rem; margin-top:.65rem; color:var(--ink-500); font-size:.75rem; text-align:center; }
.report-line-labels span { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.report-funnel-chart { display:flex; flex-direction:column; align-items:center; gap:4px; padding:1.25rem 1rem 1.5rem; }
.report-funnel-segment { display:flex; justify-content:space-between; align-items:center; gap:1rem; min-width:24%; padding:.7rem 1rem; color:var(--on-accent); clip-path:polygon(3% 0,97% 0,90% 100%,10% 100%); font-size:.82rem; transition:width .2s ease; }
.report-funnel-segment span { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.report-funnel-segment strong { flex:0 0 auto; }
.dashboard-customize { display:flex; flex-wrap:wrap; align-items:center; gap:.65rem 1rem; margin-bottom:1rem; padding:.75rem 1rem; background:var(--surface-1); border:1px solid var(--line); border-radius:10px; color:var(--ink-600); font-size:.82rem; }
.dashboard-customize label { display:flex; align-items:center; gap:.35rem; }
/* Report condition editor layout */
.report-condition-row { display:grid; grid-template-columns:minmax(0,1fr) minmax(0,.9fr) minmax(0,1.2fr) auto; gap:.45rem; align-items:center; margin:.45rem 0; }
.report-condition-row input:disabled { background:var(--surface-2); color:var(--ink-400); }
.report-condition-row .button { min-height:2.5rem; padding:.45rem .65rem; }
.report-condition-draft { border-top:1px dashed var(--line); padding-top:.55rem; margin-top:.65rem; }
@media (max-width:800px) {
  .report-condition-row { grid-template-columns:1fr 1fr; }
  .report-condition-row input { grid-column:1 / -1; }
  .report-condition-row .button { justify-self:start; }
}
.report-truncated-warning, .workqueue-truncated { color:var(--warning); background:var(--warning-bg); border:1px solid var(--warning-line); border-radius:5px; padding:.35rem .55rem; font-size:.78rem; }
.workqueue-truncated { margin-top:.65rem; }
.layout-error { max-width:40rem; margin:4rem auto; padding:2.5rem; background:var(--mud-palette-surface,var(--surface-1)); border:1px solid var(--mud-palette-lines-default,var(--line)); border-radius:12px; text-align:center; box-shadow:var(--shadow-md); }.layout-error h1 { margin:0 0 .75rem; color:var(--mud-palette-text-primary,var(--ink-800)); }.layout-error p { margin:0 0 1.5rem; color:var(--mud-palette-text-secondary,var(--ink-400)); }

/* --- app chrome density ----------------------------------------------
   Measured against Maximizer's own shell (2026-09-04) because "the app
   looks amateur" turned out to be mostly this: our chrome was
   systematically bigger and heavier than the reference, so it competed
   with the data instead of receding behind it.

       reference   before   after
   top bar      38px     65px     48px
   rail width  207px    240px    208px
   nav row      36px     42px     36px
   nav label 14px/400 15px/500 14px/400
   nav icon     ~16px     24px     20px

   Not matched to 38px exactly: this bar carries a search field and
   MudBlazor's own 40px controls, which 38px cannot hold without
   clipping them. 48px is the smallest height that fits the controls we
   actually have, and it is the number the rest of the layout keys off
   via --mud-appbar-height. --------------------------------------------- */
.mud-appbar { --mud-appbar-height: 48px; min-height: 48px; height: 48px; }
.mud-appbar .mud-toolbar { min-height: 48px; height: 48px; }
.mud-layout { --mud-appbar-height: 48px; }

/* The rail. MudBlazor's 240px default was never chosen, just inherited
   (see the collapse block above). 208px matches the reference and hands
   32px back to the content on every page. */
.mud-layout:not(:has(.nav-collapsed)) { --mud-drawer-width-left: 208px; }
.mud-drawer:not(:has(.nav-collapsed)) { width: 208px !important; }

.mud-drawer .mud-nav-link,
.mud-drawer .mud-navgroup .mud-nav-link {
    min-height: 36px; height: 36px;
    padding-top: 0; padding-bottom: 0;
    font-size: var(--text-md);
}
/* 400, not 500. A whole rail set in medium reads as twenty competing
   headings; the active item carries the emphasis instead. */
.mud-drawer .mud-navgroup .mud-nav-link-text,
.mud-drawer .mud-nav-link-text { font-weight: 400; font-size: var(--text-md); }
.mud-drawer .mud-nav-link.active .mud-nav-link-text,
.mud-drawer a.active .mud-nav-link-text { font-weight: 600; }

.mud-drawer .mud-nav-link .mud-icon-root,
.mud-drawer .mud-navgroup .mud-icon-root { font-size: 20px; width: 20px; height: 20px; }

/* Quieter at rest so the active item is the only thing that stands out. */
.mud-drawer .mud-nav-link,
.mud-drawer .mud-navgroup .mud-nav-link,
.mud-drawer .mud-nav-link .mud-icon-root,
.mud-drawer .mud-navgroup .mud-icon-root { color: rgba(247,249,255,.72) !important; }

/* The wordmark should read as a label, not a headline. */
.mud-appbar .mud-typography-h6 { font-size: var(--text-xl); font-weight: 600; letter-spacing: -.01em; }

/* MudButton uppercases its label by default, which made the two quietest
   controls in the app -- the user's own name and Sign out -- read as
   SHOUTING in the corner of every page. They are wayfinding, not calls
   to action. */
.mud-appbar .mud-button-root { text-transform: none; letter-spacing: 0; }

/* The "Rows" page-size control on list toolbars -- a label stacked over a
   native select, matching SavedViewsBar's own filter. */
.list-rows { display: inline-flex; flex-direction: column; gap: 2px; flex: 0 0 auto;
    font-size: var(--text-2xs); color: var(--ink-400); text-transform: uppercase; letter-spacing: .04em; }
.list-rows select { min-width: 5rem; padding: .34rem .5rem; font-size: var(--text-md);
    border: 1px solid var(--line-strong); border-radius: var(--radius-md);
    background: var(--surface-1); color: var(--ink-800); font-family: inherit;
    text-transform: none; letter-spacing: 0; }

/* --- list-page filter rail (ListFilterPanel) ------------------------
   Zoho's own list layout: a persistent filter panel down the left, the
   results to its right. The panel is toggled from the toolbar and its
   open state is remembered per module. */
.list-shell { display: block; }
.list-shell.with-filter { display: grid; grid-template-columns: 264px minmax(0, 1fr); gap: var(--space-4); align-items: start; }
.list-main { min-width: 0; }

.list-filter { position: sticky; top: calc(var(--mud-appbar-height, 48px) + var(--space-3));
    display: flex; flex-direction: column; max-height: calc(100vh - var(--mud-appbar-height, 48px) - var(--space-5));
    background: var(--surface-1); border: 1px solid var(--line); border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm), var(--highlight-top); overflow: hidden; }
/* Inside a form (the workflow rule builder) the rail is just a
   fieldset: nothing to stick to, and no list beside it to stay level
   with. */
.list-filter.embedded { position: static; max-height: 26rem; }

.lf-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2);
    padding: var(--space-3) var(--space-3) var(--space-2); border-bottom: 1px solid var(--line-soft); }
.lf-head strong { font-size: var(--text-md); color: var(--ink-800); }
.lf-x { border: 0; background: transparent; color: var(--ink-400); font-size: 1.2rem; line-height: 1; padding: 0 .25rem; cursor: pointer; }
.lf-x:hover { color: var(--ink-700); }
.lf-search { padding: var(--space-2) var(--space-3); }
.lf-search input { width: 100%; padding: .38rem .55rem; border: 1px solid var(--line-strong);
    border-radius: var(--radius-md); background: var(--surface-1); color: var(--ink-800); font: inherit;
    box-shadow: inset 0 1px 2px rgba(20,35,80,.06); }
.lf-match { display: flex; align-items: center; gap: .4rem; padding: 0 var(--space-3) var(--space-2);
    font-size: var(--text-xs); color: var(--ink-400); }
.lf-match select { padding: .15rem .35rem; border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
    background: var(--surface-1); color: var(--ink-700); font: inherit; }
.lf-section { margin: 0; padding: var(--space-2) var(--space-3); font-size: var(--text-2xs);
    font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-300);
    border-top: 1px solid var(--line-soft); }
.lf-fields { overflow-y: auto; padding: 0 var(--space-2) var(--space-2); }
.lf-fields:last-of-type { flex: 1; }
.lf-system { flex: 0 0 auto; max-height: 12rem; }
.lf-field { border-radius: var(--radius-sm); }
.lf-field.on { background: var(--brand-50); }
.lf-check { display: flex; align-items: center; gap: .5rem; padding: .32rem var(--space-2);
    font-size: var(--text-sm); color: var(--ink-700); cursor: pointer; }
.lf-check input { width: auto; margin: 0; }
.lf-clause { display: flex; flex-direction: column; gap: .35rem; padding: .1rem var(--space-2) .5rem 1.9rem; }
.lf-clause input, .lf-clause select { padding: .3rem .45rem; border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm); background: var(--surface-1); color: var(--ink-800); font: inherit;
    font-size: var(--text-sm); width: 100%; }
.lf-clause .lf-op { width: auto; }
.lf-picklist { display: flex; flex-direction: column; gap: .15rem; }
.lf-picklist label { display: flex; align-items: center; gap: .4rem; font-size: var(--text-sm); color: var(--ink-600); }
.lf-picklist input { width: auto; }
.lf-range { display: flex; align-items: center; gap: .4rem; }
.lf-range span { color: var(--ink-400); font-size: var(--text-xs); }
.lf-empty { padding: var(--space-3); color: var(--ink-400); font-size: var(--text-sm); }
.lf-foot { display: flex; gap: var(--space-2); padding: var(--space-2) var(--space-3);
    border-top: 1px solid var(--line-soft); background: var(--surface-2); }
.lf-foot .button.small { margin-top: 0; }

@media (max-width: 960px) {
    .list-shell.with-filter { grid-template-columns: 1fr; }
    .list-filter { position: static; max-height: 22rem; margin-bottom: var(--space-3); }
}

/* Workflow rule editor. The aside is already a narrow column, so an
   action is a bordered block rather than another nested card -- one
   border deep is enough to say "these inputs belong together". */
.wf-fieldset { max-height: 12rem; overflow-y: auto; border: 1px solid var(--line);
    border-radius: var(--radius-sm); padding: var(--space-2); margin-bottom: var(--space-3); }
/* The round-robin pool. Same scrolling box as the field picker above
   it -- a workspace with forty people must not push the Save button off
   the screen. */
.wf-pool { max-height: 12rem; overflow-y: auto; border: 1px solid var(--line);
    border-radius: var(--radius-sm); padding: var(--space-2); margin-bottom: var(--space-2);
    display: flex; flex-direction: column; gap: var(--space-1); }
.wf-action { border: 1px solid var(--line); border-radius: var(--radius-sm);
    padding: var(--space-2) var(--space-3) var(--space-3); margin-bottom: var(--space-3);
    background: var(--surface-2); }
.wf-action-head { display: flex; align-items: center; justify-content: space-between;
    gap: var(--space-2); margin-bottom: var(--space-2); }
.wf-action-head strong { font-size: var(--text-sm); color: var(--ink-700); }
/* One merge placeholder and what it means, listed under the alert
   editor so a rule author picks a real field instead of guessing. */
.merge-field { display: flex; gap: var(--space-2); align-items: baseline;
    font-size: var(--text-sm); padding: .1rem 0; }
.merge-field code { font-family: var(--font-mono, monospace); }
.wf-add { display: flex; gap: var(--space-2); flex-wrap: wrap; margin-bottom: var(--space-3); }

/* Run status. Colours come off the data ramp the dashboards use, so a
   failed run reads the same as a lost deal elsewhere in the app. */
.wf-status { text-transform: capitalize; font-weight: 500; }
.wf-status.succeeded { color: var(--data-won); }
.wf-status.failed { color: var(--data-lost); }
.wf-status.skipped { color: var(--ink-400); }

/* This page is a list plus a log, not a record form, so it must opt out
   of .detail-form's four-column label/input grid -- otherwise the rules
   table is placed in a 10rem LABEL track and rendered about 90px wide
   with its own scrollbar. Same reasoning as .detail-form.record-view
   above; scoped to this page rather than loosened globally, because the
   other Admin screens genuinely are label/input forms. */
.detail-form.wf-list { display: block; }

/* .detail-grid is single-column by default, which would drop the rule
   editor underneath a full-width table and put the field you are
   editing off-screen. Give it the second track only while the editor
   is open. */
.wf-grid:has(.detail-side) { grid-template-columns: minmax(0, 1fr) 24rem; }
@media (max-width: 1100px) {
    .wf-grid:has(.detail-side) { grid-template-columns: minmax(0, 1fr); }
}

/* Permission matrix: many narrow boolean columns, one label column.
   Centring the boxes is what makes a row scannable -- the question the
   reader is asking is "which of these are ticked", not "what is in this
   cell". */
.perm-grid th, .perm-grid td { text-align: center; }
.perm-grid th:first-child, .perm-grid td:first-child { text-align: left; white-space: nowrap; }
.perm-grid th { font-size: var(--text-2xs); text-transform: uppercase; letter-spacing: .04em; }
.perm-grid input[type=checkbox] { width: auto; margin: 0; }

/* Setup landing page. A directory, not a dashboard: the reader is
   looking for one named thing, so every entry is a plain link at a
   readable size and nothing competes for attention. Cards carry a
   border and no shadow -- they group, they do not need lifting. */
.setup-head { display: flex; align-items: center; gap: var(--space-4);
    flex-wrap: wrap; margin-bottom: var(--space-5); }
.setup-head h1 { margin: 0; font-size: var(--text-3xl); font-weight: 500; color: var(--ink-900); }
.setup-search { flex: 0 1 22rem; padding: .45rem .7rem; font-size: var(--text-sm);
    border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
    background: var(--surface-1); color: var(--ink-800); }
.setup-search:focus { outline: none; border-color: var(--brand-500);
    box-shadow: 0 0 0 3px var(--brand-100); }

.setup-grid { display: grid; gap: var(--space-4);
    grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr)); align-items: start; }

.setup-card { background: var(--surface-1); border: 1px solid var(--line);
    border-radius: var(--radius-md); padding: var(--space-4); }
.setup-card h2 { margin: 0 0 var(--space-3); font-size: var(--text-2xs);
    text-transform: uppercase; letter-spacing: .06em; color: var(--ink-400); font-weight: 600; }
.setup-card ul { list-style: none; margin: 0; padding: 0;
    display: flex; flex-direction: column; gap: var(--space-3); }
.setup-card a { color: var(--brand-600); text-decoration: none; font-size: var(--text-md); }
.setup-card a:hover { text-decoration: underline; }
.setup-hint { display: block; margin-top: .15rem; font-size: var(--text-xs); color: var(--ink-400); }

.setup-note { margin-top: var(--space-5); }

/* Sign-in policy: label/control pairs where several controls are groups
   rather than single inputs, so the label column is fixed and the
   control column takes whatever it needs. */
.policy-grid { display: grid; grid-template-columns: minmax(11rem, 16rem) minmax(0, 1fr);
    gap: var(--space-3) var(--space-4); align-items: start; margin-top: var(--space-3); }
.policy-grid > label { text-align: right; font-weight: 600; font-size: var(--text-sm);
    color: var(--ink-600); padding-top: .35rem; }
.policy-grid input[type=number] { width: 8rem; }
.policy-grid textarea { width: 100%; font-family: var(--font-mono, monospace); font-size: var(--text-sm); }
.policy-grid .checkbox-row { margin: .1rem 0; }
/* Two fields under one label -- a street's two lines, an address and the
   name beside it. Without this they share an edge and read as one
   control with a rule through it. Only adjacent inputs, so the helper
   paragraphs that share these wrappers keep their own margins. */
.policy-grid > div > input + input { margin-top: var(--space-2); }
@media (max-width: 700px) {
    .policy-grid { grid-template-columns: 1fr; }
    .policy-grid > label { text-align: left; padding-top: 0; }
}

/* --- sample data: what is left, before you delete it ----------------- */
.sample-list { list-style: none; padding: 0; margin: var(--space-3) 0;
               display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-6); }
.sample-list li { color: var(--ink-600); font-size: var(--text-sm); }
.sample-list strong { color: var(--ink-800); font-variant-numeric: tabular-nums; }

/* --- business hours: the week, and the holiday list ------------------ */
.hours-table { width: 100%; border-collapse: collapse; margin: var(--space-3) 0; }
.hours-table th { text-align: left; font-size: var(--text-xs); text-transform: uppercase;
                  letter-spacing: .04em; color: var(--ink-400); padding: var(--space-2); }
.hours-table td { padding: var(--space-2); border-top: 1px solid var(--line-soft); color: var(--ink-700); }
.hours-table tr.closed-day td { color: var(--ink-400); }
.hours-table input[type=time] { width: 8rem; }

.holiday-add { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center;
               margin-bottom: var(--space-3); }
.holiday-add input[type=text], .holiday-add input:not([type]) { min-width: 18rem; }

/* --- an amount and the currency it is in, as one control ------------- */
.amount-row { display: flex; gap: var(--space-2); align-items: stretch; }
.amount-row .currency-select { width: 6rem; flex: none; }
.amount-row .currency-fixed { display: flex; align-items: center; padding: 0 var(--space-2);
                              color: var(--ink-500); font-weight: 600; font-size: var(--text-sm); }
.amount-row input { flex: 1 1 auto; min-width: 0; }

/* --- currencies: a rate is an input, a button and its unit ----------- */
.currency-table td { vertical-align: middle; }
.rate-cell { display: flex; gap: var(--space-2); align-items: center; }
.rate-cell input { width: 9rem; }

/* ============================================================
   2026 POLISH LAYER
   A calm neutral workspace with colour used for navigation and
   recognition. Module tint is deliberately local: identity, active
   navigation and section rails, never large blocks behind CRM data.
   ============================================================ */

body,
button,
input,
select,
textarea,
.mud-typography,
.mud-button-root,
.mud-input-control { font-family: var(--font-sans); }

.main-content {
    min-height: 100vh;
    background:
        radial-gradient(circle at 12% 0%, color-mix(in srgb, var(--brand-100) 48%, transparent) 0, transparent 28rem),
        var(--canvas);
}

/* Product identity and account controls. */
.mud-appbar,
.mud-appbar .mud-toolbar { min-height: 54px; height: 54px; }
.mud-layout { --mud-appbar-height: 54px; }
.mud-appbar {
    border-bottom: 1px solid var(--line);
    box-shadow: 0 1px 0 color-mix(in srgb, var(--brand-600) 6%, transparent), var(--shadow-sm) !important;
}
.mud-appbar::after {
    content: "";
    position: absolute;
    inset: auto 0 0;
    height: 2px;
    background: linear-gradient(90deg, var(--module-company), var(--brand-500), var(--module-person), var(--module-campaign));
    opacity: .8;
}
.workspace-brand {
    display: flex;
    align-items: center;
    gap: .65rem;
    flex: 0 0 auto;
    margin-right: 1.5rem;
    color: var(--ink-900);
    text-decoration: none;
}
.workspace-brand-mark {
    display: grid;
    place-items: center;
    width: 2rem;
    height: 2rem;
    border-radius: .65rem;
    background: linear-gradient(145deg, var(--brand-500), var(--module-person));
    color: var(--on-accent);
    font-size: var(--text-sm);
    font-weight: 750;
    text-transform: uppercase;
    box-shadow: 0 5px 12px color-mix(in srgb, var(--brand-600) 24%, transparent), var(--highlight-top);
}
.workspace-brand-copy { display: grid; line-height: 1.08; }
.workspace-brand-copy strong { font-size: var(--text-md); font-weight: 700; letter-spacing: -.01em; }
.workspace-brand-copy small { margin-top: .13rem; color: var(--ink-400); font-size: .625rem; letter-spacing: .055em; text-transform: uppercase; }
.appbar-search {
    min-height: 2.25rem;
    border: 1px solid transparent;
    background: var(--surface-3);
    transition: background .15s ease, border-color .15s ease, box-shadow .15s ease;
}
.appbar-search:focus-within {
    border-color: color-mix(in srgb, var(--brand-500) 58%, var(--line));
    background: var(--surface-1);
    box-shadow: 0 0 0 3px var(--brand-100);
}
.appbar-icon-button { border-radius: var(--radius-md) !important; }
.appbar-icon-button:hover { background: var(--brand-50) !important; color: var(--brand-600) !important; }
.appbar-user {
    display: inline-flex;
    align-items: center;
    gap: .45rem;
    min-height: 2.25rem;
    padding: .2rem .55rem .2rem .25rem;
    border: 1px solid transparent;
    border-radius: var(--radius-pill);
    color: var(--ink-700);
    font-size: var(--text-sm);
    font-weight: 600;
    text-decoration: none;
}
.appbar-user:hover { border-color: var(--line); background: var(--surface-2); }
.appbar-user-avatar {
    display: grid;
    place-items: center;
    width: 1.75rem;
    height: 1.75rem;
    border-radius: 50%;
    background: linear-gradient(145deg, var(--module-company-soft), var(--module-person-soft));
    color: var(--brand-700);
    font-size: var(--text-xs);
    font-weight: 750;
}
.appbar-signout { margin-left: .15rem; }
.appbar-logout {
    display: grid;
    place-items: center;
    width: 2.25rem;
    height: 2.25rem;
    padding: 0;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    background: transparent;
    color: var(--ink-500);
    cursor: pointer;
}
.appbar-logout:hover { border-color: var(--line); background: var(--surface-2); color: var(--brand-700); }

/* Module-aware navigation. */
.nav-home { --module-color: var(--nav-icon-home); }
.module-home { --module-color: var(--brand-500); --module-soft: var(--brand-50); }
.nav-company { --module-color: var(--nav-icon-company); }
.module-company { --module-color: var(--module-company); --module-soft: var(--module-company-soft); }
.nav-person { --module-color: var(--nav-icon-person); }
.module-person { --module-color: var(--module-person); --module-soft: var(--module-person-soft); }
.nav-lead { --module-color: var(--nav-icon-lead); }
.module-lead { --module-color: var(--module-lead); --module-soft: var(--module-lead-soft); }
.nav-work { --module-color: var(--nav-icon-work); --module-soft: var(--module-work-soft); }
.nav-calendar { --module-color: var(--nav-icon-calendar); --module-soft: var(--module-opportunity-soft); }
.nav-activity { --module-color: var(--nav-icon-activity); }
.module-activity { --module-color: var(--module-activity); --module-soft: var(--module-activity-soft); }
.nav-opportunity { --module-color: var(--nav-icon-opportunity); }
.module-opportunity { --module-color: var(--module-opportunity); --module-soft: var(--module-opportunity-soft); }
.nav-case { --module-color: var(--nav-icon-case); }
.module-case { --module-color: var(--module-case); --module-soft: var(--module-case-soft); }
.nav-campaign { --module-color: var(--nav-icon-campaign); }
.module-campaign { --module-color: var(--module-campaign); --module-soft: var(--module-campaign-soft); }
.nav-library { --module-color: var(--nav-icon-library); }
.nav-report { --module-color: var(--nav-icon-report); --module-soft: var(--module-report-soft); }
.nav-inbox { --module-color: var(--nav-icon-inbox); }
.nav-import { --module-color: var(--nav-icon-import); }
.nav-setup { --module-color: var(--nav-icon-setup); }
.mud-drawer .mud-nav-link .mud-icon-root,
.mud-drawer .mud-navgroup .mud-icon-root {
    color: var(--module-color, rgba(247,249,255,.72)) !important;
}
.mud-drawer .mud-nav-link-icon {
    display: grid;
    place-items: center;
    width: 1.65rem;
    height: 1.65rem;
    margin-right: .6rem !important;
    border-radius: .5rem;
    background: color-mix(in srgb, var(--module-color, var(--brand-400)) 18%, transparent);
}
.mud-drawer .mud-nav-link.active,
.mud-drawer a.active {
    background: linear-gradient(90deg, rgba(255,255,255,.15), rgba(255,255,255,.06)) !important;
    box-shadow: inset 3px 0 0 var(--module-color, var(--brand-400));
}
.mud-drawer .mud-nav-link.active .mud-nav-link-icon,
.mud-drawer a.active .mud-nav-link-icon {
    background: color-mix(in srgb, var(--module-color, var(--brand-400)) 28%, rgba(255,255,255,.08));
    box-shadow: 0 0 0 1px rgba(255,255,255,.08);
}
.mud-drawer .mud-nav-link.active .mud-icon-root,
.mud-drawer a.active .mud-icon-root { color: var(--module-color, var(--on-accent)) !important; }
.nav-collapsed .mud-nav-link-icon { margin-right: 0 !important; }

/* List-page identity and toolbar. */
.module-page-header {
    display: flex;
    align-items: center;
    gap: .85rem;
    min-height: 4.75rem;
    margin: 0 0 1rem;
    padding: .85rem 1rem;
    border: 1px solid color-mix(in srgb, var(--module-color) 18%, var(--line));
    border-radius: var(--radius-lg);
    background: linear-gradient(110deg, var(--module-soft) 0, var(--surface-1) 38%, var(--surface-1) 100%);
    box-shadow: var(--shadow-sm), var(--highlight-top);
}
.module-page-icon {
    display: grid;
    place-items: center;
    width: 2.75rem;
    height: 2.75rem;
    flex: 0 0 2.75rem;
    border-radius: .85rem;
    background: var(--module-soft);
    color: var(--module-color);
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--module-color) 18%, transparent);
}
.module-page-title { display: grid; gap: .08rem; min-width: 0; }
.module-page-title .mud-typography-h4,
.module-page-title h1 {
    margin: 0;
    color: var(--ink-900);
    font-size: var(--text-3xl);
    font-weight: 680;
    letter-spacing: -.025em;
    line-height: 1.15;
}
.module-page-title .mud-typography-color-secondary,
.module-page-title > p,
.module-page-title > small { margin: 0; color: var(--ink-500) !important; font-size: var(--text-xs); font-weight: 600; }
.module-page-spacer { margin-left: auto; }

/* Record hero: title, identity, metadata and actions are one object. */
.detail-header {
    position: relative;
    overflow: visible;
    margin-bottom: 1rem;
    padding: 1rem 1.1rem;
    border: 1px solid color-mix(in srgb, var(--module-color, var(--brand-500)) 18%, var(--line));
    border-radius: var(--radius-lg);
    background: linear-gradient(110deg, var(--module-soft, var(--brand-50)) 0, var(--surface-1) 34%, var(--surface-1) 100%);
    box-shadow: inset 4px 0 0 var(--module-color, var(--brand-500)), var(--shadow-sm), var(--highlight-top);
}
.detail-header:has(~ .detail-grid) {
    top: calc(var(--mud-appbar-height, 54px) + .5rem);
    padding: 1rem 1.1rem;
    margin-top: 0;
    background: color-mix(in srgb, var(--surface-1) 94%, transparent);
    backdrop-filter: blur(12px);
    border-bottom-color: color-mix(in srgb, var(--module-color, var(--brand-500)) 18%, var(--line));
}
.detail-header .back-link { margin-bottom: .25rem; color: var(--ink-600); font-size: var(--text-xs); font-weight: 600; }
.detail-header .back-link:hover { color: var(--module-color, var(--brand-700)); }
.detail-header .mud-typography-h4 { color: var(--ink-900); font-size: var(--text-4xl); font-weight: 680 !important; letter-spacing: -.025em; line-height: 1.15; }
.detail-actions { flex-wrap: wrap; justify-content: flex-end; }
.record-avatar-large { width: 3.75rem; height: 3.75rem; flex-basis: 3.75rem; border-radius: 1rem; }
.record-avatar-company { color: var(--module-company); background: var(--module-company-soft); }
.record-avatar-person { color: var(--module-person); background: var(--module-person-soft); }
.detail-grid[class*="module-"] {
    --section-accent: var(--module-color);
    --section-accent-soft: var(--module-soft);
    --field-accent: var(--module-color);
    --field-accent-soft: var(--module-soft);
    --field-accent-hover: color-mix(in srgb, var(--module-color) 18%, transparent);
}

/* One card language across record content. */
.detail-form,
.record-summary,
.notes-panel,
.documents-panel,
.timeline-panel,
.related-panel,
.dashboard-panel,
.sid-panel,
.sid-kpi,
.workqueue-card,
.list-filter {
    border-color: var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm), var(--highlight-top);
}
.detail-form { padding: 1.25rem 1.4rem 1.4rem; }
.detail-form.record-edit-form { row-gap: .85rem; }
.detail-form h2 {
    margin-right: -1.4rem;
    margin-left: -1.4rem;
    padding: .7rem 1.4rem;
    border-color: var(--line-soft);
    background: linear-gradient(90deg, var(--section-accent-soft), color-mix(in srgb, var(--surface-2) 74%, transparent));
    box-shadow: inset 4px 0 0 var(--section-accent);
    color: var(--ink-700);
    font-size: var(--text-xs);
    font-weight: 750;
    letter-spacing: .075em;
}
.record-summary {
    gap: 0;
    border-color: var(--line);
    border-radius: var(--radius-lg);
    background: var(--surface-1);
    box-shadow: var(--shadow-sm), var(--highlight-top);
}
.record-summary-field {
    position: relative;
    padding: .85rem 1rem;
    border-right: 1px solid var(--line-soft);
}
.record-summary-field::before {
    content: "";
    position: absolute;
    top: 0;
    right: 1rem;
    left: 1rem;
    height: 2px;
    border-radius: var(--radius-pill);
    background: linear-gradient(90deg, var(--section-accent), var(--brand-400));
    opacity: .65;
}
.record-summary-field:last-child { border-right: 0; }
.record-summary-field span { color: var(--ink-400); letter-spacing: .055em; }
.record-summary-field strong { color: var(--ink-800); font-size: var(--text-md); }

/* All native CRM fields now share one size and focus treatment. */
.record-edit-form .form-field > :where(input:not([type="checkbox"]):not([type="radio"]):not([type="file"]), select),
.record-edit-form .udf-field > :where(input:not([type="checkbox"]):not([type="radio"]):not([type="file"]), select),
.record-edit-form .field-row > div > :where(input:not([type="checkbox"]):not([type="radio"]):not([type="file"]), select),
.record-edit-form .amount-row > :where(input:not([type="checkbox"]):not([type="radio"]):not([type="file"]), select),
.record-edit-form .form-field > textarea,
.record-edit-form .udf-field > textarea,
.record-edit-form .field-row > div > textarea {
    min-height: 2.55rem;
    padding: .55rem .7rem;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-md);
    background: var(--surface-1);
    color: var(--ink-800);
    font: inherit;
    font-size: var(--text-md);
    box-shadow: inset 0 1px 2px color-mix(in srgb, var(--ink-900) 6%, transparent);
    transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
.record-edit-form .form-field > :where(input:not([type="checkbox"]):not([type="radio"]):not([type="file"]), select, textarea),
.record-edit-form .udf-field > :where(input:not([type="checkbox"]):not([type="radio"]):not([type="file"]), select, textarea),
.record-edit-form .field-row > div > :where(input:not([type="checkbox"]):not([type="radio"]):not([type="file"]), select, textarea) {
    width: 100%;
    min-width: 0;
}
.record-edit-form .amount-row > :where(input:not([type="checkbox"]):not([type="radio"]):not([type="file"]), select) { min-width: 0; }
.record-edit-form .form-field > textarea,
.record-edit-form .udf-field > textarea,
.record-edit-form .field-row > div > textarea { min-height: 6rem; resize: vertical; }
.record-edit-form .form-field > select[multiple],
.record-edit-form .udf-field > select[multiple] { min-height: 7rem; }
.record-edit-form .form-field > :where(input, select, textarea):hover,
.record-edit-form .udf-field > :where(input, select, textarea):hover,
.record-edit-form .field-row > div > :where(input, select, textarea):hover,
.record-edit-form .amount-row > :where(input, select, textarea):hover { border-color: color-mix(in srgb, var(--field-accent) 68%, var(--line-strong)); }
.record-edit-form .form-field > :where(input, select, textarea):focus,
.record-edit-form .udf-field > :where(input, select, textarea):focus,
.record-edit-form .field-row > div > :where(input, select, textarea):focus,
.record-edit-form .amount-row > :where(input, select, textarea):focus {
    outline: 0;
    border-color: var(--field-accent);
    box-shadow: 0 0 0 3px var(--field-accent-hover), inset 0 1px 2px color-mix(in srgb, var(--ink-900) 4%, transparent);
}
.record-edit-form .form-field > label,
.record-edit-form .udf-label { color: var(--field-label); font-size: var(--text-sm); font-weight: 650; }
.record-edit-form .udf-fields-editor { padding: 1rem 1.1rem 1.1rem; }
.record-edit-form .udf-fields-editor > h2 { margin: -1rem -1.1rem .35rem; padding: .7rem 1.1rem; }
.udf-field { display: grid; gap: .35rem; min-width: 0; align-content: start; }
.udf-field-wide { grid-column: 1 / -1; }
.udf-help { margin: 0; color: var(--ink-400); font-size: var(--text-xs); line-height: 1.4; }
.udf-checkbox { min-height: 2.55rem; margin: 0; padding: .45rem .65rem; border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--surface-2); }

/* Buttons: one silhouette across MudBlazor and hand-written controls. */
.mud-button-root,
.button {
    min-height: 2.25rem;
    margin-top: 0;
    border-radius: var(--radius-md) !important;
    font-weight: 650;
    letter-spacing: 0;
    text-transform: none;
    transition: transform .14s ease, box-shadow .14s ease, border-color .14s ease, background .14s ease;
}
.mud-button-filled-primary,
.button:not(.secondary):not(.danger):not(.ghost) {
    background: linear-gradient(135deg, var(--brand-600), var(--brand-500)) !important;
    color: var(--on-accent) !important;
    box-shadow: 0 4px 10px color-mix(in srgb, var(--brand-600) 22%, transparent), var(--highlight-top);
}
.mud-button-filled-primary:hover,
.button:not(.secondary):not(.danger):not(.ghost):hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 7px 15px color-mix(in srgb, var(--brand-600) 25%, transparent), var(--highlight-top); }
.button.ghost {
    border: 1px solid transparent;
    background: transparent;
    color: var(--brand-700);
    box-shadow: none;
}
.button.ghost:hover:not(:disabled) { border-color: var(--line); background: var(--brand-50); box-shadow: none; }
.mud-button-outlined { background: color-mix(in srgb, var(--surface-1) 92%, transparent); border-color: var(--line-strong); }
.mud-button-outlined:hover { border-color: var(--brand-400); background: var(--brand-50); }
.mud-button-outlined-error,
.mud-button-outlined-error:hover {
    border-color: var(--danger-line) !important;
    background: var(--danger-bg) !important;
    color: var(--danger-fg) !important;
}
.button:disabled,
.button:not(.secondary):not(.danger):not(.ghost):disabled,
button[type=submit]:not(.mud-button-root):disabled {
    border-color: var(--line) !important;
    background: var(--surface-3) !important;
    color: var(--ink-300) !important;
    box-shadow: none !important;
    transform: none !important;
    cursor: not-allowed;
}

/* Dense data can still breathe without losing CRM efficiency. */
.table-scroll,
.company-list-scroll {
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    background: var(--surface-1);
    box-shadow: var(--shadow-sm), var(--highlight-top);
}
.column-layout-table { box-shadow: none !important; }
.column-layout-table thead,
.grid thead,
.mud-table-root thead { background: linear-gradient(180deg, var(--surface-2), color-mix(in srgb, var(--brand-50) 42%, var(--surface-2))); }
.column-layout-table th,
.grid th,
.mud-table-root th {
    height: 2.65rem;
    color: var(--ink-500);
    font-size: var(--text-xs);
    font-weight: 700;
    letter-spacing: .025em;
    border-bottom-color: var(--line);
}
.column-layout-table td,
.grid td,
.mud-table-root td { min-height: 2.85rem; border-bottom-color: var(--line-soft); }
.column-layout-table tbody tr,
.grid tbody tr,
.mud-table-root tbody tr { transition: background .12s ease, box-shadow .12s ease; }
.column-layout-table tbody tr.clickable-row:hover,
.grid tbody tr.clickable-row:hover,
.mud-table-root tbody tr.clickable-row:hover,
tr.row-link:hover { background: var(--brand-50); box-shadow: inset 3px 0 0 var(--brand-400); }
.record-cell strong { color: var(--ink-800); font-weight: 680; }

/* The home screen is the daily landing point, so its figures should scan
   like a dashboard rather than a row of identical white rectangles. */
.home-kpis .mud-paper {
    height: 100%;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    background: var(--surface-1);
    box-shadow: var(--shadow-sm), var(--highlight-top) !important;
}
.home-kpis .mud-grid-item:nth-child(4n + 1) .mud-paper { border-top: 3px solid var(--brand-500); }
.home-kpis .mud-grid-item:nth-child(4n + 2) .mud-paper { border-top: 3px solid var(--module-person); }
.home-kpis .mud-grid-item:nth-child(4n + 3) .mud-paper { border-top: 3px solid var(--module-activity); }
.home-kpis .mud-grid-item:nth-child(4n) .mud-paper { border-top: 3px solid var(--module-work); }

/* Menus and dialogs should feel part of the same raised layer. */
.avatar-menu-popover,
.modal,
.mud-dialog {
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    background: var(--surface-1);
    box-shadow: var(--shadow-lg), var(--highlight-top);
}
.avatar-menu-popover { width: 11rem; padding: .3rem; }
.avatar-menu-popover > a,
.avatar-menu-action { min-height: 2.6rem; border: 0; border-radius: var(--radius-md); background: var(--surface-1); color: var(--ink-700); }
.avatar-menu-trigger .record-avatar { box-shadow: 0 0 0 3px var(--surface-1), 0 2px 8px color-mix(in srgb, var(--ink-900) 18%, transparent); }
.avatar-menu-popover > a:hover,
.avatar-menu-action:hover { background: var(--brand-50); color: var(--brand-700); }
.avatar-menu-remove { color: var(--danger); }
.avatar-menu-remove:hover { background: var(--danger-bg); color: var(--danger-fg); }
.modal-backdrop,
.mud-overlay { backdrop-filter: blur(4px); }

/* Segmented navigation and status affordances. */
.record-tabs,
.record-rail { border-color: var(--line); background: color-mix(in srgb, var(--surface-3) 84%, var(--brand-50)); box-shadow: var(--shadow-sm); }
.record-tabs button.active { color: var(--brand-700); box-shadow: var(--shadow-sm), inset 0 -2px 0 var(--brand-500); }
.pill,
.mud-chip { font-weight: 650; }
.related-count { background: var(--brand-100); color: var(--brand-700); }

/* Dashboard colour is tied to meaning, not decoration. */
.sid-kpis > :nth-child(4n + 1),
.dashboard-kpis > :nth-child(4n + 1) { box-shadow: inset 0 3px 0 var(--module-company), var(--shadow-sm), var(--highlight-top); }
.sid-kpis > :nth-child(4n + 2),
.dashboard-kpis > :nth-child(4n + 2) { box-shadow: inset 0 3px 0 var(--module-opportunity), var(--shadow-sm), var(--highlight-top); }
.sid-kpis > :nth-child(4n + 3),
.dashboard-kpis > :nth-child(4n + 3) { box-shadow: inset 0 3px 0 var(--module-person), var(--shadow-sm), var(--highlight-top); }
.sid-kpis > :nth-child(4n),
.dashboard-kpis > :nth-child(4n) { box-shadow: inset 0 3px 0 var(--module-campaign), var(--shadow-sm), var(--highlight-top); }

html.theme-dark {
    --module-company-soft: color-mix(in srgb, var(--module-company) 16%, var(--surface-1));
    --module-person-soft: color-mix(in srgb, var(--module-person) 16%, var(--surface-1));
    --module-lead-soft: color-mix(in srgb, var(--module-lead) 16%, var(--surface-1));
    --module-work-soft: color-mix(in srgb, var(--module-work) 16%, var(--surface-1));
    --module-activity-soft: color-mix(in srgb, var(--module-activity) 16%, var(--surface-1));
    --module-opportunity-soft: color-mix(in srgb, var(--module-opportunity) 16%, var(--surface-1));
    --module-case-soft: color-mix(in srgb, var(--module-case) 16%, var(--surface-1));
    --module-campaign-soft: color-mix(in srgb, var(--module-campaign) 16%, var(--surface-1));
    --module-report-soft: color-mix(in srgb, var(--module-report) 16%, var(--surface-1));
}
html.theme-dark .button.secondary,
html.theme-dark .button.ghost { color: var(--brand-400); }
html.theme-dark .button.secondary { border-color: color-mix(in srgb, var(--brand-400) 70%, var(--line)); }

/* Sales Inbox: private mailbox chrome, deliberately distinct from a CRM
   record page.  The narrow folder rail and dense rows mirror a familiar
   mail client while CRM filing stays an explicit action. */
.sales-mailbox { min-height: calc(100vh - 6.5rem); margin: -.25rem; border: 1px solid var(--line); border-radius: var(--radius-lg); overflow: hidden; background: var(--surface-1); box-shadow: var(--shadow-sm); }
.sales-mailbox-topbar { display: grid; grid-template-columns: minmax(16rem,1fr) minmax(18rem,34rem) auto; align-items: center; gap: 1rem; min-height: 4.4rem; padding: .7rem 1rem; border-bottom: 1px solid var(--line); background: var(--surface-1); }
.sales-mailbox-title { display: flex; align-items: center; gap: .7rem; min-width: 0; }
.sales-mailbox-title .module-page-icon { width: 2.4rem; height: 2.4rem; flex-basis: 2.4rem; }
.sales-mailbox-title h1 { margin: 0; color: var(--ink-900); font-size: 1.05rem; }
.sales-mailbox-title small { display: block; overflow: hidden; margin-top: .15rem; color: var(--ink-400); text-overflow: ellipsis; white-space: nowrap; }
.sales-mailbox-search { display: flex; align-items: center; gap: .45rem; padding: 0 .75rem; border: 1px solid var(--line-strong); border-radius: var(--radius-pill); background: var(--surface-2); }
.sales-mailbox-search input { width: 100%; min-height: 2.45rem; border: 0; outline: 0; background: transparent; color: var(--ink-800); }
.sales-mailbox-shell { display: grid; grid-template-columns: 14.5rem minmax(0,1fr); min-height: calc(100vh - 11rem); }
.sales-mailbox-folders { display: flex; flex-direction: column; gap: .85rem; padding: .9rem; border-right: 1px solid var(--line); background: color-mix(in srgb, var(--surface-3) 78%, var(--brand-50)); }
.mailbox-new-email { display: flex; justify-content: center; width: 100%; }
.mailbox-account-picker { display: grid; gap: .25rem; color: var(--ink-400); font-size: var(--text-xs); font-weight: 700; }
.mailbox-account-picker select { width: 100%; min-height: 2.35rem; padding: .4rem; border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--surface-1); color: var(--ink-700); }
.mailbox-current-account { display: flex; align-items: center; gap: .55rem; padding: .65rem; border: 1px solid var(--line-soft); border-radius: var(--radius-md); background: var(--surface-1); min-width: 0; }
.mailbox-current-account > span, .mailbox-row-avatar { display: grid; place-items: center; width: 2rem; height: 2rem; flex: 0 0 2rem; border-radius: 50%; background: linear-gradient(135deg, var(--brand-100), var(--module-person-soft)); color: var(--brand-700); font-size: var(--text-xs); font-weight: 750; }
.mailbox-current-account div { min-width: 0; }
.mailbox-current-account strong, .mailbox-current-account small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mailbox-current-account strong { color: var(--ink-700); font-size: var(--text-sm); }.mailbox-current-account small { color: var(--ink-400); font-size: var(--text-xs); }
.sales-mailbox-folders nav { display: grid; gap: .2rem; }
.sales-mailbox-folders nav button { display: grid; grid-template-columns: 1.4rem 1fr auto; align-items: center; gap: .45rem; min-height: 2.6rem; padding: .5rem .65rem; border: 0; border-radius: var(--radius-md); background: transparent; color: var(--ink-600); font: inherit; font-weight: 600; text-align: left; cursor: pointer; }
.sales-mailbox-folders nav button:hover { background: var(--surface-1); }.sales-mailbox-folders nav button.active { background: var(--brand-100); color: var(--brand-700); box-shadow: inset 3px 0 0 var(--brand-500); }
.sales-mailbox-folders nav em { min-width: 1.55rem; padding: .08rem .35rem; border-radius: var(--radius-pill); background: var(--surface-1); color: var(--ink-400); font-size: var(--text-xs); font-style: normal; text-align: center; }
.mailbox-private-note { display: flex; gap: .5rem; margin-top: auto; padding: .7rem; border: 1px solid var(--line-soft); border-radius: var(--radius-md); background: var(--surface-1); color: var(--ink-400); }
.mailbox-private-note p { margin: 0; font-size: var(--text-xs); line-height: 1.45; }.mailbox-private-note strong { display: block; margin-bottom: .15rem; color: var(--ink-600); }
.sales-mailbox-content { min-width: 0; background: var(--surface-1); }
.sales-mailbox-toolbar { display: flex; align-items: center; gap: .65rem; min-height: 3.5rem; padding: .55rem .8rem; border-bottom: 1px solid var(--line); background: var(--surface-1); }
.sales-mailbox-toolbar strong { color: var(--ink-800); }.sales-mailbox-toolbar > span { color: var(--ink-400); font-size: var(--text-sm); }
.mailbox-message-list { min-width: 0; }
.mailbox-message-row { display: grid; grid-template-columns: 2rem minmax(9rem,15rem) minmax(13rem,20rem) minmax(12rem,1fr) auto 5rem; align-items: center; gap: .75rem; width: 100%; min-height: 3.65rem; padding: .55rem .9rem; border: 0; border-bottom: 1px solid var(--line-soft); background: var(--surface-1); color: var(--ink-700); text-align: left; cursor: pointer; transition: background .12s ease, box-shadow .12s ease; }
.mailbox-message-row:hover { background: var(--brand-50); box-shadow: inset 3px 0 0 var(--brand-400); }
.mailbox-message-row strong, .mailbox-message-row b, .mailbox-row-preview { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mailbox-message-row b { color: var(--ink-800); font-weight: 680; }.mailbox-row-preview { color: var(--ink-400); }.mailbox-message-row time { color: var(--ink-500); font-size: var(--text-xs); text-align: right; }
.mailbox-crm-badge { padding: .18rem .42rem; border-radius: var(--radius-pill); background: var(--module-company-soft); color: var(--module-company); font-size: .68rem; font-weight: 750; }
.mailbox-loading, .mailbox-empty { min-height: 28rem; }
.mailbox-conversation-layout { display: grid; grid-template-columns: minmax(0,1fr) 18rem; min-height: calc(100vh - 14.5rem); }
.mailbox-conversation-view { min-width: 0; padding: 1rem; background: var(--surface-2); overflow: auto; }
.mailbox-conversation-view > header { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: .8rem; padding: .9rem 1rem; border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--surface-1); }
.mailbox-conversation-view h2 { margin: .15rem 0 0; color: var(--ink-900); font-size: 1.35rem; }.mailbox-conversation-view header small { color: var(--ink-400); }
.mailbox-message-card { margin-bottom: .8rem; border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--surface-1); box-shadow: var(--shadow-sm); }
.mailbox-message-card > header { display: grid; grid-template-columns: 2rem minmax(0,1fr) auto; align-items: center; gap: .65rem; padding: .75rem 1rem; border-bottom: 1px solid var(--line-soft); }
.mailbox-message-card > header div { display: grid; }.mailbox-message-card > header small, .mailbox-message-card time { color: var(--ink-400); font-size: var(--text-xs); }
.mailbox-message-body { min-height: 6rem; padding: 1rem; color: var(--ink-700); line-height: 1.6; white-space: pre-wrap; }
.mailbox-message-card > footer { display: flex; align-items: center; gap: 1rem; min-height: 2.8rem; padding: .45rem 1rem; border-top: 1px solid var(--line-soft); }
.mailbox-message-card > footer :where(a,button) { border: 0; background: transparent; color: var(--brand-700); font: inherit; font-weight: 650; text-decoration: none; cursor: pointer; }.mailbox-message-card > footer .filed-badge { margin-left: auto; }
.mailbox-crm-panel { padding: 1rem; border-left: 1px solid var(--line); background: var(--surface-1); }.mailbox-crm-panel h3 { margin: 0 0 .5rem; color: var(--ink-800); }.mailbox-crm-panel p { color: var(--ink-500); font-size: var(--text-sm); line-height: 1.55; }.mailbox-crm-panel .button { width: 100%; margin: .5rem 0; }.mailbox-crm-panel small { color: var(--ink-400); line-height: 1.45; }
.mailbox-crm-actions{display:grid;gap:.25rem;margin:.9rem 0 1rem;padding:.8rem;border:1px solid var(--line);border-radius:.8rem;background:var(--surface-0)}.mailbox-crm-actions .button{margin:0}.mailbox-crm-actions small{margin:0 0 .45rem}.filing-suggestions-state,.filing-section-heading{display:flex;align-items:center;justify-content:space-between;gap:.75rem;margin:1rem 1.4rem .5rem}.filing-suggestions-state{justify-content:flex-start;padding:.85rem;border:1px solid var(--line);border-radius:.65rem;background:var(--surface-2)}.filing-suggestions-state>div,.filing-section-heading>div{display:flex;flex-direction:column}.filing-suggestions-state small,.filing-section-heading small{color:var(--muted)}.filing-section-heading>span{padding:.2rem .5rem;border-radius:999px;background:var(--brand-100);color:var(--brand-700);font-size:.75rem;font-weight:700}.email-record-results.suggested{margin-top:.45rem;border-color:color-mix(in srgb,var(--brand-500) 35%,var(--border))}.filing-no-suggestion{margin-top:1rem}

/* Full email composer. */
.composer-page { width: min(72rem,100%); margin: 0 auto; }
.composer-page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: .8rem; }.composer-page-header h1 { margin: .25rem 0 0; color: var(--ink-900); font-size: 1.55rem; }.composer-page-header p { margin: .2rem 0 0; color: var(--ink-400); }.composer-page-header a { color: var(--brand-700); font-size: var(--text-sm); font-weight: 650; text-decoration: none; }.composer-header-actions { display: flex; gap: .5rem; }
.email-composer-card { overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface-1); box-shadow: var(--shadow-lg), var(--highlight-top); }
.composer-address-row { display: grid; grid-template-columns: 4.5rem minmax(0,1fr) auto; align-items: center; min-height: 3.15rem; padding: 0 .9rem; border-bottom: 1px solid var(--line-soft); }.composer-address-row > label { color: var(--ink-500); font-size: var(--text-sm); font-weight: 700; }.composer-address-row :where(input,select) { width: 100%; min-height: 2.6rem; border: 0; outline: 0; background: transparent; color: var(--ink-800); font: inherit; }.composer-recipient-toggles { display: flex; }.composer-recipient-toggles button,.composer-remove-row { border: 0; background: transparent; color: var(--brand-700); cursor: pointer; }
.composer-inline-warning { padding: .4rem 1rem; background: var(--warning-bg,#fff8df); color: var(--warning-fg,#7a5400); font-size: var(--text-sm); }
.composer-format-toolbar { display: flex; align-items: center; gap: .25rem; min-height: 2.8rem; padding: .35rem .75rem; border-bottom: 1px solid var(--line); background: var(--surface-2); }.composer-format-toolbar button { min-width: 2.1rem; min-height: 2rem; padding: .25rem .45rem; border: 1px solid transparent; border-radius: .4rem; background: transparent; color: var(--ink-600); cursor: pointer; }.composer-format-toolbar button:hover { border-color: var(--line); background: var(--surface-1); }.composer-format-toolbar > span { width: 1px; height: 1.4rem; margin: 0 .25rem; background: var(--line); }
.composer-editor { min-height: 24rem; padding: 1.1rem 1.2rem; outline: 0; color: var(--ink-800); font-size: 1rem; line-height: 1.6; }.composer-editor:empty::before { content: attr(data-placeholder); color: var(--ink-300); pointer-events: none; }
.composer-attachments { display: flex; flex-wrap: wrap; gap: .45rem; padding: .7rem 1rem; border-top: 1px solid var(--line-soft); }.composer-attachments > span { display: flex; align-items: center; gap: .35rem; padding: .4rem .55rem; border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--surface-2); color: var(--ink-600); }.composer-attachments small { color: var(--ink-400); }.composer-attachments button { border: 0; background: transparent; color: var(--ink-400); cursor: pointer; }
.composer-footer { display: flex; align-items: center; gap: .7rem; min-height: 4rem; padding: .65rem .85rem; border-top: 1px solid var(--line); background: var(--surface-2); }.composer-send { min-width: 7rem; }.composer-attach-button { display: inline-flex; align-items: center; gap: .35rem; min-height: 2.3rem; padding: .45rem .65rem; border: 1px solid var(--line-strong); border-radius: var(--radius-md); background: var(--surface-1); color: var(--ink-600); font-weight: 650; cursor: pointer; }.composer-attach-button input { display: none; }.composer-file-limit { color: var(--ink-400); font-size: var(--text-xs); }.composer-crm-save { margin-left: auto; color: var(--module-company); font-size: var(--text-sm); font-weight: 650; }.composer-discard { margin-left: auto; }.composer-crm-save + .composer-discard { margin-left: 0; }.composer-saved-state { padding: .45rem 1rem; background: var(--module-company-soft); color: var(--module-company); font-size: var(--text-sm); }

@media (max-width: 900px) {
    .sales-mailbox-topbar { grid-template-columns: 1fr auto; }.sales-mailbox-search { grid-column: 1 / -1; grid-row: 2; }.sales-mailbox-shell { grid-template-columns: 4.25rem minmax(0,1fr); }.sales-mailbox-folders { padding: .55rem; }.mailbox-new-email { font-size: 0; }.mailbox-new-email::after { content: "+"; font-size: 1.25rem; }.mailbox-current-account div,.mailbox-private-note,.sales-mailbox-folders nav button:not(.active) em { display: none; }.sales-mailbox-folders nav button { grid-template-columns: 1fr; text-align: center; }.mailbox-conversation-layout { grid-template-columns: 1fr; }.mailbox-crm-panel { border-top: 1px solid var(--line); border-left: 0; }.mailbox-message-row { grid-template-columns: 2rem minmax(7rem,12rem) minmax(10rem,1fr) 4rem; }.mailbox-row-preview,.mailbox-crm-badge { display: none; }
}

@media (max-width: 620px) {
    .composer-address-row { grid-template-columns: 3.5rem minmax(0,1fr) auto; }.composer-editor { min-height: 18rem; }.composer-footer { align-items: flex-start; flex-wrap: wrap; }.composer-crm-save { order: 5; width: 100%; margin-left: 0; }.composer-file-limit { display: none; }.mailbox-message-row { grid-template-columns: 2rem minmax(0,1fr) 4rem; }.mailbox-message-row b { grid-column: 2; }.mailbox-message-row strong { display: none; }.mailbox-message-row time { grid-column: 3; grid-row: 1; }
}

/* Record interactions use a full-width, searchable history grid.  Email and
   notes live together here because both are client communication, while the
   Timeline remains the broader audit/history view. */
.interaction-workspace {
    display: grid;
    gap: 1rem;
    min-width: 0;
}
.interaction-workspace-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1rem;
    padding: 1.1rem 1.25rem;
    border: 1px solid var(--line);
    border-left: 4px solid var(--module-activity);
    border-radius: var(--radius-lg);
    background: linear-gradient(115deg, var(--module-activity-soft), var(--surface-1) 42%);
    box-shadow: var(--shadow-sm), var(--highlight-top);
}
.interaction-workspace-header h1 { margin: .2rem 0 0; color: var(--ink-900); font-size: 1.65rem; }
.interaction-workspace-header p { margin: .2rem 0 0; color: var(--ink-500); }
.interaction-back { color: var(--brand-700); font-size: var(--text-sm); font-weight: 650; text-decoration: none; }
.interaction-header-actions { display: flex; gap: .6rem; flex-wrap: wrap; }
.interaction-toolbar {
    display: flex;
    align-items: end;
    gap: .75rem;
    min-width: 0;
    padding: .75rem;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    background: var(--surface-1);
    box-shadow: var(--shadow-sm);
}
.interaction-toolbar > label { display: grid; gap: .25rem; color: var(--ink-500); font-size: var(--text-xs); font-weight: 650; }
.interaction-toolbar :where(input, select) {
    min-height: 2.35rem;
    padding: .45rem .65rem;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-md);
    background: var(--surface-1);
    color: var(--ink-800);
}
.interaction-toolbar :where(input, select):focus { outline: 0; border-color: var(--brand-500); box-shadow: 0 0 0 3px var(--brand-100); }
.interaction-search { position: relative; flex: 1 1 22rem; }
.interaction-search > span { position: absolute; left: .7rem; bottom: .53rem; color: var(--ink-400); font-size: 1.25rem; }
.interaction-search input { width: 100%; padding-left: 2.1rem; }
.interaction-result-count { margin: 0 0 .55rem auto; color: var(--ink-400); font-size: var(--text-sm); white-space: nowrap; }
.interaction-grid-wrap {
    overflow: auto;
    max-height: calc(100vh - 16.5rem);
    min-height: 20rem;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    background: var(--surface-1);
    box-shadow: var(--shadow-sm), var(--highlight-top);
}
.interaction-grid { width: 100%; min-width: 72rem; border-collapse: separate; border-spacing: 0; table-layout: fixed; }
.interaction-grid thead { position: sticky; top: 0; z-index: 1; background: linear-gradient(180deg, var(--surface-2), var(--surface-3)); }
.interaction-grid th {
    height: 2.75rem;
    padding: .55rem .7rem;
    border-bottom: 1px solid var(--line);
    color: var(--ink-500);
    font-size: var(--text-xs);
    font-weight: 750;
    letter-spacing: .025em;
    text-align: left;
}
.interaction-grid th:nth-child(1) { width: 10rem; }
.interaction-grid th:nth-child(2) { width: 10.5rem; }
.interaction-grid th:nth-child(3) { width: 18rem; }
.interaction-grid th:nth-child(4) { width: 30%; }
.interaction-grid th:nth-child(5) { width: 16rem; }
.interaction-grid th:nth-child(6) { width: 11rem; }
.interaction-grid th:nth-child(7) { width: 4.5rem; }
.interaction-grid td {
    height: 3rem;
    padding: .55rem .7rem;
    overflow: hidden;
    border-bottom: 1px solid var(--line-soft);
    color: var(--ink-700);
    font-size: var(--text-sm);
    text-overflow: ellipsis;
    white-space: nowrap;
}
.interaction-grid tbody tr { cursor: pointer; transition: background .12s ease, box-shadow .12s ease; }
.interaction-grid tbody tr:hover { background: var(--brand-50); box-shadow: inset 3px 0 0 var(--brand-400); }
.interaction-grid tbody tr.selected { background: color-mix(in srgb, var(--module-activity-soft) 75%, var(--surface-1)); box-shadow: inset 4px 0 0 var(--module-activity); }
.interaction-grid td:first-child { display: flex; align-items: center; gap: .5rem; }
.interaction-type-icon {
    display: inline-grid;
    place-items: center;
    width: 1.7rem;
    height: 1.7rem;
    flex: 0 0 1.7rem;
    border-radius: .5rem;
    background: var(--brand-100);
    color: var(--brand-700);
    font-size: .9rem;
}
.interaction-type-icon.inbound { background: var(--module-company-soft); color: var(--module-company); }
.interaction-type-icon.outbound { background: var(--module-opportunity-soft); color: var(--module-opportunity); }
.interaction-type-icon.note { background: var(--module-work-soft); color: var(--module-work); }
.interaction-type-icon.call { background: var(--module-person-soft); color: var(--module-person); }
.interaction-type-icon.meeting { background: var(--module-activity-soft); color: var(--module-activity); }
.interaction-loading, .interaction-empty { min-height: 18rem; }
.interaction-detail-window { width: min(58rem, calc(100vw - 2rem)); max-height: calc(100vh - 2rem); overflow: auto; padding: 0; }
.interaction-detail-actions { position: sticky; top: 0; z-index: 2; display: grid; grid-template-columns: auto auto 1fr auto; gap: .5rem; padding: .7rem .9rem; border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--surface-1) 94%, transparent); backdrop-filter: blur(8px); }
.interaction-detail-title { display: flex; align-items: center; gap: .8rem; padding: 1.2rem 1.35rem .7rem; }
.interaction-detail-title h2 { margin: .15rem 0 0; color: var(--ink-900); font-size: 1.35rem; }
.interaction-detail-title small { color: var(--ink-400); font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.interaction-detail-window .email-headers, .interaction-detail-window .email-viewer-body, .interaction-detail-window .email-attachments { margin-right: 1.35rem; margin-left: 1.35rem; }
.interaction-detail-window .email-viewer-body { min-height: 15rem; margin-bottom: 1.35rem; }
.interaction-note-dialog { width: min(38rem, calc(100vw - 2rem)); padding: 1.25rem; }
.interaction-note-dialog > header { display: flex; justify-content: space-between; align-items: start; margin-bottom: 1rem; }
.interaction-note-dialog h2 { margin: .15rem 0 0; }
.interaction-note-dialog > label:not(.checkbox-row) { display: grid; gap: .4rem; color: var(--ink-600); font-weight: 650; }
.interaction-note-dialog textarea { width: 100%; padding: .7rem; border: 1px solid var(--line-strong); border-radius: var(--radius-md); background: var(--surface-1); color: var(--ink-800); font: inherit; resize: vertical; }
.interaction-note-dialog footer { display: flex; justify-content: flex-end; gap: .55rem; margin-top: 1rem; }

@media (max-width: 900px) {
    .interaction-workspace-header { align-items: flex-start; flex-direction: column; }
    .interaction-toolbar { align-items: stretch; flex-wrap: wrap; }
    .interaction-toolbar > label:not(.interaction-search) { flex: 1 1 9rem; }
    .interaction-result-count { margin-left: 0; }
    .interaction-grid-wrap { max-height: none; }
}

@media (max-width: 820px) {
    .workspace-brand-copy small,
    .appbar-user > span:last-child { display: none; }
    .workspace-brand { margin-right: .5rem; }
    .appbar-search { width: min(16rem, 44vw); max-width: none; }
    .module-page-header { align-items: flex-start; flex-wrap: wrap; }
    .module-page-header .mud-spacer { display: none; }
    .detail-header { padding: .85rem; }
}

@media (max-width: 560px) {
    .workspace-brand-copy { display: none; }
    .appbar-search-kbd { display: none; }
    .appbar-search { width: 42vw; padding-right: .6rem; padding-left: .6rem; }
    .module-page-header { padding: .75rem; }
    .module-page-icon { width: 2.4rem; height: 2.4rem; flex-basis: 2.4rem; }
    .record-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .record-summary-field { border-bottom: 1px solid var(--line-soft); }
}
