@font-face { font-family: 'Inter'; src: url(fonts/Inter.woff2) format('woff2'); font-weight: 100 900; font-display: swap; }
@font-face { font-family: 'Space Grotesk'; src: url(fonts/SpaceGrotesk.woff2) format('woff2'); font-weight: 300 700; font-display: swap; }

:root {
  --spark: #12B76A; --action: #0B7A53; --action-hover: #096746; --forest: #0B2B1D; --forest-2: #12392A; --forest-3: #1F5A40;
  --glow: #3DD68C; --mint: #E7F8EF; --paper: #F6F8F7; --white: #FFFFFF;
  --ink: #0B2B1D; --ink-2: #3F5A4D; --ink-3: #5B7468; --line: #DCE5E0; --line-2: #C5D3CB;
  --danger: #B42318; --danger-bg: #FDECEA; --warn: #8A5300; --warn-bg: #FFF4E0; --busy: #F5B042; --off: #7A8F85;
  --head: 'Space Grotesk', 'Inter', system-ui, sans-serif;
  --body: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --r: 10px;
}
* { box-sizing: border-box; }
html, body, #app { margin: 0; height: 100%; }
body { font: 15px/1.55 var(--body); color: var(--ink); background: var(--paper); -webkit-font-smoothing: antialiased; }
h1, h2, h3 { font-family: var(--head); font-weight: 700; letter-spacing: -0.02em; margin: 0; line-height: 1.15; }
h1 { font-size: 30px; } h2 { font-size: 20px; } h3 { font-size: 16px; letter-spacing: -0.01em; }
p { margin: 0; }
a { color: var(--action); text-underline-offset: 2px; }
a:hover { color: var(--action-hover); }
:focus-visible { outline: 3px solid var(--glow); outline-offset: 2px; border-radius: 4px; }
.muted { color: var(--ink-3); }
.small { font-size: 13px; }
.hidden { display: none !important; }
.mono { font-variant-numeric: tabular-nums; letter-spacing: 0.02em; }

