:root {
  color-scheme: light;
  --ink: #18222f;
  --muted: #617084;
  --line: #d8e0e7;
  --panel: #ffffff;
  --page: #f4f7f8;
  --brand: #245f73;
  --brand-strong: #17485a;
  --amber: #b56b11;
  --amber-bg: #fff2d7;
  --green: #197348;
  --green-bg: #dff7e9;
  --grey-bg: #eef1f4;
  --blue: #275dba;
  --red: #a63232;
  --red-bg: #ffe3e3;
  --radius: 8px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
}

button,
input,
select {
  font: inherit;
}

button,
a.primary-button,
a.admin-link,
.secondary-button,
.primary-button {
  min-height: 48px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  cursor: pointer;
  text-decoration: none;
}

.topbar,
.admin-topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 18px 24px;
  background: #ffffff;
  border-bottom: 1px solid var(--line);
}

.topbar h1,
.admin-topbar h1 {
  margin: 2px 0 0;
  font-size: 30px;
  line-height: 1.1;
}

.brand-block {
  display: grid;
  gap: 6px;
  flex: 0 0 auto;
}

.topbar-identity {
  display: flex;
  align-items: center;
  gap: clamp(24px, 4vw, 64px);
  flex: 1 1 auto;
  min-width: 0;
}

.brand-logo {
  display: block;
  max-width: 220px;
  max-height: 78px;
  object-fit: contain;
}

.eyebrow {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.topbar-actions,
.form-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.eta-countdown {
  display: grid;
  gap: 6px;
  min-width: 360px;
  padding: 15px 20px;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  background: #f8fafb;
  text-align: center;
}

.eta-countdown span {
  color: var(--muted);
  font-size: 15px;
  font-weight: 900;
  text-transform: uppercase;
}

.eta-countdown strong {
  color: var(--brand-strong);
  font-size: 38px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.topbar .date-input {
  width: 210px;
  cursor: pointer;
  font-weight: 800;
}

.primary-button,
a.primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 18px;
  background: var(--brand);
  color: #ffffff;
  border-color: var(--brand);
  font-weight: 800;
}

.secondary-button,
.admin-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 16px;
  background: #ffffff;
  color: var(--brand-strong);
  border: 1px solid var(--line);
  font-weight: 800;
}

.sound-toggle {
  min-width: 126px;
}

.sound-toggle.enabled {
  background: var(--green-bg);
  color: #135736;
  border-color: #97d5b2;
}

.icon-button {
  width: 52px;
  background: #ffffff;
  color: var(--ink);
  font-size: 22px;
  font-weight: 900;
}

.date-input,
.search-box input,
.select-box select,
.settings-panel input,
.settings-panel select,
.settings-panel textarea {
  min-height: 48px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0 12px;
  background: #ffffff;
  color: var(--ink);
}

.settings-panel textarea {
  min-height: 170px;
  padding: 12px;
  resize: vertical;
}

.logo-upload {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.logo-upload input {
  min-height: 48px;
}

main {
  padding: 18px 24px 40px;
}

.status-strip {
  display: grid;
  grid-template-columns: repeat(5, minmax(130px, 1fr));
  gap: 12px;
}

.stat-block {
  min-height: 92px;
  padding: 14px;
  border: 1px solid var(--line);
  border-left: 8px solid var(--muted);
  border-radius: var(--radius);
  background: var(--panel);
}

.stat-block span {
  display: block;
  color: var(--muted);
  font-weight: 800;
}

.stat-block strong {
  display: block;
  margin-top: 6px;
  font-size: 34px;
}

.stat-block.amber {
  border-left-color: var(--amber);
}

.stat-block.green {
  border-left-color: var(--green);
}

.stat-block.blue {
  border-left-color: var(--blue);
}

.controls-band {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  margin: 18px 0 12px;
}

.tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.tabs button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 118px;
  padding: 0 16px;
  background: #ffffff;
  color: var(--ink);
  font-weight: 900;
}

.tabs button.active {
  background: var(--ink);
  color: #ffffff;
}

.tabs button.backorder-tab {
  border-color: #e3b4b4;
}

.tabs button.tomorrow-tab {
  min-width: 230px;
  border-color: #a8c5cf;
}

