:root {
  --bg: #f5f7f8;
  --panel: #ffffff;
  --panel-muted: #f9fafb;
  --border: #dbe3e4;
  --border-strong: #c5d1d3;
  --text: #17242a;
  --muted: #617078;
  --teal: #0c6b64;
  --teal-strong: #084c47;
  --navy: #17324d;
  --blue: #245b9c;
  --amber: #b26b00;
  --amber-bg: #fff4dd;
  --red: #b42318;
  --red-bg: #ffe7e4;
  --green: #0f7a4f;
  --green-bg: #e7f6ef;
  --shadow: 0 18px 48px rgba(23, 36, 42, 0.08);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input,
select,
textarea {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: 264px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  background: #102b36;
  color: #f3fbfa;
  display: flex;
  flex-direction: column;
  gap: 26px;
  padding: 24px 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: #eaf7f4;
  color: var(--teal-strong);
  font-weight: 800;
}

.brand-title {
  font-size: 15px;
  font-weight: 750;
}

.brand-subtitle {
  color: #a9c5c1;
  font-size: 12px;
  margin-top: 2px;
}

.nav-list {
  display: grid;
  gap: 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 42px;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: #d7e7e5;
  text-align: left;
  cursor: pointer;
}

.nav-item:hover,
.nav-item.active {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.12);
  color: #ffffff;
}

.icon {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
  font-size: 13px;
  font-weight: 700;
}

.sidebar-note {
  margin-top: auto;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.07);
}

.note-title {
  font-size: 13px;
  font-weight: 750;
  margin-bottom: 6px;
}

.sidebar-note p {
  margin: 0;
  color: #c7dcda;
  font-size: 12px;
  line-height: 1.45;
}

.main {
  padding: 24px;
  min-width: 0;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
  margin-bottom: 18px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 26px;
  line-height: 1.2;
}

h2 {
  font-size: 16px;
  line-height: 1.2;
}

.topbar p,
.panel-header p {
  color: var(--muted);
  font-size: 13px;
  margin-top: 5px;
}

.pilot-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 34px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #ffffff;
  color: var(--teal-strong);
  font-size: 13px;
  font-weight: 700;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.stat-card {
  min-height: 92px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: 0 8px 24px rgba(23, 36, 42, 0.04);
}

.stat-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.stat-card strong {
  display: block;
  margin-top: 10px;
  color: var(--navy);
  font-size: 30px;
  line-height: 1;
}

.work-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(340px, 0.75fr);
  gap: 14px;
  align-items: start;
}

.bottom-grid {
  display: grid;
  grid-template-columns: 1.25fr 0.75fr;
  gap: 14px;
  margin-top: 14px;
}

.panel {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
  min-width: 0;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  padding: 16px;
  border-bottom: 1px solid var(--border);
}

.panel-header.compact {
  padding-bottom: 12px;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
}

.filter {
  height: 32px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #ffffff;
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
}

.filter.active,
.filter:hover {
  background: var(--teal);
  border-color: var(--teal);
  color: #ffffff;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

th {
  height: 38px;
  padding: 0 14px;
  color: var(--muted);
  font-size: 11px;
  text-align: left;
  text-transform: uppercase;
}

td {
  padding: 13px 14px;
  border-top: 1px solid var(--border);
  vertical-align: middle;
  font-size: 13px;
}

tbody tr {
  cursor: pointer;
}

tbody tr:hover,
tbody tr.selected {
  background: #f2f8f7;
}

.caller-name {
  display: block;
  font-weight: 750;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.caller-meta {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chip {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  min-height: 26px;
  padding: 4px 8px;
  border-radius: 7px;
  font-size: 12px;
  font-weight: 750;
  white-space: nowrap;
}

.chip.routine {
  background: var(--green-bg);
  color: var(--green);
}

.chip.same-day {
  background: #e9f1ff;
  color: var(--blue);
}

.chip.urgent {
  background: var(--amber-bg);
  color: var(--amber);
}

.chip.safeguarding,
.chip.emergency {
  background: var(--red-bg);
  color: var(--red);
}

.status-pill {
  display: inline-block;
  max-width: 100%;
  color: var(--navy);
  font-size: 12px;
  font-weight: 650;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.detail-content {
  padding: 16px;
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 320px;
  color: var(--muted);
  text-align: center;
}

.detail-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.detail-title-row strong {
  display: block;
  font-size: 18px;
}

.detail-number {
  color: var(--muted);
  font-size: 13px;
  margin-top: 3px;
}

.detail-block {
  padding: 13px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel-muted);
  margin-top: 10px;
}

.detail-block label {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  margin-bottom: 6px;
}

.detail-block p {
  color: var(--text);
  font-size: 13px;
  line-height: 1.45;
}

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 14px;
}

.action-button {
  min-height: 38px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: #ffffff;
  color: var(--navy);
  cursor: pointer;
  font-size: 12px;
  font-weight: 750;
}

.action-button.primary {
  background: var(--teal);
  border-color: var(--teal);
  color: #ffffff;
}

.action-button.warn {
  background: var(--red-bg);
  border-color: #ffc9c3;
  color: var(--red);
}

.action-button:disabled {
  background: #eef2f3;
  border-color: var(--border);
  color: #8a979c;
  cursor: not-allowed;
}

.action-button:hover:not(:disabled) {
  transform: translateY(-1px);
}

.ladder {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  padding: 16px;
}

.ladder-card {
  min-height: 112px;
  padding: 13px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel-muted);
}

.ladder-card span {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: #e8eeee;
  color: var(--navy);
  font-size: 12px;
  font-weight: 800;
}

.ladder-card strong {
  display: block;
  margin-top: 12px;
  font-size: 13px;
}

.ladder-card small {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.ladder-card.high span {
  background: var(--amber-bg);
  color: var(--amber);
}

.ladder-card.alert span {
  background: var(--red-bg);
  color: var(--red);
}

.category-chart {
  display: grid;
  gap: 10px;
  padding: 16px;
}

.bar-row {
  display: grid;
  grid-template-columns: minmax(120px, 170px) 1fr 32px;
  align-items: center;
  gap: 9px;
  font-size: 12px;
}

.bar-label {
  color: var(--text);
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bar-track {
  height: 9px;
  border-radius: 999px;
  background: #e3eaeb;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: inherit;
  background: var(--teal);
}

.bar-count {
  color: var(--muted);
  text-align: right;
  font-weight: 750;
}

@media (max-width: 1100px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    padding: 16px;
  }

  .nav-list {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .sidebar-note {
    display: none;
  }

  .work-grid,
  .bottom-grid {
    grid-template-columns: 1fr;
  }

  .stats-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .main {
    padding: 14px;
  }

  .topbar {
    flex-direction: column;
  }

  .nav-list,
  .stats-grid,
  .ladder,
  .detail-grid,
  .actions {
    grid-template-columns: 1fr;
  }

  .nav-item {
    justify-content: flex-start;
  }

  .panel-header {
    flex-direction: column;
  }

  th:nth-child(2),
  td:nth-child(2),
  th:nth-child(4),
  td:nth-child(4) {
    display: none;
  }
}
