/* ==========================================================================
   Mailora UI — shared design system
   Light + dark themes, Gmail-inspired Material 3 look.
   ========================================================================== */

:root {
  --font: "Inter", "Google Sans", Roboto, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-display: "Plus Jakarta Sans", "Inter", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --bg: #f6f8fc;
  --surface: #ffffff;
  --surface-2: #f2f6fc;
  --surface-3: #e9eef6;
  --hover: rgba(31, 31, 31, .06);
  --pressed: rgba(31, 31, 31, .1);
  --border: #e3e7ee;
  --border-strong: #c4c7c5;
  --text: #1f1f1f;
  --text-2: #444746;
  --text-3: #747775;

  --primary: #0b57d0;
  --primary-hover: #0842a0;
  --on-primary: #ffffff;
  --primary-soft: #d3e3fd;
  --on-primary-soft: #041e49;
  --compose: #c2e7ff;
  --on-compose: #001d35;

  --success: #146c2e;  --success-soft: #c4eed0;
  --warn: #8a5300;     --warn-soft: #ffe8c0;
  --danger: #b3261e;   --danger-soft: #fce8e6;
  --info: #0b57d0;     --info-soft: #d3e3fd;

  --unread-bg: #ffffff;
  --read-bg: #f2f6fc;
  --row-selected: #c2dbff;

  --shadow-1: 0 1px 2px rgba(60,64,67,.3), 0 1px 3px 1px rgba(60,64,67,.15);
  --shadow-2: 0 1px 3px rgba(60,64,67,.3), 0 4px 8px 3px rgba(60,64,67,.15);
  --shadow-3: 0 4px 4px rgba(60,64,67,.3), 0 8px 12px 6px rgba(60,64,67,.15);

  --r-xs: 6px; --r-sm: 8px; --r-md: 12px; --r-lg: 16px; --r-xl: 28px; --r-full: 999px;
  --topbar-h: 64px;
  --sidebar-w: 256px;
  --ease: cubic-bezier(.2, 0, 0, 1);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111317; --surface: #1b1d22; --surface-2: #202329; --surface-3: #2a2e36;
    --hover: rgba(227,227,227,.08); --pressed: rgba(227,227,227,.12);
    --border: #30343c; --border-strong: #4a4f58;
    --text: #e3e3e3; --text-2: #c4c7c5; --text-3: #8e918f;
    --primary: #a8c7fa; --primary-hover: #c2d7fb; --on-primary: #062e6f;
    --primary-soft: #0b3a7a; --on-primary-soft: #d3e3fd;
    --compose: #004a77; --on-compose: #c2e7ff;
    --success: #6dd58c; --success-soft: #0f3d1f;
    --warn: #ffb95c; --warn-soft: #3d2a00;
    --danger: #f2b8b5; --danger-soft: #4b1512;
    --info: #a8c7fa; --info-soft: #0b3a7a;
    --unread-bg: #1b1d22; --read-bg: #16181c; --row-selected: #0b3a7a;
    --shadow-1: 0 1px 2px rgba(0,0,0,.5), 0 1px 3px 1px rgba(0,0,0,.3);
    --shadow-2: 0 2px 4px rgba(0,0,0,.5), 0 4px 10px 3px rgba(0,0,0,.35);
    --shadow-3: 0 4px 8px rgba(0,0,0,.55), 0 10px 20px 6px rgba(0,0,0,.4);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #111317; --surface: #1b1d22; --surface-2: #202329; --surface-3: #2a2e36;
  --hover: rgba(227,227,227,.08); --pressed: rgba(227,227,227,.12);
  --border: #30343c; --border-strong: #4a4f58;
  --text: #e3e3e3; --text-2: #c4c7c5; --text-3: #8e918f;
  --primary: #a8c7fa; --primary-hover: #c2d7fb; --on-primary: #062e6f;
  --primary-soft: #0b3a7a; --on-primary-soft: #d3e3fd;
  --compose: #004a77; --on-compose: #c2e7ff;
  --success: #6dd58c; --success-soft: #0f3d1f;
  --warn: #ffb95c; --warn-soft: #3d2a00;
  --danger: #f2b8b5; --danger-soft: #4b1512;
  --info: #a8c7fa; --info-soft: #0b3a7a;
  --unread-bg: #1b1d22; --read-bg: #16181c; --row-selected: #0b3a7a;
  --shadow-1: 0 1px 2px rgba(0,0,0,.5), 0 1px 3px 1px rgba(0,0,0,.3);
  --shadow-2: 0 2px 4px rgba(0,0,0,.5), 0 4px 10px 3px rgba(0,0,0,.35);
  --shadow-3: 0 4px 8px rgba(0,0,0,.55), 0 10px 20px 6px rgba(0,0,0,.4);
  color-scheme: dark;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font); font-size: 14px; line-height: 1.45;
  background: var(--bg); color: var(--text);
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
}
h1, h2, h3, h4 { font-family: var(--font-display); margin: 0; font-weight: 600; letter-spacing: -.01em; }
h1 { font-size: 28px; line-height: 1.25; }
h2 { font-size: 22px; line-height: 1.3; }
h3 { font-size: 16px; }
h4 { font-size: 14px; }
p { margin: 0; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font: inherit; color: inherit; }
input, select, textarea { font: inherit; color: inherit; }
code, .mono { font-family: var(--mono); font-size: 12.5px; }
hr { border: 0; border-top: 1px solid var(--border); margin: 16px 0; }
::selection { background: var(--primary-soft); }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.muted { color: var(--text-2); }
.subtle { color: var(--text-3); }
.small { font-size: 12px; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.row { display: flex; align-items: center; gap: 8px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.grow { flex: 1; min-width: 0; }
.wrap { flex-wrap: wrap; }
.gap-4 { gap: 4px; } .gap-16 { gap: 16px; } .gap-24 { gap: 24px; }
.mt-8 { margin-top: 8px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; } .mb-16 { margin-bottom: 16px; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 10px; border: 3px solid transparent; background-clip: content-box; }

/* ---------- Icons (Material Symbols) ---------- */
.ms {
  font-family: 'Material Symbols Rounded'; font-weight: normal; font-style: normal;
  font-size: 20px; line-height: 1; letter-spacing: normal; text-transform: none;
  display: inline-block; white-space: nowrap; direction: ltr; width: 1em; overflow: hidden;
  font-feature-settings: 'liga'; -webkit-font-feature-settings: 'liga';
  font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
  user-select: none; flex-shrink: 0; vertical-align: middle;
}
.ms.fill { font-variation-settings: 'FILL' 1, 'wght' 400, 'GRAD' 0, 'opsz' 24; }
.ms.sm { font-size: 18px; } .ms.lg { font-size: 24px; } .ms.xl { font-size: 32px; }

/* ---------- Brand ---------- */
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--text); font-family: var(--font-display); font-weight: 700; font-size: 20px; letter-spacing: -.02em; }
.brand:hover { text-decoration: none; }
.brand-logo { width: 36px; height: 36px; flex-shrink: 0; }
.brand small { font-family: var(--font); font-weight: 500; font-size: 13px; color: var(--text-2); margin-left: 2px; letter-spacing: 0; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 24px; border-radius: var(--r-full); border: 0;
  font-weight: 500; font-size: 14px; cursor: pointer; white-space: nowrap;
  transition: background .15s var(--ease), box-shadow .15s var(--ease), color .15s;
  background: transparent; color: var(--primary); position: relative; text-decoration: none !important;
}
.btn .ms { font-size: 18px; }
.btn:disabled, .btn.is-disabled { opacity: .45; pointer-events: none; }
.btn-primary { background: var(--primary); color: var(--on-primary); }
.btn-primary:hover { background: var(--primary-hover); box-shadow: var(--shadow-1); }
.btn-tonal { background: var(--primary-soft); color: var(--on-primary-soft); }
.btn-tonal:hover { box-shadow: var(--shadow-1); }
.btn-outline { border: 1px solid var(--border-strong); color: var(--primary); }
.btn-outline:hover { background: var(--hover); }
.btn-text { padding: 0 12px; }
.btn-text:hover { background: var(--hover); }
.btn-ghost { color: var(--text-2); padding: 0 12px; }
.btn-ghost:hover { background: var(--hover); }
.btn-danger { background: var(--danger); color: #fff; }
:root[data-theme="dark"] .btn-danger { color: #3c0b08; }
.btn-danger-text { color: var(--danger); }
.btn-danger-text:hover { background: var(--danger-soft); }
.btn-sm { height: 32px; padding: 0 14px; font-size: 13px; }
.btn-block { width: 100%; }
.btn.loading { color: transparent !important; pointer-events: none; }
.btn.loading::after {
  content: ""; position: absolute; width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid currentColor; border-color: var(--on-primary) var(--on-primary) var(--on-primary) transparent;
  animation: spin .7s linear infinite;
}
.btn-tonal.loading::after, .btn-outline.loading::after, .btn-text.loading::after { border-color: var(--primary) var(--primary) var(--primary) transparent; }

.icon-btn {
  width: 40px; height: 40px; border-radius: 50%; border: 0; background: transparent;
  display: inline-grid; place-items: center; cursor: pointer; color: var(--text-2);
  transition: background .15s; flex-shrink: 0; position: relative;
}
.icon-btn:hover { background: var(--hover); }
.icon-btn:active { background: var(--pressed); }
.icon-btn.sm { width: 32px; height: 32px; }
.icon-btn.sm .ms { font-size: 18px; }
.icon-btn.active { color: var(--primary); }

/* ---------- Tooltips ---------- */
[data-tip] { position: relative; }
[data-tip]:hover::after {
  content: attr(data-tip); position: absolute; top: calc(100% + 6px); left: 50%; transform: translateX(-50%);
  background: #3c4043; color: #fff; font-size: 12px; font-weight: 500; padding: 5px 8px; border-radius: 4px;
  white-space: nowrap; z-index: 900; pointer-events: none; animation: fadeIn .15s .4s both;
}
[data-tip-pos="right"]:hover::after { top: 50%; left: calc(100% + 6px); transform: translateY(-50%); }
[data-tip-pos="top"]:hover::after { top: auto; bottom: calc(100% + 6px); }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label, .label { font-size: 13px; font-weight: 500; color: var(--text-2); }
.field .hint { font-size: 12px; color: var(--text-3); }
.field .error-text { font-size: 12px; color: var(--danger); display: none; align-items: center; gap: 4px; }
.field.has-error .error-text { display: flex; }
.field.has-error .input, .field.has-error .select { border-color: var(--danger); box-shadow: 0 0 0 1px var(--danger); }
.input, .select, .textarea {
  width: 100%; height: 44px; padding: 0 14px; border-radius: var(--r-sm);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  transition: border-color .15s, box-shadow .15s; outline: none;
}
.textarea { height: auto; min-height: 96px; padding: 12px 14px; resize: vertical; line-height: 1.5; }
.input:hover, .select:hover, .textarea:hover { border-color: var(--text-2); }
.input:focus, .select:focus, .textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); }
.input::placeholder, .textarea::placeholder { color: var(--text-3); }
.input.sm, .select.sm { height: 36px; font-size: 13px; }
.select {
  appearance: none; padding-right: 36px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='%23747775'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
}
.input-group { display: flex; align-items: stretch; border: 1px solid var(--border-strong); border-radius: var(--r-sm); background: var(--surface); transition: border-color .15s, box-shadow .15s; overflow: hidden; }
.input-group:focus-within { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); }
.input-group .input { border: 0; box-shadow: none !important; border-radius: 0; }
.input-group .addon { display: flex; align-items: center; padding: 0 12px; background: var(--surface-2); color: var(--text-2); white-space: nowrap; border-left: 1px solid var(--border); font-size: 13px; }
.input-group .addon:first-child { border-left: 0; border-right: 1px solid var(--border); }
.input-group .icon-btn { height: 42px; width: 42px; border-radius: 0; }
.input-group .select { border: 0; box-shadow: none !important; border-radius: 0; border-left: 1px solid var(--border); width: auto; background-color: var(--surface-2); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid .span-2 { grid-column: span 2; }
.checkbox, .radio { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--primary); width: 18px; height: 18px; margin: 0; cursor: pointer; }

