/* MANTIS Shipping Boards — Office UI (Mantis Asset / Command Design System) */
.office {
  --navy-950: #0B1830;
  --navy-900: #0F1F35;
  --navy-800: #1E3A5F;
  --navy-700: #2A5A8C;
  --hero-gradient: linear-gradient(155deg, #0B1830 0%, #1E3A5F 58%, #2A5A8C 100%);
  --amber-400: #FFBE3B;
  --amber-500: #F59E0B;
  --amber-gradient: linear-gradient(180deg, #FFBE3B 0%, #F59E0B 100%);
  --amber-ink: #1A1200;
  --amber-glow: 0 6px 18px rgba(245, 158, 11, 0.28);

  --board-bg: #F4F6FA;
  --sheet-bg: #F4F6FA;
  --surface: #FFFFFF;
  --surface-alt: #F8FAFC;
  --surface-soft: #E6EBF2;
  --surface-subtle: #ECEEF3;
  --ink: #0F1F35;
  --secondary: #516076;
  --muted: #6A7689;
  --rule: #E3E8EF;
  --rule-strong: #CBD5E1;
  --stripe: #1E3A5F;
  --today: #B45309;
  --dark-ink: #FFFFFF;
  --done-mark: #15803D;
  --done-bg: #DCFCE7;
  --event-bg: #FEF3C7;
  --event-ink: #B45309;
  --event-border: #FDE68A;
  --alert-bg: #FEE2E2;
  --alert-ink: #C0262D;
  --alert-strong: #991B1B;
  --alert-border: #FECACA;
  --info-bg: #DBEAFE;
  --info-ink: #1D5FD1;
  --action-pick-up: #1E3A5F;

  --office-line: #EDF0F5;
  --office-col-line: #F1F4F8;
  --office-focus: #1E3A5F;
  --office-hover: #EEF3F9;
  --office-heading: #F8FAFC;
  --office-even: #FAFCFF;
  --office-done: #F0FDF4;
  --office-draft: #F8FAFC;
  --office-readonly: #F8FAFC;
  --office-primary-hover: #F59E0B;

  --shadow-card: 0 1px 2px rgba(15, 31, 53, 0.05), 0 6px 18px rgba(15, 31, 53, 0.06);
  --shadow-popover: 0 12px 32px rgba(11, 24, 48, 0.16), 0 2px 6px rgba(11, 24, 48, 0.08);
  --shadow-sheet: 0 -8px 24px rgba(5, 12, 25, 0.14);

  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 18px;
  --radius-sheet: 26px;

  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", system-ui, sans-serif;
  --font-mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;

  --office-gutter: clamp(14px, 2.8vw, 28px);
  --office-left: max(var(--office-gutter), env(safe-area-inset-left));
  --office-right: max(var(--office-gutter), env(safe-area-inset-right));

  color-scheme: light;
  background: var(--sheet-bg);
  color: var(--ink);
  margin: 0;
  font: 15px/1.45 var(--font-sans);
  accent-color: var(--navy-800);
  -webkit-font-smoothing: antialiased;
}

.office *, .office *::before, .office *::after { box-sizing: border-box; }
.office [hidden] { display: none !important; }
.office :where(h1, h2, h3, p) { margin: 0; }
.office h1 { font-size: clamp(24px, 2.5vw, 30px); line-height: 1.15; font-weight: 800; letter-spacing: -0.025em; }
.office h2 { font-size: 17px; line-height: 1.25; font-weight: 800; letter-spacing: -0.015em; }
.office a { color: var(--navy-800); }

.office :where(button, input, select, textarea) {
  font: inherit;
  color: var(--ink);
  border: 1px solid var(--rule-strong);
  background: var(--surface);
  border-radius: var(--radius-sm);
  transition: background-color 140ms ease, border-color 140ms ease, box-shadow 140ms ease, transform 100ms ease;
}
.office :where(button, input:not([type="checkbox"]), select, textarea) { padding: 8px 12px; }
.office :where(button, summary, input[type="checkbox"]) { cursor: pointer; }
.office :where(button:hover, summary:hover) { background: var(--office-hover); }
.office :where(button:disabled, input:disabled) { opacity: .55; cursor: default; }
.office :where(a, button, input, select, textarea, summary):focus-visible {
  outline: 2px solid var(--office-focus);
  outline-offset: 2px;
}

/* Mantis Button Hierarchy */
.office .primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--amber-gradient);
  color: var(--amber-ink);
  border: 1px solid rgba(180, 83, 9, 0.16);
  border-radius: 999px;
  font-weight: 800;
  padding: 9px 18px;
  box-shadow: var(--amber-glow);
}
.office .primary:hover:not(:disabled) {
  background: linear-gradient(180deg, #FFC854 0%, #F59E0B 100%);
  box-shadow: 0 8px 20px rgba(245, 158, 11, 0.36);
}
.office .primary:active:not(:disabled) { transform: translateY(1px); }

.office .btn-navy {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  background: var(--navy-800);
  color: #FFFFFF;
  border: 1px solid var(--navy-800);
  border-radius: 999px;
  font-weight: 700;
  padding: 8px 16px;
}
.office .btn-navy:hover:not(:disabled) { background: var(--navy-700); border-color: var(--navy-700); }

.office .btn-soft {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  background: var(--surface-soft);
  color: var(--navy-800);
  border: 1px solid #D7DFE9;
  border-radius: 999px;
  font-weight: 700;
  padding: 8px 15px;
}
.office .btn-soft:hover:not(:disabled) { background: #DBE3EE; }

.btn-icon { width: 18px; height: 18px; flex: 0 0 18px; }

.office :where(a, button, input, select, textarea, summary) { min-width: 44px; min-height: 44px; }
.office :where(input, select, textarea) { max-width: 100%; font-size: 16px; }

/* Custom Checkboxes & Radios */
.office :is(input[type="checkbox"], input[type="radio"]) {
  appearance: none;
  flex: 0 0 44px;
  margin: 0;
  width: 44px;
  height: 44px;
  border: 0;
  background: no-repeat center / 22px 22px
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Crect x='1.5' y='1.5' width='21' height='21' rx='6' stroke='%2394A3B8' stroke-width='2' fill='white'/%3E%3C/svg%3E");
}
.office input[type="radio"] {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Ccircle cx='12' cy='12' r='10' stroke='%2394A3B8' stroke-width='2' fill='white'/%3E%3C/svg%3E");
}
.office :is(input[type="checkbox"], input[type="radio"]):checked {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Crect x='1' y='1' width='22' height='22' rx='6' fill='%231E3A5F'/%3E%3Cpath d='m6.5 12.2 3.8 3.8 7.5-8' stroke='white' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round' fill='none'/%3E%3C/svg%3E");
}
.office input[type="radio"]:checked {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Ccircle cx='12' cy='12' r='11' fill='%231E3A5F'/%3E%3Ccircle cx='12' cy='12' r='4.2' fill='white'/%3E%3C/svg%3E");
}

/* Mantis Brand Mark & Wordmark */
.brand-lockup {
  display: inline-flex;
  align-items: center;
  gap: 12px;
}
.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--amber-gradient);
  color: var(--navy-950);
  display: grid;
  place-items: center;
  box-shadow: 0 6px 18px rgba(245, 158, 11, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.35);
  flex: 0 0 auto;
}
.brand-mark svg { width: 22px; height: 22px; }
.brand-mark-lg {
  width: 72px;
  height: 72px;
  border-radius: 22px;
  box-shadow: 0 12px 28px rgba(245, 158, 11, 0.36), inset 0 1px 0 rgba(255, 255, 255, 0.4);
}
.brand-mark-lg svg { width: 40px; height: 40px; }
.brand-text { display: grid; gap: 1px; }
.wordmark {
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0.16em;
  color: #FFFFFF;
  line-height: 1.1;
}
.wordmark-lg {
  font-size: 20px;
  letter-spacing: 0.22em;
  margin-top: 12px;
}
.product {
  color: rgba(255, 255, 255, 0.78);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.2;
}

