:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --ink: #0f172a;
  --ink-soft: #334155;
  --muted: #64748b;
  --line: #dbe3ef;
  --line-strong: #cbd5e1;
  --primary: #2563eb;
  --primary-strong: #1d4ed8;
  --nav: #172033;
  --nav-2: #222d43;
  --success-bg: #dcfce7;
  --success: #166534;
  --warn-bg: #fef3c7;
  --warn: #92400e;
  --danger-bg: #fee2e2;
  --danger: #991b1b;
  --shadow: 0 14px 40px rgba(15, 23, 42, .10);
  --radius: 8px;
  color-scheme: light;
}

[data-theme="dark"] {
  --bg: #0b1120;
  --surface: #111827;
  --surface-2: #0f172a;
  --ink: #e5edf8;
  --ink-soft: #cbd5e1;
  --muted: #94a3b8;
  --line: #263244;
  --line-strong: #334155;
  --primary: #60a5fa;
  --primary-strong: #3b82f6;
  --nav: #080d18;
  --nav-2: #111827;
  --success-bg: #052e2b;
  --success: #86efac;
  --warn-bg: #3a2808;
  --warn: #fcd34d;
  --danger-bg: #3f1116;
  --danger: #fca5a5;
  --shadow: 0 18px 46px rgba(0, 0, 0, .35);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button, input, select, textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

a {
  color: inherit;
}

.app {
  min-height: 100vh;
}

.login-shell,
.status-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(360px, 480px);
  background:
    linear-gradient(120deg, rgba(37, 99, 235, .12), transparent 42%),
    radial-gradient(circle at 18% 24%, rgba(20, 184, 166, .16), transparent 30%),
    var(--bg);
}

.brand-panel {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 56px;
  background: var(--nav);
  color: #fff;
  overflow: hidden;
}

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: #fff;
  color: #172033;
  font-weight: 900;
  letter-spacing: 0;
}

.brand-copy {
  max-width: 680px;
}

.brand-copy h1 {
  margin: 0 0 18px;
  font-size: clamp(38px, 6vw, 76px);
  line-height: .95;
  letter-spacing: 0;
}

.brand-copy p {
  margin: 0;
  max-width: 560px;
  color: #cbd5e1;
  font-size: 18px;
  line-height: 1.7;
}

.signal-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 44px;
}

.signal {
  border: 1px solid rgba(255,255,255,.13);
  background: rgba(255,255,255,.06);
  border-radius: var(--radius);
  padding: 14px;
}

.signal strong {
  display: block;
  font-size: 20px;
}

.signal span {
  color: #94a3b8;
  font-size: 12px;
  text-transform: uppercase;
}

.login-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px;
}

.login-card,
.status-card {
  width: min(100%, 430px);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
}

.login-card h2,
.status-card h2 {
  margin: 0 0 6px;
  font-size: 24px;
}

.muted {
  color: var(--muted);
}

.tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin: 22px 0;
  padding: 4px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.tab {
  border: 0;
  border-radius: 6px;
  padding: 10px 8px;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
  font-size: 13px;
}

.tab.active {
  background: var(--surface);
  color: var(--primary);
  box-shadow: 0 1px 2px rgba(15,23,42,.08);
}

.field {
  display: grid;
  gap: 7px;
  margin-bottom: 14px;
}

.field label {
  color: var(--ink-soft);
  font-weight: 700;
  font-size: 13px;
}

.input,
.select,
.textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  padding: 10px 12px;
  outline: none;
}

.textarea {
  min-height: 96px;
  resize: vertical;
}

.input:focus,
.select:focus,
.textarea:focus,
.tab:focus-visible,
.btn:focus-visible,
.nav-item:focus-visible {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .18);
  outline: none;
}

.btn {
  min-height: 40px;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 10px 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 800;
  background: var(--surface-2);
  color: var(--ink-soft);
}

.btn.primary {
  background: var(--primary);
  color: #fff;
}

.btn.primary:hover {
  background: var(--primary-strong);
}

.btn.ghost {
  background: transparent;
  border-color: var(--line);
}

.btn.full {
  width: 100%;
}

.alert {
  border-radius: var(--radius);
  padding: 12px 14px;
  margin: 14px 0;
  border: 1px solid var(--line);
  font-weight: 650;
}

.alert.error {
  color: var(--danger);
  background: var(--danger-bg);
  border-color: transparent;
}

