:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --panel-soft: #f8fafc;
  --line: #d9e1ea;
  --line-dark: #c5d0dc;
  --text: #17212b;
  --muted: #657486;
  --red: #cf3f34;
  --orange: #d97922;
  --yellow: #b98a11;
  --green: #21865a;
  --teal: #177b82;
  --blue: #3e64aa;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", "Malgun Gothic", Arial, sans-serif;
  font-size: 14px;
  letter-spacing: 0;
}

.app-header {
  height: 70px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

.brand-block { display: flex; align-items: baseline; gap: 12px; min-width: 0; }
.brand-title { font-size: 24px; font-weight: 800; letter-spacing: 0; }
.brand-sub { color: var(--muted); font-size: 13px; font-weight: 700; }

.header-meta {
  display: flex;
  gap: 10px;
  align-items: center;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}
.header-meta span {
  padding: 4px 8px;
  border: 1px solid #b9d4cf;
  border-radius: 999px;
  color: #126c60;
  background: #edf8f5;
  font-weight: 800;
  text-transform: uppercase;
}

.shell {
  width: min(1480px, calc(100vw - 40px));
  margin: 18px auto 42px;
  display: grid;
  gap: 14px;
}

.definition-row {
  min-height: 54px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 14px;
  border: 1px solid #b8d7dc;
  border-radius: 8px;
  background: #f0fbfc;
}
.definition-row span {
  display: block;
  margin-bottom: 3px;
  color: var(--teal);
  font-size: 12px;
  font-weight: 900;
}
.definition-row strong { font-size: 14px; }
.definition-row code {
  padding: 7px 10px;
  border-radius: 6px;
  background: #dff3f5;
  color: #0f5960;
  font-family: inherit;
  font-weight: 900;
  white-space: nowrap;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}
.metric {
  min-height: 96px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}
.metric span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}
.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 25px;
  line-height: 1.1;
  letter-spacing: 0;
}
.metric small {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
}

.priority-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
.priority-card {
  min-height: 136px;
  display: grid;
  gap: 8px;
  padding: 14px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--blue);
  border-radius: 8px;
  background: var(--panel);
}
.priority-card.vehicle { border-left-color: var(--red); }
.priority-card.route { border-left-color: var(--teal); }
.priority-card.charger { border-left-color: var(--orange); }
.priority-card .kicker {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}
.priority-card h3 {
  margin: 0;
  font-size: 16px;
  line-height: 1.25;
  letter-spacing: 0;
}
.priority-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.42;
}
.priority-card b { color: var(--text); }

.workbench {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  overflow: hidden;
}
.workbench-top {
  min-height: 54px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}
.tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}
.tab {
  min-width: 88px;
  height: 34px;
  padding: 0 14px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 900;
  cursor: pointer;
}
.tab.active { background: var(--text); color: #fff; }
.record-count {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(240px, 1.3fr) repeat(4, minmax(112px, 0.7fr)) auto;
  gap: 10px;
  align-items: end;
  padding: 12px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-soft);
}
.control { display: grid; gap: 4px; min-width: 0; }
.control.hidden { display: none; }
.control span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}
input, select, button {
  height: 36px;
  border: 1px solid var(--line-dark);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  font: inherit;
}
input, select { width: 100%; padding: 0 10px; min-width: 0; }
.sort-button {
  padding: 0 12px;
  font-weight: 900;
  cursor: pointer;
}

.view { display: none; }
.view.active { display: block; }
.table-wrap { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  min-width: 1180px;
}
th, td {
  padding: 10px 11px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}
th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--panel);
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
  cursor: pointer;
}
td {
  font-size: 13px;
  line-height: 1.42;
}
tbody tr:hover { background: #f7fafc; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.wide { min-width: 260px; white-space: normal; }
.grade {
  display: inline-flex;
  width: 28px;
  height: 23px;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  color: #fff;
  font-weight: 900;
}
.cause {
  display: inline-flex;
  padding: 4px 8px;
  border-radius: 999px;
  background: #edf1f5;
  color: var(--text);
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.action-list {
  display: grid;
  gap: 8px;
  padding: 12px;
}
.action {
  display: grid;
  gap: 7px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}
.action-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}
.action strong { font-size: 14px; }
.muted { color: var(--muted); }
.pill {
  padding: 4px 8px;
  border-radius: 999px;
  background: #edf1f5;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

@media (max-width: 1100px) {
  .metric-grid, .priority-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .toolbar { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sort-button { width: 100%; }
}

@media (max-width: 720px) {
  .app-header {
    height: auto;
    min-height: 70px;
    align-items: flex-start;
    flex-direction: column;
    padding: 14px 18px;
  }
  .brand-block { flex-direction: column; gap: 2px; }
  .shell { width: calc(100vw - 24px); margin-top: 12px; }
  .definition-row { align-items: flex-start; flex-direction: column; }
  .metric-grid, .priority-grid, .toolbar { grid-template-columns: 1fr; }
  .workbench-top { align-items: stretch; flex-direction: column; }
  .tabs { width: 100%; overflow-x: auto; }
}