/* Command Navy Hero Header */
.office-bar {
  position: relative;
  overflow: hidden;
  background: var(--hero-gradient);
  color: #FFFFFF;
  padding: max(16px, env(safe-area-inset-top)) var(--office-right) 44px var(--office-left);
}
.hero-contours {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.office-bar-inner {
  position: relative;
  z-index: 1;
  max-width: 1460px;
  margin-inline: auto;
  display: grid;
  gap: 16px;
}
.office-bar-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}
.office-bar nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.office-bar nav a,
.office-bar nav button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 7px 16px;
  text-decoration: none;
  font-weight: 700;
  font-size: 14px;
  color: #FFFFFF;
  background: rgba(255, 255, 255, 0.13);
  border: 1px solid rgba(255, 255, 255, 0.18);
  backdrop-filter: blur(8px);
}
.office-bar nav a:hover,
.office-bar nav button:hover {
  background: rgba(255, 255, 255, 0.22);
}
.office-bar nav .screen-setup-button {
  color: #0B1830;
  background: #D9E7F7;
  border-color: #B3C9E4;
}
.office-bar nav .screen-setup-button:hover {
  background: #ECF5FF;
}
.office-bar nav a[aria-current="page"] {
  background: #FFFFFF;
  color: var(--navy-900);
  border-color: #FFFFFF;
  box-shadow: 0 2px 10px rgba(5, 12, 25, 0.18);
}
.office-bar nav a:focus-visible,
.office-bar nav button:focus-visible {
  outline: 2px solid var(--amber-400);
  outline-offset: 2px;
}

.office-hero-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  flex-wrap: wrap;
}
.office-hero-copy { display: grid; gap: 4px; }
.office-hero-copy h1 { color: #FFFFFF; }
.hero-subtitle {
  color: rgba(255, 255, 255, 0.78);
  font-size: 14px;
  font-weight: 500;
}

/* HeroStats Glass Pills */
.hero-stats {
  display: inline-flex;
  gap: 10px;
  flex-wrap: wrap;
}
.hero-stat {
  min-width: 78px;
  padding: 8px 14px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.11);
  border: 1px solid rgba(255, 255, 255, 0.16);
  display: grid;
  gap: 1px;
}
.hero-stat-value {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 20px;
  font-weight: 800;
  line-height: 1.1;
  color: #FFFFFF;
}
.hero-stat-ok .hero-stat-value { color: #86EFAC; }
.hero-stat-warn .hero-stat-value { color: var(--amber-400); }
.hero-stat-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.74);
}

/* Overlapping Light Sheet */
.schedule-main,
.import-main,
.settings-main {
  position: relative;
  z-index: 2;
  margin-top: -22px;
  border-radius: var(--radius-sheet) var(--radius-sheet) 0 0;
  background: var(--sheet-bg);
  box-shadow: var(--shadow-sheet);
  padding: 20px var(--office-right) max(36px, env(safe-area-inset-bottom)) var(--office-left);
  min-height: calc(100dvh - 150px);
}
.schedule-shell { max-width: 1460px; margin-inline: auto; }
.import-shell { max-width: 1120px; margin-inline: auto; }
.settings-shell { max-width: 1080px; margin-inline: auto; }

.card {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
}

/* Clock Warning Banner */
.office .schedule-clock {
  margin: 0 0 14px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  background: var(--event-bg);
  border: 1px solid var(--event-border);
  color: var(--event-ink);
  justify-content: flex-start;
  row-gap: 8px;
  font-size: 15px;
  font-weight: 700;
  text-align: left;
}
.office .schedule-clock button {
  background: var(--navy-800);
  color: #FFFFFF;
  border-color: var(--navy-800);
  border-radius: 999px;
}
.office .schedule-clock button:hover { background: var(--navy-700); }
.schedule-clock [role="alert"] { flex-basis: 100%; color: var(--alert-strong); }

/* Schedule Toolbar Card */
.sheet-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px 18px;
  padding: 12px 16px;
  margin-bottom: 18px;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  color: var(--secondary);
}
.sheet-toolbar form {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.sheet-toolbar label {
  padding-right: 2px;
  color: var(--ink);
  font-weight: 700;
  font-size: 14px;
}
.toolbar-hint { font-size: 13px; color: var(--muted); }
#schedule-status {
  margin-inline-start: auto;
  font-size: 13px;
  font-weight: 600;
  color: var(--secondary);
}
#schedule-status.field-error {
  padding: 5px 12px;
  border-radius: 999px;
  background: var(--alert-bg);
  color: var(--alert-strong);
}

/* Carryover Banner */
#carryover { margin-bottom: 18px; }
#carryover-title {
  margin: 0 0 10px;
  color: var(--event-ink);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 800;
}