.tab-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 30px;
  min-height: 30px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--red);
  color: #ffffff;
  font-size: 14px;
  line-height: 1;
}

.tab-badge.tomorrow-badge {
  background: var(--brand);
}

.filters {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  min-width: min(620px, 100%);
}

.search-box {
  flex: 1;
}

.search-box span,
.select-box span,
.settings-panel label span {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.category-summary {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  min-height: 30px;
  margin-bottom: 12px;
}

.category-summary span {
  padding: 7px 10px;
  border-radius: var(--radius);
  background: #e7edf1;
  color: var(--ink);
  font-weight: 800;
}

.orders-grid {
  display: grid;
  gap: 18px;
}

.status-section {
  display: grid;
  gap: 10px;
}

.status-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-left: 8px solid #7a8795;
  border-radius: var(--radius);
  background: #ffffff;
}

.status-section-in_progress .status-section-head {
  border-left-color: var(--amber);
}

.status-section-complete .status-section-head {
  border-left-color: var(--green);
}

.status-section-backorder .status-section-head {
  border-left-color: var(--red);
}

.status-section-head h2 {
  margin: 0;
  font-size: 22px;
}

.status-section-head span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 42px;
  min-height: 34px;
  border-radius: 999px;
  background: #edf2f5;
  font-weight: 900;
}

.orders-grid-inner {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
  gap: 14px;
}

.order-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-top: 8px solid #7a8795;
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: 0 10px 24px rgba(24, 34, 47, 0.06);
}

.order-card.status-in_progress {
  border-top-color: var(--amber);
}

.order-card.status-complete {
  border-top-color: var(--green);
}

.order-card.status-backorder {
  border-top-color: var(--red);
}

.order-main {
  display: block;
  width: 100%;
  min-height: 172px;
  padding: 16px;
  border: 0;
  border-radius: 0;
  background: transparent;
  text-align: left;
}

.order-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.status-pill {
  padding: 7px 10px;
  border-radius: 999px;
  background: var(--grey-bg);
  color: var(--ink);
  font-size: 13px;
  font-weight: 900;
}

.status-in_progress .status-pill {
  background: var(--amber-bg);
  color: #6f420a;
}

.status-complete .status-pill {
  background: var(--green-bg);
  color: #135736;
}

.status-backorder .status-pill {
  background: var(--red-bg);
  color: #7d2020;
}

.order-number {
  color: var(--muted);
  font-weight: 900;
}

.order-balance {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 12px 0 -4px;
}

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

.customer-name {
  margin: 16px 0;
  font-size: 26px;
  line-height: 1.12;
  overflow-wrap: anywhere;
}

.order-dates,
.delivery-method-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 0;
}

.delivery-method-row {
  grid-template-columns: 1fr;
  margin-top: 8px;
}

.order-dates div,
.delivery-method-row div {
  min-height: 58px;
  padding: 9px;
  border-radius: var(--radius);
  background: #f3f6f7;
}

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

dd {
  margin: 4px 0 0;
  font-weight: 800;
}

.status-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  padding: 0 16px 16px;
}

.status-actions button {
  min-height: 64px;
  padding: 0 8px;
  background: #ffffff;
  color: var(--ink);
  font-size: 14px;
  font-weight: 900;
  line-height: 1.2;
  white-space: normal;
}

.status-actions button[data-status="complete"] {
  grid-column: 1 / -1;
}

.status-actions button.active[data-status="not_started"] {
  background: var(--grey-bg);
}

.status-actions button.active[data-status="in_progress"] {
  background: var(--amber);
  color: #ffffff;
  border-color: var(--amber);
}

.status-actions button.active[data-status="in_production"] {
  background: var(--blue);
  color: #ffffff;
  border-color: var(--blue);
}

.status-actions button.active[data-status="complete"] {
  background: var(--green);
  color: #ffffff;
  border-color: var(--green);
}

.status-actions button.active[data-status="backorder"] {
  background: var(--red);
  color: #ffffff;
  border-color: var(--red);
}

.status-actions button.active[data-status="partial_backorder"] {
  background: var(--red);
  color: #ffffff;
  border-color: var(--red);
}

.required-date-form,
.order-method-form {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto;
  gap: 10px;
  align-items: end;
  padding: 0 16px 16px;
}

