:root {
  --bg: #0b1020;
  --panel: rgba(255, 255, 255, 0.06);
  --panel2: rgba(255, 255, 255, 0.09);
  --text: rgba(255, 255, 255, 0.92);
  --muted: rgba(255, 255, 255, 0.55);
  --border: rgba(255, 255, 255, 0.12);
  --accent: #f6821f;
  --danger: #ef4444;
  --success: #22c55e;
}

* { box-sizing: border-box; }

html, body { height: 100%; margin: 0; }

body {
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  background: radial-gradient(1200px 800px at 15% 20%, #172554 0%, transparent 60%),
              radial-gradient(900px 600px at 80% 0%, #3b0764 0%, transparent 55%),
              var(--bg);
  color: var(--text);
  font-size: 14px;
}

.container { max-width: 1200px; margin: 0 auto; padding: 0 16px; }

/* Auth gate */
.auth-gate {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh;
}
.auth-gate[hidden] {
  display: none;
}
.auth-box {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px;
  width: 360px;
  max-width: 90vw;
}
.auth-title { margin: 0 0 8px; font-size: 22px; font-weight: 800; }
.auth-hint { color: var(--muted); margin: 0 0 16px; font-size: 13px; }
.auth-form { display: flex; flex-direction: column; gap: 10px; }
.auth-error {
  margin-top: 10px;
  font-size: 13px;
  border-radius: 8px;
  padding: 8px 10px;
  border: 1px solid rgba(239,68,68,0.35);
  background: rgba(239,68,68,0.12);
  color: #fecaca;
}
.auth-error--info {
  border-color: rgba(59,130,246,0.35);
  background: rgba(59,130,246,0.12);
  color: #bfdbfe;
}
.auth-error--success {
  border-color: rgba(34,197,94,0.35);
  background: rgba(34,197,94,0.12);
  color: #bbf7d0;
}
.auth-error--danger {
  border-color: rgba(239,68,68,0.35);
  background: rgba(239,68,68,0.12);
  color: #fecaca;
}

/* Header */
.header {
  position: sticky; top: 0; z-index: 10;
  backdrop-filter: blur(10px);
  background: rgba(11, 16, 32, 0.85);
  border-bottom: 1px solid var(--border);
}
.header__inner { display: flex; align-items: center; justify-content: space-between; padding-top: 12px; padding-bottom: 12px; }
.header__brand { display: flex; align-items: center; gap: 12px; }
.header__home { color: var(--muted); text-decoration: none; font-size: 20px; }
.header__home:hover { color: var(--text); }
.header__title { font-weight: 800; font-size: 18px; }
.header__actions { display: flex; gap: 8px; }

/* Tabs */
.tabs {
  border-bottom: 1px solid var(--border);
  background: rgba(11, 16, 32, 0.5);
}
.tabs__inner { display: flex; gap: 0; }
.tab {
  appearance: none; border: none; background: none;
  color: var(--muted); padding: 12px 18px;
  font-weight: 600; font-size: 14px; cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
}
.tab:hover { color: var(--text); }
.tab--active { color: var(--text); border-bottom-color: var(--accent); }

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

.main { padding-top: 0; padding-bottom: 32px; }

/* Inputs */
.input {
  appearance: none;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.3);
  color: var(--text);
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 13px;
  font-family: inherit;
}
.input:focus { outline: none; border-color: rgba(255,255,255,0.3); }
.input--sm { padding: 6px 8px; font-size: 12px; }
.textarea { resize: vertical; min-height: 60px; }

/* Buttons */
.btn {
  appearance: none;
  border: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(255,255,255,0.10), rgba(255,255,255,0.04));
  color: var(--text);
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
  text-decoration: none;
  display: inline-flex; align-items: center; gap: 6px;
  transition: background 0.15s, border-color 0.15s;
  white-space: nowrap;
}
.btn:hover { border-color: rgba(255,255,255,0.22); background: linear-gradient(180deg, rgba(255,255,255,0.14), rgba(255,255,255,0.06)); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn--sm { padding: 5px 10px; font-size: 12px; }
.btn--xs { padding: 3px 7px; font-size: 11px; border-radius: 6px; }
.btn--accent { border-color: rgba(246,130,31,0.5); background: linear-gradient(180deg, rgba(246,130,31,0.3), rgba(246,130,31,0.12)); }
.btn--accent:hover { border-color: rgba(246,130,31,0.7); }
.btn--danger { border-color: rgba(239,68,68,0.4); background: linear-gradient(180deg, rgba(239,68,68,0.2), rgba(239,68,68,0.08)); color: #fca5a5; }
.btn--danger:hover { border-color: rgba(239,68,68,0.6); }
.btn--success { border-color: rgba(34,197,94,0.4); background: linear-gradient(180deg, rgba(34,197,94,0.2), rgba(34,197,94,0.08)); color: #86efac; }
.btn--success:hover { border-color: rgba(34,197,94,0.6); }
.btn--muted { color: var(--muted); }

/* Fields */
.field { display: flex; align-items: center; gap: 8px; }
.field--col { flex-direction: column; align-items: stretch; gap: 4px; }
.field__label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; font-weight: 700; }

/* Toolbar */
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 8px 0; }

/* Aggregate bar */
.agg-bar {
  display: flex; gap: 10px; flex-wrap: wrap; padding: 12px 0;
}
.agg-card {
  border: 1px solid var(--border);
  background: var(--panel2);
  border-radius: 10px;
  padding: 10px 14px;
  min-width: 120px;
}
.agg-card__label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.agg-card__value { font-size: 18px; font-weight: 800; margin-top: 2px; }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); }
th { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; font-weight: 700; position: sticky; top: 0; background: var(--bg); }
tr:hover td { background: rgba(255,255,255,0.03); }
.row--hidden { opacity: 0.5; }
.badge { display: inline-block; padding: 2px 6px; border-radius: 4px; font-size: 11px; font-weight: 600; }
.badge--hidden { background: rgba(239,68,68,0.2); color: #fca5a5; }
.badge--visible { background: rgba(34,197,94,0.15); color: #86efac; }

/* Section titles */
.section-title { font-size: 15px; font-weight: 700; margin: 18px 0 8px; }

/* Error */
.error {
  padding: 12px; border-radius: 10px;
  border: 1px solid rgba(239,68,68,0.4);
  background: rgba(239,68,68,0.12);
  color: var(--text); white-space: pre-wrap;
  margin: 8px 0;
}

.muted { color: var(--muted); font-size: 12px; }

/* Comment rows */
.comment-cell { max-width: 300px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Modal */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
}
.modal-overlay[hidden] {
  display: none;
}
.modal {
  background: #151b30;
  border: 1px solid var(--border);
  border-radius: 14px;
  width: 440px; max-width: 92vw;
  max-height: 90vh; overflow-y: auto;
}
.modal__header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal__title { margin: 0; font-size: 16px; font-weight: 700; }
.modal__close { appearance: none; border: none; background: none; color: var(--muted); font-size: 22px; cursor: pointer; padding: 0; }
.modal__close:hover { color: var(--text); }
.modal__body { padding: 16px 20px; display: flex; flex-direction: column; gap: 12px; }
.modal__actions { display: flex; gap: 8px; padding-top: 8px; }

/* Toast */
.toast-container {
  position: fixed; bottom: 20px; right: 20px;
  display: flex; flex-direction: column; gap: 8px;
  z-index: 200;
}
.toast {
  padding: 10px 16px; border-radius: 8px;
  font-size: 13px; font-weight: 600;
  animation: toastIn 0.3s ease;
}
.toast--success { background: rgba(34,197,94,0.9); color: #fff; }
.toast--error { background: rgba(239,68,68,0.9); color: #fff; }

@keyframes toastIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Responsive */
@media (max-width: 640px) {
  .agg-bar { flex-direction: column; }
  .toolbar { flex-direction: column; align-items: stretch; }
}
