/* Look on top of Bootstrap: a calm page, white (or raised dark) cards, one accent per check kind.
   Tokens first; Bootstrap's own variables are pointed at them so its components follow. */
:root, [data-bs-theme="light"] {
  --page: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #f7f8fa;
  --line: #e4e7ec;
  --ink: #101828;
  --ink-2: #667085;
  --serp: #2563eb;
  --serp-hover: #1d4ed8;
  --llm: #7c3aed;
  --llm-hover: #6d28d9;
  --shadow: 0 1px 2px rgb(16 24 40 / .05), 0 1px 3px rgb(16 24 40 / .06);
  --bs-body-bg: var(--surface);
  --bs-body-color: var(--ink);
  --bs-border-color: var(--line);
  --bs-secondary-color: var(--ink-2);
  --bs-secondary-bg: var(--surface-2);
  --bs-tertiary-bg: var(--page);
}
[data-bs-theme="dark"] {
  --page: #0d1117;
  --surface: #161b22;
  --surface-2: #1c2330;
  --line: #2a3140;
  --ink: #e6edf3;
  --ink-2: #8b949e;
  --serp: #3b82f6;
  --serp-hover: #2563eb;
  --llm: #8b5cf6;
  --llm-hover: #7c3aed;
  --shadow: 0 1px 2px rgb(0 0 0 / .4);
  --bs-body-bg: var(--surface);
  --bs-body-color: var(--ink);
  --bs-border-color: var(--line);
  --bs-secondary-color: var(--ink-2);
  --bs-secondary-bg: var(--surface-2);
  --bs-tertiary-bg: var(--page);
}

body { background: var(--page); color: var(--ink); font-size: 15px; }
.app { display: grid; grid-template-columns: 260px minmax(0, 1fr); min-height: 100vh; }
.app.log-open { grid-template-columns: 260px minmax(0, 1fr) 380px; }
main { padding: 28px 32px 48px; max-width: 1240px; width: 100%; }
[hidden] { display: none !important; }
#page-title { font-weight: 650; letter-spacing: -.01em; }

