/* Mailora design system */
:root {
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "JetBrains Mono", "Cascadia Mono", "SF Mono", Consolas, monospace;
  --r-sm: 5px; --r-md: 5px; --r-lg: 8px;
  --sp-1: .25rem; --sp-2: .5rem; --sp-3: .75rem; --sp-4: 1rem; --sp-5: 1.5rem; --sp-6: 2rem;
  --ease: cubic-bezier(.2, .8, .2, 1);

  --bg: #f3f6f6; --elev: #fff; --panel: #fff; --panel-2: #f5f8f8; --line: #dde5e4; --line-strong: #c5d0cf;
  --text: #455350; --text-strong: #14211f; --muted: #66767a;
  --brand: #0f766e; --brand-hover: #0b5f58; --brand-soft: rgba(15, 118, 110, .10); --on-brand: #fff;
  --ok: #178a54; --ok-soft: rgba(23, 138, 84, .11); --warn: #a86a00; --warn-soft: rgba(200, 130, 0, .13); --err: #c8332b; --err-soft: rgba(200, 51, 43, .10);
  --shadow: 0 1px 2px rgba(10, 30, 28, .08);
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #11171a; --elev: #161d20; --panel: #1a2226; --panel-2: #212b30; --line: #2a353b; --line-strong: #394650;
  --text: #a9b6b8; --text-strong: #e4ecec; --muted: #7f8f93;
  --brand: #2dd4bf; --brand-hover: #5eead4; --brand-soft: rgba(45, 212, 191, .13); --on-brand: #06231f;
  --ok: #3fb97c; --ok-soft: rgba(63, 185, 124, .14); --warn: #e0a23c; --warn-soft: rgba(224, 162, 60, .15); --err: #e5534b; --err-soft: rgba(229, 83, 75, .15);
  --shadow: 0 1px 2px rgba(0, 0, 0, .3);
}
* { box-sizing: border-box; }
html { font-size: 14px; }
body { margin: 0; font-family: var(--font); background: var(--bg); color: var(--text); line-height: 1.5; -webkit-font-smoothing: antialiased; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: 1.45rem; font-weight: 600; color: var(--text-strong); letter-spacing: -.01em; line-height: 1.25; }
h2 { font-size: 1.05rem; font-weight: 600; color: var(--text-strong); }
a { color: var(--brand); text-decoration: none; } a:hover { text-decoration: underline; }
button { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: var(--r-sm); }
[hidden] { display: none !important; }
.muted { color: var(--muted); } .small { font-size: .85rem; } .mono { font-family: var(--mono); font-size: .88em; } .num { font-variant-numeric: tabular-nums; } .strong { font-weight: 600; color: var(--text-strong); }
svg.i { width: 1.15rem; height: 1.15rem; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* Components */
.btn { display: inline-flex; align-items: center; gap: var(--sp-2); height: 2.25rem; padding: 0 var(--sp-4); border: 1px solid var(--line-strong); border-radius: var(--r-md); background: var(--panel); font-weight: 500; font-size: .92rem; white-space: nowrap; }
.btn:hover { background: var(--panel-2); text-decoration: none; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--on-brand); } .btn.primary:hover { background: var(--brand-hover); }
.btn.ghost { border-color: transparent; background: none; } .btn.ghost:hover { background: var(--panel-2); }
.btn.danger { border-color: var(--err); color: var(--err); } .btn.danger:hover { background: var(--err-soft); }
.btn.icon { width: 2.25rem; padding: 0; justify-content: center; }
.btn.block { width: 100%; justify-content: center; height: 2.6rem; }
.btn:disabled { opacity: .6; cursor: not-allowed; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow); }
.card-pad { padding: var(--sp-5); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); margin-bottom: var(--sp-4); }
.pill { display: inline-flex; align-items: center; gap: .4rem; padding: .12rem .6rem; border-radius: 99px; font-size: .78rem; font-weight: 500; background: var(--panel-2); color: var(--muted); }
.pill::before { content: ""; width: .5rem; height: .5rem; border-radius: 50%; background: currentColor; }
.pill.ok { background: var(--ok-soft); color: var(--ok); } .pill.warn { background: var(--warn-soft); color: var(--warn); } .pill.err { background: var(--err-soft); color: var(--err); }
.field { display: grid; gap: .35rem; margin-bottom: var(--sp-4); }
.field label { font-size: .85rem; font-weight: 500; color: var(--text-strong); }
.input { height: 2.6rem; padding: 0 .85rem; border: 1px solid var(--line-strong); border-radius: var(--r-md); background: var(--panel); color: var(--text-strong); font: inherit; width: 100%; }
.input:focus { outline: 2px solid var(--brand); outline-offset: 0; border-color: var(--brand); }
.err-text { color: var(--err); font-size: .88rem; min-height: 1.3rem; }
.bar { height: .45rem; border-radius: 99px; background: var(--panel-2); overflow: hidden; } .bar > i { display: block; height: 100%; border-radius: 99px; background: var(--brand); } .bar.warn > i { background: var(--warn); } .bar.err > i { background: var(--err); }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th { text-align: left; font-size: .75rem; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); padding: .55rem var(--sp-4); border-bottom: 1px solid var(--line); background: var(--panel-2); }
td { padding: .8rem var(--sp-4); border-bottom: 1px solid var(--line); vertical-align: middle; } tr:last-child td { border-bottom: 0; } tbody tr:hover { background: var(--panel-2); }
.empty { padding: var(--sp-5) var(--sp-4); text-align: center; color: var(--muted); }