/* Toggle switch */
.switch { position: relative; display: inline-flex; width: 52px; height: 32px; flex-shrink: 0; cursor: pointer; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch .track { position: absolute; inset: 0; border-radius: 16px; background: var(--surface-3); border: 2px solid var(--text-3); transition: .2s var(--ease); }
.switch .track::before { content: ""; position: absolute; width: 16px; height: 16px; left: 6px; top: 6px; border-radius: 50%; background: var(--text-3); transition: .2s var(--ease); }
.switch input:checked + .track { background: var(--primary); border-color: var(--primary); }
.switch input:checked + .track::before { width: 24px; height: 24px; left: 22px; top: 2px; background: var(--on-primary); }
.switch input:focus-visible + .track { outline: 2px solid var(--primary); outline-offset: 2px; }

/* Setting rows */
.setting { display: flex; align-items: center; gap: 16px; padding: 16px 0; border-bottom: 1px solid var(--border); }
.setting:last-child { border-bottom: 0; }
.setting .setting-text { flex: 1; min-width: 0; }
.setting .setting-title { font-weight: 500; }
.setting .setting-desc { color: var(--text-2); font-size: 13px; margin-top: 2px; }
.setting .select, .setting .input { width: auto; min-width: 180px; }

/* Segmented control */
.field > .segmented { align-self: flex-start; }
.segmented { display: inline-flex; border: 1px solid var(--border-strong); border-radius: var(--r-full); overflow: hidden; }
.segmented button { border: 0; background: transparent; padding: 0 16px; height: 36px; cursor: pointer; font-weight: 500; font-size: 13px; color: var(--text); display: inline-flex; align-items: center; gap: 6px; border-left: 1px solid var(--border-strong); }
.segmented button:first-child { border-left: 0; }
.segmented button.active { background: var(--primary-soft); color: var(--on-primary-soft); }
.segmented button.active::before { content: "check"; font-family: 'Material Symbols Rounded'; font-size: 18px; }

/* Choice cards (radio as cards) */
.choice-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.choice {
  border: 1px solid var(--border-strong); border-radius: var(--r-md); padding: 16px; cursor: pointer;
  display: flex; gap: 12px; align-items: flex-start; transition: .15s; background: var(--surface);
}
.choice:hover { background: var(--hover); }
.choice input { margin-top: 2px; }
.choice.selected, .choice:has(input:checked) { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); background: color-mix(in srgb, var(--primary-soft) 35%, var(--surface)); }
.choice .choice-icon { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--surface-3); color: var(--primary); flex-shrink: 0; }
.choice .choice-title { font-weight: 600; }
.choice .choice-desc { font-size: 13px; color: var(--text-2); margin-top: 2px; }

