:root {
  color-scheme: light;
  --ink: #17202a;
  --muted: #607080;
  --line: #d9e0e7;
  --panel: #ffffff;
  --paper: #f5f7f9;
  --blue: #1266a8;
  --green: #1b7f4c;
  --red: #af3342;
  --gold: #9a6500;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Segoe UI, Arial, sans-serif;
  color: var(--ink);
  background: var(--paper);
}

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

.app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 232px 1fr;
}

.sidebar {
  background: #152332;
  color: #fff;
  padding: 18px 14px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 22px;
}

.mark {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #2f855a;
  font-weight: 700;
}

.brand strong {
  display: block;
  font-size: 16px;
}

.brand span {
  color: #b9c8d6;
  font-size: 12px;
}

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

.nav button {
  width: 100%;
  border: 0;
  border-radius: 6px;
  color: #d8e3ec;
  background: transparent;
  text-align: left;
  padding: 10px 12px;
  cursor: pointer;
}

.nav button.active,
.nav button:hover {
  background: #24384d;
  color: #fff;
}

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

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

h1 {
  margin: 0;
  font-size: 26px;
  letter-spacing: 0;
}

.subtle {
  color: var(--muted);
  margin: 5px 0 0;
}

.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.btn {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  padding: 9px 12px;
  border-radius: 6px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn.primary {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
}

.btn.danger {
  color: var(--red);
}

.kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(145px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.kpi,
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.kpi {
  padding: 14px;
}

.kpi span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 7px;
}

.kpi strong {
  font-size: 22px;
}

.kpi small {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-top: 7px;
}

.layout {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 14px;
}

.panel {
  padding: 14px;
  min-width: 0;
}

.panel h2 {
  margin: 0 0 12px;
  font-size: 17px;
}

.bulk-actions {
  min-height: 40px;
  margin: -4px 0 10px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfd;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.bulk-actions .subtle {
  margin: 0;
}

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

.field {
  display: grid;
  gap: 5px;
}

.field.full {
  grid-column: 1 / -1;
}

label {
  color: var(--muted);
  font-size: 12px;
}

input,
select,
textarea {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 10px;
  width: 100%;
  background: #fff;
}

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

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

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

th {
  color: var(--muted);
  font-weight: 600;
  background: #fbfcfd;
}

.select-cell {
  width: 38px;
  text-align: center;
}

.select-cell input {
  width: 17px;
  height: 17px;
  margin: 0;
  cursor: pointer;
}

.row-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.mini {
  padding: 5px 7px;
  border-radius: 5px;
  border: 1px solid var(--line);
  background: #fff;
  cursor: pointer;
  color: var(--ink);
}

.mini.danger {
  color: var(--red);
}

.inline-select {
  min-width: 150px;
  padding: 6px 8px;
  border-radius: 5px;
}

.status {
  display: inline-block;
  padding: 3px 7px;
  border-radius: 999px;
  background: #e9eef3;
  color: #34495e;
}

.money.good {
  color: var(--green);
}

.money.bad {
  color: var(--red);
}

.notice {
  margin: 0 0 14px;
  padding: 10px 12px;
  border: 1px solid #cfe0ef;
  background: #eef7ff;
  border-radius: 8px;
  color: #24465f;
}

.remote-address { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 0 0 14px; padding: 11px 13px; border: 1px solid #b7d8c5; background: #eff9f3; border-radius: 8px; }
.remote-address span { font-weight: 600; }
.remote-address a { color: var(--blue); overflow-wrap: anywhere; }
.remote-address small { color: var(--muted); margin-left: auto; }

.tracking-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 14px;
}

.tracking-meta div {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  background: #fbfcfd;
}

.tracking-meta span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 5px;
}

.tracking-meta strong {
  font-size: 13px;
  overflow-wrap: anywhere;
}

.hidden {
  display: none !important;
}

.driver-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 18px;
  background: #edf1f5;
}

.driver-shell {
  width: min(520px, 100%);
}

.driver-brand {
  color: var(--ink);
  margin-bottom: 14px;
}

.driver-brand span {
  color: var(--muted);
}

.driver-form {
  display: grid;
  gap: 12px;
}

.driver-form h1 {
  font-size: 24px;
}

.signed-in-user { align-self: center; color: var(--muted); font-size: 13px; }
.auth-page { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: #edf1f5; }
.auth-shell { width: min(420px, 100%); }
.auth-brand { color: var(--ink); margin-bottom: 14px; }
.auth-brand span { color: var(--muted); }
.auth-panel { padding: 22px; }
.auth-panel h1 { font-size: 24px; }
.auth-form { display: grid; gap: 13px; margin-top: 20px; }
.auth-form .btn { justify-content: center; margin-top: 4px; }
.auth-error { color: var(--red); background: #fff1f2; border: 1px solid #f0c7cc; border-radius: 6px; padding: 9px 10px; margin: 14px 0 0; font-size: 13px; }

.driver-loads { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 14px; }
.driver-load-card { display: grid; gap: 15px; }
.driver-load-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.driver-load-heading h2 { font-size: 21px; margin: 2px 0 0; }
.driver-route { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.driver-route div { border-left: 3px solid var(--blue); padding-left: 10px; display: grid; gap: 4px; }
.driver-route span, .driver-route small { color: var(--muted); font-size: 12px; }
.driver-route strong { font-size: 15px; }
.driver-load-meta { display: flex; flex-wrap: wrap; gap: 8px 18px; color: var(--muted); font-size: 13px; }
.driver-notes { margin: 0; padding: 10px; background: #f7f9fb; border: 1px solid var(--line); border-radius: 6px; white-space: pre-wrap; }
.driver-pod-form { display: grid; grid-template-columns: minmax(180px, 1fr) minmax(160px, 1fr) auto; gap: 10px; align-items: end; border-top: 1px solid var(--line); padding-top: 14px; }
.empty-state { max-width: 560px; padding: 24px; }
.permission-block { margin-top: 16px; }
.field-label { display: block; color: var(--muted); font-size: 12px; margin-bottom: 8px; }
.permission-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 7px 12px; }
.permission-grid label { display: flex; align-items: center; gap: 7px; color: var(--ink); }
.permission-grid input { width: 16px; height: 16px; margin: 0; }
.form-actions { justify-content: flex-start; margin-top: 16px; }
.cloud-tools { display: flex; justify-content: space-between; align-items: center; gap: 18px; margin-bottom: 14px; }
.cloud-tools h2 { margin-bottom: 4px; }
.restore-form { display: flex; align-items: center; gap: 8px; }
.restore-form input { max-width: 220px; }

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

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 2;
  }

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

  .layout,
  .kpis {
    grid-template-columns: 1fr;
  }

  .topbar {
    display: block;
  }

  .cloud-tools, .restore-form { align-items: stretch; flex-direction: column; }
  .remote-address small { margin-left: 0; width: 100%; }

  .driver-pod-form { grid-template-columns: 1fr; }

  .actions {
    justify-content: flex-start;
    margin-top: 12px;
  }
}

@media (max-width: 560px) {
  .driver-loads, .driver-route, .permission-grid, .grid { grid-template-columns: 1fr; }
  .main { padding: 14px; }
}
