/* ==========================================================================
   Signet — interface
   Terminal palette only: black, white, grays + blue (focus/info), green (ok),
   red (error), amber (warning). No gradients, no shadows for decoration.
   ========================================================================== */

:root {
  --bg: #000;
  --bg-2: #0a0a0a;
  --surface: #0a0a0a;
  --surface-2: #111;
  --surface-3: #1a1a1a;
  --border: #1f1f1f;
  --border-2: #2e2e2e;
  --border-3: #454545;
  --text: #ededed;
  --text-2: #a1a1a1;
  --text-3: #707070;
  --invert-bg: #ededed;
  --invert-text: #000;
  --blue: #3291ff;
  --blue-solid: #0070f3;
  --blue-soft: rgba(50, 145, 255, .12);
  --green: #3fd47a;
  --green-soft: rgba(63, 212, 122, .1);
  --red: #ff5c5c;
  --red-soft: rgba(255, 92, 92, .1);
  --amber: #f5a524;
  --amber-soft: rgba(245, 165, 36, .1);
  --overlay: rgba(0, 0, 0, .72);
  --radius: 8px;
  --radius-sm: 6px;
  --sans: "Geist", "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "Geist Mono", "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, "Liberation Mono", monospace;
  --sidebar: 240px;
  --topbar: 56px;
  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg: #fff;
  --bg-2: #fafafa;
  --surface: #fff;
  --surface-2: #fafafa;
  --surface-3: #f2f2f2;
  --border: #eaeaea;
  --border-2: #dedede;
  --border-3: #c4c4c4;
  --text: #171717;
  --text-2: #666;
  --text-3: #8f8f8f;
  --invert-bg: #171717;
  --invert-text: #fff;
  --blue: #0068d6;
  --blue-solid: #0070f3;
  --blue-soft: rgba(0, 112, 243, .08);
  --green: #0f8a43;
  --green-soft: rgba(15, 138, 67, .08);
  --red: #d32f2f;
  --red-soft: rgba(211, 47, 47, .07);
  --amber: #a35200;
  --amber-soft: rgba(245, 165, 36, .12);
  --overlay: rgba(255, 255, 255, .75);
  color-scheme: light;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "tnum" 1;
}
a { color: var(--text); text-decoration: underline; text-decoration-color: var(--border-3); text-underline-offset: 3px; }
a:hover { text-decoration-color: var(--text); }
h1, h2, h3, h4 { margin: 0 0 .5rem; font-weight: 600; letter-spacing: -0.02em; line-height: 1.25; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1rem; }
h3 { font-size: .9rem; }
p { margin: 0 0 .75rem; }
code, pre, .mono { font-family: var(--mono); font-size: .86em; letter-spacing: 0; }
code { background: var(--surface-3); border: 1px solid var(--border); padding: .05rem .35rem; border-radius: 4px; }
small, .muted { color: var(--text-2); }
.dim { color: var(--text-3); }
hr { border: 0; border-top: 1px solid var(--border); margin: 1.25rem 0; }
::selection { background: var(--blue-solid); color: #fff; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; border-radius: 4px; }
.icon { width: 16px; height: 16px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; vertical-align: -3px; }
.icon-sm { width: 14px; height: 14px; }
.icon-lg { width: 20px; height: 20px; }
.skip { position: absolute; left: -999px; top: 8px; z-index: 200; background: var(--invert-bg); color: var(--invert-text); padding: .5rem .8rem; border-radius: var(--radius-sm); }
.skip:focus { left: 8px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Brand ---------- */
.brand { display: flex; align-items: center; gap: .6rem; text-decoration: none; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand-mark { width: 26px; height: 26px; flex: none; display: block; }
.brand-word { font-family: var(--mono); font-weight: 700; font-size: 1rem; letter-spacing: -0.03em; display: inline-flex; align-items: center; gap: 3px; }
.brand-word::after { content: ""; width: .5em; height: 1.05em; background: var(--blue-solid); display: inline-block; animation: blink 1.1s steps(1) infinite; }
.brand-site { font-family: var(--mono); font-size: .7rem; color: var(--text-3); display: block; margin-top: -2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 150px; }
@keyframes blink { 50% { opacity: 0; } }

/* ---------- Layout ---------- */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar); background: var(--bg); border-right: 1px solid var(--border);
  position: fixed; inset: 0 auto 0 0; display: flex; flex-direction: column; z-index: 40;
  transition: transform .2s ease;
}
.sidebar-head { height: var(--topbar); display: flex; align-items: center; padding: 0 1rem; border-bottom: 1px solid var(--border); }
.nav { padding: .5rem; overflow-y: auto; flex: 1; }
.nav-section { font-family: var(--mono); font-size: .68rem; text-transform: lowercase; color: var(--text-3); padding: 1rem .6rem .35rem; letter-spacing: 0; }
.nav-section::before { content: "// "; }
.nav a { display: flex; align-items: center; gap: .6rem; padding: .42rem .6rem; border-radius: var(--radius-sm); color: var(--text-2); text-decoration: none; font-size: .86rem; position: relative; }
.nav a:hover { background: var(--surface-3); color: var(--text); }
.nav a.active { background: var(--surface-3); color: var(--text); font-weight: 500; }
.nav a.active::before { content: ""; position: absolute; left: -.5rem; top: 8px; bottom: 8px; width: 2px; background: var(--text); border-radius: 2px; }
.nav .count { margin-left: auto; font-family: var(--mono); font-size: .68rem; color: var(--amber); border: 1px solid var(--amber); padding: 0 .35rem; border-radius: 4px; }
.sidebar-foot { border-top: 1px solid var(--border); padding: .7rem .8rem; display: flex; align-items: center; gap: .6rem; }
.avatar { width: 30px; height: 30px; border-radius: 50%; border: 1px solid var(--border-2); background: var(--surface-3); display: grid; place-items: center; font-family: var(--mono); font-weight: 600; font-size: .8rem; flex: none; }
.who { min-width: 0; flex: 1; line-height: 1.3; }
.who strong { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: .84rem; font-weight: 500; }
.who small { font-family: var(--mono); font-size: .7rem; color: var(--text-3); }
.main { flex: 1; margin-left: var(--sidebar); min-width: 0; }
.topbar { position: sticky; top: 0; z-index: 30; height: var(--topbar); background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: saturate(180%) blur(8px); border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: .75rem; padding: 0 1.5rem; }
.crumbs { display: flex; align-items: center; gap: .45rem; font-size: .86rem; min-width: 0; }
.crumbs .sep { color: var(--border-3); }
.crumbs .root { color: var(--text-2); font-family: var(--mono); font-size: .8rem; }
.crumbs strong { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .spacer { flex: 1; }
.topbar .role { font-family: var(--mono); font-size: .72rem; color: var(--text-2); border: 1px solid var(--border-2); padding: .1rem .45rem; border-radius: 999px; }
.topbar .menu-toggle { display: none; }
.content { padding: 2rem 1.5rem 4rem; max-width: 1280px; margin: 0 auto; }
.backdrop { display: none; }

@media (max-width: 960px) {
  .sidebar { transform: translateX(-100%); }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .backdrop { display: block; position: fixed; inset: 0; background: var(--overlay); z-index: 35; }
  .main { margin-left: 0; }
  .topbar .menu-toggle { display: inline-flex; }
  .topbar { padding: 0 .75rem; }
  .content { padding: 1.25rem 1rem 3rem; }
}

/* ---------- Page header ---------- */
.page-head { display: flex; align-items: flex-end; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.page-head h1 { margin: 0; }
.page-head .actions { margin-left: auto; display: flex; gap: .5rem; flex-wrap: wrap; }
.eyebrow { font-family: var(--mono); font-size: .72rem; color: var(--text-3); margin-bottom: .2rem; }
.eyebrow::before { content: "$ "; color: var(--blue); }

/* ---------- Grid & cards ---------- */
.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-stats { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 0; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.grid-stats > .card { border: 0; border-radius: 0; margin: 0 !important; box-shadow: inset -1px -1px 0 var(--border); }
@media (max-width: 1100px) { .grid-4, .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 720px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; min-width: 0; }
.card + .card { margin-top: 1rem; }
.grid > .card + .card { margin-top: 0; }
a.card { text-decoration: none; color: inherit; transition: border-color .15s; }
a.card:hover { border-color: var(--border-3); }
.card-head { display: flex; align-items: center; gap: .6rem; margin-bottom: 1rem; flex-wrap: wrap; }
.card-head h2, .card-head h3 { margin: 0; display: flex; align-items: center; gap: .5rem; font-size: .92rem; }
.card-head h2 .icon, .card-head h3 .icon { color: var(--text-3); }
.card-head .actions { margin-left: auto; display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.section { margin-top: 1.25rem; }
.stack > * + * { margin-top: .75rem; }

/* KPI tiles */
.stat { display: flex; flex-direction: column; gap: .35rem; padding: 1rem 1.1rem; }
.stat .label { font-family: var(--mono); font-size: .72rem; color: var(--text-2); display: flex; align-items: center; gap: .45rem; text-transform: lowercase; }
.stat .value { font-size: 1.75rem; font-weight: 600; letter-spacing: -0.04em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat .icon-wrap { display: inline-flex; color: var(--text-3); }
.stat .icon-wrap .icon { width: 14px; height: 14px; }
.stat.success .value { color: var(--green); }
.stat.danger .value { color: var(--red); }
.stat.warning .value { color: var(--amber); }
.stat.info .value { color: var(--blue); }

.kv { display: grid; grid-template-columns: minmax(110px, 38%) 1fr; gap: 0; margin: 0; }
.kv dt, .kv dd { padding: .5rem 0; border-bottom: 1px dashed var(--border); margin: 0; }
.kv dt { color: var(--text-2); font-size: .82rem; font-family: var(--mono); }
.kv dd { word-break: break-word; }
.kv dt:last-of-type, .kv dd:last-of-type { border-bottom: 0; }
@media (max-width: 480px) { .kv { grid-template-columns: 1fr; } .kv dt { border-bottom: 0; padding-bottom: 0; } }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  height: 34px; padding: 0 .85rem; border-radius: var(--radius-sm);
  border: 1px solid var(--border-2); background: var(--bg); color: var(--text);
  font: inherit; font-size: .84rem; font-weight: 500; cursor: pointer; white-space: nowrap;
  text-decoration: none; transition: background .12s, border-color .12s, color .12s;
}
.btn:hover { background: var(--surface-3); border-color: var(--border-3); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--invert-bg); color: var(--invert-text); border-color: var(--invert-bg); }
.btn-primary:hover { background: var(--text-2); border-color: var(--text-2); color: var(--invert-text); }
.btn-danger { color: var(--red); border-color: color-mix(in srgb, var(--red) 45%, transparent); }
.btn-danger:hover { background: var(--red); border-color: var(--red); color: #fff; }
.btn-success { color: var(--green); border-color: color-mix(in srgb, var(--green) 45%, transparent); }
.btn-success:hover { background: var(--green-soft); border-color: var(--green); }
.btn-warning { color: var(--amber); border-color: color-mix(in srgb, var(--amber) 45%, transparent); }
.btn-warning:hover { background: var(--amber-soft); border-color: var(--amber); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-3); border-color: transparent; color: var(--text); }
.btn-sm { height: 28px; padding: 0 .6rem; font-size: .78rem; }
.btn-block { width: 100%; }
.btn-icon { width: 34px; padding: 0; }
.btn-sm.btn-icon { width: 28px; }
.inline-form { display: inline; margin: 0; }
.btn-row { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.btn-row.center { justify-content: center; }
kbd { font-family: var(--mono); font-size: .7rem; border: 1px solid var(--border-2); border-bottom-width: 2px; border-radius: 4px; padding: 0 .3rem; color: var(--text-2); }

/* ---------- Forms ---------- */
.form-grid { display: grid; gap: 1rem; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 720px) { .form-grid { grid-template-columns: 1fr; } }
.field { display: flex; flex-direction: column; gap: .35rem; margin-bottom: 1rem; }
.form-grid .field { margin-bottom: 0; }
label { font-size: .8rem; font-weight: 500; color: var(--text); }
.hint { font-size: .76rem; color: var(--text-3); font-weight: 400; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=url],
input[type=search], input[type=datetime-local], input[type=date], select, textarea {
  width: 100%; height: 36px; padding: 0 .7rem; border-radius: var(--radius-sm);
  border: 1px solid var(--border-2); background: var(--bg); color: var(--text);
  font: inherit; font-size: .86rem; transition: border-color .12s, box-shadow .12s;
}
textarea { height: auto; min-height: 88px; padding: .55rem .7rem; resize: vertical; }
select { appearance: none; padding-right: 2rem; background-image: linear-gradient(45deg, transparent 50%, var(--text-2) 50%), linear-gradient(135deg, var(--text-2) 50%, transparent 50%); background-position: calc(100% - 15px) 15px, calc(100% - 10px) 15px; background-size: 5px 5px; background-repeat: no-repeat; }
input::placeholder, textarea::placeholder { color: var(--text-3); }
input:hover, select:hover, textarea:hover { border-color: var(--border-3); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--text-2); box-shadow: 0 0 0 3px var(--blue-soft); }
input[type=file] { color: var(--text-2); font: inherit; font-size: .82rem; }
input[type=file]::file-selector-button { font: inherit; font-size: .8rem; border: 1px solid var(--border-2); background: var(--bg); color: var(--text); border-radius: var(--radius-sm); padding: .3rem .7rem; margin-right: .6rem; cursor: pointer; }
input.mono, .mono input { font-family: var(--mono); letter-spacing: .02em; }
.check { display: flex; align-items: flex-start; gap: .55rem; font-weight: 400; font-size: .85rem; cursor: pointer; }
.check input { margin: .15rem 0 0; accent-color: var(--text); width: 15px; height: 15px; flex: none; }
.check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: .65rem 1rem; }
.filters { display: flex; flex-wrap: wrap; gap: .6rem; align-items: flex-end; margin-bottom: 1rem; }
.filters .field { margin: 0; min-width: 140px; }
.filters .grow { flex: 1; min-width: 200px; }
.grow { flex: 1; min-width: 0; }
@media (max-width: 600px) { .filters .field, .filters .grow { min-width: 100%; } .filters .btn { flex: 1; } }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: .84rem; }
th, td { text-align: left; padding: .6rem .85rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-family: var(--mono); font-size: .7rem; text-transform: lowercase; color: var(--text-3); font-weight: 400; background: var(--bg-2); white-space: nowrap; position: sticky; top: 0; }
tr:last-child td { border-bottom: 0; }
tbody tr { transition: background .1s; }
tbody tr:hover { background: var(--surface-2); }
td.actions { text-align: right; white-space: nowrap; }
td.actions > * + * { margin-left: .25rem; }
td.nowrap, th.nowrap { white-space: nowrap; }
td.mono, td .mono { font-size: .8rem; }
.empty { text-align: center; color: var(--text-3); padding: 2.5rem 1rem; font-family: var(--mono); font-size: .8rem; }
.empty::before { content: "∅  "; color: var(--border-3); }
.card.empty { padding: 3rem 1rem; }

/* ---------- Status badges: dot + mono label ---------- */
.badge { display: inline-flex; align-items: center; gap: .35rem; font-family: var(--mono); font-size: .72rem; line-height: 1.6; text-transform: lowercase; white-space: nowrap; padding: 0 .45rem; border-radius: 4px; border: 1px solid var(--border-2); color: var(--text-2); }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.badge-success { color: var(--green); border-color: color-mix(in srgb, var(--green) 35%, transparent); background: var(--green-soft); }
.badge-warning { color: var(--amber); border-color: color-mix(in srgb, var(--amber) 35%, transparent); background: var(--amber-soft); }
.badge-danger { color: var(--red); border-color: color-mix(in srgb, var(--red) 35%, transparent); background: var(--red-soft); }
.badge-info { color: var(--blue); border-color: color-mix(in srgb, var(--blue) 35%, transparent); background: var(--blue-soft); }
.badge-muted { color: var(--text-2); }
.badge-primary { color: var(--text); background: var(--surface-3); }
.badge-primary::before, .badge-muted::before { display: none; }

/* ---------- Alerts & toasts ---------- */
.alert { padding: .75rem .9rem; border-radius: var(--radius-sm); border: 1px solid var(--border-2); background: var(--surface-2); margin-bottom: 1rem; display: flex; gap: .6rem; align-items: flex-start; font-size: .86rem; }
.alert > .icon { margin-top: 2px; }
.alert > div { min-width: 0; flex: 1; }
.alert-success { border-color: color-mix(in srgb, var(--green) 40%, transparent); background: var(--green-soft); }
.alert-success > .icon { color: var(--green); }
.alert-error, .alert-danger { border-color: color-mix(in srgb, var(--red) 40%, transparent); background: var(--red-soft); }
.alert-error > .icon, .alert-danger > .icon { color: var(--red); }
.alert-warning { border-color: color-mix(in srgb, var(--amber) 40%, transparent); background: var(--amber-soft); }
.alert-warning > .icon { color: var(--amber); }
.alert-info { border-color: color-mix(in srgb, var(--blue) 40%, transparent); background: var(--blue-soft); }
.alert-info > .icon { color: var(--blue); }

.toasts { position: fixed; right: 1rem; bottom: 1rem; display: flex; flex-direction: column; gap: .5rem; z-index: 100; width: min(380px, calc(100vw - 2rem)); }
.toast { background: var(--bg); border: 1px solid var(--border-2); border-radius: var(--radius); padding: .7rem .8rem; display: flex; gap: .6rem; align-items: flex-start; font-size: .84rem; animation: toast-in .18s ease-out; box-shadow: 0 8px 30px rgba(0, 0, 0, .25); }
.toast::before { content: "i"; font-family: var(--mono); font-size: .72rem; font-weight: 700; width: 18px; height: 18px; border-radius: 50%; display: grid; place-items: center; flex: none; background: var(--blue-solid); color: #fff; margin-top: 1px; }
.toast.success::before { content: "✓"; background: var(--green); color: #000; }
.toast.error::before { content: "!"; background: var(--red); color: #fff; }
.toast.warning::before { content: "!"; background: var(--amber); color: #000; }
.toast .close { margin-left: auto; background: none; border: 0; color: var(--text-3); cursor: pointer; font-size: 1rem; line-height: 1; padding: 0 .2rem; }
.toast .close:hover { color: var(--text); }
.toast.hide { opacity: 0; transform: translateY(6px); transition: all .2s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- Modals ---------- */
.modal { position: fixed; inset: 0; z-index: 90; display: none; align-items: center; justify-content: center; padding: 1rem; background: var(--overlay); backdrop-filter: blur(2px); }
.modal.open { display: flex; animation: fade .12s ease-out; }
.modal-box { background: var(--bg); border: 1px solid var(--border-2); border-radius: 12px; width: 100%; max-width: 500px; max-height: calc(100vh - 2rem); overflow-y: auto; box-shadow: 0 30px 60px rgba(0, 0, 0, .4); }
.modal-box.wide { max-width: 760px; }
.modal-head { display: flex; align-items: center; padding: .9rem 1.1rem; border-bottom: 1px solid var(--border); }
.modal-head h3 { margin: 0; font-size: .95rem; }
.modal-head .close { margin-left: auto; }
.modal-body { padding: 1.1rem; }
.modal-foot { padding: .8rem 1.1rem; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: .5rem; background: var(--bg-2); border-radius: 0 0 12px 12px; }
@media (max-width: 600px) {
  .modal { align-items: flex-end; padding: 0; }
  .modal-box { border-radius: 12px 12px 0 0; max-height: 92vh; }
  .modal-foot { border-radius: 0; }
  .modal-foot .btn { flex: 1; }
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* ---------- Misc components ---------- */
.pager { display: flex; gap: .35rem; align-items: center; justify-content: flex-end; margin-top: 1rem; flex-wrap: wrap; }
.pager .info { margin-right: auto; color: var(--text-3); font-family: var(--mono); font-size: .74rem; }
.keybox { font-family: var(--mono); background: var(--bg-2); border: 1px solid var(--border-2); border-radius: var(--radius-sm); padding: .9rem 1rem; white-space: pre-wrap; word-break: break-all; max-height: 420px; overflow-y: auto; font-size: .85rem; line-height: 1.8; margin: 0; counter-reset: line; }
.secret { font-family: var(--mono); background: var(--bg-2); border: 1px dashed var(--border-3); border-radius: var(--radius-sm); padding: .55rem .75rem; word-break: break-all; display: block; font-size: .8rem; }
.game-icon { width: 36px; height: 36px; border-radius: var(--radius-sm); object-fit: cover; background: var(--surface-3); border: 1px solid var(--border-2); display: grid; place-items: center; color: var(--text); font-family: var(--mono); font-weight: 700; flex: none; font-size: .85rem; }
.game-icon.lg { width: 52px; height: 52px; font-size: 1.15rem; }
.game-card { display: flex; flex-direction: column; gap: .9rem; }
.game-card .top { display: flex; gap: .75rem; align-items: center; }
.game-card h3 { margin: 0 0 .2rem; font-size: .95rem; }
.game-card .meta { display: grid; grid-template-columns: repeat(4, 1fr); border-top: 1px solid var(--border); padding-top: .8rem; color: var(--text-3); font-family: var(--mono); font-size: .7rem; }
.game-card .meta strong { color: var(--text); display: block; font-family: var(--sans); font-size: 1.05rem; font-weight: 600; }
.chart { width: 100%; height: 190px; display: block; }
.chart .bar-ok { fill: var(--text); }
.chart .bar-fail { fill: var(--red); }
.chart .axis { fill: var(--text-3); font-size: 10px; font-family: var(--mono); }
.chart .grid-line { stroke: var(--border); stroke-width: 1; stroke-dasharray: 2 3; }
.legend { display: flex; gap: 1rem; font-family: var(--mono); font-size: .72rem; color: var(--text-2); }
.legend span::before { content: ""; display: inline-block; width: 8px; height: 8px; margin-right: .35rem; background: var(--text); }
.legend span.fail::before { background: var(--red); }
.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--border); margin-bottom: 1.25rem; overflow-x: auto; }
.tabs a { padding: .6rem .8rem; color: var(--text-2); border-bottom: 2px solid transparent; white-space: nowrap; text-decoration: none; font-size: .86rem; margin-bottom: -1px; }
.tabs a.active { color: var(--text); border-bottom-color: var(--text); }
.tabs a:hover { color: var(--text); }
.flex { display: flex; gap: .7rem; align-items: center; flex-wrap: wrap; }
.right { margin-left: auto; }
.text-right { text-align: right; }
.danger-zone { border-color: color-mix(in srgb, var(--red) 35%, transparent); }
.danger-zone h2 { color: var(--red); }
.truncate { max-width: 280px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: inline-block; vertical-align: bottom; }
.hidden { display: none !important; }
.prompt { font-family: var(--mono); color: var(--text-2); }
.prompt::before { content: "› "; color: var(--blue); }

/* ---------- Auth & installer ---------- */
.auth-wrap { min-height: 100vh; display: grid; grid-template-rows: 1fr auto; padding: 1.5rem; background-color: var(--bg); background-image: radial-gradient(var(--border) 1px, transparent 1px); background-size: 22px 22px; }
.auth-center { display: grid; place-items: center; }
.auth-card { width: 100%; max-width: 400px; background: var(--bg); border: 1px solid var(--border-2); border-radius: 12px; padding: 2rem; }
.auth-card.wide { max-width: 720px; }
.auth-card .brand { justify-content: center; margin-bottom: 1.5rem; }
.auth-card .brand-mark { width: 34px; height: 34px; }
.auth-card .brand-word { font-size: 1.25rem; }
.auth-card h1 { text-align: center; font-size: 1.25rem; }
.auth-card .sub { text-align: center; color: var(--text-2); margin-bottom: 1.5rem; font-size: .88rem; }
.auth-links { display: flex; justify-content: space-between; gap: 1rem; margin-top: 1.25rem; font-size: .82rem; flex-wrap: wrap; }
.auth-links a { color: var(--text-2); }
.auth-foot { text-align: center; font-family: var(--mono); font-size: .7rem; color: var(--text-3); padding-top: 1.5rem; }
.auth-foot .ok { color: var(--green); }
@media (max-width: 480px) { .auth-wrap { padding: 0; } .auth-card { border: 0; border-radius: 0; min-height: 100%; padding: 2rem 1.25rem; } }
.steps { display: flex; gap: 0; margin-bottom: 1.75rem; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.steps span { flex: 1; font-family: var(--mono); font-size: .68rem; padding: .4rem .3rem; text-align: center; color: var(--text-3); border-right: 1px solid var(--border); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.steps span:last-child { border-right: 0; }
.steps span.on { background: var(--invert-bg); color: var(--invert-text); }
.steps span.done { color: var(--green); }
@media (max-width: 600px) { .steps span { font-size: 0; } .steps span::first-letter { font-size: .7rem; } }
.req-list { list-style: none; padding: 0; margin: 0 0 1.25rem; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.req-list li { display: flex; gap: .6rem; padding: .55rem .8rem; border-bottom: 1px solid var(--border); align-items: flex-start; font-size: .85rem; }
.req-list li:last-child { border-bottom: 0; }
.req-list .ok { color: var(--green); }
.req-list .bad { color: var(--red); }
.req-list .warn { color: var(--amber); }

/* ---------- Theme toggle ---------- */
.theme-toggle .sun { display: none; }
:root[data-theme="light"] .theme-toggle .sun { display: inline; }
:root[data-theme="light"] .theme-toggle .moon { display: none; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
@media print {
  .sidebar, .topbar, .toasts, .btn { display: none !important; }
  .main { margin: 0; }
}

/* Brand mark colours (inline SVG) */
.bm-seal { fill: var(--bg); stroke: var(--text); }
.bm-ink { stroke: var(--text); }
.bm-fill { fill: var(--text); }

/* Responsive tables: rows become labeled cards on small screens (labels injected by app.js). */
@media (max-width: 640px) {
  table.stackable thead { display: none; }
  table.stackable, table.stackable tbody, table.stackable tr { display: block; width: 100%; }
  table.stackable tr { border-bottom: 1px solid var(--border); padding: .45rem 0; }
  table.stackable tr:last-child { border-bottom: 0; }
  table.stackable td { display: flex; justify-content: space-between; align-items: center; gap: 1rem; border: 0; padding: .3rem .85rem; text-align: right; min-height: 30px; }
  table.stackable td::before { content: attr(data-label); font-family: var(--mono); font-size: .7rem; color: var(--text-3); text-align: left; flex: none; }
  table.stackable td[data-label=""]::before { display: none; }
  table.stackable td.actions { justify-content: flex-end; flex-wrap: wrap; }
  table.stackable td.empty { display: block; text-align: center; }
  table.stackable td.empty::before { content: "∅  "; font-family: var(--mono); color: var(--border-3); }
  table.stackable .truncate { max-width: 60vw; }
}
@media (max-width: 600px) {
  .page-head > form, .page-head > .filters { flex: 1 1 100%; width: 100%; }
  .page-head .actions { margin-left: 0; width: 100%; }
  .page-head .actions .btn { flex: 1; }
}

/* ==========================================================================
   v2 — Depth, motion & cinematic components
   ========================================================================== */

:root {
  --ease-out: cubic-bezier(.2, .8, .2, 1);
  --ease-spring: cubic-bezier(.34, 1.56, .64, 1);
  --ease-cinema: cubic-bezier(.22, 1, .36, 1);
  --dur-1: .12s;
  --dur-2: .22s;
  --dur-3: .38s;
  --dur-4: .6s;
  --elev-0: inset 0 1px 0 rgba(255, 255, 255, .03);
  --elev-1: inset 0 1px 0 rgba(255, 255, 255, .04), 0 1px 2px rgba(0, 0, 0, .5), 0 4px 12px -6px rgba(0, 0, 0, .6);
  --elev-2: inset 0 1px 0 rgba(255, 255, 255, .06), 0 2px 4px rgba(0, 0, 0, .5), 0 18px 40px -14px rgba(0, 0, 0, .8);
  --elev-3: inset 0 1px 0 rgba(255, 255, 255, .08), 0 30px 80px -20px rgba(0, 0, 0, .9), 0 0 0 1px rgba(255, 255, 255, .06);
  --glass: rgba(10, 10, 10, .6);
  --spot: rgba(255, 255, 255, .06);
  --vignette: radial-gradient(1200px 600px at 50% -200px, rgba(255, 255, 255, .045), transparent 70%);
}
:root[data-theme="light"] {
  --elev-0: inset 0 1px 0 rgba(255, 255, 255, .8);
  --elev-1: 0 1px 2px rgba(0, 0, 0, .05), 0 4px 12px -6px rgba(0, 0, 0, .08);
  --elev-2: 0 2px 4px rgba(0, 0, 0, .05), 0 18px 40px -14px rgba(0, 0, 0, .18);
  --elev-3: 0 30px 80px -20px rgba(0, 0, 0, .25), 0 0 0 1px rgba(0, 0, 0, .06);
  --glass: rgba(255, 255, 255, .7);
  --spot: rgba(0, 0, 0, .035);
  --vignette: radial-gradient(1200px 600px at 50% -200px, rgba(0, 0, 0, .035), transparent 70%);
}

/* ---------- Depth: layered surfaces ---------- */
body { background-image: var(--vignette); background-repeat: no-repeat; background-attachment: fixed; }
.sidebar { background: color-mix(in srgb, var(--bg) 92%, var(--text) 1.5%); box-shadow: 1px 0 0 var(--border), 8px 0 30px -20px rgba(0, 0, 0, .8); border-right: 0; }
.topbar { background: var(--glass); box-shadow: 0 1px 0 var(--border), 0 10px 30px -24px rgba(0, 0, 0, .9); border-bottom: 0; }
.card { box-shadow: var(--elev-1); position: relative; isolation: isolate; transition: border-color var(--dur-2), box-shadow var(--dur-3) var(--ease-out), transform var(--dur-3) var(--ease-out); }
.card:hover { border-color: var(--border-2); }
.table-wrap { box-shadow: var(--elev-1); }
.grid-stats { box-shadow: var(--elev-1); }
.modal-box { box-shadow: var(--elev-3); }
.btn { box-shadow: var(--elev-0); }
.btn-primary { box-shadow: inset 0 1px 0 rgba(255, 255, 255, .25), 0 1px 2px rgba(0, 0, 0, .4); }
.btn-lg { height: 42px; padding: 0 1.25rem; font-size: .92rem; border-radius: 8px; }
.btn-glass { background: rgba(127, 127, 127, .14); border-color: rgba(255, 255, 255, .14); color: var(--text); backdrop-filter: blur(10px); }
.btn-glass:hover { background: rgba(127, 127, 127, .26); border-color: rgba(255, 255, 255, .24); }
.btn-glass.btn-warning { color: var(--amber); }
.btn-glass.btn-success { color: var(--green); }
.btn:active { transform: scale(.97); }
.label-like { font-size: .8rem; font-weight: 500; display: block; margin-bottom: .35rem; }
.tag { font-size: .7rem; color: var(--text-2); border: 1px solid var(--border-2); border-radius: 4px; padding: 0 .4rem; line-height: 1.6; }
.back-link { display: inline-flex; align-items: center; gap: .35rem; font-size: .82rem; color: var(--text-2); text-decoration: none; margin-bottom: 1rem; transition: color var(--dur-1), gap var(--dur-2) var(--ease-out); }
.back-link:hover { color: var(--text); gap: .55rem; }

/* Cursor spotlight on cards and tiles (position set by app.js) */
[data-spotlight]::after, .card::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; z-index: -1;
  background: radial-gradient(420px circle at var(--mx, 50%) var(--my, -200%), var(--spot), transparent 60%);
  opacity: 0; transition: opacity var(--dur-3);
}
[data-spotlight]:hover::after, .card:hover::after { opacity: 1; }

/* ---------- Motion: page transitions (cross-document View Transitions) ---------- */
@view-transition { navigation: auto; }
::view-transition-old(root) { animation: vt-out .22s var(--ease-out) both; }
::view-transition-new(root) { animation: vt-in .38s var(--ease-cinema) both; }
@keyframes vt-out { to { opacity: 0; transform: scale(.985); filter: blur(2px); } }
@keyframes vt-in { from { opacity: 0; transform: scale(1.015); } }
.sidebar { view-transition-name: sidebar; }
.topbar { view-transition-name: topbar; }
::view-transition-old(sidebar), ::view-transition-new(sidebar), ::view-transition-old(topbar), ::view-transition-new(topbar) { animation: none; }

/* Content entrance: staggered fade-up of top-level blocks */
.content > :not(.reveal):not(.modal):not(script) { animation: rise var(--dur-4) var(--ease-cinema) both; }
.content > :nth-child(2) { animation-delay: .04s; }
.content > :nth-child(3) { animation-delay: .08s; }
.content > :nth-child(4) { animation-delay: .12s; }
.content > :nth-child(5) { animation-delay: .16s; }
.content > :nth-child(n+6) { animation-delay: .2s; }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

/* Scroll reveal (JS adds .is-visible; without JS everything stays visible) */
html.js .reveal { opacity: 0; transform: translateY(18px) scale(.985); }
html.js .reveal.is-visible { opacity: 1; transform: none; transition: opacity var(--dur-4) var(--ease-cinema), transform var(--dur-4) var(--ease-cinema); transition-delay: calc(var(--stagger, 0) * 55ms); }

/* ---------- Hero ---------- */
.hero { display: flex; align-items: flex-end; justify-content: space-between; gap: 1.5rem; flex-wrap: wrap; padding: 2rem; margin-bottom: 1.75rem; border: 1px solid var(--border); border-radius: 14px; background:
  radial-gradient(600px 220px at 85% 0%, rgba(127, 127, 127, .12), transparent 70%),
  linear-gradient(180deg, var(--surface-2), var(--bg)); box-shadow: var(--elev-2); position: relative; overflow: hidden; }
.hero::before { content: ""; position: absolute; inset: 0; background-image: radial-gradient(var(--border) 1px, transparent 1px); background-size: 18px 18px; mask-image: linear-gradient(90deg, transparent 30%, #000); opacity: .7; pointer-events: none; }
.hero > * { position: relative; }
.hero h1 { font-size: 2rem; letter-spacing: -0.04em; margin-bottom: .35rem; }
.hero-copy { max-width: 620px; }
.hero-stats { display: flex; gap: 2rem; margin-top: 1.25rem; flex-wrap: wrap; }
.hero-stats div { display: flex; flex-direction: column; }
.hero-stats strong { font-size: 1.5rem; font-weight: 600; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.hero-stats strong.ok { color: var(--green); }
.hero-stats span { font-family: var(--mono); font-size: .7rem; color: var(--text-3); }
@media (max-width: 600px) { .hero { padding: 1.25rem; } .hero h1 { font-size: 1.5rem; } .hero-actions, .hero-actions .btn { width: 100%; } }

/* ---------- Netflix tiles ---------- */
.tile-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 1.1rem; }
.tile {
  position: relative; display: flex; flex-direction: column; border-radius: 12px; overflow: hidden; text-decoration: none; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--elev-1); isolation: isolate;
  transform-origin: center 60%; transition: transform var(--dur-3) var(--ease-cinema), box-shadow var(--dur-3) var(--ease-cinema), border-color var(--dur-2);
  will-change: transform;
}
.tile:hover, .tile:focus-visible { transform: translateY(-6px) scale(1.045); box-shadow: var(--elev-3); border-color: var(--border-3); z-index: 5; text-decoration: none; }
.tile-art { position: relative; aspect-ratio: 16 / 9; display: grid; place-items: center; overflow: hidden; background: linear-gradient(160deg, var(--surface-3), var(--bg)); border-bottom: 1px solid var(--border); }
.tile-backdrop { position: absolute; inset: -20%; width: 140%; height: 140%; object-fit: cover; filter: blur(28px) saturate(1.2) brightness(.55); transform: scale(1.1); transition: transform 1.2s var(--ease-cinema), filter var(--dur-4); }
.tile:hover .tile-backdrop { transform: scale(1.25); filter: blur(22px) saturate(1.4) brightness(.65); }
.tile-logo { position: relative; max-width: 46%; max-height: 62%; object-fit: contain; filter: drop-shadow(0 10px 20px rgba(0, 0, 0, .6)); transition: transform var(--dur-4) var(--ease-cinema); }
.tile:hover .tile-logo { transform: scale(1.08) translateY(-2px); }
.tile-monogram { font-family: var(--mono); font-size: 3.2rem; font-weight: 700; letter-spacing: -0.06em; color: var(--text); opacity: .9; text-shadow: 0 8px 30px rgba(0, 0, 0, .6); transition: transform var(--dur-4) var(--ease-cinema); }
.tile:hover .tile-monogram { transform: scale(1.1); }
.tile-art::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, transparent 45%, rgba(0, 0, 0, .55)); pointer-events: none; }
.tile-prefix { position: absolute; left: .7rem; bottom: .6rem; z-index: 2; font-family: var(--mono); font-size: .72rem; font-weight: 600; color: #fff; background: rgba(0, 0, 0, .55); border: 1px solid rgba(255, 255, 255, .18); backdrop-filter: blur(6px); padding: .05rem .45rem; border-radius: 4px; }
.tile-flag { position: absolute; right: .7rem; top: .6rem; z-index: 2; font-family: var(--mono); font-size: .68rem; color: #fff; background: var(--red); padding: 0 .4rem; border-radius: 3px; }
.tile-body { padding: .85rem .95rem .95rem; display: flex; flex-direction: column; gap: .45rem; }
.tile-title { margin: 0; font-size: .95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile-meta { display: flex; gap: .85rem; font-family: var(--mono); font-size: .7rem; color: var(--text-3); }
.tile-meta strong { color: var(--text); font-family: var(--sans); font-weight: 600; font-size: .82rem; margin-right: 2px; }
.tile-meta .ok strong { color: var(--green); }
.tile-more { display: grid; grid-template-rows: 0fr; opacity: 0; transition: grid-template-rows var(--dur-3) var(--ease-cinema), opacity var(--dur-2), margin var(--dur-3); }
.tile-more-inner { overflow: hidden; min-height: 0; }
.tile:hover .tile-more, .tile:focus-visible .tile-more { grid-template-rows: 1fr; opacity: 1; margin-top: .2rem; }
.tile-key { display: block; font-size: .7rem; background: var(--bg); border-color: var(--border-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile-more p { margin: .45rem 0 0; font-size: .78rem; color: var(--text-2); }
.tile-cta { display: inline-flex; align-items: center; gap: .3rem; margin-top: .45rem; font-size: .78rem; font-weight: 500; }
.tile-add { appearance: none; font: inherit; cursor: pointer; align-items: center; justify-content: center; gap: .6rem; min-height: 230px; border-style: dashed; border-color: var(--border-2); background: transparent; box-shadow: none; color: var(--text-2); }
.tile-add:hover { color: var(--text); border-color: var(--text-2); background: var(--surface); }
.tile-add-icon { width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center; border: 1px solid var(--border-2); background: var(--surface-2); transition: transform var(--dur-3) var(--ease-spring); }
.tile-add:hover .tile-add-icon { transform: rotate(90deg) scale(1.1); }
@media (hover: none) { .tile-more { grid-template-rows: 1fr; opacity: 1; } .tile:hover { transform: none; } }

/* ---------- Netflix rows (horizontal carousel) ---------- */
.row-section { margin-bottom: 1.75rem; }
.row-head { display: flex; align-items: center; gap: .9rem; margin-bottom: .4rem; }
.row-head h2 { margin: 0; font-size: 1.05rem; }
.row-link { font-size: .78rem; color: var(--text-2); text-decoration: none; display: inline-flex; align-items: center; gap: .1rem; opacity: 0; transform: translateX(-6px); transition: opacity var(--dur-2), transform var(--dur-2) var(--ease-out); }
.row-section:hover .row-link, .row-link:focus-visible { opacity: 1; transform: none; }
.row-controls { margin-left: auto; display: flex; gap: .25rem; }
.row-track { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(240px, 260px); gap: 1rem; overflow-x: auto; overscroll-behavior-x: contain; scroll-snap-type: x mandatory; scroll-padding: 0 1rem; padding: 1.4rem .25rem 2rem; margin: -1rem -.25rem -1.4rem; scrollbar-width: none; mask-image: linear-gradient(90deg, #000 92%, transparent); }
.row-track::-webkit-scrollbar { display: none; }
.row-track > .tile { scroll-snap-align: start; }
@media (max-width: 600px) { .row-track { grid-auto-columns: 78%; } .row-controls { display: none; } .row-link { opacity: 1; transform: none; } }

/* ---------- Billboard (game detail hero) ---------- */
.billboard { position: relative; overflow: hidden; border-radius: 16px; border: 1px solid var(--border); min-height: 280px; display: flex; align-items: flex-end; margin-bottom: 1.5rem; box-shadow: var(--elev-2); background: linear-gradient(135deg, var(--surface-3), var(--bg) 70%); isolation: isolate; }
.billboard-backdrop { position: absolute; inset: -15%; width: 130%; height: 130%; object-fit: cover; filter: blur(48px) saturate(1.3) brightness(.5); z-index: -2; animation: drift 24s ease-in-out infinite alternate; }
@keyframes drift { from { transform: scale(1.05) translate(0, 0); } to { transform: scale(1.18) translate(-3%, 2%); } }
.billboard-shade { position: absolute; inset: 0; z-index: -1; background: linear-gradient(90deg, rgba(0, 0, 0, .85) 0%, rgba(0, 0, 0, .55) 45%, rgba(0, 0, 0, .1) 100%), linear-gradient(0deg, rgba(0, 0, 0, .7), transparent 60%); }
:root[data-theme="light"] .billboard-shade { background: linear-gradient(90deg, rgba(255, 255, 255, .92) 0%, rgba(255, 255, 255, .6) 45%, rgba(255, 255, 255, .15) 100%), linear-gradient(0deg, rgba(255, 255, 255, .7), transparent 60%); }
.billboard-inner { display: flex; gap: 1.75rem; align-items: flex-end; padding: 2.25rem; width: 100%; }
.billboard-logo { width: 132px; height: 132px; flex: none; border-radius: 22px; display: grid; place-items: center; background: rgba(127, 127, 127, .12); border: 1px solid rgba(255, 255, 255, .12); backdrop-filter: blur(12px); box-shadow: 0 20px 50px -10px rgba(0, 0, 0, .7); overflow: hidden; animation: logo-in .9s var(--ease-cinema) both .05s; }
.billboard-logo img { width: 78%; height: 78%; object-fit: contain; }
.billboard-logo span { font-family: var(--mono); font-size: 3.6rem; font-weight: 700; letter-spacing: -0.06em; }
@keyframes logo-in { from { opacity: 0; transform: scale(1.25); filter: blur(10px); } to { opacity: 1; transform: none; filter: none; } }
.billboard-copy { min-width: 0; animation: rise .8s var(--ease-cinema) both .15s; }
.billboard-copy h1 { font-size: clamp(1.8rem, 4vw, 3rem); letter-spacing: -0.045em; margin: .4rem 0 .5rem; line-height: 1.05; }
.billboard-desc { color: var(--text-2); max-width: 560px; font-size: .95rem; }
.billboard-tags { display: flex; gap: .4rem; flex-wrap: wrap; align-items: center; }
.billboard-actions { display: flex; gap: .6rem; flex-wrap: wrap; margin-top: 1rem; }
@media (max-width: 700px) {
  .billboard { min-height: 0; }
  .billboard-inner { flex-direction: column; align-items: flex-start; padding: 1.25rem; gap: 1rem; }
  .billboard-logo { width: 84px; height: 84px; border-radius: 16px; }
  .billboard-logo span { font-size: 2.2rem; }
  .billboard-actions .btn, .billboard-actions .inline-form { flex: 1 1 100%; }
  .billboard-actions .inline-form .btn { width: 100%; }
}

/* ---------- Form steps ---------- */
.form-steps { display: flex; flex-direction: column; gap: 1.5rem; }
.form-step + .form-step { padding-top: 1.5rem; border-top: 1px dashed var(--border-2); }
.form-step-head { display: flex; gap: .8rem; align-items: flex-start; margin-bottom: 1rem; }
.form-step-head h4 { margin: 0; font-size: .92rem; }
.form-step-head p { margin: 0; color: var(--text-3); font-size: .8rem; }
.step-no { font-family: var(--mono); font-size: .7rem; color: var(--text-2); border: 1px solid var(--border-2); border-radius: 6px; padding: .15rem .35rem; background: var(--surface-2); }

.input-affix { display: flex; align-items: stretch; }
.input-affix input { border-radius: var(--radius-sm) 0 0 var(--radius-sm); text-transform: uppercase; }
.input-affix .affix { display: grid; place-items: center; padding: 0 .65rem; border: 1px solid var(--border-2); border-left: 0; border-radius: 0 var(--radius-sm) var(--radius-sm) 0; background: var(--surface-2); color: var(--text-3); font-size: .8rem; }

/* Live key preview: a "typed" license key */
.key-preview { display: flex; flex-wrap: wrap; align-items: center; font-family: var(--mono); font-size: 1.05rem; letter-spacing: .06em; padding: .8rem 1rem; border-radius: var(--radius-sm); border: 1px solid var(--border-2); background: repeating-linear-gradient(0deg, transparent 0 3px, rgba(127, 127, 127, .03) 3px 4px), var(--bg); box-shadow: inset 0 2px 10px rgba(0, 0, 0, .35); }
.key-preview::after { content: ""; width: .55em; height: 1.1em; margin-left: .25em; background: var(--blue-solid); animation: blink 1.1s steps(1) infinite; }
.kp-prefix { color: var(--text); font-weight: 700; }
.kp-sep { color: var(--text-3); }
.kp-group { color: var(--text-2); }
.kp-group.flip { animation: flip .35s var(--ease-out); }
@keyframes flip { from { opacity: 0; transform: translateY(-40%); } }

/* Logo dropzone */
.dropzone { position: relative; }
.dropzone-input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer; z-index: 2; }
.dropzone-label { display: flex; align-items: center; gap: 1rem; padding: 1rem; border: 1px dashed var(--border-3); border-radius: 10px; background: var(--bg-2); cursor: pointer; transition: border-color var(--dur-2), background var(--dur-2), transform var(--dur-2) var(--ease-out); }
.dropzone:hover .dropzone-label, .dropzone-input:focus-visible + .dropzone-label { border-color: var(--text-2); background: var(--surface-2); }
.dropzone.is-dragover .dropzone-label { border-style: solid; border-color: var(--blue); background: var(--blue-soft); transform: scale(1.01); }
.dropzone.has-file .dropzone-label { border-style: solid; border-color: color-mix(in srgb, var(--green) 50%, transparent); }
.dropzone-preview { width: 72px; height: 72px; flex: none; border-radius: 14px; border: 1px solid var(--border-2); background: var(--surface-3); display: grid; place-items: center; overflow: hidden; color: var(--text-3); box-shadow: var(--elev-1); }
.dropzone-preview img { width: 100%; height: 100%; object-fit: contain; animation: logo-in .5s var(--ease-cinema) both; }
.dropzone-text { display: flex; flex-direction: column; gap: .15rem; font-size: .8rem; color: var(--text-3); min-width: 0; }
.dropzone-text strong { color: var(--text); font-size: .88rem; font-weight: 500; }
.dropzone-file { color: var(--green); font-size: .72rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Toggle switches */
.switch-list { display: grid; gap: .5rem; }
.switch { display: flex; align-items: flex-start; gap: .75rem; padding: .7rem .8rem; border: 1px solid var(--border); border-radius: var(--radius-sm); cursor: pointer; transition: border-color var(--dur-2), background var(--dur-2); font-weight: 400; }
.switch:hover { border-color: var(--border-2); background: var(--surface-2); }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch-ui { width: 34px; height: 20px; flex: none; border-radius: 999px; background: var(--surface-3); border: 1px solid var(--border-3); position: relative; transition: background var(--dur-2), border-color var(--dur-2); margin-top: 1px; }
.switch-ui::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: var(--text-2); transition: transform var(--dur-3) var(--ease-spring), background var(--dur-2); }
.switch input:checked + .switch-ui { background: var(--green); border-color: var(--green); }
.switch input:checked + .switch-ui::after { transform: translateX(14px); background: #fff; }
.switch input:focus-visible + .switch-ui { outline: 2px solid var(--blue); outline-offset: 2px; }
.switch strong { display: block; font-size: .84rem; font-weight: 500; }
.switch small { color: var(--text-3); font-size: .76rem; }

/* Game picker (license generator) */
.game-picker { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(200px, 100%), 1fr)); gap: .6rem; }
.pick { position: relative; display: flex; align-items: center; gap: .7rem; padding: .6rem .7rem; border: 1px solid var(--border); border-radius: 10px; background: var(--bg-2); text-decoration: none; color: var(--text); transition: border-color var(--dur-2), transform var(--dur-2) var(--ease-out), background var(--dur-2); }
.pick:hover { border-color: var(--border-3); transform: translateY(-2px); background: var(--surface-2); }
.pick.is-selected { border-color: var(--text); background: var(--surface-3); box-shadow: 0 0 0 1px var(--text), var(--elev-1); }
.pick-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.pick-text strong { font-size: .84rem; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pick-text .mono { font-size: .7rem; color: var(--text-3); }
.pick-check { margin-left: auto; width: 20px; height: 20px; border-radius: 50%; background: var(--text); color: var(--bg); display: grid; place-items: center; animation: pop .3s var(--ease-spring); }
@keyframes pop { from { transform: scale(0); } }

/* Empty state */
.empty-state { text-align: center; padding: 4rem 1rem; border: 1px dashed var(--border-2); border-radius: 14px; }
.empty-art { display: grid; place-items: center; margin-bottom: 1rem; }
.empty-mark { width: 64px; height: 64px; animation: float 4s ease-in-out infinite; }
@keyframes float { 50% { transform: translateY(-6px); } }

/* ---------- Modal: Netflix preview open / close ---------- */
.modal.open { animation: fade var(--dur-2) ease-out; }
.modal.open .modal-box { animation: modal-in var(--dur-3) var(--ease-cinema) both; }
.modal.closing { display: flex; animation: fade-out .18s ease-in both; }
.modal.closing .modal-box { animation: modal-out .18s ease-in both; }
@keyframes modal-in { from { opacity: 0; transform: translateY(18px) scale(.94); } to { opacity: 1; transform: none; } }
@keyframes modal-out { to { opacity: 0; transform: translateY(10px) scale(.97); } }
@keyframes fade-out { to { opacity: 0; } }
.modal-head .eyebrow { margin: 0; }
@media (max-width: 600px) {
  .modal.open .modal-box { animation: sheet-in var(--dur-3) var(--ease-cinema) both; }
  .modal.closing .modal-box { animation: sheet-out .2s ease-in both; }
}
@keyframes sheet-in { from { transform: translateY(100%); } to { transform: none; } }
@keyframes sheet-out { to { transform: translateY(100%); } }

/* ---------- Micro-interactions ---------- */
.nav a { transition: background var(--dur-1), color var(--dur-1), padding var(--dur-2) var(--ease-out); }
.nav a:hover { padding-left: .8rem; }
.nav a .icon { transition: transform var(--dur-2) var(--ease-spring); }
.nav a:hover .icon { transform: scale(1.12); }
.nav a.active::before { animation: grow-y var(--dur-3) var(--ease-cinema); }
@keyframes grow-y { from { transform: scaleY(0); } }
tbody tr { transition: background var(--dur-1), box-shadow var(--dur-2); }
tbody tr:hover { box-shadow: inset 2px 0 0 var(--text-3); }
.badge { transition: transform var(--dur-2) var(--ease-spring); }
tr:hover .badge { transform: translateX(1px); }
.stat .value { transition: color var(--dur-2); }
.grid-stats > .card { transition: background var(--dur-2); }
.grid-stats > .card:hover { background: var(--surface-2); }
.toast { animation: toast-in var(--dur-3) var(--ease-spring); }
@keyframes toast-in { from { opacity: 0; transform: translateX(24px) scale(.96); } to { opacity: 1; transform: none; } }
.chart rect { transform-box: fill-box; transform-origin: bottom; animation: bar-up .8s var(--ease-cinema) both; }
.chart rect:nth-of-type(odd) { animation-delay: .05s; }
@keyframes bar-up { from { transform: scaleY(0); } }
.btn .icon { transition: transform var(--dur-2) var(--ease-spring); }
.btn:hover .icon { transform: translateX(1px); }
.btn[data-modal-open]:hover .icon, .tile-add:hover .icon { transform: rotate(90deg); }

/* ---------- Intro (auth & installer): logo "ta-dum" ---------- */
.auth-card { box-shadow: var(--elev-3); animation: card-in .7s var(--ease-cinema) both .35s; }
.auth-card .brand-mark { animation: intro-mark 1s var(--ease-cinema) both; }
.auth-card .brand-word { animation: intro-word .7s var(--ease-cinema) both .3s; }
.auth-card > :not(.brand) { animation: rise .6s var(--ease-cinema) both .55s; }
@keyframes intro-mark { 0% { opacity: 0; transform: scale(2.4); filter: blur(14px); } 60% { opacity: 1; filter: blur(0); } 100% { transform: none; } }
@keyframes intro-word { from { opacity: 0; letter-spacing: .4em; filter: blur(6px); } to { opacity: 1; letter-spacing: -0.03em; filter: none; } }
@keyframes card-in { from { border-color: transparent; box-shadow: none; } }
.auth-wrap { position: relative; overflow: hidden; }
.auth-wrap::before { content: ""; position: absolute; left: 50%; top: 40%; width: 900px; height: 900px; transform: translate(-50%, -50%); background: radial-gradient(closest-side, rgba(127, 127, 127, .14), transparent); pointer-events: none; animation: breathe 8s ease-in-out infinite; }
@keyframes breathe { 50% { transform: translate(-50%, -50%) scale(1.15); opacity: .7; } }
.auth-wrap > * { position: relative; }

@media (prefers-reduced-motion: reduce) {
  html.js .reveal { opacity: 1; transform: none; }
  .tile:hover { transform: none; }
  ::view-transition-old(root), ::view-transition-new(root) { animation: none; }
}

/* Netflix-style overlay expansion: the details panel floats over the next row instead of pushing it */
.tile-grid { align-items: start; }
.tile { overflow: visible; }
.tile-art { border-radius: 11px 11px 0 0; }
.tile-grid .tile-more {
  position: absolute; left: -1px; right: -1px; top: 100%; z-index: 6;
  display: block; padding: 0 .95rem .95rem; margin: 0;
  background: var(--surface); border: 1px solid var(--border-3); border-top: 0; border-radius: 0 0 12px 12px;
  box-shadow: var(--elev-3);
  opacity: 0; transform: translateY(-8px); pointer-events: none; visibility: hidden;
  transition: opacity var(--dur-2), transform var(--dur-3) var(--ease-cinema), visibility 0s linear var(--dur-3);
}
.tile-grid .tile-more::before { content: ""; position: absolute; left: 0; right: 0; top: -12px; height: 12px; background: var(--surface); }
.tile-grid .tile:hover .tile-more, .tile-grid .tile:focus-visible .tile-more {
  opacity: 1; transform: none; visibility: visible; pointer-events: auto; transition: opacity var(--dur-2), transform var(--dur-3) var(--ease-cinema);
}
.tile-grid .tile:hover, .tile-grid .tile:focus-visible { border-radius: 12px 12px 0 0; border-bottom-color: transparent; }
.tile-grid .tile-more-inner { overflow: visible; }
.row-track .tile-more { display: none; }
@media (hover: none) {
  .tile-grid .tile-more { position: static; opacity: 1; transform: none; visibility: visible; pointer-events: auto; border: 0; box-shadow: none; padding-top: 0; }
  .tile-grid .tile-more::before { display: none; }
}
.badge-primary { text-transform: none; }
.input-affix .affix { white-space: nowrap; }
.grid-stats { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }

/* ==========================================================================
   v3 — Terminal aesthetic, navigation, fields, mobile, landing, client home
   ========================================================================== */

:root { --tabbar: 64px; --safe-b: env(safe-area-inset-bottom, 0px); --scan: rgba(255, 255, 255, .018); }
:root[data-theme="light"] { --scan: rgba(0, 0, 0, .02); }

/* ---------- Page transitions: calmer, no blur/zoom, content-only slide ---------- */
::view-transition-old(root), ::view-transition-new(root) { animation-duration: .16s; animation-timing-function: ease; }
::view-transition-old(root) { animation-name: vt-fade-out; }
::view-transition-new(root) { animation-name: vt-fade-in; }
.content { view-transition-name: page; }
::view-transition-old(page) { animation: vt-page-out .14s ease-in both; }
::view-transition-new(page) { animation: vt-page-in .3s var(--ease-cinema) both; }
@keyframes vt-fade-out { to { opacity: 0; } }
@keyframes vt-fade-in { from { opacity: 0; } }
@keyframes vt-page-out { to { opacity: 0; transform: translateY(-4px); } }
@keyframes vt-page-in { from { opacity: 0; transform: translateY(8px); } }
.content > :not(.reveal):not(.modal):not(script) { animation-duration: .35s; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* Top progress bar (navigation feedback) */
.nav-progress { position: fixed; top: 0; left: 0; right: 0; height: 2px; z-index: 300; pointer-events: none; transform-origin: 0 50%; transform: scaleX(0); background: var(--blue-solid); box-shadow: 0 0 10px var(--blue-solid); opacity: 0; }
body.is-navigating .nav-progress { opacity: 1; animation: progress-run 8s cubic-bezier(.1, .7, .2, 1) forwards; }
body.is-done .nav-progress { animation: progress-done .4s ease forwards; }
@keyframes progress-run { 0% { transform: scaleX(0); } 20% { transform: scaleX(.45); } 100% { transform: scaleX(.92); } }
@keyframes progress-done { 0% { opacity: 1; transform: scaleX(1); } 100% { opacity: 0; transform: scaleX(1); } }

/* ---------- Terminal primitives ---------- */
.t-ok { color: var(--green); }
.t-dim { color: var(--text-3); }
.t-info { color: var(--blue); }
.t-warn { color: var(--amber); }
.t-err { color: var(--red); }
.dot-live { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 0 color-mix(in srgb, var(--green) 60%, transparent); animation: live 2s infinite; vertical-align: 1px; }
@keyframes live { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--green) 55%, transparent); } 70% { box-shadow: 0 0 0 7px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }
.caret { display: inline-block; width: .5em; height: .9em; margin-left: .08em; background: var(--blue-solid); vertical-align: -0.06em; animation: blink 1.1s steps(1) infinite; }
.terminal { border: 1px solid var(--border-2); border-radius: 10px; background: var(--bg); overflow: hidden; box-shadow: var(--elev-2); position: relative; }
.terminal::after { content: ""; position: absolute; inset: 0; pointer-events: none; background: repeating-linear-gradient(0deg, var(--scan) 0 1px, transparent 1px 3px); }
.terminal-bar { display: flex; align-items: center; gap: 6px; padding: .55rem .8rem; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.terminal-bar > span { width: 10px; height: 10px; border-radius: 50%; background: var(--border-3); }
.terminal-bar > span:first-child { background: var(--red); opacity: .8; }
.terminal-bar > span:nth-child(2) { background: var(--amber); opacity: .8; }
.terminal-bar > span:nth-child(3) { background: var(--green); opacity: .8; }
.terminal-bar em { margin-left: .5rem; font-style: normal; font-family: var(--mono); font-size: .72rem; color: var(--text-3); }
.terminal-body { margin: 0; padding: 1rem 1.1rem; font-family: var(--mono); font-size: .82rem; line-height: 1.75; white-space: pre-wrap; word-break: break-word; color: var(--text); }
.terminal-body strong { color: var(--text); font-weight: 700; letter-spacing: .04em; }
.tw-line { opacity: 0; display: inline; transition: opacity .2s; }
.tw-line.on { opacity: 1; }
.tw-line.on:last-of-type::after { content: ""; display: inline-block; width: .5em; height: 1em; background: var(--blue-solid); margin-left: .2em; vertical-align: -0.15em; animation: blink 1.1s steps(1) infinite; }
.terminal-card { padding: 0; overflow: hidden; }

/* ---------- Toasts: terminal log lines with a countdown ---------- */
.toasts { right: 1rem; bottom: calc(1rem + var(--safe-b)); width: min(400px, calc(100vw - 2rem)); gap: .45rem; }
.toast {
  position: relative; overflow: hidden; display: flex; align-items: flex-start; gap: .55rem;
  padding: .65rem .75rem .75rem; border-radius: 8px; font-family: var(--mono); font-size: .78rem; line-height: 1.5;
  background: color-mix(in srgb, var(--bg) 92%, var(--text) 3%); border: 1px solid var(--border-2);
  box-shadow: 0 12px 40px -12px rgba(0, 0, 0, .8); backdrop-filter: blur(10px);
  animation: toast-in .32s var(--ease-cinema) both; touch-action: pan-y;
}
.toast::before { display: none; }
.toast-tag { flex: none; font-weight: 700; color: var(--blue); }
.toast.success .toast-tag { color: var(--green); }
.toast.error .toast-tag { color: var(--red); }
.toast.warning .toast-tag { color: var(--amber); }
.toast.error { border-color: color-mix(in srgb, var(--red) 40%, var(--border-2)); }
.toast-text { flex: 1; min-width: 0; color: var(--text); font-family: var(--sans); font-size: .82rem; }
.toast .close { font-family: var(--sans); }
.toast-bar { position: absolute; left: 0; bottom: 0; height: 2px; width: 100%; background: currentColor; color: var(--blue); transform-origin: left; animation: toast-count var(--toast-ms, 4.5s) linear forwards; opacity: .8; }
.toast.success .toast-bar { color: var(--green); }
.toast.error .toast-bar { color: var(--red); }
.toast.warning .toast-bar { color: var(--amber); }
.toast.paused .toast-bar { animation-play-state: paused; }
.toast.hide { animation: toast-out .24s ease-in forwards; }
@keyframes toast-count { from { transform: scaleX(1); } to { transform: scaleX(0); } }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateX(30px); } }
@media (max-width: 960px) { .toasts { left: .75rem; right: .75rem; width: auto; bottom: calc(var(--tabbar) + .75rem + var(--safe-b)); } }

/* ---------- Sidebar ---------- */
.sidebar { width: var(--sidebar); }
.sidebar-head { gap: .5rem; }
.sidebar-close { display: none; margin-left: auto; }
.sidebar-status { font-size: .68rem; color: var(--text-3); padding: .55rem 1rem; border-bottom: 1px dashed var(--border); display: flex; align-items: center; gap: .45rem; }
.nav { padding: .4rem .55rem 1rem; scrollbar-width: thin; scrollbar-color: var(--border-2) transparent; }
.nav-section { padding: 1.1rem .65rem .4rem; letter-spacing: .02em; }
.nav-section::before { content: "// "; color: var(--border-3); }
.nav a { gap: .65rem; padding: .38rem .55rem; margin: 1px 0; border: 1px solid transparent; }
.nav-ico { width: 26px; height: 26px; flex: none; display: grid; place-items: center; border-radius: 6px; border: 1px solid var(--border); background: var(--bg); color: var(--text-3); transition: color var(--dur-1), border-color var(--dur-1), background var(--dur-1), transform var(--dur-2) var(--ease-spring); }
.nav-ico .icon { width: 14px; height: 14px; }
.nav a:hover { padding-left: .55rem; background: var(--surface-2); }
.nav a:hover .nav-ico { color: var(--text); border-color: var(--border-3); transform: none; }
.nav a:hover .icon { transform: none; }
.nav a.active { background: var(--surface-3); border-color: var(--border-2); color: var(--text); }
.nav a.active .nav-ico { color: var(--bg); background: var(--text); border-color: var(--text); }
.nav a.active::before { left: -.55rem; top: 9px; bottom: 9px; width: 3px; background: var(--blue-solid); box-shadow: 0 0 10px var(--blue-solid); }
.nav a.active .nav-label::after { content: "_"; color: var(--blue); margin-left: 2px; animation: blink 1.1s steps(1) infinite; font-family: var(--mono); }
.nav-label { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-foot { gap: .4rem; padding: .6rem; }
.who-link { display: flex; align-items: center; gap: .6rem; flex: 1; min-width: 0; padding: .35rem .45rem; border-radius: 8px; text-decoration: none; color: var(--text); transition: background var(--dur-1); }
.who-link:hover { background: var(--surface-3); }
.who small { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Avatars */
.avatar { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; border: 1px solid var(--border-2); background: var(--surface-3); display: inline-grid; place-items: center; font-family: var(--mono); font-weight: 700; font-size: .8rem; flex: none; color: var(--text); }
.avatar-sm { width: 26px; height: 26px; font-size: .68rem; }
.avatar-lg { width: 64px; height: 64px; font-size: 1.4rem; border-radius: 18px; }
.avatar-xl { width: 112px; height: 112px; font-size: 2.6rem; border-radius: 28px; border-width: 2px; }
img.avatar { display: block; }
.topbar-avatar { display: inline-flex; border-radius: 50%; transition: transform var(--dur-2) var(--ease-spring); }
.topbar-avatar:hover { transform: scale(1.08); }
.user-cell { display: inline-flex; align-items: center; gap: .55rem; text-decoration: none; color: var(--text); }
.user-cell:hover strong { text-decoration: underline; text-underline-offset: 3px; }

/* ---------- Fields ---------- */
label { letter-spacing: .005em; }
.field > label::before { content: "› "; color: var(--text-3); font-family: var(--mono); }
.field:focus-within > label { color: var(--text); }
.field:focus-within > label::before { color: var(--blue); }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=url],
input[type=search], input[type=datetime-local], input[type=date], select, textarea {
  height: 40px; background: var(--bg-2); border-color: var(--border-2); box-shadow: inset 0 1px 2px rgba(0, 0, 0, .25);
  caret-color: var(--blue); transition: border-color var(--dur-1), box-shadow var(--dur-2), background var(--dur-2);
}
textarea { height: auto; }
input:focus, select:focus, textarea:focus { background: var(--bg); border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-soft), inset 0 1px 2px rgba(0, 0, 0, .2); }
input:user-invalid, textarea:user-invalid, select:user-invalid { border-color: var(--red); box-shadow: 0 0 0 3px var(--red-soft); }
input:user-invalid + .hint, .field:has(input:user-invalid) .hint { color: var(--red); }
input:disabled, select:disabled, textarea:disabled { opacity: .55; cursor: not-allowed; }
input[type=number] { font-family: var(--mono); }
.input-icon { position: relative; display: flex; align-items: center; }
.input-icon > .icon { position: absolute; left: .7rem; color: var(--text-3); pointer-events: none; transition: color var(--dur-1); }
.input-icon > input { padding-left: 2.1rem; }
.input-icon:focus-within > .icon { color: var(--blue); }
.input-icon.has-action > input { padding-right: 3.6rem; }
.input-action { position: absolute; right: .35rem; height: 30px; padding: 0 .55rem; border: 0; border-radius: 5px; background: transparent; color: var(--text-2); font: inherit; font-family: var(--mono); font-size: .72rem; cursor: pointer; }
.input-action:hover { background: var(--surface-3); color: var(--text); }
.callout { display: flex; gap: .6rem; align-items: flex-start; padding: .7rem .85rem; margin-bottom: 1.25rem; border: 1px dashed var(--border-3); border-radius: 8px; font-size: .82rem; color: var(--text-2); background: var(--bg-2); }
.callout .icon { margin-top: 3px; color: var(--blue); }
.callout strong { color: var(--text); }
.strength { display: flex; align-items: center; gap: 4px; margin: -.25rem 0 1.1rem; }
.strength span { flex: 1; height: 3px; border-radius: 2px; background: var(--surface-3); transition: background var(--dur-2); }
.strength em { flex: 2.5; font-style: normal; font-family: var(--mono); font-size: .68rem; color: var(--text-3); margin-left: .4rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.strength[data-score="1"] span:nth-child(-n+1) { background: var(--red); }
.strength[data-score="2"] span:nth-child(-n+2) { background: var(--amber); }
.strength[data-score="3"] span:nth-child(-n+3) { background: var(--blue); }
.strength[data-score="4"] span:nth-child(-n+4) { background: var(--green); }
.segmented { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; padding: 4px; border: 1px solid var(--border-2); border-radius: 10px; background: var(--bg-2); }
.segmented label { margin: 0; cursor: pointer; }
.segmented label::before { display: none; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span { display: flex; align-items: center; justify-content: center; gap: .4rem; height: 36px; border-radius: 7px; color: var(--text-2); font-size: .84rem; transition: background var(--dur-2), color var(--dur-2), box-shadow var(--dur-2); }
.segmented input:checked + span { background: var(--surface-3); color: var(--text); box-shadow: var(--elev-1); }
.segmented input:focus-visible + span { outline: 2px solid var(--blue); outline-offset: 1px; }
.btn-primary { position: relative; overflow: hidden; }
.btn-primary::after { content: ""; position: absolute; inset: 0; background: linear-gradient(110deg, transparent 30%, rgba(255, 255, 255, .35) 50%, transparent 70%); transform: translateX(-120%); }
.btn-primary:hover::after { transform: translateX(120%); transition: transform .7s var(--ease-out); }
.small-text { font-size: .76rem; }

/* ---------- Mobile: bottom tab bar, drawer, touch sizes ---------- */
.tabbar { display: none; }
@media (max-width: 960px) {
  body.app { padding-bottom: calc(var(--tabbar) + var(--safe-b)); }
  .tabbar {
    display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; position: fixed; left: 0; right: 0; bottom: 0; z-index: 45;
    height: calc(var(--tabbar) + var(--safe-b)); padding-bottom: var(--safe-b);
    background: var(--glass); backdrop-filter: saturate(180%) blur(14px); border-top: 1px solid var(--border);
  }
  .tabbar a, .tabbar button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: var(--text-3); text-decoration: none; font-family: var(--mono); font-size: .64rem; background: none; border: 0; cursor: pointer; position: relative; -webkit-tap-highlight-color: transparent; }
  .tabbar .icon { width: 20px; height: 20px; transition: transform var(--dur-2) var(--ease-spring); }
  .tabbar a.active { color: var(--text); }
  .tabbar a.active::before { content: ""; position: absolute; top: 0; left: 30%; right: 30%; height: 2px; background: var(--blue-solid); border-radius: 0 0 2px 2px; box-shadow: 0 0 10px var(--blue-solid); }
  .tabbar a:active .icon, .tabbar button:active .icon { transform: scale(.85); }
  .sidebar { width: min(86vw, 320px); box-shadow: 30px 0 60px -20px rgba(0, 0, 0, .8); transition: transform .32s var(--ease-cinema); }
  .sidebar-close { display: inline-flex; }
  .topbar .role, .topbar .theme-toggle { display: none; }
  .topbar .menu-toggle { display: none; }
  .content { padding: 1rem .9rem 2rem; }
  .btn { height: 40px; }
  .btn-sm { height: 34px; }
  input[type=text], input[type=email], input[type=password], input[type=number], input[type=url], input[type=search], input[type=datetime-local], input[type=date], select, textarea { font-size: 16px; height: 44px; }
  textarea { height: auto; }
  .nav a { padding: .55rem .55rem; }
  .page-head { margin-bottom: 1rem; }
  .hero, .billboard { border-radius: 12px; }
  .card { padding: 1rem; }
}
@media (max-width: 960px) and (min-width: 0) { .sidebar-foot { padding-bottom: calc(.6rem + var(--safe-b)); } }

/* ---------- Profile header (account) ---------- */
.profile-hero { display: flex; align-items: center; gap: 1.5rem; padding: 1.5rem; margin-bottom: 1.25rem; border: 1px solid var(--border); border-radius: 14px; background: linear-gradient(180deg, var(--surface-2), var(--bg)); box-shadow: var(--elev-2); }
.profile-hero h1 { margin: .1rem 0 .2rem; font-size: 1.6rem; letter-spacing: -0.03em; }
.profile-hero p { margin-bottom: .75rem; }
.profile-photo { position: relative; flex: none; }
.photo-edit { position: absolute; right: -6px; bottom: -6px; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: var(--text); color: var(--bg); border: 3px solid var(--bg); cursor: pointer; transition: transform var(--dur-2) var(--ease-spring); }
.photo-edit::before { display: none; }
.photo-edit:hover { transform: scale(1.1) rotate(-8deg); }
.photo-form { margin: 0; }
@media (max-width: 600px) { .profile-hero { flex-direction: column; text-align: center; } .profile-hero .btn-row { justify-content: center; } }

/* ---------- Client home ---------- */
.client-hero { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 1.25rem; padding: 1.5rem; margin-bottom: 1.5rem; border: 1px solid var(--border); border-radius: 14px; background: radial-gradient(500px 200px at 100% 0%, rgba(127, 127, 127, .1), transparent), linear-gradient(180deg, var(--surface-2), var(--bg)); box-shadow: var(--elev-2); }
.client-hero h1 { font-size: 1.55rem; letter-spacing: -0.03em; margin: .1rem 0 .25rem; }
.client-hero p { margin: 0; }
.client-kpis { display: grid; grid-template-columns: repeat(4, auto); gap: 0; margin: 0; border: 1px solid var(--border-2); border-radius: 10px; overflow: hidden; }
.client-kpis div { padding: .55rem .9rem; border-right: 1px solid var(--border-2); text-align: center; background: var(--bg); }
.client-kpis div:last-child { border-right: 0; }
.client-kpis dt { font-family: var(--mono); font-size: .64rem; color: var(--text-3); }
.client-kpis dd { margin: 0; font-size: 1.3rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.client-kpis dd.ok { color: var(--green); }
.client-kpis dd.warn { color: var(--amber); }
@media (max-width: 900px) { .client-hero { grid-template-columns: auto 1fr; } .client-kpis { grid-column: 1 / -1; grid-template-columns: repeat(4, 1fr); } }
@media (max-width: 480px) { .client-hero { padding: 1rem; } .client-kpis div { padding: .5rem .3rem; } .client-kpis dd { font-size: 1.1rem; } }
.client-grid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 1.25rem; align-items: start; }
@media (max-width: 1100px) { .client-grid { grid-template-columns: 1fr; } .client-side { order: -1; } }
.client-side { display: grid; gap: 1rem; position: sticky; top: calc(var(--topbar) + 1rem); }
@media (max-width: 1100px) { .client-side { position: static; } }
.section-title { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: .75rem; }
.section-title h2 { margin: 0; font-size: 1.05rem; }
.license-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1rem; }
.license-card { position: relative; display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: 14px; overflow: hidden; text-decoration: none; color: var(--text); background: var(--surface); box-shadow: var(--elev-1); isolation: isolate; transition: transform var(--dur-3) var(--ease-cinema), box-shadow var(--dur-3), border-color var(--dur-2); }
.license-card:hover { transform: translateY(-4px); box-shadow: var(--elev-3); border-color: var(--border-3); text-decoration: none; }
.lc-art { position: relative; height: 96px; overflow: hidden; display: grid; place-items: center; background: linear-gradient(135deg, var(--surface-3), var(--bg)); border-bottom: 1px solid var(--border); }
.lc-art::after { content: ""; position: absolute; inset: 0; background: repeating-linear-gradient(0deg, var(--scan) 0 1px, transparent 1px 3px), linear-gradient(180deg, transparent, rgba(0, 0, 0, .45)); }
.lc-backdrop { position: absolute; inset: -30%; width: 160%; height: 160%; object-fit: cover; filter: blur(26px) brightness(.5) saturate(1.3); transition: transform 1s var(--ease-cinema); }
.license-card:hover .lc-backdrop { transform: scale(1.15); }
.lc-logo { position: relative; z-index: 1; height: 60px; width: 60px; object-fit: contain; filter: drop-shadow(0 8px 18px rgba(0, 0, 0, .6)); }
.lc-mono { position: relative; z-index: 1; font-family: var(--mono); font-size: 2.4rem; font-weight: 700; }
.lc-body { padding: .9rem 1rem 1rem; display: grid; gap: .55rem; }
.lc-top { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.lc-top h3 { margin: 0; font-size: .95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lc-key { font-size: .74rem; justify-self: start; }
.lc-time { display: flex; justify-content: space-between; font-size: .74rem; }
.lc-progress { -webkit-appearance: none; appearance: none; width: 100%; height: 4px; border: 0; border-radius: 4px; background: var(--surface-3); overflow: hidden; }
.lc-progress::-webkit-progress-bar { background: var(--surface-3); border-radius: 4px; }
.lc-progress::-webkit-progress-value { background: var(--green); border-radius: 4px; transition: width .8s var(--ease-cinema); }
.lc-progress::-moz-progress-bar { background: var(--green); border-radius: 4px; }
.lc-progress.is-low::-webkit-progress-value { background: var(--amber); }
.lc-progress.is-low::-moz-progress-bar { background: var(--amber); }
.status-expired .lc-progress::-webkit-progress-value, .status-banned .lc-progress::-webkit-progress-value, .status-revoked .lc-progress::-webkit-progress-value { background: var(--red); }
.lc-devices { display: flex; align-items: center; gap: 4px; font-size: .7rem; }
.lc-devices .slot { width: 14px; height: 6px; border-radius: 2px; border: 1px solid var(--border-3); }
.lc-devices .slot.on { background: var(--text); border-color: var(--text); }
.lc-devices .mono { margin-left: .35rem; }
.status-banned, .status-revoked { border-color: color-mix(in srgb, var(--red) 35%, var(--border)); }
.status-banned .lc-art, .status-revoked .lc-art, .status-expired .lc-art { filter: grayscale(1); }
.redeem-form { padding: 1rem; display: grid; gap: .6rem; }
.redeem-form label { font-size: .76rem; }
.redeem-form label::before { content: "$ "; color: var(--blue); }
.redeem-form .hint { margin: 0; }
.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline::before { content: ""; position: absolute; left: 4px; top: 6px; bottom: 6px; width: 1px; background: var(--border-2); }
.timeline li { display: flex; gap: .75rem; padding: .35rem 0; font-size: .82rem; }
.timeline strong { display: block; font-weight: 500; }
.timeline small { color: var(--text-3); font-size: .7rem; }
.tl-dot { width: 9px; height: 9px; flex: none; margin-top: 5px; border-radius: 50%; background: var(--bg); border: 2px solid var(--blue); position: relative; z-index: 1; }

/* ---------- Invites ---------- */
.invite-new { border-color: color-mix(in srgb, var(--amber) 40%, var(--border)); }
.invite-new .terminal-body strong { font-size: 1rem; }

/* ---------- Landing page ---------- */
body.landing { background-image: radial-gradient(var(--border) 1px, transparent 1px), var(--vignette); background-size: 26px 26px, auto; background-attachment: fixed; }
.lp-nav { position: sticky; top: 0; z-index: 50; display: flex; align-items: center; gap: 1.5rem; padding: .85rem clamp(1rem, 4vw, 3rem); background: var(--glass); backdrop-filter: saturate(180%) blur(12px); border-bottom: 1px solid var(--border); }
.lp-links { display: flex; gap: 1.25rem; font-family: var(--mono); font-size: .78rem; }
.lp-links a { color: var(--text-2); text-decoration: none; }
.lp-links a::before { content: "./"; color: var(--text-3); }
.lp-links a:hover { color: var(--text); }
.lp-cta { margin-left: auto; display: flex; gap: .5rem; align-items: center; }
@media (max-width: 760px) { .lp-links { display: none; } .lp-cta .btn:not(.btn-primary):not(.theme-toggle) { display: none; } }
.lp-hero { max-width: 1200px; margin: 0 auto; padding: clamp(3rem, 8vw, 6.5rem) clamp(1rem, 4vw, 3rem) 3rem; display: grid; grid-template-columns: 1.05fr .95fr; gap: 3rem; align-items: center; }
@media (max-width: 960px) { .lp-hero { grid-template-columns: 1fr; gap: 2rem; } }
.lp-hero h1 { font-size: clamp(2.3rem, 5.5vw, 4.2rem); line-height: 1.02; letter-spacing: -0.055em; margin: 1rem 0; animation: rise .8s var(--ease-cinema) both .1s; }
.type-cycle { font-family: var(--mono); font-weight: 600; letter-spacing: -0.04em; color: var(--text); display: inline-block; border-bottom: 2px solid var(--blue-solid); transition: opacity .25s, transform .25s, filter .25s; }
.type-cycle.out { opacity: 0; transform: translateY(-8px); filter: blur(4px); }
.lead { font-size: clamp(1rem, 1.6vw, 1.15rem); color: var(--text-2); max-width: 560px; margin-bottom: 1.5rem; animation: rise .8s var(--ease-cinema) both .2s; }
.lp-hero .btn-row { animation: rise .8s var(--ease-cinema) both .3s; }
.pill { display: inline-flex; align-items: center; gap: .5rem; font-family: var(--mono); font-size: .74rem; color: var(--text-2); border: 1px solid var(--border-2); border-radius: 999px; padding: .25rem .75rem; background: var(--bg); animation: rise .6s var(--ease-cinema) both; }
.lp-facts { display: flex; gap: 2rem; margin: 2rem 0 0; animation: rise .8s var(--ease-cinema) both .4s; }
.lp-facts dt { font-family: var(--mono); font-size: .68rem; color: var(--text-3); }
.lp-facts dd { margin: 0; font-weight: 600; }
.lp-terminal { animation: terminal-in 1s var(--ease-cinema) both .25s; transform-origin: 50% 100%; }
.lp-terminal .terminal-body { font-size: .84rem; min-height: 290px; }
@keyframes terminal-in { from { opacity: 0; transform: perspective(1000px) rotateX(12deg) translateY(30px); } to { opacity: 1; transform: none; } }
.lp-games { padding: 1rem 0 2rem; }
.lp-kicker { font-family: var(--mono); font-size: .76rem; color: var(--text-3); text-align: center; margin-bottom: 1rem; }
.marquee { overflow: hidden; mask-image: linear-gradient(90deg, transparent, #000 12%, #000 88%, transparent); }
.marquee-track { display: flex; gap: 1rem; width: max-content; animation: marquee 40s linear infinite; }
.marquee:hover .marquee-track { animation-play-state: paused; }
@keyframes marquee { to { transform: translateX(-50%); } }
.marquee-item { display: inline-flex; align-items: center; gap: .6rem; padding: .5rem .9rem; border: 1px solid var(--border-2); border-radius: 999px; background: var(--bg); white-space: nowrap; font-size: .86rem; }
.marquee-item img, .marquee-item b { width: 24px; height: 24px; border-radius: 6px; object-fit: contain; display: grid; place-items: center; background: var(--surface-3); font-family: var(--mono); font-size: .7rem; }
.lp-section { max-width: 1200px; margin: 0 auto; padding: 4rem clamp(1rem, 4vw, 3rem); }
.lp-section > .lp-kicker { text-align: left; }
.lp-section h2 { font-size: clamp(1.6rem, 3.2vw, 2.4rem); letter-spacing: -0.04em; margin-bottom: 2rem; max-width: 720px; }
.feature-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1px; background: var(--border); border: 1px solid var(--border); border-radius: 14px; overflow: hidden; }
@media (max-width: 900px) { .feature-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px) { .feature-grid { grid-template-columns: 1fr; } }
.feature { position: relative; isolation: isolate; padding: 1.75rem; background: var(--bg); transition: background var(--dur-2); }
.feature:hover { background: var(--surface); }
.feature h3 { font-size: 1rem; margin: .9rem 0 .4rem; }
.feature p { color: var(--text-2); font-size: .88rem; margin: 0; }
.f-ico { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 10px; border: 1px solid var(--border-2); background: var(--surface-2); transition: transform var(--dur-3) var(--ease-spring), background var(--dur-2); }
.feature:hover .f-ico { transform: translateY(-3px) rotate(-6deg); background: var(--text); color: var(--bg); }
.steps-lp { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
@media (max-width: 900px) { .steps-lp { grid-template-columns: 1fr; } }
.steps-lp li { display: flex; gap: .9rem; padding: 1.4rem; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); box-shadow: var(--elev-1); }
.steps-lp h3 { margin: 0 0 .35rem; font-size: 1rem; }
.steps-lp p { color: var(--text-2); font-size: .86rem; margin-bottom: .75rem; }
.steps-lp code { display: inline-block; }
.lp-security { display: grid; grid-template-columns: 1fr 1fr; gap: 2rem; align-items: center; }
@media (max-width: 900px) { .lp-security { grid-template-columns: 1fr; } }
.check-list { list-style: none; margin: 0; padding: 1.25rem 1.5rem; border: 1px solid var(--border-2); border-radius: 14px; background: var(--bg); font-family: var(--mono); font-size: .84rem; display: grid; gap: .7rem; box-shadow: var(--elev-2); }
.lp-final { text-align: center; padding: 5rem 1rem; border-top: 1px solid var(--border); background: radial-gradient(600px 240px at 50% 0%, rgba(127, 127, 127, .1), transparent); }
.lp-final h2 { font-size: clamp(1.6rem, 3.5vw, 2.6rem); letter-spacing: -0.04em; }
.lp-footer { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; padding: 1.5rem clamp(1rem, 4vw, 3rem); border-top: 1px solid var(--border); font-size: .76rem; }
.lp-footer .brand-mark { width: 20px; height: 20px; }

@media (prefers-reduced-motion: reduce) {
  .tw-line { opacity: 1; }
  .marquee-track { animation: none; }
  .nav-progress { display: none; }
}

/* v3 fixes */
.client-side > .card { margin-top: 0; }
.strength { flex-wrap: wrap; margin: .5rem 0 1.25rem; }
.strength em { flex: 1 1 100%; margin: .35rem 0 0; }
.sidebar-theme { display: none; }
@media (max-width: 960px) {
  .sidebar { z-index: 70; }
  body.nav-open .backdrop { z-index: 65; }
  .sidebar-theme { display: inline-flex; margin-left: auto; }
  .sidebar-close { margin-left: 0; }
  body.nav-open .tabbar { opacity: 0; pointer-events: none; transition: opacity .2s; }
}

/* ==========================================================================
   v4 — Telegram, motion polish, mobile refinements
   ========================================================================== */

/* Ripple */
.btn, .tabbar a, .tabbar button, .pick { position: relative; overflow: hidden; }
.ripple { position: absolute; border-radius: 50%; pointer-events: none; background: currentColor; opacity: .18; transform: scale(0); animation: ripple .6s var(--ease-out) forwards; }
@keyframes ripple { to { transform: scale(1); opacity: 0; } }

/* Typing eyebrow */
.eyebrow.typing::after { content: ""; display: inline-block; width: .5em; height: 1em; margin-left: 1px; background: var(--blue-solid); vertical-align: -0.15em; }

/* Table rows cascade in */
tbody tr.row-in { animation: row-in .42s var(--ease-cinema) both; }
@keyframes row-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* Focus ring flash when jumping to a section */
.flash-ring { animation: flash-ring 1.6s ease-out 1; }
@keyframes flash-ring { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--blue) 60%, transparent), var(--elev-1); } 100% { box-shadow: 0 0 0 14px transparent, var(--elev-1); } }

/* Spinner */
.spinner { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--border-3); border-top-color: var(--blue); animation: spin .8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Telegram ---------- */
.tg-badge { width: 26px; height: 26px; display: inline-grid; place-items: center; border-radius: 8px; background: var(--blue-solid); color: #fff; }
.tg-badge .icon { color: #fff; }
.tg-card { overflow: hidden; }
.tg-card::before { content: ""; position: absolute; right: -60px; top: -60px; width: 200px; height: 200px; border-radius: 50%; background: radial-gradient(closest-side, var(--blue-soft), transparent); pointer-events: none; z-index: -1; }
.tg-linked { display: flex; align-items: center; gap: .85rem; padding: .85rem; border: 1px solid var(--border-2); border-radius: 12px; background: var(--bg-2); margin-bottom: .9rem; }
.tg-linked p { margin: 0; }
.tg-avatar { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; background: var(--blue-solid); color: #fff; box-shadow: 0 0 0 4px var(--blue-soft); animation: pulse-ring 2.4s ease-out infinite; }
.tg-avatar .icon { width: 20px; height: 20px; }
@keyframes pulse-ring { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--blue-solid) 45%, transparent); } 80%, 100% { box-shadow: 0 0 0 12px transparent; } }
.tg-features { list-style: none; margin: 0 0 1rem; padding: 0; display: grid; gap: .4rem; font-size: .84rem; color: var(--text-2); }
.tg-features .icon { color: var(--green); margin-right: .25rem; }
.tg-steps { list-style: none; margin: 0 0 1rem; padding: 0; display: grid; gap: .5rem; font-size: .85rem; }
.tg-steps li { display: flex; align-items: center; gap: .6rem; }
.tg-open { margin-bottom: .25rem; }
.tg-open .icon { animation: plane 2.4s ease-in-out infinite; }
@keyframes plane { 0%, 100% { transform: translate(0, 0); } 50% { transform: translate(3px, -3px); } }
.tg-wait { display: flex; align-items: center; gap: .6rem; margin: .9rem 0 .4rem; font-size: .78rem; color: var(--text-2); }
.tg-pending.is-linked .spinner { border-color: var(--green); animation: none; }
.tg-pending.is-expired { opacity: .6; }
.tg-pending.is-expired .spinner { animation: none; border-top-color: var(--red); }
.tg-connect .icon { transition: transform var(--dur-3) var(--ease-spring); }
.tg-connect:hover .icon { transform: translate(3px, -3px) rotate(-8deg); }

/* ---------- Mobile refinements ---------- */
@media (max-width: 960px) {
  .topbar { transition: transform .28s var(--ease-cinema); }
  .topbar.is-hidden { transform: translateY(-100%); }
  .tabbar a.active .icon { animation: tab-pop .35s var(--ease-spring); }
  @keyframes tab-pop { 0% { transform: scale(.7); } 100% { transform: scale(1); } }
  .tabbar a.active { background: radial-gradient(60px 40px at 50% 30%, var(--blue-soft), transparent); }
  /* Stacked table rows look like cards */
  table.stackable tbody tr { margin: .55rem; border: 1px solid var(--border); border-radius: 12px; background: var(--bg-2); padding: .35rem 0; }
  table.stackable tbody tr:last-child { border-bottom: 1px solid var(--border); }
  .table-wrap { background: transparent; border: 0; box-shadow: none; }
  /* Bottom-sheet modals get a grab handle */
  .modal-box::before { content: ""; display: block; width: 40px; height: 4px; margin: 8px auto 0; border-radius: 4px; background: var(--border-3); }
  .hero { padding: 1.15rem; }
  .hero h1 { font-size: 1.45rem; }
  .hero-stats { gap: 1.25rem; }
  .card-head { margin-bottom: .75rem; }
  .grid-stats .stat { padding: .8rem .9rem; }
  .grid-stats .stat .value { font-size: 1.45rem; }
  .profile-hero { padding: 1.25rem; }
  .btn-row > .btn, .btn-row > .inline-form { flex: 1 1 auto; }
  .btn-row > .inline-form .btn { width: 100%; }
  .license-cards { grid-template-columns: 1fr; }
  .tile-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .75rem; }
  .tile-body { padding: .7rem; }
  .tile-meta { flex-wrap: wrap; gap: .4rem .7rem; }
}
@media (max-width: 420px) { .tile-grid { grid-template-columns: 1fr; } }
@media (min-width: 961px) { .modal-box::before { display: none; } }

@media (prefers-reduced-motion: reduce) {
  .tg-avatar, .tg-open .icon, .spinner { animation: none; }
  tbody tr.row-in { animation: none; }
}

/* ==========================================================================
   v5 — Tabs, calm home, people management, env/logs, Telegram widget, mobile
   ========================================================================== */

/* ---------- Tabs ---------- */
.tabset-head { position: relative; margin: 0 0 1.25rem; }
.tabnav { position: relative; display: flex; gap: .15rem; border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; }
.tabnav::-webkit-scrollbar { display: none; }
.tabnav a { position: relative; display: inline-flex; align-items: center; gap: .45rem; padding: .7rem .85rem; color: var(--text-2); text-decoration: none; font-size: .86rem; white-space: nowrap; border-radius: 8px 8px 0 0; transition: color var(--dur-1), background var(--dur-1); }
.tabnav a .icon { color: var(--text-3); transition: color var(--dur-1), transform var(--dur-2) var(--ease-spring); }
.tabnav a:hover { color: var(--text); background: var(--surface-2); }
.tabnav a:hover .icon { transform: translateY(-1px); }
.tabnav a.active { color: var(--text); font-weight: 500; }
.tabnav a.active .icon { color: var(--blue); }
.tabnav a .tg-logo { width: 14px; height: 14px; }
.tab-ink { position: absolute; left: 0; bottom: -1px; height: 2px; width: 0; background: var(--text); border-radius: 2px 2px 0 0; box-shadow: 0 0 10px color-mix(in srgb, var(--text) 35%, transparent); transition: transform .32s var(--ease-cinema), width .32s var(--ease-cinema); pointer-events: none; }
.tab-badge { font-family: var(--mono); font-size: .66rem; line-height: 1; padding: .18rem .38rem; border-radius: 999px; background: var(--surface-3); color: var(--text-2); border: 1px solid var(--border-2); }
.tabnav a.active .tab-badge { background: var(--text); color: var(--bg); border-color: var(--text); }
.tab-menu { display: none; }
.tab-panel { animation: none; }
.tab-panel.panel-in { animation: panel-in .34s var(--ease-cinema); }
.tab-panel[hidden] { display: none !important; }
@keyframes panel-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.narrow { max-width: 760px; }
.page-head.compact { margin-bottom: .9rem; }
.page-head.compact h1 { font-size: 1.45rem; }

/* Mobile: tabs collapse into a hamburger menu */
@media (max-width: 720px) {
  .tab-menu {
    display: flex; align-items: center; gap: .6rem; width: 100%; height: 46px; padding: 0 .9rem;
    border: 1px solid var(--border-2); border-radius: 10px; background: var(--bg-2); color: var(--text);
    font: inherit; font-weight: 500; cursor: pointer; box-shadow: var(--elev-1);
  }
  .tab-menu .chev { margin-left: auto; transition: transform var(--dur-2) var(--ease-out); }
  .tabset-head.menu-open .tab-menu .chev { transform: rotate(90deg); }
  .tabnav {
    position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 25; flex-direction: column; gap: 2px;
    padding: .35rem; border: 1px solid var(--border-2); border-radius: 12px; background: var(--bg); box-shadow: var(--elev-3);
    opacity: 0; transform: translateY(-6px) scale(.98); pointer-events: none; visibility: hidden;
    transition: opacity .18s ease, transform .22s var(--ease-cinema), visibility 0s linear .22s;
  }
  .tabset-head.menu-open .tabnav { opacity: 1; transform: none; pointer-events: auto; visibility: visible; transition: opacity .18s ease, transform .22s var(--ease-cinema); }
  .tabnav a { border-radius: 8px; padding: .75rem .8rem; }
  .tabnav a.active { background: var(--surface-3); }
  .tab-badge { margin-left: auto; }
  .tab-ink { display: none; }
}

/* ---------- Calm home ---------- */
.kpi-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .75rem; margin-bottom: 1rem; }
.kpi-row.three { grid-template-columns: repeat(3, minmax(0, 1fr)); margin: 0; }
.kpi-row .card + .card { margin-top: 0; }
a.kpi { text-decoration: none; color: inherit; }
.kpi { padding: 1rem 1.1rem; transition: transform var(--dur-3) var(--ease-cinema), border-color var(--dur-2), box-shadow var(--dur-3); }
a.kpi:hover { transform: translateY(-3px); border-color: var(--border-3); box-shadow: var(--elev-2); }
@media (max-width: 900px) { .kpi-row { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.home-grid { display: grid; grid-template-columns: 1.3fr 1fr; gap: 1rem; }
.home-grid .card + .card { margin-top: 0; }
@media (max-width: 900px) { .home-grid { grid-template-columns: 1fr; } }
.all-clear { display: flex; align-items: center; gap: .9rem; padding: .6rem 0; }
.all-clear p { margin: 0; }
.all-clear-dot { width: 14px; height: 14px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 0 color-mix(in srgb, var(--green) 50%, transparent); animation: live 2.2s infinite; flex: none; }
.attn-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .45rem; }
.attn { display: flex; align-items: center; gap: .7rem; padding: .7rem .8rem; border-radius: 10px; border: 1px solid var(--border); background: var(--bg-2); color: var(--text); text-decoration: none; font-size: .86rem; transition: border-color var(--dur-2), transform var(--dur-2) var(--ease-out), background var(--dur-2); }
.attn:hover { transform: translateX(3px); border-color: var(--border-3); background: var(--surface-2); }
.attn .chev { margin-left: auto; color: var(--text-3); }
.attn-warning > .icon:first-child { color: var(--amber); }
.attn-danger > .icon:first-child { color: var(--red); }
.attn-info > .icon:first-child { color: var(--blue); }
.attn-danger { border-color: color-mix(in srgb, var(--red) 30%, var(--border)); }
.quick-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .55rem; }
.quick-item { display: flex; align-items: center; gap: .6rem; padding: .8rem; border-radius: 10px; border: 1px solid var(--border); background: var(--bg-2); color: var(--text); text-decoration: none; font-size: .84rem; font-weight: 500; transition: transform var(--dur-2) var(--ease-spring), border-color var(--dur-2), background var(--dur-2); }
.quick-item:hover { transform: translateY(-2px); border-color: var(--border-3); background: var(--surface-2); }
.quick-item .icon { color: var(--text-2); }
.quick-item .tg-logo { width: 18px; height: 18px; }

/* ---------- People pages ---------- */
.person-hero { display: flex; align-items: center; gap: 1.1rem; padding: 1.25rem 1.4rem; margin-bottom: 1.1rem; border: 1px solid var(--border); border-radius: 14px; background: linear-gradient(180deg, var(--surface-2), var(--bg)); box-shadow: var(--elev-2); flex-wrap: wrap; }
.person-id { min-width: 0; flex: 1; }
.person-id h1 { margin: .1rem 0 .15rem; font-size: 1.4rem; letter-spacing: -0.03em; }
.person-id p { margin: 0 0 .45rem; }
.person-actions { margin-left: auto; display: flex; gap: .5rem; }
@media (max-width: 600px) { .person-actions { width: 100%; } .person-actions .inline-form, .person-actions .btn { flex: 1; width: 100%; } }

/* ---------- Environment editor ---------- */
.env-form { display: grid; gap: 1rem; }
.env-group { border: 1px solid var(--border); border-radius: 10px; padding: .4rem .9rem .8rem; margin: 0; background: var(--bg-2); }
.env-group legend { padding: 0 .4rem; font-size: .74rem; color: var(--text-3); }
.env-row { display: grid; grid-template-columns: 210px 1fr; gap: .75rem; align-items: center; padding: .35rem 0; border-bottom: 1px dashed var(--border); }
.env-row:last-child { border-bottom: 0; }
.env-row label { font-size: .78rem; color: var(--text-2); }
.env-row label::before { content: "$"; color: var(--blue); margin-right: .2rem; }
@media (max-width: 640px) { .env-row { grid-template-columns: 1fr; gap: .3rem; } }

/* ---------- Log viewer ---------- */
.logview { border: 1px solid var(--border-2); border-radius: 10px; background: var(--bg); font-family: var(--mono); font-size: .74rem; max-height: 560px; overflow: auto; position: relative; }
.logline { display: grid; grid-template-columns: 150px 70px 80px 1fr; gap: .6rem; padding: .32rem .75rem; border-bottom: 1px solid var(--border); white-space: nowrap; }
.logline:hover { background: var(--surface-2); }
.logline .lt { color: var(--text-3); }
.logline .ll { font-weight: 700; }
.logline .lc { color: var(--text-2); }
.logline .lm { white-space: normal; word-break: break-word; color: var(--text); }
.lv-debug .ll { color: var(--text-3); }
.lv-info .ll { color: var(--blue); }
.lv-notice .ll { color: var(--green); }
.lv-warning .ll { color: var(--amber); }
.lv-error .ll, .lv-critical .ll { color: var(--red); }
.lv-error, .lv-critical { background: var(--red-soft); }
@media (max-width: 720px) { .logline { grid-template-columns: 1fr; gap: .1rem; white-space: normal; } }

/* ---------- Telegram (official logo) ---------- */
.tg-logo { width: 22px; height: 22px; display: inline-block; vertical-align: middle; flex: none; border-radius: 50%; }
.tg-logo-xs { width: 16px; height: 16px; }
.tg-logo-sm { width: 22px; height: 22px; }
.tg-logo-lg { width: 56px; height: 56px; filter: drop-shadow(0 8px 20px rgba(42, 158, 217, .35)); }
.tg-logo.is-muted { filter: grayscale(1); opacity: .6; }
.card-head h2 .tg-logo, .card-head h3 .tg-logo { margin-right: .1rem; }
.tg-avatar { background: transparent; box-shadow: none; animation: none; width: 46px; height: 46px; }
.tg-avatar .tg-logo { width: 46px; height: 46px; animation: pulse-ring 2.4s ease-out infinite; }
.tg-connect-box { display: flex; align-items: center; gap: 1rem; padding: 1rem; border: 1px solid var(--border-2); border-radius: 12px; background: linear-gradient(135deg, rgba(42, 158, 217, .08), transparent 60%), var(--bg-2); margin-bottom: 1rem; }
.tg-connect-box h3 { margin: 0 0 .2rem; }
.tg-connect-box p { margin: 0; }
.tg-connect-box .tg-logo-lg { animation: float 4s ease-in-out infinite; }
.tg-widget { min-height: 48px; display: flex; align-items: center; margin-bottom: .75rem; }
.tg-widget iframe { border-radius: 8px; }
.tg-alt { margin-top: .5rem; border-top: 1px dashed var(--border-2); padding-top: .75rem; }
.tg-alt summary { cursor: pointer; font-size: .82rem; color: var(--text-2); list-style: none; display: flex; align-items: center; gap: .4rem; }
.tg-alt summary::-webkit-details-marker { display: none; }
.tg-alt summary::before { content: "›"; font-family: var(--mono); color: var(--blue); transition: transform var(--dur-2); display: inline-block; }
.tg-alt[open] summary::before { transform: rotate(90deg); }
.tg-empty { display: flex; align-items: center; gap: 1rem; }
.tg-empty p { margin: 0; }
.tg-linked .right { margin-left: auto; }

/* ---------- Mobile: hamburger navigation (no bottom bar), toasts on top ---------- */
@media (max-width: 960px) {
  body.app { padding-bottom: 0; }
  .topbar .menu-toggle { display: inline-flex; }
  .topbar .theme-toggle { display: none; }
  .tabbar { display: none !important; }
  .toasts { top: calc(.6rem + env(safe-area-inset-top, 0px)); bottom: auto; left: .6rem; right: .6rem; width: auto; flex-direction: column-reverse; }
  .toast { animation: toast-drop .32s var(--ease-cinema) both; }
  .toast.hide { animation: toast-up .22s ease-in forwards; }
  .menu-toggle .icon { transition: transform var(--dur-2) var(--ease-out); }
  body.nav-open .menu-toggle .icon { transform: rotate(90deg); }
  .sidebar .nav a { animation: none; }
  body.nav-open .sidebar .nav a { animation: nav-in .3s var(--ease-cinema) both; }
  body.nav-open .sidebar .nav a:nth-child(2) { animation-delay: .02s; }
  body.nav-open .sidebar .nav a:nth-child(3) { animation-delay: .04s; }
  body.nav-open .sidebar .nav a:nth-child(4) { animation-delay: .06s; }
  body.nav-open .sidebar .nav a:nth-child(5) { animation-delay: .08s; }
  body.nav-open .sidebar .nav a:nth-child(n+6) { animation-delay: .1s; }
  .content { padding-bottom: calc(2rem + env(safe-area-inset-bottom, 0px)); }
}
@keyframes toast-drop { from { opacity: 0; transform: translateY(-14px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes toast-up { to { opacity: 0; transform: translateY(-14px); } }
@keyframes nav-in { from { opacity: 0; transform: translateX(-10px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  .tab-panel.panel-in, .tg-avatar .tg-logo, .tg-connect-box .tg-logo-lg { animation: none; }
}
.tabset-head { z-index: 30; } .tabset-head.menu-open { z-index: 40; }

/* =====================================================================================
   v6 — touch scale, moderation UI, busy buttons, app mode (Android WebView)
   ===================================================================================== */

/* ---------- Drawer: no shadow band while closed (it leaked a dark gradient at the left edge) ---------- */
@media (max-width: 960px) {
  .sidebar { box-shadow: none; visibility: hidden; transition: transform .32s var(--ease-cinema), box-shadow .32s ease, visibility 0s linear .32s; }
  body.nav-open .sidebar { box-shadow: 30px 0 60px -20px rgba(0, 0, 0, .8); visibility: visible; transition: transform .32s var(--ease-cinema), box-shadow .32s ease, visibility 0s; }
}

/* ---------- Touch scale: readable text and 40px+ targets on phones ---------- */
@media (max-width: 720px) {
  body { font-size: 15px; }
  .btn { height: 40px; padding: 0 1rem; font-size: .9rem; }
  .btn-sm { height: 34px; padding: 0 .7rem; font-size: .82rem; }
  .btn-sm.btn-icon { width: 34px; }
  input:not([type=checkbox]):not([type=radio]):not([type=file]), select, textarea { font-size: 16px; min-height: 42px; }
  input[type=checkbox], input[type=radio] { width: 18px; height: 18px; }
  .nav a { padding: .62rem .7rem; font-size: .95rem; }
  table { font-size: .88rem; }
  .badge { font-size: .74rem; }
  .modal-foot .btn { flex: 1; }
}

/* ---------- Busy state for submitted buttons ---------- */
.btn.is-busy { position: relative; color: transparent !important; pointer-events: none; }
.btn.is-busy > * { visibility: hidden; }
.btn.is-busy::after {
  content: ""; position: absolute; inset: 0; margin: auto; width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid var(--text-3); border-top-color: var(--text); animation: spin .7s linear infinite;
}
.btn-primary.is-busy::after { border-color: color-mix(in srgb, var(--invert-text) 35%, transparent); border-top-color: var(--invert-text); }

/* ---------- Moderation ---------- */
.icon-xs { width: 12px; height: 12px; }
.btn-danger-ghost { color: var(--red); }
.btn-danger-ghost:hover { background: var(--red-soft); color: var(--red); }
.person-actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.row-actions { display: flex; gap: .35rem; justify-content: flex-end; align-items: center; }
.col-check { width: 1%; }
.col-actions { width: 1%; white-space: nowrap; text-align: right; }
tr.row-blocked td:not(.col-actions):not(.col-check) { opacity: .62; }
tr.row-blocked .user-cell strong { text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--red) 70%, transparent); }
input.is-valid { border-color: var(--green) !important; box-shadow: 0 0 0 3px var(--green-soft, rgba(0, 200, 83, .15)); }

.bulk-bar { padding: .6rem .8rem; margin-bottom: .9rem; display: none; }
.bulk-bar.is-active { display: block; animation: bulk-in .26s var(--ease-cinema) both; }
.bulk-bar-row { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; }
.bulk-bar .field { margin: 0; }
.bulk-count { display: inline-flex; align-items: center; gap: .35rem; font-family: var(--mono); font-size: .8rem; color: var(--text-2); }
@keyframes bulk-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
@media (max-width: 720px) {
  .bulk-bar.is-active { position: sticky; top: calc(var(--topbar) + .4rem); z-index: 25; box-shadow: var(--elev-3); }
  .bulk-bar-row > * { flex: 1 1 100%; }
  .bulk-count { flex: 0 0 auto; }
}

/* Account tables become cards on phones: no sideways scrolling to reach the actions. */
@media (max-width: 720px) {
  .table-wrap:has(.table-accounts) { border: 0; background: transparent; overflow: visible; }
  .table-accounts thead { display: none; }
  .table-accounts, .table-accounts tbody { display: block; }
  .table-accounts tr {
    display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: .25rem .6rem; align-items: center;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .75rem .8rem; margin-bottom: .6rem;
    animation: card-in .3s var(--ease-cinema) both;
  }
  .table-accounts td { display: block; border: 0; padding: 0; min-width: 0; }
  .table-accounts td.empty { grid-column: 1 / -1; text-align: center; padding: 1rem; }
  .table-accounts td.col-check { grid-row: 1; grid-column: 1; }
  .table-accounts td.col-main { grid-row: 1; grid-column: 2; min-width: 0; }
  .table-accounts td.col-actions { grid-row: 1; grid-column: 3; }
  .table-accounts td[data-label]:not(.col-main) { grid-column: 2 / -1; font-size: .84rem; color: var(--text-2); display: flex; flex-wrap: wrap; gap: .25rem .5rem; align-items: center; overflow-wrap: anywhere; }
  .table-accounts td[data-label]:not(.col-main)::before { content: attr(data-label); font-family: var(--mono); font-size: .7rem; color: var(--text-3); text-transform: lowercase; flex: 0 0 5.5rem; }
  .table-accounts .row-actions .btn span { display: none; }
  .table-accounts .row-actions .btn { width: 38px; min-width: 38px; padding: 0; flex: none; }
  .table-accounts .row-actions .btn-danger-ghost { border-color: color-mix(in srgb, var(--red) 35%, transparent); }
  .table-accounts tr:nth-child(2) { animation-delay: .03s; } .table-accounts tr:nth-child(3) { animation-delay: .06s; }
  .table-accounts tr:nth-child(4) { animation-delay: .09s; } .table-accounts tr:nth-child(n+5) { animation-delay: .12s; }
}
@keyframes card-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- App mode (Signet for Android): native feel ---------- */
html.in-app { -webkit-tap-highlight-color: transparent; overscroll-behavior-y: none; scrollbar-width: none; }
html.in-app::-webkit-scrollbar { display: none; }
html.in-app body { overscroll-behavior-y: none; background-attachment: scroll; }
html.in-app .topbar, html.in-app .sidebar, html.in-app .tabset-head, html.in-app .btn, html.in-app .badge,
html.in-app .nav, html.in-app th, html.in-app label, html.in-app .tab-menu { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
html.in-app a, html.in-app button { -webkit-touch-callout: none; }
html.in-app img { -webkit-user-drag: none; -webkit-touch-callout: none; }
html.in-app .btn:active, html.in-app .nav a:active, html.in-app .card a:active { transform: scale(.97); transition: transform .08s; }
html.in-app .nav-progress { height: 0; } /* the app draws its own progress bar */
html.in-app .landing-only, html.in-app [data-web-only] { display: none !important; }
html.in-app .content { animation: app-page-in .28s var(--ease-cinema) both; }
@keyframes app-page-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
html.in-app .toasts { top: .6rem; }
@media (prefers-reduced-motion: reduce) {
  html.in-app .content, .bulk-bar.is-active, .table-accounts tr { animation: none; }
}

/* ---------- Android app download page ---------- */
.app-promo { text-align: center; }
.app-promo h1 { margin-top: 1rem; }
.app-promo .sub { margin-bottom: 1.25rem; }
.app-promo-phone { width: 96px; height: 172px; margin: .25rem auto 0; border: 2px solid var(--border-3); border-radius: 18px; padding: 8px; background: var(--bg-2); box-shadow: var(--elev-3); animation: phone-float 5s ease-in-out infinite; }
.app-promo-screen { height: 100%; border-radius: 11px; background: var(--bg); border: 1px solid var(--border); display: flex; flex-direction: column; align-items: center; gap: 7px; padding: 14px 10px; }
.app-promo-mark .brand-mark { width: 30px; height: 30px; }
.app-promo-line { display: block; width: 100%; height: 6px; border-radius: 3px; background: var(--surface-3); animation: shimmer 1.8s ease-in-out infinite; }
.app-promo-line.short { width: 60%; }
.app-steps { text-align: left; margin: 1.25rem 0 1rem; padding-left: 1.2rem; color: var(--text-2); font-size: .9rem; display: grid; gap: .35rem; }
.app-verify { text-align: left; margin: .5rem 0 1rem; font-size: .85rem; }
.app-verify summary { cursor: pointer; color: var(--text-2); }
.app-verify code.break { display: block; word-break: break-all; padding: .5rem; background: var(--bg-2); border-radius: var(--radius-sm); margin-top: .35rem; font-size: .74rem; }
.auth-app-link { color: var(--text-2); text-decoration: none; display: inline-flex; align-items: center; gap: .3rem; }
.auth-app-link:hover { color: var(--text); }
@keyframes phone-float { 0%, 100% { transform: translateY(0) rotate(-2deg); } 50% { transform: translateY(-6px) rotate(2deg); } }
@keyframes shimmer { 0%, 100% { opacity: .55; } 50% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .app-promo-phone, .app-promo-line { animation: none; } }
.sidebar-app { display: flex; align-items: center; gap: .5rem; margin: .4rem .6rem; padding: .5rem .65rem; border: 1px dashed var(--border-2); border-radius: var(--radius-sm); color: var(--text-2); text-decoration: none; font-size: .8rem; transition: border-color .15s, color .15s, background .15s; }
.sidebar-app span { flex: 1; }
.sidebar-app:hover { border-color: var(--blue); color: var(--text); background: var(--surface-3); }
.sidebar-app:hover .icon:last-child { transform: translateX(2px); }
.sidebar-app .icon:last-child { transition: transform .15s; }
/* Row actions are icon buttons everywhere (labels live in title/aria-label) so the table never clips them. */
.table-accounts .row-actions .btn span { display: none; }
.table-accounts .row-actions .btn { width: 32px; padding: 0; }
.table-accounts td.col-main .user-cell strong { white-space: nowrap; }
@media (min-width: 721px) {
  .table-accounts .col-actions { position: sticky; right: 0; background: var(--surface); box-shadow: -12px 0 12px -12px rgba(0, 0, 0, .25); }
  .table-accounts thead .col-actions { background: var(--bg-2); }
  .table-accounts .row-actions .btn-danger-ghost { border-color: color-mix(in srgb, var(--red) 30%, transparent); }
}
.filters .push-right { margin-left: auto; }
.log-clear-row { gap: .5rem; flex-wrap: wrap; }
.remember-check { margin: .35rem 0 1rem; }

/* ---------- Notifications ---------- */
.bell { position: relative; }
.bell-count { position: absolute; top: 2px; right: 0; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px; background: var(--red); color: #fff; font-family: var(--mono); font-size: .62rem; line-height: 16px; text-align: center; box-shadow: 0 0 0 2px var(--bg); }
.bell.has-unread .icon { animation: bell-ring 1.4s var(--ease-cinema) 1; transform-origin: 50% 10%; }
.bell.ring .icon { animation: bell-ring .9s var(--ease-cinema) 1; transform-origin: 50% 10%; }
@keyframes bell-ring { 0%, 100% { transform: rotate(0); } 15% { transform: rotate(14deg); } 30% { transform: rotate(-12deg); } 45% { transform: rotate(8deg); } 60% { transform: rotate(-5deg); } 75% { transform: rotate(2deg); } }
.notif-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .5rem; }
.notif a { display: grid; grid-template-columns: auto 1fr auto; gap: .75rem; align-items: start; padding: .8rem .95rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); text-decoration: none; transition: border-color .15s, transform .15s, background .15s; animation: card-in .32s var(--ease-cinema) both; }
.notif:nth-child(2) a { animation-delay: .03s; } .notif:nth-child(3) a { animation-delay: .06s; } .notif:nth-child(4) a { animation-delay: .09s; } .notif:nth-child(n+5) a { animation-delay: .12s; }
.notif a:hover { border-color: var(--border-3); transform: translateY(-1px); }
.notif.unread a { border-left: 3px solid var(--blue); background: color-mix(in srgb, var(--blue) 5%, var(--surface)); }
.notif-ico { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; background: var(--surface-3); color: var(--text-2); }
.kind-security .notif-ico { color: var(--red); background: var(--red-soft); }
.kind-license .notif-ico { color: var(--blue); }
.kind-reset .notif-ico { color: var(--amber); background: var(--amber-soft); }
.notif-main { display: grid; gap: .15rem; min-width: 0; }
.notif-main strong { font-weight: 600; }
.notif-body { color: var(--text-2); font-size: .86rem; overflow-wrap: anywhere; }
.notif-time { color: var(--text-3); font-size: .72rem; white-space: nowrap; }
.notif.unread .notif-main strong::after { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--blue); margin-left: .45rem; vertical-align: middle; }
.notif-empty { text-align: center; padding: 2.5rem 1rem; }
.notif-empty-bell { width: 54px; height: 54px; margin: 0 auto 1rem; border-radius: 50%; display: grid; place-items: center; background: var(--surface-3); animation: phone-float 4s ease-in-out infinite; }
@media (max-width: 720px) {
  .notif a { grid-template-columns: auto 1fr; }
  .notif-time { grid-column: 2; }
}
@media (prefers-reduced-motion: reduce) { .bell .icon, .notif a, .notif-empty-bell { animation: none !important; } }

/* ---------- App mode: pull-to-refresh indicator (drawn by app.js) ---------- */
.ptr { display: none; }
html.in-app .ptr {
  display: grid; place-items: center; position: fixed; top: 0; left: 50%; z-index: 120; width: 40px; height: 40px; border-radius: 50%;
  background: var(--bg); color: var(--text-2); border: 1px solid var(--border-2); box-shadow: var(--elev-3);
  transform: translate(-50%, -48px); opacity: 0; pointer-events: none; will-change: transform, opacity;
}
html.in-app .ptr.ready { color: var(--blue); border-color: color-mix(in srgb, var(--blue) 45%, var(--border-2)); }
html.in-app .ptr.ptr-back { transition: transform .24s var(--ease-cinema), opacity .2s ease; }
html.in-app .ptr.spinning { transition: transform .2s var(--ease-cinema); opacity: 1; color: var(--blue); }
html.in-app .ptr.spinning svg { animation: spin .7s linear infinite; }

/* ---------- Scrolling: never drift sideways, keep inner scrollers contained ---------- */
@media (max-width: 960px) {
  html, body { overflow-x: clip; }                 /* clip (not hidden): sticky headers keep working */
  .table-wrap, .tabnav, .logview, .keybox { overscroll-behavior-x: contain; -webkit-overflow-scrolling: touch; }
  .modal-box, .sidebar .nav, .logview, .keybox { overscroll-behavior-y: contain; }
}

/* ---------- App mode: edge-to-edge, borderless, native-feeling surfaces ---------- */
html.in-app { scroll-behavior: auto; }
html.in-app body { background-image: none; }
@media (max-width: 960px) {
  html.in-app .content { padding: 1rem .85rem 2.5rem; }
  html.in-app .topbar { border-bottom: 0; box-shadow: none; background: var(--bg); backdrop-filter: none; }
  html.in-app .card, html.in-app .table-wrap, html.in-app .notif a, html.in-app .table-accounts tr,
  html.in-app .grid-stats, html.in-app .tabset-head .tab-menu, html.in-app .bulk-bar {
    border-color: transparent; box-shadow: none; background: var(--surface-2, var(--surface));
  }
  html.in-app .card { border-radius: 14px; }
  html.in-app .table-wrap { border-radius: 14px; margin-left: -.15rem; margin-right: -.15rem; }
  html.in-app th { background: transparent; }
  html.in-app .notif.unread a { border-left: 3px solid var(--blue); }
  html.in-app .modal-box { border: 0; border-radius: 18px 18px 0 0; }
  html.in-app .sidebar { border-right: 0; }
  html.in-app .person-hero, html.in-app .page-head { border: 0; }
  /* Sign-in screens: no framed card, the screen is the card */
  html.in-app .auth-wrap { background-image: none; padding: 1rem .9rem; }
  html.in-app .auth-card { border: 0; box-shadow: none; background: transparent; padding: 1.5rem .25rem; }
  html.in-app .auth-foot { border-top: 0; }
}
