/* ==========================================================================
   Todmail Design System (Rev800)
   Tokens → base → components → layouts. Shared by webmail and admin console.
   ========================================================================== */

:root {
  --font: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Roboto, Arial, sans-serif;
  --font-display: "Segoe UI Variable Display", "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: "Cascadia Code", "JetBrains Mono", Consolas, ui-monospace, monospace;

  --accent-h: 16; --accent-s: 78%; --accent-l: 52%;
  --accent: hsl(var(--accent-h) var(--accent-s) var(--accent-l));
  --accent-strong: hsl(var(--accent-h) var(--accent-s) calc(var(--accent-l) - 8%));
  --accent-soft: hsl(var(--accent-h) var(--accent-s) var(--accent-l) / .12);
  --accent-softer: hsl(var(--accent-h) var(--accent-s) var(--accent-l) / .07);
  --on-accent: #fff;

  --bg: #f5f4f1;
  --bg-sunken: #efede9;
  --surface: #ffffff;
  --surface-2: #faf9f7;
  --surface-hover: #f3f1ed;
  --border: #e6e2dc;
  --border-strong: #d4cfc7;
  --text: #1c1a18;
  --text-2: #4a4641;
  --muted: #7a746c;
  --faint: #a8a199;

  --ok: #1f8a5b; --ok-soft: #1f8a5b1a;
  --warn: #b7791f; --warn-soft: #b7791f1f;
  --bad: #c9372c; --bad-soft: #c9372c17;
  --info: #2f6fbf; --info-soft: #2f6fbf17;

  --shadow-1: 0 1px 2px rgb(30 25 20 / .06), 0 1px 1px rgb(30 25 20 / .04);
  --shadow-2: 0 4px 14px rgb(30 25 20 / .08), 0 1px 3px rgb(30 25 20 / .06);
  --shadow-3: 0 18px 48px rgb(30 25 20 / .18), 0 4px 12px rgb(30 25 20 / .08);
  --radius-s: 6px; --radius: 9px; --radius-l: 14px; --radius-xl: 20px;

  --row-h: 72px;
  --topbar-h: 54px;
  --rail-w: 68px;
  --ease: cubic-bezier(.2,.7,.2,1);
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #121110;
  --bg-sunken: #0e0d0c;
  --surface: #1a1917;
  --surface-2: #1f1e1b;
  --surface-hover: #262421;
  --border: #2c2a26;
  --border-strong: #3a3732;
  --text: #ece8e2;
  --text-2: #c9c3ba;
  --muted: #958e84;
  --faint: #6c665e;
  --accent-soft: hsl(var(--accent-h) var(--accent-s) var(--accent-l) / .2);
  --accent-softer: hsl(var(--accent-h) var(--accent-s) var(--accent-l) / .11);
  --ok-soft: #2fb37a26; --warn-soft: #e0a23a26; --bad-soft: #ef5a4d24; --info-soft: #4f8fdf26;
  --ok: #3cbf86; --warn: #e3a63c; --bad: #ef6a5e; --info: #6aa5ec;
  --shadow-1: 0 1px 2px rgb(0 0 0 / .4);
  --shadow-2: 0 6px 18px rgb(0 0 0 / .45);
  --shadow-3: 0 24px 60px rgb(0 0 0 / .6);
  color-scheme: dark;
}

:root[data-accent="ocean"]  { --accent-h: 211; --accent-s: 72%; --accent-l: 48%; }
:root[data-accent="forest"] { --accent-h: 152; --accent-s: 55%; --accent-l: 36%; }
:root[data-accent="violet"] { --accent-h: 262; --accent-s: 58%; --accent-l: 56%; }
:root[data-accent="rose"]   { --accent-h: 343; --accent-s: 68%; --accent-l: 52%; }
:root[data-accent="graphite"] { --accent-h: 30; --accent-s: 6%; --accent-l: 30%; }
:root[data-theme="dark"][data-accent="graphite"] { --accent-l: 70%; --on-accent: #111; }
:root[data-density="compact"] { --row-h: 54px; }

/* ---------------- Base ---------------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; font: 14px/1.45 var(--font); color: var(--text); background: var(--bg);
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; overflow: hidden;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent-strong); text-decoration: none; }
a:hover { text-decoration: underline; }
:root[data-theme="dark"] a { color: hsl(var(--accent-h) var(--accent-s) 66%); }
h1, h2, h3, h4 { font-family: var(--font-display); margin: 0; letter-spacing: -.01em; }
h1 { font-size: 22px; font-weight: 650; }
h2 { font-size: 17px; font-weight: 640; }
h3 { font-size: 15px; font-weight: 620; }
::selection { background: var(--accent-soft); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.mono { font-family: var(--mono); font-size: 12.5px; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 12.5px; }
.hidden { display: none !important; }
.grow { flex: 1; min-width: 0; }
.row { display: flex; align-items: center; gap: 8px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
svg.i { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
svg.i.sm { width: 16px; height: 16px; }
svg.i.xs { width: 14px; height: 14px; }
svg.i.lg { width: 22px; height: 22px; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 10px; border: 3px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background-color: var(--faint); }
::-webkit-scrollbar-track { background: transparent; }

/* ---------------- Buttons ---------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 34px; padding: 0 14px;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); border-radius: var(--radius);
  font-weight: 560; font-size: 13.5px; cursor: pointer; white-space: nowrap; transition: background .12s, border-color .12s, box-shadow .12s, transform .06s;
  text-decoration: none !important;
}
.btn:hover { background: var(--surface-hover); }
.btn:active { transform: translateY(.5px); }
.btn:disabled { opacity: .5; cursor: default; pointer-events: none; }
.btn.primary { background: var(--accent); border-color: transparent; color: var(--on-accent); box-shadow: 0 1px 2px hsl(var(--accent-h) 60% 30% / .3), inset 0 1px 0 rgb(255 255 255 / .14); }
.btn.primary:hover { background: var(--accent-strong); }
.btn.danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 35%, var(--border)); }
.btn.danger:hover { background: var(--bad-soft); }
.btn.danger.solid { background: var(--bad); color: #fff; border-color: transparent; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-hover); }
.btn.sm { height: 28px; padding: 0 10px; font-size: 12.5px; border-radius: var(--radius-s); }
.btn.lg { height: 42px; padding: 0 20px; font-size: 14.5px; }
.btn.block { width: 100%; }
.icon-btn {
  display: inline-grid; place-items: center; width: 34px; height: 34px; border: 0; background: transparent; color: var(--text-2);
  border-radius: var(--radius); cursor: pointer; position: relative; transition: background .12s, color .12s;
}
.icon-btn:hover { background: var(--surface-hover); color: var(--text); }
.icon-btn.sm { width: 28px; height: 28px; border-radius: var(--radius-s); }
.icon-btn.active { color: var(--accent); background: var(--accent-softer); }
.icon-btn:disabled { opacity: .4; pointer-events: none; }
.icon-btn .dot { position: absolute; top: 6px; right: 6px; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); border: 2px solid var(--surface); }
.btn-group { display: inline-flex; }
.btn-group > .btn { border-radius: 0; margin-left: -1px; }
.btn-group > .btn:first-child { border-radius: var(--radius) 0 0 var(--radius); margin-left: 0; }
.btn-group > .btn:last-child { border-radius: 0 var(--radius) var(--radius) 0; }
.btn-group > .btn.on { background: var(--accent-soft); color: var(--accent-strong); border-color: color-mix(in srgb, var(--accent) 40%, var(--border)); z-index: 1; }
:root[data-theme="dark"] .btn-group > .btn.on { color: hsl(var(--accent-h) var(--accent-s) 70%); }
kbd { font: 11px var(--mono); padding: 1px 6px; border-radius: 5px; border: 1px solid var(--border-strong); border-bottom-width: 2px; background: var(--surface-2); color: var(--text-2); }

/* ---------------- Forms ---------------- */
.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 560; color: var(--text-2); min-width: 0; }
.field .hint { font-weight: 400; color: var(--muted); font-size: 12px; }
.input, .field input:not([type=checkbox]):not([type=radio]):not([type=color]), .field select, .field textarea, select.input, textarea.input {
  height: 36px; width: 100%; padding: 0 11px; border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--surface);
  color: var(--text); font-weight: 400; font-size: 14px; transition: border-color .12s, box-shadow .12s; outline: none;
}
.field textarea, textarea.input { height: auto; min-height: 90px; padding: 9px 11px; resize: vertical; line-height: 1.5; }
.input:focus, .field input:focus, .field select:focus, .field textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input::placeholder, .field input::placeholder, textarea::placeholder { color: var(--faint); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
@media (max-width: 700px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }
.check { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; font-size: 13.5px; color: var(--text); font-weight: 450; }
input[type=checkbox], input[type=radio] { accent-color: var(--accent); width: 16px; height: 16px; margin: 0; cursor: pointer; }
.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: 13.5px; font-weight: 450; color: var(--text); }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch .track { width: 36px; height: 21px; border-radius: 20px; background: var(--border-strong); position: relative; transition: background .15s; flex: none; }
.switch .track::after { content: ""; position: absolute; top: 2.5px; left: 2.5px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgb(0 0 0 / .3); transition: transform .18s var(--ease); }
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track::after { transform: translateX(15px); }
.switch input:focus-visible + .track { outline: 2px solid var(--accent); outline-offset: 2px; }
.search-box { position: relative; display: flex; align-items: center; }
.search-box svg { position: absolute; left: 11px; color: var(--muted); pointer-events: none; }
.search-box input { padding-left: 36px !important; }
.form-error { color: var(--bad); font-size: 13px; min-height: 18px; }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 14px 0; border-bottom: 1px solid var(--border); }
.setting-row:last-child { border-bottom: 0; }
.setting-row .label { font-weight: 560; }
.setting-row .desc { color: var(--muted); font-size: 12.5px; margin-top: 2px; max-width: 60ch; }