/* Auth */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); }
.auth-form { display: flex; flex-direction: column; justify-content: center; padding: var(--sp-6); max-width: 30rem; width: 100%; margin: 0 auto; }
.auth-form h1 { margin-bottom: .4rem; } .auth-form > p { margin-bottom: var(--sp-5); }
.brand { display: flex; align-items: center; gap: var(--sp-3); font-weight: 600; color: var(--text-strong); margin-bottom: 2.5rem; font-size: 1.1rem; }
.brand img { width: 2.2rem; height: 2.2rem; }
.side .brand { margin: 0; height: 56px; padding: 0 var(--sp-5); border-bottom: 1px solid var(--line); }
.auth-side { position: relative; overflow: hidden; display: flex; flex-direction: column; justify-content: flex-end; padding: var(--sp-6); color: #fff; background: #0e1517; border-left: 1px solid var(--line); isolation: isolate; }
.auth-side::before, .auth-side::after { content: ""; position: absolute; z-index: -1; border-radius: 50%; filter: blur(60px); }
.auth-side::before { width: 28rem; height: 28rem; left: -6rem; top: -6rem; background: #2dd4bf; opacity: .22; }
.auth-side::after { width: 32rem; height: 32rem; right: -10rem; bottom: -8rem; background: #0f766e; opacity: .35; }
.auth-side h2 { color: #fff; font-size: 1.6rem; max-width: 26rem; line-height: 1.25; }
.auth-side ul { list-style: none; padding: 0; margin: var(--sp-5) 0 0; display: grid; gap: .6rem; color: #a9b6b8; }
.auth-side li { display: flex; gap: .6rem; align-items: center; } .auth-side svg { color: #2dd4bf; }

/* App scaffold */
.app { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; background: var(--elev); border-right: 1px solid var(--line); }
.side nav { flex: 1; overflow-y: auto; padding: var(--sp-4) var(--sp-3); display: grid; align-content: start; gap: 2px; }
.nav-label { padding: var(--sp-4) var(--sp-3) var(--sp-2); font-size: .7rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); } .nav-label:first-child { padding-top: 0; }
.nav { display: flex; align-items: center; gap: var(--sp-3); height: 2.2rem; padding: 0 var(--sp-3); border-radius: var(--r-md); color: var(--text); font-size: 1rem; white-space: nowrap; }
.nav:hover { background: var(--panel-2); color: var(--text-strong); text-decoration: none; }
.nav[aria-current="page"] { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
button.nav { width: 100%; border: 0; background: none; text-align: left; }
.side-foot { padding: var(--sp-3); border-top: 1px solid var(--line); font-size: .75rem; color: var(--muted); }
.col { min-width: 0; display: flex; flex-direction: column; }
.top { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: var(--sp-3); height: 56px; padding: 0 var(--sp-5); background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(6px); border-bottom: 1px solid var(--line); }
.top .grow { flex: 1; }
.avatar { width: 2.1rem; height: 2.1rem; border-radius: 50%; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); font-weight: 600; font-size: .8rem; }
main { padding: var(--sp-6); display: grid; gap: var(--sp-5); max-width: 82rem; width: 100%; }
main > * { min-width: 0; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--sp-4); flex-wrap: wrap; }
.menu-btn { display: none; }

/* Dashboard */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--sp-4); }
.kpi { padding: var(--sp-4) var(--sp-5); }
.kpi .label { display: flex; align-items: center; gap: .5rem; color: var(--muted); font-size: .82rem; }
.kpi .value { font-size: 1.85rem; font-weight: 600; color: var(--text-strong); letter-spacing: -.02em; margin: .2rem 0 .1rem; }
.kpi .value small { font-size: .9rem; font-weight: 500; color: var(--muted); }
.grid-2 { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: var(--sp-5); align-items: start; }
.grid-2.even { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.status-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr)); gap: var(--sp-3); }
.tile { display: grid; gap: .25rem; padding: var(--sp-3) var(--sp-4); border-left: 3px solid var(--line-strong); }
.tile-head { display: flex; align-items: center; gap: .5rem; color: var(--muted); font-size: .82rem; }
.tile-big { font-size: 1.05rem; color: var(--text-strong); }
.tile-ok { border-left-color: var(--ok); } .tile-warn { border-left-color: var(--warn); } .tile-err { border-left-color: var(--err); }
.attn { display: flex; gap: var(--sp-3); padding: var(--sp-3) var(--sp-4); border-radius: var(--r-md); background: var(--warn-soft); font-size: .88rem; }
.attn svg { color: var(--warn); margin-top: .1rem; } .attn.error { background: var(--err-soft); } .attn.error svg { color: var(--err); } .attn.ok { background: var(--ok-soft); } .attn.ok svg { color: var(--ok); }
.stack { display: grid; gap: var(--sp-3); }
.feed { list-style: none; padding: 0; margin: 0; display: grid; gap: var(--sp-4); }
.feed li { display: grid; grid-template-columns: .6rem 1fr; gap: var(--sp-3); font-size: .88rem; }
.feed .dot { width: .55rem; height: .55rem; border-radius: 50%; background: var(--brand); margin-top: .45rem; } .feed .dot.warning { background: var(--warn); } .feed .dot.error { background: var(--err); }
.chart svg { display: block; width: 100%; height: 9rem; }
.chart .grid { stroke: var(--line); stroke-width: 1; vector-effect: non-scaling-stroke; }
.chart .line { fill: none; stroke: var(--brand); stroke-width: 2; vector-effect: non-scaling-stroke; }
.chart .area { fill: var(--brand-soft); stroke: none; }