/* ---------- controls ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 18px; border-radius: var(--r);
  border: 1px solid transparent; font: 600 15px var(--body); cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn-primary { background: var(--action); color: var(--white); }
.btn-primary:hover { background: var(--action-hover); color: var(--white); }
.btn-secondary { background: var(--white); color: var(--ink); border-color: var(--line-2); }
.btn-secondary:hover { background: var(--paper); color: var(--ink); }
.btn-ghost { background: transparent; color: var(--ink-2); padding: 0 12px; }
.btn-ghost:hover { background: rgba(11, 43, 29, 0.06); color: var(--ink); }
.btn-danger { background: var(--white); color: var(--danger); border-color: #F1B4AE; }
.btn-danger:hover { background: var(--danger-bg); color: var(--danger); }
.btn-sm { min-height: 36px; padding: 0 12px; font-size: 14px; }
.btn[disabled] { opacity: 0.55; cursor: progress; }
.btn-block { width: 100%; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 14px; font-weight: 600; }
.field .hint { font-size: 13px; color: var(--ink-3); font-weight: 400; }
input[type=text], input[type=email], input[type=password], input:not([type]), select, textarea {
  font: 15px var(--body); color: var(--ink); background: var(--white); border: 1px solid var(--line-2); border-radius: var(--r);
  min-height: 44px; padding: 0 12px; width: 100%; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--action); box-shadow: 0 0 0 3px rgba(18, 183, 106, 0.25); }
.code-input { font: 600 24px var(--head); letter-spacing: 0.3em; text-align: center; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; color: var(--ink-2); }
.check input { width: 18px; height: 18px; margin-top: 2px; accent-color: var(--action); flex: none; }
.form { display: flex; flex-direction: column; gap: 16px; }
.row2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.alert { border-radius: var(--r); padding: 12px 14px; font-size: 14px; }
.alert-error { background: var(--danger-bg); color: var(--danger); }
.alert-ok { background: var(--mint); color: #0B5D3B; }
.alert-warn { background: var(--warn-bg); color: var(--warn); }

.segmented { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; background: var(--paper); border: 1px solid var(--line); border-radius: 12px; padding: 5px; }
.segmented label { cursor: pointer; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented .seg { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; border-radius: 8px; }
.segmented .seg b { font-size: 14px; }
.segmented .seg small { font-size: 12px; color: var(--ink-3); }
.segmented input:checked + .seg { background: var(--white); box-shadow: 0 0 0 1px var(--line-2); }
.segmented input:focus-visible + .seg { outline: 3px solid var(--glow); }

/* ---------- auth layout ---------- */
.auth { min-height: 100%; display: grid; grid-template-columns: minmax(360px, 5fr) 7fr; }
.auth-side { background: var(--forest); color: var(--white); padding: 40px 48px; display: flex; flex-direction: column; justify-content: space-between; gap: 40px; }
.auth-side .logo { height: 36px; width: auto; display: block; align-self: flex-start; }
.auth-side h1 { font-size: 40px; line-height: 1.08; max-width: 12ch; }
.auth-side .facts { list-style: none; padding: 0; margin: 28px 0 0; display: flex; flex-direction: column; gap: 14px; color: #CFE9DB; max-width: 34ch; }
.auth-side .facts li { display: flex; gap: 12px; align-items: flex-start; }
.auth-side .facts svg { flex: none; margin-top: 3px; }
.auth-side .foot { font-size: 13px; color: #9FD8BC; }
.auth-main { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 40px 24px; background: var(--white); }
.auth-card { width: 100%; max-width: 420px; display: flex; flex-direction: column; gap: 22px; }
.auth-card h2 { font-size: 26px; }
.auth-card .lead { color: var(--ink-2); }
.auth-links { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-size: 14px; }
.langs { display: flex; gap: 4px; }
.langs button { border: 0; background: none; font: 600 13px var(--body); color: var(--ink-3); padding: 6px 8px; border-radius: 6px; cursor: pointer; }
.langs button[aria-pressed=true] { color: var(--ink); background: var(--paper); }
.auth-top { position: absolute; top: 20px; right: 24px; }
.wait { display: flex; gap: 14px; align-items: flex-start; background: var(--mint); border-radius: 12px; padding: 16px; }
.pulse { width: 12px; height: 12px; border-radius: 50%; background: var(--spark); margin-top: 6px; flex: none; animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(18, 183, 106, 0.5); } 50% { box-shadow: 0 0 0 8px rgba(18, 183, 106, 0); } }
@media (prefers-reduced-motion: reduce) { .pulse { animation: none; } }

/* ---------- app shell ---------- */
.shell { min-height: 100%; display: grid; grid-template-columns: 248px minmax(0, 1fr); }
.side { background: var(--forest); color: #CFE9DB; display: flex; flex-direction: column; padding: 20px 14px; gap: 18px; position: sticky; top: 0; height: 100vh; }
.side .logo { height: 28px; width: auto; display: block; margin: 4px 8px 4px; align-self: flex-start; }
.org-switch { display: flex; flex-direction: column; gap: 4px; padding: 0 4px; }
.org-switch label { font-size: 12px; color: #9FD8BC; padding-left: 4px; }
.org-switch select { background: var(--forest-2); color: var(--white); border-color: var(--forest-3); min-height: 40px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 8px; color: #CFE9DB; text-decoration: none; font-weight: 500; }
.nav a:hover { background: var(--forest-2); color: var(--white); }
.nav a[aria-current=page] { background: var(--forest-2); color: var(--white); box-shadow: inset 3px 0 0 var(--glow); }
.nav svg { flex: none; }
.side .spacer { flex: 1; }
.side .me { border-top: 1px solid var(--forest-3); padding: 14px 8px 0; display: flex; flex-direction: column; gap: 8px; }
.side .me a { color: #CFE9DB; text-decoration: none; display: flex; align-items: center; gap: 10px; }
.side .me a:hover { color: var(--white); }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--spark); color: var(--forest); display: grid; place-items: center; font: 700 13px var(--head); flex: none; }
.side .me .who { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.side .me .who small { color: #9FD8BC; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side .signout { background: none; border: 0; color: #9FD8BC; font: 500 13px var(--body); text-align: left; padding: 4px 0; cursor: pointer; }
.side .signout:hover { color: var(--white); }
.topbar-mobile { display: none; }

.main { padding: 32px 40px 64px; max-width: 1180px; width: 100%; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.page-head p { color: var(--ink-2); margin-top: 6px; }
.trial { font-size: 13px; color: var(--ink-2); background: var(--white); border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px; }

.panel { background: var(--white); border: 1px solid var(--line); border-radius: 14px; }
.panel + .panel { margin-top: 20px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 18px 20px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.panel-body { padding: 20px; }
.panel-body.form { max-width: 560px; }

.table-wrap { overflow-x: auto; }
table.list { width: 100%; border-collapse: collapse; font-size: 14px; }
table.list th { text-align: left; font-weight: 600; color: var(--ink-3); font-size: 13px; padding: 12px 20px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.list td { padding: 14px 20px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.list tr:last-child td { border-bottom: 0; }
table.list tr.click { cursor: pointer; }
table.list tr.click:hover td { background: #FAFCFB; }
.dname { font-weight: 600; }
.status { display: inline-flex; align-items: center; gap: 8px; font-weight: 500; white-space: nowrap; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--off); flex: none; }
.dot.on { background: var(--spark); }
.tag { display: inline-block; font-size: 12px; font-weight: 600; padding: 3px 8px; border-radius: 6px; background: var(--paper); color: var(--ink-2); border: 1px solid var(--line); white-space: nowrap; }
.tag.green { background: var(--mint); color: #0B5D3B; border-color: #CFE9DB; }
.tag.warn { background: var(--warn-bg); color: var(--warn); border-color: #F5D9A8; }

.empty { padding: 44px 24px; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 32px; align-items: start; }
.empty h2 { font-size: 24px; }
.steps { list-style: none; counter-reset: s; padding: 0; margin: 18px 0 0; display: flex; flex-direction: column; gap: 14px; }
.steps li { counter-increment: s; display: flex; gap: 12px; color: var(--ink-2); }
.steps li::before { content: counter(s); flex: none; width: 26px; height: 26px; border-radius: 50%; background: var(--mint); color: #0B5D3B; font: 700 13px var(--head); display: grid; place-items: center; }
.enroll { background: var(--forest); color: var(--white); border-radius: 14px; padding: 24px; display: flex; flex-direction: column; gap: 10px; }
.enroll .label { color: #9FD8BC; font-size: 13px; }
.enroll .code { font: 700 30px var(--head); letter-spacing: 0.06em; color: var(--glow); }
.enroll .row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
.enroll .btn-secondary { background: transparent; color: var(--white); border-color: var(--forest-3); }
.enroll .btn-secondary:hover { background: var(--forest-2); color: var(--white); }

.audit li { display: flex; gap: 16px; padding: 12px 20px; border-bottom: 1px solid var(--line); font-size: 14px; }
.audit li:last-child { border-bottom: 0; }
.audit time { color: var(--ink-3); white-space: nowrap; min-width: 128px; font-variant-numeric: tabular-nums; }
.audit .ip { color: var(--ink-3); margin-left: auto; white-space: nowrap; }
ul.audit { list-style: none; margin: 0; padding: 0; }

.kv { display: grid; grid-template-columns: 180px minmax(0, 1fr); gap: 10px 16px; font-size: 14px; }
.kv dt { color: var(--ink-3); }
.kv dd { margin: 0; }

.qr { background: var(--white); border: 1px solid var(--line); border-radius: 12px; padding: 12px; width: max-content; }
.qr img { display: block; width: 184px; height: 184px; image-rendering: pixelated; }
.codes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 16px; font: 600 15px var(--body); font-variant-numeric: tabular-nums; background: var(--paper); border-radius: 10px; padding: 14px 16px; }

.row-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row-actions.end { justify-content: flex-end; }
td.row-actions { display: table-cell; text-align: right; white-space: nowrap; }
td.row-actions > * + * { margin-left: 6px; }
.row-between { display: flex; justify-content: space-between; align-items: center; }
.side .langs button { color: #9FD8BC; }
.side .langs button[aria-pressed=true] { color: var(--white); background: var(--forest-2); }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
legend.field { padding: 0; margin-bottom: 6px; }
.steps { margin: 16px 0 0; }

/* ---------- dialog ---------- */
dialog { border: 0; border-radius: 16px; padding: 0; width: min(520px, calc(100% - 32px)); color: var(--ink); box-shadow: 0 24px 64px rgba(11, 43, 29, 0.28); }
dialog::backdrop { background: rgba(11, 43, 29, 0.45); }
dialog .d-head { padding: 20px 22px 0; }
dialog .d-body { padding: 16px 22px; display: flex; flex-direction: column; gap: 16px; }
dialog .d-foot { padding: 14px 22px 20px; display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.policy { display: flex; flex-direction: column; gap: 8px; }
.policy label { display: flex; gap: 12px; padding: 12px 14px; border: 1px solid var(--line-2); border-radius: 10px; cursor: pointer; }
.policy label:has(input:checked) { border-color: var(--action); background: var(--mint); }
.policy input { accent-color: var(--action); margin-top: 3px; flex: none; }
.policy b { display: block; font-size: 14px; }
.policy small { color: var(--ink-2); font-size: 13px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips label { display: inline-flex; gap: 6px; align-items: center; border: 1px solid var(--line-2); border-radius: 999px; padding: 6px 12px; font-size: 14px; cursor: pointer; }
.chips label:has(input:checked) { border-color: var(--action); background: var(--mint); }
.chips input { accent-color: var(--action); }

.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--forest); color: var(--white); padding: 12px 18px; border-radius: 10px; font-size: 14px; z-index: 50; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2); }

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  .auth { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .auth-main { justify-content: flex-start; padding-top: 20px; }
  .auth-side { padding: 24px; gap: 16px; }
  .auth-side h1 { font-size: 28px; max-width: none; }
  .auth-side .facts, .auth-side .foot { display: none; }
  .auth-top { position: static; align-self: flex-end; margin-bottom: 8px; }
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; display: none; }
  .side.open { display: flex; }
  .topbar-mobile { display: flex; align-items: center; justify-content: space-between; background: var(--forest); padding: 12px 16px; }
  .topbar-mobile img { height: 26px; }
  .topbar-mobile button { background: none; border: 1px solid var(--forest-3); color: var(--white); border-radius: 8px; min-height: 40px; padding: 0 12px; font: 600 14px var(--body); }
  .main { padding: 24px 16px 48px; }
  .empty { grid-template-columns: 1fr; padding: 28px 18px; }
  .row2 { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 1fr; gap: 2px; }
  .kv dd { margin-bottom: 10px; }
  table.list th, table.list td { padding: 12px 14px; }
  .hide-sm { display: none; }
}