/* ---------------- Pills / badges ---------------- */
.pill { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 9px; border-radius: 30px; font-size: 12px; font-weight: 560; background: var(--surface-hover); color: var(--text-2); white-space: nowrap; }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.info { background: var(--info-soft); color: var(--info); }
.pill.accent { background: var(--accent-soft); color: var(--accent-strong); }
.pill .d { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; font-size: 11.5px; font-weight: 650; background: var(--accent); color: var(--on-accent); }
.badge.soft { background: var(--surface-hover); color: var(--text-2); }
.chip { white-space: nowrap; flex: none; display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 12px; border: 1px solid var(--border-strong); border-radius: 30px; background: var(--surface); font-size: 12.5px; font-weight: 560; cursor: pointer; color: var(--text-2); }
.chip:hover { background: var(--surface-hover); }
.chip.on { background: var(--accent-soft); border-color: transparent; color: var(--accent-strong); }
:root[data-theme="dark"] .chip.on { color: hsl(var(--accent-h) var(--accent-s) 72%); }

/* ---------------- Avatar ---------------- */
.avatar { --h: 20; display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; flex: none; font-weight: 640; font-size: 13.5px; letter-spacing: .02em;
  background: hsl(var(--h) 55% 88%); color: hsl(var(--h) 55% 28%); user-select: none; }
:root[data-theme="dark"] .avatar { background: hsl(var(--h) 35% 26%); color: hsl(var(--h) 60% 82%); }
.avatar.sm { width: 28px; height: 28px; font-size: 11.5px; }
.avatar.lg { width: 48px; height: 48px; font-size: 17px; }
.avatar.xl { width: 72px; height: 72px; font-size: 26px; }