/* Cards */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); }
section.card .card-body { padding: 20px 22px; }
section.card h2 { font-weight: 600; }
.stat-card .card-body { padding: 18px 20px; }
.stat-icon { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; font-size: 17px; margin-bottom: 12px; }
.stat-icon.blue { color: #2563eb; background: rgb(37 99 235 / .12); }
.stat-icon.teal { color: #0d9488; background: rgb(13 148 136 / .12); }
.stat-icon.green { color: #16a34a; background: rgb(22 163 74 / .12); }
.stat-icon.violet { color: #7c3aed; background: rgb(124 58 237 / .12); }
[data-bs-theme="dark"] .stat-icon.blue { color: #60a5fa; }
[data-bs-theme="dark"] .stat-icon.teal { color: #2dd4bf; }
[data-bs-theme="dark"] .stat-icon.green { color: #4ade80; }
[data-bs-theme="dark"] .stat-icon.violet { color: #a78bfa; }
.stat-label { color: var(--ink-2); font-size: 13px; }
.stat { font-size: 28px; font-weight: 700; line-height: 1.2; letter-spacing: -.02em; margin-top: 2px; }

/* Buttons: SERP = blue, LLM = violet, both solid with an icon (a spinner while running).
   Set through Bootstrap's own --bs-btn-* variables, so its hover/focus/active/disabled rules use our colours. */
.btn-run, .btn-ghost { display: inline-flex; align-items: center; gap: 8px; --bs-btn-border-radius: 9px; --bs-btn-padding-x: 14px; --bs-btn-padding-y: 8px; }
.btn-run {
  --c: var(--serp); --c-hover: var(--serp-hover);
  --bs-btn-font-weight: 600;
  --bs-btn-color: #fff; --bs-btn-bg: var(--c); --bs-btn-border-color: var(--c);
  --bs-btn-hover-color: #fff; --bs-btn-hover-bg: var(--c-hover); --bs-btn-hover-border-color: var(--c-hover);
  --bs-btn-active-color: #fff; --bs-btn-active-bg: var(--c-hover); --bs-btn-active-border-color: var(--c-hover);
  --bs-btn-disabled-color: #fff; --bs-btn-disabled-bg: var(--c); --bs-btn-disabled-border-color: var(--c); --bs-btn-disabled-opacity: .55;
  --bs-btn-focus-shadow-rgb: 59, 130, 246;
  box-shadow: 0 1px 2px rgb(16 24 40 / .12);
}
.btn-llm { --c: var(--llm); --c-hover: var(--llm-hover); --bs-btn-focus-shadow-rgb: 139, 92, 246; }
.btn-run.btn-sm { --bs-btn-padding-x: 11px; --bs-btn-padding-y: 5px; --bs-btn-font-size: 13px; gap: 6px; }
.btn-run .spinner-border { width: 14px; height: 14px; border-width: 2px; }
.btn-ghost {
  gap: 6px; --bs-btn-font-weight: 500;
  --bs-btn-color: var(--ink); --bs-btn-bg: var(--surface); --bs-btn-border-color: var(--line);
  --bs-btn-hover-color: var(--ink); --bs-btn-hover-bg: var(--surface-2); --bs-btn-hover-border-color: var(--line);
  --bs-btn-active-color: var(--ink); --bs-btn-active-bg: var(--surface-2); --bs-btn-active-border-color: var(--ink-2);
  --bs-btn-focus-shadow-rgb: 102, 112, 133;
}
#log-toggle[aria-expanded="true"] { --bs-btn-bg: var(--surface-2); --bs-btn-border-color: var(--ink-2); --bs-btn-hover-border-color: var(--ink-2); }
.dot { position: absolute; top: -3px; right: -3px; width: 10px; height: 10px; border-radius: 50%; background: var(--bs-danger); border: 2px solid var(--page); }

/* Sidebar */
.sidebar { background: var(--surface); border-right: 1px solid var(--line); padding: 22px 14px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.side-link { display: block; padding: 8px 10px; border-radius: 8px; color: var(--ink); text-decoration: none; }
.side-link:hover { background: var(--surface-2); }
.side-link[aria-current="page"] { background: rgb(37 99 235 / .1); color: var(--serp); font-weight: 600; }
[data-bs-theme="dark"] .side-link[aria-current="page"] { background: rgb(59 130 246 / .16); color: #93c5fd; }
.side-link small { display: block; color: var(--ink-2); font-size: 12px; font-weight: 400; }
.side-head { display: flex; justify-content: space-between; align-items: center; margin: 20px 10px 6px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-2); }
.side-head a { text-transform: none; letter-spacing: 0; font-size: 13px; text-decoration: none; }
.side-empty { color: var(--ink-2); font-size: 13px; padding: 4px 10px; }
.account { margin: 22px 10px 0; padding-top: 14px; border-top: 1px solid var(--line); overflow-wrap: anywhere; }

/* Tables */
.table { --bs-table-bg: transparent; --bs-table-hover-bg: var(--surface-2); margin-bottom: 0; }
.table > :not(caption) > * > * { padding: 10px 12px; border-bottom-color: var(--line); }
.table thead th { font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-2); white-space: nowrap; border-bottom-width: 1px; }
.table tbody tr:hover > * { background: var(--surface-2); }
.table tbody tr:last-child > * { border-bottom: 0; }
.table td { white-space: nowrap; }
.table td.wrap { white-space: normal; min-width: 200px; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .day { text-align: center; font-variant-numeric: tabular-nums; }
.table .today { background: rgb(37 99 235 / .06); }
.table .x { width: 1%; padding-right: 0; }
.table caption { caption-side: top; color: var(--ink-2); }
.kw-cell { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.icon-btn { width: 28px; height: 28px; padding: 0; border: 0; background: none; line-height: 1; color: var(--ink-2); border-radius: 6px; flex: none; }
.icon-btn.remove { font-size: 18px; }
.icon-btn.remove:hover { color: var(--bs-danger); background: var(--surface-2); }
.icon-btn.check-one { font-size: 16px; }
.icon-btn.check-one:hover:not(:disabled) { color: var(--serp); background: var(--surface-2); }
.icon-btn:disabled { opacity: .4; }

.form-control, .form-select { background-color: var(--surface); border-color: var(--line); border-radius: 8px; }
.form-label { color: var(--ink-2); }
.msg { min-height: 1.4em; margin: 6px 0 0; }
.chart { position: relative; height: 320px; }
.pre-line { white-space: pre-line; }

/* Log panel */
.log-panel { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; background: var(--surface); border-left: 1px solid var(--line); padding: 22px 18px; }
.log-lines { flex: 1; overflow: auto; font: 12px/1.55 var(--bs-font-monospace); }
.log-lines div { padding: 4px 0; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
.log-lines .err { color: var(--bs-danger); }
.log-lines .err time { color: var(--ink-2); }

/* Login */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.auth-card { width: 100%; max-width: 380px; }

.modal-content { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; }

/* Phones: sidebar becomes a strip above the page, the log slides over it */
@media (max-width: 800px) {
  .app, .app.log-open { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--line); padding: 12px 16px; }
  .brand { padding-bottom: 8px !important; }
  .side-head { margin: 8px 0 4px; }
  #site-nav { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; }
  #site-nav .side-link { white-space: nowrap; border: 1px solid var(--line); }
  main { padding: 16px 16px 40px; }
  .log-panel { position: fixed; inset: 0; z-index: 1040; height: auto; border-left: 0; }
}
