@charset "UTF-8";
:root {
  color-scheme: light;
  --bg: #f7f7fa;
  --surface: #fff;
  --text: #202127;
  --muted: #767780;
  --accent: #ed243b;
  --accent-dark: #cf152c;
  --accent-soft: #fff0f2;
  --line: #e6e6ec;
  --radius: 24px;
  --safe-top: max(env(safe-area-inset-top, 0px), var(--tg-safe-top, 0px));
  --safe-bottom: max(env(safe-area-inset-bottom, 0px), var(--tg-safe-bottom, 0px));
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  color: var(--text);
  background: #eaeaf0;
  font-synthesis: none;
  -webkit-font-smoothing: antialiased;
}

* { box-sizing: border-box; }
.app-shell.app-shell {width:min(100%,1440px);}
body { margin: 0; }
button, input { font: inherit; }
button { color: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
button:focus-visible, input:focus-visible { outline: 3px solid #ed243b55; outline-offset: 3px; }
[hidden] { display: none !important; }
.icon-library { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: 0 0 auto; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

.app-shell {
  width: min(100%, 1040px);
  min-height: 100dvh;
  margin: auto;
  background: var(--bg);
  box-shadow: 0 20px 90px #2824380d;
  position: relative;
}

.app-header {
  padding: calc(20px + var(--safe-top)) 34px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #efeff3;
}
.brand { display: flex; align-items: center; gap: 13px; }
.wordmark { font-size: 33px; font-weight: 850; letter-spacing: -2.7px; line-height: 1.1; }
.wordmark span { color: var(--accent); }
.admin-mark { padding: 6px 8px 5px; border-radius: 8px; background: var(--accent-soft); color: var(--accent); font-size: 8px; line-height: 1; font-weight: 750; letter-spacing: 1.3px; }
.header-caption { font-size: 9px; font-weight: 600; letter-spacing: 2px; color: var(--muted); }

main { padding: 32px 34px calc(48px + var(--safe-bottom)); }
.page-heading { margin-bottom: 24px; }
.eyebrow { font-size: 8px; letter-spacing: 1.8px; font-weight: 650; color: #74747e; }
.title-row { margin-top: 13px; display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; }
h1 { margin: 0; font-size: clamp(28px, 4vw, 38px); line-height: 1.1; letter-spacing: -1.4px; }
.title-row p { margin: 9px 0 0; color: var(--muted); font-size: 12px; line-height: 1.55; }
.total-pill { min-width: 72px; padding: 10px 14px; border: 1px solid var(--line); border-radius: 16px; background: #fff; display: grid; justify-items: center; }
.total-pill span:first-child { font-size: 19px; line-height: 1; font-weight: 750; font-variant-numeric: tabular-nums; }
.total-pill span:last-child { margin-top: 4px; font-size: 8px; color: var(--muted); text-transform: uppercase; letter-spacing: .8px; }

.create-card { padding: 22px; border-radius: var(--radius); background: #fff; box-shadow: 0 10px 32px #302b4907; }
.create-card, .create-copy, .create-controls { display: flex; align-items: center; }
.create-card { justify-content: space-between; gap: 24px; }
.create-copy { gap: 14px; min-width: 0; }
.card-icon, .empty-icon { width: 46px; height: 46px; border-radius: 15px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); flex: 0 0 auto; }
.card-icon .icon { width: 21px; height: 21px; }
.create-copy h2 { margin: 0; font-size: 15px; letter-spacing: -.2px; }
.create-copy p { margin: 6px 0 0; color: var(--muted); font-size: 10px; line-height: 1.45; }
.create-controls { gap: 10px; flex: 0 0 auto; }
.quantity-field { height: 48px; display: grid; grid-template-columns: 40px 1fr 40px; align-items: center; border: 1px solid var(--line); border-radius: 16px; background: var(--bg); overflow: hidden; }
.quantity-field label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); }
.quantity-field input { width: 58px; height: 100%; padding: 0; border: 0; outline: 0; background: transparent; color: var(--text); text-align: center; font-size: 14px; font-weight: 700; font-variant-numeric: tabular-nums; -moz-appearance: textfield; }
.quantity-field input::-webkit-inner-spin-button, .quantity-field input::-webkit-outer-spin-button { margin: 0; -webkit-appearance: none; }
.stepper { width: 40px; height: 100%; padding: 0; border: 0; background: transparent; color: var(--muted); display: grid; place-items: center; }
.stepper:hover { color: var(--accent); background: #fff; }
.stepper .icon { width: 15px; height: 15px; }
.primary-button { min-height: 48px; padding: 0 18px; border: 0; border-radius: 16px; background: var(--accent); color: #fff; display: flex; align-items: center; justify-content: center; gap: 10px; font-size: 12px; font-weight: 650; box-shadow: 0 9px 24px #ed243b23; transition: background .2s, transform .2s; }
.primary-button:hover { background: var(--accent-dark); }
.primary-button:active { transform: scale(.985); }
.primary-button .icon { width: 17px; height: 17px; }
.field-error { flex-basis: 100%; margin: 4px 0 0 60px; color: #bf1630; font-size: 11px; }

.codes-section { margin-top: 34px; }
.section-row { margin: 0 2px 13px; display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; }
.section-row h2 { margin: 0; font-size: 16px; letter-spacing: -.25px; }
.section-row p { margin: 6px 0 0; color: var(--muted); font-size: 9px; }
.inactive-count { color: var(--accent); font-size: 9px; font-weight: 650; white-space: nowrap; }

.table-wrap { border: 1px solid #ededf1; border-radius: var(--radius); background: #fff; overflow: hidden; box-shadow: 0 10px 32px #302b4905; }
table { width: 100%; border-collapse: collapse; table-layout: fixed; }
th { padding: 15px 13px 12px; border-bottom: 1px solid var(--line); color: #898993; font-size: 8px; font-weight: 650; letter-spacing: .65px; text-align: left; text-transform: uppercase; }
th:nth-child(1) { width: 22%; padding-left: 20px; }
th:nth-child(2) { width: 20%; }
th:nth-child(3), th:nth-child(4) { width: 24%; }
th:last-child { width: 10%; }
td { height: 68px; padding: 13px; border-bottom: 1px solid #f0f0f4; font-size: 11px; vertical-align: middle; }
td:first-child { padding-left: 20px; }
tr:last-child td { border-bottom: 0; }
tbody tr { transition: background .2s; }
tbody tr:hover { background: #fafafd; }
.code-cell { display: flex; align-items: center; gap: 8px; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: #b9b9c2; box-shadow: 0 0 0 4px #b9b9c214; flex: 0 0 auto; }
tr[data-active="false"] .status-dot { background: var(--accent); box-shadow: 0 0 0 4px #ed243b12; }
.code-value { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; font-weight: 700; letter-spacing: .35px; font-variant-numeric: tabular-nums; }
.user { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.user strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; font-weight: 650; }
.user span { color: var(--muted); font-size: 9px; }
.inactive-user { color: #90909a; font-weight: 550; }
.date { color: #4f5058; font-size: 10px; line-height: 1.45; font-variant-numeric: tabular-nums; }
.date-empty { color: #b0b0b9; }
.copy-button { width: 38px; height: 38px; margin-left: auto; padding: 0; display: grid; place-items: center; border: 0; border-radius: 12px; background: #f5f5f8; color: #73737d; transition: background .2s, color .2s, transform .2s; }
.copy-button:hover { color: var(--accent); background: var(--accent-soft); }
.copy-button:active { transform: scale(.94); }
.copy-button.copied { color: #21875b; background: #ecf8f2; }
.copy-button .icon { width: 17px; height: 17px; }

.empty-state { min-height: 250px; padding: 42px 20px; border: 1px dashed #dcdce4; border-radius: var(--radius); display: flex; align-items: center; justify-content: center; flex-direction: column; background: #ffffff80; text-align: center; }
.empty-icon { width: 52px; height: 52px; border-radius: 18px; }
.empty-state h3 { margin: 15px 0 0; font-size: 14px; }
.empty-state p { margin: 7px 0 0; color: var(--muted); font-size: 10px; }
.toast { position: fixed; z-index: 10; bottom: calc(28px + var(--safe-bottom)); left: 50%; transform: translateX(-50%); width: min(calc(100% - 40px), 400px); padding: 14px 18px; border-radius: 16px; background: #26262fee; color: #fff; font-size: 11px; line-height: 1.55; box-shadow: 0 8px 28px #20212720; animation: appear .2s ease-out; }
@keyframes appear { from { opacity: 0; translate: 0 8px; } to { opacity: 1; translate: 0 0; } }

@media (min-width: 1100px) {
  body { padding: 28px 0; }
  .app-shell { min-height: calc(100dvh - 56px); border-radius: 34px; overflow: hidden; }
}

@media (max-width: 760px) {
  .app-header { padding-left: 22px; padding-right: 22px; }
  main { padding: 26px 20px calc(42px + var(--safe-bottom)); }
  .create-card { align-items: stretch; flex-direction: column; gap: 19px; }
  .create-controls { width: 100%; }
  .quantity-field { flex: 1; }
  .quantity-field input { width: 100%; }
  .primary-button { flex: 1; }
  .field-error { margin-left: 0; }

  .table-wrap { border: 0; border-radius: 0; background: transparent; box-shadow: none; overflow: visible; }
  table, tbody, tr, td { display: block; width: 100%; }
  thead { display: none; }
  tbody { display: grid; gap: 10px; }
  tbody tr { padding: 17px 16px; border: 1px solid #ededf1; border-radius: 20px; background: #fff; box-shadow: 0 8px 24px #302b4905; display: grid; grid-template-columns: 1fr auto; column-gap: 14px; }
  tbody tr:hover { background: #fff; }
  td { min-width: 0; height: auto; padding: 0; border: 0; }
  td:first-child { padding: 0 0 14px; grid-column: 1; }
  td:nth-child(2) { padding: 12px 0; border-top: 1px solid #f0f0f4; border-bottom: 1px solid #f0f0f4; grid-column: 1 / -1; }
  td:nth-child(3), td:nth-child(4) { padding-top: 14px; }
  td:nth-child(3) { grid-column: 1; }
  td:nth-child(4) { grid-column: 2; text-align: right; }
  td:last-child { grid-column: 2; grid-row: 1; }
  td:nth-child(3)::before, td:nth-child(4)::before { content: attr(data-label); display: block; margin-bottom: 5px; color: #9898a2; font-size: 7px; font-weight: 650; letter-spacing: .55px; text-transform: uppercase; }
  .copy-button { margin: -5px -4px 0 0; }
}

@media (max-width: 390px) {
  .header-caption { display: none; }
  .title-row { align-items: flex-start; }
  .total-pill { min-width: 64px; }
  .create-controls { align-items: stretch; flex-direction: column; }
  .quantity-field, .primary-button { width: 100%; flex: auto; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

.status-panel { padding: 26px; border-radius: 24px; background: #fff; text-align: center; }
.status-panel h2 { font-size: 17px; margin: 0; }
.status-panel p { color: var(--muted); font-size: 12px; line-height: 1.6; }
.status-panel .primary-button { margin: 20px auto 0; }
button:disabled { cursor: default; opacity: .6; }
.quantity-field input:focus-visible { outline-offset: -3px; border-radius: 8px; }
.create-card { flex-wrap: wrap; }
.field-error { margin: 10px 0 0; }
.code-value { font-size: 10px; }
.code-copy { min-width: 0; }
.code-note { display: block; margin-top: 4px; color: var(--muted); font-size: 8px; line-height: 1.4; }
.code-value { display: block; user-select: all; }
.inactive-user { display: block; }
.status-note { display: block; margin-top: 4px; color: var(--muted); font-size: 8px; }
.secondary-button { width: 100%; min-height: 44px; border: 1px solid var(--line); border-radius: 16px; background: #fff; margin-top: 14px; font-size: 12px; font-weight: 600; }
.text-button { display: block; margin: 16px auto 0; border: 0; background: transparent; color: var(--muted); font-size: 11px; min-height: 40px; }
#codes-title:focus { outline: none; }
@media(max-width:760px) { .code-value { font-size: 11px; } }

/* Server error IDs remain readable on narrow screens. */
#status-message,#list-error{overflow-wrap:anywhere}

/* Analytics shares the admin identity, with denser desktop tables. */
.admin-tabs {display:flex;gap:6px;padding:18px 34px 0;}
.admin-tabs button {border:0;border-radius:14px;background:transparent;color:var(--muted);font-size:11px;padding:13px 17px;min-height:44px;display:flex;gap:10px;align-items:center;}
.admin-tabs button span {font-size:13px;font-weight:650;}
.admin-tabs button[aria-current] {background:var(--text);color:#fff;}
.app-shell {width:min(100%,1440px);}
.filter-card {padding:20px;background:#fff;border:1px solid var(--line);border-radius:20px;}
.filter-main {display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:14px;align-items:end;}
.filter-main label,.range-pair label {display:grid;gap:8px;font-size:11px;font-weight:600;color:var(--muted);min-width:0;}
.filter-card input,.filter-card select {width:100%;min-width:0;min-height:44px;border:1px solid var(--line);border-radius:10px;padding:10px;background:var(--bg);color:var(--text);font:inherit;font-size:12px;}
.filter-card select:focus-visible {outline:3px solid #ed243b55;outline-offset:3px;}
.advanced-filters {margin-top:18px;border-top:1px solid var(--line);padding-top:16px;}
.advanced-filters summary,.chart-values summary {cursor:pointer;font-size:12px;min-height:32px;}
.range-filters {display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:14px;margin-top:12px;}
.range-pair {margin:0;padding:12px;border:1px solid var(--line);border-radius:12px;display:grid;grid-template-columns:1fr 1fr;gap:10px;min-width:0;}
.range-pair legend {font-size:11px;font-weight:650;padding:0 4px;}
.filter-actions {display:flex;align-items:center;gap:18px;flex-wrap:wrap;margin-top:18px;}
.filter-actions #users-count {margin-left:auto;font-size:12px;color:var(--muted);}
.coverage-note,.metric-explanation {font-size:11px;line-height:1.7;color:var(--muted);margin:18px 2px;}
.analytics-message {text-align:center;padding:32px 15px;font-size:13px;color:var(--muted);}
.analytics-table-wrap {overflow:auto;border:1px solid var(--line);border-radius:18px;background:#fff;}
.analytics-table {width:100%;border-collapse:collapse;min-width:1120px;}
.analytics-table th {font-size:10px;white-space:normal;padding:14px 10px;background:#fafafb;}
.analytics-table td {font-size:11px;padding:16px 10px;white-space:normal;min-width:95px;font-variant-numeric:tabular-nums;}
.sort-button {border:0;padding:0;background:none;text-align:left;font:inherit;min-height:32px;}
.analytics-table th[aria-sort=ascending] button::after {content:' ↑';color:var(--accent);}
.analytics-table th[aria-sort=descending] button::after {content:' ↓';color:var(--accent);}
.incomplete-cost {display:block;font-size:10px;color:#96541e;margin-top:5px;}
.metric-grid {display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:14px;}
.metric-card {background:#fff;border:1px solid var(--line);border-radius:20px;padding:24px;display:flex;flex-direction:column;gap:12px;min-width:0;}
.metric-card:nth-child(2) {background:#e8f1f0;border-color:#d7e6e4;}
.metric-label {font-size:11px;color:var(--muted);}
.metric-value {font-size:clamp(23px,3vw,34px);letter-spacing:-1px;font-weight:700;overflow-wrap:anywhere;font-variant-numeric:tabular-nums;}
.metric-note {font-size:10px;color:var(--muted);}
.chart-grid {display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:16px;margin:22px 0;}
.chart-card {min-width:0;padding:22px;background:#fff;border:1px solid var(--line);border-radius:20px;}
.chart-heading {display:flex;align-items:center;justify-content:space-between;gap:10px;margin-bottom:20px;flex-wrap:wrap;}
.chart-heading h2 {font-size:14px;margin:0;}
.chart-heading>span {font-size:10px;color:var(--muted);}
.analytics-chart {width:100%;display:block;}
.wide-chart {grid-column:1/-1;}
.wide-chart .analytics-chart {max-height:260px;}
.chart-values {font-size:11px;max-height:260px;overflow:auto;}
.chart-values table {width:100%;border-collapse:collapse;}
.chart-values th,.chart-values td {padding:8px;white-space:normal;font-size:11px;}
.types-card {margin-top:16px;}
.type-row {margin-top:16px;}
.type-label {display:flex;justify-content:space-between;font-size:12px;gap:14px;margin-bottom:9px;}
.type-track {height:7px;border-radius:6px;background:var(--bg);overflow:hidden;}
.type-track span {display:block;height:100%;background:#1f5c60;border-radius:6px;}
@media(max-width:1000px) {
  .filter-main {grid-template-columns:repeat(2,minmax(0,1fr));}
  .range-filters {grid-template-columns:repeat(2,minmax(0,1fr));}
}
@media(max-width:760px) {
  .admin-tabs {padding:16px 20px 0;gap:4px;}
  .admin-tabs button {flex:1;justify-content:center;padding:12px 5px;gap:6px;font-size:9px;}
  .admin-tabs button span {font-size:11px;}
  .filter-card {padding:16px;}
  .filter-main {gap:12px;}
  .filter-main>label:first-child {grid-column:1/-1;}
  .metric-grid {grid-template-columns:repeat(2,minmax(0,1fr));gap:10px;}
  .metric-card {padding:17px;gap:10px;}
  .metric-value {font-size:25px;}
  .chart-grid {grid-template-columns:1fr;}
  .chart-card {padding:16px;}
  .analytics-table-wrap {background:transparent;border:0;overflow:visible;}
  .analytics-table {display:block;min-width:0;}
  .analytics-table thead {display:none;}
  .analytics-table tbody {display:grid;gap:12px;}
  .analytics-table tr {display:grid;background:#fff;border:1px solid var(--line);border-radius:18px;padding:16px;}
  .analytics-table td {display:flex!important;justify-content:space-between;gap:12px;align-items:baseline;min-width:0;width:auto!important;padding:8px 0!important;border:0;text-align:right;}
  .analytics-table td::before {content:attr(data-label);display:block!important;text-align:left;font-size:10px;color:var(--muted);}
  .analytics-table td small {max-width:100px;}
  .chart-values table {display:table;}
  .chart-values thead {display:table-header-group;}
  .chart-values tbody {display:table-row-group;}
  .chart-values tr {display:table-row;}
  .chart-values th,.chart-values td {display:table-cell!important;width:auto!important;padding:8px!important;}
  .chart-values td::before {display:none;}
}
@media(max-width:400px) {
  .range-filters {grid-template-columns:1fr;}
  .filter-main {grid-template-columns:1fr;}
  .metric-value {font-size:22px;}
  .metric-label {font-size:10px;}
  .filter-actions {gap:12px;}
  .filter-actions #users-count {width:100%;margin:0;}
}


.analytics-table { table-layout:auto; }
.analytics-table th { width:auto; }
@media(max-width:760px) { .analytics-table tr {grid-template-columns:1fr;gap:0;} .analytics-table td {grid-column:1/-1!important;grid-row:auto!important;} .chart-values td,.chart-values th {height:auto;} }
