:root {
  --bg: #f4f6f9;
  --card: #fff;
  --text: #1d2733;
  --muted: #667085;
  --border: #dde3ea;
  --accent: #0b5cad;
  --green: #1f9d55;
  --amber: #d98a00;
  --red: #c62828;
  --gray: #98a2b3;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font: 14px/1.45 "Segoe UI", system-ui, -apple-system, sans-serif;
  color: var(--text);
  background: var(--bg);
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code { background: #eef1f5; padding: 1px 4px; border-radius: 3px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 14px 24px; background: #0f2a47; color: #fff;
}
.topbar h1 { margin: 0; font-size: 20px; font-weight: 600; }
.topbar .title { display: flex; align-items: baseline; gap: 12px; }
.topbar a { color: #9cc8ff; }
.topbar .muted { color: #b8c7d9; }
.refresh { display: flex; align-items: center; gap: 12px; }

button { font: inherit; cursor: pointer; }
#refresh-btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 7px 14px; border: 0; border-radius: 6px; background: #2f80ed; color: #fff; font-weight: 600;
}
#refresh-btn:disabled { opacity: .7; cursor: wait; }
.spinner {
  width: 14px; height: 14px; border: 2px solid rgba(255,255,255,.4); border-top-color: #fff;
  border-radius: 50%; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.banner { margin: 12px 24px 0; padding: 10px 14px; border-radius: 6px; }
.banner.error { background: #fdecea; color: #8a1c1c; border: 1px solid #f5c2c0; }
.banner.warn { background: #fff6e0; color: #7a4f00; border: 1px solid #f3d999; }
.banner a { font-weight: 600; }

.tabs { display: flex; gap: 4px; padding: 12px 24px 0; border-bottom: 1px solid var(--border); }
.tab {
  padding: 8px 14px; border: 1px solid transparent; border-bottom: 0; border-radius: 6px 6px 0 0;
  background: transparent; color: var(--muted);
}
.tab.active { background: var(--card); color: var(--text); border-color: var(--border); margin-bottom: -1px; font-weight: 600; }
.pill { display: inline-block; min-width: 18px; padding: 0 6px; border-radius: 9px; background: var(--red); color: #fff; font-size: 11px; text-align: center; }

main { padding: 16px 24px 40px; }
.panel { display: none; }
.panel.active { display: block; }
.panel h2 { font-size: 16px; margin: 18px 0 8px; }

.empty { background: var(--card); border: 1px dashed var(--border); border-radius: 8px; padding: 24px; margin-bottom: 16px; }

.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--card); border: 1px solid var(--border); border-radius: 8px; padding: 14px 16px; }
.kpi .label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }
.kpi .value { font-size: 26px; font-weight: 700; margin: 4px 0 2px; }
.kpi .value small { font-size: 14px; font-weight: 500; color: var(--muted); }
.kpi .sub { color: var(--muted); font-size: 12px; }
.kpi.bad { border-color: #f5c2c0; background: #fff7f6; }
.kpi.bad .value { color: var(--red); }
.kpi.good .value { color: var(--green); }
.bar { height: 6px; background: #edf0f4; border-radius: 3px; overflow: hidden; margin-top: 6px; }
.bar > span { display: block; height: 100%; background: var(--green); }

.charts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.card { background: var(--card); border: 1px solid var(--border); border-radius: 8px; padding: 12px 16px; }
.card h3 { margin: 0 0 8px; font-size: 14px; }
.card.wide { grid-column: 1 / -1; }
.chart-box { position: relative; height: 240px; }
.chart-box.tall { height: 300px; }
@media (max-width: 1000px) { .charts { grid-template-columns: 1fr; } }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 10px; }
.toolbar input[type=search], .toolbar select {
  padding: 6px 8px; border: 1px solid var(--border); border-radius: 6px; font: inherit; background: #fff;
}
.toolbar input[type=search] { min-width: 260px; }
.toolbar .count { color: var(--muted); margin-left: auto; }
.btn-link { padding: 6px 10px; border: 1px solid var(--border); border-radius: 6px; background: #fff; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.seg button { padding: 6px 14px; border: 0; background: #fff; border-right: 1px solid var(--border); }
.seg button:last-child { border-right: 0; }
.seg button.active { background: var(--accent); color: #fff; }

.table-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--border); border-radius: 8px; }
table { border-collapse: collapse; width: 100%; }
th, td { padding: 7px 10px; border-bottom: 1px solid #edf0f4; text-align: left; vertical-align: top; white-space: nowrap; }
td.wrap { white-space: normal; min-width: 220px; max-width: 420px; }
th { background: #f8fafc; font-weight: 600; font-size: 12px; color: #475467; position: sticky; top: 0; }
th.sortable { cursor: pointer; user-select: none; }
th.sorted-asc::after { content: " \25B2"; font-size: 9px; }
th.sorted-desc::after { content: " \25BC"; font-size: 9px; }
th.group { text-align: center; border-left: 1px solid var(--border); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.sep, th.sep { border-left: 1px solid var(--border); }
tr:hover td { background: #f8fbff; }
tr.total td { font-weight: 700; background: #f3f6fa; }

.badge { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 12px; background: #eef1f5; color: #344054; }
.badge.Completed, .badge.Decommissioned, .badge.Migrated, .badge.Mixed, .badge.Removed { background: #e3f5ea; color: #146c3a; }
.badge.In-Progress, .badge.Due-soon { background: #fff1d6; color: #8a5a00; }
.badge.Not-Started, .badge.Pending, .badge.Not-set, .badge.Later { background: #eef1f5; color: #475467; }
.badge.Exempt, .badge.Temp-Exempt { background: #e6effc; color: #1c4f96; }
.badge.Blocked, .badge.Other, .badge.Overdue, .badge.high { background: #fdecea; color: #a12020; }
.badge.medium { background: #fff1d6; color: #8a5a00; }
.badge.low { background: #eef1f5; color: #475467; }
.flag { color: var(--red); font-weight: 600; }

.cancelled { margin-top: 18px; }
.cancelled summary { cursor: pointer; color: var(--muted); margin-bottom: 8px; }