/* Feedback */
.toasts { position: fixed; right: var(--sp-5); bottom: var(--sp-5); z-index: 50; display: grid; gap: var(--sp-2); }
.toast { display: flex; align-items: center; gap: var(--sp-3); padding: .7rem var(--sp-4); border-radius: var(--r-md); background: var(--text-strong); color: var(--bg); font-size: .9rem; box-shadow: var(--shadow); animation: toast-in .3s var(--ease); transition: opacity .25s, transform .25s; }
.toast.out { opacity: 0; transform: translateY(8px); } .toast.err svg { color: var(--err); } .toast svg { color: var(--ok); }
dialog { border: 1px solid var(--line-strong); border-radius: var(--r-lg); background: var(--panel); color: var(--text); padding: var(--sp-5); box-shadow: 0 30px 80px -20px rgb(0 0 0 / .5); width: min(30rem, calc(100vw - 2rem)); }
dialog::backdrop { background: rgb(0 0 0 / .6); backdrop-filter: blur(2px); }
dialog .row { margin-top: var(--sp-5); }
.row { display: flex; gap: var(--sp-2); flex-wrap: wrap; align-items: center; } .row.end { justify-content: flex-end; }
.skeleton { display: grid; gap: var(--sp-3); } .sk-line { display: block; height: 5.5rem; border-radius: var(--r-lg); background: linear-gradient(90deg, var(--panel-2) 25%, var(--line) 50%, var(--panel-2) 75%); background-size: 300% 100%; animation: shimmer 1.4s linear infinite; }
.topbar { position: fixed; inset: 0 0 auto 0; height: 3px; z-index: 200; overflow: hidden; opacity: 0; pointer-events: none; transition: opacity .2s; } .topbar.on { opacity: 1; }
.topbar::before { content: ""; position: absolute; inset: 0; width: 40%; background: var(--brand); animation: topbar 1.1s ease-in-out infinite; }
.boot { min-height: 100dvh; display: grid; place-items: center; } .boot-spin { width: 2rem; height: 2rem; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--brand); animation: spin .8s linear infinite; }

