@import url('https://fonts.googleapis.com/css2?family=Fira+Code:wght@500;600;700&family=Fira+Sans:wght@400;500;600;700&display=swap');

:root {
  color-scheme: dark;
  --bg: #020617;
  --bg-soft: #0f172a;
  --panel: rgba(15, 23, 42, 0.82);
  --panel-strong: #111827;
  --border: rgba(148, 163, 184, 0.22);
  --border-strong: rgba(148, 163, 184, 0.36);
  --text: #f8fafc;
  --muted: #94a3b8;
  --muted-strong: #cbd5e1;
  --accent: #22c55e;
  --accent-strong: #16a34a;
  --accent-soft: rgba(34, 197, 94, 0.14);
  --danger: #fb7185;
  --warning: #fbbf24;
  --info: #38bdf8;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.38);
  --radius-lg: 24px;
  --radius-md: 16px;
  --radius-sm: 12px;
  --nav-height: 88px;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html { scroll-behavior: smooth; }

body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at top left, rgba(34, 197, 94, 0.18), transparent 34rem),
    radial-gradient(circle at 85% 12%, rgba(56, 189, 248, 0.12), transparent 28rem),
    linear-gradient(180deg, #020617 0%, #0f172a 100%);
  color: var(--text);
  font-family: 'Fira Sans', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 16px;
  line-height: 1.5;
  padding-top: var(--nav-height);
}

a { color: inherit; }

button,
a,
input,
select,
summary { transition: border-color 180ms ease, background 180ms ease, color 180ms ease, box-shadow 180ms ease; }

button,
summary,
.nav-links a,
.primary-link,
.secondary-link,
.icon-button { cursor: pointer; }

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
summary:focus-visible,
.modal:focus-visible,
.table-wrap:focus-visible {
  outline: 3px solid rgba(34, 197, 94, 0.72);
  outline-offset: 3px;
}

.skip-link {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 60;
  transform: translateY(-160%);
  border-radius: 999px;
  background: var(--accent);
  color: #04130a;
  font-weight: 700;
  padding: 10px 14px;
  text-decoration: none;
}

.skip-link:focus { transform: translateY(0); }

.topbar {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 50;
  padding: 14px 20px;
  pointer-events: none;
}

.topnav {
  max-width: 1180px;
  min-height: 60px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(2, 6, 23, 0.78);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
  padding: 10px 12px 10px 14px;
  pointer-events: auto;
}

.brand {
  min-width: max-content;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--text);
  text-decoration: none;
}

.brand-mark {
  width: 40px;
  height: 40px;
  display: inline-grid;
  place-items: center;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--accent), #67e8f9);
  color: #03110a;
  font-family: 'Fira Code', monospace;
  font-weight: 700;
  box-shadow: 0 0 32px rgba(34, 197, 94, 0.24);
}

.brand strong,
.brand small { display: block; }

.brand strong { font-size: 0.98rem; letter-spacing: -0.01em; }
.brand small { color: var(--muted); font-size: 0.76rem; }

.nav-links {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
  gap: 4px;
}

.nav-links a {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  color: var(--muted-strong);
  padding: 0 14px;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.92rem;
}

.nav-links a:hover { background: rgba(148, 163, 184, 0.12); color: var(--text); }

.nav-actions {
  min-width: max-content;
  display: flex;
  align-items: center;
  gap: 10px;
}

.session-pill {
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted-strong);
  padding: 9px 12px;
  font-size: 0.86rem;
}

.shell {
  width: min(1680px, calc(100% - 24px));
  margin: 0 auto;
  padding: 24px 0 56px;
}

