/* Dashboard pieces on top of app.css: metric cards, charts, editor, dialogs, toasts. */

.nav-link.as-button { border: 0; background: none; font: inherit; font-size: var(--fs-md); font-weight: 500; cursor: pointer; width: 100%; text-align: left; color: var(--ink-2); }
.switcher { width: 100%; margin: -8px 0 14px; }
.sidebar form { margin: 0; }

#toasts { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 10px; z-index: 50; max-width: min(420px, calc(100vw - 32px)); }
.toast { padding: 12px 16px; border-radius: var(--r); background: var(--ink); color: var(--bg); font-weight: 500; box-shadow: var(--shadow-lg); }
.toast-danger { background: var(--danger); color: #FFFFFF; }

.alert { padding: 12px 16px; border-radius: var(--r); font-weight: 500; border: 1px solid transparent; }
.alert-danger { background: var(--danger-soft); color: var(--danger-ink); }
.alert-ok { background: var(--success-soft); color: var(--success-ink); }
.alert-info { background: var(--cobalt-soft); color: var(--cobalt-soft-ink); }

.auth { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; background: var(--surface-3); }
.auth .card { width: 100%; max-width: 420px; display: flex; flex-direction: column; gap: 16px; padding: 28px; box-shadow: var(--shadow-raised); }
.auth .brand { padding: 0; }
.code-input { font-size: 26px; letter-spacing: 10px; text-align: center; font-weight: 700; min-height: 54px; }

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 8px; }
.toolbar .input { max-width: 320px; }
.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; padding-top: 12px; }

dialog { border: 1px solid var(--line); border-radius: var(--r-xl); padding: 0; background: var(--surface); color: var(--ink); width: min(480px, calc(100vw - 32px)); box-shadow: var(--shadow-lg); }
dialog::backdrop { background: rgba(10, 10, 12, .5); backdrop-filter: blur(2px); }
dialog .card { box-shadow: none; border: 0; display: flex; flex-direction: column; gap: 14px; padding: 24px; }

