/* Settings CSS, part 1 of 2: the original layout (nav, team-member page, End relationship, nav search, linked
   spreadsheets, the bounded frame, one sheet per tab, the Permissions two-panel layout, dark mode).
   Split #5 of index.html: moved unchanged, linked at the exact spot it used to sit so the cascade order is the
   same. Part 2 is settings-2.css. */
  /* ── SETTINGS LAYOUT ── */
  .settings-shell {
    display: grid; grid-template-columns: 220px 1fr; gap: 24px;
    /* Align the content area with the floating header bar above it: same 22px
       side insets, no width cap, so its left/right edges line up with .topbar
       (which uses margin: 0 22px). Previously this was pinned flush-left with a
       1100px cap, leaving it offset ~22px left and short ~195px on the right. */
    padding: 22px 0 32px; margin: 0 22px; flex: 1; align-items: start; width: auto;
    position: relative; /* positioning context for the in-settings sub-page overlay */
  }
  /* Reusable in-settings sub-page: replaces "glass" popups (register business, add
     custom role, billing plans, edit management company) with a real page that slides
     over the settings nav+panels and has its own Back button — matches settings design. */
  .settings-subpage {
    position: absolute; inset: 0; z-index: 40; display: none; flex-direction: column;
    background: var(--bg2); border-radius: 14px; overflow: hidden;
    animation: settingsSubpageIn .18s ease;
  }
  @keyframes settingsSubpageIn { from { opacity: 0; transform: translateX(8px); } to { opacity: 1; transform: none; } }
  .settings-subpage-head {
    display: flex; align-items: center; gap: 12px; padding: 14px 22px;
    border-bottom: 1px solid var(--border2); background: var(--bg); flex-shrink: 0;
  }
  .settings-subpage-title { font-size: 15px; font-weight: 700; color: var(--text); }
  .settings-subpage-body { flex: 1; overflow-y: auto; padding: 22px; }

  /* Property Manager Report hosted as a sub-page. As a popup it is a fixed-height card
     whose two columns scroll independently; a sub-page has no height of its own, so
     those panes must stop scrolling themselves and let the sub-page body scroll —
     otherwise both collapse and the report is a sliver. One column, too: the settings
     card is min(940px,100%) and the sub-page gets ~700px of it, so side-by-side would
     leave the report about 410px wide, narrower than the popup it replaced. Stacked,
     the report keeps its full width and comes first, because looking at it is the
     reason the page was opened; the send controls follow underneath. The markup sizes
     these panes with inline style, so the overrides have to be !important. */
  #settings-subpage [data-subpage-host="report-modal"] {
    background: none !important; border: none !important;
    border-radius: 0 !important; overflow: visible !important;
  }
  #settings-subpage [data-subpage-host="report-modal"] .rpt-layout {
    flex-direction: column !important; overflow: visible !important;
    padding: 0 !important; gap: 20px !important;
  }
  /* The report is a fixed-column document. On a narrow settings frame it must scroll
     sideways inside its own box — a table that overflows silently drops its right-hand
     column (Tenant) off the edge instead of erroring. */
  #settings-subpage [data-subpage-host="report-modal"] .rpt-preview {
    order: 1; overflow-x: auto !important; overflow-y: visible !important;
  }
  #settings-subpage [data-subpage-host="report-modal"] .rpt-side {
    order: 2; width: 100% !important; max-width: 460px; overflow: visible !important;
    border-top: 1px solid var(--border2); padding-top: 20px;
  }
  /* Settings restyles .form-input without a width, so the subject and message boxes
     fall back to the browser's default 160px inside a 460px column. */
  #settings-subpage [data-subpage-host="report-modal"] .rpt-side .form-input { width: 100%; }

  /* End relationship hosted as a sub-page. NOTHING IN SETTINGS IS A POPUP — this
     card is always presented as its own full panel with the header Back button,
     never stacked on top of the settings sheet. What is left over is the popup
     chrome the .modal base rule gives it: a drag handle, a shadow, a rounded
     shell, and on a phone a fixed 85dvh bottom-sheet height that would strand
     the third choice below the fold. All of it is removed here so the panel
     scrolls as one page, the way the company page it opens from does. */
  #settings-subpage [data-subpage-host="end-rel-modal"] {
    background: none !important; border: none !important; box-shadow: none !important;
    border-radius: 0 !important; overflow: visible !important;
    display: block !important; height: auto !important; max-height: none !important;
  }
  #settings-subpage [data-subpage-host="end-rel-modal"]::before { display: none !important; }
  #settings-subpage [data-subpage-host="end-rel-modal"] .modal-body {
    padding: 0 !important; overflow: visible !important; flex: none !important;
    min-height: 0 !important;
  }
  /* Settings restyles .form-input without a width, so the Type DELETE box would
     fall back to the browser's default 160px. */
  #settings-subpage [data-subpage-host="end-rel-modal"] .erx-type input { width: 100%; max-width: 220px; }

  /* Team member Files hosted as a sub-page. Same treatment as End relationship:
     the .modal base rule would leave it a drag handle, a shadow, a rounded shell
     and an 85dvh bottom-sheet height on a phone. It is a page, so it scrolls with
     the page, the file list is not capped inside a second scroller, and the
     footer Close button goes — Back in the settings header is the way out. */
  #settings-subpage [data-subpage-host="agent-docs-modal"] {
    background: none !important; border: none !important; box-shadow: none !important;
    border-radius: 0 !important; overflow: visible !important;
    display: block !important; height: auto !important; max-height: none !important;
  }
  #settings-subpage [data-subpage-host="agent-docs-modal"]::before { display: none !important; }
  #settings-subpage [data-subpage-host="agent-docs-modal"] .modal-body {
    padding: 0 !important; overflow: visible !important; flex: none !important;
    min-height: 0 !important;
  }
  #settings-subpage [data-subpage-host="agent-docs-modal"] #agent-docs-list {
    max-height: none !important; overflow: visible !important;
  }
  #settings-subpage [data-subpage-host="agent-docs-modal"] .modal-footer { display: none !important; }

  /* ── Team-member detail page (Settings → Team members → tap a row) ──
     A clean, full-surface page inside the settings window. Replaces the old
     "User Settings" popup, which opened BEHIND the settings sheet and couldn't
     be reached. Uses the shared .settings-subpage host above. */
  .tmd { max-width: 720px; margin: 0 auto; display: flex; flex-direction: column; gap: 14px; }
  .tmd-hero {
    display: flex; align-items: center; gap: 14px; padding: 18px 20px;
    border: 1px solid var(--border2); border-radius: 16px; background: var(--bg);
  }
  .tmd-avatar {
    flex: 0 0 auto; width: 52px; height: 52px; border-radius: 50%;
    background: linear-gradient(135deg, #2563eb, #1e3a8a); color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: 17px; font-weight: 700; letter-spacing: .5px;
  }
  .tmd-hero-main { min-width: 0; flex: 1; }
  .tmd-hero-name {
    font-size: 17px; font-weight: 700; color: var(--text); letter-spacing: -.01em;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  .tmd-hero-sub {
    font-size: 13px; color: var(--text2); margin-top: 2px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  .tmd-hero-meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; justify-content: flex-end; }
  .tmd-chip {
    display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 99px;
    font-size: 11px; font-weight: 600; color: var(--text2); white-space: nowrap;
    background: var(--bg3); border: 1px solid var(--border2);
  }
  .tmd-chip i { width: 11px; height: 11px; }
  .tmd-chip.warn { color: #b45309; background: rgba(180,83,9,0.08); border-color: rgba(180,83,9,0.24); }
  .tmd-card { border: 1px solid var(--border2); border-radius: 16px; background: var(--bg); overflow: hidden; }
  .tmd-card-head { padding: 15px 20px 13px; border-bottom: 1px solid var(--border); }
  .tmd-card-title { font-size: 14px; font-weight: 700; color: var(--text); }
  .tmd-card-sub { font-size: 12px; color: var(--text2); margin-top: 3px; line-height: 1.5; }
  .tmd-card-body { padding: 16px 20px; display: flex; flex-direction: column; gap: 14px; }
  .tmd-field { display: flex; flex-direction: column; gap: 5px; }
  .tmd-field .form-label { margin: 0; }
  .tmd-field .form-input { width: 100%; }
  .tmd-value { font-size: 13px; color: var(--text); }
  .tmd-hint { font-size: 11.5px; color: var(--text3); line-height: 1.45; }
  .tmd-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 13px; }
  .tmd-photo-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
  .tmd-photo-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
  .tmd-photo-actions .btn { display: inline-flex; align-items: center; gap: 7px; }
  .tmd-photo-actions .btn i { width: 14px; height: 14px; }
  .tmd-avatar-sm { width: 44px; height: 44px; font-size: 15px; }
  /* Upload target on a detail page (company documents) */
  .mgd-drop {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 7px;
    border: 2px dashed var(--border2); border-radius: 12px; padding: 20px 16px; cursor: pointer;
    background: var(--bg2); transition: border-color .15s, background .15s;
  }
  .mgd-drop:hover, .mgd-drop.over { border-color: var(--accent); background: var(--accent-soft, rgba(37,99,235,0.06)); }
  .mgd-drop i { width: 24px; height: 24px; color: var(--text3); pointer-events: none; }
  .mgd-drop .t { font-size: 12.5px; color: var(--text2); }
  .mgd-drop .lnk { color: var(--accent); text-decoration: underline; }
  .mgd-drop .s { font-size: 11px; color: var(--text3); }
  .tmd-avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: inherit; display: block; }
  textarea.form-input { resize: vertical; min-height: 62px; font-family: inherit; }
  @media (max-width: 520px) { .tmd-grid-2 { grid-template-columns: 1fr; } }
  .tmd-card-foot {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 13px 20px; border-top: 1px solid var(--border); background: var(--bg2);
  }
  .tmd-status { font-size: 12px; color: var(--text3); min-height: 16px; line-height: 1.4; }
  /* "This address already has a login": the owner answers it in place. */
  .login-warn { margin: 12px 0; padding: 12px 14px; border-radius: 10px; background: var(--note-bg); border: 1px solid var(--note-bd); color: var(--note-fg); font-size: 13px; line-height: 1.45; text-align: left; }
  .login-warn strong { font-weight: 600; }
  .login-warn-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; margin-top: 10px; }
  .msx-body > .login-warn { margin: 12px 16px; }
  .tmd-card-body > .tmd-status:empty { display: none; }   /* no dead space before it's used */
  .tmd-actions { display: flex; flex-wrap: wrap; gap: 8px; }
  .tmd-actions .btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; }
  .tmd-actions .btn i { width: 14px; height: 14px; }
  .tmd-card.danger { border-color: rgba(220,38,38,0.28); }
  .tmd-card.danger .tmd-card-title { color: #b91c1c; }
  [data-theme="dark"] .tmd-card.danger .tmd-card-title { color: #f87171; }
  /* ── END RELATIONSHIP ─────────────────────────────────────────────────────
     ONE entry point on the company page, THREE ranked choices inside it.

     The first version put three destructive-looking boxes on the page and the
     CEO could not tell which one to press. The ranking now has to be readable
     at a glance, before a word is read: a coloured rail down the left of each
     choice (accent -> amber -> red), a rank pill on the same line as the title,
     and a size ladder — the recommended choice is tinted and sits at the top,
     the worst one is plain until you actually choose it, so the eye is never
     dragged towards deleting a company. */
  .erx-lead { font-size: 13px; color: var(--text2); line-height: 1.55; margin: 0 0 13px; }
  .erx-lead b { color: var(--text); font-weight: 600; }
  .erx-opts { display: flex; flex-direction: column; gap: 9px; }
  .erx-opt {
    position: relative; display: block; width: 100%; text-align: left;
    border: 1.5px solid var(--border2); border-radius: 12px;
    background: var(--bg); padding: 12px 14px 12px 26px; cursor: pointer;
    font: inherit; color: inherit; transition: border-color .12s, background .12s, box-shadow .12s;
  }
  /* The rail. This is the ranking, said in colour before it is said in words. */
  .erx-opt::before {
    content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 5px;
    border-radius: 12px 0 0 12px; background: var(--erx-c);
  }
  .erx-opt:hover { border-color: var(--erx-c); }
  .erx-opt.sel { border-color: var(--erx-c); background: var(--erx-tint); box-shadow: 0 0 0 3px var(--erx-ring); }
  .erx-opt.off { opacity: .45; cursor: not-allowed; }
  .erx-opt.safe    { --erx-c: #2563eb; --erx-tint: rgba(37,99,235,0.07);  --erx-ring: rgba(37,99,235,0.13); }
  .erx-opt.serious { --erx-c: #b45309; --erx-tint: rgba(180,83,9,0.07);   --erx-ring: rgba(180,83,9,0.13); }
  .erx-opt.worst   { --erx-c: #b91c1c; --erx-tint: rgba(185,28,28,0.07);  --erx-ring: rgba(185,28,28,0.13); }
  [data-theme="dark"] .erx-opt.safe    { --erx-c: #60a5fa; }
  [data-theme="dark"] .erx-opt.serious { --erx-c: #fbbf24; }
  [data-theme="dark"] .erx-opt.worst   { --erx-c: #f87171; }
  .erx-opt-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
  .erx-dot {
    flex: none; width: 16px; height: 16px; border-radius: 50%;
    border: 1.5px solid var(--border2); background: var(--bg);
  }
  .erx-opt.sel .erx-dot { border-color: var(--erx-c); border-width: 5px; }
  .erx-opt-title { font-size: 14.5px; font-weight: 700; color: var(--text); }
  .erx-pill {
    font-size: 10px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase;
    padding: 3px 7px; border-radius: 999px; color: #fff; background: var(--erx-c);
    white-space: nowrap;
  }
  [data-theme="dark"] .erx-pill { color: #10131a; }
  .erx-opt-count { margin: 7px 0 0; font-size: 13.5px; font-weight: 700; color: var(--erx-c); line-height: 1.4; }
  .erx-opt-line { margin: 4px 0 0; font-size: 12.5px; color: var(--text2); line-height: 1.5; }
  .erx-opt-line.stop { font-weight: 700; color: var(--erx-c); }
  .erx-opt-foot { margin: 6px 0 0; font-size: 12px; color: var(--text2); line-height: 1.5; }
  .erx-note { font-size: 12px; color: var(--text3); line-height: 1.55; margin-top: 10px; }
  .erx-note b { color: var(--text2); }
  .erx-status { font-size: 12.5px; line-height: 1.5; margin-top: 10px; min-height: 1px; color: var(--text3); }
  .erx-foot {
    display: flex; gap: 8px; justify-content: flex-end; align-items: center;
    margin-top: 14px; padding-top: 13px; border-top: 1px solid var(--border);
  }
  .erx-done { display: flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 700; color: #0f9d6b; }
  .erx-done i { width: 18px; height: 18px; flex: none; }
  /* The linked-sheet block. Amber, not red: it is a stop, not a disaster, and
     the way past it is right there inside the box. It applies to ALL THREE
     choices — any of them would be undone by the next sync. */
  .erx-alert {
    margin-top: 13px; border: 1px solid rgba(180,83,9,0.32); border-radius: 12px;
    background: rgba(245,158,11,0.08); padding: 13px 14px;
  }
  .erx-alert-t {
    display: flex; align-items: center; gap: 7px;
    font-size: 12.5px; font-weight: 700; color: #b45309;
  }
  [data-theme="dark"] .erx-alert-t { color: #fbbf24; }
  .erx-alert-t i { width: 15px; height: 15px; flex: none; }
  .erx-alert-l { margin: 8px 0 0; padding-left: 20px; font-size: 12px; color: var(--text2); line-height: 1.6; }
  .erx-alert-b { font-size: 12px; color: var(--text2); line-height: 1.55; margin-top: 8px; }
  .erx-check {
    display: flex; align-items: flex-start; gap: 9px; margin-top: 11px;
    font-size: 12px; color: var(--text2); line-height: 1.5; cursor: pointer;
  }
  /* Width/height alone lose to the mobile form reset, which sizes every input
     to a 44px tap target — the box rendered as an empty grey slab on a phone.
     min/max pin it, and appearance restores the native tick. */
  .erx-check input[type="checkbox"] {
    margin: 2px 0 0; flex: none; accent-color: var(--accent);
    width: 16px; height: 16px; min-width: 16px; min-height: 16px;
    max-width: 16px; max-height: 16px; padding: 0;
    -webkit-appearance: checkbox; appearance: checkbox; border-radius: 3px;
  }
  .erx-go-worst, .erx-go-worst:hover {
    background: #b91c1c !important; border-color: #b91c1c !important; color: #fff !important;
  }
  .erx-type { margin-top: 13px; }
  .erx-type label { display: block; font-size: 12px; font-weight: 600; color: var(--text2); margin-bottom: 6px; }
  .erx-type input { width: 100%; max-width: 220px; letter-spacing: .12em; font-weight: 700; }
  @media (max-width: 640px) {
    .tmd-hero { flex-wrap: wrap; }
    .tmd-hero-meta { justify-content: flex-start; width: 100%; }
    .tmd-card-foot { flex-direction: column; align-items: stretch; }
    .tmd-card-foot .tmd-actions .btn { width: 100%; }
  }
  /* Quiet grouped nav: a plain panel, grey group labels, plain text items, and a
     soft grey pill for the one you are on. No glass, no gradient, no per-item
     icons — 41 little blue glyphs down the side is noise, not navigation. Built
     on tokens so it holds up in both themes. */
  .settings-nav {
    display: flex; flex-direction: column; gap: 2px;
    background:
      linear-gradient(160deg, rgba(255,255,255,0.72) 0%, rgba(210,230,255,0.62) 60%, rgba(160,200,255,0.55) 100%);
    backdrop-filter: blur(20px) saturate(1.8); -webkit-backdrop-filter: blur(20px) saturate(1.8);
    border: 1px solid rgba(200,220,255,0.55);
    border-radius: 16px; padding: 12px 8px;
    position: sticky; top: 20px;
    box-shadow:
      0 8px 32px rgba(20,50,140,0.15),
      0 2px 8px rgba(30,70,160,0.10),
      inset 0 1px 0 rgba(255,255,255,0.8),
      inset 0 -1px 0 rgba(80,130,210,0.12);
  }
  .settings-nav-label {
    font-size: 10px; font-weight: 700; color: #2a4a85;
    text-transform: uppercase; letter-spacing: 0.1em;
    padding: 12px 10px 4px; opacity: 0.75;
  }
  .settings-nav-label:first-child { padding-top: 4px; }
  .settings-tab {
    display: flex; align-items: center; gap: 9px;
    padding: 8px 10px; font-size: 13px; color: rgba(26,51,112,0.75);
    background: none; border: none; border-radius: 9px;
    cursor: pointer; text-align: left; width: 100%;
    transition: background 0.15s, color 0.15s, box-shadow 0.15s;
  }
  .settings-tab i { width: 14px; height: 14px; }
  .settings-tab:hover {
    background: rgba(255,255,255,0.5);
    color: #1a3370;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.6);
  }
  .settings-tab.active {
    background: linear-gradient(135deg, #4a85f0 0%, #2560d8 100%);
    color: #fff;
    box-shadow: 0 4px 12px rgba(40,90,210,0.35), inset 0 1px 0 rgba(255,255,255,0.25);
  }
  .settings-tab.active i { color: #fff; }

  /* Field-options expandable group */
  .settings-tab-parent .fo-chevron {
    width: 13px; height: 13px; opacity: 0.7;
    transition: transform 0.2s ease;
  }
  .settings-tab-parent.open .fo-chevron { transform: rotate(90deg); }
  .settings-tab-children {
    display: none;
    flex-direction: column; gap: 1px;
    margin: 1px 0 3px 14px;
    padding-left: 8px;
  }
  .settings-tab-children.open { display: flex; }
  #page-settings .role-hidden { display: none !important; }
  .settings-merge-strip { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 14px 0 8px; }
  .settings-merge-pill { border: 1px solid var(--border2); background: var(--bg); color: var(--text2); border-radius: 999px; padding: 6px 12px; font-size: 12.5px; font-weight: 500; cursor: pointer; font-family: inherit; }
  .settings-merge-pill:hover { background: var(--bg2); }
  .settings-merge-pill.active { background: var(--bg2); color: var(--text); border-color: var(--text3); font-weight: 600; }
  #msx .settings-merge-strip { display: none !important; }
  .settings-tab-child {
    font-size: 12.5px; padding: 6px 8px 6px 10px; gap: 8px;
  }
  .settings-tab-child i { width: 13px; height: 13px; opacity: 0.8; }

  /* ── Settings nav search (filters the menu of settings options) ── */
  .settings-nav-search {
    position: sticky; top: 0; z-index: 6;
    display: flex; align-items: center; gap: 7px;
    margin: 0 0 8px; padding: 8px 10px;
    background: rgba(247,250,255,0.94);
    backdrop-filter: blur(10px) saturate(1.4);
    -webkit-backdrop-filter: blur(10px) saturate(1.4);
    border: 1px solid rgba(200,220,255,0.7);
    border-radius: 10px;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.8), 0 1px 4px rgba(30,70,160,0.07);
  }
  .settings-nav-search-icon { width: 14px; height: 14px; color: #2a4a85; opacity: 0.65; flex: 0 0 auto; }
  .settings-nav-search-input {
    flex: 1 1 auto; min-width: 0; padding: 0;
    border: none; background: none; outline: none;
    font-size: 13px; color: #1a3370; font-family: inherit;
  }
  .settings-nav-search-input::placeholder { color: rgba(42,74,133,0.5); }
  .settings-nav-search-clear {
    flex: 0 0 auto; display: flex; align-items: center; justify-content: center;
    width: 18px; height: 18px; padding: 0;
    border: none; border-radius: 50%; cursor: pointer;
    background: rgba(42,74,133,0.12); color: #2a4a85;
    transition: background 0.15s;
  }
  .settings-nav-search-clear:hover { background: rgba(42,74,133,0.22); }
  .settings-nav-search-clear i { width: 11px; height: 11px; }
  .settings-nav-empty { font-size: 12px; color: rgba(42,74,133,0.6); padding: 10px; text-align: center; }
  /* #36 — search inputs get an always-visible clear (✕) once they hold text, so the box
     can be wiped in one click without select-all. Custom-masked so it themes with the UI. */
  input[type="search"]::-webkit-search-cancel-button {
    -webkit-appearance: none; appearance: none;
    height: 15px; width: 15px; margin-left: 6px; cursor: pointer;
    background: currentColor; opacity: 0.4;
    -webkit-mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.5' stroke-linecap='round'><path d='M18 6 6 18M6 6l12 12'/></svg>") center/contain no-repeat;
            mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.5' stroke-linecap='round'><path d='M18 6 6 18M6 6l12 12'/></svg>") center/contain no-repeat;
  }
  input[type="search"]::-webkit-search-cancel-button:hover { opacity: 0.75; }
  /* #36 — the "‹" back chevron is a mobile detail-view affordance; on desktop the nav
     is always visible and there's a close ✕, so the stray unaligned chevron is hidden. */
  #page-settings .settings-mobile-back { display: none; }
  /* #20 — custom dropdown whose option list opens perfectly flush/aligned under its box
     (native <select> lists are OS-positioned and can't be centered). */
  .cs-wrap { position: relative; width: 100%; }
  .cs-btn { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 8px; text-align: left; cursor: pointer; }
  .cs-btn > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .cs-btn > i { width: 15px; height: 15px; opacity: 0.55; flex-shrink: 0; transition: transform 0.15s; }
  .cs-wrap.open .cs-btn > i { transform: rotate(180deg); }
  /* The menu is body-mounted (position:fixed) so it never gets clipped by a modal or
     drawer's overflow; JS sets left/top/width to match the trigger box exactly, so the
     list is flush and symmetrical with the box it drops from. */
  .cs-menu { position: fixed; z-index: 100002;
    background: var(--bg); border: 1px solid var(--border2); border-radius: 9px;
    box-shadow: var(--shadow-md); padding: 4px; max-height: 260px; overflow-y: auto; }
  .cs-menu[hidden] { display: none; }

  /* ── Linked spreadsheets ───────────────────────────────────────────────────
     Grouped inset lists: white cards, a hairline instead of a border, one
     accent, no pills and no badges. Built on the app's own tokens rather than
     hard-coded greys, because this page ships in both themes — the wizard next
     door already shipped once in hard-coded light colours and was unreadable in
     dark mode. */
  .lsx-head { display:flex; align-items:flex-start; gap:18px; margin:2px 0 22px; }
  .lsx-head-text { flex:1; min-width:0; }
  .lsx-title { font-size:19px; font-weight:600; letter-spacing:-0.021em; color:var(--text); margin:0; }
  .lsx-sub   { font-size:12.5px; color:var(--text2); margin:7px 0 0; line-height:1.5; letter-spacing:-0.006em; }
  .lsx-card  { background:var(--bg); border-radius:14px; box-shadow:0 0 0 1px var(--border2); overflow:hidden; margin-bottom:18px; }
  .lsx-pad   { padding:16px 18px; }
  .lsx-div   { height:1px; background:var(--border); }

  .lsx-big   { font-size:26px; font-weight:600; letter-spacing:-0.022em; color:var(--text);
               font-variant-numeric:tabular-nums; line-height:1; }
  .lsx-muted { color:var(--text2); font-size:13px; letter-spacing:-0.011em; }
  .lsx-right { color:var(--text2); font-size:12px; letter-spacing:-0.008em; text-align:right; }

  /* freshness bar — flex-weighted by unit count, never a chart */
  .lsx-bar    { display:flex; gap:3px; height:8px; margin:15px 0 11px; }
  .lsx-bar > i { border-radius:4px; display:block; }
  .lsx-legend { display:flex; flex-wrap:wrap; gap:15px; font-size:12px; color:var(--text2); letter-spacing:-0.006em; }
  .lsx-legend span { display:inline-flex; align-items:center; gap:7px; }

  .lsx-dot { width:9px; height:9px; border-radius:50%; flex:0 0 auto; display:inline-block; }
  .lsx-dot.is-current { background:var(--ls-good); }
  .lsx-dot.is-reading { background:var(--accent); animation:lsx-pulse 1.8s ease-in-out infinite; }
  .lsx-dot.is-stalled { background:var(--danger); }
  .lsx-dot.is-paused  { background:var(--text3, var(--text2)); opacity:.55; }
  @keyframes lsx-pulse { 0%,100% { opacity:1; } 50% { opacity:.3; } }
  @media (prefers-reduced-motion: reduce) { .lsx-dot.is-reading { animation:none; } }

  /* a row is a button: the whole thing is the disclosure target */
  .lsx-row { display:flex; align-items:center; gap:13px; width:100%; text-align:left;
             background:none; border:0; padding:13px 18px; cursor:pointer; color:inherit; font:inherit; }
  .lsx-row:hover { background:var(--bg2); }
  .lsx-row:focus-visible { outline:2px solid var(--accent); outline-offset:-2px; }
  .lsx-name { font-size:13.5px; font-weight:500; letter-spacing:-0.011em; color:var(--text); }
  .lsx-line { font-size:12px; color:var(--text2); margin-top:3px; letter-spacing:-0.006em; }
  .lsx-line.is-problem { color:var(--danger); }
  .lsx-when { font-size:12px; color:var(--text2); font-variant-numeric:tabular-nums; white-space:nowrap; }
  .lsx-when.is-reading { color:var(--accent); }
  /* "We re-read your sheet and your units moved." News, not a fault — so it
     wears the accent blue, never the amber a real problem uses. */
  .lsx-new { display:inline-flex; align-items:center; padding:2px 9px; border-radius:20px;
             font-size:11px; font-weight:600; white-space:nowrap; letter-spacing:-0.004em;
             background:rgba(37,99,235,0.10); color:var(--accent); border:1px solid rgba(37,99,235,0.35); }
  .lsx-review { display:flex; align-items:center; gap:14px; flex-wrap:wrap;
                padding:12px 14px; margin-bottom:14px; border-radius:12px;
                background:rgba(37,99,235,0.07); border:1px solid rgba(37,99,235,0.28); }
  .lsx-review-t { flex:1; min-width:200px; font-size:12.5px; color:var(--text); line-height:1.6; }
  .lsx-chev { color:var(--text3, var(--text2)); opacity:.55; transition:transform 220ms ease-out; flex:0 0 auto; }
  .lsx-row[aria-expanded="true"] .lsx-chev { transform:rotate(90deg); }


  .lsx-kv { display:flex; align-items:baseline; gap:14px; padding:11px 0; border-top:1px solid var(--border); }
  .lsx-kv-k { width:100px; flex:0 0 auto; font-size:12.5px; color:var(--text2); letter-spacing:-0.006em; }
  .lsx-kv-v { flex:1; font-size:12.5px; color:var(--text); letter-spacing:-0.006em; line-height:1.55; }
  .lsx-act  { background:none; border:0; padding:0; font:inherit; font-size:12.5px; color:var(--accent);
              cursor:pointer; white-space:nowrap; }
  .lsx-act:hover { text-decoration:underline; }
  .lsx-act.is-danger { color:var(--danger); }

  .lsx-map   { display:grid; grid-template-columns:auto auto 1fr; gap:5px 11px; align-items:baseline; margin-top:9px; }
  .lsx-map-c { font-family:ui-monospace,SFMono-Regular,Menlo,monospace; font-size:11.5px; color:var(--text2); }
  .lsx-map-a { color:var(--text3, var(--text2)); opacity:.6; font-size:11.5px; }
  .lsx-map-f { font-size:12.5px; color:var(--text); }
  .lsx-ignored { font-size:11.5px; color:var(--text2); opacity:.85; margin-top:10px; line-height:1.6; }

  /* ── Linked spreadsheets: the review screen and the client picker ────────────
     Greys only: a flagged row is a question, not an alarm, so nothing here is
     tinted. Buttons are the app's own .btn / .btn-primary (the lighter brand
     blue); these classes only size them. Declared at top level, not inside a
     breakpoint, so the phone block below only changes sizes and inherits the
     rest. */
  .lsf-wrap { padding:20px 24px 32px; }
  .lsf-top { display:flex; align-items:flex-start; gap:16px; margin:2px 0 16px; }
  .lsf-banner { padding:10px 14px; margin-bottom:16px; border-radius:10px; font-size:12.5px; line-height:1.5;
                color:var(--text); background:var(--bg3); border:1px solid var(--border2); }
  .lsx-review.lsf-reviewbox { background:var(--bg3); border-color:var(--border2); }
  .lsf-card { margin-bottom:16px; }
  .lsf-gh { display:flex; align-items:center; gap:8px; padding:13px 18px 9px; font-size:11px; font-weight:700;
            letter-spacing:.06em; text-transform:uppercase; color:var(--text2); }
  .lsf-gn { margin-left:auto; min-width:22px; padding:1px 8px; border-radius:12px; text-align:center;
            background:var(--bg3); border:1px solid var(--border2); color:var(--text); letter-spacing:0; }
  .lsf-item { padding:14px 18px 16px; border-top:1px solid var(--border); }
  .lsf-itop { display:flex; align-items:baseline; gap:12px; }
  .lsf-title { flex:1; min-width:0; font-size:13.5px; font-weight:600; letter-spacing:-0.011em; color:var(--text); overflow-wrap:anywhere; }
  .lsf-when { font-size:12px; color:var(--text2); white-space:nowrap; font-variant-numeric:tabular-nums; }
  .lsf-why { margin-top:4px; font-size:12.5px; line-height:1.55; color:var(--text2); }
  .lsf-hint { margin-top:8px; font-size:12px; line-height:1.55; color:var(--text2); }
  .lsf-cmp { display:grid; grid-template-columns:104px minmax(0,1fr) minmax(0,1fr); margin-top:12px;
             border:1px solid var(--border2); border-radius:10px; overflow:hidden; font-size:12.5px; background:var(--bg); }
  .lsf-cmp > div { padding:8px 12px; border-top:1px solid var(--border); color:var(--text); overflow-wrap:anywhere; line-height:1.45; }
  .lsf-cmp > .h { border-top:0; background:var(--bg2); font-size:10px; font-weight:700; letter-spacing:.06em;
                  text-transform:uppercase; color:var(--text2); }
  .lsf-cmp > .k { color:var(--text2); }
  .lsf-blank { color:var(--text2); opacity:.7; }
  .lsf-acts { display:flex; flex-wrap:wrap; align-items:center; gap:8px; margin-top:12px; }
  .lsf-btn { padding:5px 14px; font-size:12.5px; line-height:1.3; }
  .lsf-btn:disabled { opacity:.45; cursor:not-allowed; }
  /* the lighter brand blue in both themes, white text - a phone dark-mode rule
     elsewhere paints .btn-primary near-white, which is not this app's button */
  html .lsf-btn.btn-primary { background:var(--accent); border-color:var(--accent); color:#fff; }
  html .lsf-btn:not(.btn-primary) { background:transparent; border-color:var(--border2); color:var(--text); }
  .lsf-msg { font-size:12.5px; line-height:1.55; color:var(--text); margin-top:10px; }
  .lsf-err { margin-top:8px; font-size:12.5px; line-height:1.5; color:var(--danger); }
  .lsf-form { margin-top:12px; padding:12px 14px; border-radius:10px; background:var(--bg2); border:1px solid var(--border2); }
  .lsf-lab { display:block; margin:0 0 5px; font-size:12px; font-weight:600; color:var(--text); }
  .lsf-form .lsf-lab + .lsf-in.lsf-wide { margin-bottom:10px; }
  .lsf-line { display:flex; flex-wrap:wrap; align-items:center; gap:8px; }
  .lsf-in { box-sizing:border-box; height:34px; min-width:0; flex:1 1 180px; max-width:320px; padding:0 12px;
            border:1px solid var(--border2); border-radius:8px; background:var(--bg); color:var(--text);
            font:inherit; font-size:13px; }
  .lsf-in.lsf-wide { display:block; width:100%; max-width:none; }
  .lsf-in:focus { outline:2px solid var(--accent); outline-offset:-1px; }
  .lsf-pick { display:flex; flex-wrap:wrap; align-items:center; gap:6px; margin-top:12px; }
  .lsf-pick .lsf-lab { margin:0 4px 0 0; font-weight:500; color:var(--text2); }
  .lsf-chip { padding:4px 12px; border-radius:16px; border:1px solid var(--border2); background:var(--bg);
              color:var(--text); font:inherit; font-size:12.5px; cursor:pointer; }
  .lsf-chip:hover { background:var(--bg3); }
  .lsf-confirm { font-size:12.5px; line-height:1.55; color:var(--text); margin-bottom:10px; }
  .lsx-flagchip { display:inline-flex; align-items:center; padding:2px 9px; border-radius:20px; cursor:pointer;
                  font-size:11px; font-weight:600; white-space:nowrap; letter-spacing:-0.004em;
                  background:var(--bg3); color:var(--text); border:1px solid var(--border2); }
  .lsx-flagchip:hover { background:var(--bg2); }

  /* management-company picker: an inline list (it pushes content down rather than
     floating), so a scrolling wizard page can never clip it. */
  .lsp { position:relative; width:100%; }
  .lsp-in { width:100%; box-sizing:border-box; }
  .lsp-in { scroll-margin-top:16px; }
  .lsp-menu { margin-top:4px; max-height:260px; overflow-y:auto; border:1px solid var(--border2); border-radius:10px;
              background:var(--bg); padding:4px; }
  .lsp-menu[hidden] { display:none; }
  .lsp-opt { padding:8px 10px; border-radius:7px; font-size:13px; color:var(--text); cursor:pointer; line-height:1.35; }
  .lsp-opt:hover, .lsp-opt.is-active { background:var(--bg3); }
  .lsp-create { color:var(--accent); font-weight:600; }
  .lsp-more { padding:6px 10px; font-size:12px; color:var(--text2); }
  .lsp-note { margin-top:6px; min-height:16px; font-size:11.5px; line-height:1.5; color:var(--text2); }
  .lsp-note strong { color:var(--text); font-weight:600; }

  @media (max-width:768px) {
    .lsf-btn { min-height:44px; padding:0 16px; font-size:14px; flex:1 1 auto; }
    .lsf-in { height:44px; font-size:16px; max-width:none; flex:1 1 100%; }
    .lsf-line .lsf-btn { flex:1 1 40%; }
    .lsf-chip { min-height:44px; min-width:44px; padding:0 16px; font-size:14px; }
    .lsf-cmp { grid-template-columns:84px minmax(0,1fr) minmax(0,1fr); font-size:12px; }
    .lsf-cmp > div { padding:8px; }
    .lsf-wrap { padding:16px 16px calc(32px + var(--tabbar-space, 0px)); }
    .lsf-item, .lsf-gh { padding-left:14px; padding-right:14px; }
    .lsp-in { font-size:16px; min-height:44px; }
    .lsp-menu { max-height:min(260px, 34vh); }
    .lsp-opt { min-height:44px; display:flex; align-items:center; font-size:15px; }
    .lsp-note .lsx-act { min-height:44px; }
  }

  /* The mapping step's "we can't read this" tag. It replaced a bold amber SPAN
     reading "· check this" that had no handler at all — it looked exactly like
     a control, and the first person to use it pressed it and nothing happened.
     A <button> element, so it is keyboard reachable and announces itself. */
  .ls-flag { display:inline-flex; align-items:center; gap:5px; padding:3px 10px;
             border-radius:20px; font:inherit; font-size:11px; font-weight:600;
             cursor:pointer; white-space:nowrap;
             background:var(--ls-warn-soft, rgba(180,83,9,0.12));
             color:var(--ls-warn); border:1px solid var(--ls-warn); }
  .ls-flag:hover { filter:brightness(1.08); }
  .ls-flag:focus-visible { outline:2px solid var(--accent); outline-offset:2px; }
  /* The dropdown is where the problem is actually fixed, so the dropdown is
     what carries the warning — not a word floating in the next column. */
  select.ls-needs { border-color:var(--ls-warn) !important; }

  .lsx-foot { font-size:12px; color:var(--text2); opacity:.85; line-height:1.6; padding:2px 2px 8px; }
  .lsx-conn { display:flex; align-items:center; gap:14px; padding:13px 18px; }
  .lsx-conn-k { flex:1; font-size:13.5px; color:var(--text); letter-spacing:-0.011em; }
  .lsx-conn-v { font-size:12.5px; color:var(--text2); overflow:hidden; text-overflow:ellipsis; white-space:nowrap; max-width:46%; }

  /* Google's own file-picker dialog. Google mounts it on <body> with a z-index in
     the low thousands, which puts it UNDERNEATH the Settings sheet it was opened
     from — the same trap the Team-member popup and this wizard both fell into,
     except this dialog is an iframe we do not own, so it cannot be re-hosted as a
     settings sub-page the way settingsHostModalAsSubpage does. Stacking is the one
     lever we have, so take it well clear of the app's own ceiling (100002).
     !important is required: Google sets the z-index inline. */
  .picker-dialog-bg { z-index: 2000000 !important; }
  .picker-dialog    { z-index: 2000001 !important; }
  .cs-opt { display: block; width: 100%; text-align: left; padding: 8px 10px; font-size: inherit;
    background: none; border: none; color: var(--text); cursor: pointer; border-radius: 6px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .cs-opt:hover, .cs-opt:focus { background: var(--bg3); outline: none; }
  .cs-opt.sel { background: var(--bg3); font-weight: 600; }
  .cs-search { position: sticky; top: 0; width: 100%; box-sizing: border-box; padding: 8px 10px;
    border: none; border-bottom: 1px solid var(--border2); background: var(--bg2); color: var(--text);
    font-size: 13px; font-family: inherit; outline: none; }
  /* Native <select> kept as the value store but visually hidden here — NOT via display:none,
     so app code can still toggle sel.style.display to show/hide the field (cs mirrors that
     onto the wrapper). */
  .cs-native-hidden { position: absolute !important; width: 1px !important; height: 1px !important;
    min-width: 0 !important; max-width: 1px !important; min-height: 0 !important;
    padding: 0 !important; margin: -1px !important; overflow: hidden !important;
    clip: rect(0,0,0,0) !important; clip-path: inset(50%) !important;
    white-space: nowrap !important; border: 0 !important; }
  /* Companion styling so enhanced buttons keep the bespoke look of a few specially-styled
     selects (that styling was keyed to the now-hidden native <select> / its id). */
  .cdf-select.cs-btn { border: none; background: transparent; padding: 2px 0; }
  .iu-row .cs-btn { font-size: 11px; padding: 3px 6px; }
  .tpl-mgr-edit .cs-btn { background: var(--bg2); }
  .cs-wrap[data-cs-for="showing-status"] { width: auto; }
  .cs-btn[data-cs-for="showing-status"] { min-width: 130px; }
  #page-settings .cs-wrap[data-cs-for="trs-digest-hour"],
  #page-settings .cs-wrap[data-cs-for="trs-escalate-days"] { width: 196px; flex: 0 0 auto; margin-left: auto; }
  .mk-selwrap:has(.cs-wrap)::after { display: none; }

  [data-theme="dark"] .settings-nav-search {
    background: rgba(18,30,58,0.94);
    border-color: rgba(80,130,210,0.3);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.05), 0 1px 4px rgba(0,0,0,0.25);
  }
  [data-theme="dark"] .settings-nav-search-icon { color: rgba(150,185,240,0.8); }
  [data-theme="dark"] .settings-nav-search-input { color: rgba(210,225,255,0.95); }
  [data-theme="dark"] .settings-nav-search-input::placeholder { color: rgba(150,185,240,0.5); }
  [data-theme="dark"] .settings-nav-search-clear { background: rgba(150,185,240,0.18); color: rgba(200,220,255,0.95); }
  [data-theme="dark"] .settings-nav-search-clear:hover { background: rgba(150,185,240,0.3); }
  [data-theme="dark"] .settings-nav-empty { color: rgba(150,185,240,0.6); }

  @media (max-width: 820px) {
    .settings-nav-search { position: static; flex: 1 1 100%; width: 100%; margin: 0 0 6px; }
  }

  /* Field-options row UI */
  .fo-row .form-input.fo-label {
    padding: 5px 8px; height: 30px; line-height: 1;
    background: rgba(255,255,255,0.7);
  }
  .fo-row .btn { line-height: 1; }
  .fo-row .fo-handle:active { cursor: grabbing; }
  .fo-default-on { box-shadow: 0 0 0 1px #f59e0b inset; }
  [data-theme="dark"] .fo-row { background: rgba(255,255,255,0.04) !important; }
  [data-theme="dark"] .fo-row-readonly { background: rgba(255,255,255,0.02) !important; }
  [data-theme="dark"] .fo-row .form-input.fo-label { background: rgba(20,28,48,0.5); }

  .settings-panels { display: flex; flex-direction: column; gap: 16px; min-width: 0; min-height: 540px; }

  /* ── Settings as a bounded frame (desktop ≥821px) ──────────────────────
     The header stays pinned; the nav and content columns each fill to the
     bottom of the screen and scroll INTERNALLY when their content is taller
     than the viewport — the page itself never grows/scrolls. The 22px bottom
     gap (shell padding-bottom) mirrors the 22px gap between the header and
     the content top. Mobile/tablet (≤820px) keep normal full-page scroll. */
  @media (min-width: 821px) {
    #page-settings { overflow: hidden; }
    .settings-shell {
      /* Fill leftover height under the sticky header; never grow past it. */
      flex: 1 1 auto; min-height: 0;
      /* Make the single grid row fill the shell (and cap children) so both
         columns stretch to the frame height instead of sizing to content. */
      grid-template-rows: minmax(0, 1fr);
      align-items: stretch;
      padding-bottom: 22px;
    }
    /* The nav scrolls internally. The .settings-panels container is just a
       flex column holding the active panel; the PANEL itself owns the scroll
       (set in the white-sheet rules below) so its white surface fills the
       frame and scrolls as one sheet. */
    .settings-nav {
      min-height: 0; overflow-y: auto; overflow-x: hidden;
      position: static; top: auto;
    }
    .settings-panels { min-height: 0; display: flex; flex-direction: column; }
    .settings-panel:not(#sp-permissions) { overflow-y: auto; overflow-x: hidden; }
    /* #sp-permissions is excluded from the white-sheet scroll rules above, so it
       needs its OWN height cascade here — otherwise it sizes to content, overflows
       the bounded frame, and (since the page clips at #page-settings) the bottom
       sections + Save become unreachable: "permissions won't scroll". Bound the
       card chain so the two inner columns (.perm-roles-col / .perm-sections-col,
       already overflow-y:auto) become the scrollers — the title stays pinned. */
    #sp-permissions { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; overflow-x: hidden; }
    #sp-permissions .settings-card { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
    #sp-permissions .settings-card-body { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
    #sp-permissions .perm-layout { flex: 1 1 auto; min-height: 0; }
  }
  /* ── Settings content = ONE white sheet per tab, sections divided by lines ──
     Each .settings-panel (singular = one tab) is the white surface and fills
     the bounded frame to the bottom. The .settings-card blocks inside it become
     flat, transparent sections separated by a top divider. #sp-permissions is
     excluded — it keeps its own two-panel (perm-layout) treatment. */
  .settings-panel:not(#sp-permissions) {
    background: #ffffff;
    border: 1px solid rgba(200,220,255,0.55);
    border-radius: 16px;
    box-shadow:
      0 8px 32px rgba(20,50,140,0.12),
      0 2px 8px rgba(30,70,160,0.08),
      inset 0 1px 0 rgba(255,255,255,0.75);
    /* Explicit axis only — a bare `overflow: hidden` here appears LATER in source
       than the @media(min-width:821px) `overflow-y:auto` above (equal specificity),
       so it would clobber it back to hidden and kill vertical scroll. Clip only x;
       the media query owns overflow-y (auto on desktop, visible/body-scroll ≤820). */
    overflow-x: hidden;
    /* Fill the bounded frame to the bottom and scroll internally if tall. */
    flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column;
  }
  .settings-panel:not(#sp-permissions) .settings-card {
    background: transparent;
    border: none;
    border-radius: 0;
    box-shadow: none;
    overflow: visible;
  }
  /* Divider line between stacked sections (not before the first). */
  .settings-panel:not(#sp-permissions) .settings-card + .settings-card {
    border-top: 1px solid rgba(200,220,255,0.55);
  }

  /* The office knowledge box is the ONLY source Pace answers policy questions
     from, and it shipped empty for every workspace. An empty textarea with a
     grey example in it reads as "already configured", so the blank state said
     nothing while Pace handed every fee, deposit, pet and parking question to a
     person. This states the consequence instead. Colours come from the --ls-warn
     pair, which is defined for both themes. */
  .ai-know-empty {
    margin: 6px 0 8px;
    padding: 10px 12px;
    border: 1px solid var(--ls-warn);
    border-left-width: 3px;
    border-radius: 8px;
    background: var(--ls-warn-soft);
    color: var(--text);
    font-size: 13px;
    line-height: 1.5;
  }
  .ai-know-empty strong { display: block; margin-bottom: 3px; color: var(--ls-warn); }
  .ai-know-empty[hidden] { display: none; }
  .settings-card-head {
    display: flex; align-items: flex-start; gap: 12px;
    padding: 18px 20px; border-bottom: 1px solid rgba(200,220,255,0.4);
    background: linear-gradient(180deg, rgba(255,255,255,0.28) 0%, rgba(255,255,255,0) 100%);
  }
  .settings-card-icon {
    flex-shrink: 0; width: 36px; height: 36px;
    background: linear-gradient(135deg, rgba(74,133,240,0.25) 0%, rgba(37,96,216,0.35) 100%);
    border: 1px solid rgba(100,160,240,0.35);
    border-radius: 9px; color: #2560d8;
    display: flex; align-items: center; justify-content: center;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.5);
  }
  .settings-card-icon i { width: 18px; height: 18px; }
  .settings-card-title { font-size: 14px; font-weight: 600; color: #1a3370; }
  .settings-card-sub   { font-size: 12px; color: #2a4a85; opacity: 0.8; margin-top: 2px; line-height: 1.5; }
  .settings-card-body  { padding: 18px 20px; }
  /* Settings forms: stack labels above full-width inputs so fields line up
     (the global .form-label is inline + .form-input has no width, which left
     fields starting at different spots / different widths). Inputs that set
     their own width / max-width / min-width inline are left untouched via the
     :not() guard, so deliberately-sized fields — area code, %, color swatch,
     side-by-side flex rows — keep their intended size. */
  .settings-panel .form-label { display: block; margin-bottom: 6px; }
  .settings-panel .form-input:not([style*="width"]) { width: 100%; box-sizing: border-box; }
  /* ── Permissions — GHL-style two-panel layout ── */
  #sp-permissions .settings-card-body { padding:0; overflow-y:auto; }
  .perm-layout { display:flex; min-height:540px; }

  /* Left: role list */
  .perm-roles-col {
    width:210px; min-width:190px; flex-shrink:0;
    border-right:1px solid rgba(100,150,220,0.18);
    padding:14px 10px; display:flex; flex-direction:column; gap:2px;
    overflow-y:auto;
  }
  .perm-roles-label {
    font-size:10px; font-weight:700; text-transform:uppercase; letter-spacing:0.6px;
    color:#94a3b8; padding:4px 6px 6px;
  }
  .perm-role-item {
    display:flex; align-items:center; gap:9px; padding:9px 10px; border-radius:9px;
    cursor:pointer; transition:background .14s; position:relative;
  }
  .perm-role-item:hover { background:rgba(100,150,220,0.08); }
  .perm-role-item.active { background:rgba(37,96,216,0.1); }
  .perm-role-item-icon {
    width:30px; height:30px; border-radius:8px; flex-shrink:0;
    background:rgba(37,96,216,0.09); display:flex; align-items:center;
    justify-content:center; color:#2560d8;
  }
  .perm-role-item.active .perm-role-item-icon { background:#2560d8; color:#fff; }
  .perm-role-item-info { flex:1; min-width:0; }
  .perm-role-item-name {
    font-size:13px; font-weight:600; color:#1a3370;
    white-space:nowrap; overflow:hidden; text-overflow:ellipsis;
  }
  .perm-role-item.active .perm-role-item-name { color:#2560d8; }
  .perm-role-item-badge { font-size:10px; color:#94a3b8; margin-top:1px; }
  .perm-role-item-del {
    background:none; border:none; color:#dc2626; cursor:pointer;
    padding:3px 6px; border-radius:4px; font-size:11px; line-height:1;
    opacity:0; transition:opacity .14s, background .14s;
  }
  .perm-role-item:hover .perm-role-item-del { opacity:1; }
  .perm-role-item-del:hover { background:rgba(220,38,38,0.1); }
  .perm-roles-divider { height:1px; background:rgba(100,150,220,0.14); margin:6px 4px; }
  .perm-add-role-btn {
    display:flex; align-items:center; gap:8px; padding:9px 10px; margin-top:4px;
    border:2px dashed rgba(100,150,220,0.3); border-radius:9px; background:none;
    color:#3a6cd8; font-size:12px; font-weight:500; cursor:pointer; width:100%; transition:all .14s;
  }
  .perm-add-role-btn:hover { background:rgba(100,150,220,0.07); border-color:#6699ff; }

  /* Right: sections panel */
  .perm-sections-col {
    flex:1; overflow-y:auto; padding:18px 22px;
    display:flex; flex-direction:column; min-width:0;
  }
  .perm-sections-header {
    display:flex; align-items:center; justify-content:space-between;
    margin-bottom:14px; gap:12px;
  }
  .perm-sections-title { font-size:16px; font-weight:700; color:#1a3370; }
  .perm-sections-badge {
    font-size:11px; color:#64748b; background:rgba(100,150,220,0.1);
    padding:3px 10px; border-radius:20px; white-space:nowrap;
  }
  .perm-search-bar {
    display:flex; align-items:center; gap:9px;
    background:rgba(100,150,220,0.06); border:1px solid rgba(100,150,220,0.18);
    border-radius:9px; padding:8px 12px; margin-bottom:10px;
  }
  .perm-search-bar i { color:#94a3b8; width:14px; height:14px; flex-shrink:0; }
  .perm-search-input {
    background:none; border:none; outline:none; font-size:13px;
    color:#1a3370; flex:1; padding:0;
  }
  /* Section groups */
  .perm-section-group { border-bottom:1px solid rgba(100,150,220,0.11); }
  .perm-section-group:last-child { border-bottom:none; }
  .perm-section-head {
    display:flex; align-items:center; gap:12px; padding:12px 0;
    cursor:pointer; user-select:none;
  }
  .perm-section-head-icon {
    width:32px; height:32px; border-radius:8px; flex-shrink:0;
    background:rgba(37,96,216,0.08); display:flex; align-items:center;
    justify-content:center; color:#2560d8;
  }
  .perm-section-head-label { flex:1; font-size:14px; font-weight:600; color:#1a3370; }
  .perm-section-master-wrap { display:flex; align-items:center; gap:7px; }
  .perm-section-toggle-lbl { font-size:11px; color:#94a3b8; min-width:20px; text-align:right; }
  /* Toggle switch */
  .perm-switch { position:relative; width:36px; height:20px; flex-shrink:0; display:inline-block; }
  .perm-switch input { opacity:0; width:0; height:0; position:absolute; }
  .perm-switch-track {
    position:absolute; inset:0; border-radius:20px;
    background:#e2e8f0; transition:background .18s; cursor:pointer;
  }
  .perm-switch input:checked + .perm-switch-track { background:#2560d8; }
  .perm-switch input:disabled + .perm-switch-track { cursor:default; opacity:0.7; }
  .perm-switch-thumb {
    position:absolute; top:2px; left:2px; width:16px; height:16px;
    border-radius:50%; background:#fff; transition:transform .18s;
    box-shadow:0 1px 3px rgba(0,0,0,0.2); pointer-events:none;
  }
  .perm-switch input:checked ~ .perm-switch-thumb { transform:translateX(16px); }
  .perm-section-chevron { color:#94a3b8; transition:transform .18s; width:16px; height:16px; }
  .perm-section-group.open .perm-section-chevron { transform:rotate(180deg); }
  .perm-section-body { display:none; padding:2px 0 14px 44px; }
  .perm-section-group.open .perm-section-body {
    display:grid; grid-template-columns:repeat(2,1fr); gap:8px;
  }
  .perm-check-item {
    display:flex; align-items:center; gap:8px; padding:8px 11px;
    border-radius:8px; background:rgba(100,150,220,0.04);
    border:1px solid rgba(100,150,220,0.12); cursor:pointer; transition:background .14s;
  }
  .perm-check-item:hover { background:rgba(100,150,220,0.1); }
  .perm-check-item.locked { cursor:default; opacity:0.75; }
  .perm-check-item input[type="checkbox"] { accent-color:#2560d8; width:14px; height:14px; cursor:pointer; flex-shrink:0; }
  .perm-check-item.locked input { cursor:default; }
  .perm-check-item-lbl { font-size:12px; font-weight:500; color:#2a4a85; }

  /* ── Dark mode ── */
  [data-theme="dark"] .perm-roles-col { border-right-color:rgba(100,150,255,0.14); }
  [data-theme="dark"] .perm-roles-label { color:rgba(180,210,255,0.45); }
  [data-theme="dark"] .perm-role-item:hover { background:rgba(100,150,255,0.08); }
  [data-theme="dark"] .perm-role-item.active { background:rgba(100,150,255,0.14); }
  [data-theme="dark"] .perm-role-item-icon { background:rgba(100,150,255,0.11); color:#7aa8ff; }
  [data-theme="dark"] .perm-role-item.active .perm-role-item-icon { background:#2560d8; color:#fff; }
  [data-theme="dark"] .perm-role-item-name { color:rgba(200,225,255,0.88); }
  [data-theme="dark"] .perm-role-item.active .perm-role-item-name { color:#7aa8ff; }
  [data-theme="dark"] .perm-role-item-badge { color:rgba(180,210,255,0.38); }
  [data-theme="dark"] .perm-roles-divider { background:rgba(100,150,255,0.11); }
  [data-theme="dark"] .perm-add-role-btn { color:#7aa8ff; border-color:rgba(100,150,255,0.24); }
  [data-theme="dark"] .perm-add-role-btn:hover { background:rgba(100,150,255,0.09); }
  [data-theme="dark"] .perm-sections-title { color:rgba(200,225,255,0.95); }
  [data-theme="dark"] .perm-sections-badge { background:rgba(100,150,255,0.1); color:rgba(180,210,255,0.5); }
  [data-theme="dark"] .perm-search-bar { background:rgba(100,150,255,0.06); border-color:rgba(100,150,255,0.18); }
  [data-theme="dark"] .perm-search-input { color:rgba(200,225,255,0.9); }
  [data-theme="dark"] .perm-search-bar i { color:rgba(180,210,255,0.38); }
  [data-theme="dark"] .perm-section-group { border-bottom-color:rgba(100,150,255,0.09); }
  [data-theme="dark"] .perm-section-head-icon { background:rgba(100,150,255,0.1); color:#7aa8ff; }
  [data-theme="dark"] .perm-section-head-label { color:rgba(200,225,255,0.9); }
  [data-theme="dark"] .perm-section-toggle-lbl { color:rgba(180,210,255,0.4); }
  [data-theme="dark"] .perm-switch-track { background:rgba(80,100,150,0.4); }
  [data-theme="dark"] .perm-section-chevron { color:rgba(180,210,255,0.38); }
  [data-theme="dark"] .perm-check-item { background:rgba(100,150,255,0.04); border-color:rgba(100,150,255,0.11); }
  [data-theme="dark"] .perm-check-item:hover { background:rgba(100,150,255,0.11); }
  [data-theme="dark"] .perm-check-item-lbl { color:rgba(180,210,255,0.78); }

  .settings-meta-row {
    display: flex; justify-content: space-between; align-items: center;
    padding: 10px 0; border-bottom: 1px solid rgba(200,220,255,0.45); font-size: 13px;
  }
  .settings-meta-row:last-child { border-bottom: none; }
  .settings-meta-row > span:first-child { color: #2a4a85; opacity: 0.85; }
  .settings-meta-row > span:last-child  { color: #1a3370; font-weight: 500; }

  @media (max-width: 820px) {
    .settings-shell { grid-template-columns: 1fr; }
    .settings-nav { position: static; flex-direction: row; flex-wrap: wrap; align-items: flex-start; align-content: flex-start; }
    .settings-nav-label { width: 100%; padding-top: 6px; }
    .settings-tab { flex: 1 1 auto; min-width: 130px; }
  }

