/* The panel's one stylesheet. The same deep-purple look as the public page and
   the app -- translucent purple cards, a pink glow for what matters, pill
   buttons -- right-to-left throughout. Dark only: it is one product, and the
   app and the site are dark too. No framework: there are a dozen components
   and all of them are below. */

@font-face { font-family: Vazirmatn; font-weight: 400; font-display: swap;
  src: url('/fonts/Vazirmatn-Regular.woff2') format('woff2'); }
@font-face { font-family: Vazirmatn; font-weight: 500; font-display: swap;
  src: url('/fonts/Vazirmatn-Medium.woff2') format('woff2'); }
@font-face { font-family: Vazirmatn; font-weight: 700; font-display: swap;
  src: url('/fonts/Vazirmatn-Bold.woff2') format('woff2'); }

:root {
  --bg: #13052c; --bg-deep: #0e0322;
  /* Surfaces are solid, not translucent: a sticky table header has to hide the
     rows that scroll under it. */
  --surface: #1f0b40; --surface-2: #180734; --surface-3: #2a1253;
  --line: #3a2168; --line-soft: #2c1552; --line-strong: #563394;
  --topbar: rgba(19, 5, 44, .8);
  --fg: #f7f2ff; --muted: #b9a9d8;
  --brand: #f0a0f0; --brand-strong: #ffb3ec; --brand-ink: #ffffff;
  --brand-soft: rgba(232, 121, 249, .15);
  --pink: #ff74da;
  --grad: linear-gradient(135deg, #e63bb0 0%, #b02ee6 52%, #7c3aed 100%);
  --ok: #4ade80;   --ok-soft: rgba(74, 222, 128, .13);
  --warn: #fbbf24; --warn-soft: rgba(251, 191, 36, .13);
  --bad: #fb7185;  --bad-soft: rgba(251, 113, 133, .14);
  --info: #c4b5fd; --info-soft: rgba(167, 139, 250, .17);
  --shadow: 0 14px 34px -14px rgba(4, 0, 18, .7), inset 0 1px 0 rgba(255, 255, 255, .04);
  --radius: 16px; --radius-sm: 11px;
  --font: Vazirmatn, Tahoma, "Segoe UI", system-ui, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, "SF Mono", Menlo, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; background: var(--bg-deep); }
body {
  margin: 0; min-height: 100vh;
  font-family: var(--font); font-size: 15px; line-height: 1.75; color: var(--fg);
  background:
    radial-gradient(900px 520px at 88% -12%, rgba(217, 70, 239, .22), transparent 64%),
    radial-gradient(800px 600px at -6% 30%, rgba(124, 58, 237, .2), transparent 66%),
    linear-gradient(180deg, #1d0842 0%, var(--bg) 42%, var(--bg-deep) 100%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-strong); text-decoration: underline; }
h1 { font-size: 24px; line-height: 1.45; margin: 2px 0 4px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
h2 { font-size: 16.5px; margin: 0; }
h3 { font-size: 15px; margin: 0 0 10px; }
p { margin: 0 0 10px; }
code, pre { font-family: var(--mono); font-size: .92em; }
:focus-visible { outline: 2px solid var(--pink); outline-offset: 2px; }
::selection { background: rgba(232, 121, 249, .35); color: #fff; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.nowrap { white-space: nowrap; }
.strong { font-weight: 700; }

/* ------------------------------------------------------------------ top bar */

.topbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--topbar); border-bottom: 1px solid var(--line-soft);
  -webkit-backdrop-filter: saturate(1.4) blur(14px); backdrop-filter: saturate(1.4) blur(14px);
}
.topbar-in { max-width: 1180px; margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; gap: 14px; }
.brand { display: flex; align-items: center; gap: 9px; color: var(--fg); font-weight: 800; font-size: 17px; white-space: nowrap; }
.brand:hover { color: var(--fg); text-decoration: none; }
.brand svg { filter: drop-shadow(0 0 10px rgba(255, 92, 207, .35)); }
.brand b {
  background: linear-gradient(90deg, #ff8ae0, #c79bff); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.brand small {
  font-weight: 500; font-size: 11.5px; color: var(--muted);
  border: 1px solid var(--line); border-radius: 999px; padding: 0 9px; margin-inline-start: 4px;
  background: rgba(255, 255, 255, .03);
}
.nav { display: flex; gap: 4px; flex: 1; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
.nav a { color: var(--muted); padding: 6px 14px; border-radius: 999px; white-space: nowrap; font-size: 14.5px; transition: color .15s, background-color .15s; }
.nav a:hover { color: var(--fg); background: rgba(255, 255, 255, .06); text-decoration: none; }
.nav a.on {
  color: #fff; font-weight: 700;
  background: linear-gradient(135deg, rgba(230, 59, 176, .34), rgba(124, 58, 237, .34));
  box-shadow: inset 0 0 0 1px rgba(255, 134, 223, .32);
}
.whoami { display: flex; align-items: center; gap: 8px; margin: 0; }
.who { color: var(--muted); font-size: 13px; max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; unicode-bidi: plaintext; }

@media (max-width: 880px) {
  .topbar-in { flex-wrap: wrap; gap: 6px 12px; padding-bottom: 8px; }
  .nav { order: 3; flex-basis: 100%; margin: 0 -6px; }
  .whoami { margin-inline-start: auto; }
  .who { display: none; }
}

/* ------------------------------------------------------------------- layout */

.container { max-width: 1180px; margin: 0 auto; padding: 24px 16px 64px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px 18px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head p { margin: 0; max-width: 760px; }
.back { font-size: 13px; color: var(--muted); }
.back:hover { color: var(--fg); }

.card {
  background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; margin: 0 0 16px; box-shadow: var(--shadow); min-width: 0;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.card-head a.muted:hover { color: var(--fg); }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; margin-bottom: 16px; }
.grid-2 > .card, .stack > .card { margin: 0; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.narrow { max-width: 760px; }
@media (max-width: 920px) { .grid-2 { grid-template-columns: minmax(0, 1fr); } }

/* -------------------------------------------------------------------- stats */

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(165px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat {
  position: relative; overflow: hidden;
  display: flex; flex-direction: column; gap: 2px; padding: 15px 17px; color: var(--fg);
  background: linear-gradient(160deg, rgba(255, 255, 255, .05), rgba(255, 255, 255, 0) 70%), var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  transition: border-color .15s, transform .15s, box-shadow .15s;
}
a.stat:hover {
  color: var(--fg); border-color: rgba(255, 134, 223, .55); text-decoration: none; transform: translateY(-1px);
  box-shadow: 0 0 0 1px rgba(255, 134, 223, .12), 0 14px 30px -14px rgba(230, 59, 176, .5);
}
.stat .num { font-size: 29px; font-weight: 800; line-height: 1.3; }
.stat .num small { font-size: 15px; font-weight: 500; color: var(--muted); }
.stat .label { color: var(--muted); font-size: 13px; }
.num.ok { color: var(--ok); } .num.warn { color: var(--warn); } .num.bad { color: var(--bad); }

/* -------------------------------------------------------------------- forms */

input, select, textarea, button { font: inherit; color: inherit; }
input, select, textarea {
  width: 100%; padding: 9px 13px; color: var(--fg); background: var(--surface-2);
  border: 1px solid var(--line); border-radius: var(--radius-sm); outline: none;
  transition: border-color .15s, box-shadow .15s, background-color .15s;
}
input:hover, select:hover, textarea:hover { border-color: var(--line-strong); }
input:focus, select:focus, textarea:focus { border-color: var(--pink); box-shadow: 0 0 0 3px rgba(255, 116, 218, .18); background: #1c0a3c; }
select option { background: var(--surface); color: var(--fg); }
input[readonly] { opacity: .7; }
input[dir="ltr"], textarea[dir="ltr"] { text-align: left; }
textarea { resize: vertical; min-height: 72px; }
::placeholder { color: var(--muted); opacity: .7; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > span { font-size: 13.5px; font-weight: 500; color: var(--muted); }
.field small { font-size: 12px; color: var(--muted); }
.field em { font-style: normal; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 12px; }
.card > .toolbar:first-child, .stack .toolbar { margin-top: 0; }
.toolbar input, .toolbar select { width: auto; }
.toolbar .grow { flex: 1 1 200px; min-width: 0; }
.toolbar select { min-width: 220px; }
.toolbar .ip { flex: 0 1 170px; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.inline-form { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line-soft); }
.search { margin-bottom: 10px; }

/* ------------------------------------------------------------------ buttons */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 18px; border: 1px solid transparent; border-radius: 999px;
  background: var(--grad); color: var(--brand-ink); font-size: 14.5px; font-weight: 700; line-height: 1.5;
  white-space: nowrap; cursor: pointer; text-decoration: none;
  box-shadow: 0 8px 22px -10px rgba(230, 59, 176, .8), inset 0 1px 0 rgba(255, 255, 255, .22);
  transition: filter .15s, background-color .15s, border-color .15s, box-shadow .15s;
}
.btn:hover { color: var(--brand-ink); filter: brightness(1.1); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn.ghost { background: rgba(255, 255, 255, .05); color: var(--fg); border-color: var(--line-strong); box-shadow: none; }
.btn.ghost:hover { background: rgba(255, 255, 255, .1); border-color: rgba(230, 190, 255, .45); filter: none; }
.btn.danger { background: #e11d48; color: #fff; box-shadow: 0 8px 22px -12px rgba(225, 29, 72, .8); }
.btn.danger.ghost { background: transparent; color: var(--bad); border-color: rgba(251, 113, 133, .35); box-shadow: none; }
.btn.danger.ghost:hover { background: var(--bad-soft); }
.btn.link { background: none; border-color: transparent; color: var(--muted); padding-inline: 8px; box-shadow: none; }
.btn.link:hover { color: var(--fg); }
.btn.sm { padding: 5px 14px; font-size: 13.5px; }
.btn.xs { padding: 2px 11px; font-size: 12.5px; font-weight: 600; }
.btn.block { width: 100%; padding-block: 10px; }
.btn.done { background: var(--ok); color: #052e16; border-color: transparent; box-shadow: none; }

/* ------------------------------------------------------------------- tables */

.table-wrap { overflow-x: auto; margin: 0 -18px; padding: 0 18px; -webkit-overflow-scrolling: touch; }
.table-wrap.tall { max-height: 70vh; overflow-y: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 10px; text-align: right; vertical-align: middle; border-bottom: 1px solid var(--line-soft); }
th { position: sticky; top: 0; z-index: 1; background: var(--surface); color: var(--muted); font-size: 13px; font-weight: 500; white-space: nowrap; }
tbody tr { transition: background-color .12s; }
tbody tr:hover { background: rgba(255, 255, 255, .035); }
tbody tr:last-child td { border-bottom: none; }
td form { margin: 0; }
td .sub { color: var(--muted); font-size: 12.5px; margin-top: 1px; }
tr.revoked td { opacity: .55; }
tr.revoked .code { text-decoration: line-through; }
.row-actions { display: flex; gap: 6px; align-items: center; }
td > .btn.xs { margin-inline-start: 6px; }

/* -------------------------------------------------------------- bits & pieces */

.pill {
  display: inline-flex; align-items: center; padding: 1px 10px; border-radius: 999px;
  font-size: 12.5px; font-weight: 600; line-height: 1.7; white-space: nowrap; vertical-align: middle;
  border: 1px solid transparent;
}
.pill.ok { background: var(--ok-soft); color: var(--ok); border-color: rgba(74, 222, 128, .22); }
.pill.warn { background: var(--warn-soft); color: var(--warn); border-color: rgba(251, 191, 36, .22); }
.pill.bad { background: var(--bad-soft); color: var(--bad); border-color: rgba(251, 113, 133, .25); }
.pill.info { background: var(--info-soft); color: var(--info); border-color: rgba(196, 181, 253, .25); }
.pill.muted { background: rgba(255, 255, 255, .04); color: var(--muted); border-color: var(--line); }
h1 .pill { font-size: 13px; }

.flashes { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.flash {
  padding: 10px 14px; border-radius: var(--radius-sm); font-size: 14.5px; overflow-wrap: anywhere;
  background: var(--surface); border: 1px solid var(--line); border-inline-start: 4px solid var(--muted);
}
.flash.ok { background: linear-gradient(270deg, var(--ok-soft), transparent), var(--surface); border-color: rgba(74, 222, 128, .25); border-inline-start-color: var(--ok); }
.flash.err { background: linear-gradient(270deg, var(--bad-soft), transparent), var(--surface); border-color: rgba(251, 113, 133, .28); border-inline-start-color: var(--bad); }
.flash.info { background: linear-gradient(270deg, var(--info-soft), transparent), var(--surface); border-color: rgba(196, 181, 253, .25); border-inline-start-color: var(--info); }
.card .flash { margin-bottom: 4px; }

.code {
  display: inline-block; direction: ltr; unicode-bidi: isolate; white-space: nowrap;
  padding: 1px 9px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2);
  color: var(--brand-strong); font-family: var(--mono); font-size: 13.5px; letter-spacing: .3px;
}
pre {
  direction: ltr; text-align: left; margin: 0; padding: 12px 14px; overflow-x: auto;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm);
}
pre.message {
  direction: rtl; text-align: right; unicode-bidi: plaintext; white-space: pre-wrap; overflow-wrap: anywhere;
  font-family: var(--font); font-size: 14.5px; line-height: 1.95;
}
.handover { border-color: rgba(255, 134, 223, .35); }
.handover.fresh {
  border-color: var(--pink);
  box-shadow: 0 0 0 3px rgba(255, 116, 218, .14), 0 0 34px -6px rgba(255, 92, 207, .45), var(--shadow);
}

.kv { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 8px 18px; margin: 0; }
.kv dt { color: var(--muted); font-size: 13.5px; }
.kv dd { margin: 0; }

.meter { height: 8px; max-width: 320px; margin-top: 6px; overflow: hidden; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); }
.meter span { display: block; height: 100%; background: linear-gradient(90deg, #22c55e, var(--ok)); border-radius: inherit; }
.meter.high span { background: linear-gradient(90deg, #f59e0b, var(--warn)); }
.meter.full span { background: linear-gradient(90deg, #e11d48, var(--bad)); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 14px 0 8px; }
.chips a { padding: 3px 13px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); font-size: 13.5px; background: rgba(255, 255, 255, .02); }
.chips a:hover { color: var(--fg); border-color: var(--line-strong); text-decoration: none; }
.chips a.on {
  color: #fff; font-weight: 700; border-color: rgba(255, 134, 223, .4);
  background: linear-gradient(135deg, rgba(230, 59, 176, .3), rgba(124, 58, 237, .3));
}
.chips .n { opacity: .75; margin-inline-start: 2px; }

.events { list-style: none; margin: 0; padding: 0; }
.events li { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px; padding: 9px 0; border-bottom: 1px solid var(--line-soft); }
.events li:last-child { border-bottom: none; }
.events .what { font-weight: 600; }
.events .detail { color: var(--muted); font-size: 13px; unicode-bidi: plaintext; overflow-wrap: anywhere; }
.events .meta { color: var(--muted); font-size: 12.5px; white-space: nowrap; margin-inline-start: auto; }

.empty { margin: 6px 0; padding: 22px 12px; text-align: center; color: var(--muted); border: 1px dashed var(--line-strong); border-radius: var(--radius-sm); background: rgba(255, 255, 255, .015); }
.danger-zone { border-color: rgba(251, 113, 133, .3); }
.danger-zone h2 { color: var(--bad); }

/* ------------------------------------------------------------- signed out */

body.auth .container { max-width: 440px; padding-top: 9vh; }
.auth-head { text-align: center; margin-bottom: 18px; }
/* The mark inside the app's power ring. */
.auth-head svg {
  display: block; box-sizing: content-box; padding: 13px; margin: 0 auto; border-radius: 50%;
  background: radial-gradient(circle at 50% 36%, #46197e 0%, #26094a 70%);
  box-shadow: 0 0 0 2px #ff86df, 0 0 0 8px rgba(255, 116, 218, .07), 0 0 34px rgba(255, 92, 207, .5), inset 0 0 18px rgba(255, 92, 207, .25);
}
.auth-head h1 { justify-content: center; font-size: 21px; margin-top: 16px; }
.auth-head p { margin: 0; }
.auth-box .card { padding: 22px; }
.hint { font-size: 14px; }
.hint pre { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 12.5px; }

.error-box { max-width: 520px; margin: 8vh auto 0; padding: 34px 22px; text-align: center; }
.error-box .code-big {
  font-size: 60px; font-weight: 800; line-height: 1.2;
  background: linear-gradient(90deg, #ff8ae0, #b98cff); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.error-box h1 { justify-content: center; }
.error-box .actions { justify-content: center; margin-top: 14px; }

@media (max-width: 560px) {
  .container { padding-top: 16px; }
  .card { padding: 14px; }
  .table-wrap { margin: 0 -14px; padding: 0 14px; }
  .page-head > .btn, .page-head > form, .page-head > form .btn { width: 100%; }
  .kv { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .kv dd { margin-bottom: 8px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
