/* Bug Tracker Dashboard — light theme by default */

:root,
:root[data-theme="light"] {
  --surface-1: #fcfcfb;
  --page-plane: #f9f9f7;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #898781;
  --gridline: #e1e0d9;
  --baseline: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);

  --series-1: #2a78d6; /* blue */
  --series-2: #1baf7a; /* aqua */
  --series-3: #eda100; /* yellow */
  --series-4: #008300; /* green */
  --series-5: #4a3aa7; /* violet */
  --series-6: #e34948; /* red */
  --series-7: #e87ba4; /* magenta */
  --series-8: #eb6834; /* orange */

  --status-good: #0ca30c;
  --status-warning: #fab219;
  --status-serious: #ec835a;
  --status-critical: #d03b3b;

  --seq-250: #86b6ef;
  --seq-400: #3987e5;
  --seq-550: #1c5cab;
}

:root[data-theme="dark"] {
  --surface-1: #1a1a19;
  --page-plane: #0d0d0d;
  --text-primary: #ffffff;
  --text-secondary: #c3c2b7;
  --text-muted: #898781;
  --gridline: #2c2c2a;
  --baseline: #383835;
  --border: rgba(255, 255, 255, 0.10);

  --series-1: #3987e5;
  --series-2: #199e70;
  --series-3: #c98500;
  --series-4: #008300;
  --series-5: #9085e9;
  --series-6: #e66767;
  --series-7: #d55181;
  --series-8: #d95926;

  --status-good: #0ca30c;
  --status-warning: #fab219;
  --status-serious: #ec835a;
  --status-critical: #d03b3b;

  --seq-250: #184f95;
  --seq-400: #2a78d6;
  --seq-550: #86b6ef;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]):not([data-theme="dark"]) {
    --surface-1: #1a1a19;
    --page-plane: #0d0d0d;
    --text-primary: #ffffff;
    --text-secondary: #c3c2b7;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--page-plane);
  color: var(--text-primary);
}

.hidden { display: none !important; }
.muted { color: var(--text-muted); font-size: 13px; }

/* Topbar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  background: var(--surface-1);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  gap: 12px;
}
.topbar-left { display: flex; align-items: baseline; gap: 12px; }
.topbar-left h1 { font-size: 19px; margin: 0; }
.subtitle { color: var(--text-muted); font-size: 13px; }
.topbar-right { display: flex; align-items: center; gap: 8px; }

.btn {
  font-family: inherit;
  font-size: 13px;
  border-radius: 8px;
  border: 1px solid var(--border);
  padding: 8px 14px;
  cursor: pointer;
  background: var(--surface-1);
  color: var(--text-primary);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.btn-primary { background: var(--series-1); border-color: var(--series-1); color: #fff; }
.btn-ghost { background: transparent; }
.btn-icon { padding: 8px 10px; font-size: 15px; }
.btn:hover { filter: brightness(0.97); }
.btn-primary:hover { filter: brightness(1.08); }

/* Empty state */
.empty-state {
  max-width: 520px;
  margin: 80px auto;
  text-align: center;
  color: var(--text-secondary);
}

/* Dashboard layout */
.dashboard { padding: 20px 24px 48px; max-width: 1400px; margin: 0 auto; }

.filter-row {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 14px;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 18px;
}
.filter-group { display: flex; flex-direction: column; gap: 4px; min-width: 130px; }
.filter-group label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.02em; }
.filter-search { flex: 1; min-width: 200px; }
.filter-row select, .filter-row input[type="search"] {
  font-family: inherit;
  font-size: 13px;
  padding: 7px 9px;
  border-radius: 6px;
  border: 1px solid var(--baseline);
  background: var(--surface-1);
  color: var(--text-primary);
}

/* KPI tiles */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}
.kpi-tile {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.kpi-headline { grid-column: span 2; background: linear-gradient(135deg, var(--series-1) 0%, var(--seq-550) 100%); border: none; }
.kpi-headline .kpi-label, .kpi-headline .kpi-value, .kpi-headline .kpi-sub { color: #fff; }
.kpi-headline .kpi-value { font-size: 40px; font-weight: 700; }
.kpi-label { font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.02em; }
.kpi-value { font-size: 26px; font-weight: 600; font-variant-numeric: proportional-nums; }
.kpi-sub { font-size: 12px; color: var(--text-secondary); }
.kpi-critical .kpi-value { color: var(--status-critical); }

@media (max-width: 1100px) {
  .kpi-row { grid-template-columns: repeat(3, 1fr); }
  .kpi-headline { grid-column: span 3; }
}
@media (max-width: 640px) {
  .kpi-row { grid-template-columns: repeat(2, 1fr); }
  .kpi-headline { grid-column: span 2; }
}

/* Charts */
.chart-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 20px;
}
.chart-card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px 10px;
  margin: 0;
}
.chart-card-wide { grid-column: span 2; }
.chart-card figcaption {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 10px;
  color: var(--text-secondary);
}
.table-toggle {
  font-size: 11px;
  background: transparent;
  border: 1px solid var(--baseline);
  border-radius: 6px;
  padding: 3px 8px;
  cursor: pointer;
  color: var(--text-secondary);
}
.chart-canvas-wrap { position: relative; height: 260px; }
.table-view table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table-view th, .table-view td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--gridline); }

