/* ==========================================================================
   Ibrahim Upwork Manager - dashboard styles
   Desktop-first, responsive. Neutral SaaS surface, one accent colour,
   dense tables, no decorative motion.
   ========================================================================== */

:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #fbfcfd;
  --border: #e3e7ed;
  --border-strong: #cfd6e0;
  --text: #10151f;
  --text-2: #55617a;
  --text-3: #8a93a6;
  --accent: #0f6f63;
  --accent-weak: #e6f2f0;
  --accent-text: #0b544b;
  --danger: #b42318;
  --danger-weak: #fdeceb;
  --warn: #b54708;
  --warn-weak: #fdf3e7;
  --ok: #067647;
  --ok-weak: #e8f6ef;
  --info: #175cd3;
  --info-weak: #eaf1fd;

  --radius: 8px;
  --radius-sm: 5px;
  --shadow: 0 1px 2px rgb(16 21 31 / 0.06), 0 1px 3px rgb(16 21 31 / 0.04);
  --shadow-lg: 0 8px 24px rgb(16 21 31 / 0.12);
  --sidebar-w: 232px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0c111b;
    --surface: #121a28;
    --surface-2: #0f1725;
    --border: #222e42;
    --border-strong: #33415c;
    --text: #e8ecf3;
    --text-2: #9aa6bd;
    --text-3: #6c7893;
    --accent: #2dd4bf;
    --accent-weak: #10312e;
    --accent-text: #5eead4;
    --danger: #f97066;
    --danger-weak: #3a1613;
    --warn: #fdb022;
    --warn-weak: #3a2510;
    --ok: #47cd89;
    --ok-weak: #0d2b1e;
    --info: #6ba5ff;
    --info-weak: #10203c;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.35);
    --shadow-lg: 0 8px 24px rgb(0 0 0 / 0.5);
  }
}

* { box-sizing: border-box; }

/*
 * The `hidden` attribute is honoured by the UA stylesheet as `display: none`,
 * but ANY author rule that sets `display` beats it, because author styles win
 * over UA styles regardless of specificity. That silently defeated `hidden` on
 * `.login-screen { display: grid }` and `.banner { display: flex }`, which is
 * what allowed the login form and the dashboard to render at the same time.
 *
 * This rule makes `hidden` mean hidden, everywhere, permanently. Top-level auth
 * states no longer rely on it at all - they are mounted and unmounted - but any
 * future use of the attribute is now safe.
 */
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.011em; }
h1 { font-size: 1.375rem; }
h2 { font-size: 1.0625rem; }
h3 { font-size: 0.9375rem; }

code, .mono { font-family: var(--mono); font-size: 0.8125rem; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 3px;
}

/* --------------------------------------------------------------- Layout -- */

.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100dvh; }

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand { padding: 18px 18px 14px; border-bottom: 1px solid var(--border); }
.brand-name { font-size: 0.9375rem; font-weight: 650; letter-spacing: -0.01em; }
.brand-sub { font-size: 0.75rem; color: var(--text-3); margin-top: 2px; }

.nav { padding: 10px; display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; }
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px; border-radius: var(--radius-sm);
  color: var(--text-2); font-weight: 500; font-size: 0.875rem;
}
.nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav a.active { background: var(--accent-weak); color: var(--accent-text); font-weight: 600; }
.nav a .count { margin-left: auto; font-size: 0.75rem; color: var(--text-3); font-variant-numeric: tabular-nums; }
.nav-icon { width: 16px; text-align: center; opacity: 0.8; flex: none; }

.sidebar-foot { padding: 12px; border-top: 1px solid var(--border); display: grid; gap: 8px; }

.main { display: flex; flex-direction: column; min-width: 0; }

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 14px;
  padding: 12px 24px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.topbar h1 { flex: none; }
.topbar-spacer { flex: 1; }

.view { padding: 22px 24px 56px; max-width: 1500px; width: 100%; }
.view-section + .view-section { margin-top: 22px; }

/* --------------------------------------------------------------- Pieces -- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-head {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 16px; border-bottom: 1px solid var(--border);
}
.card-head h2, .card-head h3 { flex: none; }
.card-head .spacer { flex: 1; }
.card-body { padding: 16px; }
.card-body.tight { padding: 0; }

.grid { display: grid; gap: 14px; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.split { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); align-items: start; }

.stat { padding: 14px 16px; }
.stat-label { font-size: 0.75rem; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.045em; font-weight: 600; }
.stat-value { font-size: 1.625rem; font-weight: 640; margin-top: 4px; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.stat-hint { font-size: 0.75rem; color: var(--text-3); margin-top: 2px; }

.muted { color: var(--text-2); }
.dim { color: var(--text-3); }
.small { font-size: 0.8125rem; }
.tiny { font-size: 0.75rem; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.mt { margin-top: 12px; }
.mb { margin-bottom: 12px; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.stack { display: grid; gap: 10px; }

/* --------------------------------------------------------------- Badges -- */

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px; border-radius: 999px;
  font-size: 0.75rem; font-weight: 600; line-height: 1.5;
  border: 1px solid transparent; white-space: nowrap;
}
.badge.ok      { background: var(--ok-weak);     color: var(--ok); }
.badge.warn    { background: var(--warn-weak);   color: var(--warn); }
.badge.danger  { background: var(--danger-weak); color: var(--danger); }
.badge.info    { background: var(--info-weak);   color: var(--info); }
.badge.neutral { background: var(--surface-2);   color: var(--text-2); border-color: var(--border); }
.badge.accent  { background: var(--accent-weak); color: var(--accent-text); }

.dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; }

/* --------------------------------------------------------------- Score --- */

.score {
  display: inline-flex; align-items: baseline; gap: 2px;
  font-variant-numeric: tabular-nums; font-weight: 680; font-size: 0.9375rem;
}
.score .of { font-size: 0.6875rem; color: var(--text-3); font-weight: 500; }
.score.s-high { color: var(--ok); }
.score.s-mid  { color: var(--warn); }
.score.s-low  { color: var(--text-3); }

.meter { height: 6px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; overflow: hidden; }
.meter > span { display: block; height: 100%; background: var(--accent); }

/* -------------------------------------------------------------- Buttons -- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 6px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  font: inherit; font-size: 0.8125rem; font-weight: 550; cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease;
}
.btn:hover:not(:disabled) { background: var(--surface-2); border-color: var(--text-3); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover:not(:disabled) { filter: brightness(1.08); }
.btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, var(--border)); }
.btn.danger:hover:not(:disabled) { background: var(--danger-weak); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn.ghost:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }
.btn.sm { padding: 3px 8px; font-size: 0.75rem; }
.btn.block { width: 100%; }

/* --------------------------------------------------------------- Forms --- */

label { display: block; font-size: 0.8125rem; font-weight: 560; color: var(--text-2); margin-bottom: 4px; }

input[type="text"], input[type="password"], input[type="number"], input[type="search"], select, textarea {
  width: 100%; padding: 6px 9px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  font: inherit; font-size: 0.8125rem;
}
textarea { min-height: 120px; resize: vertical; line-height: 1.6; }
textarea.tall { min-height: 300px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent); }

.field { min-width: 0; }
.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; align-items: end; }

.checkline { display: flex; align-items: center; gap: 7px; font-size: 0.8125rem; color: var(--text-2); }
.checkline input { width: auto; }