.alert.success {
  color: var(--success);
  background: var(--success-bg);
  border-color: transparent;
}

.dashboard {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  background: var(--nav);
  color: #fff;
  display: flex;
  flex-direction: column;
}

.sidebar-head {
  padding: 24px 20px;
  border-bottom: 1px solid rgba(255,255,255,.1);
  display: flex;
  align-items: center;
  gap: 12px;
}

.sidebar-title strong {
  display: block;
  font-size: 16px;
}

.sidebar-title span {
  color: #94a3b8;
  font-size: 12px;
  text-transform: uppercase;
}

.nav {
  padding: 18px 0;
  display: grid;
  gap: 2px;
}

.nav-item {
  width: 100%;
  border: 0;
  border-left: 3px solid transparent;
  background: transparent;
  color: #cbd5e1;
  padding: 13px 20px;
  text-align: left;
  font-weight: 750;
}

.nav-item:hover,
.nav-item.active {
  background: rgba(255,255,255,.07);
  color: #fff;
  border-left-color: var(--primary);
}

.sidebar-foot {
  margin-top: auto;
  padding: 16px 20px 22px;
  display: grid;
  gap: 10px;
}

.main {
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  padding: 18px 28px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
}

.topbar h1 {
  margin: 0;
  font-size: 24px;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.lang-switch {
  display: inline-grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  width: min(100%, 148px);
  padding: 4px;
  margin-bottom: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255,255,255,.08);
}

.login-shell .lang-switch {
  border-color: rgba(255,255,255,.18);
}

.lang-switch button {
  border: 0;
  border-radius: 4px;
  min-height: 32px;
  background: transparent;
  color: inherit;
  font-weight: 800;
  font-size: 12px;
}

.lang-switch button.active {
  background: var(--surface);
  color: var(--primary);
  box-shadow: 0 1px 2px rgba(15,23,42,.1);
}

.content {
  padding: 28px;
  max-width: 1440px;
}

.grid {
  display: grid;
  gap: 18px;
}

.grid.stats {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.grid.two {
  grid-template-columns: minmax(320px, .9fr) minmax(0, 1.4fr);
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 1px 3px rgba(15, 23, 42, .06);
  padding: 20px;
}

.card h3 {
  margin: 0 0 14px;
  font-size: 17px;
}

.stat {
  min-height: 120px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.stat span {
  color: var(--muted);
  font-weight: 700;
  font-size: 13px;
}

.stat strong {
  display: block;
  font-size: 32px;
  line-height: 1;
}

.toolbar {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.toolbar .input {
  max-width: 360px;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
  background: var(--surface);
}

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

th {
  color: var(--muted);
  background: var(--surface-2);
  font-size: 12px;
  text-transform: uppercase;
}

tr:last-child td {
  border-bottom: 0;
}

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 12px;
  font-weight: 800;
  background: var(--surface-2);
  color: var(--muted);
}

.badge.active,
.badge.standard {
  background: var(--success-bg);
  color: var(--success);
}

.badge.credits,
.badge.expiring-soon {
  background: var(--warn-bg);
  color: var(--warn);
}

.badge.expired,
.badge.paused,
.badge.not_found {
  background: var(--danger-bg);
  color: var(--danger);
}

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

.result-box {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  margin-top: 14px;
}

.hidden {
  display: none !important;
}

@media (max-width: 960px) {
  .login-shell,
  .status-shell {
    grid-template-columns: 1fr;
  }
  .brand-panel {
    min-height: 42vh;
    padding: 32px 24px;
  }
  .dashboard {
    grid-template-columns: 1fr;
  }
  .sidebar {
    position: static;
    height: auto;
  }
  .nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    padding: 10px;
  }
  .nav-item {
    border-left: 0;
    border-radius: 6px;
    padding: 11px 12px;
  }
  .grid.stats,
  .grid.two,
  .form-grid {
    grid-template-columns: 1fr;
  }
  .topbar {
    position: static;
    align-items: flex-start;
    flex-direction: column;
  }
  .content {
    padding: 18px;
  }
}

@media (max-width: 620px) {
  .tabs {
    grid-template-columns: repeat(2, 1fr);
  }
  .signal-strip {
    grid-template-columns: 1fr;
  }
  .login-card,
  .status-card {
    padding: 20px;
  }
  .brand-copy h1 {
    font-size: 38px;
  }
}
