:root {
  --slate-900: #0f172a;
  --slate-800: #1e293b;
  --slate-700: #334155;
  --slate-500: #64748b;
  --slate-300: #cbd5e1;
  --slate-200: #e2e8f0;
  --slate-100: #f1f5f9;
  --slate-50:  #f8fafc;
  --indigo:    #6366f1;
  --green:     #16a34a;
  --red:       #ef4444;
  --amber:     #f59e0b;
  --white:     #ffffff;
  --radius-sm: 6px;
  --radius:    10px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.07);
  --shadow:    0 2px 8px rgba(0,0,0,0.10);
  /* Legacy aliases kept for templates that use them */
  --border: var(--slate-200);
  --meta:   var(--slate-500);
  --navy:   var(--slate-900);
  --navy-mid: var(--slate-700);
  --yellow: var(--amber);
}

[data-theme="dark"] {
  color-scheme: dark;
  --slate-900: #f8fafc;
  --slate-800: #e2e8f0;
  --slate-700: #cbd5e1;
  --slate-500: #94a3b8;
  --slate-300: #475569;
  --slate-200: #334155;
  --slate-100: #1e293b;
  --slate-50: #0f172a;
  --white: #111827;
  --border: #334155;
  --meta: #94a3b8;
  --navy: #020617;
  --navy-mid: #cbd5e1;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.35);
  --shadow: 0 3px 12px rgba(0,0,0,0.45);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font: 16px/1.6 'Inter', system-ui, Arial, sans-serif;
  color: var(--slate-700);
  background: var(--slate-50);
}

.container { width: min(100%, 1200px); margin: 0 auto; padding: 0 24px; }

/* ── Layout: sidebar + content ───────────────────────────────────────────── */
.layout { display: flex; align-items: stretch; min-height: 100vh; }

.sidebar {
  width: 248px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 16px 12px;
  background: linear-gradient(180deg, var(--slate-800) 0%, var(--slate-900) 100%);
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.sidebar__brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 4px 8px 12px;
  margin-bottom: 4px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}
