:root {
  color-scheme: light;
  --ink: #17202a;
  --muted: #617083;
  --line: #d8e0e8;
  --soft: #f4f7fa;
  --panel: #ffffff;
  --accent: #0f766e;
  --accent-strong: #115e59;
  --blue: #2563eb;
  --amber: #d97706;
  --red: #dc2626;
  --green: #16a34a;
  --day: #ffffff;
  --day-text: #1f3b57;
  --shadow: 0 14px 32px rgba(21, 32, 43, .08);
}

body.dark {
  --ink: #e8eef4;
  --muted: #9fb0c2;
  --line: #2c3a4b;
  --soft: #1f2b38;
  --panel: #16212d;
  --accent: #14b8a6;
  --accent-strong: #0f766e;
  --blue: #60a5fa;
  --amber: #f59e0b;
  --red: #f87171;
  --green: #4ade80;
  --day: #182536;
  --day-text: #d8e6f3;
  --shadow: 0 14px 32px rgba(0, 0, 0, .26);
  background: #0f1722;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  background: #eef3f7;
  color: var(--ink);
}

body.auth-locked main,
body.auth-locked .topbar,
body.auth-locked .tabs {
  display: none;
}

.login-screen {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: #0f1722;
  z-index: 1000;
}

.login-screen[hidden] {
  display: none;
}

.login-panel {
  width: min(420px, calc(100vw - 32px));
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 28px;
  display: grid;
  gap: 14px;
}

.login-panel label {
  display: grid;
  gap: 6px;
  font-weight: 700;
}

.login-panel input {
  width: 100%;
  padding: 11px 12px;
  border-radius: 6px;
  border: 1px solid var(--line);
}

.login-error {
  min-height: 20px;
  color: var(--red);
  font-weight: 700;
}

body.dark button.ghost {
  background: #111b26;
  color: var(--ink);
}

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

button {
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: white;
  padding: 10px 14px;
  cursor: pointer;
  font-weight: 700;
}

button:hover { background: var(--accent-strong); }
button.secondary { background: #1f3b57; }
button.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }

.table-time-input,
.table-money-input,
.table-text-input {
  width: 76px;
  min-width: 0;
  padding: 7px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--ink);
  font-weight: 700;
}

.table-time-input {
  width: 66px;
}

.table-text-input {
  width: 160px;
}

.money-cell {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 10px;
  white-space: nowrap;
}

.overweight-badge {
  display: inline-block;
  margin-left: 4px;
  padding: 2px 5px;
  border-radius: 5px;
  background: #fee2e2;
  color: #991b1b;
  font-size: 10px;
  font-weight: 900;
  text-transform: uppercase;
  white-space: nowrap;
}

.topbar {
  min-height: 84px;
  padding: 18px 24px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
}

body.dark .topbar,
body.dark .tabs,
body.dark .toolbar,
body.dark .queue,
body.dark .week-board,
body.dark .table-wrap,
body.dark .report-grid section,
body.dark .master-grid section,
body.dark .module-panel,
body.dark .metrics article,
body.dark .driver-column,
body.dark dialog {
  background: var(--panel);
}

body.dark .tab.active,
body.dark main {
  background: #0f1722;
}

body.dark .tab {
  color: var(--muted);
}

h1, h2, p { margin: 0; }
h1 { font-size: 24px; letter-spacing: 0; }
h2 { font-size: 17px; letter-spacing: 0; }
p { color: var(--muted); margin-top: 4px; }

.top-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.user-label { align-self: center; font-weight: 700; color: var(--muted); }
.admin-only[hidden] { display: none !important; }

.tabs {
  display: flex;
  gap: 6px;
  padding: 10px 24px 0;
  background: #fff;
  border-bottom: 1px solid var(--line);
}

.tab {
  background: transparent;
  color: var(--muted);
  border-radius: 6px 6px 0 0;
  border: 1px solid transparent;
  border-bottom: 0;
}

.tab.active {
  color: var(--ink);
  background: #eef3f7;
  border-color: var(--line);
}

main { padding: 18px 24px 28px; }
.view { display: none; }
.view.active { display: block; }

.toolbar {
  min-height: 58px;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-bottom: 14px;
}

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

.week-current {
  min-width: 150px;
}

.week-search {
  display: flex;
  gap: 6px;
  align-items: center;
  position: relative;
}

.week-search input {
  width: 170px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 10px;
}

