:root {
  color-scheme: light;
  --bg: #f8f3f3;
  --surface: #ffffff;
  --surface-soft: #fff0f0;
  --text: #271818;
  --muted: #756565;
  --line: #ead6d6;
  --brand: #c40000;
  --brand-dark: #990000;
  --service: #46a934;
  --idle: #e02929;
  --pyp: #f1b38b;
  --pending: #fff45c;
  --shadow: 0 14px 34px rgba(72, 0, 0, 0.1);
}

* {
  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;
  font-size: 15px;
}

.container {
  max-width: 1180px;
}

a {
  color: var(--brand);
  text-decoration: none;
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  align-items: center;
  background: #8e0000;
  color: #fff;
  display: flex;
  gap: 18px;
  justify-content: space-between;
  padding: 14px clamp(16px, 3vw, 34px);
}

.brand {
  color: #fff;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.nav {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.nav a {
  border-radius: 6px;
  color: rgba(255, 255, 255, 0.86);
  padding: 8px 10px;
}

.nav a:hover,
.nav a.active {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.user-strip {
  align-items: center;
  display: flex;
  gap: 10px;
}

.container {
  margin: 0 auto;
  max-width: 1180px;
  padding: 24px clamp(14px, 3vw, 34px) 42px;
}

.page-head {
  align-items: center;
  display: flex;
  gap: 16px;
  justify-content: space-between;
  margin-bottom: 18px;
}

.page-head h1 {
  font-size: clamp(24px, 3vw, 34px);
  letter-spacing: 0;
  margin: 0;
}

.eyebrow {
  color: rgba(255, 255, 255, 0.78);
  display: inline-flex;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.08em;
  margin-bottom: 8px;
  text-transform: uppercase;
}

.eyebrow.dark {
  color: var(--brand);
}

.toolbar {
  align-items: end;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  margin-bottom: 18px;
  overflow: hidden;
}

.panel-header {
  align-items: center;
  background: var(--surface-soft);
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  padding: 14px 16px;
}

.panel-header h2 {
  font-size: 16px;
  margin: 0;
}

.panel-body {
  padding: 16px;
}

.grid {
  display: grid;
  gap: 12px;
}

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

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

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

.grid-span {
  grid-column: span 2;
}

label {
  color: var(--muted);
  display: grid;
  font-size: 12px;
  font-weight: 700;
  gap: 6px;
  text-transform: uppercase;
}

input,
select,
textarea {
  background: #fff;
  border: 1px solid #dec8c8;
  border-radius: 6px;
  color: var(--text);
  font: inherit;
  min-height: 40px;
  padding: 9px 10px;
  width: 100%;
}

input[type="checkbox"] {
  min-height: auto;
  width: auto;
}

textarea {
  min-height: 76px;
  resize: vertical;
}

.btn {
  align-items: center;
  background: var(--brand);
  border: 0;
  border-radius: 6px;
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  font: inherit;
  font-weight: 800;
  gap: 8px;
  justify-content: center;
  min-height: 40px;
  padding: 9px 13px;
  white-space: nowrap;
}

.btn:hover {
  background: var(--brand-dark);
}

.btn.light {
  background: #fff;
  color: var(--brand);
}

.btn.light:hover {
  background: #f8e7e7;
  color: var(--brand-dark);
}

.btn.secondary {
  background: #f4e7e7;
  color: #4b1717;
}

.btn.danger {
  background: #bb2d2d;
}

.btn.small {
  font-size: 13px;
  min-height: 32px;
  padding: 6px 9px;
}

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

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

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 10px;
  text-align: left;
  vertical-align: top;
}

th {
  background: #b60000;
  color: #fff;
  font-size: 12px;
  text-transform: uppercase;
}

tr:last-child td {
  border-bottom: 0;
}

.badge {
  border-radius: 999px;
  display: inline-flex;
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
  padding: 6px 9px;
}

.badge.service {
  background: #daf2d5;
  color: #1d6425;
}

.badge.idle {
  background: #ffdede;
  color: #971b1b;
}

.badge.pyp {
  background: #ffe4d3;
  color: #8c471b;
}

.badge.pending {
  background: var(--pending);
  color: #534a00;
}

.flash {
  border-radius: 8px;
  font-weight: 700;
  margin-bottom: 12px;
  padding: 12px 14px;
}