/* Day Cards */
.day {
  margin-bottom: 18px;
  scroll-margin-top: 12px;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
}
.day-header {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 52px;
  padding: 8px 14px 8px 16px;
  border-bottom: 1px solid var(--rule);
  border-left: 4px solid var(--navy-800);
  border-radius: 17px 17px 0 0;
  background: var(--surface);
}
.day-today .day-header {
  border-left-color: var(--amber-500);
  background: linear-gradient(90deg, #FFFBEB 0%, #FFFFFF 45%);
}
.day-today h2 { color: var(--today); }
.day.day-empty:not(.day-today) {
  background: #FCFDFE;
  box-shadow: 0 1px 2px rgba(15, 31, 53, 0.03);
}
.day.day-empty:not(.day-today) .day-header {
  min-height: 46px;
  border-left-color: #CBD5E1;
  background: #FAFBFD;
}
.day.day-empty:not(.day-today) h2 { color: var(--secondary); font-weight: 700; }
.day-count {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--navy-800);
  font-size: 12px;
  font-weight: 700;
}
.day.day-empty:not(.day-today) .day-count {
  background: #F1F5F9;
  color: var(--muted);
}
.day-today .day-count {
  background: var(--event-bg);
  color: var(--event-ink);
}
.day-header .sheet-menu { margin-inline-start: auto; }
.day-header .sheet-menu summary {
  background: var(--surface-soft);
  color: var(--navy-800);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  font-weight: 700;
  font-size: 13px;
}
.day-header .sheet-menu summary:hover { background: #DBE3EE; }

/* Base Sheet Controls (shared across desktop, mobile cards, and add modal) */
.sheet {
  border-collapse: collapse;
  background: transparent;
  width: 100%;
  font-size: 14px;
}
.sheet th {
  background: var(--office-heading);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--secondary);
  text-align: left;
  line-height: 1.25;
  padding: 9px 10px;
  font-weight: 700;
}
.sheet th:first-child { padding-inline: 4px; text-align: center; }
.sheet td { padding: 0; vertical-align: top; min-width: 0; }

.sheet :is(input, select, textarea) {
  width: 100%;
  min-height: 44px;
  font-size: 16px;
  min-width: 0;
  margin: 0;
  padding: 8px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
}
.sheet :is(input:not([type="checkbox"]), select) {
  height: 44px;
  text-overflow: ellipsis;
}
.sheet textarea {
  height: auto;
  line-height: 1.38;
  resize: none;
  overflow: hidden;
  overflow-wrap: anywhere;
  field-sizing: content;
}
.sheet :is(input, textarea)::placeholder {
  color: #94A3B8;
  font-weight: 500;
}
.sheet tr:hover :is(input, textarea):not([readonly])::placeholder {
  color: #64748B;
}
.sheet :is([data-field="job"], [data-field="time"]) input {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 16px;
}
.sheet select { font-weight: 700; color: var(--navy-800); }
.sheet select:disabled { opacity: 1; cursor: default; }
.sheet select option { background: var(--surface); color: var(--ink); font-weight: 600; }
.sheet :is(input:not([type="checkbox"]), select, textarea):focus {
  background: #EFF6FF;
  outline: 2px solid var(--office-focus);
  outline-offset: -2px;
}
.sheet :is([data-field="done"], [data-field="show_note"]) { text-align: center; }
.sheet input[type="checkbox"] {
  flex: 0 0 44px;
  margin: 0 auto;
  padding: 0;
  width: 44px;
  height: 44px;
  accent-color: var(--navy-800);
  cursor: pointer;
}

/* Semantic Action Badges (Desktop <select> & Mobile .card-action) */
.day .sheet td[data-field="action"] select {
  appearance: none;
  padding: 0 28px 0 12px;
  border-radius: 10px;
  border: 1px solid #CBD5E1;
  background-color: #F8FAFC;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12' fill='none' stroke='%23334155' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m2.5 4.5 3.5 3.5 3.5-3.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 9px center;
  font-weight: 700;
  cursor: pointer;
}
.day .sheet td[data-field="action"] select:disabled {
  padding-right: 12px;
  background-image: none;
  cursor: default;
}
.day .sheet td[data-field="action"] select[data-action=""] {
  border-style: dashed;
  border-color: #CBD5E1;
  background-color: #F8FAFC;
  color: var(--muted);
  font-weight: 600;
}
.day .sheet td[data-field="action"] select[data-action="deliver"],
.card-action[data-action="deliver"] {
  background-color: #DCFCE7;
  border-color: #86EFAC;
  color: #166534;
}
.day .sheet td[data-field="action"] select[data-action="pick up"],
.card-action[data-action="pick up"] {
  background-color: #DBEAFE;
  border-color: #93C5FD;
  color: #1E3A8A;
}
.day .sheet td[data-field="action"] select[data-action="pick up/deliver"],
.day .sheet td[data-field="action"] select[data-action="deliver/pick up"],
.card-action[data-action="pick up/deliver"],
.card-action[data-action="deliver/pick up"] {
  background-color: #E0E7FF;
  border-color: #A5B4FC;
  color: #3730A3;
}
.day .sheet td[data-field="action"] select[data-action="load"],
.card-action[data-action="load"] {
  background-color: #FEF3C7;
  border-color: #FCD34D;
  color: #92400E;
}
.day .sheet td[data-field="action"] select[data-action="operate"],
.card-action[data-action="operate"] {
  background-color: #E2E8F0;
  border-color: #CBD5E1;
  color: #1E293B;
}
.card-action:not([hidden]) {
  display: inline-block;
  justify-self: start;
  padding: 2px 9px;
  margin: 2px 0;
  border-radius: 999px;
  border: 1px solid #CBD5E1;
  background-color: var(--info-bg);
  font-size: 13px;
  font-weight: 700;
}