.calendar-popup {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 20;
  width: 292px;
  padding: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.calendar-head {
  display: grid;
  grid-template-columns: 34px 1fr 34px;
  gap: 8px;
  align-items: center;
  margin-bottom: 10px;
}

.calendar-head button {
  height: 32px;
  padding: 0;
}

.calendar-head strong {
  text-align: center;
  color: var(--ink);
}

.calendar-weekdays,
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.calendar-weekdays {
  margin-bottom: 5px;
}

.calendar-weekdays span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-align: center;
}

.calendar-day {
  height: 32px;
  border-radius: 6px;
  background: var(--soft);
  color: var(--ink);
  padding: 0;
  font-weight: 700;
}

.calendar-day:hover {
  background: #dbeafe;
  color: #1d4ed8;
}

.calendar-day.muted-day {
  opacity: .42;
}

.calendar-day.today {
  outline: 2px solid var(--accent);
}

.calendar-day.selected-week {
  background: #dbeafe;
  color: #1d4ed8;
}

body.dark .calendar-day:hover,
body.dark .calendar-day.selected-week {
  background: #1e3a5f;
  color: #bfdbfe;
}

.eyebrow {
  display: block;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .08em;
  margin-bottom: 3px;
}

.legend { display: flex; gap: 14px; flex-wrap: wrap; color: var(--muted); font-size: 13px; }
.dot { width: 10px; height: 10px; display: inline-block; border-radius: 50%; margin-right: 5px; }
.sent { background: var(--blue); }
.onsite { background: var(--amber); }
.done { background: var(--green); }
.delay { background: var(--red); }

