/* ================================================================
   SP CHECKER v2 — Design System
   Single-file CSS. Dark default, light via [data-theme="light"].
   No patches, no !important, no overrides. Clean tokens.
   ================================================================ */

/* --- Reset --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* --- Tokens (dark, default) --- */
:root {
  color-scheme: dark;

  /* Surfaces */
  --bg:       #0c1017;
  --surface:  #141820;
  --raised:   #1a1f2a;
  --overlay:  rgba(0,0,0,.55);

  /* Text */
  --text:     #e4e8f0;
  --muted:    #8a92a4;
  --faint:    #5a6174;

  /* Accent */
  --accent:   #5b8def;
  --accent-t: rgba(91,141,239,.12);

  /* Borders */
  --border:   rgba(255,255,255,.08);
  --border-s: rgba(255,255,255,.04);

  /* Semantic */
  --ok:       #34c77b;
  --ok-t:     rgba(52,199,123,.12);
  --warn:     #f0a944;
  --warn-t:   rgba(240,169,68,.12);
  --err:      #ef5b5b;
  --err-t:    rgba(239,91,91,.12);
  --info:     #5b8def;
  --info-t:   rgba(91,141,239,.12);
  --purple:   #a78bfa;
  --purple-t: rgba(167,139,250,.12);

  /* Radius */
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 20px;
  --r-full: 999px;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0,0,0,.25);
  --shadow-md: 0 4px 14px rgba(0,0,0,.30);
  --shadow-lg: 0 12px 40px rgba(0,0,0,.40);

  /* Typography */
  --font: 'Inter', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

/* --- Tokens (light) --- */
html[data-theme="light"] {
  color-scheme: light;
  --bg:       #f5f6fa;
  --surface:  #ffffff;
  --raised:   #f0f1f5;
  --overlay:  rgba(0,0,0,.25);
  --text:     #1a1e28;
  --muted:    #6b7280;
  --faint:    #9ca3af;
  --accent:   #3b6ee6;
  --accent-t: rgba(59,110,230,.08);
  --border:   rgba(0,0,0,.08);
  --border-s: rgba(0,0,0,.04);
  --ok-t:     rgba(34,160,90,.08);
  --warn-t:   rgba(200,140,40,.08);
  --err-t:    rgba(200,60,60,.08);
  --info-t:   rgba(59,110,230,.08);
  --purple-t: rgba(120,80,200,.08);
  --shadow-sm: 0 1px 3px rgba(0,0,0,.06);
  --shadow-md: 0 4px 14px rgba(0,0,0,.08);
  --shadow-lg: 0 12px 40px rgba(0,0,0,.12);
}

/* --- Base --- */
body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.55;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; height: auto; }

/* --- Layout --- */
.wrap {
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px 20px;
}

/* --- Card --- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
}
.card + .card { margin-top: 16px; }

/* --- Header --- */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
}
.site-header .inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 10px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: inherit;
  flex-shrink: 0;
}
.brand-logo {
  width: 32px; height: 32px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--border);
}
.brand-title {
  font-weight: 800;
  font-size: 16px;
  letter-spacing: .4px;
  color: var(--text);
}
.brand-sub {
  font-size: 10px;
  color: var(--faint);
  line-height: 1.2;
}

/* Nav */
.main-nav {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-left: auto;
}
.nav-link {
  padding: 6px 12px;
  border-radius: var(--r-sm);
  color: var(--muted);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  transition: background .15s, color .15s;
  white-space: nowrap;
}
.nav-link:hover { background: var(--accent-t); color: var(--text); text-decoration: none; }
.nav-link.active { background: var(--accent-t); color: var(--accent); font-weight: 600; }

.session-mini { margin-left: 8px; }
.session-mini .nav-link { color: var(--faint); }