.hero-card,
.panel {
  border: 1px solid var(--border);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.hero-card {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  border-radius: 32px;
  padding: clamp(28px, 5vw, 48px);
  margin-bottom: 22px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-family: 'Fira Code', monospace;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: -0.03em;
  line-height: 1.08;
}

h1 { max-width: 760px; font-size: clamp(2rem, 5vw, 4.7rem); }
h2 { font-size: clamp(1.35rem, 2.5vw, 2rem); }

.hero-copy {
  max-width: 720px;
  margin: 18px 0 0;
  color: var(--muted-strong);
  font-size: 1.08rem;
}

.hero-actions,
.form-actions,
.section-heading,
.section-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.hero-actions { flex-wrap: wrap; justify-content: flex-end; }

.primary-link,
.secondary-link,
.primary-button,
.ghost-button {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  border: 1px solid transparent;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  padding: 0 18px;
  text-decoration: none;
}

.primary-link,
.primary-button {
  background: var(--accent);
  color: #03110a;
  border-color: rgba(187, 247, 208, 0.3);
  box-shadow: 0 10px 32px rgba(34, 197, 94, 0.22);
}

.primary-link:hover,
.primary-button:hover { background: #4ade80; }

.primary-button:disabled,
.ghost-button:disabled { cursor: not-allowed; opacity: 0.58; }

.secondary-link,
.ghost-button {
  background: rgba(148, 163, 184, 0.1);
  color: var(--text);
  border-color: var(--border);
}

.secondary-link:hover,
.ghost-button:hover { border-color: var(--border-strong); background: rgba(148, 163, 184, 0.16); }

.auth-layout {
  display: grid;
  place-items: center;
  margin-top: 22px;
}

.panel {
  border-radius: var(--radius-lg);
  padding: clamp(18px, 2vw, 24px);
}

.auth-card { width: min(100%, 520px); }

.admin-layout {
  display: grid;
  gap: 22px;
}

.section-heading {
  justify-content: space-between;
  margin-bottom: 18px;
}

.muted {
  margin: 8px 0 18px;
  color: var(--muted);
}

.compact { margin: 0; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.report-filters.form-grid {
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  align-items: start;
  border: 1px solid rgba(148, 163, 184, 0.16);
  border-radius: 20px;
  background: rgba(2, 6, 23, 0.22);
  padding: 18px;
}

.single-column { grid-template-columns: 1fr; }

.field,
.form-grid > label {
  display: grid;
  gap: 8px;
  align-content: start;
}

.span-2 { grid-column: span 2; }

label {
  color: var(--muted-strong);
  font-weight: 700;
  font-size: 0.92rem;
}

input,
select {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: rgba(2, 6, 23, 0.72);
  color: var(--text);
  font: inherit;
  padding: 11px 13px;
}

.report-filters input,
.report-filters select {
  min-height: 44px;
  padding: 10px 12px;
  font-size: 0.92rem;
}

.report-filters label {
  color: var(--muted);
  font-family: 'Fira Code', monospace;
  font-size: 0.76rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

input::placeholder { color: #64748b; }
input:hover,
select:hover { border-color: var(--border-strong); }
input:focus,
select:focus { border-color: rgba(34, 197, 94, 0.68); }

.form-message {
  min-height: 24px;
  margin: 0;
  color: var(--muted-strong);
  font-weight: 600;
}

.form-message.error { color: var(--danger); }
.form-message.success { color: var(--accent); }

.secret-output,
pre {
  white-space: pre-wrap;
  word-break: break-word;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: rgba(2, 6, 23, 0.76);
  color: var(--muted-strong);
  padding: 16px;
}

.secret-output:empty { display: none; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(180px, 1fr));
  gap: 14px;
}

.stat-card {
  min-height: 118px;
  display: grid;
  align-content: space-between;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: linear-gradient(180deg, rgba(30, 41, 59, 0.74), rgba(15, 23, 42, 0.72));
  padding: 18px;
}

.stat-card span {
  color: var(--muted);
  font-family: 'Fira Code', monospace;
  font-size: 0.76rem;
  text-transform: uppercase;
}

.stat-card strong {
  display: block;
  margin-top: 8px;
  font-family: 'Fira Code', monospace;
  font-size: clamp(1.5rem, 3vw, 2.15rem);
}

.stat-card small { color: var(--muted); }

.raw-details { margin-top: 16px; }
.raw-details summary { color: var(--muted-strong); font-weight: 700; }
.raw-details pre { max-height: 360px; overflow: auto; }

.table-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 10px 0 12px;
  color: var(--muted);
  font-size: 0.9rem;
}

.pager-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

table {
  width: 100%;
  min-width: 860px;
  border-collapse: collapse;
}

th,
td {
  border-bottom: 1px solid var(--border);
  padding: 14px 16px;
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--muted);
  background: rgba(2, 6, 23, 0.34);
  font-family: 'Fira Code', monospace;
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

td { color: var(--muted-strong); }
tbody tr:hover { background: rgba(148, 163, 184, 0.07); }
tbody tr:last-child td { border-bottom: 0; }

.report-filters { margin-bottom: 14px; }

.report-field-wide { grid-column: span 2; }

.report-filters .form-actions {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  padding-top: 2px;
}

.report-filters .primary-button,
.report-filters .secondary-link {
  min-height: 42px;
  padding: 0 16px;
  font-size: 0.9rem;
}

.report-filters .primary-button { min-width: 150px; }

.notice {
  border: 1px solid rgba(56, 189, 248, 0.28);
  border-radius: var(--radius-md);
  background: rgba(56, 189, 248, 0.1);
  color: var(--muted-strong);
  margin: 16px 0 18px;
  padding: 14px 16px;
}

.report-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 18px;
  margin: 22px 0;
}

.report-grid article {
  min-width: 0;
  border: 1px solid rgba(148, 163, 184, 0.16);
  border-radius: 20px;
  background: rgba(2, 6, 23, 0.18);
  padding: 16px;
}

.report-grid h3,
#tts-reports h3 {
  margin: 0 0 10px;
  color: var(--text);
}

.compact-table { min-width: 520px; }

.key-name { color: var(--text); font-weight: 700; }
.key-id-line {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  color: var(--muted);
  font-family: 'Fira Code', monospace;
  font-size: 0.74rem;
}

.text-button {
  border: 0;
  background: transparent;
  color: var(--accent);
  font: inherit;
  font-weight: 700;
  padding: 0;
}

.text-button:hover { color: #86efac; }
.code-text { font-family: 'Fira Code', monospace; font-size: 0.86rem; }

.status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  border: 1px solid var(--border);
  padding: 4px 10px;
  font-weight: 800;
  font-size: 0.78rem;
  text-transform: capitalize;
}

.status-active { color: #86efac; background: var(--accent-soft); border-color: rgba(34, 197, 94, 0.28); }
.status-blocked,
.status-revoked { color: #fecdd3; background: rgba(251, 113, 133, 0.12); border-color: rgba(251, 113, 133, 0.28); }
.status-expired { color: #fde68a; background: rgba(251, 191, 36, 0.12); border-color: rgba(251, 191, 36, 0.28); }

.quota-meter {
  min-width: 130px;
  display: grid;
  gap: 7px;
}

.meter-track {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.18);
}

.meter-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--info));
}