/* ---------- Cards ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); }
.card-pad { padding: 24px; }
.card-header { display: flex; align-items: center; gap: 12px; padding: 20px 24px; border-bottom: 1px solid var(--border); }
.card-header h3 { flex: 1; }
.card-header .desc { color: var(--text-2); font-size: 13px; font-weight: 400; margin-top: 2px; font-family: var(--font); }
.card-body { padding: 20px 24px; }
.card-footer { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }

/* ---------- Badges & chips ---------- */
.badge { display: inline-flex; align-items: center; gap: 4px; height: 24px; padding: 0 10px; border-radius: var(--r-full); font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge .ms { font-size: 16px; }
.badge.ok { background: var(--success-soft); color: var(--success); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.err { background: var(--danger-soft); color: var(--danger); }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge.neutral { background: var(--surface-3); color: var(--text-2); }
.badge.pending .ms { animation: spin 1s linear infinite; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.dot.ok { background: var(--success); } .dot.warn { background: var(--warn); } .dot.err { background: var(--danger); } .dot.neutral { background: var(--text-3); }

.chip { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; border-radius: var(--r-sm); border: 1px solid var(--border-strong); background: var(--surface); font-size: 13px; font-weight: 500; cursor: pointer; color: var(--text-2); white-space: nowrap; }
.chip:hover { background: var(--hover); }
.chip.active { background: var(--primary-soft); color: var(--on-primary-soft); border-color: transparent; }
.chip .ms { font-size: 18px; }

/* ---------- Avatars ---------- */
.avatar { width: 32px; height: 32px; border-radius: 50%; display: inline-grid; place-items: center; color: #fff; font-weight: 600; font-size: 14px; flex-shrink: 0; user-select: none; background: var(--primary); text-transform: uppercase; }
.avatar.lg { width: 40px; height: 40px; font-size: 16px; }
.avatar.xl { width: 72px; height: 72px; font-size: 30px; }
.avatar.sm { width: 24px; height: 24px; font-size: 11px; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th { text-align: left; font-weight: 600; color: var(--text-2); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; padding: 12px 16px; border-bottom: 1px solid var(--border); white-space: nowrap; background: var(--surface); position: sticky; top: 0; z-index: 1; }
.table td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background .1s; }
.table tbody tr:hover { background: var(--surface-2); }
.table .cell-user { display: flex; align-items: center; gap: 12px; }
.table .cell-user .name { font-weight: 500; }
.table .cell-user .email { color: var(--text-2); font-size: 12.5px; }
.table .actions { text-align: right; white-space: nowrap; }

/* ---------- Copy field / code ---------- */
.copy-field { display: flex; align-items: center; gap: 4px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-sm); padding: 4px 4px 4px 12px; min-width: 0; }
.copy-field code { flex: 1; min-width: 0; overflow-x: auto; white-space: nowrap; padding: 6px 0; color: var(--text); scrollbar-width: none; }
.copy-field code::-webkit-scrollbar { display: none; }
.copy-field.wrap code { white-space: pre-wrap; word-break: break-all; }
.copy-field .icon-btn { width: 32px; height: 32px; }
.copy-field .icon-btn .ms { font-size: 18px; }
pre.code { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-md); padding: 16px; overflow: auto; font-family: var(--mono); font-size: 12.5px; line-height: 1.6; margin: 0; white-space: pre; }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { position: relative; border: 0; background: transparent; padding: 0 16px; height: 48px; cursor: pointer; font-weight: 500; color: var(--text-2); display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; border-radius: 8px 8px 0 0; }
.tab:hover { background: var(--hover); color: var(--text); }
.tab.active { color: var(--primary); }
.tab.active::after { content: ""; position: absolute; left: 12px; right: 12px; bottom: 0; height: 3px; border-radius: 3px 3px 0 0; background: var(--primary); }

/* ---------- Alerts ---------- */
.alert { display: flex; gap: 12px; padding: 14px 16px; border-radius: var(--r-md); font-size: 13.5px; align-items: flex-start; }
.alert .ms { margin-top: 1px; }
.alert.info { background: var(--info-soft); color: var(--on-primary-soft); }
.alert.info .ms { color: var(--info); }
.alert.warn { background: var(--warn-soft); color: var(--text); }
.alert.warn .ms { color: var(--warn); }
.alert.ok { background: var(--success-soft); color: var(--text); }
.alert.ok .ms { color: var(--success); }
.alert.err { background: var(--danger-soft); color: var(--text); }
.alert.err .ms { color: var(--danger); }
.alert strong { display: block; margin-bottom: 2px; }

/* ---------- Menus / popovers ---------- */
.menu {
  position: fixed; z-index: 1000; min-width: 200px; max-width: 320px; background: var(--surface);
  border-radius: var(--r-sm); box-shadow: var(--shadow-2); padding: 8px 0; animation: menuIn .14s var(--ease);
  max-height: 70vh; overflow-y: auto; border: 1px solid var(--border);
}
.menu-item { display: flex; align-items: center; gap: 14px; padding: 0 16px; height: 40px; cursor: pointer; font-size: 14px; color: var(--text); width: 100%; border: 0; background: transparent; text-align: left; white-space: nowrap; }
.menu-item:hover, .menu-item.focus { background: var(--hover); }
.menu-item .ms { color: var(--text-2); }
.menu-item.danger, .menu-item.danger .ms { color: var(--danger); }
.menu-item .kbd { margin-left: auto; color: var(--text-3); font-size: 12px; }
.menu-sep { height: 1px; background: var(--border); margin: 8px 0; }
.menu-label { padding: 8px 16px 4px; font-size: 12px; color: var(--text-3); font-weight: 500; text-transform: uppercase; letter-spacing: .04em; }
.popover { position: fixed; z-index: 1000; background: var(--surface); border-radius: var(--r-xl); box-shadow: var(--shadow-3); animation: menuIn .16s var(--ease); border: 1px solid var(--border); }

/* ---------- Modal ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 950; display: grid; place-items: center; padding: 16px; animation: fadeIn .15s; }
.modal { background: var(--surface); border-radius: var(--r-xl); width: 100%; max-width: 560px; max-height: calc(100vh - 32px); display: flex; flex-direction: column; box-shadow: var(--shadow-3); animation: modalIn .2s var(--ease); }
.modal.lg { max-width: 760px; }
.modal.sm { max-width: 420px; }
.modal-header { padding: 24px 24px 12px; display: flex; align-items: flex-start; gap: 12px; }
.modal-header h2 { flex: 1; font-size: 22px; }
.modal-header .modal-icon { color: var(--primary); }
.modal-body { padding: 8px 24px 16px; overflow-y: auto; }
.modal-footer { padding: 16px 24px 24px; display: flex; justify-content: flex-end; gap: 8px; }

/* ---------- Toast (snackbar) ---------- */
.toast-stack { position: fixed; left: 24px; bottom: 24px; z-index: 1100; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 16px; min-width: 300px; max-width: 520px; background: #303030; color: #f2f2f2; padding: 4px 8px 4px 16px; min-height: 48px; border-radius: 4px; box-shadow: var(--shadow-2); font-size: 14px; animation: toastIn .25s var(--ease); }
:root[data-theme="dark"] .toast { background: #e3e3e3; color: #1f1f1f; }
.toast .toast-msg { flex: 1; padding: 10px 0; }
.toast .toast-action { background: none; border: 0; color: #a8c7fa; font-weight: 600; cursor: pointer; padding: 8px 10px; border-radius: 4px; }
:root[data-theme="dark"] .toast .toast-action { color: #0b57d0; }
.toast .toast-action:hover { background: rgba(255,255,255,.08); }
.toast .icon-btn { color: inherit; width: 36px; height: 36px; }
.toast.out { animation: toastOut .2s var(--ease) forwards; }

/* ---------- Progress ---------- */
.progress { height: 4px; background: var(--surface-3); border-radius: 4px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--primary); border-radius: 4px; transition: width .4s var(--ease); }
.progress.ok > span { background: var(--success); } .progress.warn > span { background: var(--warn); } .progress.err > span { background: var(--danger); }
.progress.indeterminate { position: relative; background: var(--primary-soft); }
.progress.indeterminate > span { position: absolute; width: 40%; animation: indet 1.1s var(--ease) infinite; }
.spinner { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--primary); border-right-color: transparent; animation: spin .7s linear infinite; display: inline-block; }
.topline-loader { position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 2000; overflow: hidden; display: none; }
.topline-loader.on { display: block; }
.topline-loader::before { content: ""; position: absolute; height: 100%; width: 40%; background: var(--primary); animation: indet 1.1s var(--ease) infinite; }

/* ---------- Empty state ---------- */
.empty { text-align: center; padding: 64px 24px; color: var(--text-2); }
.empty .empty-icon { width: 96px; height: 96px; border-radius: 50%; margin: 0 auto 16px; display: grid; place-items: center; background: var(--surface-3); color: var(--text-3); }
.empty .empty-icon .ms { font-size: 44px; }
.empty h3 { color: var(--text); margin-bottom: 6px; font-size: 18px; }

/* ---------- App shell (top bar + sidebar) ---------- */
.topbar { height: var(--topbar-h); display: flex; align-items: center; gap: 8px; padding: 8px 12px 8px 12px; position: sticky; top: 0; z-index: 50; background: var(--bg); }
.topbar .brand { min-width: calc(var(--sidebar-w) - 64px); padding-left: 4px; }
.topbar .top-actions { display: flex; align-items: center; gap: 2px; margin-left: auto; padding-left: 8px; }
.topbar .avatar-btn { border: 0; background: transparent; padding: 4px; border-radius: 50%; cursor: pointer; margin-left: 6px; }
.topbar .avatar-btn:hover { background: var(--hover); }
.search {
  flex: 1; max-width: 720px; height: 48px; border-radius: var(--r-xl); background: var(--surface-3);
  display: flex; align-items: center; padding: 0 4px; gap: 4px; position: relative; transition: background .15s, box-shadow .15s;
}
.search:focus-within { background: var(--surface); box-shadow: var(--shadow-1); }
.search input { flex: 1; border: 0; background: transparent; outline: none; height: 100%; font-size: 16px; min-width: 0; }
.search input::placeholder { color: var(--text-2); }

.sidebar { width: var(--sidebar-w); flex-shrink: 0; padding: 8px 16px 16px 8px; overflow-y: auto; height: calc(100vh - var(--topbar-h)); position: sticky; top: var(--topbar-h); }
.nav-item {
  display: flex; align-items: center; gap: 18px; height: 32px; padding: 0 12px 0 22px; border-radius: 0 var(--r-full) var(--r-full) 0;
  color: var(--text); cursor: pointer; font-size: 14px; border: 0; background: transparent; width: 100%; text-align: left; text-decoration: none !important;
}
.nav-item .ms { color: var(--text-2); font-size: 20px; }
.nav-item .count { margin-left: auto; font-size: 12px; font-weight: 600; }
.nav-item:hover { background: var(--hover); }
.nav-item.active { background: var(--primary-soft); color: var(--on-primary-soft); font-weight: 700; }
.nav-item.active .ms { color: var(--on-primary-soft); font-variation-settings: 'FILL' 1, 'wght' 400, 'GRAD' 0, 'opsz' 24; }
.nav-item .label-dot { width: 12px; height: 12px; border-radius: 3px; margin: 0 4px; }
.nav-section { margin: 16px 0 6px 22px; font-size: 14px; font-weight: 500; display: flex; align-items: center; justify-content: space-between; color: var(--text); }
.nav-section .icon-btn { width: 28px; height: 28px; }

.main-surface { background: var(--surface); border-radius: var(--r-lg); margin: 0 16px 16px 0; min-height: calc(100vh - var(--topbar-h) - 16px); display: flex; flex-direction: column; min-width: 0; }

/* ---------- Auth layout ---------- */
.auth-page { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px; background: var(--bg); }
.auth-card {
  width: 100%; max-width: 1040px; background: var(--surface); border-radius: var(--r-xl); padding: 36px;
  display: grid; grid-template-columns: 1fr 1fr; gap: 40px; min-height: 384px; position: relative; overflow: hidden;
}
.auth-card .auth-left h1 { font-size: 36px; font-weight: 500; font-family: var(--font-display); margin: 24px 0 14px; }
.auth-card .auth-left p { font-size: 16px; color: var(--text-2); }
.auth-card .auth-right { display: flex; flex-direction: column; justify-content: center; padding-top: 32px; }
.auth-actions { display: flex; justify-content: flex-end; align-items: center; gap: 8px; margin-top: 40px; }
.auth-actions .btn-text { margin-right: auto; padding: 0 8px; margin-left: -8px; }
.auth-footer { width: 100%; max-width: 1040px; display: flex; justify-content: space-between; padding: 16px 4px; font-size: 12px; color: var(--text-2); }
.auth-footer a { color: var(--text-2); margin-left: 24px; }
.auth-footer select { background: transparent; border: 0; color: var(--text-2); font-size: 12px; cursor: pointer; }
.auth-progress { position: absolute; top: 0; left: 0; right: 0; height: 4px; }
.account-chip { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--border-strong); border-radius: var(--r-full); padding: 3px 10px 3px 3px; font-size: 14px; font-weight: 500; cursor: pointer; background: transparent; margin-top: 8px; }
.account-chip:hover { background: var(--hover); }
.step-pane { display: none; animation: slideIn .3s var(--ease); }
.step-pane.active { display: block; }
.strength { display: flex; gap: 4px; margin-top: 8px; }
.strength span { flex: 1; height: 4px; border-radius: 2px; background: var(--surface-3); transition: background .2s; }
.reqs { list-style: none; padding: 0; margin: 10px 0 0; display: grid; grid-template-columns: 1fr 1fr; gap: 4px 12px; font-size: 12.5px; color: var(--text-3); }
.reqs li { display: flex; align-items: center; gap: 6px; }
.reqs li .ms { font-size: 16px; }
.reqs li.ok { color: var(--success); }
.otp { display: flex; gap: 8px; }
.otp input { width: 48px; height: 56px; text-align: center; font-size: 22px; font-weight: 600; border-radius: var(--r-sm); border: 1px solid var(--border-strong); background: var(--surface); outline: none; }
.otp input:focus { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); }
.suggestions { display: flex; flex-direction: column; gap: 2px; margin-top: 8px; }
.suggestions label { display: flex; align-items: center; gap: 12px; padding: 8px 4px; cursor: pointer; border-radius: 8px; }
.suggestions label:hover { background: var(--hover); }

/* ---------- Stepper (wizard) ---------- */
.stepper { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.stepper li { display: flex; align-items: center; gap: 14px; padding: 10px 12px; border-radius: var(--r-md); color: var(--text-2); cursor: default; position: relative; }
.stepper li .step-num { width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--border-strong); display: grid; place-items: center; font-size: 13px; font-weight: 600; flex-shrink: 0; background: var(--surface); }
.stepper li .step-text { display: flex; flex-direction: column; }
.stepper li .step-text small { font-size: 12px; color: var(--text-3); }
.stepper li.active { background: var(--primary-soft); color: var(--on-primary-soft); font-weight: 600; }
.stepper li.active .step-num { border-color: var(--primary); background: var(--primary); color: var(--on-primary); }
.stepper li.done { cursor: pointer; color: var(--text); }
.stepper li.done:hover { background: var(--hover); }
.stepper li.done .step-num { border-color: var(--success); background: var(--success); color: #fff; font-size: 0; }
.stepper li.done .step-num::before { content: "check"; font-family: 'Material Symbols Rounded'; font-size: 18px; }
:root[data-theme="dark"] .stepper li.done .step-num { color: #0f3d1f; }

/* ---------- DNS record list ---------- */
.dns-record { border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface); overflow: hidden; }
.dns-record + .dns-record { margin-top: 12px; }
.dns-record-head { display: flex; align-items: center; gap: 12px; padding: 14px 16px; cursor: pointer; }
.dns-record-head:hover { background: var(--surface-2); }
.dns-type { min-width: 52px; height: 28px; border-radius: 6px; display: inline-grid; place-items: center; font-family: var(--mono); font-size: 12px; font-weight: 700; padding: 0 8px; background: var(--surface-3); color: var(--text); }
.dns-type.MX { background: #e7f0fe; color: #0b57d0; } .dns-type.TXT { background: #e6f4ea; color: #137333; }
.dns-type.CNAME { background: #fef7e0; color: #9a5b00; } .dns-type.SRV { background: #f3e8fd; color: #8430ce; }
.dns-type.CAA { background: #fce8e6; color: #c5221f; } .dns-type.A, .dns-type.AAAA, .dns-type.PTR { background: #e4f7fb; color: #007b83; }
:root[data-theme="dark"] .dns-type.MX { background: #0b3a7a; color: #a8c7fa; }
:root[data-theme="dark"] .dns-type.TXT { background: #0f3d1f; color: #6dd58c; }
:root[data-theme="dark"] .dns-type.CNAME { background: #3d2a00; color: #ffb95c; }
:root[data-theme="dark"] .dns-type.SRV { background: #3a1a5c; color: #d7aefb; }
:root[data-theme="dark"] .dns-type.CAA { background: #4b1512; color: #f2b8b5; }
:root[data-theme="dark"] .dns-type.A, :root[data-theme="dark"] .dns-type.AAAA, :root[data-theme="dark"] .dns-type.PTR { background: #003a40; color: #7fdbe6; }
.dns-record-title { flex: 1; min-width: 0; }
.dns-record-title .t { font-weight: 600; }
.dns-record-title .d { font-size: 12.5px; color: var(--text-2); }
.dns-record-body { padding: 4px 16px 16px; display: none; border-top: 1px solid var(--border); }
.dns-record.open .dns-record-body { display: block; }
.dns-record.open .chev { transform: rotate(180deg); }
.chev { transition: transform .2s var(--ease); color: var(--text-2); }
.dns-fields { display: grid; grid-template-columns: 110px 1fr; gap: 10px 16px; align-items: center; margin-top: 12px; }
.dns-fields > .k { font-size: 12px; color: var(--text-2); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.tag-required { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--text-3); }

/* ---------- Stat cards ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 16px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 20px; display: flex; flex-direction: column; gap: 8px; }
.stat .stat-top { display: flex; align-items: center; justify-content: space-between; color: var(--text-2); font-size: 13px; font-weight: 500; }
.stat .stat-icon { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: var(--primary-soft); color: var(--on-primary-soft); }
.stat .stat-value { font-family: var(--font-display); font-size: 28px; font-weight: 700; letter-spacing: -.02em; }
.stat .stat-delta { font-size: 12.5px; color: var(--text-2); display: flex; align-items: center; gap: 4px; }
.stat .stat-delta.up { color: var(--success); } .stat .stat-delta.down { color: var(--danger); }

/* Score ring */
.ring { --val: 0; --c: var(--success); width: 140px; height: 140px; border-radius: 50%; display: grid; place-items: center; background: conic-gradient(var(--c) calc(var(--val) * 1%), var(--surface-3) 0); position: relative; flex-shrink: 0; }
.ring::before { content: ""; position: absolute; inset: 12px; border-radius: 50%; background: var(--surface); }
.ring > div { position: relative; text-align: center; }
.ring .ring-val { font-family: var(--font-display); font-size: 34px; font-weight: 700; line-height: 1; }
.ring .ring-lbl { font-size: 12px; color: var(--text-2); margin-top: 4px; }

/* Keyboard key */
kbd { font-family: var(--mono); font-size: 12px; background: var(--surface-2); border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: 5px; padding: 2px 7px; color: var(--text); }

/* ---------- Animations ---------- */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes menuIn { from { opacity: 0; transform: scale(.96) translateY(-4px); } to { opacity: 1; transform: none; } }
@keyframes modalIn { from { opacity: 0; transform: scale(.94); } to { opacity: 1; transform: none; } }
@keyframes toastIn { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateY(16px); } }
@keyframes slideIn { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: none; } }
@keyframes indet { from { left: -40%; } to { left: 100%; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } }

/* ---------- Responsive base ---------- */
@media (max-width: 900px) {
  .auth-card { grid-template-columns: 1fr; gap: 8px; padding: 28px 24px; }
  .auth-card .auth-right { padding-top: 0; }
  .auth-card .auth-left h1 { font-size: 28px; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .span-2 { grid-column: auto; }
}
@media (max-width: 600px) {
  .auth-page { padding: 0; justify-content: flex-start; background: var(--surface); }
  .auth-card { border-radius: 0; padding: 24px 16px; }
  .auth-footer { padding: 16px; flex-direction: column; gap: 8px; }
  .auth-footer a { margin: 0 16px 0 0; }
  .toast-stack { left: 16px; right: 16px; bottom: 16px; }
  .toast { min-width: 0; }
  .dns-fields { grid-template-columns: 1fr; gap: 4px; }
  .dns-fields > .k { margin-top: 8px; }
  .reqs { grid-template-columns: 1fr; }
  .otp input { width: 42px; height: 50px; }
}
