:root {
  color-scheme: dark;
  --bg: #0b1020;
  --panel: #121a2f;
  --panel-border: #24304d;
  --text: #e8edf8;
  --muted: #9aa8c7;
  --accent: #5b8cff;
  --accent-soft: rgba(91, 140, 255, 0.14);
  --ok: #3ecf8e;
  --warn: #f5b942;
  --danger: #ff6b6b;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
  font-family: "Segoe UI", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(91, 140, 255, 0.18), transparent 28%),
    linear-gradient(180deg, #0b1020 0%, #0d1324 100%);
  color: var(--text);
}

.hidden {
  display: none !important;
}

.auth-gate {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth-card {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 18px;
  padding: 28px;
  box-shadow: var(--shadow);
}

.auth-card h1,
.topbar h1,
.panel h2 {
  margin: 0;
}

.auth-card p,
.eyebrow,
.cards .label {
  color: var(--muted);
}

.auth-card label {
  display: block;
  margin: 18px 0 8px;
  font-size: 0.92rem;
}

input {
  width: 100%;
  border: 1px solid var(--panel-border);
  background: #0a1122;
  color: var(--text);
  border-radius: 10px;
  padding: 12px 14px;
}

button {
  border: 0;
  border-radius: 10px;
  background: var(--accent);
  color: white;
  padding: 11px 16px;
  font-weight: 600;
  cursor: pointer;
}

button.ghost {
  background: transparent;
  border: 1px solid var(--panel-border);
  color: var(--text);
}

button.danger {
  color: var(--danger);
  border-color: rgba(255, 107, 107, 0.35);
}

button.danger:hover {
  background: rgba(255, 107, 107, 0.12);
}

.actions-cell {
  width: 1%;
  white-space: nowrap;
}

.error {
  color: var(--danger);
  margin-top: 12px;
}

.app {
  max-width: 1200px;
  margin: 0 auto;
  padding: 28px 20px 48px;
}

.topbar,
.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.topbar {
  margin-bottom: 24px;
}

.topbar-actions {
  display: flex;
  gap: 10px;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.72rem;
  margin: 0 0 6px;
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  padding: 18px;
  box-shadow: var(--shadow);
}

.card strong {
  display: block;
  font-size: 1.5rem;
  margin-top: 8px;
}

.panel {
  background: rgba(18, 26, 47, 0.88);
  border: 1px solid var(--panel-border);
  border-radius: 18px;
  margin-bottom: 18px;
  overflow: hidden;
}

.panel-head {
  padding: 18px 20px;
  border-bottom: 1px solid var(--panel-border);
}

.panel-note {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 14px 18px;
  text-align: left;
  border-bottom: 1px solid rgba(36, 48, 77, 0.7);
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
}

.badge.ok {
  background: rgba(62, 207, 142, 0.16);
  color: var(--ok);
}

.badge.needs_refresh,
.badge.warning {
  background: rgba(245, 185, 66, 0.16);
  color: var(--warn);
}

.badge.expired,
.badge.critical,
.badge.error,
.badge.exhausted,
.badge.token_error {
  background: rgba(255, 107, 107, 0.16);
  color: var(--danger);
}

.badge.limit_zero {
  background: rgba(245, 185, 66, 0.16);
  color: var(--warn);
}

.badge.unknown {
  background: rgba(154, 168, 199, 0.16);
  color: var(--muted);
}

.empty {
  color: var(--muted);
  padding: 18px;
}

.quota-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
  padding: 18px;
}

.quota-empty {
  grid-column: 1 / -1;
  margin: 0;
}

.quota-card {
  background: linear-gradient(180deg, rgba(16, 24, 44, 0.95) 0%, rgba(12, 18, 34, 0.98) 100%);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  padding: 18px;
  box-shadow: var(--shadow);
}

.quota-card--warning {
  border-color: rgba(245, 185, 66, 0.45);
}

.quota-card--critical,
.quota-card--exhausted,
.quota-card--error {
  border-color: rgba(255, 107, 107, 0.45);
}

.quota-card--limit_zero {
  border-color: rgba(245, 185, 66, 0.35);
}

.quota-card--ok {
  border-color: rgba(62, 207, 142, 0.28);
}

.quota-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 16px;
}

.quota-account {
  margin: 0;
  font-size: 1.02rem;
  font-weight: 700;
}

.quota-file {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.78rem;
  word-break: break-all;
}

.quota-hero {
  margin-bottom: 14px;
}

.quota-hero-value {
  display: block;
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.quota-hero-label {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.86rem;
}

.quota-progress {
  height: 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  overflow: hidden;
  margin-bottom: 10px;
}

.quota-progress-fill {
  height: 100%;
  border-radius: inherit;
  transition: width 0.35s ease;
}

.quota-progress-fill--ok {
  background: linear-gradient(90deg, #2f9f72, var(--ok));
}

.quota-progress-fill--warning,
.quota-progress-fill--limit_zero {
  background: linear-gradient(90deg, #c9921d, var(--warn));
}

.quota-progress-fill--critical,
.quota-progress-fill--exhausted,
.quota-progress-fill--error {
  background: linear-gradient(90deg, #d94848, var(--danger));
}

.quota-progress-fill--unknown {
  background: rgba(154, 168, 199, 0.45);
}

.quota-stats {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 8px;
  align-items: center;
  color: var(--muted);
  font-size: 0.82rem;
  margin-bottom: 12px;
}

.quota-stats strong {
  color: var(--text);
  font-size: 1rem;
}

.quota-stats span:first-child {
  text-align: left;
}

.quota-stats span:last-child {
  text-align: right;
}

.quota-stats--simple {
  grid-template-columns: 1fr 1fr;
}

.quota-period {
  margin: 0;
  color: var(--muted);
  font-size: 0.8rem;
}

.quota-error {
  margin: 0;
  color: #ffb4b4;
  font-size: 0.9rem;
  line-height: 1.5;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(4, 8, 18, 0.72);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 20;
}

.modal-card {
  width: min(560px, 100%);
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 18px;
  padding: 22px;
  box-shadow: var(--shadow);
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.modal-copy,
.muted {
  color: var(--muted);
  line-height: 1.5;
}

.oauth-steps {
  margin: 0 0 16px 18px;
  color: var(--muted);
  line-height: 1.6;
}

.modal-card label {
  display: block;
  margin: 16px 0 8px;
}

.modal-card > button {
  margin-top: 12px;
}

.url-copy-row {
  display: flex;
  gap: 10px;
  align-items: stretch;
}

.url-copy-row input {
  flex: 1;
  font-size: 0.85rem;
}

.url-copy-row button {
  margin-top: 0;
  flex-shrink: 0;
  white-space: nowrap;
}

.success {
  color: var(--ok);
  margin-top: 12px;
}

code {
  color: #b8c9ef;
}