.sidebar__logo {
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-decoration: none;
}
.sidebar__nav { display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; }
.sidebar__item {
  display: block;
  color: #cbd5e1;
  text-decoration: none;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background 0.15s, color 0.15s;
}
.sidebar__item:hover { background: rgba(255,255,255,0.10); color: #fff; }
.sidebar__item:focus-visible { outline: 2px solid var(--indigo); outline-offset: -2px; }
.sidebar__item--active { background: var(--indigo); color: #fff; }
.sidebar__item--active:hover { background: var(--indigo); }
.sidebar__item--home { font-weight: 600; color: #fff; }
.sidebar__empty { color: #94a3b8; font-size: 12px; padding: 8px 12px; }

/* ── Sidebar search ─────────────────────────────────────── */
.sidebar__search { padding: 0 4px 6px; }
.sidebar__search input {
  width: 100%;
  box-sizing: border-box;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: var(--radius-sm);
  color: #fff;
  font-size: 13px;
  padding: 6px 10px;
  outline: none;
  transition: border-color 0.15s, background 0.15s;
}
.sidebar__search input::placeholder { color: #64748b; }
.sidebar__search input:focus {
  border-color: var(--indigo);
  background: rgba(255,255,255,0.12);
}

/* ── Sidebar accordion groups ───────────────────────────── */
.sidebar__group { margin-bottom: 1px; }
.sidebar__group-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 8px 5px 10px;
  border-radius: var(--radius-sm);
  color: #64748b;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  user-select: none;
  transition: background 0.15s, color 0.15s;
}
.sidebar__group-header:hover { background: rgba(255,255,255,0.06); color: #94a3b8; }
.sidebar__group-chevron {
  font-size: 8px;
  flex-shrink: 0;
  color: #475569;
  transition: transform 0.2s ease;
}
.sidebar__group-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sidebar__group--open .sidebar__group-chevron { transform: rotate(90deg); }
.sidebar__group--open .sidebar__group-header { color: #94a3b8; }
.sidebar__group-members {
  overflow: hidden;
  max-height: 0;
  transition: max-height 0.22s ease;
}
.sidebar__group--open .sidebar__group-members { max-height: 1200px; }
.sidebar__group-members .sidebar__item {
  padding-left: 18px;
  font-size: 13px;
}

.sidebar__footer {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-top: 12px;
  margin-top: 4px;
  border-top: 1px solid rgba(255,255,255,0.1);
}
.sidebar__link {
  color: #94a3b8;
  text-decoration: none;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
}
.sidebar__link:hover { background: rgba(255,255,255,0.10); color: #fff; }
.sidebar__link:focus-visible { outline: 2px solid var(--indigo); outline-offset: -2px; }
.sidebar__user { color: #64748b; font-size: 12px; padding: 6px 12px; font-weight: 600; }

.theme-toggle {
  width: 34px;
  height: 32px;
  border: 1px solid rgba(255,255,255,.18);
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,.08);
  color: #e2e8f0;
  cursor: pointer;
  font-size: 17px;
  flex-shrink: 0;
}
.theme-toggle:hover { background: rgba(255,255,255,.16); }

/* Mobile drawer toggle button (hidden on desktop) */
.sidebar-toggle {
  display: none;
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 120;
  width: 40px;
  height: 40px;
  border: 1px solid var(--slate-300);
  border-radius: var(--radius-sm);
  background: var(--white);
  color: var(--slate-700);
  font-size: 20px;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
}

/* ── Typography ──────────────────────────────────────────────────────────── */
main { flex: 1; min-width: 0; padding: 32px 0 64px; }
h1 { font-size: 26px; font-weight: 700; margin-bottom: 20px; color: var(--slate-900); }
h2 { font-size: 18px; font-weight: 600; margin: 22px 0 12px; color: var(--slate-700); }
h3 { font-size: 15px; font-weight: 600; margin: 16px 0 8px; }
p  { margin-bottom: 10px; }

/* ── Cards ───────────────────────────────────────────────────────────────── */
.card {
  background: var(--white);
  border: 1px solid var(--slate-200);
  border-radius: var(--radius);
  padding: 20px 24px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}

/* ── Tables ──────────────────────────────────────────────────────────────── */
table { width: 100%; border-collapse: collapse; font-size: 14px; margin-bottom: 16px; }
th {
  background: var(--slate-900);
  color: #e2e8f0;
  padding: 9px 12px;
  text-align: left;
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 0.03em;
}
th:first-child { border-radius: var(--radius-sm) 0 0 0; }
th:last-child  { border-radius: 0 var(--radius-sm) 0 0; }
td { padding: 8px 12px; border-bottom: 1px solid var(--slate-200); }
tr:last-child td { border-bottom: none; }
tr:nth-child(even) td { background: var(--slate-50); }
tr:hover td { background: #f0f4ff; transition: background 0.1s; }

/* ── Forms ───────────────────────────────────────────────────────────────── */
label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 4px;
  color: var(--slate-500);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
input[type=text], input[type=password], input[type=number],
input[type=date], input[type=week], select, textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--slate-300);
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-family: inherit;
  background: var(--white);
  color: var(--slate-700);
  transition: border-color 0.15s;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--indigo);
  outline-offset: 1px;
  border-color: transparent;
}
.form-row { display: flex; gap: 12px; margin-bottom: 12px; }
.form-row .field { flex: 1; }
.form-group { margin-bottom: 12px; }
.period-row { display: flex; align-items: flex-end; gap: 12px; margin-bottom: 14px; }
.period-row .field { flex: 1; }
.period-row select { width: auto; }

/* ── Checkboxes ──────────────────────────────────────────────────────────── */
.checkbox-grid { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 16px; }
.checkbox-grid label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 500;
  font-size: 14px;
  color: var(--slate-700);
  text-transform: none;
  letter-spacing: normal;
  cursor: pointer;
  padding: 6px 12px;
  border: 1px solid var(--slate-200);
  border-radius: 9999px;
  background: var(--white);
  transition: border-color 0.15s, background 0.15s;
}
.checkbox-grid label:hover { border-color: var(--indigo); background: #eef2ff; }
.checkbox-grid input[type=checkbox] { width: auto; }

/* ── Score inputs ────────────────────────────────────────────────────────── */
.score-input { width: 60px !important; text-align: center; }

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: opacity 0.15s, transform 0.1s;
}
.btn:hover { opacity: 0.88; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-primary   { background: var(--slate-900); color: #fff; }
.btn-secondary { background: var(--white); color: var(--slate-700); border: 1px solid var(--slate-300); }
.btn-danger    { background: var(--red);   color: #fff; }
.btn-success   { background: var(--green); color: #fff; }
.btn-sm { padding: 5px 11px; font-size: 13px; }
.btn-cache {
  border: 1px solid #fca5a5;
  background: #fff;
  color: #b91c1c;
}
.btn-cache:hover { border-color: var(--red); background: #fef2f2; opacity: 1; }
.btn-rerun {
  border: 1px solid #a5b4fc;
  background: #eef2ff;
  color: #4338ca;
}
.btn-rerun:hover { border-color: var(--indigo); background: #e0e7ff; opacity: 1; }

/* ── Badges ──────────────────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 9999px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.03em;
}
.badge-running { background: #fef9c3; color: #a16207; }
.badge-done    { background: #dcfce7; color: #15803d; }
.badge-error   { background: #fee2e2; color: #b91c1c; }
.badge-yellow  { background: #fef9c3; color: #a16207; }

/* ── Alert ───────────────────────────────────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  font-size: 13px;
}
.alert-error   { background: #fee2e2; color: #b91c1c; border: 1px solid #fca5a5; }
.alert-success { background: #dcfce7; color: #15803d; border: 1px solid #86efac; }
.alert-info    { background: #e0f2fe; color: #0369a1; border: 1px solid #7dd3fc; }

/* ── Mode switcher chips ─────────────────────────────────────────────────── */
.mode-chips { display: flex; gap: 6px; margin-bottom: 18px; }
.mode-chips .chip {
  padding: 6px 16px;
  border: 1.5px solid var(--slate-200);
  border-radius: 9999px;
  font-size: 13px;
  font-weight: 500;
  color: var(--slate-500);
  cursor: pointer;
  background: var(--white);
  transition: all 0.15s;
  user-select: none;
}
.mode-chips .chip input[type=radio] { display: none; }
.mode-chips .chip:hover { border-color: var(--indigo); color: var(--indigo); }
.mode-chips .chip.active { background: var(--slate-900); border-color: var(--slate-900); color: #fff; }

.period-panel { margin-bottom: 14px; }
.hidden { display: none !important; }

/* ── Report HTML rendering ───────────────────────────────────────────────── */
.report-content h1 { font-size: 18px; margin-top: 24px; }
.report-content h2 { font-size: 15px; }
.report-content h3 { font-size: 13px; }
.report-content blockquote {
  border-left: 3px solid var(--slate-200);
  padding-left: 12px;
  color: var(--slate-500);
  margin: 8px 0;
}
.report-content pre {
  background: var(--slate-100);
  padding: 10px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  overflow-x: auto;
}
.report-content details { margin: 8px 0; }
.report-content a { color: var(--indigo); }

/* ── Tabs ────────────────────────────────────────────────────────────────── */
.tabs { display: flex; gap: 2px; border-bottom: 2px solid var(--slate-200); margin-bottom: 16px; }
.tab-btn {
  padding: 8px 16px;
  border: none;
  background: none;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  color: var(--slate-500);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color 0.15s;
}
.tab-btn.active { color: var(--slate-900); border-bottom-color: var(--slate-900); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Download grid ───────────────────────────────────────────────────────── */
.download-grid { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

/* ── Status page ─────────────────────────────────────────────────────────── */
.status-spinner { font-size: 32px; margin: 32px 0 16px; text-align: center; }
.status-message { text-align: center; color: var(--slate-500); }

/* ── Login ───────────────────────────────────────────────────────────────── */
.login-wrap { max-width: 360px; margin: 80px auto; }
.login-wrap h2 { margin-bottom: 24px; }

/* ── Utility ─────────────────────────────────────────────────────────────── */
.text-meta { color: var(--slate-500); font-size: 12px; }
small.text-meta { display: block; margin-top: 4px; }
.mt-8  { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mb-8  { margin-bottom: 8px; }
.gap-8 { gap: 8px; }
.flex  { display: flex; }
.flex-end { justify-content: flex-end; }
.align-center { align-items: center; }

/* ── Tooltip ─────────────────────────────────────────────────────────────── */
.tip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 15px; height: 15px;
  border-radius: 50%;
  background: var(--slate-300);
  color: var(--slate-700);
  font-size: 10px; font-weight: 700;
  cursor: pointer;
  position: relative;
  user-select: none;
  vertical-align: middle;
  margin-left: 4px;
  flex-shrink: 0;
  line-height: 1;
  transition: background 0.15s;
}
.tip:hover { background: var(--slate-500); color: #fff; }
.tip-popup {
  display: none;
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--slate-900);
  color: #e2e8f0;
  font-size: 12px;
  font-weight: 400;
  line-height: 1.6;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  width: 230px;
  z-index: 200;
  box-shadow: var(--shadow);
  pointer-events: none;
  text-align: left;
  white-space: normal;
}
.tip-popup::after {
  content: '';
  position: absolute;
  top: 100%; left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: var(--slate-900);
}
.tip.active .tip-popup { display: block; }

/* ── Rank badges ─────────────────────────────────────────────────────────── */
.rank-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 9999px;
  font-weight: 700;
  font-size: 12px;
}
.rank-A1 { background: #dcfce7; color: #15803d; }
.rank-A2 { background: #bbf7d0; color: #166534; }
.rank-A3 { background: #fef9c3; color: #a16207; }
.rank-B  { background: #ffedd5; color: #c2410c; }
.rank-C  { background: #fee2e2; color: #b91c1c; }
.rank-empty { background: var(--slate-100); color: var(--slate-500); }

/* ── Dev score card ──────────────────────────────────────────────────────── */
.dev-card {
  background: var(--white);
  border: 1px solid var(--slate-200);
  border-left: 4px solid var(--slate-300);
  border-radius: var(--radius);
  padding: 24px 28px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.15s;
}
.dev-card:hover { box-shadow: var(--shadow); }
.dev-card[data-rank="A1"] { border-left-color: #16a34a; }
.dev-card[data-rank="A2"] { border-left-color: #2563eb; }
.dev-card[data-rank="A3"] { border-left-color: #d97706; }
.dev-card[data-rank="B"]  { border-left-color: #ea580c; }
.dev-card[data-rank="C"]  { border-left-color: #dc2626; }

.dev-card-header { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.dev-card-header h3 { margin: 0; font-size: 21px; font-weight: 700; flex: 1; color: var(--slate-900); }
.total-score { font-size: 46px; font-weight: 800; color: var(--slate-900); line-height: 1; letter-spacing: -1.5px; }
.total-score-unit { font-size: 17px; font-weight: 400; color: var(--slate-500); letter-spacing: 0; }

/* Score bar */
.score-bar { height: 9px; background: var(--slate-200); border-radius: 9999px; margin-bottom: 18px; overflow: hidden; }
.score-fill { height: 100%; border-radius: 9999px; transition: width 0.5s ease; background: linear-gradient(90deg, var(--green), #22c55e); }
/* Provisional bar: lead score still pending → striped, muted */
.score-fill--provisional {
  background-image: repeating-linear-gradient(45deg, var(--slate-300) 0, var(--slate-300) 6px, var(--slate-200) 6px, var(--slate-200) 12px);
  opacity: 0.9;
}
/* "(tạm tính)" label next to a provisional score — clearly secondary, not a final score */
.pending-lead-note {
  font-size: 12px;
  font-weight: 500;
  color: var(--amber);
  letter-spacing: 0;
  white-space: nowrap;
}

/* Context metrics used by the scoring criteria */
.kpi-strip {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}
.kpi-item {
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--slate-200);
  border-radius: var(--radius-sm);
  background: var(--slate-50);
}
.kpi-label {
  display: block;
  overflow: hidden;
  color: var(--slate-500);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .03em;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}
.kpi-item strong { display: block; margin-top: 2px; color: var(--slate-900); font-size: 17px; }

/* Metric groups — 3-column grid */
.metric-groups { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.metric-group {
  padding: 16px;
  border: 1px solid var(--slate-200);
  border-radius: var(--radius-sm);
  background: var(--slate-50);
}
.metric-group h4 { font-size: 14px; font-weight: 700; margin: 0 0 12px; color: var(--slate-700); text-transform: uppercase; letter-spacing: .04em; }
.metric-row { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; font-size: 14px; }
.metric-row .label { color: var(--slate-500); width: 76px; flex-shrink: 0; font-size: 13px; }

/* Progress bar replacing dot scale */
.metric-bar { flex: 1; height: 8px; background: var(--slate-200); border-radius: 9999px; overflow: hidden; }
.metric-bar-fill { height: 100%; border-radius: 9999px; transition: width 0.4s ease; }
.pct-num { font-size: 13px; font-weight: 700; color: var(--slate-700); min-width: 38px; text-align: right; }
.auto-score {
  min-width: 38px;
  padding-left: 8px;
  border-left: 1px solid var(--slate-300);
  color: var(--slate-700);
  font-size: 13px;
  font-weight: 700;
  text-align: right;
}
.metric-context {
  margin-top: 4px;
  padding-top: 8px;
  border-top: 1px dashed var(--slate-300);
  color: var(--slate-500);
  font-size: 12px;
  font-weight: 600;
}

/* Dot scale (legacy fallback) */
.dots { color: var(--slate-900); letter-spacing: 1px; font-size: 14px; }

/* Star-click inputs */
.star-input { display: inline-flex; gap: 2px; }
.star-input .star { cursor: default; font-size: 20px; color: var(--slate-200); line-height: 1; }
.star-input.editable .star { cursor: pointer; transition: color 0.1s; }
.star-input.editable .star:hover { color: var(--amber); }
.star-input .star.filled { color: var(--amber); }

/* ── Job cards (history list on dashboard) ───────────────────────────────── */
.job-cards { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }
.job-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border: 1px solid var(--slate-200);
  border-radius: var(--radius-sm);
  background: var(--white);
  transition: box-shadow 0.15s;
}
.job-card:hover { box-shadow: var(--shadow); }
.job-card-period { font-weight: 600; font-size: 13px; color: var(--slate-900); min-width: 200px; }
.job-card-devs { flex: 1; font-size: 12px; color: var(--slate-500); }
.job-card-actions { display: flex; gap: 6px; }

/* ── Landing overview grid ───────────────────────────────────────────────── */
.dev-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}
.dev-grid-card {
  display: block;
  padding: 20px;
  background: var(--white);
  border: 1px solid var(--slate-200);
  border-left: 4px solid var(--slate-300);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  text-decoration: none;
  color: inherit;
  transition: box-shadow 0.15s, transform 0.1s;
}
.dev-grid-card:hover { box-shadow: var(--shadow); transform: translateY(-2px); }
.dev-grid-card:focus-visible { outline: 2px solid var(--indigo); outline-offset: 2px; }
.dev-grid-card[data-rank="A1"] { border-left-color: #16a34a; }
.dev-grid-card[data-rank="A2"] { border-left-color: #2563eb; }
.dev-grid-card[data-rank="A3"] { border-left-color: #d97706; }
.dev-grid-card[data-rank="B"]  { border-left-color: #ea580c; }
.dev-grid-card[data-rank="C"]  { border-left-color: #dc2626; }
.dev-grid-card__head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; margin-bottom: 12px;
}
.dev-grid-card__name { font-size: 16px; font-weight: 700; color: var(--slate-900); }
.dev-grid-card__total { display: flex; align-items: baseline; }
.dev-grid-card__num { font-size: 32px; font-weight: 800; color: var(--slate-900); letter-spacing: -1px; line-height: 1; }
.dev-grid-card__empty { padding: 8px 0; font-size: 13px; }

/* ── Dev dashboard page ──────────────────────────────────────────────────── */
.dev-page-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; margin-bottom: 20px;
}
.dev-page-header h1 { margin-bottom: 6px; }
.dev-page-sub { display: flex; align-items: center; gap: 10px; }
.dev-latest__head {
  display: flex; align-items: baseline; gap: 16px; flex-wrap: wrap; margin-bottom: 16px;
}
.dev-latest__num { font-size: 46px; font-weight: 800; color: var(--slate-900); line-height: 1; letter-spacing: -1.5px; }
.dev-latest__delta { font-size: 16px; }
.dev-latest__dots {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px; margin-bottom: 16px;
}
.dev-dot {
  display: flex; flex-direction: column; gap: 4px;
  padding: 12px; border: 1px solid var(--slate-200);
  border-radius: var(--radius-sm); background: var(--slate-50);
}
.dev-dot__label {
  font-size: 11px; font-weight: 600; color: var(--slate-500);
  text-transform: uppercase; letter-spacing: .03em;
}
.dev-latest__actions { display: flex; gap: 8px; }

@media (max-width: 768px) {
  .dev-page-header { flex-direction: column; }
  .dev-latest__dots { grid-template-columns: 1fr; }
}

/* ── Delta indicator ─────────────────────────────────────────────────────── */
.delta-up   { color: var(--green); font-weight: 600; }
.delta-down { color: var(--red);   font-weight: 600; }
.delta-flat { color: var(--slate-500); }

/* ── Admin save row ──────────────────────────────────────────────────────── */
.save-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--slate-200);
}

/* ── Report page header ──────────────────────────────────────────────────── */
.report-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}
.report-header h1 { margin-bottom: 8px; }
.report-actions {
  display: flex;
  align-items: flex-start;
  flex-shrink: 0;
  gap: 8px;
}
.download-strip { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.download-label {
  font-size: 11px; font-weight: 600; color: var(--slate-500);
  text-transform: uppercase; letter-spacing: .04em; margin-right: 2px;
}

/* ── Sticky save bar ─────────────────────────────────────────────────────── */
.sticky-save {
  position: sticky;
  bottom: 0;
  background: var(--white);
  border-top: 1px solid var(--slate-200);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 -2px 8px rgba(0,0,0,0.08);
  z-index: 50;
  margin: 16px -16px -56px;
}

/* ── Note/Save row ───────────────────────────────────────────────────────── */
.note-save-row {
  display: flex; align-items: center; flex-wrap: wrap; gap: 8px;
  width: 100%; margin-top: 14px;
  padding: 12px;
  border: 1px solid var(--slate-200);
  border-radius: var(--radius-sm);
  background: var(--slate-50);
}
.note-label { font-size: 13px; font-weight: 700; color: var(--slate-700); width: 42px; flex-shrink: 0; }
.note-save-row .note-input {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 42px;
  padding: 9px 12px;
  border-color: var(--slate-300);
  background: var(--white);
  font-size: 14px;
}
.note-save-row .save-scores-btn {
  min-height: 42px;
  flex-shrink: 0;
  padding: 9px 18px;
  box-shadow: 0 2px 5px rgba(22, 163, 74, .22);
}
.note-save-row .save-scores-btn:hover { background: #15803d; opacity: 1; }
.save-status-inline {
  flex-basis: 100%;
  margin-left: 50px;
  font-size: 12px;
}
.save-status-inline:empty { display: none; }

/* ── Task detail accordion ───────────────────────────────────────────────── */
.task-detail {
  margin-top: 12px;
  border-top: 1px solid var(--slate-200);
  padding-top: 10px;
}
.task-detail > summary {
  font-size: 13px;
  font-weight: 600;
  color: var(--slate-500);
  cursor: pointer;
  user-select: none;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 6px;
}
.task-detail > summary::before { content: "▶"; font-size: 9px; transition: transform 0.15s; display:inline-block; }
.task-detail[open] > summary::before { transform: rotate(90deg); }
.task-detail-body { padding: 12px 0 4px; display: flex; flex-direction: column; gap: 10px; }
.detail-nodata-message {
  margin: 0;
  padding: 8px 10px;
  border: 1px dashed var(--slate-300);
  border-radius: var(--radius-sm);
  background: var(--slate-50);
  color: var(--slate-500);
  font-size: 12px;
}

/* Detail section */
.detail-section { font-size: 13px; }
.detail-section-header {
  display: flex; align-items: center; gap: 6px; margin-bottom: 6px;
}
.detail-section-title { font-weight: 700; color: var(--slate-700); font-size: 13px; }
.detail-note { font-size: 12px; color: var(--slate-500); font-style: italic; }

/* Groups within a section — colored left border */
.detail-group {
  border-left: 3px solid var(--slate-200);
  padding-left: 10px;
  margin-bottom: 8px;
}
.detail-group.pass { border-left-color: var(--green); }
.detail-group.fail { border-left-color: var(--red); }
.detail-group.warn { border-left-color: var(--amber); }
.detail-group.blue { border-left-color: var(--indigo); }

.detail-group-label {
  display: inline-block; font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .04em;
  margin-bottom: 4px; padding: 2px 7px;
  border-radius: 4px;
}
.detail-group-label.pass { background: #dcfce7; color: #15803d; }
.detail-group-label.fail { background: #fee2e2; color: #b91c1c; }
.detail-group-label.warn { background: #fef9c3; color: #a16207; }

/* Issue rows — 1 ticket per row */
.issue-rows { display: flex; flex-direction: column; gap: 3px; padding-left: 4px; }
.issue-row {
  display: flex; align-items: center; gap: 8px;
  padding: 2px 0;
}
.issue-summary { flex: 1; min-width: 120px; }
.issue-hours {
  width: 48px; flex-shrink: 0; text-align: right;
  font-size: 11px; font-weight: 700; color: var(--slate-500);
  font-variant-numeric: tabular-nums;
}

/* Override flag buttons */
.override-btn {
  margin-left: auto; flex-shrink: 0;
  font-size: 0.68rem; padding: 1px 7px; border-radius: 4px;
  border: 1px solid var(--border); background: var(--bg-card);
  color: var(--text); cursor: pointer; transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}
.override-btn:hover { background: var(--slate-100); }
.override-btn.override-active {
  background: var(--green-light, #dcfce7); color: var(--green, #16a34a);
  border-color: var(--green, #16a34a);
}
.override-btn.override-downgrade { border-color: var(--amber, #d97706); color: var(--amber, #d97706); }
.override-btn.override-downgrade:hover { background: #fef9c3; }
.override-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Override reason icon (💬) — reuses .tip popup, but no slate circle */
.override-note-icon {
  width: auto; height: auto; min-width: 0;
  background: transparent; color: inherit;
  font-size: 0.8rem; padding: 0 2px; margin-left: 2px; flex-shrink: 0;
}
.override-note-icon:hover { background: transparent; }
.override-note-text {
  max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: 11px; color: var(--slate-500); flex-shrink: 1;
}

/* Inline note input for downgrade confirm */
.override-note-input { display: flex; align-items: center; gap: 4px; margin-top: 4px; flex-wrap: wrap; }
.override-note-input.hidden { display: none; }
.override-note-input input {
  font-size: 0.78rem; padding: 2px 6px; border: 1px solid var(--border);
  border-radius: 4px; flex: 1; min-width: 140px; background: var(--bg-card); color: var(--text);
}
.btn-confirm-ov, .btn-cancel-ov {
  font-size: 0.72rem; padding: 2px 8px; border-radius: 4px; cursor: pointer;
  border: 1px solid var(--border);
}
.btn-confirm-ov { background: var(--green, #16a34a); color: #fff; border-color: var(--green, #16a34a); }
.btn-cancel-ov  { background: var(--bg-card); color: var(--text); }

/* Collapsible pass sub-group */
.detail-group-collapsible { border: none; padding: 0; margin: 0; }
.detail-group-collapsible summary { cursor: pointer; list-style: none; }
.detail-group-collapsible summary::-webkit-details-marker { display: none; }
.detail-group-collapsible summary .detail-group-label { cursor: pointer; }
.detail-group-collapsible summary .detail-group-label::before { content: "▶ "; font-size: 9px; }
.detail-group-collapsible[open] summary .detail-group-label::before { content: "▼ "; }

/* Toast notification */
.toast {
  position: fixed; bottom: 24px; right: 24px; z-index: 9999;
  padding: 9px 16px; border-radius: 6px; font-size: 0.85rem;
  background: var(--bg-card); border: 1px solid var(--border);
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
  animation: toast-fadeout 2.8s forwards;
}
.toast-success { border-color: var(--green, #16a34a); color: var(--green, #16a34a); }
.toast-warning { border-color: #f59e0b; color: #b45309; }
.toast-error   { border-color: var(--red, #dc2626); color: var(--red, #dc2626); }
@keyframes toast-fadeout { 0%,65%{opacity:1} 100%{opacity:0} }
.issue-key {
  font-size: 13px; font-weight: 700; color: var(--indigo);
  text-decoration: none; white-space: nowrap; flex-shrink: 0;
}
.issue-key:hover { text-decoration: underline; }
.issue-key.pass { color: var(--green); }
.issue-key.fail { color: var(--red); }
.issue-key.warn { color: var(--amber); }
.issue-key.indigo { color: var(--indigo); }
.issue-summary { font-size: 13px; color: var(--slate-500); line-height: 1.4; }
.issue-tag { font-size: 10px; flex-shrink: 0; }

/* ── Debug page ──────────────────────────────────────────────────────────── */
.debug-table-wrap { overflow-x: auto; }
.debug-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.debug-table th, .debug-table td {
  padding: 8px 10px; border-bottom: 1px solid var(--slate-200); text-align: left;
}
.debug-table th { font-size: 11px; text-transform: uppercase; color: var(--slate-500); }
.debug-status { font-size: 11px; font-weight: 700; text-transform: uppercase; padding: 2px 6px; border-radius: 4px; }
.debug-status--running { background: #fef9c3; color: #a16207; }
.debug-status--done { background: #dcfce7; color: var(--green); }
.debug-status--error { background: #fee2e2; color: var(--red); }
.debug-trace-row td { background: var(--slate-50); padding-top: 0; }
.debug-pre {
  font-size: 11px; line-height: 1.45; overflow-x: auto;
  background: var(--slate-100); padding: 12px; border-radius: var(--radius-sm);
  white-space: pre-wrap; word-break: break-word; max-height: 320px; overflow-y: auto;
}
.debug-log-tail { max-height: 480px; }
.debug-trace-summary { cursor: pointer; font-size: 12px; font-weight: 600; color: var(--slate-600); margin: 8px 0; }
.sidebar__running { padding: 8px 16px; border-top: 1px solid var(--slate-200); }
.sidebar__link--running { color: var(--amber); font-weight: 600; }

/* Chip list — excluded / missing due */
.issue-chips { display: flex; flex-wrap: wrap; gap: 4px; padding-left: 4px; }
.issue-chip {
  font-size: 10px; font-weight: 600; color: var(--slate-500);
  background: var(--slate-100); border-radius: 4px; padding: 2px 6px;
}
.issue-chip.warn { background: #fef9c3; color: #a16207; }
.issue-chip-link {
  display: inline-block;
  font-size: 10px; font-weight: 600; color: var(--indigo);
  background: #eef2ff; border-radius: 4px; padding: 2px 7px;
  text-decoration: none;
}
.issue-chip-link:hover { background: #e0e7ff; text-decoration: none; }

/* ── Dark theme overrides ────────────────────────────────────────────────── */
[data-theme="dark"] .sidebar {
  background: linear-gradient(180deg, #111827 0%, #020617 100%);
}
[data-theme="dark"] th,
[data-theme="dark"] .btn-primary,
[data-theme="dark"] .mode-chips .chip.active {
  border-color: #475569;
  background: #1e293b;
  color: #f8fafc;
}
[data-theme="dark"] tr:hover td { background: #172033; }
[data-theme="dark"] .checkbox-grid label:hover,
[data-theme="dark"] .issue-chip-link { background: #1e293b; }
[data-theme="dark"] .btn-cache {
  border-color: #7f1d1d;
  background: #1f1518;
  color: #fca5a5;
}
[data-theme="dark"] .btn-cache:hover { border-color: #ef4444; background: #2b171b; }
[data-theme="dark"] .btn-rerun {
  border-color: #4338ca;
  background: #1e1b4b;
  color: #c7d2fe;
}
[data-theme="dark"] .btn-rerun:hover { border-color: #818cf8; background: #312e81; }
[data-theme="dark"] .rank-A1,
[data-theme="dark"] .rank-A2,
[data-theme="dark"] .badge-green,
[data-theme="dark"] .badge-done,
[data-theme="dark"] .detail-group-label.pass {
  background: #143322;
  color: #86efac;
}
[data-theme="dark"] .rank-A3,
[data-theme="dark"] .badge-yellow,
[data-theme="dark"] .badge-running,
[data-theme="dark"] .detail-group-label.warn {
  background: #3a2b12;
  color: #fde68a;
}
[data-theme="dark"] .rank-B { background: #3b2414; color: #fdba74; }
[data-theme="dark"] .rank-C,
[data-theme="dark"] .badge-red,
[data-theme="dark"] .badge-error,
[data-theme="dark"] .detail-group-label.fail {
  background: #3b171c;
  color: #fca5a5;
}
[data-theme="dark"] .badge-blue,
[data-theme="dark"] .issue-chip-link { color: #a5b4fc; }
[data-theme="dark"] .alert-success { background: #143322; color: #86efac; border-color: #166534; }
[data-theme="dark"] .alert-error { background: #3b171c; color: #fca5a5; border-color: #991b1b; }
[data-theme="dark"] .alert-info { background: #172554; color: #bae6fd; border-color: #1d4ed8; }
[data-theme="dark"] .tip-popup { background: #020617; color: #e2e8f0; }
[data-theme="dark"] .tip-popup::after { border-top-color: #020617; }
[data-theme="dark"] [style*="background:#f4f6f8"],
[data-theme="dark"] [style*="background: #f4f6f8"],
[data-theme="dark"] [style*="background:#fff9e6"] {
  background: #1e293b !important;
}

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar-toggle { display: block; }
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 110;
    height: 100vh;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    box-shadow: var(--shadow);
  }
  .sidebar.sidebar--open { transform: translateX(0); }
  main { padding-top: 64px; }
  .report-header { flex-direction: column; }
  .report-actions { flex-wrap: wrap; }
  .metric-groups { grid-template-columns: 1fr; }
  .kpi-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .job-card { flex-wrap: wrap; }
  .job-card-period { min-width: unset; }
}

@media (min-width: 769px) and (max-width: 1100px) {
  .kpi-strip { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