/* Motion (explains state changes, < 600 ms) */
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px) scale(.98); } }
@keyframes pop { from { opacity: 0; transform: scale(.96) translateY(-6px); } }
@keyframes grow { from { transform: scaleX(0); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: 0 0; } }
@keyframes topbar { from { transform: translateX(-100%); } to { transform: translateX(260%); } }
main > *, .auth-form > * { animation: rise .5s var(--ease) backwards; }
main > :nth-child(2) { animation-delay: 60ms; } main > :nth-child(3) { animation-delay: 120ms; } main > :nth-child(4) { animation-delay: 180ms; } main > :nth-child(n+5) { animation-delay: 240ms; }
.auth-form > :nth-child(2) { animation-delay: 70ms; } .auth-form > :nth-child(n+3) { animation-delay: 140ms; }
.bar > i { transform-origin: left; animation: grow .9s var(--ease) backwards; animation-delay: 250ms; }
.btn, .nav, .kpi, .card, tbody tr { transition: background-color .15s, color .15s, border-color .15s, transform .15s var(--ease), box-shadow .2s; }
.btn:active { transform: scale(.97); } .kpi:hover { transform: translateY(-2px); } .nav:hover { transform: translateX(2px); }
dialog[open] { animation: pop .22s var(--ease); }
html.theming, html.theming * { transition: background-color .35s, color .35s, border-color .35s !important; }

@media (max-width: 1100px) { .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid-2, .grid-2.even { grid-template-columns: 1fr; } }
@media (max-width: 860px) {
  .auth { grid-template-columns: 1fr; } .auth-side { display: none; }
  .app { grid-template-columns: 1fr; }
  .side { position: fixed; inset: 0 auto 0 0; width: 17rem; z-index: 30; transform: translateX(-100%); transition: transform .2s; }
  .side.open { transform: none; box-shadow: var(--shadow); }
  .menu-btn { display: inline-flex; } .top { padding: 0 var(--sp-4); } main { padding: var(--sp-4); }
}
@media (max-width: 520px) { .kpis { grid-template-columns: 1fr; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; } }