@media (max-width: 900px) {
  .chart-grid { grid-template-columns: 1fr; }
  .chart-card-wide { grid-column: span 1; }
}

/* Bugs table */
.table-card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
}
.table-card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.table-card-header h2 { font-size: 15px; margin: 0; }
.table-scroll { overflow-x: auto; }
.table-scroll-tall { max-height: 520px; overflow-y: auto; }
.table-scroll-tall thead th { position: sticky; top: 0; background: var(--surface-1); z-index: 1; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  text-align: left;
  padding: 8px 10px;
  color: var(--text-muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  border-bottom: 1px solid var(--baseline);
  cursor: pointer;
  white-space: nowrap;
}
tbody td { padding: 8px 10px; border-bottom: 1px solid var(--gridline); font-variant-numeric: tabular-nums; }
tbody tr.row-breached { background: color-mix(in srgb, var(--status-critical) 8%, transparent); }
.tag { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; }
.tag-high { background: color-mix(in srgb, var(--status-critical) 15%, transparent); color: var(--status-critical); }
.tag-medium { background: color-mix(in srgb, var(--status-warning) 20%, transparent); color: #8a5a00; }
.tag-low { background: color-mix(in srgb, var(--series-1) 15%, transparent); color: var(--series-1); }
.tag-breached { background: color-mix(in srgb, var(--status-critical) 15%, transparent); color: var(--status-critical); }
.tag-ontrack { background: color-mix(in srgb, var(--status-good) 15%, transparent); color: var(--status-good); }
.tag-accepted { background: color-mix(in srgb, var(--status-warning) 20%, transparent); color: #8a5a00; }
.tag-na { background: transparent; color: var(--text-muted); border: 1px solid var(--baseline); }
.btn-link { border: none; background: transparent; color: var(--series-1); cursor: pointer; font-size: 12px; padding: 0; text-decoration: underline; white-space: nowrap; }

/* Overlays / settings panel */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 20px;
}
.settings-panel {
  background: var(--surface-1);
  border-radius: 12px;
  width: 560px;
  max-width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  padding: 0;
  border: 1px solid var(--border);
}
.settings-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.settings-header h2 { font-size: 16px; margin: 0; }
.settings-body { padding: 16px 20px; display: flex; flex-direction: column; gap: 18px; }
fieldset { border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px; }
legend { font-size: 12px; font-weight: 600; color: var(--text-secondary); padding: 0 6px; }
.settings-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 6px; }
.settings-row label { font-size: 13px; }
.settings-row input[type="number"] { width: 80px; padding: 5px 8px; border-radius: 6px; border: 1px solid var(--baseline); background: var(--surface-1); color: var(--text-primary); }
#closedStatuses { width: 100%; padding: 7px 9px; border-radius: 6px; border: 1px solid var(--baseline); background: var(--surface-1); color: var(--text-primary); font-family: inherit; font-size: 13px; }
.hint { font-size: 12px; color: var(--text-muted); margin: 6px 0 0; }
.holiday-add-row { display: flex; gap: 8px; margin-top: 8px; }
.holiday-add-row input { flex: 1; padding: 6px 8px; border-radius: 6px; border: 1px solid var(--baseline); background: var(--surface-1); color: var(--text-primary); font-family: inherit; font-size: 13px; }
.holiday-list { list-style: none; margin: 10px 0 0; padding: 0; max-height: 160px; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; }
.holiday-list li { display: flex; justify-content: space-between; align-items: center; font-size: 13px; padding: 4px 8px; border-radius: 6px; background: var(--page-plane); }
.holiday-list button { border: none; background: transparent; color: var(--status-critical); cursor: pointer; font-size: 13px; }
.settings-actions { display: flex; justify-content: flex-end; }

.mapping-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; }
.mapping-fields label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--text-secondary); }
.mapping-fields select { padding: 6px 8px; border-radius: 6px; border: 1px solid var(--baseline); background: var(--surface-1); color: var(--text-primary); font-family: inherit; font-size: 13px; }