/* Structured 2-Tier Desktop Dispatch Grid (>= 1000px) */
@media (width >= 1000px) {
  .day .sheet {
    --sheet-cols: 46px minmax(108px, 1.15fr) minmax(132px, 0.9fr) minmax(205px, 2.7fr) minmax(98px, 0.85fr) 106px minmax(112px, 1.5fr) 76px;
    display: block;
  }
  .day .sheet :is(thead, tbody) { display: block; }
  .day.day-empty:not(:focus-within) .sheet thead { display: none; }

  .day .sheet thead tr {
    display: grid;
    grid-template-columns: var(--sheet-cols);
    align-items: center;
    background: var(--office-heading);
    border-bottom: 1px solid var(--rule);
  }
  .day .sheet thead th[data-col="notes"] { grid-column: 6 / span 2; }

  .day .sheet tbody tr {
    display: grid;
    grid-template-columns: var(--sheet-cols);
    align-items: start;
    padding: 8px 0;
    border-bottom: 1px solid #E2E8F0;
    background: var(--surface);
    transition: background-color 120ms ease;
  }
  .day .sheet tbody tr:last-child {
    border-bottom: 0;
    border-radius: 0 0 17px 17px;
  }
  .day .sheet tbody tr:not(.is-draft):nth-child(even) { background: #FAFBFD; }
  .day .sheet tbody tr:not(.is-draft):hover { background: #F2F6FC; }

  .day .sheet tbody td { padding: 2px 4px; }
  .day .sheet tbody td[data-field="done"] { grid-column: 1; grid-row: 1 / span 2; padding-inline: 1px; }
  .day .sheet tbody td[data-field="driver"] { grid-column: 2; grid-row: 1 / span 2; }
  .day .sheet tbody td[data-field="action"] { grid-column: 3; grid-row: 1 / span 2; }
  .day .sheet tbody td[data-field="destination"] { grid-column: 4; grid-row: 1; }
  .day .sheet tbody td[data-field="address"] { grid-column: 4; grid-row: 2; }
  .day .sheet tbody td[data-field="job"] { grid-column: 5; grid-row: 1; }
  .day .sheet tbody td[data-field="time"] { grid-column: 5; grid-row: 2; }
  .day .sheet tbody td[data-field="notes"] { grid-column: 6 / span 2; grid-row: 1; }
  .day .sheet tbody td[data-field="show_note"] {
    grid-column: 6;
    grid-row: 2;
    display: flex;
    flex-direction: row-reverse;
    justify-content: flex-end;
    align-items: center;
    gap: 0;
    padding-inline: 2px;
    text-align: left;
  }
  .day .sheet tbody td[data-field="show_note"] input[type="checkbox"] { margin: 0; }
  .day .sheet tbody td[data-field="show_note"] .card-label {
    display: inline;
    font-size: 12px;
    font-weight: 600;
    color: var(--muted);
    cursor: pointer;
    white-space: nowrap;
    user-select: none;
  }
  .day .sheet tbody tr.has-note td[data-field="show_note"] .card-label,
  .day .sheet tbody td[data-field="show_note"].has-value .card-label {
    color: var(--navy-800);
    font-weight: 700;
  }
  .day .sheet tbody td[data-field="event"] { grid-column: 7; grid-row: 2; }
  .day .sheet tbody tr:not(.event-only):not(.is-anchor) td[data-field="event"].has-value {
    grid-column: 6 / span 2;
    grid-row: 3;
  }
  .day .sheet tbody td.row-tools {
    grid-column: 8;
    grid-row: 1 / span 2;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
    padding: 2px 6px 2px 2px;
  }

  /* Visual Hierarchy for Primary vs Secondary Fields */
  .day .sheet tbody td[data-field="destination"] input {
    font-weight: 700;
    color: var(--ink);
    letter-spacing: -0.01em;
  }
  .day .sheet tbody td[data-field="driver"] input {
    font-weight: 600;
  }
  .day .sheet tbody td[data-field="address"] textarea {
    color: #334155;
    padding-top: 4px;
  }
  .day .sheet tbody td[data-field="job"].has-value input {
    font-weight: 700;
    color: var(--navy-800);
    background: #F1F5F9;
  }
  .day .sheet tbody td[data-field="time"] input {
    color: #475569;
  }
  .day .sheet tbody td[data-field="event"].has-value input {
    background: var(--event-bg);
    border: 1px solid var(--event-border);
    color: var(--event-ink);
    font-weight: 700;
  }

  /* Subtle hover outline on editable fields */
  .day .sheet tbody tr:hover :is(input:not([type="checkbox"], [readonly]), textarea:not([readonly])):not(:focus) {
    box-shadow: inset 0 0 0 1px #DCE4EE;
  }

  /* Standalone Event-Only Rows (e.g. "6 trucks coming for the Amcor order") */
  .day .sheet tbody tr.event-only:not(:focus-within) {
    background: #FFFDF5;
  }
  .day .sheet tbody tr.event-only:not(:focus-within) td[data-field="event"] {
    grid-column: 4 / span 4;
    grid-row: 1;
  }
  .day .sheet tbody tr.event-only:not(:focus-within) :is(
    td[data-field="destination"],
    td[data-field="job"],
    td[data-field="address"],
    td[data-field="time"],
    td[data-field="notes"],
    td[data-field="show_note"]
  ) {
    display: none;
  }

  /* Sleek Single-Line Quick-Add Row (.is-anchor when untouched) */
  .day .sheet tbody tr.is-anchor:not(:focus-within):not(.draft-expanded) {
    padding: 4px 0;
    background: #F8FAFC;
    border-top: 1px dashed #CBD5E1;
  }
  .day.day-empty .sheet tbody tr.is-anchor:not(:focus-within):not(.draft-expanded) {
    border-top: 0;
  }
  .day .sheet tbody tr.is-anchor:not(:focus-within):not(.draft-expanded) :is(
    td[data-field="done"],
    td[data-field="driver"],
    td[data-field="action"],
    td[data-field="destination"],
    td[data-field="job"],
    td.row-tools
  ) {
    grid-row: 1;
  }
  .day .sheet tbody tr.is-anchor:not(:focus-within):not(.draft-expanded) td[data-field="event"] {
    grid-column: 6 / span 2;
    grid-row: 1;
  }
  .day .sheet tbody tr.is-anchor:not(:focus-within):not(.draft-expanded) :is(
    td[data-field="address"],
    td[data-field="time"],
    td[data-field="notes"],
    td[data-field="show_note"]
  ) {
    display: none;
  }
}

.sheet .is-done :is(input, select, textarea, .row-feedback) { color: var(--done-mark); }
.day .sheet tbody tr.is-done { background: var(--office-done) !important; }
.day .sheet tbody tr.is-draft:not(.is-anchor) {
  background: var(--office-draft);
  border-top: 1px dashed var(--rule-strong);
}
.sheet .is-anchor .row-feedback { color: var(--muted); }
.sheet [aria-invalid="true"] {
  box-shadow: inset 0 0 0 1.5px var(--alert-ink) !important;
  background: #FFF5F5 !important;
}

.sheet .row-tools { padding: 4px 6px; font-size: 11px; vertical-align: middle; }
.row-feedback { color: var(--muted); font-weight: 600; vertical-align: middle; text-align: right; }
.sheet .is-done .row-feedback { color: var(--done-mark); }
.row-menu { display: inline-block; vertical-align: middle; }
.cell-error, .field-error, .has-error .row-feedback { color: var(--alert-ink); font-weight: 600; }
.cell-error {
  display: block;
  padding: 4px 8px 5px;
  border-radius: 6px;
  background: var(--alert-bg);
  font-size: 11px;
  overflow-wrap: anywhere;
}
.row-tools .retry {
  display: block;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  margin-top: 4px;
  border-radius: 6px;
  background: var(--alert-bg);
  color: var(--alert-strong);
  border-color: var(--alert-border);
}

.day .sheet td.conflict-cell {
  grid-column: 1 / -1;
  display: block;
  padding: 4px 8px;
}
.row-conflict {
  padding: 8px 10px;
  border: 1px solid var(--alert-border);
  border-radius: 8px;
  background: var(--alert-bg);
  color: var(--alert-ink);
  font-size: 14px;
  overflow-wrap: anywhere;
  scroll-margin-block: 12px 84px;
}
.conflict-field { display: block; margin-top: 4px; }
.conflict-values dl {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 2px 8px;
  margin: 2px 0 6px;
}
.conflict-values dd { margin: 0; white-space: pre-wrap; }
.conflict-choices { display: flex; flex-wrap: wrap; gap: 6px; }

/* Workbook & Classify Badges */
.workbook-tag {
  display: inline-block;
  margin: 0 6px 4px;
  padding: 2px 7px;
  border-radius: 6px;
  background: var(--info-bg);
  color: var(--info-ink);
  font-size: 11px;
  font-weight: 700;
}
tr[data-entry] :is(input, textarea)[readonly] {
  cursor: default;
  color: var(--ink);
}
tr[data-entry] :is(input, textarea)[readonly]::placeholder {
  color: transparent;
}

/* Menus & Floating Popovers */
.sheet-menu { position: relative; }
.sheet-menu summary {
  list-style: none;
  width: fit-content;
  align-content: center;
  padding: 4px 8px;
  border-radius: 8px;
  font-size: 12px;
}
.sheet-menu summary::-webkit-details-marker { display: none; }
.sheet-menu summary::after { content: " ▾"; }
.row-menu summary {
  font-weight: 700;
  text-align: center;
  padding: 0 6px;
  font-size: 17px;
  color: var(--secondary);
  border-radius: 8px;
}
.row-menu summary::after { content: none; }
.sheet-menu .menu-items {
  position: absolute;
  z-index: 20;
  right: 0;
  top: calc(100% + 4px);
  min-width: 175px;
  max-width: min(320px, 38vw);
  width: max-content;
  padding: 6px;
  border: 1px solid var(--rule);
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: var(--shadow-popover);
}
.sheet-menu .menu-items :is(a, button) {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 8px 10px;
  background: transparent;
  border: 0;
  border-radius: 9px;
  font: 600 13px/1.3 var(--font-sans);
  color: var(--ink);
  text-align: left;
  text-decoration: none;
  overflow-wrap: anywhere;
}
.sheet-menu .menu-items :is(a, button):hover { background: var(--office-hover); }
.classify-menu { margin: 0 6px 5px; }
.classify-menu summary {
  color: var(--event-ink);
  background: var(--event-bg);
  border: 1px solid var(--event-border);
  font-size: 11px;
  font-weight: 700;
  border-radius: 7px;
}
.classify-menu .menu-items { right: auto; left: 0; }
.sheet .classify-menu { max-width: calc(100% - 12px); }
.sheet .classify-menu summary { max-width: 100%; overflow-wrap: anywhere; }
.sheet-menu[open] > summary { background: var(--surface-soft); }

/* Dialogs / Modals */
.office dialog {
  width: min(540px, calc(100% - var(--office-left) - var(--office-right)));
  max-width: none;
  max-height: calc(var(--visible-height, 100dvh) - env(safe-area-inset-top) - env(safe-area-inset-bottom) - 24px);
  overflow: auto;
  overscroll-behavior: contain;
  border: 1px solid var(--rule);
  border-radius: 22px;
  padding: 20px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 24px 60px rgba(11, 24, 48, 0.28);
}
.office dialog::backdrop {
  background: rgba(11, 24, 48, 0.56);
  backdrop-filter: blur(4px);
}
.office dialog form { display: grid; gap: 12px; }
.dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--rule);
}
.dialog-header h2 { font-size: 20px; }
.add-date-row { display: grid; gap: 5px; }
.field-label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--secondary);
}
.button-row { display: flex; flex-wrap: wrap; justify-content: end; gap: 8px; margin-top: 6px; }
.move-choices { justify-content: start; }
.move-choices button { border-radius: 999px; background: var(--surface-soft); color: var(--navy-800); border-color: #D7DFE9; font-weight: 700; }

/* Login / AuthLayout */
.login-page {
  min-height: 100dvh;
  background: #0B1830 radial-gradient(circle at top center, #1E3A5F 0%, #0B1830 70%);
  display: grid;
  place-items: center;
  padding: max(16px, env(safe-area-inset-top)) var(--office-right)
    max(16px, env(safe-area-inset-bottom)) var(--office-left);
}
.login-main { width: min(100%, 420px); }
.auth-card {
  width: 100%;
  border-radius: 28px;
  overflow: hidden;
  background: var(--sheet-bg);
  box-shadow: 0 26px 64px rgba(5, 12, 25, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.12);
}
.auth-hero {
  position: relative;
  overflow: hidden;
  background: var(--hero-gradient);
  padding: 34px 24px 56px;
  text-align: center;
  color: #FFFFFF;
}
.auth-brand {
  position: relative;
  z-index: 1;
  display: grid;
  justify-items: center;
}
.auth-tagline {
  margin-top: 4px;
  color: rgba(255, 255, 255, 0.78);
  font-size: 13px;
  font-weight: 600;
}
.auth-sheet {
  position: relative;
  z-index: 2;
  margin-top: -28px;
  border-radius: 28px 28px 0 0;
  background: var(--surface);
  padding: 26px 24px 28px;
  box-shadow: 0 -8px 24px rgba(5, 12, 25, 0.16);
  display: grid;
  gap: 16px;
}
.auth-sheet-header { display: grid; gap: 4px; }
.auth-sheet-header h1 { font-size: 26px; color: var(--ink); }
.auth-subtitle { color: var(--secondary); font-size: 14px; }
.auth-form { display: grid; gap: 10px; }
.auth-form input {
  height: 54px;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--rule-strong);
  background: var(--surface-alt);
  font-family: var(--font-mono);
  font-size: 24px;
  font-weight: 700;
  letter-spacing: 0.25em;
  text-align: center;
}
.auth-form input:focus {
  background: var(--surface);
  border-color: var(--navy-800);
  box-shadow: 0 0 0 3px rgba(30, 58, 95, 0.14);
  outline: none;
}
.auth-submit { height: 52px; font-size: 16px; margin-top: 4px; width: 100%; }
#login-status:not(:empty) {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
  color: var(--navy-800);
  font-size: 14px;
  font-weight: 600;
}
#login-status.field-error:not(:empty) {
  background: var(--alert-bg);
  color: var(--alert-strong);
  border: 1px solid var(--alert-border);
}
#pin-help:not([hidden]) {
  padding: 12px 14px;
  border-radius: var(--radius-md);
  background: var(--event-bg);
  border: 1px solid var(--event-border);
  color: var(--event-ink);
  font-size: 14px;
  font-weight: 600;
}