/* ---------------- Cards / tables ---------------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-l); box-shadow: var(--shadow-1); }
.card-head { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.card-head h2, .card-head h3 { flex: 1; }
.card-body { padding: 18px; }
.card-foot { padding: 12px 18px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; }
.table-wrap { overflow: auto; }
table.tbl { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13.5px; }
.tbl th { position: sticky; top: 0; z-index: 1; text-align: left; font-weight: 600; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; padding: 10px 14px; background: var(--surface-2); border-bottom: 1px solid var(--border); white-space: nowrap; }
.tbl td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr { transition: background .1s; }
.tbl tbody tr:hover { background: var(--surface-2); }
.tbl tr.clickable { cursor: pointer; }
.tbl td.num, .tbl th.num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl td.actions { text-align: right; white-space: nowrap; width: 1%; }
.tbl .sub { color: var(--muted); font-size: 12.5px; }
.meter { height: 6px; border-radius: 6px; background: var(--bg-sunken); overflow: hidden; min-width: 60px; }
.meter > i { display: block; height: 100%; background: var(--accent); border-radius: 6px; }
.meter.warn > i { background: var(--warn); } .meter.bad > i { background: var(--bad); }
.empty { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 10px; padding: 48px 24px; color: var(--muted); }
.empty .art { width: 72px; height: 72px; border-radius: 22px; display: grid; place-items: center; background: var(--accent-softer); color: var(--accent); margin-bottom: 6px; }
.empty .art svg { width: 34px; height: 34px; stroke-width: 1.5; }
.empty h3 { color: var(--text); }
.empty p { margin: 0; max-width: 46ch; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 8px 22px; font-size: 13.5px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; }
.notice { display: flex; gap: 10px; align-items: flex-start; padding: 10px 14px; border-radius: var(--radius); font-size: 13px; background: var(--info-soft); color: var(--text); border: 1px solid color-mix(in srgb, var(--info) 22%, transparent); }
.notice svg { color: var(--info); margin-top: 1px; }
.notice.warn { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 25%, transparent); } .notice.warn svg { color: var(--warn); }
.notice.bad { background: var(--bad-soft); border-color: color-mix(in srgb, var(--bad) 25%, transparent); } .notice.bad svg { color: var(--bad); }
.notice.ok { background: var(--ok-soft); border-color: color-mix(in srgb, var(--ok) 25%, transparent); } .notice.ok svg { color: var(--ok); }
.notice { flex-wrap: wrap; }
.notice .grow { line-height: 1.45; min-width: 180px; }
.skeleton { background: linear-gradient(90deg, var(--surface-hover), var(--bg-sunken), var(--surface-hover)); background-size: 200% 100%; animation: sk 1.2s infinite linear; border-radius: 6px; }
@keyframes sk { to { background-position: -200% 0; } }
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--border-strong); border-top-color: var(--accent); animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------- Tabs / segmented ---------------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; }
.tabs button { border: 0; background: none; padding: 10px 14px; font-weight: 560; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; display: inline-flex; gap: 7px; align-items: center; }
.tabs button:hover { color: var(--text); }
.tabs button.active { color: var(--text); border-bottom-color: var(--accent); }

/* ---------------- Overlays: dialog / drawer / menu / toast ---------------- */
.overlay { position: fixed; inset: 0; z-index: 1000; background: rgb(20 16 12 / .38); display: grid; place-items: center; padding: 24px; animation: fade .14s ease; backdrop-filter: blur(2px); }
:root[data-theme="dark"] .overlay { background: rgb(0 0 0 / .55); }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.985); } }
@keyframes slide-in { from { transform: translateX(30px); opacity: 0; } }
.dialog { width: min(560px, 100%); max-height: calc(100vh - 48px); display: flex; flex-direction: column; background: var(--surface); border-radius: var(--radius-xl); box-shadow: var(--shadow-3); border: 1px solid var(--border); animation: pop .18s var(--ease); overflow: hidden; }
.dialog.wide { width: min(820px, 100%); } .dialog.narrow { width: min(420px, 100%); }
.dialog-head { display: flex; align-items: center; gap: 12px; padding: 18px 22px 8px; }
.dialog-head h2 { flex: 1; }
.dialog-body { min-height: 0; padding: 10px 22px 20px; overflow: auto; display: flex; flex-direction: column; gap: 14px; }
.dialog-foot { display: flex; align-items: center; gap: 8px; justify-content: flex-end; padding: 14px 22px; border-top: 1px solid var(--border); background: var(--surface-2); }
.dialog-foot .form-error { margin-right: auto; }
.drawer-overlay { place-items: stretch end; padding: 0; grid-template-rows: 100vh; }
.drawer { width: min(560px, 100vw); height: 100vh; max-height: 100vh; background: var(--surface); box-shadow: var(--shadow-3); display: flex; flex-direction: column; animation: slide-in .2s var(--ease); border-left: 1px solid var(--border); }
.drawer.wide { width: min(760px, 100vw); }
.drawer .dialog-head { padding: 18px 22px 14px; border-bottom: 1px solid var(--border); }
.drawer .dialog-body { flex: 1; padding: 20px 22px; }
.menu { position: fixed; z-index: 1100; min-width: 210px; max-width: 320px; max-height: 70vh; overflow: auto; padding: 5px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-l); box-shadow: var(--shadow-3); animation: pop .12s var(--ease); }
.menu button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 7px 10px; border: 0; background: none; border-radius: 7px; text-align: left; cursor: pointer; font-size: 13.5px; color: var(--text); }
.menu button:hover, .menu button.kb { background: var(--surface-hover); }
.menu button:disabled { opacity: .45; pointer-events: none; }
.menu button.danger { color: var(--bad); }
.menu button svg { color: var(--muted); } .menu button.danger svg { color: var(--bad); }
.menu button kbd { margin-left: auto; }
.menu .sep { height: 1px; margin: 5px 4px; background: var(--border); }
.menu .label { padding: 6px 10px 4px; font-size: 11.5px; font-weight: 640; text-transform: uppercase; letter-spacing: .05em; color: var(--faint); }
.menu .check-mark { margin-left: auto; color: var(--accent); }
.toasts { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); z-index: 1200; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 14px; min-height: 44px; padding: 8px 10px 8px 16px; border-radius: 12px; background: #23201d; color: #f3efe9; box-shadow: var(--shadow-3); font-size: 13.5px; animation: pop .2s var(--ease); max-width: min(560px, 92vw); }
:root[data-theme="dark"] .toast { background: #efebe5; color: #1c1a18; }
.toast .t-btn { border: 0; background: none; color: hsl(var(--accent-h) 90% 68%); font-weight: 650; cursor: pointer; padding: 6px 8px; border-radius: 6px; }
:root[data-theme="dark"] .toast .t-btn { color: var(--accent-strong); }
.toast .t-btn:hover { background: rgb(255 255 255 / .08); }
.toast.bad { background: var(--bad); color: #fff; }
.tooltip { position: fixed; z-index: 1300; padding: 5px 9px; border-radius: 7px; background: #23201d; color: #f6f2ec; font-size: 12px; pointer-events: none; box-shadow: var(--shadow-2); white-space: nowrap; animation: fade .1s; }

/* ---------------- Command palette ---------------- */
.palette { width: min(640px, 100%); align-self: start; margin-top: 10vh; background: var(--surface); border-radius: var(--radius-xl); box-shadow: var(--shadow-3); border: 1px solid var(--border); overflow: hidden; animation: pop .15s var(--ease); }
.palette .p-input { display: flex; align-items: center; gap: 12px; padding: 0 18px; border-bottom: 1px solid var(--border); }
.palette .p-input input { flex: 1; height: 56px; border: 0; outline: 0; background: none; font-size: 16px; }
.palette .p-list { max-height: 50vh; overflow: auto; padding: 6px; }
.palette .p-item { display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 9px; cursor: pointer; }
.palette .p-item.on { background: var(--accent-softer); }
.palette .p-item .p-sub { color: var(--muted); font-size: 12.5px; }
.palette .p-group { padding: 10px 12px 4px; font-size: 11.5px; font-weight: 640; text-transform: uppercase; letter-spacing: .05em; color: var(--faint); }
.palette .p-foot { display: flex; gap: 14px; padding: 9px 16px; border-top: 1px solid var(--border); font-size: 12px; color: var(--muted); background: var(--surface-2); }

/* ---------------- App shell ---------------- */
.app { display: grid; grid-template-columns: var(--rail-w) 1fr; grid-template-rows: var(--topbar-h) 1fr; height: 100vh; }
.topbar { grid-column: 1 / -1; display: flex; align-items: center; gap: 14px; padding: 0 14px 0 0; background: var(--surface); border-bottom: 1px solid var(--border); position: relative; z-index: 5; }
.topbar .brand { width: var(--rail-w); display: grid; place-items: center; height: 100%; flex: none; }
.brand-mark { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: linear-gradient(140deg, hsl(var(--accent-h) 85% 58%), hsl(calc(var(--accent-h) - 14) 80% 44%)); color: #fff; box-shadow: 0 2px 6px hsl(var(--accent-h) 70% 40% / .35), inset 0 1px 0 rgb(255 255 255 / .25); }
.brand-mark svg { width: 20px; height: 20px; stroke-width: 2; }
.brand-name { font-family: var(--font-display); font-weight: 700; font-size: 16px; letter-spacing: -.02em; }
.brand-name small { font-weight: 560; color: var(--muted); font-size: 12px; margin-left: 6px; letter-spacing: 0; }
.topbar .t-search { flex: 1; max-width: 640px; margin: 0 auto; }
.topbar .t-search .input { height: 38px; background: var(--bg); border-color: transparent; border-radius: 11px; }
.topbar .t-search .input:focus { background: var(--surface); border-color: var(--accent); }
.topbar .t-search kbd { position: absolute; right: 10px; }
.topbar .t-actions { display: flex; align-items: center; gap: 4px; }
.user-chip { display: flex; align-items: center; gap: 9px; padding: 4px 6px 4px 4px; border-radius: 30px; border: 0; background: none; cursor: pointer; }
.user-chip:hover { background: var(--surface-hover); }
.user-chip .u-name { font-weight: 600; font-size: 13px; line-height: 1.2; text-align: left; }
.user-chip .u-mail { font-size: 11.5px; color: var(--muted); }
.rail { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 0; background: var(--surface); border-right: 1px solid var(--border); }
.rail button { position: relative; width: 52px; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 8px 0 6px; border: 0; background: none; border-radius: 12px; color: var(--muted); cursor: pointer; font-size: 10.5px; font-weight: 600; letter-spacing: .01em; }
.rail button:hover { color: var(--text); background: var(--surface-hover); }
.rail button.active { color: var(--accent-strong); background: var(--accent-softer); }
:root[data-theme="dark"] .rail button.active { color: hsl(var(--accent-h) var(--accent-s) 70%); }
.rail button.active::before { content: ""; position: absolute; left: -8px; top: 12px; bottom: 12px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent); }
.rail button svg { width: 22px; height: 22px; }
.rail button .badge { position: absolute; top: 2px; right: 4px; min-width: 18px; height: 18px; font-size: 10.5px; padding: 0 5px; }
.rail .spacer { flex: 1; }
.view { min-width: 0; min-height: 0; overflow: hidden; position: relative; }
.impersonation-bar { grid-column: 1 / -1; background: var(--warn); color: #fff; font-weight: 600; font-size: 13px; padding: 6px 16px; display: flex; gap: 10px; align-items: center; justify-content: center; }

/* ---------------- Pages ---------------- */
.page { height: 100%; overflow: auto; }
.page-inner { max-width: 1240px; margin: 0 auto; padding: 26px 32px 60px; }
.page-head { display: flex; align-items: flex-end; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head .titles { flex: 1; min-width: 240px; }
.page-head .titles p { margin: 4px 0 0; color: var(--muted); }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.crumbs { display: flex; gap: 6px; align-items: center; color: var(--muted); font-size: 13px; margin-bottom: 6px; }
.crumbs a { color: var(--muted); } .crumbs a:hover { color: var(--text); }
.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }

/* ---------------- Login ---------------- */
.login { display: grid; grid-template-columns: minmax(380px, 1fr) minmax(420px, 560px); height: 100vh; background: var(--surface); }
.login-art { position: relative; overflow: hidden; background: #1a1411; color: #f6efe6; padding: 48px; display: flex; flex-direction: column; justify-content: space-between; }
.login-art::before { content: ""; position: absolute; inset: -20%; background:
  radial-gradient(40% 40% at 30% 30%, hsl(var(--accent-h) 90% 55% / .55), transparent 70%),
  radial-gradient(35% 35% at 75% 65%, hsl(calc(var(--accent-h) + 30) 90% 55% / .35), transparent 70%),
  radial-gradient(30% 30% at 60% 20%, hsl(calc(var(--accent-h) - 20) 80% 45% / .4), transparent 70%); filter: blur(10px); }
.login-art::after { content: ""; position: absolute; inset: 0; background-image: linear-gradient(rgb(255 255 255 / .04) 1px, transparent 1px), linear-gradient(90deg, rgb(255 255 255 / .04) 1px, transparent 1px); background-size: 44px 44px; mask-image: linear-gradient(180deg, transparent, #000 40%, #000 70%, transparent); }
.login-art > * { position: relative; z-index: 1; }
.login-art h2 { font-size: 40px; line-height: 1.08; font-weight: 700; letter-spacing: -.03em; max-width: 14ch; }
.login-art p { color: #d9cfc3; max-width: 44ch; font-size: 15px; }
.login-feats { display: grid; grid-template-columns: repeat(2, minmax(0, 220px)); gap: 14px 26px; margin-top: 26px; }
.login-feats div { display: flex; gap: 10px; align-items: center; color: #efe6db; font-size: 13.5px; }
.login-feats svg { color: hsl(var(--accent-h) 90% 66%); }
.login-form { display: flex; flex-direction: column; justify-content: center; padding: 48px clamp(28px, 6vw, 72px); gap: 22px; }
.login-form h1 { font-size: 28px; font-weight: 700; letter-spacing: -.02em; }
.login-form .sub { color: var(--muted); margin-top: 6px; }
.login-form .input { height: 44px; font-size: 15px; }
.login-form .foot { color: var(--muted); font-size: 13px; }
@media (max-width: 900px) { .login { grid-template-columns: 1fr; } .login-art { display: none; } }

/* ==========================================================================
   Webmail – Mail
   ========================================================================== */
.mail { display: grid; height: 100%; grid-template-columns: var(--folders-w, 248px) var(--list-w, 420px) minmax(0, 1fr); }
.mail.reading-off { grid-template-columns: var(--folders-w, 248px) minmax(0, 1fr) 0; }
.mail.reading-off .reader-pane { display: none; }
.mail.reading-bottom { grid-template-columns: var(--folders-w, 248px) minmax(0, 1fr); grid-template-rows: minmax(200px, 42%) minmax(0, 1fr); }
.mail.reading-bottom .folder-pane { grid-row: 1 / span 2; }
.mail.reading-bottom .list-pane { border-right: 0; border-bottom: 1px solid var(--border); }
.mail.folders-collapsed { --folders-w: 0px; }
.mail.folders-collapsed .folder-pane { display: none; }
.folder-pane { display: flex; flex-direction: column; min-height: 0; background: var(--bg); border-right: 1px solid var(--border); }
.folder-pane .fp-top { padding: 14px 12px 8px; }
.compose-btn { width: 100%; height: 44px; justify-content: flex-start; padding: 0 16px; border-radius: 13px; font-size: 14px; gap: 10px; }
.folder-scroll { flex: 1; overflow: auto; padding: 4px 8px 12px; }
.f-section { display: flex; align-items: center; justify-content: space-between; padding: 14px 10px 4px; font-size: 11.5px; font-weight: 650; text-transform: uppercase; letter-spacing: .06em; color: var(--faint); }
.f-section .icon-btn { width: 24px; height: 24px; }
.folder { display: flex; align-items: center; gap: 10px; height: 34px; padding: 0 10px; border-radius: 9px; cursor: pointer; color: var(--text-2); user-select: none; font-size: 13.5px; position: relative; }
.folder:hover { background: var(--surface-hover); }
.folder.active { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: var(--shadow-1); }
.folder.active svg { color: var(--accent); }
.folder.drop { background: var(--accent-soft); outline: 2px dashed var(--accent); outline-offset: -2px; }
.folder svg { color: var(--muted); }
.folder .f-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.folder .f-count { font-size: 12px; font-weight: 650; color: var(--accent-strong); }
:root[data-theme="dark"] .folder .f-count { color: hsl(var(--accent-h) var(--accent-s) 68%); }
.folder .f-count.muted { color: var(--muted); font-weight: 500; }
.folder .twisty { width: 16px; display: grid; place-items: center; margin-left: -6px; color: var(--faint); }
.folder .twisty svg { width: 13px; height: 13px; transition: transform .15s; }
.folder .twisty.closed svg { transform: rotate(-90deg); }
.quota-box { margin: 8px 12px 14px; padding: 12px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border); font-size: 12px; color: var(--muted); }
.quota-box .meter { margin-top: 7px; }
.list-pane { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--surface); border-right: 1px solid var(--border); position: relative; }
.lp-head { padding: 14px 16px 10px; display: flex; flex-direction: column; gap: 10px; border-bottom: 1px solid var(--border); }
.lp-title { display: flex; align-items: center; gap: 8px; }
.lp-title h1 { font-size: 19px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lp-filters { display: flex; gap: 6px; align-items: center; overflow-x: auto; scrollbar-width: none; }
.lp-filters .spacer { flex: 1; }
.bulkbar { display: flex; align-items: center; gap: 4px; padding: 8px 12px; background: var(--accent-softer); border-bottom: 1px solid var(--border); animation: fade .12s; }
.bulkbar .count { font-weight: 650; font-size: 13px; margin: 0 8px 0 4px; }
.msg-list { flex: 1; overflow: auto; outline: none; }
.grp { position: sticky; top: 0; z-index: 2; padding: 9px 16px 5px; font-size: 11.5px; font-weight: 650; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(6px); }
.msg { position: relative; display: grid; grid-template-columns: 36px minmax(0, 1fr); gap: 0 12px; padding: 11px 14px 11px 16px; min-height: var(--row-h); border-bottom: 1px solid color-mix(in srgb, var(--border) 60%, transparent); cursor: default; user-select: none; }
.msg:hover { background: var(--surface-2); }
.msg.selected { background: var(--accent-softer); }
.msg.selected::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--accent); }
.msg.checked { background: var(--accent-soft); }
.msg .m-av { position: relative; padding-top: 2px; }
.msg .m-av .avatar { cursor: pointer; }
.msg .m-av input { position: absolute; inset: 2px 0 auto 0; width: 36px; height: 36px; opacity: 0; cursor: pointer; }
.msg.checked .m-av .avatar, .msg .m-av:hover .avatar { background: var(--accent); color: var(--on-accent); }
.msg.checked .m-av .avatar::after { content: "✓"; position: absolute; }
.msg.checked .m-av .avatar span { visibility: hidden; }
.msg .m-av .avatar { position: relative; }
.msg .m-top { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.msg .m-from { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; color: var(--text-2); }
.msg .m-date { font-size: 12px; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.msg .m-subj { display: flex; align-items: center; gap: 6px; min-width: 0; font-size: 13.5px; color: var(--text-2); margin-top: 1px; }
.msg .m-subj span.s { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg .m-prev { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 1px; }
:root[data-density="compact"] .msg .m-prev { display: none; }
:root[data-density="compact"] .msg { padding-top: 8px; padding-bottom: 8px; }
.msg.unread .m-from { color: var(--text); font-weight: 680; }
.msg.unread .m-subj { color: var(--text); font-weight: 600; }
.msg.unread .m-date { color: var(--accent-strong); font-weight: 650; }
:root[data-theme="dark"] .msg.unread .m-date { color: hsl(var(--accent-h) var(--accent-s) 68%); }
.msg .unread-dot { position: absolute; left: 5px; top: 50%; width: 7px; height: 7px; margin-top: -3.5px; border-radius: 50%; background: var(--accent); }
.msg .m-icons { display: inline-flex; gap: 4px; color: var(--muted); align-items: center; }
.msg .m-icons svg { width: 14px; height: 14px; }
.msg .flag-on { color: var(--bad); }
.msg .flag-on svg { fill: currentColor; }
.msg .thread-n { font-size: 11px; font-weight: 650; padding: 0 6px; border-radius: 10px; background: var(--surface-hover); color: var(--text-2); }
.msg .hover-acts { position: absolute; right: 10px; top: 8px; display: none; gap: 2px; background: var(--surface); border: 1px solid var(--border); border-radius: 9px; box-shadow: var(--shadow-2); padding: 2px; }
.msg:hover .hover-acts { display: flex; }
.msg:hover .m-date { visibility: hidden; }
.msg .hover-acts .icon-btn { width: 28px; height: 28px; }
.list-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 14px; border-top: 1px solid var(--border); font-size: 12.5px; color: var(--muted); }
.reader-pane { min-width: 0; min-height: 0; overflow: auto; background: var(--surface); display: flex; flex-direction: column; }
.mail.reading-right .reader-pane { background: var(--bg); }
.reader-empty { flex: 1; display: grid; place-items: center; color: var(--muted); }
.reader-bar { position: sticky; top: 0; z-index: 3; display: flex; align-items: center; gap: 2px; padding: 8px 14px; background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--border); }
.reader-bar .sep { width: 1px; height: 20px; background: var(--border); margin: 0 6px; }
.reader-body { padding: 22px clamp(16px, 3vw, 34px) 40px; max-width: 980px; width: 100%; margin: 0 auto; }
.r-subject { font-size: 22px; font-weight: 680; line-height: 1.25; letter-spacing: -.015em; display: flex; gap: 10px; align-items: flex-start; }
.r-subject .grow { word-break: break-word; }
.r-tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.r-card { margin-top: 18px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-l); box-shadow: var(--shadow-1); overflow: hidden; }
.r-card.collapsed .r-content, .r-card.collapsed .r-attach, .r-card.collapsed .r-notices { display: none; }
.r-card.collapsed .r-head { cursor: pointer; }
.r-head { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 12px; padding: 16px 18px; align-items: start; }
.r-head .who { min-width: 0; }
.r-head .who b { font-size: 14.5px; }
.r-head .who .addr { color: var(--muted); font-size: 13px; }
.r-head .to { color: var(--muted); font-size: 12.5px; margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
.r-head .to.open { white-space: normal; }
.r-head .when { color: var(--muted); font-size: 12.5px; text-align: right; white-space: nowrap; }
.r-head .when .acts { display: flex; gap: 2px; justify-content: flex-end; margin-top: 6px; }
.r-head .snip { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.r-notices { padding: 0 18px; display: flex; flex-direction: column; gap: 8px; }
.r-content { padding: 6px 4px 6px; }
.r-content iframe { width: 100%; border: 0; display: block; min-height: 120px; background: #fff; border-radius: 0 0 var(--radius) var(--radius); }
.r-attach { display: flex; gap: 10px; flex-wrap: wrap; padding: 12px 18px 18px; border-top: 1px solid var(--border); }
.att { display: flex; align-items: center; gap: 10px; width: 240px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 11px; background: var(--surface-2); color: var(--text) !important; text-decoration: none !important; position: relative; }
.att:hover { border-color: var(--border-strong); background: var(--surface-hover); }
.att .ext { width: 38px; height: 38px; border-radius: 9px; display: grid; place-items: center; font-size: 10.5px; font-weight: 750; letter-spacing: .03em; color: #fff; background: #7a746c; flex: none; text-transform: uppercase; overflow: hidden; }
.att .ext img { width: 100%; height: 100%; object-fit: cover; }
.att .ext.pdf { background: #d4433a; } .att .ext.doc { background: #2f6fbf; } .att .ext.xls { background: #1f8a5b; } .att .ext.ppt { background: #d0652a; } .att .ext.img { background: #8657c7; } .att .ext.zip { background: #6b5b3e; }
.att .a-meta { min-width: 0; flex: 1; } .att .a-name { font-size: 13px; font-weight: 560; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .att .a-size { font-size: 11.5px; color: var(--muted); }
.r-quick { display: flex; gap: 8px; margin-top: 18px; }
.auth-badges { display: inline-flex; gap: 5px; }
.drag-ghost { position: fixed; top: -100px; left: -100px; padding: 6px 12px; border-radius: 8px; background: var(--accent); color: var(--on-accent); font-weight: 600; font-size: 13px; }

/* ---------------- Compose windows ---------------- */
.compose-dock { position: fixed; right: 18px; bottom: 0; z-index: 900; display: flex; gap: 12px; align-items: flex-end; pointer-events: none; }
.cw { pointer-events: auto; width: 600px; height: min(640px, calc(100vh - 80px)); display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-bottom: 0; border-radius: 14px 14px 0 0; box-shadow: var(--shadow-3); animation: pop .18s var(--ease); }
.cw.min { height: 46px; width: 300px; overflow: hidden; }
.cw.max { position: fixed; inset: 40px max(40px, calc(50vw - 560px)); width: auto; height: auto; border-radius: 16px; border-bottom: 1px solid var(--border); z-index: 950; }
.cw-overlay { position: fixed; inset: 0; background: rgb(20 16 12 / .3); z-index: 940; }
.cw-head { display: flex; align-items: center; gap: 4px; height: 46px; padding: 0 8px 0 16px; border-bottom: 1px solid var(--border); background: var(--surface-2); border-radius: 14px 14px 0 0; cursor: pointer; flex: none; }
.cw-head b { flex: 1; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cw-head .status { font-size: 12px; color: var(--muted); margin-right: 6px; }
.cw-fields { flex: none; }
.cw-row { display: flex; align-items: center; gap: 8px; padding: 0 16px; min-height: 42px; border-bottom: 1px solid var(--border); }
.cw-row > label { width: 44px; color: var(--muted); font-size: 13px; flex: none; }
.cw-row input.plain { flex: 1; border: 0; outline: 0; background: none; height: 40px; font-size: 14px; min-width: 120px; }
.cw-row .toggles { display: flex; gap: 2px; }
.cw-row .toggles button { border: 0; background: none; color: var(--muted); font-size: 12.5px; font-weight: 600; cursor: pointer; padding: 4px 7px; border-radius: 6px; }
.cw-row .toggles button:hover { background: var(--surface-hover); color: var(--text); }
.rcpt { flex: 1; display: flex; flex-wrap: wrap; gap: 5px; align-items: center; padding: 5px 0; position: relative; min-width: 0; }
.rcpt input { flex: 1; min-width: 140px; border: 0; outline: 0; background: none; height: 30px; font-size: 14px; }
.rchip { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 4px 0 4px; border-radius: 20px; background: var(--surface-hover); border: 1px solid var(--border); font-size: 13px; max-width: 100%; }
.rchip .avatar { width: 22px; height: 22px; font-size: 10px; }
.rchip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rchip button { border: 0; background: none; cursor: pointer; color: var(--muted); display: grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; }
.rchip button:hover { background: var(--border); color: var(--text); }
.rchip.invalid { background: var(--bad-soft); border-color: color-mix(in srgb, var(--bad) 40%, transparent); color: var(--bad); }
.suggest { position: absolute; left: 0; top: 100%; z-index: 20; width: min(420px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-3); padding: 5px; }
.suggest > div { display: flex; gap: 10px; align-items: center; padding: 7px 9px; border-radius: 8px; cursor: pointer; }
.suggest > div.on, .suggest > div:hover { background: var(--accent-softer); }
.suggest .sg-name { font-weight: 560; font-size: 13.5px; } .suggest .sg-mail { color: var(--muted); font-size: 12.5px; }
.rte-bar { display: flex; gap: 1px; flex-wrap: wrap; align-items: center; padding: 6px 10px; border-bottom: 1px solid var(--border); flex: none; }
.rte-bar .icon-btn { width: 30px; height: 30px; border-radius: 7px; }
.rte-bar .sep { width: 1px; height: 18px; background: var(--border); margin: 0 4px; }
.rte-bar select { height: 28px; border: 1px solid transparent; background: none; border-radius: 6px; padding: 0 4px; font-size: 12.5px; color: var(--text-2); cursor: pointer; }
.rte-bar select:hover { background: var(--surface-hover); }
.rte-bar input[type=color] { width: 0; height: 0; opacity: 0; position: absolute; }
.rte { flex: 1; overflow: auto; padding: 16px 18px; outline: none; font-size: 14.5px; line-height: 1.55; color: #1c1a18; background: #fff; }
:root[data-theme="dark"] .rte { background: #fbfaf8; }
.rte blockquote { margin: 8px 0; padding-left: 12px; border-left: 3px solid #d6d0c8; color: #555; }
.rte img { max-width: 100%; }
.rte p { margin: 0 0 .6em; }
.rte .signature { color: #555; }
.rte table { border-collapse: collapse; } .rte td, .rte th { border: 1px solid #ccc; padding: 4px 8px; }
.cw-atts { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 14px; border-top: 1px solid var(--border); flex: none; }
.cw-atts:empty { display: none; }
.cw-att { display: inline-flex; align-items: center; gap: 7px; height: 30px; padding: 0 6px 0 10px; border-radius: 8px; background: var(--surface-hover); font-size: 12.5px; max-width: 260px; }
.cw-att span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cw-foot { display: flex; align-items: center; gap: 6px; padding: 10px 14px; border-top: 1px solid var(--border); flex: none; }
.cw-foot .form-error { flex: 1; min-height: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cw.dragover .rte { outline: 2px dashed var(--accent); outline-offset: -8px; background: var(--accent-softer); }
.send-split { display: inline-flex; }
.send-split .btn:first-child { border-radius: var(--radius) 0 0 var(--radius); }
.send-split .btn:last-child { border-radius: 0 var(--radius) var(--radius) 0; padding: 0 8px; border-left: 1px solid rgb(255 255 255 / .25); }
@media (max-width: 720px) { .cw { width: 100vw; } .compose-dock { right: 0; } }

/* ==========================================================================
   Calendar
   ========================================================================== */
.cal { display: grid; grid-template-columns: 260px minmax(0, 1fr); height: 100%; }
.cal-side { border-right: 1px solid var(--border); background: var(--bg); padding: 14px 14px; overflow: auto; display: flex; flex-direction: column; gap: 18px; }
.mini-cal { user-select: none; }
.mini-cal .mc-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; font-weight: 640; font-size: 13.5px; }
.mini-cal .mc-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 1px; text-align: center; font-size: 12px; }
.mini-cal .mc-grid span { height: 28px; display: grid; place-items: center; border-radius: 50%; cursor: pointer; color: var(--text-2); position: relative; }
.mini-cal .mc-grid span.dow { color: var(--faint); font-weight: 600; cursor: default; font-size: 11px; }
.mini-cal .mc-grid span.other { color: var(--faint); }
.mini-cal .mc-grid span:not(.dow):hover { background: var(--surface-hover); }
.mini-cal .mc-grid span.today { background: var(--accent); color: var(--on-accent); font-weight: 700; }
.mini-cal .mc-grid span.sel:not(.today) { background: var(--accent-soft); color: var(--accent-strong); font-weight: 650; }
.mini-cal .mc-grid span.has::after { content: ""; position: absolute; bottom: 3px; width: 4px; height: 4px; border-radius: 50%; background: var(--accent); }
.mini-cal .mc-grid span.today.has::after { background: var(--on-accent); }
.upcoming h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--faint); margin-bottom: 8px; }
.up-item { display: flex; gap: 10px; padding: 8px; border-radius: 9px; cursor: pointer; }
.up-item:hover { background: var(--surface-hover); }
.up-item .bar { width: 3px; border-radius: 3px; background: var(--accent); flex: none; }
.up-item b { font-size: 13px; display: block; } .up-item span { font-size: 12px; color: var(--muted); }
.cal-main { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--surface); }
.cal-bar { display: flex; align-items: center; gap: 10px; padding: 12px 18px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.cal-bar h1 { font-size: 20px; flex: 1; min-width: 180px; text-transform: capitalize; }
.month { flex: 1; display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); grid-template-rows: auto repeat(6, minmax(0, 1fr)); min-height: 0; }
.month .dow { padding: 8px 10px; font-size: 11.5px; font-weight: 650; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; border-bottom: 1px solid var(--border); }
.month .cell { border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); padding: 4px 5px; min-height: 0; overflow: hidden; display: flex; flex-direction: column; gap: 2px; cursor: pointer; }
.month .cell:nth-child(7n) { border-right: 0; }
.month .cell:hover { background: var(--surface-2); }
.month .cell.other { background: var(--surface-2); } .month .cell.other .dn { color: var(--faint); }
.month .cell .dn { font-size: 12.5px; font-weight: 600; width: 26px; height: 26px; display: grid; place-items: center; border-radius: 50%; color: var(--text-2); margin-bottom: 1px; }
.month .cell.today .dn { background: var(--accent); color: var(--on-accent); }
.ev { --c: var(--accent); display: flex; align-items: center; gap: 5px; font-size: 12px; padding: 2px 6px; border-radius: 5px; cursor: pointer; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; color: var(--text); background: color-mix(in srgb, var(--c) 14%, transparent); border-left: 3px solid var(--c); flex: none; }
.ev:hover { background: color-mix(in srgb, var(--c) 24%, transparent); }
.ev.allday { background: var(--c); color: #fff; border-left-color: transparent; }
.ev .t { color: var(--muted); font-variant-numeric: tabular-nums; }
.ev.allday .t { color: #fff; }
.more-ev { font-size: 11.5px; color: var(--muted); padding: 0 6px; font-weight: 600; }
.week { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.week-head { display: grid; grid-template-columns: 64px repeat(var(--days), minmax(0, 1fr)); border-bottom: 1px solid var(--border); padding-right: 10px; }
.week-head .wd { padding: 8px 6px; text-align: center; border-left: 1px solid var(--border); }
.week-head .wd small { display: block; font-size: 11.5px; text-transform: uppercase; color: var(--muted); font-weight: 650; letter-spacing: .04em; }
.week-head .wd b { font-size: 22px; font-weight: 600; display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 50%; }
.week-head .wd.today b { background: var(--accent); color: var(--on-accent); }
.week-allday { display: grid; grid-template-columns: 64px repeat(var(--days), minmax(0, 1fr)); border-bottom: 1px solid var(--border); min-height: 28px; padding-right: 10px; }
.week-allday > div { border-left: 1px solid var(--border); padding: 3px; display: flex; flex-direction: column; gap: 2px; }
.week-allday .lbl { font-size: 11px; color: var(--muted); display: grid; place-items: center; border: 0; }
.week-scroll { flex: 1; overflow-y: scroll; position: relative; }
.week-grid { display: grid; grid-template-columns: 64px repeat(var(--days), minmax(0, 1fr)); position: relative; }
.week-grid .hours div { height: 52px; font-size: 11px; color: var(--muted); text-align: right; padding-right: 8px; transform: translateY(-7px); }
.week-grid .day { position: relative; border-left: 1px solid var(--border); background-image: repeating-linear-gradient(to bottom, transparent 0 51px, var(--border) 51px 52px); }
.week-grid .day.today { background-color: var(--accent-softer); }
.week-grid .tev { position: absolute; left: 3px; right: 4px; border-radius: 7px; padding: 4px 7px; font-size: 12px; overflow: hidden; cursor: pointer; background: color-mix(in srgb, var(--c, var(--accent)) 18%, var(--surface)); border-left: 3px solid var(--c, var(--accent)); color: var(--text); box-shadow: var(--shadow-1); }
.week-grid .tev:hover { z-index: 5; box-shadow: var(--shadow-2); }
.week-grid .tev b { display: block; font-weight: 620; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.week-grid .tev span { color: var(--muted); font-size: 11.5px; }
.now-line { position: absolute; left: 0; right: 0; height: 2px; background: var(--bad); z-index: 4; pointer-events: none; }
.now-line::before { content: ""; position: absolute; left: -5px; top: -4px; width: 10px; height: 10px; border-radius: 50%; background: var(--bad); }
.agenda { flex: 1; overflow: auto; padding: 10px 24px 40px; }
.agenda .a-day { display: grid; grid-template-columns: 110px minmax(0,1fr); gap: 16px; padding: 14px 0; border-bottom: 1px solid var(--border); }
.agenda .a-date b { font-size: 26px; font-weight: 650; display: block; line-height: 1; } .agenda .a-date span { color: var(--muted); font-size: 12.5px; text-transform: capitalize; }
.agenda .a-ev { display: flex; gap: 14px; padding: 8px 10px; border-radius: 10px; cursor: pointer; align-items: center; }
.agenda .a-ev:hover { background: var(--surface-2); }
.agenda .a-ev .tm { width: 110px; color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.agenda .a-ev .bar { width: 4px; align-self: stretch; border-radius: 4px; background: var(--c, var(--accent)); }

/* ==========================================================================
   Contacts / Tasks / Notes / Settings
   ========================================================================== */
.split { display: grid; grid-template-columns: minmax(300px, 380px) minmax(0, 1fr); height: 100%; }
.split-list { border-right: 1px solid var(--border); display: flex; flex-direction: column; min-height: 0; background: var(--surface); }
.split-list .sl-head { padding: 16px 16px 12px; display: flex; flex-direction: column; gap: 10px; border-bottom: 1px solid var(--border); }
.split-list .sl-scroll { flex: 1; overflow: auto; }
.split-detail { overflow: auto; background: var(--bg); }
.c-row { display: flex; align-items: center; gap: 12px; padding: 9px 16px; cursor: pointer; }
.c-row:hover { background: var(--surface-2); }
.c-row.active { background: var(--accent-softer); }
.c-row .c-name { font-weight: 560; } .c-row .c-sub { font-size: 12.5px; color: var(--muted); }
.c-letter { position: sticky; top: 0; padding: 6px 16px; font-size: 12px; font-weight: 700; color: var(--accent-strong); background: var(--surface-2); border-bottom: 1px solid var(--border); z-index: 1; }
.contact-card { max-width: 760px; margin: 0 auto; padding: 36px 32px; }
.contact-hero { display: flex; gap: 22px; align-items: center; margin-bottom: 26px; }
.contact-hero h1 { font-size: 26px; }
.contact-hero .role { color: var(--muted); margin-top: 4px; }
.contact-actions { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.info-list { display: flex; flex-direction: column; }
.info-list .il { display: flex; gap: 14px; padding: 14px 18px; border-bottom: 1px solid var(--border); align-items: flex-start; }
.info-list .il:last-child { border-bottom: 0; }
.info-list .il svg { color: var(--muted); margin-top: 1px; }
.info-list .il small { display: block; color: var(--muted); font-size: 12px; }
.tasks { display: grid; grid-template-columns: 240px minmax(0, 1fr) var(--task-detail-w, 0px); height: 100%; }
.tasks.detail-open { --task-detail-w: 360px; }
.tasks-side { border-right: 1px solid var(--border); background: var(--bg); padding: 14px 10px; overflow: auto; }
.tasks-side .folder .f-count { color: var(--muted); font-weight: 500; }
.tasks-main { display: flex; flex-direction: column; min-width: 0; background: var(--surface); }
.tasks-main .tm-head { padding: 22px 28px 12px; }
.tasks-main .tm-head h1 { font-size: 24px; }
.task-add { display: flex; align-items: center; gap: 10px; margin: 0 28px 10px; padding: 0 14px; border: 1px solid var(--border-strong); border-radius: 12px; background: var(--surface); box-shadow: var(--shadow-1); }
.task-add input { flex: 1; border: 0; outline: 0; background: none; height: 46px; font-size: 14.5px; }
.task-add svg { color: var(--accent); }
.task-scroll { flex: 1; overflow: auto; padding: 0 28px 40px; }
.task { display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: 11px; border: 1px solid var(--border); background: var(--surface); margin-bottom: 6px; cursor: pointer; transition: box-shadow .12s, transform .12s; }
.task:hover { box-shadow: var(--shadow-2); }
.task.active { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.task .tk-check { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--border-strong); display: grid; place-items: center; flex: none; cursor: pointer; background: none; color: transparent; }
.task .tk-check:hover { border-color: var(--accent); color: var(--accent); }
.task.done .tk-check { background: var(--ok); border-color: var(--ok); color: #fff; }
.task .tk-title { flex: 1; min-width: 0; }
.task.done .tk-title b { text-decoration: line-through; color: var(--muted); font-weight: 450; }
.task .tk-title b { font-weight: 500; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.task .tk-meta { font-size: 12px; color: var(--muted); display: flex; gap: 10px; }
.task .tk-meta .overdue { color: var(--bad); font-weight: 600; }
.task .star { color: var(--faint); }
.task .star.on { color: #e8a317; } .task .star.on svg { fill: currentColor; }
.task-detail { border-left: 1px solid var(--border); background: var(--surface-2); overflow: auto; padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.notes-grid { columns: 260px; column-gap: 16px; padding: 0 28px 40px; }
.note { --nc: #fff4bf; --nb: #f0de86; break-inside: avoid; margin-bottom: 16px; background: var(--nc); border: 1px solid var(--nb); border-radius: 14px; padding: 14px 16px 10px; cursor: pointer; color: #2b2720; box-shadow: var(--shadow-1); transition: box-shadow .12s, transform .12s; position: relative; }
.note:hover { box-shadow: var(--shadow-2); transform: translateY(-1px); }
.note h4 { font-size: 15px; margin-bottom: 6px; }
.note .n-body { white-space: pre-wrap; font-size: 13.5px; line-height: 1.5; max-height: 280px; overflow: hidden; word-break: break-word; }
.note .n-foot { display: flex; justify-content: space-between; align-items: center; font-size: 11.5px; color: #6f6656; margin-top: 10px; }
.note.green { --nc: #dcf3dd; --nb: #a9dcab; } .note.blue { --nc: #dcebfb; --nb: #a8c9ef; } .note.pink { --nc: #fbe0ea; --nb: #efafc6; } .note.purple { --nc: #ebe1fa; --nb: #c7b1ee; } .note.gray { --nc: #eeece8; --nb: #d2cec7; }
:root[data-theme="dark"] .note { filter: saturate(.8) brightness(.92); }
.note .pin { position: absolute; top: 10px; right: 10px; color: #6f6656; }
.color-dots { display: flex; gap: 8px; }
.color-dots button { width: 24px; height: 24px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; }
.color-dots button.on { border-color: var(--text); }
.settings { display: grid; grid-template-columns: 260px minmax(0, 1fr); height: 100%; }
.settings-nav { border-right: 1px solid var(--border); background: var(--bg); padding: 18px 10px; overflow: auto; }
.settings-nav h2 { padding: 0 10px 12px; }
.settings-main { overflow: auto; }
.settings-main .page-inner { max-width: 860px; }
.section-card { margin-bottom: 18px; }
.swatches { display: flex; gap: 10px; flex-wrap: wrap; }
.swatches button { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--surface); box-shadow: 0 0 0 1px var(--border-strong); cursor: pointer; }
.swatches button.on { box-shadow: 0 0 0 2px var(--text); }
.theme-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.theme-cards button { border: 1px solid var(--border-strong); border-radius: 12px; background: var(--surface); padding: 10px; cursor: pointer; text-align: left; font-weight: 560; display: flex; flex-direction: column; gap: 8px; }
.theme-cards button.on { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.theme-cards .prev { height: 64px; border-radius: 8px; border: 1px solid var(--border); display: grid; grid-template-columns: 22% 1fr; overflow: hidden; }
.theme-cards .prev.l { background: #fff; } .theme-cards .prev.l i { background: #f2efea; }
.theme-cards .prev.d { background: #1a1917; } .theme-cards .prev.d i { background: #121110; }
.theme-cards .prev.s { background: linear-gradient(90deg, #fff 50%, #1a1917 50%); }
.rule-card { display: flex; gap: 14px; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.rule-card:last-child { border-bottom: 0; }
.rule-card .rc-body { flex: 1; min-width: 0; }
.rule-card .rc-body b { display: block; }
.rule-card .rc-body span { font-size: 12.5px; color: var(--muted); }
.copy-field { display: flex; align-items: center; gap: 6px; padding: 4px 4px 4px 12px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface-2); font-family: var(--mono); font-size: 12.5px; }
.copy-field span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ==========================================================================
   Admin console
   ========================================================================== */
.console { display: grid; grid-template-columns: 252px minmax(0, 1fr); grid-template-rows: var(--topbar-h) 1fr; height: 100vh; }
.console .topbar { padding-left: 0; }
.console .topbar .brand { width: 252px; justify-content: flex-start; padding-left: 18px; display: flex; gap: 11px; align-items: center; border-right: 1px solid var(--border); }
.nav { background: var(--surface); border-right: 1px solid var(--border); padding: 12px 10px; overflow: auto; display: flex; flex-direction: column; gap: 2px; }
.nav .n-sec { padding: 14px 10px 5px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--faint); }
.nav a { display: flex; align-items: center; gap: 11px; height: 36px; padding: 0 10px; border-radius: 9px; color: var(--text-2); font-weight: 520; font-size: 13.5px; text-decoration: none !important; cursor: pointer; }
.nav a:hover { background: var(--surface-hover); color: var(--text); }
.nav a.active { background: var(--accent-softer); color: var(--accent-strong); font-weight: 620; }
:root[data-theme="dark"] .nav a.active { color: hsl(var(--accent-h) var(--accent-s) 70%); }
.nav a.active svg { color: currentColor; }
.nav a svg { color: var(--muted); }
.nav a .badge { margin-left: auto; }
.nav .n-foot { margin-top: auto; padding-top: 14px; }
.console-main { overflow: auto; background: var(--bg); }
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi { padding: 16px 18px; display: flex; flex-direction: column; gap: 6px; }
.kpi .k-top { display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: 12.5px; font-weight: 560; }
.kpi .k-ico { width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; background: var(--accent-softer); color: var(--accent); }
.kpi .k-val { font-size: 28px; font-weight: 680; letter-spacing: -.02em; font-variant-numeric: tabular-nums; font-family: var(--font-display); }
.kpi .k-sub { font-size: 12px; color: var(--muted); }
.dash-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 16px; }
.span-4 { grid-column: span 4; } .span-5 { grid-column: span 5; } .span-6 { grid-column: span 6; } .span-7 { grid-column: span 7; } .span-8 { grid-column: span 8; } .span-12 { grid-column: span 12; }
@media (max-width: 1100px) { .dash-grid > * { grid-column: span 12; } }
.health-hero { display: flex; align-items: center; gap: 18px; padding: 20px 22px; }
.health-hero .h-ring { width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; flex: none; }
.health-hero .h-ring.ok { background: var(--ok-soft); color: var(--ok); } .health-hero .h-ring.warn { background: var(--warn-soft); color: var(--warn); } .health-hero .h-ring.bad { background: var(--bad-soft); color: var(--bad); }
.health-hero .h-ring svg { width: 28px; height: 28px; }
.svc-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; }
.svc { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface-2); font-size: 13px; }
.svc .d { width: 9px; height: 9px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); flex: none; }
.svc .d.off { background: var(--faint); box-shadow: none; } .svc .d.bad { background: var(--bad); box-shadow: 0 0 0 3px var(--bad-soft); }
.svc .port { margin-left: auto; color: var(--muted); font-family: var(--mono); font-size: 12px; }
.bars { display: flex; flex-direction: column; gap: 10px; }
.bars .b-row { display: grid; grid-template-columns: 110px minmax(0, 1fr) 54px; gap: 12px; align-items: center; font-size: 13px; }
.bars .b-track { height: 10px; border-radius: 6px; background: var(--bg-sunken); overflow: hidden; }
.bars .b-track i { display: block; height: 100%; border-radius: 6px; background: var(--accent); }
.bars .b-row .num { text-align: right; font-variant-numeric: tabular-nums; color: var(--text-2); }
.chart { width: 100%; height: 200px; }
.chart .grid line { stroke: var(--border); }
.chart text { fill: var(--muted); font-size: 11px; }
.domain-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.domain-card { padding: 18px; cursor: pointer; transition: box-shadow .12s, transform .12s, border-color .12s; display: flex; flex-direction: column; gap: 14px; }
.domain-card:hover { box-shadow: var(--shadow-2); border-color: var(--border-strong); transform: translateY(-1px); }
.domain-card .dc-head { display: flex; align-items: center; gap: 12px; }
.domain-card .dc-ico { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--accent-softer); color: var(--accent); font-weight: 750; font-size: 16px; }
.domain-card .dc-name { font-weight: 650; font-size: 15.5px; }
.domain-card .dc-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.domain-card .dc-stats div b { display: block; font-size: 18px; font-weight: 650; font-variant-numeric: tabular-nums; }
.domain-card .dc-stats div span { font-size: 12px; color: var(--muted); }
.proto-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 4px 24px; }
.dns-rec { display: grid; grid-template-columns: 70px minmax(0, 1.1fr) minmax(0, 2fr) auto; gap: 12px; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.dns-rec:last-child { border-bottom: 0; }
.dns-rec .type { font-family: var(--mono); font-weight: 700; font-size: 12px; padding: 3px 0; border-radius: 6px; text-align: center; background: var(--accent-softer); color: var(--accent-strong); }
.dns-rec .val { font-family: var(--mono); font-size: 12px; word-break: break-all; color: var(--text-2); max-height: 54px; overflow: hidden; }
.dns-rec .nm { font-family: var(--mono); font-size: 12.5px; word-break: break-all; }
.dns-rec .dns-note { grid-column: 2 / -1; font-size: 12px; color: var(--muted); margin-top: -6px; }
.log-line { display: grid; grid-template-columns: 150px 80px 70px minmax(0, 1fr) 140px; gap: 12px; padding: 7px 16px; font-size: 12.5px; border-bottom: 1px solid var(--border); align-items: baseline; }
.log-line:hover { background: var(--surface-2); }
.log-line .msg-t { font-family: var(--mono); font-size: 12px; word-break: break-word; }
.log-line .ip { font-family: var(--mono); font-size: 12px; color: var(--muted); text-align: right; overflow: hidden; text-overflow: ellipsis; }
.legacy-frame { width: 100%; height: 100%; border: 0; display: block; background: var(--surface); }
.user-cell { display: flex; align-items: center; gap: 11px; min-width: 0; }
.user-cell .uc-meta { min-width: 0; } .user-cell b { font-weight: 600; display: block; } .user-cell span { font-size: 12.5px; color: var(--muted); }
.proto-dots { display: flex; gap: 3px; }
.proto-dots i { font-style: normal; font-size: 10px; font-weight: 700; padding: 1px 5px; border-radius: 4px; background: var(--ok-soft); color: var(--ok); }
.proto-dots i.off { background: var(--surface-hover); color: var(--faint); text-decoration: line-through; }

/* ---------------- Responsive shell ---------------- */
@media (max-width: 1100px) {
  .mail { grid-template-columns: var(--folders-w, 220px) minmax(0, 1fr); }
  .mail .reader-pane { position: absolute; inset: 0; z-index: 6; display: none; }
  .mail.has-open .reader-pane { display: flex; }
}
/* ---- Rev802: native replacements for the legacy console ---- */
.subnav-layout { display: grid; grid-template-columns: 230px minmax(0, 1fr); gap: 18px; align-items: start; }
.subnav { padding: 6px; position: sticky; top: 0; }
.subnav .folder { text-decoration: none; color: var(--text); }
.ds-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 4px 22px; align-items: end; }
.ds-grid .field { margin: 6px 0; }
.ds-h { grid-column: 1 / -1; font-size: 12px; font-weight: 650; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 14px 0 2px; padding-bottom: 6px; border-bottom: 1px solid var(--border); }
.ds-grid > .ds-h:first-child { margin-top: 0; }
.ds-sw { align-self: center; }
.ds-wide { grid-column: 1 / -1; }
.cond-row { display: grid; grid-template-columns: minmax(150px, 1.1fr) 120px minmax(120px, 1.4fr) auto; gap: 8px; align-items: center; }
.cond-row.two { grid-template-columns: minmax(170px, 1fr) minmax(140px, 1.4fr) auto; }
.trend { display: flex; align-items: flex-end; gap: 3px; height: 160px; }
.trend .tb { flex: 1; display: flex; flex-direction: column-reverse; height: 100%; min-width: 4px; }
.trend .tb i { display: block; border-radius: 3px 3px 0 0; }
.trend .tb i.s, .lg.s { background: var(--ok, #2f8f4e); }
.trend .tb i.f, .lg.f { background: var(--bad); }
.lg { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin: 0 4px 0 10px; vertical-align: -1px; }
.cert-list { display: flex; flex-direction: column; gap: 6px; max-height: 52vh; overflow: auto; margin-bottom: 10px; }
.cert-pick { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; cursor: pointer; }
.cert-pick:hover { background: var(--surface-2); }
.cert-pick:has(input:checked) { border-color: var(--accent); background: var(--accent-soft, var(--surface-2)); }
.cert-pick.disabled { opacity: .55; cursor: not-allowed; }
.cert-pick .sub { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
@media (max-width: 900px) { .subnav-layout { grid-template-columns: minmax(0, 1fr); } .subnav { position: static; display: flex; overflow-x: auto; } .cond-row, .cond-row.two { grid-template-columns: 1fr; } }

@media (max-width: 760px) {
  :root { --rail-w: 0px; }
  .app { grid-template-columns: 1fr; grid-template-rows: var(--topbar-h) 1fr 60px; }
  .rail { grid-row: 3; flex-direction: row; justify-content: space-around; border-right: 0; border-top: 1px solid var(--border); padding: 4px; }
  .rail .spacer, .rail .r-extra { display: none; }
  .rail button.active::before { display: none; }
  .topbar .brand { width: 54px; }
  .user-chip .u-txt, .topbar .brand-name, .topbar .t-search kbd, #t-help, #t-palette { display: none; }
  .topbar { gap: 6px; }
  .r-head { grid-template-columns: auto minmax(0, 1fr); }
  .r-head .when { grid-column: 1 / -1; text-align: left; display: flex; align-items: center; justify-content: space-between; }
  .r-head .when .acts { margin: 0; }
  .reader-bar { overflow-x: auto; }
  .cw.max { inset: 0; border-radius: 0; }
  .mail { grid-template-columns: minmax(0, 1fr); }
  .mail .folder-pane { position: absolute; inset: 0 auto 0 0; width: 280px; z-index: 7; box-shadow: var(--shadow-3); display: none; }
  .mail.folders-open .folder-pane { display: flex; }
  .cal, .split, .tasks, .settings, .console { grid-template-columns: minmax(0, 1fr); }
  .cal-side, .settings-nav, .tasks-side, .nav { display: none; }
  .split .split-detail { display: none; } .split.detail .split-detail { display: block; } .split.detail .split-list { display: none; }
  .page-inner { padding: 18px 16px 50px; }
}

@media print {
  body { overflow: visible; background: #fff; }
  .topbar, .rail, .folder-pane, .list-pane, .reader-bar, .compose-dock, .toasts { display: none !important; }
  .app, .mail { display: block; height: auto; }
  .reader-pane { overflow: visible; }
}
.ok-text { color: var(--ok, #2f8f4e); } .bad-text { color: var(--danger, #c0392b); }

/* Phase36: accessible collapsible admin navigation */
#nav .todmail-nav-toggle{display:flex;align-items:center;justify-content:space-between;width:100%;background:transparent;border:0;cursor:pointer;text-align:left;font:inherit;color:inherit;padding:10px 14px} 
#nav .todmail-nav-toggle:hover{background:rgba(128,128,128,.08)}
#nav .todmail-nav-items[hidden]{display:none!important}
#nav .todmail-nav-toggle:focus-visible{outline:2px solid currentColor;outline-offset:-2px}

/* Certificate settings (login language selector removed in Rev809 Gate3). */
.login-form { position: relative; }
.todmail-cert-tabs { display:flex; flex-wrap:wrap; gap:8px; margin:0 0 18px; border-bottom:1px solid var(--border); padding-bottom:10px; }
.todmail-cert-tabs a { display:inline-flex; padding:9px 15px; border-radius:8px; text-decoration:none; color:var(--muted); font-weight:600; }
.todmail-cert-tabs a.active { color:var(--text); background:var(--surface-2); }
.todmail-settings-layout { display:grid; grid-template-columns:230px minmax(0,1fr); gap:18px; align-items:start; }
.todmail-cert-settings-layout { display:block; }
@media(max-width:800px){ .todmail-settings-layout {grid-template-columns:1fr;} .todmail-settings-layout nav {position:static!important;} }

