/* Dot Office Alert - admin dashboard */
:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #f8f9fc;
  --border: #e3e7f0;
  --border-strong: #cfd5e3;
  --text: #172033;
  --text-2: #4a556d;
  --muted: #7a849b;
  --accent: #4f63e7;
  --accent-hover: #3f52d4;
  --accent-soft: #eef0fe;
  --sidebar: #111a2e;
  --sidebar-2: #1a2540;
  --sidebar-text: #c4cbe0;
  --ok: #148a5b;
  --ok-soft: #e5f6ee;
  --warn: #b86e00;
  --warn-soft: #fff4e0;
  --danger: #cf2f3f;
  --danger-soft: #fdecee;
  --info: #2b6fd6;
  --info-soft: #e8f1fd;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.05), 0 1px 3px rgba(16, 24, 40, 0.06);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, 0.18);
  --font: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, "SF Mono", monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0c1222;
    --surface: #141c30;
    --surface-2: #19223a;
    --border: #263150;
    --border-strong: #33406a;
    --text: #e8ecf7;
    --text-2: #b4bdd4;
    --muted: #8590ab;
    --accent: #7086ff;
    --accent-hover: #8697ff;
    --accent-soft: #1f2a52;
    --sidebar: #0a0f1d;
    --sidebar-2: #151d33;
    --ok-soft: #10362a;
    --ok: #3fcf8e;
    --warn-soft: #3a2a0c;
    --warn: #f3b048;
    --danger-soft: #3d1820;
    --danger: #ff6b7a;
    --info-soft: #12284a;
    --info: #6aa6ff;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 14px/1.5 var(--font); background: var(--bg); color: var(--text); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 22px; font-weight: 650; }