/* Settings Page */
.settings-main > .settings-shell > [role="status"]:not(:empty) { margin-bottom: 12px; }
.settings-grid {
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
  gap: 16px;
  align-items: start;
}
.settings-panel {
  padding: 20px;
}
.settings-panel h2 { margin-bottom: 10px; font-size: 18px; color: var(--ink); }
.settings-panel p { color: var(--secondary); font-size: 13px; }
.settings-panel .field-error { color: var(--alert-ink); }
.settings-panel p:not(:empty) { margin-top: 6px; }
.settings-list {
  display: grid;
  border: 1px solid var(--rule);
  border-radius: var(--radius-md);
  background: var(--surface-alt);
  overflow: hidden;
  margin-bottom: 12px;
}
.settings-people { width: 100%; border-collapse: collapse; margin: 10px 0 12px; }
.settings-people th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--secondary);
  border-bottom: 1px solid var(--rule);
  padding: 8px 6px;
}
.settings-people td { padding: 6px 4px; border-bottom: 1px solid var(--office-line); }
.settings-people :is(input[type="text"], select), .settings-panel textarea { width: 100%; }
.settings-people td:nth-child(3) { text-align: center; }
.settings-panel textarea { display: block; resize: vertical; margin-top: 6px; background: var(--surface-alt); }
.board-settings-panel { grid-column: 1 / -1; }
#boards-handover a {
  display: inline-flex;
  align-items: center;
  color: inherit;
  font-weight: 700;
}
.check {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  margin: 0;
  border-bottom: 1px solid var(--rule);
  font-weight: 600;
}
.check:last-child { border-bottom: 0; }
.horizon { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; font-weight: 600; }
.horizon input { width: 88px; text-align: center; font-family: var(--font-mono); }
.settings-save { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.settings-save [role="status"]:not(:empty) {
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--done-bg);
  color: var(--done-mark);
  font-weight: 700;
  font-size: 13px;
}
.settings-save [role="status"].field-error:not(:empty) {
  background: var(--alert-bg);
  color: var(--alert-strong);
}
.pin-settings { margin-top: 16px; }
.pin-fields { display: flex; gap: 12px; align-items: end; flex-wrap: wrap; }
.pin-fields label { display: grid; gap: 5px; font-size: 13px; font-weight: 700; color: var(--secondary); }
.pin-fields input { width: 170px; font-family: var(--font-mono); }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.settings-people :is(input[type="text"], select) { min-width: 0; }
.settings-people td:last-child { width: 1%; }
.office :is(input[type="checkbox"], input[type="radio"]):focus-visible { outline-offset: -2px; }
.field-error { overflow-wrap: anywhere; }