.flash.success {
  background: #dff7e2;
  color: #175b25;
}

.flash.error {
  background: #ffe0e0;
  color: #8a1717;
}

.summary-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.summary-card {
  background: var(--surface);
  border: 1px solid #edd5d5;
  border-radius: 8px;
  box-shadow: 0 16px 38px rgba(65, 0, 0, 0.08);
  padding: 16px;
  position: relative;
  overflow: hidden;
}

.summary-card::before {
  background: linear-gradient(180deg, var(--brand), #f0b2b2);
  content: "";
  inset: 0 auto 0 0;
  position: absolute;
  width: 4px;
}

.summary-card h2 {
  align-items: center;
  display: flex;
  font-size: 18px;
  justify-content: space-between;
  margin: 0 0 12px;
  padding-left: 4px;
}

.metric {
  display: grid;
  gap: 2px;
}

.metric strong {
  font-size: 24px;
}

.metric-row {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(3, 1fr);
}

.metric-row .metric {
  background: #fff7f7;
  border: 1px solid #f0dddd;
  border-radius: 8px;
  padding: 8px;
}

.metric-row .metric strong {
  font-size: 20px;
}

.dashboard-hero {
  align-items: center;
  background:
    linear-gradient(105deg, rgba(120, 0, 0, 0.98), rgba(196, 0, 0, 0.9)),
    radial-gradient(circle at 90% 10%, rgba(255, 255, 255, 0.28), transparent 30%);
  border-radius: 8px;
  box-shadow: 0 20px 44px rgba(84, 0, 0, 0.18);
  color: #fff;
  display: flex;
  gap: 20px;
  justify-content: space-between;
  margin-bottom: 18px;
  min-height: 150px;
  padding: 24px;
}

.dashboard-hero h1 {
  font-size: clamp(28px, 4vw, 42px);
  letter-spacing: 0;
  line-height: 1;
  margin: 0 0 10px;
}

.dashboard-hero p {
  color: rgba(255, 255, 255, 0.86);
  font-weight: 650;
  margin: 0;
}

.month-filter {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 8px;
  padding: 12px;
}

.month-filter label {
  color: rgba(255, 255, 255, 0.86);
}

.executive-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: 1.35fr repeat(3, minmax(0, 1fr));
  margin-bottom: 14px;
}

.executive-card {
  background: #fff;
  border: 1px solid #edd5d5;
  border-radius: 8px;
  box-shadow: 0 14px 34px rgba(65, 0, 0, 0.07);
  display: grid;
  gap: 7px;
  min-height: 122px;
  padding: 18px;
}

.executive-card.main {
  background:
    linear-gradient(135deg, #2b1717, #651313),
    linear-gradient(135deg, var(--brand), var(--brand-dark));
  color: #fff;
}

.executive-card strong {
  font-size: clamp(26px, 3vw, 36px);
  line-height: 1;
}

.executive-card small {
  color: var(--muted);
  font-weight: 650;
}

.executive-card.main small,
.executive-card.main .metric-label {
  color: rgba(255, 255, 255, 0.78);
}

.metric-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.dashboard-header {
  align-items: center;
  background: #fff;
  border: 1px solid #ead6d6;
  border-left: 6px solid var(--brand);
  border-radius: 8px;
  box-shadow: 0 12px 30px rgba(67, 0, 0, 0.06);
  display: flex;
  gap: 18px;
  justify-content: space-between;
  margin-bottom: 16px;
  padding: 18px 20px;
}

.dashboard-header h1 {
  font-size: clamp(26px, 3vw, 34px);
  letter-spacing: 0;
  margin: 0 0 6px;
}

.dashboard-header p {
  color: var(--muted);
  font-weight: 650;
  margin: 0;
}

.dashboard-header .month-filter {
  background: #fff6f6;
  border: 1px solid #ead6d6;
  border-radius: 8px;
  padding: 10px;
}

.dashboard-header .month-filter label {
  color: var(--muted);
}

.kpi-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: 1.45fr repeat(3, minmax(0, 1fr));
  margin-bottom: 14px;
}

.kpi-card {
  background: #fff;
  border: 1px solid #ead6d6;
  border-radius: 8px;
  box-shadow: 0 12px 30px rgba(67, 0, 0, 0.06);
  display: grid;
  gap: 8px;
  min-height: 118px;
  padding: 18px;
}

