/* SMS Cluster: a dense, quiet admin UI. One accent (teal), money out in red, money in in green. */

:root {
    --bg: #f4f5f7;
    --panel: #ffffff;
    --line: #e3e6ea;
    --line-strong: #cfd4da;
    --text: #1c2430;
    --muted: #667085;
    --accent: #0f766e;
    --accent-soft: #e6f4f2;
    --out: #b42318;
    --out-soft: #fdecea;
    --in: #067647;
    --in-soft: #e7f6ee;
    --warn: #8a5a00;
    --warn-soft: #fdf3dc;
    --radius: 8px;
    --mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
    font-family: system-ui, -apple-system, "Segoe UI", "Microsoft YaHei", sans-serif;
    font-size: 14px;
    color: var(--text);
    background: var(--bg);
}

* { box-sizing: border-box; }
body { margin: 0; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 16px; margin: 24px 0 10px; }
p { margin: 6px 0; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.nowrap { white-space: nowrap; }
.out-amt { color: var(--out); }
.in-amt { color: var(--in); }

/* ---- Shell ---- */
.shell { display: grid; grid-template-columns: 210px 1fr; min-height: 100vh; }
.side { background: #111a24; color: #cfd6df; display: flex; flex-direction: column; padding: 16px 10px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; font-weight: 600; font-size: 15px; padding: 4px 8px 18px; }
.brand:hover { text-decoration: none; }
.brand-mark { width: 22px; height: 22px; border-radius: 6px; background: var(--accent); position: relative; }
.brand-mark::after { content: ""; position: absolute; inset: 6px 5px 7px; border-radius: 2px; background: #fff; }
.side nav { display: flex; flex-direction: column; gap: 1px; flex: 1; }
.side nav a { color: #cfd6df; padding: 7px 10px; border-radius: 6px; }
.side nav a:hover { background: #1c2836; text-decoration: none; }
.side nav a.active { background: #1f3a3a; color: #fff; }
.nav-group { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: #7d8896; padding: 14px 10px 4px; }
.who { border-top: 1px solid #243140; padding: 12px 10px 0; display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 13px; }
.who form { margin: 0; }
.who .link { color: #9fb0c2; }
.content { padding: 24px 28px 48px; min-width: 0; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }

/* ---- Panels, stats ---- */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; margin-bottom: 20px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.stat .label { color: var(--muted); font-size: 12px; }
.stat .value { font-size: 22px; font-weight: 600; margin-top: 2px; font-variant-numeric: tabular-nums; }
.stat .value small { font-size: 12px; font-weight: 400; color: var(--muted); }
.stat.attention { border-color: #f0c36b; background: #fffbf0; }
.stat a { color: inherit; }

/* ---- Tables ---- */
.table-wrap { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { font-size: 12px; font-weight: 600; color: var(--muted); background: #fafbfc; position: sticky; top: 0; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fafcfc; }
td.body { max-width: 520px; white-space: pre-wrap; word-break: break-word; }
td.actions { white-space: nowrap; text-align: right; }
tr.inactive td { color: var(--muted); }
.empty { padding: 28px; text-align: center; color: var(--muted); }
tfoot td { font-weight: 600; background: #fafbfc; }

/* ---- Badges ---- */
.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; background: #eef0f3; color: #475467; white-space: nowrap; }
.badge.good { background: var(--in-soft); color: var(--in); }
.badge.bad { background: var(--out-soft); color: var(--out); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.out { background: var(--out-soft); color: var(--out); }
.badge.in { background: var(--in-soft); color: var(--in); }
.chip { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line-strong); border-radius: 999px; padding: 2px 4px 2px 10px; margin: 0 6px 6px 0; font-family: var(--mono); font-size: 13px; }
.chip.off { color: var(--muted); border-style: dashed; }

/* ---- Forms ---- */
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-bottom: 14px; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.field.grow { flex: 1; min-width: 220px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; align-items: end; }
.form-grid .wide { grid-column: 1 / -1; }
input, select, textarea { font: inherit; color: var(--text); border: 1px solid var(--line-strong); border-radius: 6px; padding: 6px 9px; background: #fff; min-width: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid #99d5ce; outline-offset: 0; border-color: var(--accent); }
textarea { font-family: var(--mono); font-size: 13px; resize: vertical; }
textarea.sms { font-family: inherit; font-size: 14px; }
label.check { flex-direction: row; align-items: center; gap: 6px; color: var(--text); font-size: 14px; }
.form-actions { display: flex; gap: 8px; margin-top: 14px; align-items: center; }

button, .button { font: inherit; border: 1px solid var(--line-strong); background: #fff; color: var(--text); border-radius: 6px; padding: 6px 12px; cursor: pointer; white-space: nowrap; display: inline-block; }
button:hover, .button:hover { background: #f3f5f7; text-decoration: none; }
button.primary, .button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover, .button.primary:hover { background: #0b5f59; }
button.danger { color: var(--out); }
button.small { padding: 2px 8px; font-size: 12px; }
button.link { border: 0; background: none; padding: 0; color: var(--accent); }
button.link:hover { text-decoration: underline; background: none; }
button:disabled { opacity: .55; cursor: default; }
.chip button { border: 0; background: none; padding: 0 6px; font-size: 12px; color: var(--muted); }

.notice { border-radius: 6px; padding: 8px 12px; margin-bottom: 14px; }
.notice.error { background: var(--out-soft); color: var(--out); border: 1px solid #f5c2bd; }
.notice.ok { background: var(--in-soft); color: var(--in); border: 1px solid #b7e4cb; }
.validation-message { color: var(--out); font-size: 12px; }

/* ---- Template editor ---- */
.split { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-word; }
.help { font-size: 13px; color: var(--muted); }
.help code, td code { font-family: var(--mono); font-size: 12px; background: #f1f3f5; padding: 0 4px; border-radius: 4px; }

/* ---- Sign-in ---- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-card { width: 100%; max-width: 380px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 28px; }
.auth-card .brand { color: var(--text); padding: 0 0 18px; }
.auth-card form { display: flex; flex-direction: column; gap: 12px; margin-top: 14px; }
.auth-card .field { font-size: 13px; }

#blazor-error-ui { display: none; position: fixed; bottom: 0; left: 0; right: 0; padding: 10px 20px; background: var(--out-soft); color: var(--out); border-top: 1px solid #f5c2bd; z-index: 1000; }

@media (max-width: 900px) {
    .shell { grid-template-columns: 1fr; }
    .side { position: static; height: auto; }
    .side nav { flex-direction: row; flex-wrap: wrap; }
    .nav-group { display: none; }
    .split { grid-template-columns: 1fr; }
    .content { padding: 16px; }
}

/* ---- New API key ---- */
.key-panel { border-color: #99d5ce; background: var(--accent-soft); }
.key-box { display: flex; gap: 10px; align-items: center; margin: 10px 0; flex-wrap: wrap; }
.key-box code { font-family: var(--mono); font-size: 15px; background: #fff; border: 1px solid var(--line-strong); border-radius: 6px; padding: 8px 12px; word-break: break-all; user-select: all; }
