:root {
  --black: #0a0a0a;
  --ink: #171717;
  --muted: #717171;
  --line: #d8d8d8;
  --surface: #f4f4f1;
  --white: #ffffff;
  --orange: #ff5a1f;
  font-family: Inter, Arial, sans-serif;
  color: var(--ink);
  background: var(--surface);
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; background: var(--surface); }
button, input, select, textarea { font: inherit; }
button { border-radius: 0; }
.mono, .eyebrow, th, .state, .nav-item span { font-family: "Chivo Mono", Consolas, monospace; }
.app-shell { min-height: 100vh; display: grid; grid-template-columns: 248px minmax(0, 1fr); }
.sidebar { background: var(--black); color: var(--white); padding: 28px 20px; display: flex; flex-direction: column; }
.brand { display: flex; gap: 12px; align-items: center; color: inherit; text-decoration: none; font-weight: 700; font-size: 13px; line-height: 1.05; letter-spacing: .04em; }
.brand-mark { display: grid; place-items: center; width: 42px; height: 42px; color: var(--black); background: var(--orange); font-family: "Chivo Mono", monospace; font-size: 15px; }
nav { display: grid; gap: 2px; margin-top: 64px; }
.nav-item { color: #9b9b9b; text-decoration: none; padding: 14px 12px; border-left: 2px solid transparent; font-size: 14px; }
.nav-item span { display: inline-block; width: 34px; color: #5a5a5a; font-size: 10px; }
.nav-item:hover, .nav-item:focus-visible, .nav-item.is-active { color: var(--white); background: #171717; border-color: var(--orange); outline: 0; }
.sidebar-foot { margin-top: auto; border-top: 1px solid #303030; padding: 18px 12px 0; display: grid; gap: 5px; font-size: 12px; }
.sidebar-foot span:last-child { color: #8f8f8f; }
main { min-width: 0; padding: 36px 42px 56px; }
.topbar { display: flex; justify-content: space-between; align-items: flex-end; padding-bottom: 28px; border-bottom: 1px solid var(--ink); }
.eyebrow { color: var(--muted); font-size: 10px; letter-spacing: .12em; }
h1, h2 { margin: 5px 0 0; letter-spacing: -.04em; }
h1 { font-size: clamp(32px, 4vw, 50px); line-height: 1; }
h2 { font-size: 23px; }
.operator { display: flex; align-items: center; gap: 10px; font-size: 12px; }
.operator-identity { display: grid; gap: 2px; }
.operator small { color: var(--muted); }
.status-dot { width: 9px; height: 9px; background: var(--orange); }
.logout-button { min-height: 38px; margin-left: 10px; border: 1px solid var(--ink); background: var(--white); color: var(--ink); padding: 9px 12px; font: 600 10px "Chivo Mono", monospace; letter-spacing: .04em; cursor: pointer; }
.logout-button:hover, .logout-button:focus-visible { border-color: var(--orange); color: var(--orange); outline: 0; }
.logout-button:disabled { cursor: wait; opacity: .55; }
.metrics { display: grid; grid-template-columns: repeat(4, 1fr); border: 1px solid var(--ink); border-top: 0; background: var(--white); }
.metrics article { min-height: 126px; padding: 18px; border-right: 1px solid var(--line); display: grid; align-content: space-between; }
.metrics article:last-child { border-right: 0; }
.metrics span, .metrics small { color: var(--muted); font-size: 10px; font-family: "Chivo Mono", monospace; }
.metrics strong { font-size: 36px; letter-spacing: -.04em; }
.metrics .metric-accent strong { color: var(--orange); }
.panel { margin-top: 34px; border: 1px solid var(--ink); background: var(--white); }
.panel-head { padding: 22px; display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; border-bottom: 1px solid var(--ink); }
.search { display: grid; gap: 6px; width: min(340px, 45%); font: 10px "Chivo Mono", monospace; color: var(--muted); }
.search input { width: 100%; border: 1px solid var(--line); border-radius: 0; padding: 10px 12px; background: var(--white); color: var(--ink); outline: 0; }
.search input:focus { border-color: var(--orange); }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 930px; }
th { padding: 13px 16px; text-align: left; color: var(--muted); background: #f8f8f6; font-size: 9px; letter-spacing: .08em; font-weight: 500; }
td { padding: 15px 16px; border-top: 1px solid var(--line); font-size: 12px; }
td strong, td small { display: block; }
td small { margin-top: 4px; color: var(--muted); font-size: 10px; }
.state { display: inline-flex; align-items: center; gap: 6px; font-size: 9px; }
.state::before { content: ""; width: 7px; height: 7px; background: var(--ink); }
.state-ok::before { background: var(--orange); }
.text-action { border: 0; background: transparent; color: var(--ink); padding: 6px 0; font: 600 10px "Chivo Mono", monospace; cursor: pointer; }
.text-action:hover, .text-action:focus-visible { color: var(--orange); outline: 0; }
.notice { position: fixed; right: 18px; bottom: 18px; width: min(360px, calc(100vw - 36px)); border: 1px solid var(--orange); background: var(--black); color: var(--white); padding: 14px 16px; font-size: 12px; }
.handoff { position: fixed; z-index: 10; inset: 0; display: grid; place-items: center; padding: 24px; background: rgb(10 10 10 / 82%); }
.handoff-card { width: min(520px, 100%); border: 1px solid var(--orange); background: var(--white); padding: 30px; }
.handoff-card p { color: var(--muted); line-height: 1.6; }
.handoff-actions { display: grid; gap: 10px; margin-top: 24px; }
.handoff-button { display: grid; place-items: center; text-decoration: none; }
.handoff-close { min-height: 40px; border: 0; background: transparent; color: var(--muted); font: 600 10px "Chivo Mono", monospace; cursor: pointer; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
[hidden] { display: none !important; }
.auth-screen { min-height: 100vh; display: grid; grid-template-columns: minmax(260px, .8fr) minmax(420px, 1.2fr); background: var(--white); }
.auth-brand { display: flex; align-items: flex-start; gap: 12px; padding: 34px; background: var(--black); color: var(--white); font-weight: 700; font-size: 13px; line-height: 1.05; letter-spacing: .04em; }
.auth-card { width: min(480px, calc(100% - 48px)); margin: auto; padding: 52px 0; }
.auth-card > p { color: var(--muted); font-size: 14px; line-height: 1.6; }
.form-grid { display: grid; gap: 16px; margin-top: 30px; }
.form-grid label, .action-form label { display: grid; gap: 7px; color: var(--muted); font: 10px "Chivo Mono", monospace; letter-spacing: .06em; }
.form-grid input, .action-form input, .action-form select, .action-form textarea { width: 100%; border: 1px solid var(--line); border-radius: 0; padding: 12px; background: var(--white); color: var(--ink); outline: 0; }
.form-grid input:focus, .action-form input:focus, .action-form select:focus, .action-form textarea:focus { border-color: var(--orange); }
.primary, .secondary, .danger { min-height: 44px; border: 1px solid var(--black); padding: 11px 14px; font: 600 10px "Chivo Mono", monospace; letter-spacing: .05em; cursor: pointer; }
.primary { background: var(--orange); color: var(--black); border-color: var(--orange); }
.secondary { background: var(--black); color: var(--white); }
.danger { background: var(--white); color: #a11; border-color: #a11; }
.primary:hover, .primary:focus-visible { background: var(--black); color: var(--white); outline: 0; }
.secondary:hover, .secondary:focus-visible { background: var(--orange); color: var(--black); border-color: var(--orange); outline: 0; }
.form-error { min-height: 20px; color: #a11 !important; font: 11px "Chivo Mono", monospace; }
.qr { width: 220px; padding: 12px; border: 1px solid var(--ink); background: var(--white); }
.qr svg { display: block; width: 100%; height: auto; }
.manual-key { overflow-wrap: anywhere; font-size: 11px !important; }
.recovery-panel { margin-top: 28px; border: 1px solid var(--orange); padding: 20px; }
.recovery-panel pre { padding: 14px; background: var(--surface); font: 12px/1.8 "Chivo Mono", monospace; }
.recovery-panel button { width: 100%; margin-top: 8px; }
.drawer { position: fixed; z-index: 5; inset: 0 0 0 auto; width: min(520px, 100vw); overflow-y: auto; border-left: 1px solid var(--ink); background: var(--white); padding: 32px; }
.drawer-close { position: absolute; right: 22px; top: 18px; border: 0; background: transparent; font-size: 28px; cursor: pointer; }
.drawer > p { color: var(--muted); font-size: 11px; }
.drawer-actions { display: grid; gap: 18px; margin-top: 30px; }
.action-form { display: grid; gap: 12px; border-top: 1px solid var(--line); padding-top: 18px; }
.action-form h3 { margin: 0; font-size: 14px; }
.action-form textarea { min-height: 72px; resize: vertical; }
.danger-zone { border-color: #a11; }
.filters { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; padding: 20px 22px; border-bottom: 1px solid var(--line); }
.filters label { display: grid; gap: 7px; color: var(--muted); font: 10px "Chivo Mono", monospace; }
.filters input, .filters select { width: 100%; border: 1px solid var(--line); border-radius: 0; padding: 10px 12px; background: var(--white); }
.filters button { align-self: end; }
.panel-footer { display: flex; justify-content: center; padding: 18px; border-top: 1px solid var(--line); }
.module-note { margin: 0; padding: 14px 22px; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 12px; }
.admin-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.admin-actions select { border: 1px solid var(--line); padding: 7px; background: var(--white); font: 10px "Chivo Mono", monospace; }
.danger-text { color: #a11; }
.logo-preview { display: grid; grid-template-columns: 96px 1fr; align-items: center; gap: 12px; border: 1px solid var(--line); padding: 10px; }
.logo-preview img { width: 96px; height: 64px; object-fit: contain; background: var(--surface); }
.logo-preview span { color: var(--muted); font: 10px "Chivo Mono", monospace; }

@media (max-width: 860px) {
  .auth-screen { grid-template-columns: 1fr; }
  .auth-brand { min-height: 110px; }
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { min-height: auto; padding: 18px; }
  nav { grid-template-columns: repeat(3, 1fr); margin-top: 24px; }
  .sidebar-foot { display: none; }
  main { padding: 24px 18px 40px; }
  .metrics { grid-template-columns: repeat(2, 1fr); }
  .metrics article:nth-child(2) { border-right: 0; }
  .metrics article:nth-child(-n + 2) { border-bottom: 1px solid var(--line); }
  .filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 560px) {
  nav { grid-template-columns: 1fr; }
  .topbar { align-items: flex-start; flex-direction: column; gap: 18px; }
  .operator { width: 100%; flex-wrap: wrap; }
  .logout-button { margin-left: auto; }
  .panel-head { align-items: stretch; flex-direction: column; }
  .search { width: 100%; }
  .filters { grid-template-columns: 1fr; }
}