/* --- KPI Tiles --- */
.kpi-row { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.tile {
  flex: 1 1 180px;
  min-width: 160px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 16px 18px;
  text-decoration: none;
  color: inherit;
  transition: transform .15s, box-shadow .15s;
  cursor: pointer;
}
.tile:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); text-decoration: none; }
.tile-num { font-size: 28px; font-weight: 800; line-height: 1.1; }
.tile-label { font-size: 12px; color: var(--muted); margin-top: 4px; }
.tile.accent .tile-num { color: var(--accent); }
.tile.ok .tile-num { color: var(--ok); }
.tile.warn .tile-num { color: var(--warn); }
.tile.err .tile-num { color: var(--err); }
.tile.purple .tile-num { color: var(--purple); }

/* --- Toolbar --- */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}
.toolbar-title { font-size: 16px; font-weight: 700; }
.toolbar-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* --- Filters --- */
.filters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}
.filters select,
.filters input[type="search"],
.filters input[type="text"],
.filters input[type="number"] {
  background: var(--raised);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 7px 10px;
  font: inherit;
  font-size: 13px;
}
.filters select:focus,
.filters input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-t);
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: var(--raised);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: background .15s;
  white-space: nowrap;
}
.btn:hover { background: var(--accent-t); text-decoration: none; }
.btn-primary { background: var(--accent); color: #fff; border-color: transparent; }
.btn-primary:hover { opacity: .9; }
.btn-danger { border-color: var(--err); color: var(--err); }
.btn-danger:hover { background: var(--err-t); }
.btn-sm { padding: 5px 10px; font-size: 12px; border-radius: 6px; }

/* --- Table --- */
.table { width: 100%; border-collapse: collapse; }
.table thead th {
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  padding: 10px 10px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--surface);
  white-space: nowrap;
}
.table tbody td {
  padding: 10px 10px;
  border-bottom: 1px solid var(--border-s);
  font-size: 13px;
  vertical-align: middle;
}
.table tbody tr { transition: background .1s; }
.table tbody tr:hover { background: var(--accent-t); }
.table tbody tr.clickable { cursor: pointer; }

/* Sort links */
.sort-link { color: var(--muted); text-decoration: none; }
.sort-link:hover { color: var(--text); text-decoration: none; }

/* Truncated cells */
.cell-trunc { max-width: 340px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* --- Pills / Badges --- */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: var(--r-full);
  font-size: 12px;
  font-weight: 500;
  background: var(--raised);
  border: 1px solid var(--border);
  white-space: nowrap;
}
.pill.ok   { background: var(--ok-t);   border-color: var(--ok);   color: var(--ok); }
.pill.warn { background: var(--warn-t); border-color: var(--warn); color: var(--warn); }
.pill.err  { background: var(--err-t);  border-color: var(--err);  color: var(--err); }
.pill.info { background: var(--info-t); border-color: var(--info); color: var(--info); }
.pill.purple { background: var(--purple-t); border-color: var(--purple); color: var(--purple); }
.pill.off  { opacity: .5; }

/* --- Pagination --- */
.pagination { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 14px; align-items: center; }
.pg {
  padding: 5px 10px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: var(--raised);
  color: var(--text);
  text-decoration: none;
  font-size: 13px;
}
.pg:hover { background: var(--accent-t); text-decoration: none; }
.pg.active { background: var(--accent-t); border-color: var(--accent); color: var(--accent); font-weight: 600; }
.pg.disabled { opacity: .35; pointer-events: none; }

/* --- Modal --- */
.modal-backdrop {
  position: fixed; inset: 0;
  background: var(--overlay);
  backdrop-filter: blur(4px);
  display: none; z-index: 900;
}
.modal-backdrop.show { display: block; }
.modal {
  position: fixed; inset: 0;
  display: none;
  justify-content: center;
  align-items: flex-start;
  padding: 80px 16px 40px;
  z-index: 901;
  overflow: auto;
}
.modal.show { display: flex; }
.modal-card {
  width: min(720px, 96vw);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}
.modal-title { font-weight: 700; font-size: 15px; }
.modal-body {
  padding: 18px 20px;
  max-height: 65vh;
  overflow: auto;
}
.modal-body dl {
  display: grid;
  grid-template-columns: 150px 1fr;
  gap: 6px 14px;
}
.modal-body dt { color: var(--muted); font-size: 12px; }
.modal-body dd { word-break: break-word; }