/* Domains */
.scroll-x { overflow-x: auto; }
.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: var(--r-md); overflow: hidden; background: var(--panel); width: fit-content; max-width: 100%; }
.seg button { border: 0; background: none; padding: 0 var(--sp-4); height: 2.15rem; font-size: .88rem; font-weight: 500; color: var(--muted); white-space: nowrap; }
.seg button[aria-pressed="true"] { background: var(--brand-soft); color: var(--brand); }
.rows { display: grid; }
.rows > div { display: flex; align-items: center; gap: var(--sp-2); padding: .45rem 0; border-bottom: 1px solid var(--line); font-size: .92rem; flex-wrap: wrap; }
.rows > div:last-child { border-bottom: 0; }
.rows .mono { color: var(--text-strong); word-break: break-all; }
.rows .muted { min-width: 3.5rem; }
select.input { appearance: auto; }
td .mono { word-break: break-all; }

/* Forms & lists */
.input.inline { width: auto; min-width: 12rem; }
textarea.input { height: auto; min-height: 2.6rem; padding: .6rem .85rem; line-height: 1.45; resize: vertical; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 var(--sp-5); }
.check { display: flex; align-items: center; gap: .5rem; cursor: pointer; margin: .25rem 0 var(--sp-4); }
.w-bar { min-width: 8rem; }
.card > .card-head { margin: 0; }
.card-pad.card-head { margin-bottom: 0; }
@media (max-width: 860px) { .form-grid { grid-template-columns: 1fr; } }

/* Users, tokens, account */
dialog.wide { width: min(40rem, calc(100vw - 2rem)); max-height: 90vh; overflow-y: auto; }
dialog .field { margin-top: var(--sp-3); margin-bottom: var(--sp-2); }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr)); gap: 0 var(--sp-3); margin-top: var(--sp-2); }
.checks .check { margin: .15rem 0; font-size: .88rem; }
details summary { cursor: pointer; color: var(--brand); width: fit-content; margin: var(--sp-2) 0; }
.qr-box { padding: var(--sp-3); width: fit-content; background: #fff; border-radius: var(--r-md); }
.qr-box img { display: block; }
td.wrap, .wrap { word-break: break-word; }

/* Monitoring & logs */
.chart-axis { display: flex; justify-content: space-between; margin-top: .25rem; }
.chart-read { min-height: 1.3rem; margin-top: .25rem; }
.toolbar { display: flex; gap: var(--sp-3); flex-wrap: wrap; }
pre.log { margin: 0; padding: var(--sp-4); border-radius: var(--r-md); background: #0f1417; color: #c4d0d0; font: .78rem/1.55 var(--mono); overflow: auto; }
pre.log.tall { height: 60vh; min-height: 18rem; white-space: pre-wrap; word-break: break-word; }
pre.log .log-line { display: block; }
pre.log .sev-warning { color: #f0b84a; } pre.log .sev-error { color: #ff7b72; }
.card > pre.log { border-radius: var(--r-lg); }

/* Licensor notice */
.made-with { margin-top: .4rem; font-size: .75rem; color: var(--muted); }
.made-with a { color: inherit; text-decoration: underline; }
.made-with.on-dark { margin-top: var(--sp-5); color: #a9b6b8; }

/* Branding, update badge */
.brand img { object-fit: contain; } .brand-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-badge { margin-left: auto; font-size: .7rem; padding: .05rem .45rem; border-radius: 99px; background: var(--brand); color: var(--on-brand); font-weight: 600; }
.color-pick { width: 2.6rem; height: 2.2rem; padding: 0; border: 1px solid var(--line-strong); border-radius: var(--r-sm); background: var(--panel); cursor: pointer; }
.brand-preview { padding: var(--sp-3); border: 1px dashed var(--line-strong); border-radius: var(--r-md); width: fit-content; background: var(--panel-2); margin-bottom: var(--sp-3); }
.brand-preview img { display: block; max-height: 64px; max-width: 240px; object-fit: contain; }
.log-tail { white-space: pre-wrap; font-family: var(--mono); font-size: .78rem; background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--r-md); padding: var(--sp-3); max-height: 22rem; overflow: auto; }
.notes { white-space: pre-wrap; font-size: .85rem; max-height: 14rem; overflow: auto; }
