:root {
  --ink: #171b19;
  --muted: #68706b;
  --paper: #f3f5f1;
  --surface: #ffffff;
  --line: #d9ded9;
  --line-strong: #b7c0b9;
  --green: #087355;
  --green-soft: #e5f3ed;
  --amber: #a66e08;
  --amber-soft: #fff3d9;
  --red: #bd3e31;
  --red-soft: #fae8e5;
  --blue: #285f83;
  --blue-soft: #e5f0f7;
  --shadow: 0 16px 44px rgba(25, 34, 29, 0.08);
  --sans: "Noto Sans SC", sans-serif;
  --mono: "IBM Plex Mono", monospace;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--paper); }
body { margin: 0; min-height: 100vh; color: var(--ink); background: var(--paper); font-family: var(--sans); font-size: 14px; letter-spacing: 0; }
button, input, select { font: inherit; letter-spacing: 0; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
[hidden] { display: none !important; }

.brand { display: inline-flex; align-items: center; gap: 11px; min-width: 128px; }
.brand-mark { display: grid; place-items: center; width: 38px; height: 38px; color: #fff; background: var(--ink); border-radius: 6px; }
.brand-mark svg { width: 20px; height: 20px; }
.brand strong { display: block; font-size: 17px; line-height: 1.1; }
.brand small { display: block; margin-top: 4px; color: var(--muted); font: 500 9px/1 var(--mono); }
.system-state { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); font-size: 12px; }
.system-state > span { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 4px var(--green-soft); }
.section-index, .eyebrow { margin: 0; color: var(--green); font: 600 10px/1.2 var(--mono); text-transform: uppercase; }

.public-shell { display: grid; grid-template-rows: auto 1fr auto; }
.public-header { display: flex; align-items: center; justify-content: space-between; min-height: 76px; padding: 16px clamp(22px, 5vw, 72px); border-bottom: 1px solid var(--line); }
.redeem-layout { display: grid; grid-template-columns: minmax(280px, 0.82fr) minmax(430px, 1.18fr); gap: clamp(48px, 8vw, 120px); align-items: center; width: min(1120px, calc(100% - 44px)); margin: 0 auto; padding: 56px 0; }
.redeem-intro h1 { margin: 14px 0 18px; font-size: 54px; line-height: 1.12; font-weight: 700; }
.lead { max-width: 420px; margin: 0; color: var(--muted); font-size: 16px; line-height: 1.8; }
.process-list { margin: 54px 0 0; border-top: 1px solid var(--line-strong); }
.process-list div { display: grid; grid-template-columns: 48px 1fr; align-items: center; min-height: 53px; border-bottom: 1px solid var(--line); }
.process-list dt { color: var(--green); font: 500 11px var(--mono); }
.process-list dd { margin: 0; font-size: 13px; }
.redeem-workspace { min-width: 0; }
.workspace-panel, .login-panel { padding: clamp(26px, 4vw, 42px); background: var(--surface); border: 1px solid var(--line); border-radius: 7px; box-shadow: var(--shadow); }
.panel-heading, .dialog-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; margin-bottom: 32px; }
.panel-heading h2, .dialog-heading h2 { margin: 7px 0 0; font-size: 21px; line-height: 1.25; }
.panel-heading > svg { width: 24px; height: 24px; color: var(--green); }
label { display: block; margin: 0 0 8px; color: #39413d; font-size: 12px; font-weight: 600; }
.input-wrap, .compact-input { display: flex; align-items: center; gap: 10px; background: #fbfcfa; border: 1px solid var(--line-strong); border-radius: 5px; transition: border-color .18s, box-shadow .18s; }
.input-wrap { min-height: 50px; padding: 0 14px; margin-bottom: 20px; }
.input-wrap:focus-within, .compact-input:focus-within { border-color: var(--green); box-shadow: 0 0 0 3px var(--green-soft); }
.input-wrap svg, .compact-input svg { flex: 0 0 auto; width: 17px; height: 17px; color: var(--muted); }
input, select { width: 100%; min-width: 0; color: var(--ink); background: transparent; border: 0; outline: 0; }
.input-wrap input { height: 48px; font-family: var(--mono); font-size: 13px; }
select, input[type="number"], .form-grid input { min-height: 40px; padding: 8px 10px; background: #fbfcfa; border: 1px solid var(--line-strong); border-radius: 5px; }
.turnstile-wrap { min-height: 67px; margin-bottom: 18px; overflow: hidden; }

.primary-command, .secondary-command, .danger-command { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; padding: 0 16px; border: 1px solid transparent; border-radius: 5px; font-weight: 600; white-space: nowrap; }
.primary-command { color: #fff; background: var(--green); }
.primary-command:hover { background: #075e46; }
.primary-command:disabled { opacity: .55; cursor: wait; }
.primary-command:not(.compact) { width: 100%; min-height: 49px; }
.secondary-command { color: var(--ink); background: #fff; border-color: var(--line-strong); }
.secondary-command:hover { background: var(--paper); }
.danger-command { color: var(--red); background: #fff; border-color: #e4b8b2; }
.danger-command:hover { background: var(--red-soft); }
.primary-command svg, .secondary-command svg, .danger-command svg { width: 16px; height: 16px; }
.form-note { display: flex; align-items: flex-start; gap: 7px; margin: 16px 0 0; color: var(--muted); font-size: 11px; line-height: 1.6; }
.form-note svg { flex: 0 0 auto; width: 15px; height: 15px; margin-top: 1px; color: var(--green); }
.icon-command { display: inline-grid; place-items: center; flex: 0 0 auto; width: 36px; height: 36px; padding: 0; color: var(--muted); background: transparent; border: 1px solid var(--line); border-radius: 5px; }
.icon-command:hover { color: var(--ink); background: var(--paper); border-color: var(--line-strong); }
.icon-command svg { width: 17px; height: 17px; }

.activation-panel { min-height: 420px; }
.activation-topline { display: flex; align-items: center; justify-content: space-between; margin-bottom: 36px; }
.status-badge { display: inline-flex; align-items: center; gap: 8px; min-height: 28px; padding: 0 10px; color: var(--amber); background: var(--amber-soft); border-radius: 4px; font-size: 11px; font-weight: 600; }
.status-badge > span { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.status-badge.success { color: var(--green); background: var(--green-soft); }
.status-badge.error { color: var(--red); background: var(--red-soft); }
.countdown { font: 600 15px var(--mono); }
.value-block { padding-bottom: 28px; border-bottom: 1px solid var(--line); }
.value-label { display: block; margin-bottom: 9px; color: var(--muted); font-size: 11px; }
.value-line { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.value-line strong { min-width: 0; overflow-wrap: anywhere; font: 600 26px/1.3 var(--mono); }
.code-block { min-height: 142px; padding: 26px 0; }
.code-value strong { font-size: 36px; color: var(--green); }
.code-waiting { display: flex; gap: 8px; align-items: center; height: 45px; }
.code-waiting span { width: 10px; height: 10px; background: var(--line-strong); border-radius: 2px; animation: waiting 1.2s infinite ease-in-out; }
.code-waiting span:nth-child(2) { animation-delay: .15s; }
.code-waiting span:nth-child(3) { animation-delay: .3s; }
@keyframes waiting { 0%, 70%, 100% { transform: translateY(0); background: var(--line-strong); } 35% { transform: translateY(-6px); background: var(--green); } }
.sms-text { margin: 14px 0 0; padding: 11px 12px; color: #4b5550; background: var(--paper); border-left: 3px solid var(--line-strong); font-size: 12px; line-height: 1.65; white-space: pre-wrap; }
.activation-actions { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.public-footer { display: flex; justify-content: space-between; gap: 20px; padding: 20px clamp(22px, 5vw, 72px); color: var(--muted); border-top: 1px solid var(--line); font-size: 11px; }

.login-shell { background: var(--ink); }
.login-layout { display: grid; grid-template-columns: 1fr minmax(380px, 460px); gap: 80px; align-items: center; width: min(980px, calc(100% - 44px)); min-height: 100vh; margin: auto; padding: 50px 0; }
.login-brand { color: #fff; }
.login-brand .brand-mark { color: var(--ink); background: #fff; }
.login-brand .brand small { color: #9ba49f; }
.login-brand .section-index { margin-top: 90px; color: #65c3a4; }
.login-brand h1 { margin: 12px 0 0; font-size: 56px; }
.login-panel { box-shadow: 0 28px 80px rgba(0, 0, 0, .35); }

.admin-shell { display: grid; grid-template-columns: 238px minmax(0, 1fr); background: #f6f7f4; }
.admin-sidebar { position: sticky; top: 0; display: flex; flex-direction: column; height: 100vh; padding: 25px 20px 18px; color: #e8ede9; background: var(--ink); }
.admin-sidebar .brand { margin: 0 8px 38px; }
.admin-sidebar .brand-mark { color: var(--ink); background: #edf3ef; }
.admin-sidebar .brand small { color: #89938d; }
.admin-nav { display: grid; gap: 4px; }
.admin-nav button { display: flex; align-items: center; gap: 11px; width: 100%; min-height: 42px; padding: 0 12px; color: #aeb8b2; background: transparent; border: 0; border-radius: 5px; text-align: left; }
.admin-nav button:hover { color: #fff; background: #252b28; }
.admin-nav button.active { color: #fff; background: var(--green); }
.admin-nav svg { width: 17px; height: 17px; }
.sidebar-footer { display: flex; align-items: center; justify-content: space-between; margin-top: auto; padding: 16px 6px 0; border-top: 1px solid #303733; }
.sidebar-footer .system-state { color: #aeb8b2; }
.sidebar-footer .icon-command { color: #aeb8b2; border-color: #39423d; }
.admin-main { min-width: 0; padding: 0 clamp(22px, 4vw, 58px) 58px; }
.admin-topbar { display: flex; align-items: center; justify-content: space-between; min-height: 100px; border-bottom: 1px solid var(--line); }
.admin-topbar h1 { margin: 7px 0 0; font-size: 24px; }
.admin-view { display: none; padding-top: 32px; }
.admin-view.active { display: block; animation: enter .22s ease-out; }
@keyframes enter { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }
.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 44px; background: var(--line); border: 1px solid var(--line); gap: 1px; }
.metric { min-height: 128px; padding: 22px; background: var(--surface); }
.metric span { color: var(--muted); font-size: 11px; }
.metric strong { display: block; margin-top: 20px; font: 600 30px var(--mono); }
.section-heading { display: flex; justify-content: space-between; margin-bottom: 16px; }
.section-heading h2, .toolbar h2, .settings-copy h2 { margin: 7px 0 0; font-size: 19px; }
.status-grid { display: grid; grid-template-columns: repeat(3, 1fr); border-top: 1px solid var(--line-strong); }
.status-item { display: flex; align-items: center; justify-content: space-between; min-height: 56px; padding-right: 24px; border-bottom: 1px solid var(--line); }
.status-item:nth-child(3n+2), .status-item:nth-child(3n+3) { padding-left: 24px; border-left: 1px solid var(--line); }
.status-item span { color: var(--muted); font-size: 11px; }
.status-item strong { font: 600 16px var(--mono); }

.toolbar { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin-bottom: 18px; }
.toolbar-fields, .toolbar-actions, .form-actions { display: flex; align-items: center; gap: 10px; }
.interaction-filters { display: grid; grid-template-columns: repeat(5, minmax(150px, 1fr)); gap: 8px; margin-bottom: 12px; }
.interaction-filters input, .interaction-filters select { min-width: 0; }
.interaction-filters button { justify-self: stretch; }
.compact-input { width: 230px; min-height: 40px; padding: 0 11px; }
.compact-input input { height: 38px; font-size: 12px; }
.toolbar select { width: auto; min-width: 140px; }
.bulk-bar { display: flex; align-items: center; gap: 16px; min-height: 42px; padding: 0 12px; color: var(--muted); background: #ecefea; border: 1px solid var(--line); border-bottom: 0; font-size: 11px; }
.bulk-bar span { margin-right: auto; }
.bulk-bar button { padding: 4px 0; color: var(--ink); background: transparent; border: 0; font-size: 12px; }
.text-danger { color: var(--red) !important; }
.data-table-wrap { width: 100%; overflow: auto; background: var(--surface); border: 1px solid var(--line); }
.data-table { width: 100%; min-width: 850px; border-collapse: collapse; }
.data-table th { height: 42px; padding: 0 12px; color: var(--muted); background: #f1f3ef; border-bottom: 1px solid var(--line); font-size: 10px; font-weight: 600; text-align: left; white-space: nowrap; }
.data-table td { height: 50px; padding: 8px 12px; border-bottom: 1px solid #e7eae6; font-size: 12px; white-space: nowrap; }
.data-table tr:last-child td { border-bottom: 0; }
.data-table tr:hover td { background: #fafbf9; }
.data-table button { color: var(--blue); background: transparent; border: 0; font-size: 11px; }
.data-table input[type="checkbox"] { width: 15px; height: 15px; accent-color: var(--green); }
.table-foot { margin: 10px 0 0; color: var(--muted); font-size: 11px; text-align: right; }
.table-status { display: inline-flex; align-items: center; min-height: 23px; padding: 0 7px; border-radius: 4px; background: var(--paper); font: 500 10px var(--mono); }
.table-status.ACTIVE, .table-status.COMPLETED, .table-status.CODE_RECEIVED { color: var(--green); background: var(--green-soft); }
.table-status.RESERVED, .table-status.WAITING_SMS, .table-status.WAITING_RETRY { color: var(--amber); background: var(--amber-soft); }
.table-status.MANUAL_REVIEW, .table-status.DISABLED { color: var(--red); background: var(--red-soft); }
.table-status.CONSUMED, .table-status.CANCELLED, .table-status.EXPIRED, .table-status.DELETED { color: var(--muted); background: #ecefea; }

.settings-layout { display: grid; grid-template-columns: minmax(220px, .7fr) minmax(380px, 1.3fr); gap: 70px; align-items: start; max-width: 900px; }
.settings-copy p { color: var(--muted); line-height: 1.8; }
.settings-form { padding: 28px; background: var(--surface); border: 1px solid var(--line); border-radius: 6px; }
.settings-form .form-actions { justify-content: flex-end; margin-top: 26px; }

.app-dialog { width: min(470px, calc(100% - 30px)); padding: 28px; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 7px; box-shadow: 0 28px 90px rgba(18, 24, 20, .25); }
.app-dialog::backdrop { background: rgba(20, 25, 22, .48); }
.wide-dialog { width: min(760px, calc(100% - 30px)); }
.app-dialog .dialog-heading { margin-bottom: 24px; }
.app-dialog label { margin-top: 16px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 28px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.form-grid label { margin-top: 0; }
.form-grid input { display: block; margin-top: 7px; }
.result-content { max-height: 55vh; margin: 0; padding: 18px; overflow: auto; color: #dce8e1; background: #171b19; border-radius: 5px; font: 12px/1.7 var(--mono); white-space: pre-wrap; overflow-wrap: anywhere; }
.toast { position: fixed; right: 22px; bottom: 22px; z-index: 100; max-width: min(390px, calc(100% - 44px)); padding: 13px 16px; color: #fff; background: var(--ink); border-radius: 5px; box-shadow: var(--shadow); opacity: 0; transform: translateY(8px); pointer-events: none; transition: opacity .2s, transform .2s; }
.toast.visible { opacity: 1; transform: none; }
.toast.error { background: var(--red); }

@media (max-width: 900px) {
  .redeem-layout { grid-template-columns: 1fr; gap: 42px; align-items: start; max-width: 620px; }
  .redeem-intro h1 { font-size: 42px; }
  .process-list { margin-top: 32px; }
  .login-layout { grid-template-columns: 1fr; gap: 42px; max-width: 500px; }
  .login-brand .section-index { margin-top: 48px; }
  .login-brand h1 { font-size: 42px; }
  .admin-shell { grid-template-columns: 76px minmax(0, 1fr); }
  .admin-sidebar { padding-inline: 12px; }
  .admin-sidebar .brand { min-width: 0; justify-content: center; margin-inline: 0; }
  .admin-sidebar .brand > span:last-child, .admin-nav button { font-size: 0; }
  .admin-nav button { justify-content: center; padding: 0; }
  .admin-nav svg { width: 19px; height: 19px; }
  .sidebar-footer { justify-content: center; }
  .sidebar-footer .system-state { display: none; }
  .metric-grid { grid-template-columns: 1fr 1fr; }
  .status-grid { grid-template-columns: 1fr 1fr; }
  .status-item:nth-child(n) { padding-inline: 16px; border-left: 0; }
  .status-item:nth-child(even) { border-left: 1px solid var(--line); }
  .settings-layout { grid-template-columns: 1fr; gap: 24px; }
}

@media (max-width: 620px) {
  .public-header { min-height: 68px; padding-inline: 18px; }
  .public-header .system-state { display: none; }
  .redeem-layout { width: calc(100% - 28px); padding: 34px 0; }
  .redeem-intro h1 { font-size: 36px; }
  .workspace-panel, .login-panel { padding: 23px 18px; }
  .activation-actions { grid-template-columns: 1fr; }
  .public-footer { display: grid; padding-inline: 18px; }
  .login-layout { width: calc(100% - 28px); padding: 28px 0; }
  .admin-shell { display: block; padding-bottom: 66px; }
  .admin-sidebar { position: fixed; z-index: 20; top: auto; bottom: 0; left: 0; right: 0; width: 100%; height: 62px; padding: 8px 10px; border-top: 1px solid #39423d; }
  .admin-sidebar .brand, .sidebar-footer { display: none; }
  .admin-nav { display: grid; grid-template-columns: repeat(6, 1fr); gap: 2px; }
  .admin-nav button { min-height: 45px; }
  .admin-main { padding: 0 14px 30px; }
  .admin-topbar { min-height: 80px; }
  .metric-grid { grid-template-columns: 1fr 1fr; }
  .metric { min-height: 105px; padding: 16px; }
  .metric strong { margin-top: 14px; font-size: 24px; }
  .toolbar { align-items: stretch; flex-direction: column; }
  .toolbar-fields, .toolbar-actions { width: 100%; }
  .toolbar-fields > *, .toolbar-actions > * { flex: 1; min-width: 0; }
  .interaction-filters { grid-template-columns: 1fr; }
  .status-grid { grid-template-columns: 1fr; }
  .status-item:nth-child(n) { border-left: 0; }
  .form-grid { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
