:root {
  --bg: #080f1a;
  --surface: #111b2b;
  --surface-2: #172337;
  --border: rgba(148, 163, 184, 0.16);
  --text: #f1f5f9;
  --muted: #94a3b8;
  --accent: #14b8a6;
  --accent-strong: #0d9488;
  --ok: #22c55e;
  --warn: #f59e0b;
  --crit: #ef4444;
  --radius: 14px;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', Tahoma, 'Cairo', system-ui, -apple-system, sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 0.88rem; }
code {
  background: rgba(255, 255, 255, 0.07);
  padding: 2px 6px;
  border-radius: 6px;
  font-size: 0.85em;
  direction: ltr;
  display: inline-block;
}

/* Auth */
.auth-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
  background: radial-gradient(circle at top, #13253f 0%, var(--bg) 60%);
}
.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 32px 24px;
  text-align: center;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
}
.auth-card h1 { margin: 12px 0 6px; font-size: 1.45rem; }
.google-btn-wrap { margin: 22px auto 12px; display: flex; justify-content: center; min-height: 44px; }
.auth-error { color: #fca5a5; background: rgba(239, 68, 68, 0.14); padding: 10px 12px; border-radius: 10px; font-size: 0.88rem; }
.auth-hint { margin-top: 18px; font-size: 0.8rem; }

/* App Shell */
.app-shell { max-width: 1180px; margin: 0 auto; padding-bottom: 84px; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  background: rgba(8, 15, 26, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-title { font-weight: 700; font-size: 1.05rem; }
.brand-sub { color: var(--muted); font-size: 0.78rem; }
.topbar-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.btn {
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  border-radius: 10px;
  padding: 8px 14px;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s, background 0.15s;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--accent-strong); border-color: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent); }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--text); }

/* Health Banner */
.health-banner {
  margin: 14px 16px 0;
  padding: 14px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--surface);
}
.health-banner.ok { border-color: rgba(34, 197, 94, 0.35); background: rgba(34, 197, 94, 0.08); }
.health-banner.warn { border-color: rgba(245, 158, 11, 0.45); background: rgba(245, 158, 11, 0.1); }
.health-banner.crit { border-color: rgba(239, 68, 68, 0.5); background: rgba(239, 68, 68, 0.12); }
.health-banner-main { display: flex; align-items: center; gap: 12px; }
.health-sub { font-size: 0.82rem; color: var(--muted); }
.dot { width: 12px; height: 12px; border-radius: 999px; background: var(--ok); flex-shrink: 0; }
.health-banner.warn .dot { background: var(--warn); }
.health-banner.crit .dot { background: var(--crit); }

.pill {
  font-size: 0.78rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  white-space: nowrap;
}
.pill-ok { background: rgba(34, 197, 94, 0.16); color: #86efac; }
.pill-warn { background: rgba(245, 158, 11, 0.18); color: #fcd34d; }
.pill-crit { background: rgba(239, 68, 68, 0.2); color: #fca5a5; }
.pill-muted { background: rgba(148, 163, 184, 0.15); color: var(--muted); }

/* Content */
.content { padding: 16px; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

.grid-kpi {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(175px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(310px, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
}
.card-title { font-weight: 700; font-size: 1rem; margin: 0; }

.kpi-label { color: var(--muted); font-size: 0.82rem; }
.kpi-value { font-size: 1.55rem; font-weight: 800; margin: 4px 0; direction: ltr; text-align: right; }
.kpi-sub { font-size: 0.78rem; color: var(--muted); }

/* Quota bars */
.quota-item { padding: 11px 0; border-bottom: 1px solid var(--border); }
.quota-item:last-child { border-bottom: none; padding-bottom: 0; }
.quota-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 6px; }
.quota-nums { font-size: 0.82rem; color: var(--muted); direction: ltr; }
.bar-track { height: 9px; border-radius: 999px; background: rgba(255, 255, 255, 0.08); overflow: hidden; }
.bar-fill { height: 100%; border-radius: 999px; background: var(--ok); transition: width 0.3s ease; }
.bar-fill.warn { background: var(--warn); }
.bar-fill.crit { background: var(--crit); }
.bar-fill.unknown { background: #64748b; }
.quota-reset { font-size: 0.75rem; color: var(--muted); margin-top: 4px; }

/* Lists */
.row-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.row-item:last-child { border-bottom: none; }

/* Reviews */
.review-card {
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--surface-2);
  margin-bottom: 8px;
  border: 1px solid var(--border);
}
.review-card.neg { border-color: rgba(239, 68, 68, 0.45); }

/* Chart */
.chart-wrap { width: 100%; overflow-x: auto; }
.chart-svg { width: 100%; height: 170px; display: block; }

/* Settings Form */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}
.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 0.82rem; color: var(--muted); }
.field input[type="number"],
.field input[type="text"] {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 8px 10px;
  font-size: 0.9rem;
}
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  background: var(--surface-2);
  border-radius: 10px;
}
.limit-edit-row {
  display: grid;
  grid-template-columns: 1.8fr 1fr 0.75fr 0.75fr;
  gap: 8px;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.limit-edit-row input {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 6px 8px;
  font-size: 0.85rem;
}
@media (max-width: 640px) {
  .limit-edit-row { grid-template-columns: 1fr 1fr; }
  .limit-edit-name { grid-column: 1 / -1; font-weight: 600; }
}

/* Bottom Navigation */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 30;
  background: rgba(11, 19, 32, 0.96);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-around;
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
}
.nav-btn {
  background: transparent;
  border: none;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 10px;
  cursor: pointer;
}
.nav-btn.active { color: var(--accent); background: rgba(20, 184, 166, 0.1); }
.nav-ico { font-size: 1.15rem; }

/* Toast */
.toast {
  position: fixed;
  top: 72px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 50;
  background: #0f172a;
  color: #fff;
  border: 1px solid var(--accent);
  padding: 10px 18px;
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  font-size: 0.9rem;
}
