:root {
  --navy: #0b2545;
  --navy-2: #13315c;
  --red: #d7263d;
  --red-dark: #b71e32;
  --bg: #f4f6fb;
  --card: #ffffff;
  --ink: #1b2430;
  --muted: #6b7785;
  --line: #e3e8ef;
  --green: #1f9d55;
  --green-bg: #e6f6ed;
  --amber: #b7791f;
  --amber-bg: #fdf3e2;
  --blue: #2563eb;
  --blue-bg: #e7eefc;
  --teal: #0f766e;
  --teal-bg: #e0f2f1;
  --red-bg: #fdeaec;
  --gray-bg: #eef1f5;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(16,24,40,.06), 0 1px 2px rgba(16,24,40,.04);
  --shadow-lg: 0 10px 30px rgba(11,37,69,.10);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.5;
}
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Layout shell */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 248px; flex-shrink: 0;
  background: linear-gradient(180deg, var(--navy), var(--navy-2));
  color: #cdd7e6; padding: 22px 16px; position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; }
.brand .logo {
  width: 38px; height: 38px; border-radius: 9px; background: var(--red);
  display: grid; place-items: center; font-weight: 800; color: #fff; font-size: 18px;
  box-shadow: 0 4px 10px rgba(215,38,61,.4);
}
.brand b { color: #fff; font-size: 15px; display: block; line-height: 1.15; }
.brand span { color: #9fb1c9; font-size: 11.5px; }
.nav { display: flex; flex-direction: column; gap: 4px; margin-top: 8px; }
.nav a {
  color: #cdd7e6; padding: 10px 12px; border-radius: 9px; font-weight: 500;
  display: flex; align-items: center; gap: 10px; transition: background .15s;
}
.nav a:hover { background: rgba(255,255,255,.08); text-decoration: none; }
.nav a.active { background: var(--red); color: #fff; }
.nav .sep { height: 1px; background: rgba(255,255,255,.12); margin: 12px 6px; }
.sidebar .foot { position: absolute; bottom: 18px; left: 16px; right: 16px; font-size: 11.5px; color: #8298b5; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  background: var(--card); border-bottom: 1px solid var(--line);
  padding: 16px 28px; display: flex; align-items: center; justify-content: space-between;
}
.topbar h1 { font-size: 18px; margin: 0; }
.topbar .crumb { color: var(--muted); font-size: 13px; }
.content { padding: 24px 28px 48px; max-width: 1180px; width: 100%; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
  background: var(--navy); color: #fff; border: none; padding: 10px 16px;
  border-radius: 9px; font-size: 14px; font-weight: 600; transition: filter .15s;
  text-decoration: none;
}
.btn:hover { filter: brightness(1.1); text-decoration: none; }
.btn-red { background: var(--red); }
.btn-red:hover { background: var(--red-dark); }
.btn-ghost { background: #fff; color: var(--navy); border: 1px solid var(--line); }
.btn-ghost:hover { background: var(--gray-bg); filter: none; }
.btn-sm { padding: 7px 12px; font-size: 13px; }

/* Cards & grid */
.grid { display: grid; gap: 16px; }
.cols-4 { grid-template-columns: repeat(4, 1fr); }
.cols-3 { grid-template-columns: repeat(3, 1fr); }
.cols-2 { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 980px) { .cols-4, .cols-3, .cols-2 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 640px) { .cols-4, .cols-3, .cols-2 { grid-template-columns: 1fr; } .sidebar { display: none; } }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px 20px;
}
.card h3 { margin: 0 0 14px; font-size: 14.5px; }
.card .hint { color: var(--muted); font-size: 12.5px; }

/* KPI */
.kpi { position: relative; overflow: hidden; }
.kpi .label { color: var(--muted); font-size: 12.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.kpi .value { font-size: 30px; font-weight: 800; margin: 6px 0 2px; color: var(--navy); }
.kpi .sub { font-size: 12.5px; color: var(--muted); }
.kpi .spark { position: absolute; right: 16px; top: 16px; font-size: 24px; opacity: .25; }
.kpi.good .value { color: var(--green); }
.kpi.warn .value { color: var(--amber); }
.kpi.bad .value { color: var(--red); }

/* Badges */
.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px;
  font-size: 12px; font-weight: 600; white-space: nowrap;
}
.badge-gray  { background: var(--gray-bg);  color: #475569; }
.badge-blue  { background: var(--blue-bg);  color: var(--blue); }
.badge-green { background: var(--green-bg); color: var(--green); }
.badge-amber { background: var(--amber-bg); color: var(--amber); }
.badge-teal  { background: var(--teal-bg);  color: var(--teal); }
.badge-red   { background: var(--red-bg);   color: var(--red); }

/* Tables */
table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
table.tbl th {
  text-align: left; color: var(--muted); font-size: 11.5px; text-transform: uppercase;
  letter-spacing: .03em; padding: 10px 12px; border-bottom: 1px solid var(--line);
}
table.tbl td { padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.tbl tr:last-child td { border-bottom: none; }
table.tbl tr:hover td { background: #fafbfd; }
.mono { font-family: "SF Mono", Consolas, monospace; font-size: 13px; }
.muted { color: var(--muted); }
.right { text-align: right; }
.nowrap { white-space: nowrap; }

/* Progress / bars */
.bar { background: var(--gray-bg); border-radius: 999px; height: 8px; overflow: hidden; }
.bar > span { display: block; height: 100%; border-radius: 999px; background: var(--navy); }
.bar.green > span { background: var(--green); }
.bar.amber > span { background: var(--amber); }
.bar.red > span { background: var(--red); }

.lane-row { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.lane-row .name { width: 230px; font-size: 13px; }
.lane-row .bar { flex: 1; }
.lane-row .n { width: 36px; text-align: right; font-weight: 700; font-size: 13px; }

/* Gauge */
.gauge { display: flex; align-items: center; gap: 18px; }
.gauge .ring {
  --p: 0; width: 96px; height: 96px; border-radius: 50%;
  background: conic-gradient(var(--green) calc(var(--p)*1%), var(--gray-bg) 0);
  display: grid; place-items: center; flex-shrink: 0;
}
.gauge .ring::before { content: ""; position: absolute; width: 70px; height: 70px; border-radius: 50%; background: #fff; }
.gauge .ring b { position: relative; font-size: 18px; color: var(--navy); }

/* Flash */
.flash { padding: 12px 16px; border-radius: 10px; margin-bottom: 16px; font-size: 14px; font-weight: 500; }
.flash-success { background: var(--green-bg); color: var(--green); border: 1px solid #b7e4c7; }
.flash-error   { background: var(--red-bg);   color: var(--red);   border: 1px solid #f5c2c7; }
.flash-info    { background: var(--blue-bg);  color: var(--blue);  border: 1px solid #b6d0fb; }

.banner {
  background: linear-gradient(90deg, #fff7ed, #fffbeb); border: 1px solid #fde6c8;
  color: #92400e; padding: 11px 16px; border-radius: 10px; font-size: 13.5px; margin-bottom: 18px;
  display: flex; gap: 10px; align-items: center;
}

/* Forms */
.form-row { margin-bottom: 16px; }
.form-row label { display: block; font-weight: 600; font-size: 13.5px; margin-bottom: 6px; }
.input, select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 9px;
  font-size: 14px; font-family: inherit; background: #fff;
}
.input:focus, select:focus { outline: 2px solid var(--blue); border-color: transparent; }
.dropzone {
  border: 2px dashed #c8d2e0; border-radius: 12px; padding: 30px; text-align: center;
  background: #fbfcfe; cursor: pointer; transition: border-color .15s, background .15s;
}
.dropzone:hover, .dropzone.drag { border-color: var(--blue); background: #f2f7ff; }
.dropzone .big { font-size: 32px; }
.dropzone .fname { margin-top: 8px; font-weight: 600; color: var(--navy); }

/* Page header */
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; flex-wrap: wrap; gap: 12px; }
.page-head h2 { margin: 0; font-size: 22px; }
.page-head p { margin: 4px 0 0; color: var(--muted); font-size: 14px; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.toolbar select { width: auto; }

.section-title { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 24px 0 10px; font-weight: 700; }

/* Field review */
.field-table td.val { font-weight: 600; }
.conf { display: inline-flex; align-items: center; gap: 8px; }
.conf .pct { font-size: 12.5px; font-weight: 700; width: 38px; text-align: right; }
.conf .bar { width: 70px; }
.conf-low .pct { color: var(--amber); }
.conf-high .pct { color: var(--green); }
.conf-none .pct { color: var(--muted); }
.review-flag { color: var(--amber); font-size: 12px; font-weight: 700; }

.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { position: relative; padding: 0 0 16px 22px; border-left: 2px solid var(--line); }
.timeline li:last-child { border-left-color: transparent; padding-bottom: 0; }
.timeline li::before {
  content: ""; position: absolute; left: -7px; top: 2px; width: 12px; height: 12px;
  border-radius: 50%; background: #fff; border: 2px solid var(--navy);
}
.timeline .ev { font-weight: 600; font-size: 13.5px; }
.timeline .dt { color: var(--muted); font-size: 12px; }
.timeline .de { color: var(--muted); font-size: 13px; }

.issue { display: flex; gap: 10px; padding: 10px 12px; border-radius: 9px; margin-bottom: 8px; font-size: 13.5px; }
.issue.error   { background: var(--red-bg); color: #842029; }
.issue.warning { background: var(--amber-bg); color: #7a5212; }
.issue .code { font-family: monospace; font-size: 11.5px; opacity: .7; }

.empty { text-align: center; padding: 50px 20px; color: var(--muted); }
.empty .big { font-size: 40px; margin-bottom: 8px; }

.inline-form { display: inline; }
.kv { display: grid; grid-template-columns: 150px 1fr; gap: 6px 14px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 500; }