h2 { font-size: 16px; font-weight: 650; }
h3 { font-size: 14px; font-weight: 650; }
p { margin: 0 0 10px; }
code, .mono { font-family: var(--mono); font-size: 12.5px; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.prewrap { white-space: pre-wrap; word-break: break-word; }
.right { text-align: right; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.grow { flex: 1; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- Layout ---------- */
.shell { display: grid; grid-template-columns: 244px 1fr; min-height: 100vh; }
.sidebar { background: var(--sidebar); color: var(--sidebar-text); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; gap: 11px; align-items: center; padding: 20px 18px 18px; color: #fff; }
.brand-mark { width: 34px; height: 34px; border-radius: 10px; background: linear-gradient(135deg, #5b72ff, #3a4fd8); display: grid; place-items: center; box-shadow: 0 4px 14px rgba(79, 99, 231, 0.45); }
.brand-mark span { width: 12px; height: 12px; border-radius: 50%; background: #fff; display: block; }
.brand-name { font-weight: 700; font-size: 15px; letter-spacing: 0.1px; }
.brand-sub { font-size: 11px; color: #8d97b5; }
.nav { padding: 6px 10px; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; flex: 1; }
.nav-section { font-size: 10.5px; letter-spacing: 1.2px; text-transform: uppercase; color: #6c7697; padding: 14px 10px 6px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--sidebar-text); font-weight: 500; }
.nav a:hover { background: var(--sidebar-2); text-decoration: none; color: #fff; }
.nav a.active { background: #26335a; color: #fff; }
.nav a svg { width: 17px; height: 17px; flex: none; opacity: 0.85; }
.nav .count { margin-left: auto; background: var(--danger); color: #fff; border-radius: 999px; font-size: 11px; padding: 0 7px; font-weight: 700; }
.sidebar-foot { padding: 14px 16px; border-top: 1px solid #1f2a47; font-size: 12px; }
.sidebar-foot .who { color: #fff; font-weight: 600; }
.sidebar-foot button { margin-top: 8px; width: 100%; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 22px 32px 6px; }
.topbar .sub { color: var(--muted); font-size: 13px; margin-top: 3px; }
.content { padding: 16px 32px 40px; max-width: 1320px; width: 100%; }
.menu-btn { display: none; }

/* ---------- Cards ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.card-body { padding: 18px 20px; }
.card + .card { margin-top: 18px; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.grid-2 > .card + .card { margin-top: 0; }

.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(178px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat { padding: 16px 18px; }
.stat .label { color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.6px; }
.stat .value { font-size: 28px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat .hint { font-size: 12px; color: var(--muted); }
.stat.ok .value { color: var(--ok); }
.stat.warn .value { color: var(--warn); }
.stat.danger .value { color: var(--danger); }
.stat a { color: inherit; }

/* ---------- Buttons & forms ---------- */
button, .btn { font: inherit; font-weight: 600; font-size: 13.5px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); padding: 8px 14px; cursor: pointer; display: inline-flex; align-items: center; gap: 7px; justify-content: center; line-height: 1.3; }
button:hover, .btn:hover { background: var(--surface-2); text-decoration: none; }
button:disabled { opacity: 0.55; cursor: not-allowed; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: var(--danger); filter: brightness(1.08); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-sm { padding: 5px 10px; font-size: 12.5px; }
.sidebar .btn-ghost { color: var(--sidebar-text); border-color: #2a3657; }
.sidebar .btn-ghost:hover { background: var(--sidebar-2); }

.field { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: 13px; color: var(--text-2); }
.field .hint, .field-hint { font-weight: 400; color: var(--muted); font-size: 12px; }
input[type=text], input[type=password], input[type=url], input[type=search], input[type=number], input[type=datetime-local], input[type=date], input[type=email], select, textarea {
  font: inherit; font-size: 14px; color: var(--text); background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); padding: 9px 11px; width: 100%;
}
textarea { resize: vertical; min-height: 110px; }
input::placeholder, textarea::placeholder { color: var(--muted); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid .span-2 { grid-column: span 2; }
.check { display: flex; gap: 9px; align-items: flex-start; font-weight: 500; color: var(--text); cursor: pointer; }
.check input { margin-top: 3px; accent-color: var(--accent); width: 16px; height: 16px; }
.counter { font-weight: 400; font-size: 11.5px; color: var(--muted); margin-left: auto; }
.label-row { display: flex; align-items: baseline; gap: 8px; }

.segmented { display: inline-flex; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); overflow: hidden; }
.segmented button { border: 0; border-radius: 0; border-right: 1px solid var(--border-strong); padding: 8px 16px; background: var(--surface); }
.segmented button:last-child { border-right: 0; }
.segmented button.on { background: var(--accent-soft); color: var(--accent); }
.segmented button.on.p-high { background: var(--warn-soft); color: var(--warn); }
.segmented button.on.p-urgent { background: var(--danger-soft); color: var(--danger); }

.choice-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.choice { border: 1px solid var(--border-strong); border-radius: var(--radius-sm); padding: 11px 12px; cursor: pointer; background: var(--surface); text-align: left; flex-direction: column; align-items: flex-start; gap: 2px; font-weight: 600; }
.choice small { font-weight: 400; color: var(--muted); font-size: 12px; }
.choice.on { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); background: var(--accent-soft); }
.picklist { border: 1px solid var(--border); border-radius: var(--radius-sm); max-height: 240px; overflow-y: auto; padding: 4px; background: var(--surface-2); }
.picklist .check { padding: 7px 8px; border-radius: 6px; }
.picklist .check:hover { background: var(--surface); }
.picklist .check .muted { margin-left: auto; font-size: 12px; }
.recipient-summary { padding: 10px 12px; background: var(--info-soft); color: var(--info); border-radius: var(--radius-sm); font-weight: 600; font-size: 13px; }
.recipient-summary.zero { background: var(--warn-soft); color: var(--warn); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.6px; color: var(--muted); font-weight: 650; padding: 10px 14px; border-bottom: 1px solid var(--border); background: var(--surface-2); white-space: nowrap; }
td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--surface-2); }
td .title { font-weight: 600; }
td .preview { color: var(--muted); font-size: 12.5px; max-width: 420px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 14px 20px; border-bottom: 1px solid var(--border); }
.toolbar input[type=search] { max-width: 280px; }
.toolbar select { width: auto; min-width: 150px; }
.pager { display: flex; justify-content: space-between; align-items: center; padding: 12px 20px; border-top: 1px solid var(--border); font-size: 13px; color: var(--muted); }

.tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.tabs button { border: 0; background: transparent; color: var(--text-2); padding: 7px 12px; border-radius: 999px; }
.tabs button.on { background: var(--accent-soft); color: var(--accent); }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 650; background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.badge.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.badge.danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.badge.info { background: var(--info-soft); color: var(--info); border-color: transparent; }
.badge.accent { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: var(--muted); flex: none; }
.dot.ok { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }
.dot.off { background: #a3abbf; }
.dot.warn { background: var(--warn); }

.progress { height: 6px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; overflow: hidden; min-width: 70px; }
.progress > span { display: block; height: 100%; background: var(--accent); }
.progress.ok > span { background: var(--ok); }
.metric { display: flex; flex-direction: column; gap: 4px; min-width: 90px; font-size: 12.5px; }

/* ---------- States ---------- */
.empty { text-align: center; padding: 42px 20px; color: var(--muted); }
.empty h3 { color: var(--text); margin-bottom: 6px; }
.loading { padding: 34px; text-align: center; color: var(--muted); }
.spinner { width: 22px; height: 22px; border: 3px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; display: inline-block; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }
.alert { padding: 11px 14px; border-radius: var(--radius-sm); font-size: 13px; border: 1px solid transparent; }
.alert.error { background: var(--danger-soft); color: var(--danger); }
.alert.ok { background: var(--ok-soft); color: var(--ok); }
.alert.warn { background: var(--warn-soft); color: var(--warn); }
.alert.info { background: var(--info-soft); color: var(--info); }

/* ---------- Detail ---------- */
.kv { display: grid; grid-template-columns: 150px 1fr; gap: 8px 14px; font-size: 13.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-word; }
.message-box { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px; white-space: pre-wrap; word-break: break-word; }
.metrics-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }

/* ---------- Toast preview ---------- */
.toast-preview { background: #1f2433; color: #f1f3f9; border-radius: 10px; padding: 14px 16px; box-shadow: var(--shadow-lg); border-left: 4px solid #6b7bff; max-width: 380px; }
.toast-preview.p-high { border-left-color: #f0a020; }
.toast-preview.p-urgent { border-left-color: #ff4d5e; }
.toast-preview .app { font-size: 11.5px; color: #a9b1c7; display: flex; gap: 7px; align-items: center; margin-bottom: 6px; }
.toast-preview .app .mini { width: 14px; height: 14px; border-radius: 4px; background: #4f63e7; display: grid; place-items: center; }
.toast-preview .app .mini span { width: 5px; height: 5px; border-radius: 50%; background: #fff; display: block; }
.toast-preview .t { font-weight: 650; margin-bottom: 3px; }
.toast-preview .m { font-size: 13px; color: #d5d9e6; white-space: pre-wrap; word-break: break-word; max-height: 120px; overflow: hidden; }

/* ---------- Modal & toasts ---------- */
dialog { border: 0; border-radius: 14px; padding: 0; box-shadow: var(--shadow-lg); width: min(560px, calc(100vw - 32px)); background: var(--surface); color: var(--text); }
dialog::backdrop { background: rgba(10, 15, 30, 0.55); }
.modal-head { padding: 18px 22px 0; display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.modal-body { padding: 16px 22px; }
.modal-foot { padding: 14px 22px 18px; display: flex; justify-content: flex-end; gap: 10px; border-top: 1px solid var(--border); }
.toasts { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 10px; z-index: 1000; }
.toast { background: var(--text); color: var(--surface); padding: 11px 16px; border-radius: 10px; box-shadow: var(--shadow-lg); font-weight: 500; max-width: 380px; }
.toast.error { background: var(--danger); color: #fff; }
.toast.ok { background: var(--ok); color: #fff; }
.secret-box { font-family: var(--mono); font-size: 17px; letter-spacing: 1px; padding: 14px; text-align: center; background: var(--surface-2); border: 1px dashed var(--border-strong); border-radius: var(--radius-sm); user-select: all; word-break: break-all; }
.qr { display: block; margin: 8px auto; width: 200px; height: 200px; background: #fff; padding: 6px; border-radius: 8px; }

/* ---------- Auth pages ---------- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(1200px 600px at 10% -10%, #dfe4ff 0, transparent 60%), var(--bg); }
.auth-card { width: min(400px, 100%); padding: 30px 28px; }
.auth-card .brand { padding: 0 0 20px; color: var(--text); }
.auth-card .brand-sub { color: var(--muted); }
@media (prefers-color-scheme: dark) { .auth-wrap { background: radial-gradient(1200px 600px at 10% -10%, #1c2550 0, transparent 60%), var(--bg); } }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 260px; z-index: 50; transform: translateX(-100%); transition: transform 0.2s; }
  .shell.nav-open .sidebar { transform: none; box-shadow: var(--shadow-lg); }
  .menu-btn { display: inline-flex; }
  .topbar { padding: 16px 16px 4px; }
  .content { padding: 12px 16px 32px; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .span-2 { grid-column: auto; }
  .choice-cards { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 1fr; gap: 2px; }
  .kv dd { margin-bottom: 8px; }
  .metrics-row { grid-template-columns: 1fr; }
  .hide-sm { display: none; }
}

/* ---------- Fixes ---------- */
button svg, .btn svg { width: 16px; height: 16px; flex: none; }
button, .btn { white-space: nowrap; }
.stats > .card + .card { margin-top: 0; }
.stats { grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); }
.choice-cards { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.nav a { padding: 7px 10px; }
.nav-section { padding: 10px 10px 4px; }
.picklist .check span:first-of-type { flex: 1; }
td .badge + .badge { margin-left: 4px; }
hr { border: 0; border-top: 1px solid var(--border); margin: 4px 0; width: 100%; }
dialog { max-height: calc(100vh - 40px); overflow-y: auto; }

/* tasks */
.prewrap { white-space: pre-wrap; word-break: break-word; }
pre.prewrap { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; margin: 0; max-height: 320px; overflow: auto; }
.strong { font-weight: 650; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--surface-2); }
ol.steps { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 8px; font-size: 13.5px; }
textarea.mono { font-family: var(--mono); font-size: 12.5px; }
