:root {
  --bg: #f4f7fb;
  --ink: #0f172a;
  --muted: #64748b;
  --panel: #ffffff;
  --line: #e2e8f0;
  --rail: #0b1220;
  --rail-mid: #162032;
  --rail-text: #94a3b8;
  --accent: #0d9488;
  --accent-hover: #0f766e;
  --accent-soft: #ccfbf1;
  --ok: #047857;
  --ok-bg: #d1fae5;
  --warn: #b45309;
  --warn-bg: #fef3c7;
  --err: #be123c;
  --err-bg: #ffe4e6;
  --info: #1d4ed8;
  --info-bg: #dbeafe;
  --sans: "Inter", "Segoe UI", system-ui, sans-serif;
  --radius: 14px;
  --radius-sm: 10px;
  --card-pad: 1.2rem;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 8px 24px rgba(15, 23, 42, 0.05);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--ink);
  font-size: 14.5px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; }
h1, h2, h3 {
  font-weight: 600;
  margin: 0 0 0.35rem;
  letter-spacing: -0.03em;
  color: var(--ink);
}
h1 { font-size: 1.55rem; }
h2 { font-size: 0.95rem; display: flex; align-items: center; gap: 0.45rem; }
p { margin: 0 0 0.8rem; }
.muted { color: var(--muted); }
.figure {
  font-size: 1.85rem;
  font-weight: 600;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
  display: block;
  margin: 0.1rem 0 0.15rem;
}

.icon {
  width: 18px;
  height: 18px;
  stroke-width: 1.75;
  flex: 0 0 auto;
  display: inline-block;
  vertical-align: -3px;
}