.kpi-card.primary {
  background: #b60000;
  border-color: #b60000;
  color: #fff;
}

.kpi-card strong {
  font-size: clamp(26px, 3vw, 38px);
  line-height: 1;
}

.kpi-card small {
  color: var(--muted);
  font-weight: 650;
}

.kpi-card.primary small,
.kpi-card.primary .metric-label {
  color: rgba(255, 255, 255, 0.82);
}

.status-strip {
  background: #fff;
  border: 1px solid #ead6d6;
  border-radius: 8px;
  box-shadow: 0 12px 30px rgba(67, 0, 0, 0.05);
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 22px;
  overflow: hidden;
}

.status-strip div {
  border-right: 1px solid #f0dddd;
  display: grid;
  gap: 4px;
  padding: 14px 18px;
}

.status-strip div:last-child {
  border-right: 0;
}

.status-strip span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
  text-transform: uppercase;
}

.status-strip strong {
  font-size: 24px;
}

.operations-strip {
  background: #fff;
  border: 1px solid #edd5d5;
  border-radius: 8px;
  box-shadow: 0 14px 34px rgba(65, 0, 0, 0.06);
  display: grid;
  gap: 0;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 22px;
  overflow: hidden;
}

.operations-strip div {
  border-right: 1px solid #f0dddd;
  display: grid;
  gap: 4px;
  padding: 14px 18px;
}

.operations-strip div:last-child {
  border-right: 0;
}

.operations-strip span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
  text-transform: uppercase;
}

.operations-strip strong {
  font-size: 24px;
}

.section-title-row {
  align-items: end;
  display: flex;
  justify-content: space-between;
  margin: 6px 0 12px;
}

.section-title-row h2 {
  font-size: 22px;
  margin: 0;
}

.vehicle-grid {
  margin-bottom: 18px;
}

.records-panel .panel-header {
  background: #fff;
}

.muted {
  color: var(--muted);
}

.actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.login-page {
  align-items: center;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.86), rgba(255, 255, 255, 0.74)),
    linear-gradient(135deg, #f8f4f4 0%, #e4d9d9 48%, #fdfafa 48%, #fff 100%);
  display: grid;
  min-height: 100vh;
  padding: 20px;
}

.login-card {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 18px 42px rgba(74, 0, 0, 0.18);
  margin: 0 auto;
  max-width: 420px;
  padding: 24px;
  width: 100%;
}

.login-card h1 {
  font-size: 22px;
  letter-spacing: 0;
  margin: 0 0 18px;
  text-align: center;
}

.login-card label {
  color: #2a1616;
  font-size: 14px;
  font-weight: 500;
  text-transform: none;
}

.login-logo {
  display: flex;
  justify-content: center;
  margin-bottom: 4px;
}

.login-logo img {
  display: block;
  height: 118px;
  width: 180px;
}

.day-cell.service {
  background: rgba(70, 169, 52, 0.14);
}

.day-cell.idle {
  background: rgba(224, 41, 41, 0.12);
}

.day-cell.pyp {
  background: rgba(241, 179, 139, 0.34);
}

.day-cell.empty {
  color: var(--muted);
}

.record-lines {
  display: grid;
  gap: 4px;
  min-width: 240px;
}

.inline-form {
  display: inline;
}

.json-preview {
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  max-width: 420px;
  overflow-wrap: anywhere;
}

@media (max-width: 780px) {
  .topbar,
  .page-head,
  .dashboard-header,
  .dashboard-hero,
  .section-title-row {
    align-items: stretch;
    flex-direction: column;
  }

  .kpi-grid,
  .status-strip,
  .executive-grid,
  .operations-strip {
    grid-template-columns: 1fr;
  }

  .status-strip div,
  .operations-strip div {
    border-bottom: 1px solid #f0dddd;
    border-right: 0;
  }

  .status-strip div:last-child,
  .operations-strip div:last-child {
    border-bottom: 0;
  }

  .grid.cols-2,
  .grid.cols-3,
  .grid.cols-4,
  .grid-span,
  .metric-row {
    grid-template-columns: 1fr;
    grid-column: auto;
  }

  .nav {
    gap: 4px;
  }
}

@media (min-width: 781px) and (max-width: 1050px) {
  .kpi-grid,
  .executive-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .status-strip,
  .operations-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