/* Import Page */
.import-main { overflow-wrap: anywhere; }
.import-main .card {
  padding: clamp(16px, 3vw, 24px);
  margin-bottom: 16px;
}
.import-main h2 { font-size: 20px; }
.import-main h3 { font-size: 15px; margin: 12px 0 6px; font-weight: 800; }
.import-main p:not(:empty) { margin-block: 6px; }
.import-main ul { padding-inline-start: 1.35em; }
.import-main li { margin-block: 6px; }
.import-hint { color: var(--secondary); font-size: 13px; font-weight: 500; }
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--rule);
}
.sources { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.source-field {
  min-width: 0;
  display: grid;
  align-content: start;
  gap: 8px;
  font-weight: 700;
  padding: 14px;
  border-radius: var(--radius-md);
  background: var(--surface-alt);
  border: 1px solid var(--rule);
}
.source-heading {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
}
.sources :is(textarea, input) { width: 100%; min-width: 0; background: var(--surface); }
.sources textarea { min-height: 112px; resize: vertical; }
.sources input[type="file"] { padding: 4px; background: var(--surface); }
.sources input::file-selector-button {
  min-height: 36px;
  padding: 0 12px;
  border: 0;
  border-radius: 8px;
  margin-inline-end: 10px;
  background: var(--surface-soft);
  color: var(--navy-800);
  font-weight: 700;
  font: inherit;
  cursor: pointer;
}
.import-actions { margin-top: 14px; display: flex; flex-wrap: wrap; gap: 10px; }

/* Metric Tiles in Import Preview */
#counts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(8.5rem, 1fr));
  gap: 10px;
  margin: 14px 0;
}
#counts div {
  background: var(--surface-alt);
  border: 1px solid var(--rule);
  border-radius: var(--radius-md);
  padding: 10px 14px;
}
#counts dt {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--secondary);
}
#counts dd {
  margin: 4px 0 0;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 24px;
  font-weight: 800;
  color: var(--ink);
}
.import-main :is(.warning, #error) {
  padding: 12px 14px;
  border-radius: var(--radius-md);
  background: var(--alert-bg);
  color: var(--alert-strong);
  border: 1px solid var(--alert-border);
  border-inline-start: 4px solid var(--alert-ink);
  font-weight: 600;
}
#warnings:not([hidden]) {
  padding: 12px 14px;
  border-radius: var(--radius-md);
  background: var(--event-bg);
  border: 1px solid var(--event-border);
  color: var(--event-ink);
  margin-block: 10px;
}
#changes { margin-top: 12px; border: 1px solid var(--rule); border-radius: var(--radius-md); overflow: hidden; }
#changes details { border-bottom: 1px solid var(--rule); background: var(--surface); }
#changes details:last-child { border-bottom: 0; }
#changes summary {
  min-height: 46px;
  align-content: center;
  padding: 10px 14px;
  cursor: pointer;
  font-weight: 700;
  background: var(--surface-alt);
}
#changes details[open] > summary {
  position: sticky;
  inset-block-start: env(safe-area-inset-top, 0px);
  z-index: 1;
  border-bottom: 1px solid var(--rule);
}
#changes li { overflow-wrap: anywhere; }

