/* ============================================================
   GWS Hub design system — black minimal
   Tokens are namespaced --hub-* so they can never collide with
   page-local :root vars (the estimator owns --bg/--card/etc).
   Reference: the /login page. Cyan is for interaction only.
   ============================================================ */

:root {
  /* Surface ramp */
  --hub-black: #060d14;
  --hub-bg: #8bbaea;
  --hub-surface: #21384f;
  --hub-surface-2: #060d13;
  --hub-surface-3: #101c28;
  --hub-border: #30649c;
  --hub-border-strong: #3d5f82;

  /* Text ramp */
  --hub-text-bright: #ffffff;
  --hub-text: #eef3fc;
  --hub-text-2: #7abaff;
  --hub-text-3: #7b9cbd;
  --hub-text-4: #496887;
  --hub-page-text: #0e2438;      /* headings sitting directly on the page ground */
  --hub-page-text-2: #1d3c5a;    /* secondary text on the page ground */

  /* Accent — interaction/focus only, never decoration */
  --hub-accent: #05c1ff;
  --hub-accent-dim: rgba(120, 228, 255, 0.1);
  --hub-focus-ring: 0 0 0 2px rgba(120, 228, 255, 0.55);
  --hub-accent-grad: linear-gradient(135deg, #00d5ff 0%, #00fffb 100%);

  /* Semantic set (the only green/red/orange in the Hub) */
  --hub-green: #4ade80;
  --hub-green-dim: rgba(74, 222, 128, 0.12);
  --hub-red: #f28b82;
  --hub-red-dim: rgba(242, 139, 130, 0.12);
  --hub-orange: #fbbf24;
  --hub-orange-dim: rgba(251, 191, 36, 0.12);

  /* Shape, depth, rhythm */
  --hub-r-sm: 6px;
  --hub-r: 10px;
  --hub-r-lg: 16px;
  --hub-card-grad: linear-gradient(165deg, #182b3f 0%, #000000 100%);
  --hub-inner-light: inset 0 1px 0 rgba(160, 200, 255, 0.12);
  --hub-r-full: 999px;
  --hub-shadow-sm: 0 2px 6px rgba(2, 6, 18, 0.55);
  --hub-shadow: 0 2px 6px rgba(2, 6, 18, 0.55), 0 12px 32px rgba(2, 6, 18, 0.45);
  --hub-shadow-lg: 0 24px 64px rgba(0, 0, 0, 0.55);
  --hub-sp-1: 4px;
  --hub-sp-2: 8px;
  --hub-sp-3: 12px;
  --hub-sp-4: 16px;
  --hub-sp-5: 24px;
  --hub-sp-6: 32px;
  --hub-font: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;

  /* Active/selected element inversion */
  --hub-active-bg: #ffffff;
  --hub-active-fg: #0a0d1f;
  --hub-grad-fg: #0a0d1f;
}

/* ---- Light theme (toggle in nav; persisted in localStorage) ---- */
html[data-theme="light"] {
  --hub-black: #ffffff;
  --hub-bg: #5cc0ff;
  --hub-surface: #ffffff;
  --hub-surface-2: #f5f5ff;
  --hub-surface-3: #c8dcf4;
  --hub-border: #103e70;
  --hub-border-strong: #b6c5d6;
  --hub-text-bright: #071421;
  --hub-text: #17293c;
  --hub-text-2: #1b3c5f;
  --hub-text-3: #54708c;
  --hub-text-4: #8ba1b5;
  --hub-page-text: #0c2036;
  --hub-page-text-2: #1c4266;
  --hub-accent: #0e9fd8;
  --hub-accent-dim: rgba(14, 159, 216, 0.12);
  --hub-focus-ring: 0 0 0 2px rgba(14, 159, 216, 0.45);
  --hub-accent-grad: linear-gradient(135deg, #14c1f5 0%, #02c6f7 100%);
  --hub-green: #16a34a;
  --hub-green-dim: rgba(22, 163, 74, 0.12);
  --hub-red: #dc2626;
  --hub-red-dim: rgba(220, 38, 38, 0.1);
  --hub-orange: #d97706;
  --hub-orange-dim: rgba(217, 119, 6, 0.12);
  --hub-card-grad: linear-gradient(165deg, #ffffff 0%, #b3daff 100%);
  --hub-inner-light: inset 0 1px 0 rgba(255, 255, 255, 0.8);
  --hub-shadow-sm: 0 1px 2px rgba(23, 43, 66, 0.08);
  --hub-shadow: 0 1px 2px rgba(23, 43, 66, 0.08), 0 8px 24px rgba(23, 43, 66, 0.1);
  --hub-shadow-lg: 0 24px 64px rgba(23, 43, 66, 0.2);
  --hub-active-bg: #12283c;
  --hub-active-fg: #ffffff;
  --hub-grad-fg: #ffffff;
}
html[data-theme="light"] body {
  background-image: linear-gradient(180deg, #ffffff 0%, #5cc0ff 360px);
}
html[data-theme="light"] body::before {
  background:
    radial-gradient(1100px 540px at 45% -240px, rgba(47, 196, 242, 0.1), transparent 60%),
    radial-gradient(950px 520px at 88% -180px, rgba(47, 126, 232, 0.06), transparent 65%);
}
html[data-theme="light"] .nav-brand img { border-radius: 8px; }

/* ---- Base ---- */
html { scrollbar-gutter: stable; }
body {
  background-image: linear-gradient(180deg, #182b3f 0%, #8bbaea 360px);
  background-repeat: no-repeat;
}
body::before {
  content: ''; position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background:
    radial-gradient(1100px 540px at 45% -240px, rgba(110, 231, 255, 0.13), transparent 60%),
    radial-gradient(950px 520px at 88% -180px, rgba(46, 143, 255, 0.1), transparent 65%);
}
body > * { position: relative; z-index: 1; }
::selection { background: rgba(120, 228, 255, 0.25); }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: var(--hub-border-strong); border-radius: 5px; border: 2px solid var(--hub-bg); }
*::-webkit-scrollbar-thumb:hover { background: var(--hub-text-4); }

:focus-visible { outline: none; box-shadow: var(--hub-focus-ring); border-radius: var(--hub-r-sm); }

.hub-container { max-width: 1280px; margin: 0 auto; padding: var(--hub-sp-5); }
.hub-container-wide { max-width: 1600px; margin: 0 auto; padding: var(--hub-sp-5); }

/* ---- Page header (the one h1 style) ---- */
.page-header { display: flex; align-items: center; justify-content: space-between; gap: var(--hub-sp-4); margin-bottom: var(--hub-sp-5); }
.page-header h1 { font-size: 22px; font-weight: 600; color: var(--hub-text-bright); letter-spacing: -0.01em; }
.page-header-sub { font-size: 13px; color: var(--hub-text-3); margin-top: 2px; }
.page-header-actions { display: flex; align-items: center; gap: var(--hub-sp-2); }

/* ---- Cards & KPIs ---- */
.card { background: var(--hub-card-grad); border: 1px solid var(--hub-border); border-radius: var(--hub-r-lg); padding: var(--hub-sp-5); box-shadow: var(--hub-inner-light), var(--hub-shadow-sm); transition: border-color 0.15s; }
.card-title { font-size: 11px; font-weight: 600; color: var(--hub-text-3); text-transform: uppercase; letter-spacing: 1.5px; margin-bottom: var(--hub-sp-4); }
.card-link { cursor: pointer; }
.card-link:hover { border-color: var(--hub-border-strong); transform: translateY(-1px); }

.kpi { background: var(--hub-surface); border: 1px solid var(--hub-border); border-radius: var(--hub-r-lg); padding: var(--hub-sp-4) var(--hub-sp-5); }
.kpi-value { font-size: 26px; font-weight: 700; color: var(--hub-text-bright); font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.kpi-label { font-size: 11px; font-weight: 500; color: var(--hub-text-3); text-transform: uppercase; letter-spacing: 1.5px; margin-top: var(--hub-sp-1); }
.kpi-value.good { color: var(--hub-green); }
.kpi-value.bad { color: var(--hub-red); }
.kpi-value.warn { color: var(--hub-orange); }

/* ---- Buttons ---- */
.btn, .btn-secondary, .btn-ghost, .btn-danger {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--hub-sp-2);
  padding: 9px 16px; border-radius: var(--hub-r-sm); font-family: var(--hub-font);
  font-size: 14px; font-weight: 600; letter-spacing: 0.2px; cursor: pointer;
  border: 1px solid transparent; text-decoration: none; white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, color 0.15s, transform 0.1s;
}
.btn { background: var(--hub-accent-grad); color: var(--hub-grad-fg); }
.btn:hover { filter: brightness(1.08); }
.btn-secondary { background: var(--hub-surface-2); color: var(--hub-text); border-color: var(--hub-border-strong); }
.btn-secondary:hover { background: var(--hub-surface-3); border-color: var(--hub-text-4); }
.btn-ghost { background: transparent; color: var(--hub-text-2); }
.btn-ghost:hover { background: var(--hub-surface-2); color: var(--hub-text); }
.btn-danger { background: var(--hub-red-dim); color: var(--hub-red); border-color: transparent; }
.btn-danger:hover { background: rgba(242, 139, 130, 0.2); }
.btn:active, .btn-secondary:active, .btn-ghost:active, .btn-danger:active { transform: scale(0.99); }
.btn:disabled, .btn-secondary:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }
.btn-sm { padding: 5px 11px; font-size: 13px; }

.btn-spinner { width: 15px; height: 15px; border: 2px solid rgba(10, 13, 31, 0.3); border-top-color: #0a0d1f; border-radius: 50%; animation: hub-spin 0.7s linear infinite; }
.btn-secondary .btn-spinner, .btn-ghost .btn-spinner { border-color: rgba(255, 255, 255, 0.2); border-top-color: var(--hub-text); }
@keyframes hub-spin { to { transform: rotate(360deg); } }

/* ---- Forms ---- */
.label { display: block; font-size: 12px; font-weight: 500; color: var(--hub-text-2); margin-bottom: 6px; }
.input, .select, .textarea {
  width: 100%; padding: 10px 12px; background: var(--hub-surface-2);
  border: 1px solid var(--hub-border); border-radius: var(--hub-r-sm);
  color: var(--hub-text); font-size: 14px; font-family: var(--hub-font);
  outline: none; transition: border-color 0.2s, background 0.2s;
}
.input::placeholder, .textarea::placeholder { color: var(--hub-text-4); }
.input:focus, .select:focus, .textarea:focus { border-color: var(--hub-accent); box-shadow: none; }
.select { appearance: none; -webkit-appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b6b6b' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 32px; }
.textarea { resize: vertical; min-height: 80px; }
input:-webkit-autofill, input:-webkit-autofill:hover, input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--hub-text);
  -webkit-box-shadow: 0 0 0 1000px var(--hub-surface-2) inset;
  transition: background-color 9999s ease-in-out 0s;
}

/* ---- Tables ---- */
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th {
  text-align: left; padding: 10px 14px; font-size: 11px; font-weight: 600;
  color: var(--hub-text-3); text-transform: uppercase; letter-spacing: 1px;
  background: var(--hub-surface-2); position: sticky; top: 0; z-index: 1;
  border-bottom: 1px solid var(--hub-border);
}
.table th:first-child { border-top-left-radius: var(--hub-r-sm); }
.table th:last-child { border-top-right-radius: var(--hub-r-sm); }
.table td { padding: 11px 14px; border-bottom: 1px solid var(--hub-border); color: var(--hub-text-2); }
.table td.num { font-variant-numeric: tabular-nums; text-align: right; }
.table tbody tr { transition: background 0.12s; }
.table tbody tr:hover { background: var(--hub-surface-2); }
.table tbody tr:last-child td { border-bottom: none; }

/* ---- Chips & badges ---- */
.chip {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px;
  border-radius: var(--hub-r-full); font-size: 12px; font-weight: 600;
  background: var(--hub-surface-3); color: var(--hub-text-2); white-space: nowrap;
}
.chip-green { background: var(--hub-green-dim); color: var(--hub-green); }
.chip-red { background: var(--hub-red-dim); color: var(--hub-red); }
.chip-orange { background: var(--hub-orange-dim); color: var(--hub-orange); }
.chip-accent { background: var(--hub-accent-dim); color: var(--hub-accent); }
.badge { display: inline-flex; align-items: center; justify-content: center; min-width: 18px; height: 18px; padding: 0 5px; border-radius: var(--hub-r-full); font-size: 11px; font-weight: 700; background: var(--hub-accent); color: #000; font-variant-numeric: tabular-nums; }

/* ---- Modals ---- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center; z-index: 2000;
  animation: hub-fade 0.15s ease-out;
}
.modal {
  background: var(--hub-surface-3); border: 1px solid var(--hub-border-strong);
  border-radius: var(--hub-r-lg); box-shadow: var(--hub-shadow-lg);
  width: 100%; max-width: 480px; max-height: 85vh; overflow-y: auto;
  padding: var(--hub-sp-5); margin: var(--hub-sp-4);
  animation: hub-rise 0.18s ease-out;
}
.modal h2, .modal h3 { font-size: 16px; font-weight: 600; color: var(--hub-text-bright); margin-bottom: var(--hub-sp-4); }

/* ---- Toasts ---- */
.hub-toast-stack { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: var(--hub-sp-2); z-index: 3000; }
.hub-toast {
  background: var(--hub-surface-3); border: 1px solid var(--hub-border-strong);
  border-radius: var(--hub-r); box-shadow: var(--hub-shadow);
  padding: 11px 16px; font-size: 14px; color: var(--hub-text);
  display: flex; align-items: center; gap: var(--hub-sp-2);
  animation: hub-rise 0.2s ease-out; max-width: 380px;
}
.hub-toast.green { border-left: 3px solid var(--hub-green); }
.hub-toast.red { border-left: 3px solid var(--hub-red); }
.hub-toast.leaving { opacity: 0; transform: translateY(6px); transition: opacity 0.2s, transform 0.2s; }

/* ---- Skeletons / empty states ---- */
.skeleton { background: linear-gradient(90deg, var(--hub-surface-2) 25%, var(--hub-surface-3) 50%, var(--hub-surface-2) 75%); background-size: 200% 100%; animation: hub-shimmer 1.4s infinite; border-radius: var(--hub-r-sm); }
@keyframes hub-shimmer { to { background-position: -200% 0; } }
.empty-state { text-align: center; padding: var(--hub-sp-6); color: var(--hub-text-3); font-size: 14px; }

/* ---- Icons (Lucide) ---- */
.icon { width: 16px; height: 16px; stroke-width: 2; vertical-align: -3px; }
.icon-sm { width: 14px; height: 14px; }
.icon-lg { width: 20px; height: 20px; }

/* ---- Utilities ---- */
.muted { color: var(--hub-text-3); }
.mono-num { font-variant-numeric: tabular-nums; }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: var(--hub-sp-3); }
.mt-2 { margin-top: var(--hub-sp-2); } .mt-4 { margin-top: var(--hub-sp-4); } .mt-5 { margin-top: var(--hub-sp-5); }
.mb-2 { margin-bottom: var(--hub-sp-2); } .mb-4 { margin-bottom: var(--hub-sp-4); } .mb-5 { margin-bottom: var(--hub-sp-5); }

/* ---- Motion ---- */
@keyframes hub-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes hub-rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.page-enter { animation: hub-fade 0.24s ease-out; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