.order-method-form {
  padding-top: 0;
}

.required-date-form label span,
.order-method-form label span {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.required-date-form input,
.order-method-form select {
  min-height: 64px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0 10px;
  background: #ffffff;
  color: var(--ink);
  cursor: pointer;
  font-size: 17px;
  font-weight: 800;
}

.order-method-form select {
  appearance: auto;
}

.required-date-form button,
.order-method-form button {
  min-height: 64px;
  padding: 0 14px;
  background: var(--brand);
  color: #ffffff;
  border-color: var(--brand);
  font-weight: 900;
}

.touch-calendar {
  width: min(780px, calc(100vw - 28px));
  max-width: none;
  max-height: calc(100dvh - 28px);
  padding: 0;
  border: 0;
  border-radius: var(--radius);
  background: #ffffff;
  color: var(--ink);
  box-shadow: 0 24px 70px rgba(24, 34, 47, 0.3);
}

.touch-calendar::backdrop {
  background: rgba(24, 34, 47, 0.62);
}

.calendar-shell {
  padding: 18px;
}

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

.calendar-head h2 {
  margin: 0;
  text-align: center;
  font-size: 30px;
}

.calendar-head button {
  min-height: 64px;
  background: #ffffff;
  color: var(--ink);
  font-size: 28px;
  font-weight: 900;
}

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

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

.calendar-weekdays span {
  padding: 8px 2px;
  color: var(--muted);
  text-align: center;
  font-size: 14px;
  font-weight: 900;
  text-transform: uppercase;
}

.calendar-days button {
  min-width: 0;
  min-height: 68px;
  padding: 4px;
  background: #f3f6f7;
  color: var(--ink);
  font-size: 23px;
  font-weight: 900;
}

.calendar-days button.outside-month {
  color: #97a3af;
  background: #fafbfc;
}

.calendar-days button.today {
  border: 3px solid var(--brand);
}

.calendar-days button.selected {
  background: var(--brand);
  color: #ffffff;
  border-color: var(--brand);
}

.calendar-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 16px;
}

.calendar-actions button {
  min-height: 64px;
  background: #ffffff;
  color: var(--ink);
  font-weight: 900;
}

.calendar-actions button:first-child {
  background: var(--brand);
  color: #ffffff;
  border-color: var(--brand);
}

.order-details {
  display: none;
  border-top: 1px solid var(--line);
  padding: 12px 16px 16px;
}

.order-card.expanded .order-details {
  display: block;
}

.detail-row {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid #edf1f4;
}

.detail-row dd {
  overflow-wrap: anywhere;
}

.detail-row.balance-row {
  align-items: center;
}

.partial-backorder-info {
  margin: 0 16px 16px;
  padding: 12px;
  border: 2px solid #efb4b4;
  border-radius: var(--radius);
  background: var(--red-bg);
}

.partial-backorder-info span {
  display: block;
  margin-bottom: 4px;
  color: #7d2020;
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.partial-backorder-info strong {
  color: #5f1717;
  overflow-wrap: anywhere;
}

.balance-pill {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  max-width: 100%;
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--red-bg);
  color: #7d2020;
  font-weight: 900;
  overflow-wrap: anywhere;
}

.empty-state,
.error-banner {
  padding: 30px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
}

.orders-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
}

.orders-table {
  width: 100%;
  min-width: 1120px;
  border-collapse: collapse;
}

.orders-table th,
.orders-table td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.orders-table th {
  background: #f6f8fa;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.orders-table td {
  color: var(--ink);
  font-weight: 750;
}

.backorder-modal {
  width: min(680px, calc(100vw - 28px));
  border: 0;
  border-radius: var(--radius);
  padding: 0;
}

.backorder-modal::backdrop,
.touch-calendar::backdrop {
  background: rgba(20, 28, 38, 0.52);
}

.backorder-modal-card {
  padding: 22px;
}

.backorder-choice-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 16px 0;
}

.backorder-choice-grid label {
  min-height: 78px;
  justify-content: center;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
}

.backorder-choice-grid span {
  font-size: 18px;
  font-weight: 900;
}

.partial-products-field textarea {
  min-height: 130px;
  resize: vertical;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 16px;
}

.hidden {
  display: none !important;
}