/* Add Stop Dialog Sheet */
.add-sheet, .add-sheet :is(tbody, tr, td) { display: block; }
.add-sheet :is(colgroup, thead, .card-summary, .card-note, .row-menu, .retry) { display: none; }
.add-sheet, .add-sheet td { border: 0; }
.add-sheet .card-label { display: block; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--secondary); margin-bottom: 4px; }
.add-sheet td { margin-bottom: 10px; }
.add-sheet :is(input:not([type="checkbox"]), select, textarea) {
  display: block;
  background: var(--surface-alt);
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius-sm);
}
.add-sheet :is([data-field="done"], [data-field="show_note"]) { text-align: start; }
.add-sheet :is([data-field="done"], [data-field="show_note"]) .card-label { display: inline-block; text-transform: none; letter-spacing: 0; font-size: 14px; color: var(--ink); }
.add-sheet .row-tools { padding: 0; font-size: 14px; }
.add-sheet tr:not(.has-error) .row-feedback { display: none; }
.add-sheet .is-draft td { background: transparent; border-top: 0; }
.add-sheet td[data-field="event"], .adding-event #add-more,
.adding-event .add-sheet td[data-field]:not([data-field="event"]),
#add-form:not(.adding-event, .add-more) td[data-field]:not([data-field="driver"], [data-field="action"], [data-field="destination"]) { display: none; }
.adding-event .add-sheet td[data-field="event"] { display: block; }
#add-more { justify-self: start; }

/* Labels hidden on desktop, used on mobile cards & add-sheet */
.card-label, .card-summary, .card-note, .card-workbook, .day-toggle,
#carryover-toggle, .schedule-actions { display: none; }

/* Mobile & Tablet Card Layout (< 1000px) */
@media (width < 1000px) {
  .sheet-keyboard-hint, .office-bar nav a[href="/import"], .office-bar nav a[href="/settings"],
  .carryover-label, .day-label, .office-hero-row { display: none; }
  .office-bar { padding-bottom: 32px; }
  .sheet-toolbar { padding: 10px 12px; gap: 8px; font-size: 14px; margin-bottom: 12px; }
  #schedule-status { margin: 0; }
  #schedule-status:empty { display: none; }
  .schedule-main { padding-bottom: calc(128px + env(safe-area-inset-bottom)); }
  .schedule-actions {
    position: fixed;
    z-index: 30;
    inset: auto 0 0;
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    align-items: stretch;
    gap: 6px;
    padding: 8px var(--office-right) calc(8px + env(safe-area-inset-bottom)) var(--office-left);
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(12px);
    border-top: 1px solid var(--rule);
    box-shadow: 0 -6px 20px rgba(15, 31, 53, 0.08);
  }
  .schedule-actions :is(a, button) {
    font-size: 13px;
    text-align: center;
    padding-inline: 8px;
  }
  .schedule-actions button { grid-column: span 3; }
  .schedule-actions a {
    grid-column: span 2;
    display: grid;
    place-items: center;
    background: var(--surface-soft);
    color: var(--navy-800);
    border: 1px solid #D7DFE9;
    border-radius: 999px;
    font-weight: 700;
    text-decoration: none;
  }
  .schedule-actions #add-stop { white-space: nowrap; }
  .office.keyboard-open .schedule-actions { visibility: hidden; }
  .settings-grid { grid-template-columns: minmax(0, 1fr); }

  .day {
    margin-bottom: 10px;
    border-radius: 16px;
  }
  .day-header {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    gap: 6px;
    padding: 4px 8px;
    border-bottom: 0;
    border-radius: 15px;
  }
  .day-open .day-header {
    border-bottom: 1px solid var(--rule);
    border-radius: 15px 15px 0 0;
  }
  .day-toggle, #carryover-toggle {
    display: flex;
    align-items: center;
    width: 100%;
    padding: 6px 8px;
    gap: 6px;
    background: transparent;
    border: 0;
    text-align: start;
    font-weight: 800;
    color: var(--ink);
  }
  .day-today .day-toggle { color: var(--today); }
  #carryover-toggle {
    background: var(--event-bg);
    color: var(--event-ink);
    border: 1px solid var(--event-border);
    border-radius: 14px;
    padding: 8px 12px;
  }
  :is(.day-toggle, #carryover-toggle)::before { content: "▸"; }
  :is(.day-toggle, #carryover-toggle)[aria-expanded="true"]::before { content: "▾"; }
  .day-count { font-size: 12px; text-align: end; }
  #carryover:not(.carryover-open) #carryover-days,
  .day:not(.day-open) .sheet, .day:not(.day-open) .day-header .sheet-menu { display: none; }
  #carryover, #carryover-title { margin: 0 0 10px; }

  .day .sheet, .day .sheet tbody { display: block; }
  .day .sheet { background: transparent; padding: 8px 10px; }
  .day .sheet :is(colgroup, thead, .is-anchor) { display: none; }
  .day .sheet tr:not(.is-anchor) {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 2px 10px;
    margin: 8px 0;
    padding: 12px 14px;
    background: var(--surface);
    border: 1px solid var(--rule);
    border-radius: 16px;
    box-shadow: 0 2px 8px rgba(15, 31, 53, 0.04);
    overflow-wrap: anywhere;
  }
  .day .sheet tr.is-done { background: var(--office-done); border-color: #BBF7D0; }
  .day .sheet td { display: none; min-width: 0; border: 0; background: transparent !important; }
  .day .sheet :is([data-field="destination"], [data-field="done"], .row-tools),
  .day .sheet .has-note :is([data-field="notes"], [data-field="show_note"]),
  .day .sheet .card-open td { display: block; }
  .day .sheet [data-field="destination"] { grid-area: 1 / 1; }
  .day .sheet [data-field="done"] { grid-area: 1 / 2; align-self: start; }
  .day .sheet [data-field="notes"] { grid-column: 1 / -1; }
  .day .sheet [data-field="show_note"] { grid-column: 1 / -1; }
  .day .sheet .row-tools { grid-column: 1 / -1; }
  .day .sheet :is([data-field="done"], [data-field="show_note"]) .card-label { display: block; font-size: 12px; font-weight: 700; color: var(--secondary); }
  .day .sheet [data-field="show_note"] { text-align: start; }
  .day .sheet :is(.has-note, .card-open) [data-field="show_note"] {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
  }
  .day .sheet [data-field="show_note"] input { margin: 0; }
  .day .sheet [data-field="show_note"] .cell-error { flex-basis: 100%; }
  .day .sheet [data-field="show_note"] .card-label { display: inline-block; }
  .day .sheet .event-only:not(.card-open) [data-field="done"] { display: none; }
  .day .sheet .card-open td:not([data-field="destination"], [data-field="done"]) { grid-column: 1 / -1; }
  .day .sheet .card-open td:not([data-field="done"], [data-field="show_note"]) .card-label {
    display: block;
    margin-top: 10px;
    margin-bottom: 4px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--secondary);
  }
  .day .sheet .card-open [data-field="driver"] { grid-row: 2; }
  .day .sheet .card-open [data-field="action"] { grid-row: 3; }
  .day .sheet .card-open :is(input:not([type="checkbox"]), select, textarea) {
    display: block;
    border: 1px solid var(--rule-strong);
    border-radius: var(--radius-sm);
    background: var(--surface-alt);
    font-size: 16px;
  }
  .day .sheet :is([data-field="destination"], [data-field="notes"]) :is(input:not([type="checkbox"]), textarea) { display: none; }
  .day .sheet .card-open :is([data-field="destination"], [data-field="notes"]) :is(input:not([type="checkbox"]), textarea) { display: block; }

  .day .card-summary {
    display: grid;
    scroll-margin-top: 10px;
    width: 100%;
    min-width: 44px;
    padding: 2px 0;
    gap: 2px;
    text-align: start;
    background: transparent;
    border: 0;
    overflow-wrap: anywhere;
    -webkit-tap-highlight-color: transparent;
  }
  .day .card-summary:active { background: var(--office-hover); border-radius: 10px; }
  .card-destination { font-size: 19px; line-height: 1.2; font-weight: 800; color: var(--ink); }
  .card-action { font-size: 15px; font-weight: 700; color: var(--info-ink); }
  .card-driver { font-size: 15px; font-weight: 600; color: var(--ink); }
  .card-job-time, .card-source { font-size: 13px; color: var(--secondary); }
  .card-job-time { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
  .card-note {
    display: block;
    margin-top: 6px;
    padding: 6px 10px;
    border-radius: 8px;
    background: var(--surface-alt);
    border-left: 3px solid var(--navy-700);
    font-size: 14px;
    color: var(--ink);
  }
  .card-open .card-note { display: none; }
  .card-open .card-workbook { display: block; padding-top: 6px; font-size: 13px; color: var(--info-ink); font-weight: 600; }
  .day .sheet .row-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 4px 0 0; font-size: 13px; }
  .day .sheet .card-open .row-tools { display: flex; }
  .day .sheet tr:not(.card-open, .has-error) .row-feedback { display: none; }
  .day .sheet tr:not(.card-open) .row-menu { display: none; }
  .day .sheet .row-menu[open], .day .sheet .classify-menu[open] { width: 100%; }
  .day .sheet :is(.row-menu, .classify-menu) .menu-items {
    position: static;
    max-width: none;
    width: 100%;
    box-shadow: none;
    margin-top: 6px;
  }
  .day .sheet .classify-menu { margin: 4px 0 0; }
  .day .sheet .row-menu summary { font-size: 0; background: var(--surface-soft); padding: 6px 12px; color: var(--navy-800); }
  .day .sheet .row-menu summary::after { content: attr(data-card-label) " ▾"; font-size: 14px; }
  .sheet-menu .menu-items { max-width: min(18rem, 75vw); }
}

@media (width < 740px) {
  .sources { grid-template-columns: minmax(0, 1fr); }
  #counts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .import-main :is(#preview-button, #apply, #undo) { width: 100%; }
}

@media (width < 600px) {
  .settings-people :is(thead, .sr-only) { display: none; }
  .settings-people, .settings-people tbody { display: block; }
  .settings-people tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    border-top: 1px solid var(--rule);
    padding-block: 8px;
  }
  .settings-people td { border-bottom: 0; }
  .settings-people td:nth-child(-n+2) { grid-column: 1 / -1; }
  .settings-people td:nth-child(3) { text-align: start; }
  .settings-people td:last-child { width: auto; }
}