/* --- Forms --- */
.form-row { display: flex; flex-direction: column; gap: 4px; margin-bottom: 14px; }
.form-row label { font-size: 12px; color: var(--muted); font-weight: 500; }
.form-row input,
.form-row select,
.form-row textarea {
  background: var(--raised);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 8px 10px;
  font: inherit;
  font-size: 13px;
}
.form-row textarea { font-family: var(--mono); font-size: 12px; min-height: 90px; resize: vertical; }
.form-row input:focus,
.form-row select:focus,
.form-row textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-t);
}
.form-inline { display: flex; gap: 14px; flex-wrap: wrap; }
.form-check { flex-direction: row; align-items: center; gap: 8px; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }

/* --- Flash --- */
.flash { padding: 10px 14px; border-radius: var(--r-sm); margin-bottom: 14px; font-size: 13px; }
.flash.ok { background: var(--ok-t); border: 1px solid var(--ok); color: var(--ok); }
.flash.err { background: var(--err-t); border: 1px solid var(--err); color: var(--err); }

/* --- Profile --- */
.profile-head { display: flex; align-items: center; gap: 16px; }
.avatar {
  width: 48px; height: 48px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--purple));
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 18px; color: #fff;
  flex-shrink: 0;
}
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; font-size: 13px; }
.kv dt { color: var(--muted); font-size: 12px; }
.kv dd { word-break: break-word; }

/* --- Grid --- */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 900px) { .grid-2 { grid-template-columns: 1fr; } }

/* --- Tabs --- */
.tabs { display: flex; gap: 4px; margin-bottom: 16px; }
.tab {
  padding: 8px 14px;
  border-radius: var(--r-sm);
  background: var(--raised);
  border: 1px solid var(--border);
  color: var(--muted);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  transition: background .15s, color .15s;
}
.tab:hover { background: var(--accent-t); color: var(--text); text-decoration: none; }
.tab.active { background: var(--accent-t); border-color: var(--accent); color: var(--accent); font-weight: 600; }

/* --- Misc --- */
.mono { font-family: var(--mono); font-size: 12px; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.mt-sm { margin-top: 8px; }
.mt-md { margin-top: 16px; }
.mb-sm { margin-bottom: 8px; }
.mb-md { margin-bottom: 16px; }
.gap-sm { gap: 8px; }
.flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.empty { padding: 20px; text-align: center; color: var(--faint); }

/* --- Loader spinner --- */
.spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* --- Back to top --- */
#backToTop {
  position: fixed; bottom: 24px; right: 24px;
  width: 38px; height: 38px;
  border: none; border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 16px;
  cursor: pointer;
  box-shadow: var(--shadow-md);
  display: none;
  z-index: 800;
  transition: transform .15s;
}
#backToTop:hover { transform: translateY(-2px); }

/* --- Theme toggle FAB --- */
.theme-fab {
  position: fixed; bottom: 24px; left: 24px;
  width: 38px; height: 38px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--surface);
  color: var(--muted);
  font-size: 16px;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  z-index: 800;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s;
}
.theme-fab:hover { background: var(--accent-t); color: var(--accent); }

/* --- Responsive --- */
@media (max-width: 768px) {
  .wrap { padding: 16px 12px; }
  .kpi-row { gap: 8px; }
  .tile { min-width: 140px; padding: 12px 14px; }
  .tile-num { font-size: 22px; }
  .site-header .inner { padding: 8px 12px; gap: 10px; }
  .main-nav { gap: 2px; }
  .nav-link { padding: 5px 8px; font-size: 12px; }
  .toolbar { gap: 8px; }
}

/* --- Scrollbar --- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }

/* --- Print --- */
@media print {
  .site-header, #backToTop, .theme-fab, .btn, .filters { display: none; }
  .card { box-shadow: none; border: 1px solid #ddd; }
  body { background: #fff; color: #000; }
}