.admin-grid {
  display: grid;
  grid-template-columns: minmax(360px, 1fr) minmax(360px, 1fr);
  gap: 16px;
}

.settings-panel {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
}

.settings-panel.narrow {
  max-width: 460px;
  margin: 60px auto 0;
}

.settings-panel h2,
.settings-panel h3 {
  margin: 0 0 14px;
}

.settings-panel label {
  display: block;
  margin-bottom: 12px;
}

.two-col,
.health-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

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

.form-message {
  min-height: 24px;
  color: var(--brand-strong);
  font-weight: 800;
}

.subtle-copy {
  margin: 0 0 14px;
  color: var(--muted);
  font-weight: 700;
}

.workbook-results {
  display: grid;
  gap: 8px;
}

.sheet-result,
.health-item,
.log-item {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f8fafb;
}

.health-item span,
.log-item small {
  display: block;
  color: var(--muted);
  font-weight: 700;
}

.log-list {
  display: grid;
  gap: 8px;
  max-height: 360px;
  overflow: auto;
}

.log-item.failed,
.log-item.error {
  border-left: 6px solid var(--red);
}

.log-item.success {
  border-left: 6px solid var(--green);
}

.log-item.partial,
.log-item.warning {
  border-left: 6px solid var(--amber);
}

.tab-editor {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f8fafb;
}

.tab-editor + .tab-editor {
  margin-top: 12px;
}

.tab-editor-main {
  display: grid;
  grid-template-columns: 1fr 1.25fr 0.9fr 0.45fr auto auto;
  gap: 10px;
  align-items: end;
}

.checkbox-label,
.mini-check {
  display: flex !important;
  align-items: center;
  gap: 8px;
}

.checkbox-label input,
.mini-check input {
  width: 22px;
  height: 22px;
  min-height: 22px;
}

details {
  margin-top: 12px;
}

summary {
  min-height: 44px;
  cursor: pointer;
  font-weight: 900;
}

.mapping-list {
  display: grid;
  gap: 8px;
}

.mapping-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1.3fr auto auto 90px;
  gap: 8px;
  align-items: center;
}

.notification-template {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f8fafb;
}

.notification-template + .notification-template {
  margin-top: 12px;
}

@media (max-width: 1400px) {
  .topbar {
    align-items: stretch;
    flex-wrap: wrap;
  }

  .topbar-identity {
    flex-basis: 100%;
  }

  .topbar-actions {
    width: 100%;
    justify-content: flex-end;
    padding-top: 12px;
    border-top: 1px solid var(--line);
  }
}

@media (max-width: 980px) {
  .topbar,
  .admin-topbar,
  .controls-band {
    align-items: stretch;
    flex-direction: column;
  }

  .status-strip,
  .admin-grid,
  .tab-editor-main,
  .mapping-row {
    grid-template-columns: 1fr;
  }

  .filters,
  .two-col,
  .health-grid {
    grid-template-columns: 1fr;
    flex-direction: column;
    align-items: stretch;
    min-width: 0;
  }

  .topbar-identity {
    width: 100%;
  }

  .eta-countdown {
    min-width: min(360px, 100%);
  }

  .topbar .date-input {
    width: 100%;
  }
}

@media (max-width: 620px) {
  main,
  .topbar,
  .admin-topbar {
    padding-left: 14px;
    padding-right: 14px;
  }

  .orders-grid-inner {
    grid-template-columns: 1fr;
  }

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

  .required-date-form,
  .order-method-form {
    grid-template-columns: 1fr;
  }

  .detail-row,
  .order-dates,
  .delivery-method-row {
    grid-template-columns: 1fr;
  }

  .topbar-identity {
    align-items: stretch;
    flex-direction: column;
    gap: 14px;
  }

  .eta-countdown {
    min-width: 0;
    width: 100%;
  }

  .calendar-shell {
    padding: 12px;
  }

  .calendar-head {
    grid-template-columns: 58px 1fr 58px;
    gap: 8px;
  }

  .calendar-head h2 {
    font-size: 24px;
  }

  .calendar-weekdays,
  .calendar-days {
    gap: 4px;
  }

  .calendar-weekdays span {
    font-size: 11px;
  }

  .calendar-days button {
    min-height: 58px;
    font-size: 19px;
  }
}