/* --------------------------------------------------------------- Table --- */

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.8125rem; }
thead th {
  position: sticky; top: 0; z-index: 1;
  text-align: left; padding: 8px 12px;
  background: var(--surface-2); color: var(--text-3);
  font-size: 0.6875rem; text-transform: uppercase; letter-spacing: 0.05em; font-weight: 650;
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
tbody td { padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover { background: var(--surface-2); }
td.num { text-align: right; font-variant-numeric: tabular-nums; }
.cell-title { font-weight: 560; color: var(--text); display: block; max-width: 46ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cell-sub { color: var(--text-3); font-size: 0.75rem; }

/* --------------------------------------------------------------- Banner -- */

.banner {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 11px 14px; border-radius: var(--radius);
  border: 1px solid; font-size: 0.8125rem;
}
.banner.warn   { background: var(--warn-weak);   border-color: color-mix(in srgb, var(--warn) 30%, transparent);   color: var(--warn); }
.banner.danger { background: var(--danger-weak); border-color: color-mix(in srgb, var(--danger) 30%, transparent); color: var(--danger); }
.banner.info   { background: var(--info-weak);   border-color: color-mix(in srgb, var(--info) 30%, transparent);   color: var(--info); }
.banner.ok     { background: var(--ok-weak);     border-color: color-mix(in srgb, var(--ok) 30%, transparent);     color: var(--ok); }
.banner strong { font-weight: 650; }
.banner .banner-body { flex: 1; min-width: 0; }

/* ------------------------------------------------- Auth splash & login --- */

/*
 * Both of these are standalone full-viewport pages. Because app.js mounts only
 * one top-level tree at a time, neither ever shares the document with the
 * application shell, so no stacking, overlay or height trickery is involved.
 */
.auth-loading,
.login-screen {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth-loading { gap: 14px; align-content: center; justify-items: center; }
.auth-loading-mark {
  width: 42px; height: 42px; border-radius: 10px;
  display: grid; place-items: center;
  background: var(--accent); color: #fff;
  font-weight: 700; font-size: 0.9375rem; letter-spacing: -0.02em;
}
.auth-loading-text { color: var(--text-3); font-size: 0.8125rem; }

.login-card { width: 100%; max-width: 400px; }
.login-card .card-body { padding: 26px; }
.login-title { font-size: 1.1875rem; font-weight: 650; letter-spacing: -0.015em; }
.login-sub { color: var(--text-3); font-size: 0.8125rem; margin-top: 4px; margin-bottom: 20px; }
.login-card .banner { margin: 2px 0; }
.login-card form .btn { margin-top: 4px; }

@media (max-width: 480px) {
  .auth-loading, .login-screen { padding: 16px; }
  .login-card .card-body { padding: 20px; }
}

/* --------------------------------------------------------------- Modal --- */

.modal-backdrop {
  position: fixed; inset: 0; z-index: 100;
  background: rgb(8 12 20 / 0.45);
  display: grid; place-items: center; padding: 24px;
}
.modal { width: 100%; max-width: 620px; max-height: 86vh; overflow: auto; box-shadow: var(--shadow-lg); }

/* --------------------------------------------------------------- Toast --- */

.toasts { position: fixed; right: 18px; bottom: 18px; z-index: 200; display: grid; gap: 8px; max-width: 380px; }
.toast {
  padding: 10px 13px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border);
  box-shadow: var(--shadow-lg); font-size: 0.8125rem;
}
.toast.error { border-color: color-mix(in srgb, var(--danger) 45%, transparent); color: var(--danger); }
.toast.ok { border-color: color-mix(in srgb, var(--ok) 45%, transparent); color: var(--ok); }

/* ------------------------------------------------------ Next actions ----- */

.actions { list-style: none; margin: 0; padding: 0; }
.actions li {
  display: flex; align-items: center; gap: 14px;
  padding: 11px 16px; border-bottom: 1px solid var(--border);
}
.actions li:last-child { border-bottom: none; }
.actions .action-main { flex: 1; min-width: 0; }
.actions .action-title { font-weight: 570; font-size: 0.875rem; }
.actions .action-detail { color: var(--text-3); font-size: 0.78125rem; margin-top: 1px; }
.actions .action-info .action-title { color: var(--text-2); font-weight: 500; }
.actions .action-warn .action-title { color: var(--warn); }

/* --------------------------------------------- Score component detail ---- */

.component + .component { padding-top: 12px; border-top: 1px dashed var(--border); }
.component-reason { font-size: 0.8125rem; color: var(--text-2); margin: 4px 0 0 0; }
.evidence, .missing { margin-top: 4px; }
.evidence li { color: var(--text-3); }
.evidence li::marker { color: var(--ok); }
.missing li { color: var(--warn); }
.missing li::marker { color: var(--warn); }

/* ------------------------------------------------ Activation checklist --- */

.checklist { margin: 0; padding-left: 20px; display: grid; gap: 12px; }
.checklist li { padding-left: 4px; }
.checklist .step-title { font-weight: 570; font-size: 0.875rem; }
.checklist .verify { color: var(--accent-text); margin-top: 2px; }

.badge.mono { font-family: var(--mono); font-size: 0.6875rem; font-weight: 500; }

/* ------------------------------------------------------------ Utilities -- */

.empty { padding: 40px 16px; text-align: center; color: var(--text-3); font-size: 0.875rem; }
.kv { display: grid; grid-template-columns: minmax(120px, auto) 1fr; gap: 6px 16px; font-size: 0.8125rem; }
.kv dt { color: var(--text-3); }
.kv dd { margin: 0; color: var(--text); }
.pill-list { display: flex; flex-wrap: wrap; gap: 5px; }
.desc { white-space: pre-wrap; line-height: 1.65; font-size: 0.8438rem; color: var(--text-2); max-height: 420px; overflow: auto; }
.bar-row { display: grid; grid-template-columns: 150px 1fr 54px; gap: 10px; align-items: center; font-size: 0.8125rem; }
.bar-row .bar-label { color: var(--text-2); }
.bar-row .num { text-align: right; font-variant-numeric: tabular-nums; color: var(--text-2); }
.list-plain { margin: 0; padding-left: 18px; }
.list-plain li { margin: 3px 0; }
.token-box {
  font-family: var(--mono); font-size: 0.75rem; word-break: break-all;
  padding: 9px; border-radius: var(--radius-sm);
  background: var(--surface-2); border: 1px solid var(--border);
}
.skeleton { color: var(--text-3); padding: 28px 4px; font-size: 0.875rem; }

/* --------------------------------------------------------- Responsive --- */

@media (max-width: 1080px) {
  .grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.split { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: static; height: auto; flex-direction: row; align-items: center;
    overflow-x: auto; border-right: none; border-bottom: 1px solid var(--border);
  }
  .brand { border-bottom: none; border-right: 1px solid var(--border); white-space: nowrap; }
  .nav { flex-direction: row; padding: 8px; }
  .nav a .count { display: none; }
  .sidebar-foot { display: none; }
  .grid.cols-3, .grid.cols-2 { grid-template-columns: minmax(0, 1fr); }
  .view { padding: 16px; }
  .topbar { padding: 10px 16px; }
}

@media (max-width: 560px) {
  .grid.cols-4 { grid-template-columns: minmax(0, 1fr); }
  .cell-title { max-width: 26ch; }
}