.keyboard-feedback {
  position: fixed;
  z-index: 40;
  inset: auto var(--office-right) var(--keyboard-bottom, 0px) var(--office-left);
  padding: 10px 14px;
  border: 1px solid var(--rule);
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: var(--shadow-popover);
  color: var(--ink);
  font-size: 14px;
  overflow-wrap: anywhere;
  pointer-events: none;
}
.keyboard-open dialog {
  position: fixed;
  inset: auto 0 calc(var(--keyboard-bottom, 0px) + 8px);
  margin: 0 auto;
  padding-bottom: 54px;
}
.person-active { display: inline-flex; align-items: center; gap: 4px; }
.person-active span { display: none; }
@media (width < 600px) {
  .person-active span { display: inline; }
}

@media (width < 480px) {
  .schedule-page .office-bar nav .screen-setup-button { display: none; }
  .day-header { grid-template-columns: minmax(0, 1fr) auto; }
  .day-header h2 { grid-column: 1 / -1; }
  .day-count { justify-self: start; text-align: start; }

  .sheet-toolbar form { gap: 6px; width: 100%; }
  .sheet-toolbar button { font-size: 14px; }
  #jump-date { flex: 1 1 135px; min-width: 0; max-width: 150px; }
  .sheet-toolbar label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
  }
}

@media (1000px <= width < 1366px) {
  .col-driver { width: 10%; }
  .col-address { width: 9%; }
  .col-notes { width: 10%; }
  .col-menu { width: 84px; }
}

@media (width < 1000px) and (height < 500px) {
  #counts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .office-bar { padding-block-start: max(6px, env(safe-area-inset-top)); padding-block-end: 26px; }
}

.sheet textarea { resize: none; }
:is(.add-sheet, .card-open) textarea { height: auto; min-height: 76px; resize: vertical; }
#details-fields { display: grid; gap: 4px 14px; margin: 0; }
#details-fields dt { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--secondary); }
#details-fields dd { margin: 0 0 10px; white-space: pre-wrap; overflow-wrap: anywhere; font-weight: 500; }