.shell {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  min-height: 100vh;
}
.rail {
  background: var(--rail);
  color: var(--rail-text);
  padding: 1.25rem 0.85rem 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
}
.brand {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.2rem 0.5rem;
  text-decoration: none;
  color: #f8fafc;
}
.brand:hover { text-decoration: none; color: #fff; }
.logo-badge {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(145deg, #2dd4bf, #0f766e);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 1rem;
}
.mark {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.15;
}
.mark span {
  display: block;
  font-size: 0.64rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #64748b;
  margin-top: 0.12rem;
}
.nav { display: flex; flex-direction: column; gap: 0.2rem; }
.nav a {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--rail-text);
  padding: 0.55rem 0.75rem;
  border-radius: 10px;
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  transition: background 0.15s var(--ease), color 0.15s var(--ease);
}
.nav a .icon { opacity: 0.7; }
.nav a:hover {
  background: var(--rail-mid);
  color: #e2e8f0;
  text-decoration: none;
}
.nav a:hover .icon { opacity: 1; }
.nav a.active {
  background: #134e4a;
  color: #ccfbf1;
  text-decoration: none;
}
.nav a.active .icon { opacity: 1; color: #5eead4; }
.rail-foot {
  margin-top: auto;
  font-size: 0.78rem;
  color: #64748b;
  padding: 0.85rem 0.8rem;
  border-radius: 12px;
  background: var(--rail-mid);
}
.rail-foot a {
  color: #e2e8f0;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-top: 0.4rem;
}
.who { font-weight: 600; color: #e2e8f0; }

.workspace {
  min-width: 0;
  width: 100%;
  max-width: none;
  padding: 1.6rem 1.75rem 2.4rem;
}
.toprow {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 1rem;
  margin-bottom: 1.15rem;
  flex-wrap: wrap;
}
.kpis {
  display: flex;
  flex-wrap: wrap;
  gap: 0.85rem;
  margin-bottom: 1.25rem;
}
.kpi {
  background: var(--panel);
  border: 1px solid var(--line);
  padding: 1rem 1.05rem;
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  box-shadow: var(--shadow);
  flex: 1 1 190px;
  min-width: 0;
}
.kpi:has(.kpi-icon) {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0.75rem;
  align-items: center;
}
.kpi-icon {
  width: 40px;
  height: 40px;
  border-radius: 11px;
  background: var(--accent-soft);
  color: var(--accent-hover);
  display: grid;
  place-items: center;
}
.kpi b {
  display: block;
  font-size: 1.35rem;
  font-weight: 600;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}
.kpi span { color: var(--muted); font-size: 0.78rem; }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: var(--card-pad);
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
  min-width: 0;
}
.card > h2 { margin-bottom: 0.75rem; }

.table-wrap {
  overflow-x: auto;
  min-width: 0;
  -webkit-overflow-scrolling: touch;
}
.card.table-wrap {
  padding: 0;
}
.card.table-wrap > .pager {
  padding: 0.75rem 1.15rem;
  border-top: 1px solid var(--line);
}
.card:not(.table-wrap) > .table-wrap:last-child {
  margin: 0.65rem calc(-1 * var(--card-pad)) calc(-1 * var(--card-pad));
  border-top: 1px solid var(--line);
}

table.data {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.875rem;
}
table.data th,
table.data td {
  padding: 0.85rem 1.15rem;
  vertical-align: middle;
  text-align: left;
  line-height: 1.45;
}
table.data th:first-child,
table.data td:first-child { padding-left: 1.25rem; }
table.data th:last-child,
table.data td:last-child { padding-right: 1.25rem; }
table.data th {
  font-weight: 600;
  color: #475569;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: #f8fafc;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
table.data td {
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  white-space: nowrap;
}
table.data tbody tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover td { background: #f8fafc; }
table.data th.num,
table.data td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
table.data th.actions,
table.data td.actions {
  text-align: right;
  white-space: nowrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  background: var(--ink);
  color: #f8fafc;
  border: 0;
  padding: 0.52rem 0.95rem;
  border-radius: 10px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s var(--ease), transform 0.15s var(--ease);
  white-space: nowrap;
}
.btn:hover {
  background: #1e293b;
  color: #fff;
  text-decoration: none;
}
.btn:active { transform: translateY(1px); }
.btn.secondary {
  background: var(--panel);
  color: var(--ink);
  border: 1px solid var(--line);
}
.btn.secondary:hover { background: #f8fafc; color: var(--ink); }
.btn.ghost {
  background: transparent;
  color: var(--accent);
  padding: 0.3rem 0.45rem;
  box-shadow: none;
}
.btn.ghost:hover { background: var(--accent-soft); color: var(--accent-hover); }
.btn.danger { background: var(--err); }
.row-actions {
  display: flex;
  gap: 0.45rem;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: flex-end;
}
.row-actions form { margin: 0; display: inline; }

label { display: block; font-size: 0.78rem; color: var(--muted); margin: 0 0 0.28rem; font-weight: 500; }
input, select, textarea {
  font: inherit;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--ink);
  max-width: 100%;
  transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
}
.form-grid input,
.form-grid select,
.form-grid textarea,
.stack input,
.stack select,
.stack textarea,
.auth-card input,
.auth-card select,
.field input,
.field select,
.field textarea {
  width: 100%;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: #5eead4;
  box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.18);
}
textarea { min-height: 88px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.85rem 1rem; }
.form-grid input[type="checkbox"] {
  width: auto;
  padding: 0;
}
.stack label { margin-top: 0.75rem; }
.stack label:first-of-type { margin-top: 0; }
.auth-card form label { margin-top: 0.75rem; }
.auth-card form label:first-of-type { margin-top: 0; }
.errors { color: var(--err); font-size: 0.8rem; margin: 0.25rem 0 0; }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.75rem;
}
.toolbar > div { flex: 1 1 180px; min-width: 0; }
.toolbar > div label { margin-top: 0; }
.toolbar input,
.toolbar select {
  width: 100%;
}
.toolbar > input,
.toolbar > select {
  flex: 1 1 220px;
  min-width: 0;
  width: auto;
}
.toolbar .btn { flex: 0 0 auto; align-self: flex-end; }

.cell-form {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.4rem;
  margin: 0;
}
.cell-form input {
  width: 8.25rem;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.flash {
  padding: 0.7rem 0.9rem;
  border-radius: 10px;
  margin-bottom: 0.8rem;
  display: flex;
  align-items: center;
  gap: 0.55rem;
}
.flash.success { background: var(--ok-bg); color: var(--ok); }
.flash.error { background: var(--err-bg); color: var(--err); }
.flash.info { background: var(--info-bg); color: var(--info); }

.pill {
  display: inline-flex;
  align-items: center;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  padding: 0.18rem 0.5rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-hover);
  white-space: nowrap;
}
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.info { background: var(--info-bg); color: var(--info); }
.pill.err { background: var(--err-bg); color: var(--err); }

.split {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
}
.split > * { min-width: 0; }
.split.balanced { grid-template-columns: 1fr 1fr; }
.crumb {
  margin: 0 0 0.2rem;
  font-size: 0.8rem;
}
.crumb a { font-weight: 600; }
.profile-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem 1rem;
}
.profile-field span {
  display: block;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.15rem;
}
.profile-field b {
  font-weight: 600;
  font-size: 0.95rem;
}
.profile-field.wide { grid-column: 1 / -1; }
table.data td.wrap {
  white-space: normal;
  max-width: 22rem;
}
.usage {
  height: 8px;
  background: #e2e8f0;
  border-radius: 99px;
  overflow: hidden;
  display: flex;
  margin: 0.35rem 0 0.55rem;
}
.usage i { display: block; height: 100%; }
.usage .direct { background: #0d9488; }
.usage .ring { background: #64748b; }
.usage .fee { background: #cbd5e1; }

.auth-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 2rem;
  background:
    radial-gradient(900px 480px at 10% -10%, #ccfbf1 0%, transparent 55%),
    radial-gradient(700px 400px at 100% 0%, #e0f2fe 0%, transparent 50%),
    var(--bg);
}
.auth-card {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 1.85rem 1.7rem;
  box-shadow: var(--shadow);
}
.auth-card h1 { margin-bottom: 0.2rem; }
.auth-card .brand { color: var(--ink); margin-bottom: 1.15rem; }
.auth-card .mark { color: var(--ink); }
.setup-wrap { padding: 1.5rem; align-items: start; }
.setup-card { width: min(780px, 100%); }
.setup-steps {
  margin: 0 0 1.25rem;
  padding: 0.9rem 0.9rem 0.9rem 1.6rem;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 12px;
  font-size: 0.88rem;
  color: var(--muted);
}
.setup-steps li { margin: 0.35rem 0; }
.setup-steps b { color: var(--ink); }
.setup-steps code {
  font-size: 0.8em;
  background: #eef2f7;
  padding: 0.05rem 0.3rem;
  border-radius: 4px;
}
.setup-card .form-grid { margin-top: 0.4rem; }
.setup-card .wide { grid-column: 1 / -1; }
.setup-card .btn { margin-top: 0.2rem; }
.mfa-qr {
  display: grid;
  place-items: center;
  margin: 1rem 0 0.75rem;
  padding: 1rem;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  forced-color-adjust: none;
}
.mfa-qr img {
  display: block;
  width: min(240px, 100%);
  height: auto;
  background: #fff;
  image-rendering: pixelated;
  forced-color-adjust: none;
}
.mfa-manual {
  margin: 0 0 1rem;
  color: var(--muted);
  font-size: 0.85rem;
}
.mfa-manual summary {
  cursor: pointer;
  user-select: none;
}
.mfa-secret {
  margin: 0.55rem 0 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.82rem;
  letter-spacing: 0.04em;
  word-break: break-all;
  color: var(--ink);
}
.pager {
  display: flex;
  gap: 0.6rem;
  margin-top: 0;
  align-items: center;
}
.doc-frame {
  display: block;
  width: 100%;
  height: 70vh;
  min-height: 36rem;
  border: 0;
  background: #fff;
}
.stack input[type="checkbox"] {
  width: auto;
  padding: 0;
  border: 0;
  box-shadow: none;
}
.check-row {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-weight: 500;
}
.workspace-bar {
  display: flex;
  justify-content: flex-end;
  gap: 1rem;
  margin: 0 0 0.85rem;
}
.bell {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  position: relative;
  color: var(--ink);
  font-size: 0.88rem;
  font-weight: 600;
}
.bell .badge {
  min-width: 1.15rem;
  height: 1.15rem;
  padding: 0 0.28rem;
  border-radius: 999px;
  background: #0d9488;
  color: #fff;
  font-size: 0.7rem;
  display: grid;
  place-items: center;
}


@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
}

@media (max-width: 560px) {
  .shell { grid-template-columns: 1fr; }
  .rail {
    position: relative;
    height: auto;
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "brand foot"
      "nav nav";
    gap: 0.65rem 0.75rem;
    padding: 0.85rem;
  }
  .brand { grid-area: brand; }
  .nav {
    grid-area: nav;
    flex-direction: row;
    flex-wrap: nowrap;
    overflow-x: auto;
    gap: 0.15rem;
  }
  .nav a { white-space: nowrap; flex: 0 0 auto; }
  .rail-foot {
    grid-area: foot;
    margin-top: 0;
    padding: 0.45rem 0.65rem;
    font-size: 0.72rem;
  }
  .kpis, .form-grid, .split, .profile-fields { grid-template-columns: 1fr; }
  .workspace { padding: 1.1rem; }
}

.stage-stepper {
  display: flex;
  gap: 0.45rem;
  overflow-x: auto;
  padding: 0.35rem 0 1rem;
  margin-bottom: 0.5rem;
}
.stage-step {
  display: flex;
  align-items: flex-start;
  gap: 0.45rem;
  min-width: 140px;
  flex: 1 1 140px;
  padding: 0.65rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
}
.stage-step.done { border-color: #a7f3d0; background: #f0fdf9; }
.stage-step.current { border-color: #5eead4; box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.12); }
.stage-step.todo { opacity: 0.7; }
.stage-num {
  width: 22px;
  height: 22px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-hover);
  display: grid;
  place-items: center;
  font-size: 0.72rem;
  font-weight: 700;
  flex: 0 0 auto;
}
.stage-step.done .stage-num { background: var(--ok-bg); color: var(--ok); }
.stage-copy { display: flex; flex-direction: column; min-width: 0; }
.stage-copy strong { font-size: 0.78rem; line-height: 1.25; }
.stage-copy small { color: var(--muted); font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.04em; }
.check-row { display: flex; align-items: flex-start; gap: 0.5rem; font-size: 0.9rem; color: var(--ink); }
.check-row input { margin-top: 0.2rem; }
.cookie-banner {
  position: fixed;
  left: 1rem;
  right: 1rem;
  bottom: 1rem;
  z-index: 50;
  background: #0b1220;
  color: #e2e8f0;
  padding: 1rem 1.1rem;
  border-radius: 14px;
  display: flex;
  gap: 1rem;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow);
  max-width: 960px;
  margin: 0 auto;
}
.cookie-banner[hidden] { display: none !important; }
.cookie-banner p { margin: 0; font-size: 0.88rem; }
.cookie-banner a { color: #5eead4; }
.legal-shell { min-height: 100vh; background: var(--bg); display: flex; flex-direction: column; }
.legal-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.5rem;
  background: #fff;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.legal-nav nav { display: flex; gap: 1rem; flex-wrap: wrap; }
.legal-nav nav a { color: var(--ink); font-weight: 600; font-size: 0.88rem; }
.legal-main { width: 100%; max-width: 860px; margin: 0 auto; padding: 2rem 1.25rem 3rem; }
.legal-doc h2 { margin-top: 1.25rem; }
.legal-doc ol, .legal-doc ul { margin: 0 0 1rem 1.2rem; }
.legal-foot { padding: 1rem 1.5rem 2rem; color: var(--muted); font-size: 0.82rem; }
.cell-form { display: flex; gap: 0.35rem; align-items: center; flex-wrap: wrap; margin-top: 0.35rem; }
.cell-form input[type="file"] { max-width: 160px; }