.empty-state {
  margin: 16px 0 0;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-md);
  color: var(--muted);
  padding: 18px;
  text-align: center;
}

.action-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.compact-button {
  min-height: 36px;
  padding: 0 12px;
  font-size: 0.84rem;
}

.modal {
  width: min(680px, calc(100% - 32px));
  border: 0;
  border-radius: 28px;
  background: transparent;
  color: var(--text);
  padding: 0;
}

.modal::backdrop {
  background: rgba(2, 6, 23, 0.72);
  backdrop-filter: blur(8px);
}

.modal-card {
  border: 1px solid var(--border-strong);
  border-radius: 28px;
  background: rgba(15, 23, 42, 0.96);
  box-shadow: var(--shadow);
  padding: clamp(20px, 4vw, 30px);
}

.icon-button {
  width: 44px;
  height: 44px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.1);
  color: var(--text);
  font: inherit;
  font-size: 1.35rem;
  line-height: 1;
}

.icon-button:hover { background: rgba(148, 163, 184, 0.16); border-color: var(--border-strong); }

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 18px;
}

@media (max-width: 960px) {
  :root { --nav-height: 150px; }
  .topnav { align-items: stretch; border-radius: 28px; flex-wrap: wrap; }
  .nav-links { order: 3; flex-basis: 100%; justify-content: flex-start; overflow-x: auto; padding-top: 4px; }
  .hero-card { align-items: stretch; flex-direction: column; }
  .hero-actions { justify-content: flex-start; }
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .report-filters.form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .report-grid { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  :root { --nav-height: 188px; }
  body { font-size: 16px; }
  .topbar { padding: 10px; }
  .topnav { border-radius: 22px; }
  .shell { width: min(100% - 24px, 1180px); padding-top: 18px; }
  .brand { width: 100%; }
  .nav-actions { width: 100%; justify-content: space-between; }
  .hero-card { border-radius: 24px; }
  .form-grid,
  .report-filters.form-grid { grid-template-columns: 1fr; }
  .span-2,
  .report-field-wide { grid-column: span 1; }
  .form-actions,
  .report-filters .form-actions,
  .modal-actions { align-items: stretch; flex-direction: column; }
  .report-filters .primary-button,
  .report-filters .secondary-link { width: 100%; }
  .primary-link,
  .secondary-link,
  .primary-button,
  .ghost-button { width: 100%; }
  .section-heading { align-items: flex-start; flex-direction: column; }
  .stat-grid { grid-template-columns: 1fr; }
}

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