.planner-layout {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.queue, .week-board, .table-wrap, .report-grid section, .master-grid section {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.queue { padding: 14px; position: sticky; top: 10px; }
.panel-title { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.panel-title span { color: var(--muted); font-size: 13px; }
.month-switcher {
  display: inline-grid;
  grid-template-columns: 30px minmax(130px, auto) 30px;
  gap: 8px;
  align-items: center;
}
.month-switcher strong {
  color: var(--ink);
  text-align: center;
}
.month-switcher button {
  height: 30px;
  padding: 0;
}
.queue-date {
  display: grid;
  grid-template-columns: 38px 1fr 38px;
  align-items: center;
  gap: 7px;
  margin-bottom: 10px;
}
.queue-date button {
  height: 34px;
  padding: 0;
}
.queue-date strong {
  min-width: 0;
  text-align: center;
  font-size: 13px;
  color: #31455a;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.queue-list { display: flex; flex-direction: column; gap: 10px; min-height: 120px; }
.queue-job {
  display: grid;
  grid-template-columns: 48px 48px minmax(0, 1fr) 58px;
  align-items: center;
  gap: 7px;
  min-height: 38px;
  padding: 7px 9px;
  background: #fff;
  border: 1px solid var(--line);
  border-left: 4px solid var(--blue);
  border-radius: 8px;
  box-shadow: 0 3px 9px rgba(23,32,42,.05);
  cursor: grab;
  font-size: 12px;
}
.queue-job strong,
.queue-job span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.queue-date-chip {
  border-radius: 999px;
  background: var(--soft);
  color: #31455a;
  padding: 3px 6px;
  text-align: center;
  font-weight: 700;
}
.empty-queue {
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  padding: 14px;
  text-align: center;
  font-size: 13px;
}

.week-board {
  overflow: auto;
  padding: 0 0 16px;
  background: #f8fbfd;
}

.day-section {
  min-width: 1180px;
  padding: 0 14px 18px;
  border-bottom: 1px solid var(--line);
}

.day-section:last-child { border-bottom: 0; }

.day-title {
  margin: 0 -14px 14px;
  background: var(--day);
  color: var(--day-text);
  text-align: left;
  font-size: 22px;
  line-height: 1;
  letter-spacing: 0;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}

.resource-group {
  margin-bottom: 16px;
}

.resource-group:last-child {
  margin-bottom: 0;
}

.resource-group-title {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .08em;
  margin: 0 0 8px;
  text-transform: uppercase;
}

.resource-columns {
  display: grid;
  grid-template-columns: repeat(auto-fill, 194px);
  width: 100%;
  align-items: stretch;
  justify-content: start;
  gap: 12px;
}

.driver-column {
  min-height: 312px;
  min-width: 0;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 22px rgba(23, 32, 42, .06);
  overflow: hidden;
}

.subbie-group {
  margin-top: 6px;
}

.subbie-column .company-line {
  background: #efe8ff;
  color: #4c1d95;
}

.subbie-column .driver-line {
  background: #f5f0ff;
  color: #3b2863;
}

.resource-card {
  background: #f7fafc;
  border-bottom: 1px solid var(--line);
  text-align: center;
  font-size: 12px;
}

body.dark .resource-card,
body.dark .slot,
body.dark .job-card,
body.dark table,
body.dark input,
body.dark select,
body.dark textarea {
  background: #111b26;
  color: var(--ink);
}

body.dark .truck-line {
  background: #20334a;
  color: #d9eafe;
}

body.dark .company-line {
  background: #3a311c;
  color: #f8dfa4;
}

body.dark .driver-line {
  background: #1d3346;
  color: #d8e6f3;
}

body.dark .job-vbs-input,
body.dark .time-row input,
body.dark .job-split,
body.dark .job-bottom,
body.dark th {
  background: #1b2836;
}

body.dark .editable-vehicle-line select {
  color: #d9eafe;
}

body.dark .vehicle-warning.overdue {
  background: #4c1d1d;
  color: #fecaca;
}

body.dark .vehicle-warning.soon {
  background: #4a3415;
  color: #fde68a;
}

body.dark .job-split span:first-child {
  color: #fed7aa;
}

body.dark .job-time,
body.dark .job-place,
body.dark .job-bottom span {
  color: var(--ink);
}

body.dark .job-container {
  color: #5eead4;
}

body.dark .pill {
  background: #243345;
  color: #d8e6f3;
}

body.dark .pill.ok,
body.dark .job-status.ok,
body.dark .job-status-select.ok {
  background: #164e35;
  color: #bbf7d0;
}

body.dark .pill.warn,
body.dark .job-status.warn,
body.dark .job-status-select.warn {
  background: #4a3415;
  color: #fde68a;
}

body.dark .job-status {
  background: #1e3a5f;
  color: #bfdbfe;
}

body.dark .job-status-select,
body.dark .detail-row {
  background: #1b2836;
}

body.dark .queue-date strong {
  color: var(--ink);
}

body.dark .queue-job {
  background: #111b26;
}

body.dark .queue-date-chip {
  background: #243345;
  color: #d8e6f3;
}

.truck-line {
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: #e7f0ff;
  color: #18324f;
  font-weight: 700;
}

.editable-vehicle-line {
  gap: 1px;
}

.editable-vehicle-line select {
  width: 100%;
  min-width: 0;
  border: 0;
  border-right: 1px solid rgba(70, 92, 120, .22);
  border-radius: 0;
  background: transparent;
  color: inherit;
  padding: 7px 5px;
  text-align: center;
  font-weight: 800;
}

.vehicle-overdue {
  background: #fee2e2 !important;
  color: #991b1b !important;
}

.vehicle-soon {
  background: #fff1d6 !important;
  color: #8a4f00 !important;
}

.vehicle-warning {
  padding: 6px 8px;
  border-top: 1px solid var(--line);
  font-size: 11px;
  font-weight: 800;
  line-height: 1.3;
  text-align: left;
}

.vehicle-warning.overdue {
  background: #fee2e2;
  color: #991b1b;
}

.vehicle-warning.soon {
  background: #fff1d6;
  color: #8a4f00;
}

.vehicle-warning.soon::first-letter {
  animation: blink 1s steps(2, start) infinite;
}

@keyframes blink {
  50% { opacity: .18; }
}

.truck-line strong,
.truck-line span {
  min-width: 0;
  padding: 7px 5px;
  overflow-wrap: anywhere;
}

.truck-line strong { border-right: 1px solid rgba(70, 92, 120, .22); }

.company-line {
  padding: 7px 5px;
  background: #fff3bf;
  color: #5f4300;
  font-weight: 700;
  border-top: 1px solid rgba(70, 92, 120, .16);
}

.driver-line {
  padding: 7px 5px;
  background: #edf5fb;
  color: #26394d;
  font-weight: 700;
  border-top: 1px solid rgba(70, 92, 120, .16);
}

.return-warning {
  padding: 7px 8px;
  background: #fff1d6;
  color: #7c2d12;
  border-top: 1px solid rgba(217, 119, 6, .28);
  font-size: 11px;
  font-weight: 800;
  line-height: 1.3;
  text-align: left;
}

body.dark .return-warning {
  background: #4a3415;
  color: #fde68a;
  border-top-color: rgba(245, 158, 11, .35);
}

.slot {
  min-height: 238px;
  padding: 9px;
  background: #fbfcfd;
}

.slot.drag-over {
  outline: 3px solid rgba(15, 118, 110, .35);
  outline-offset: -5px;
  background: #eefdf9;
}

.job-card {
  background: #fff;
  border: 1px solid var(--line);
  border-left: 5px solid var(--blue);
  border-radius: 8px;
  padding: 0;
  cursor: grab;
  box-shadow: 0 4px 12px rgba(23,32,42,.06);
  overflow: hidden;
}

.job-card:active { cursor: grabbing; }
.job-main { padding: 12px; display: grid; gap: 7px; }
.job-number {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  overflow-wrap: anywhere;
}
.job-time {
  font-size: 22px;
  line-height: 1;
  font-weight: 800;
  color: #102a43;
}
.job-place {
  font-size: 15px;
  font-weight: 800;
  color: #17202a;
  overflow-wrap: anywhere;
}
.job-container {
  font-size: 14px;
  font-weight: 800;
  letter-spacing: .02em;
  color: #0f766e;
  overflow-wrap: anywhere;
}
.site-note-chip {
  border-left: 3px solid var(--amber);
  border-radius: 5px;
  background: #fff7ed;
  color: #7c2d12;
  padding: 6px 7px;
  font-size: 11px;
  font-weight: 800;
  line-height: 1.3;
}
body.dark .site-note-chip {
  background: #4a3415;
  color: #fde68a;
}
.job-status,
.job-status-select {
  width: fit-content;
  max-width: 100%;
  border-radius: 999px;
  padding: 4px 8px;
  background: #e8f0ff;
  color: #1d4ed8;
  font-size: 12px;
  font-weight: 800;
  overflow-wrap: anywhere;
}
.job-status-select {
  border: 0;
  cursor: pointer;
}
.job-status.ok,
.job-status-select.ok { background: #dcfce7; color: #166534; }
.job-status.warn,
.job-status-select.warn { background: #fff1d6; color: #8a4f00; }
.job-vbs-input {
  width: 100%;
  min-height: 32px;
  border: 0;
  border-radius: 6px;
  background: #f4f7fa;
  color: #46586b;
  padding: 7px 8px;
  font-size: 12px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}
.job-vbs-input:focus {
  outline: 2px solid rgba(15, 118, 110, .35);
}

.time-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.time-row input {
  width: 100%;
  min-width: 64px;
  border: 0;
  border-radius: 6px;
  background: #f4f7fa;
  color: #46586b;
  padding: 7px 8px;
  font-size: 12px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  text-align: center;
}
.job-split,
.job-bottom {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-top: 1px solid var(--line);
  background: #fbfcfd;
}
.job-split {
  background: #fff7ed;
}
.job-split span,
.job-bottom span {
  min-width: 0;
  padding: 8px;
  text-align: center;
  font-size: 12px;
  font-weight: 800;
  color: #31455a;
  overflow-wrap: anywhere;
}
.job-split span:first-child {
  color: #9a3412;
}
.job-split span:first-child,
.job-bottom span:first-child { border-right: 1px solid var(--line); }

.slot .job-card {
  margin-bottom: 8px;
  border-left-width: 5px;
}

.slot .job-card[data-status="ON SITE"] { border-left-color: var(--amber); }
.slot .job-card[data-status="COMPLETED"] { border-left-color: var(--green); }
.slot .job-card[data-status="On way - delay"] { border-left-color: var(--red); }

.pill {
  border-radius: 999px;
  padding: 3px 7px;
  background: var(--soft);
  color: #31455a;
  font-size: 12px;
}

.pill.warn { background: #fff1d6; color: #8a4f00; }
.pill.ok { background: #dcfce7; color: #166534; }

.searchbox input {
  min-width: 320px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
}

.job-list-tools {
  display: flex;
  gap: 10px;
  align-items: end;
  flex-wrap: wrap;
}

.job-list-tools label {
  min-width: 220px;
}

.job-list-tools input[type="date"] {
  border: 1px solid var(--line);
  border-radius: 6px;
  min-width: 150px;
  padding: 9px 10px;
}

.file-input {
  display: none;
}

.import-status {
  max-width: 280px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.import-status.error {
  color: var(--red);
}

.job-no-button {
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--blue);
  padding: 0;
  font-weight: 900;
  text-align: left;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.job-no-button:hover {
  background: transparent;
  color: var(--accent);
}

.danger-button {
  color: var(--red);
  border-color: rgba(220, 38, 38, .35);
}

.danger-button:hover {
  background: rgba(220, 38, 38, .12);
  color: var(--red);
}

.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; background: #fff; }
th, td { border-bottom: 1px solid var(--line); padding: 10px; text-align: left; font-size: 13px; white-space: nowrap; }
th { background: #e8eef4; color: #26394d; position: sticky; top: 0; }
td select { min-width: 138px; }

.sort-header {
  width: 100%;
  border: 0;
  background: transparent;
  color: inherit;
  padding: 0;
  text-align: left;
  font-size: inherit;
}

.sort-header:hover,
.sort-header.active {
  background: transparent;
  color: var(--accent);
}

body.dark th {
  background: #26384c;
  color: #f8fbff;
  border-bottom-color: #40546b;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.report-toolbar {
  margin-bottom: 10px;
}

.report-filters {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr)) auto;
  gap: 10px;
  align-items: end;
  margin-bottom: 14px;
}

.metrics article {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  box-shadow: var(--shadow);
}

.metrics span { color: var(--muted); display: block; margin-bottom: 8px; }
.metrics strong { font-size: 28px; }

.report-grid, .master-grid, .module-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(280px, 1fr));
  gap: 14px;
}

.report-grid section, .master-grid section, .module-panel {
  padding: 16px;
}
.module-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}
.span-2 { grid-column: 1 / -1; }
.table-wrap.flat {
  border: 0;
  box-shadow: none;
  margin-top: 12px;
  overflow: auto;
}

.rota-table {
  width: auto;
  min-width: 0;
}

.rota-table th,
.rota-table td {
  width: 46px;
  min-width: 46px;
  max-width: 46px;
  padding: 7px 5px;
  text-align: center;
  font-size: 12px;
}

.rota-table th:first-child,
.rota-table td:first-child {
  width: 210px;
  min-width: 210px;
  max-width: 210px;
  text-align: left;
}

.rota-table th span,
.rota-table th strong {
  display: block;
  color: var(--ink);
  line-height: 1.2;
}

.rota-table th span {
  color: var(--muted);
  font-size: 10px;
  text-transform: uppercase;
}
.report-list { display: grid; gap: 8px; margin-top: 12px; }
.report-line { display: flex; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--line); padding: 8px 0; color: var(--muted); }
.report-line strong { color: var(--ink); }
.rich-report-line span {
  display: grid;
  gap: 3px;
}
.rich-report-line small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}
.report-table-wrap {
  margin-top: 14px;
}

.resource-list { margin-top: 12px; display: grid; gap: 8px; }
.resource-row { display: grid; grid-template-columns: 90px 1fr 80px; gap: 8px; padding: 9px; background: var(--soft); border-radius: 6px; }
.resource-row.wide-row { grid-template-columns: 1fr 1fr auto auto; }
.actions-cell {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  justify-content: flex-end;
  white-space: nowrap;
}
.editable-row {
  align-items: center;
}
.field-cloud { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.field-cloud span { background: var(--soft); border: 1px solid var(--line); border-radius: 999px; padding: 7px 10px; color: #34495e; }

.compact-form {
  display: grid;
  gap: 12px;
  margin-top: 12px;
}

.small-button {
  padding: 6px 8px;
  font-size: 12px;
}

.availability-on,
.availability-off {
  text-align: center;
  font-weight: 800;
  overflow: hidden;
  text-overflow: clip;
  cursor: pointer;
  user-select: none;
}

.availability-on:hover,
.availability-off:hover {
  outline: 2px solid rgba(20, 184, 166, .45);
  outline-offset: -2px;
}

.availability-on {
  background: #ecfdf5;
  color: #166534;
}

.availability-off {
  background: #fee2e2;
  color: #991b1b;
}

.deadline {
  border-radius: 999px;
  padding: 4px 8px;
  background: var(--soft);
  color: var(--ink);
  font-weight: 800;
}

.deadline.soon {
  background: #fff1d6;
  color: #8a4f00;
}

.deadline.overdue {
  background: #fee2e2;
  color: #991b1b;
}

.stacked-deadlines {
  display: grid;
  gap: 6px;
  white-space: normal;
}

.stacked-deadlines span {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
}

dialog {
  width: min(920px, calc(100vw - 30px));
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 24px 80px rgba(23,32,42,.28);
  padding: 0;
}

dialog::backdrop { background: rgba(20, 30, 40, .45); }
.dialog-head, .dialog-actions { display: flex; justify-content: space-between; align-items: center; padding: 16px; border-bottom: 1px solid var(--line); }
.dialog-head {
  background: var(--panel);
}
.dialog-head h2 {
  color: var(--ink);
  font-size: 19px;
  font-weight: 900;
}
.dialog-actions { border-top: 1px solid var(--line); border-bottom: 0; }
.icon-button { width: 34px; height: 34px; padding: 0; background: #eef3f7; color: var(--ink); border: 1px solid var(--line); }
body.dark .icon-button {
  background: #26384c;
  color: #f8fbff;
}
body.dark .dialog-head h2 {
  color: #f8fbff;
}

.form-grid {
  padding: 16px;
  display: grid;
  grid-template-columns: repeat(2, minmax(220px, 1fr));
  gap: 12px;
}

.details-grid {
  padding: 16px;
  display: grid;
  grid-template-columns: repeat(2, minmax(220px, 1fr));
  gap: 10px;
}

#jobDetailsBody {
  display: block;
}

.job-detail-section {
  padding: 12px 16px 4px;
}

.job-detail-section h3 {
  margin: 0 0 8px;
  color: var(--ink);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.job-detail-section .details-grid {
  padding: 0;
}

.detail-row {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  padding: 10px 12px;
  min-width: 0;
}

.detail-row span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .06em;
  margin-bottom: 4px;
  text-transform: uppercase;
}

.detail-row strong {
  display: block;
  color: var(--ink);
  font-size: 14px;
  overflow-wrap: anywhere;
}

.editable-detail input,
.editable-detail select,
.editable-detail textarea {
  width: 100%;
  min-width: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--ink);
  padding: 0;
  font-weight: 800;
}

.editable-detail input:focus,
.editable-detail select:focus,
.editable-detail textarea:focus {
  outline: 2px solid rgba(20, 184, 166, .35);
  background: rgba(20, 184, 166, .08);
  padding: 6px;
}

.editable-detail textarea {
  min-height: 58px;
}

.editable-detail small {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-weight: 800;
}

.wide-detail {
  grid-column: 1 / -1;
}

.clickable-row {
  cursor: pointer;
}

.clickable-row:hover td {
  background: rgba(20, 184, 166, .08);
}

label { display: grid; gap: 6px; font-weight: 700; color: var(--ink); }
input, select, textarea {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 10px;
  background: #fff;
}
textarea { min-height: 78px; resize: vertical; }
.wide-label { margin: 0 16px 16px; }

body.dark {
  color-scheme: dark;
}

body.dark input,
body.dark select,
body.dark textarea {
  background: #0f1b28;
  border-color: #38506a;
  color: #f8fbff;
}

body.dark input::placeholder,
body.dark textarea::placeholder {
  color: #7890a8;
}

body.dark select {
  color-scheme: dark;
}

body.dark select option {
  background: #0f1b28;
  color: #f8fbff;
}

body.dark select option:checked {
  background: #2563eb;
  color: #ffffff;
}

body.dark select option:disabled {
  color: #7d8fa3;
}

body.dark .detail-row {
  background: #162638;
  border-color: #34506b;
}

body.dark .overweight-badge {
  background: #5b1f1f;
  color: #fecaca;
}

body.dark .money-cell {
  color: #9fb3c8;
}

body.dark .detail-row span,
body.dark .editable-detail small {
  color: #b7c6d8;
}

body.dark .editable-detail input,
body.dark .editable-detail select,
body.dark .editable-detail textarea {
  background: #0f1b28;
  border: 1px solid #38506a;
  color: #f8fbff;
  padding: 8px 10px;
}

body.dark .editable-detail input:focus,
body.dark .editable-detail select:focus,
body.dark .editable-detail textarea:focus {
  background: #102334;
  border-color: var(--accent);
  outline: 2px solid rgba(20, 184, 166, .35);
}

body.dark .form-grid label,
body.dark .compact-form label,
body.dark .wide-label {
  color: #dbe7f3;
}

@media (max-width: 980px) {
  .topbar, .toolbar { align-items: flex-start; flex-direction: column; }
  .planner-layout { grid-template-columns: 1fr; }
  .queue { position: static; }
  .day-section { min-width: 760px; }
  .resource-columns { grid-auto-columns: 158px; }
  .metrics, .report-grid, .master-grid, .module-grid, .form-grid, .report-filters { grid-template-columns: 1fr; }
  .searchbox input { min-width: 0; width: 100%; }
}