/* ---------- Metric cards (overview) ---------- */
.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
@media (max-width: 1280px) { .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px) { .metrics { grid-template-columns: 1fr; } }
/* Number cards: a title, one big number, one line of context, and two figures in a quiet footer. */
.metric { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 18px 20px; display: flex; flex-direction: column; gap: 4px; }
.metric-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.metric-head h2 { font-size: var(--fs); font-weight: 500; color: var(--muted); letter-spacing: 0; }
.tile { width: 30px; height: 30px; border-radius: var(--r-sm); background: var(--surface-2); color: var(--ink-2); display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.tile svg { width: 15px; height: 15px; }
.metric .v { font-size: 30px; font-weight: 700; letter-spacing: -0.03em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.metric .v .of { font-size: var(--fs-md); font-weight: 500; color: var(--muted); margin-left: 3px; letter-spacing: 0; }
.metric-note { font-size: var(--fs-sm); color: var(--muted); height: 22px; display: flex; align-items: center; }
.metric-foot { display: flex; justify-content: space-between; gap: 8px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line-soft); font-size: var(--fs-sm); color: var(--muted); }
.metric-foot strong { color: var(--ink); font-weight: 600; }
.delta { font-weight: 600; margin-right: 4px; }
.delta.up { color: var(--success-ink); }
.delta.down { color: var(--danger-ink); }
.axis { display: flex; justify-content: space-between; font-size: var(--fs-sm); color: var(--muted); margin-top: 6px; }
.split-row { display: flex; justify-content: space-between; font-size: var(--fs-sm); }
.split-row strong { font-weight: 600; }
.split-row span:last-child { color: var(--muted); }

.progress { height: 8px; border-radius: var(--pill); background: var(--surface-2); overflow: hidden; }
.progress > span { display: block; height: 100%; border-radius: var(--pill); background: var(--cobalt); }
.split-bar { display: flex; height: 18px; border-radius: var(--pill); overflow: hidden; background: var(--surface-2); }
.split-bar > span { height: 100%; background-image: repeating-linear-gradient(-45deg, rgba(255,255,255,.22) 0 6px, transparent 6px 12px); }
.legend { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.legend li { display: flex; align-items: center; gap: 10px; font-size: var(--fs-md); }
.legend li strong { margin-left: auto; font-weight: 600; font-variant-numeric: tabular-nums; }
.swatch { width: 12px; height: 12px; border-radius: 3px; flex-shrink: 0; }

.bars { display: flex; align-items: flex-end; gap: 6px; height: 44px; }
.bars > span { flex: 1; min-height: 6px; border-radius: 4px; background: var(--c-blue-soft); }
.bars > span.now { background: var(--c-blue); }

.panels { display: grid; grid-template-columns: minmax(0, 2.4fr) minmax(300px, 1fr); gap: 16px; }
@media (max-width: 1100px) { .panels { grid-template-columns: 1fr; } }
.panel-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.panel-head h2 { font-size: var(--fs-lg); }
.panel-head .actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.chart-key { display: flex; gap: 16px; font-size: var(--fs-sm); color: var(--muted); }
.chart-key span { display: inline-flex; align-items: center; gap: 6px; }
.chart-key i { width: 14px; height: 3px; border-radius: 2px; display: inline-block; }
.chart-key i.dashed { background: repeating-linear-gradient(90deg, var(--c-blue) 0 4px, transparent 4px 7px); }
svg.chart-svg { display: block; width: 100%; height: auto; overflow: visible; }
svg.chart-svg text { font: 500 12px var(--font); fill: var(--muted); }
.donut-wrap { position: relative; width: min(240px, 100%); margin: 8px auto 4px; }
.donut-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.donut-center .v { font-size: 36px; font-weight: 700; letter-spacing: -0.03em; line-height: 1; }
.donut-center span:last-child { color: var(--muted); font-size: var(--fs-md); margin-top: 6px; }

/* ---------- Editor ---------- */
.editor { display: grid; grid-template-columns: minmax(0, 1fr) minmax(300px, 420px); gap: 16px; align-items: start; }
.editor .textarea.body { min-height: 420px; font: 400 14px/1.65 ui-monospace, SFMono-Regular, Menlo, monospace; }
.editor-side { display: flex; flex-direction: column; gap: 16px; position: sticky; top: 20px; }
.preview-frame { width: 100%; height: 460px; border: 1px solid var(--line); border-radius: var(--r); background: #F5F6FA; }
.checks { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 9px; }
.checks li { display: flex; gap: 10px; align-items: flex-start; font-size: var(--fs-sm); }
.checks svg { width: 16px; height: 16px; flex-shrink: 0; margin-top: 2px; }
.checks .ok svg { color: var(--success-ink); }
.checks .bad svg { color: var(--danger-ink); }
.saved { font-size: var(--fs-xs); color: var(--muted); font-weight: 500; }
@media (max-width: 1080px) { .editor { grid-template-columns: 1fr; } .editor-side { position: static; } }

.timeline { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.timeline li { display: flex; gap: 10px; font-size: var(--fs-sm); }
.timeline svg { width: 16px; height: 16px; flex-shrink: 0; color: var(--muted); margin-top: 2px; }
.dropzone { border: 1.5px dashed var(--line); border-radius: var(--r-lg); padding: 32px; text-align: center; display: flex; flex-direction: column; gap: 10px; align-items: center; background: var(--surface-3); }
.key-reveal { font: 500 13px ui-monospace, Menlo, monospace; word-break: break-all; padding: 12px 14px; border-radius: var(--r-sm); background: var(--surface-2); border: 1px solid var(--line); }
.htmx-request .spinner-hide { opacity: .5; }
.hint svg, .alert svg { width: 14px; height: 14px; vertical-align: -2px; }
.badge svg { width: 12px; height: 12px; }
.seg-label { display: inline-flex; align-items: center; gap: 8px; padding: 0 14px; min-height: 36px; color: var(--ink-2); font-weight: 500; border-right: 1px solid var(--line); }
.seg-label + a { border-left: 0; }
.seg a { text-decoration: none; }
.metric-note .badge { padding: 1px 8px; line-height: 20px; }

/* ---------- Lists with status pills (domains) ---------- */
.tile-lg { width: 40px; height: 40px; border-radius: var(--r); }
.tile-lg svg { width: 20px; height: 20px; }
.back { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-weight: 500; font-size: var(--fs-sm); width: max-content; }
.back:hover { color: var(--ink); }
.back svg { width: 15px; height: 15px; }
.search { position: relative; flex: 1; display: block; }
.search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--muted); }
.search .input { padding-left: 36px; max-width: none; }
.card.flush { padding: 0; overflow: hidden; }
.card.flush .table th { padding: 12px 20px; background: var(--surface-3); }
.card.flush .table td { padding: 16px 20px; }
.table-rows tr.clickable { cursor: pointer; }
.pill { display: inline-flex; align-items: center; gap: 7px; padding: 3px 10px; border: 1px solid var(--line); border-radius: var(--pill); background: var(--surface); font-size: var(--fs-sm); font-weight: 500; white-space: nowrap; color: var(--ink-2); }
.pill .dot { width: 7px; height: 7px; }
.pill-ok .dot { color: var(--success); }
.pill-wait .dot { color: var(--c-orange); }
.pill-bad .dot { color: var(--danger); }
.pill-none .dot { color: var(--subtle); }
.danger-text { color: var(--danger-ink); }
h1 .pill { font-size: var(--fs-sm); letter-spacing: 0; }

/* ---------- Editor: the email's header, like a mail client's ---------- */
.envelope { padding: 4px 20px; }
.env-row { display: flex; align-items: center; gap: 14px; min-height: 52px; border-bottom: 1px solid var(--line-soft); }
.env-row:last-child { border-bottom: 0; }
.env-label { flex: 0 0 64px; font-size: var(--fs-sm); color: var(--muted); font-weight: 500; }
.env-input { flex: 1; min-width: 0; border: 0; background: transparent; color: var(--ink); font: 400 var(--fs-md) var(--font); padding: 8px 0; outline: none; }
.env-input:focus-visible { box-shadow: inset 0 -2px 0 var(--cobalt); border-radius: 0; }
select.env-input { cursor: pointer; padding-right: 8px; }
.env-subject { font-weight: 600; }
.env-from { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.env-name { flex: 0 1 150px; font-weight: 600; }
.env-address { flex: 1 1 320px; min-width: 0; display: inline-flex; align-items: center; gap: 2px; padding: 3px 4px 3px 10px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface-3); }
.env-address .env-input { font-size: var(--fs); padding: 5px 0; }
.env-local { flex: 0 1 170px; min-width: 60px; text-align: right; }
.env-local[readonly] { color: var(--muted); }
.env-at { color: var(--muted); font-weight: 500; }
.env-domain { flex: 1 1 auto; }
.env-hint { display: inline-flex; align-items: center; gap: 4px; font-size: var(--fs-sm); white-space: nowrap; }
.env-hint svg { width: 14px; height: 14px; }
.sender-avatar { background: var(--cobalt); color: #FFFFFF; border: 0; border-radius: 50%; }
.inbox-row { display: flex; gap: 12px; padding: 12px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface-3); }
.inbox-text { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 2px; }
.inbox-top { display: flex; justify-content: space-between; gap: 8px; font-size: var(--fs); }
.inbox-top .muted { font-size: var(--fs-xs); }
.inbox-subject { font-weight: 600; font-size: var(--fs); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.inbox-preview { color: var(--muted); font-size: var(--fs-sm); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 640px) { .env-row { flex-wrap: wrap; gap: 4px; padding: 8px 0; } .env-label { flex-basis: 100%; } }
