:root {
  --ink: #17201d;
  --muted: #65716c;
  --line: #dce3df;
  --paper: #ffffff;
  --surface: #f4f7f5;
  --green: #08765a;
  --green-dark: #055d47;
  --mint: #dff4eb;
  --coral: #da5a46;
  --amber: #a65f00;
  --amber-bg: #fff0d2;
  --red-bg: #fce7e3;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--surface);
  font-synthesis: none;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: var(--surface); }
button, input, textarea { font: inherit; letter-spacing: 0; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.topbar { height: 68px; display: flex; align-items: center; justify-content: space-between; padding: 0 32px; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.94); }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font-size: 17px; font-weight: 750; }
.brand-mark { display: grid; place-items: center; width: 31px; height: 31px; border-radius: 7px; background: var(--green); color: #fff; font-size: 16px; }
.quiet-link, .text-button { border: 0; background: transparent; color: var(--muted); text-decoration: none; font-size: 14px; padding: 8px; }
.quiet-link:hover, .text-button:hover { color: var(--green); }
.topbar-actions { display: flex; align-items: center; gap: 12px; }

.user-shell { width: min(1180px, calc(100% - 48px)); margin: 0 auto; min-height: calc(100vh - 128px); display: grid; grid-template-columns: minmax(0, .78fr) minmax(520px, 1.22fr); align-items: center; gap: 72px; padding: 48px 0; }
.redeem-view, .activation-view { width: 100%; }
.intro { max-width: 470px; }
.eyebrow { margin: 0 0 12px; color: var(--green); font-size: 11px; font-weight: 800; letter-spacing: 1.6px; }
h1 { margin: 0; font-size: clamp(34px, 6vw, 54px); line-height: 1.08; letter-spacing: 0; }
.intro > p:last-child, .login-copy > p:last-child { margin: 18px 0 0; color: var(--muted); font-size: 17px; line-height: 1.7; }
.redeem-form { margin-top: 34px; padding: 24px; border: 1px solid var(--line); border-radius: 8px; background: var(--paper); box-shadow: 0 12px 32px rgba(25, 49, 40, .06); }
.redeem-form.locked { background: #f8faf9; box-shadow: none; }
.redeem-form.locked input { color: var(--muted); background: #eef2f0; }
label, .field-label { display: block; margin-bottom: 9px; color: var(--muted); font-size: 13px; font-weight: 650; }
.input-action { display: grid; grid-template-columns: 1fr auto; gap: 10px; }
input, textarea { width: 100%; border: 1px solid #cbd5d0; border-radius: 6px; background: #fff; color: var(--ink); outline: 0; }
input { height: 48px; padding: 0 14px; }
input:focus, textarea:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(8, 118, 90, .12); }
.primary, .secondary { min-height: 46px; border-radius: 6px; padding: 0 20px; border: 1px solid transparent; font-weight: 720; white-space: nowrap; }
.primary { background: var(--green); color: #fff; }
.primary:hover { background: var(--green-dark); }
.secondary { border-color: #bdc9c3; background: #fff; color: var(--ink); }
.secondary:hover:not(:disabled) { border-color: var(--green); color: var(--green); }
button:disabled { cursor: not-allowed; opacity: .55; }
.form-error { min-height: 20px; margin: 10px 0 -4px; color: var(--coral); font-size: 13px; }
.service-spec { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; margin-top: 28px; padding-top: 20px; border-top: 1px solid var(--line); }
.service-spec div { display: flex; flex-direction: column; gap: 4px; }
.service-spec strong { font-size: 13px; }
.service-spec span { color: var(--muted); font-size: 11px; }

.activation-view { min-height: 570px; }
.empty-activation { min-height: 570px; display: grid; place-content: center; justify-items: center; border: 1px dashed #c8d2cd; border-radius: 8px; background: rgba(255,255,255,.46); text-align: center; }
.empty-state-mark { width: 58px; height: 58px; display: grid; place-items: center; margin-bottom: 22px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--green); font-size: 18px; font-weight: 800; }
.empty-activation h2 { font-size: 25px; }
.empty-activation > p:last-child { margin: 9px 0 0; color: var(--muted); font-size: 13px; }
.activation-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 30px; }
.activation-heading h2 { font-size: 30px; }
.status-badge { display: inline-flex; align-items: center; gap: 7px; border-radius: 999px; padding: 8px 12px; font-size: 12px; font-weight: 750; white-space: nowrap; }
.status-badge.waiting { color: var(--amber); background: var(--amber-bg); }
.status-badge.received { color: var(--green); background: var(--mint); }
.status-badge.expired, .status-badge.cancelled { color: var(--coral); background: var(--red-bg); }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.phone-panel { padding: 25px 28px; border: 1px solid var(--line); border-bottom: 0; border-radius: 8px 8px 0 0; background: #fff; }
.phone-meta { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.phone-meta .field-label { margin-bottom: 9px; }
.country-label { margin-bottom: 9px; color: var(--green); font-size: 12px; font-weight: 750; }
.phone-row, .received-code { min-height: 46px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.phone-row strong { font-size: 30px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.icon-command { border: 0; border-radius: 5px; background: var(--surface); color: var(--green); padding: 8px 11px; font-size: 12px; font-weight: 750; }
.code-panel { min-height: 152px; padding: 25px 28px; border-radius: 0 0 8px 8px; background: var(--ink); color: #fff; }
.code-panel .field-label { color: #aeb9b4; }
.waiting-code { min-height: 62px; display: flex; align-items: center; gap: 14px; color: #c8d0cc; }
.pulse-bars { display: flex; align-items: center; gap: 4px; height: 20px; }
.pulse-bars i { display: block; width: 3px; height: 8px; background: #65c9a9; animation: pulse 1s infinite ease-in-out; }
.pulse-bars i:nth-child(2) { height: 17px; animation-delay: .15s; }
.pulse-bars i:nth-child(3) { height: 11px; animation-delay: .3s; }
@keyframes pulse { 50% { transform: scaleY(.45); opacity: .55; } }
.received-code strong { color: #7ce0be; font-size: 44px; letter-spacing: 7px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.code-panel .icon-command { background: #2b3934; color: #8ce4c7; }
.time-grid { display: grid; grid-template-columns: 1fr 1fr; margin: 22px 0; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.time-grid div { padding: 18px 20px; }
.time-grid div + div { border-left: 1px solid var(--line); }
.time-grid span { display: block; margin-bottom: 5px; color: var(--muted); font-size: 12px; }
.time-grid strong { font-size: 17px; font-variant-numeric: tabular-nums; }
.action-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.inline-message { min-height: 20px; margin: 11px 0 2px; color: var(--muted); font-size: 13px; text-align: center; }
.active-activation > .text-button { display: block; margin: 6px auto 0; }
.redemption-history { border-top: 1px solid var(--line); background: #fff; }
.history-inner { width: min(1180px, calc(100% - 48px)); margin: 0 auto; padding: 38px 0 48px; }
.history-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 18px; }
.history-heading h2 { font-size: 24px; }
.history-table-wrap { border: 1px solid var(--line); border-radius: 8px; overflow-x: auto; }
.history-table { min-width: 760px; }
.history-table td { height: 58px; }
.history-phone { display: inline-flex; align-items: center; gap: 8px; }
.history-copy { border: 0; background: transparent; color: var(--green); padding: 4px; font-size: 11px; font-weight: 700; }
.history-status { display: inline-flex; border-radius: 999px; padding: 5px 8px; background: var(--surface); color: var(--muted); font-size: 11px; font-weight: 700; }
.history-status.waiting { background: var(--amber-bg); color: var(--amber); }
.history-status.received { background: var(--mint); color: var(--green); }
.history-status.expired, .history-status.cancelled { background: var(--red-bg); color: var(--coral); }
.history-code { color: var(--green); font-weight: 800; letter-spacing: 1px; }
.history-empty { padding: 48px 20px; color: var(--muted); font-size: 13px; text-align: center; }
footer { min-height: 60px; display: flex; justify-content: space-between; align-items: center; padding: 0 32px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; }

.admin-body main { width: min(1400px, calc(100% - 48px)); margin: 0 auto; }
.login-view { min-height: calc(100vh - 68px); display: grid; grid-template-columns: 1.2fr .8fr; align-items: center; gap: 80px; max-width: 1060px; margin: 0 auto; }
.login-copy h1 { max-width: 650px; }
.login-form { padding: 30px; border: 1px solid var(--line); border-radius: 8px; background: #fff; box-shadow: 0 14px 40px rgba(25,49,40,.07); }
.login-form .primary { width: 100%; margin-top: 12px; }
.dashboard { padding: 44px 0 70px; }
.dashboard-heading, .section-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; }
.dashboard-heading h1 { font-size: 38px; }
.dashboard-heading > div > p:last-child { color: var(--muted); font-size: 12px; }
.compact { min-height: 38px; padding: 0 14px; font-size: 13px; }
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); margin: 30px 0; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #fff; }
.stats-grid div { padding: 22px; }
.stats-grid div + div { border-left: 1px solid var(--line); }
.stats-grid span { display: block; color: var(--muted); font-size: 12px; }
.stats-grid strong { display: block; margin-top: 8px; font-size: 28px; }
.policy-band { display: grid; grid-template-columns: minmax(220px, .75fr) minmax(480px, 1.25fr); align-items: center; gap: 44px; padding: 26px 0; border-top: 1px solid var(--line); }
.policy-copy p:last-child { margin: 6px 0 0; color: var(--muted); font-size: 13px; }
.policy-form { min-width: 0; }
.control-label { display: block; margin-bottom: 8px; color: var(--muted); font-size: 12px; font-weight: 700; }
.tier-selector { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 4px; border: 1px solid var(--line); border-radius: 7px; background: #fff; }
.tier-selector button { min-width: 0; min-height: 58px; display: flex; flex-direction: column; align-items: flex-start; justify-content: center; gap: 3px; padding: 8px 12px; border: 1px solid transparent; border-radius: 5px; background: transparent; color: var(--ink); }
.tier-selector button span { color: var(--muted); font-size: 10px; }
.tier-selector button.active { border-color: var(--green); background: var(--mint); color: var(--green-dark); }
.tier-selector button.active span { color: var(--green); }
.tier-selector button:disabled { background: var(--surface); color: var(--muted); }
.tier-loading { grid-column: 1 / -1; padding: 18px; color: var(--muted); font-size: 12px; text-align: center; }
.policy-actions { min-height: 42px; display: flex; align-items: flex-end; justify-content: flex-end; gap: 14px; margin-top: 9px; }
.policy-actions span { color: var(--muted); font-size: 12px; }
.generator-band { display: flex; align-items: center; justify-content: space-between; gap: 28px; padding: 24px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
h2 { margin: 0; font-size: 19px; }
.generator-band p, .section-heading p { margin: 5px 0 0; color: var(--muted); font-size: 13px; }
.generator-form { display: grid; grid-template-columns: 130px 100px auto; align-items: end; gap: 10px; }
.generator-form label { margin: 0; }
.generator-form input { height: 42px; margin-top: 7px; }
.generator-form .primary { min-height: 42px; }
.generated-panel { padding: 28px 0; border-bottom: 1px solid var(--line); }
.generated-panel textarea { height: 132px; margin-top: 16px; padding: 14px; resize: vertical; font: 13px/1.55 ui-monospace, SFMono-Regular, Menlo, monospace; }
.records-section { padding-top: 34px; }
.filters { display: flex; padding: 3px; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.filter { min-height: 32px; padding: 0 12px; border: 0; border-radius: 4px; background: transparent; color: var(--muted); font-size: 12px; }
.filter.active { background: var(--ink); color: #fff; }
.records-toolbar { min-height: 42px; display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-top: 16px; }
.records-toolbar span { color: var(--muted); font-size: 12px; }
.records-search { display: grid; grid-template-columns: auto minmax(220px, 320px) auto auto; align-items: center; gap: 8px; margin: 0; }
.records-search label { margin: 0; color: var(--muted); font-size: 12px; font-weight: 700; }
.records-search input { height: 34px; margin: 0; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; text-transform: uppercase; }
.records-pagination { display: flex; align-items: center; gap: 10px; }
.records-pagination button { min-width: 74px; }
.table-wrap { margin-top: 18px; border: 1px solid var(--line); border-radius: 8px; overflow-x: auto; background: #fff; }
table { width: 100%; border-collapse: collapse; min-width: 900px; }
th, td { padding: 14px 16px; border-bottom: 1px solid #e8ecea; text-align: left; font-size: 13px; white-space: nowrap; }
th { background: #f7f9f8; color: var(--muted); font-size: 11px; text-transform: uppercase; }
tbody tr:hover { background: #f8faf9; }
tbody tr:last-child td { border-bottom: 0; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.table-status { display: inline-flex; align-items: center; border-radius: 999px; padding: 5px 8px; background: var(--surface); color: var(--muted); font-size: 11px; font-weight: 700; }
.table-status.received, .table-status.unused { background: var(--mint); color: var(--green); }
.table-status.waiting, .table-status.processing { background: var(--amber-bg); color: var(--amber); }
.table-status.expired, .table-status.cancelled { background: var(--red-bg); color: var(--coral); }
.code-cell { color: var(--green); font-weight: 800; letter-spacing: 1px; }
.empty-state { padding: 60px 20px; color: var(--muted); text-align: center; }

@media (max-width: 980px) {
  .user-shell { width: min(680px, calc(100% - 40px)); grid-template-columns: 1fr; align-items: start; gap: 42px; }
  .intro { max-width: 620px; }
  .activation-view, .empty-activation { min-height: 480px; }
}

@media (max-width: 760px) {
  .topbar { height: 60px; padding: 0 16px; }
  .user-shell { width: min(100% - 28px, 620px); min-height: calc(100vh - 110px); grid-template-columns: 1fr; align-items: start; gap: 34px; padding: 34px 0; }
  h1 { font-size: 37px; }
  .redeem-form { margin-top: 30px; padding: 20px; }
  .input-action { grid-template-columns: 1fr; }
  .service-spec { gap: 12px; }
  .activation-view, .empty-activation { min-height: 340px; }
  .history-inner { width: min(100% - 28px, 620px); padding: 30px 0 38px; }
  .history-table-wrap { border: 0; overflow: visible; }
  .history-table { display: block; min-width: 0; }
  .history-table thead { display: none; }
  .history-table tbody { display: grid; gap: 10px; }
  .history-table tr { display: grid; grid-template-columns: 1fr 1fr; gap: 13px 16px; padding: 16px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
  .history-table td { min-width: 0; height: auto; display: flex; flex-direction: column; align-items: flex-start; gap: 5px; padding: 0; border: 0; white-space: normal; overflow-wrap: anywhere; }
  .history-table td::before { content: attr(data-label); color: var(--muted); font-size: 10px; font-weight: 700; }
  .history-table td:first-child, .history-table td:last-child { grid-column: 1 / -1; }
  .history-empty { border: 1px solid var(--line); border-radius: 8px; }
  .activation-heading { align-items: flex-start; flex-direction: column; gap: 14px; }
  .phone-panel, .code-panel { padding: 22px 20px; }
  .phone-row strong { font-size: 24px; }
  .received-code strong { font-size: 35px; letter-spacing: 4px; }
  .action-row { grid-template-columns: 1fr; }
  footer { min-height: 50px; padding: 0 16px; }
  footer span:last-child { display: none; }
  .admin-body main { width: min(100% - 28px, 1400px); }
  .login-view { min-height: calc(100vh - 60px); grid-template-columns: 1fr; align-content: center; gap: 34px; padding: 40px 0; }
  .login-copy h1 { font-size: 36px; }
  .dashboard { padding-top: 30px; }
  .dashboard-heading { align-items: flex-start; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .stats-grid div:nth-child(3) { border-left: 0; border-top: 1px solid var(--line); }
  .stats-grid div:nth-child(4) { border-top: 1px solid var(--line); }
  .generator-band { align-items: flex-start; flex-direction: column; }
  .policy-band { grid-template-columns: 1fr; gap: 20px; }
  .tier-selector { grid-template-columns: 1fr; }
  .tier-selector button { align-items: center; flex-direction: row; justify-content: space-between; min-height: 46px; }
  .generator-form { width: 100%; grid-template-columns: 1fr 1fr; }
  .generator-form .primary { grid-column: 1 / -1; }
  .section-heading { align-items: flex-start; flex-direction: column; }
  .filters { width: 100%; overflow-x: auto; }
  .filter { flex: 1; }
  .records-toolbar { align-items: flex-start; flex-direction: column; }
  .records-search { width: 100%; grid-template-columns: 1fr 1fr; }
  .records-search label, .records-search input { grid-column: 1 / -1; }
  .records-pagination { width: 100%; justify-content: space-between; }
  .records-pagination button { flex: 1; }
}
