:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --panel: #ffffff;
  --ink: #17202a;
  --muted: #64748b;
  --line: #d9e1ea;
  --accent: #0f766e;
  --accent-strong: #115e59;
  --warn: #b45309;
  --ok: #047857;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

body.locked .shell {
  display: none;
}

.login-view {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
}

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

.login-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 16px;
  max-width: 420px;
  padding: 24px;
  width: 100%;
}

.login-panel h1 {
  font-size: 26px;
  margin-top: 14px;
}

.login-panel p,
.login-panel small {
  color: var(--muted);
}

.login-panel small.error {
  color: #b91c1c;
}

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

.sidebar {
  background: #111827;
  color: #f8fafc;
  padding: 24px 18px;
}

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

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: var(--accent);
  font-weight: 800;
}

.brand small {
  display: block;
  margin-top: 2px;
  color: #a8b3c4;
}

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

nav button {
  background: transparent;
  border: 0;
  color: #cbd5e1;
  cursor: pointer;
  font: inherit;
  padding: 10px 12px;
  border-radius: 7px;
  text-align: left;
  width: 100%;
}

nav button.active,
nav button:hover {
  background: #243244;
  color: #ffffff;
}

nav button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.ghost-button {
  background: transparent;
  border: 1px solid #334155;
  color: #cbd5e1;
  margin-top: 24px;
  width: 100%;
}

.ghost-button:hover {
  background: #243244;
}

.workspace {
  padding: 28px;
}

.app-view[hidden] {
  display: none;
}

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

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 30px;
  line-height: 1.1;
}

.topbar p,
.panel p {
  color: var(--muted);
  margin-top: 8px;
}

.status {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  padding: 8px 12px;
  color: var(--warn);
  white-space: nowrap;
}

.status.ok {
  color: var(--ok);
}

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

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

.metrics article {
  padding: 18px;
}

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

.metrics strong {
  font-size: 32px;
}

.panel {
  padding: 20px;
}

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

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

button {
  border: 0;
  border-radius: 7px;
  background: var(--accent);
  color: #ffffff;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  min-height: 40px;
  padding: 0 14px;
}

button:hover {
  background: var(--accent-strong);
}

.secondary-button {
  background: #475569;
}

.secondary-button:hover {
  background: #334155;
}

.store-form,
.filters-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  align-items: end;
  margin-bottom: 18px;
}

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

.store-form button,
.filters-form button {
  align-self: end;
}

.wide-field {
  display: grid;
  gap: 6px;
  grid-column: 1 / -1;
}

.checkbox-label {
  align-items: center;
  display: flex;
  flex-direction: row;
  gap: 8px;
  min-height: 40px;
}

.checkbox-label input {
  min-height: auto;
}

.form-message {
  color: var(--muted);
  margin-bottom: 14px;
  min-height: 20px;
}

.form-message.error {
  color: #b91c1c;
}

.form-message.ok {
  color: var(--ok);
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-weight: 700;
}

input,
select,
textarea {
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--ink);
  font: inherit;
  padding: 0 12px;
}

input,
select {
  min-height: 40px;
}

textarea {
  min-height: 120px;
  padding: 10px 12px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  outline: 3px solid rgba(15, 118, 110, 0.15);
}

.store-list,
.orders-list {
  display: grid;
  gap: 10px;
}

.store-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 12px 14px;
}

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

.store-actions button {
  min-height: 34px;
}

.color-swatch {
  border: 1px solid var(--line);
  border-radius: 999px;
  display: inline-block;
  height: 24px;
  width: 24px;
}

.status-pill {
  align-items: center;
  background: color-mix(in srgb, var(--status-color) 12%, white);
  border: 1px solid color-mix(in srgb, var(--status-color) 35%, white);
  border-radius: 999px;
  color: var(--ink);
  display: inline-flex;
  font-weight: 700;
  min-height: 26px;
  padding: 0 10px;
}

.store-row small {
  display: block;
  color: var(--muted);
  margin-top: 4px;
}

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

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

.orders-table-wrapper {
  overflow-x: auto;
}

.columns-control {
  border: 1px solid var(--line);
  border-radius: 7px;
  margin-bottom: 14px;
  padding: 10px 12px;
}

.columns-control summary {
  cursor: pointer;
  font-weight: 700;
}

.columns-options {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  margin-top: 12px;
}

.columns-options label {
  align-items: center;
  display: flex;
  flex-direction: row;
  gap: 6px;
}

.columns-options input {
  min-height: auto;
}

.orders-table th {
  color: var(--muted);
  font-size: 14px;
}

.orders-table td {
  font-size: 14px;
}

.orders-table small {
  color: var(--muted);
  display: block;
  margin-top: 3px;
}

.pagination-bar {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 16px;
}

.pagination-bar button {
  min-height: 36px;
}

.calendar-toolbar {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: space-between;
  margin-bottom: 16px;
}

.segmented-control {
  background: #e9eef5;
  border: 1px solid var(--line);
  border-radius: 7px;
  display: flex;
  gap: 2px;
  padding: 3px;
}

.segmented-control button {
  background: transparent;
  color: var(--muted);
  min-height: 34px;
}

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

.calendar-surface {
  overflow-x: auto;
}

.calendar-time-grid {
  display: grid;
  grid-template-columns: 70px repeat(var(--calendar-days), minmax(180px, 1fr));
  min-width: 760px;
}

.calendar-grid-corner,
.calendar-day-head,
.calendar-hour,
.calendar-slot {
  border-bottom: 1px solid var(--line);
  border-right: 1px solid var(--line);
}

.calendar-day-head {
  background: #f8fafc;
  color: var(--muted);
  font-weight: 800;
  padding: 10px;
  text-transform: capitalize;
}

.calendar-hour {
  color: var(--muted);
  font-size: 13px;
  padding: 10px 8px;
}

.calendar-slot {
  min-height: 84px;
  padding: 6px;
}

.calendar-event-card,
.calendar-chip {
  background: color-mix(in srgb, var(--event-color) 14%, white);
  border: 1px solid color-mix(in srgb, var(--event-color) 45%, white);
  border-left: 5px solid var(--event-color);
  color: var(--ink);
  cursor: pointer;
  display: grid;
  gap: 3px;
  margin-bottom: 6px;
  min-height: 0;
  padding: 7px 8px;
  text-align: left;
  width: 100%;
}

.calendar-event-card span,
.calendar-event-card small,
.calendar-chip {
  overflow: hidden;
  text-overflow: ellipsis;
}

.calendar-event-card small {
  color: var(--muted);
}

.routes-layout {
  display: grid;
  gap: 18px;
  margin-top: 18px;
}

.route-panel {
  padding: 18px;
}

.route-create-tools {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: space-between;
}

.route-event-pick-list,
.route-combos {
  display: grid;
  gap: 10px;
}

.route-event-check {
  align-items: flex-start;
  border: 1px solid var(--line);
  border-radius: 7px;
  display: flex;
  gap: 10px;
  padding: 10px 12px;
}

.route-event-check.assigned {
  background: #f8fafc;
  opacity: 0.72;
}

.route-event-check input {
  margin-top: 4px;
  min-height: auto;
}

.combo-card {
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 12px;
}

.combo-card-header {
  align-items: center;
  display: flex;
  justify-content: space-between;
  margin-bottom: 10px;
}

.route-summary-bar {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin: 18px 0;
}

.route-summary-card {
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 14px;
}

.route-summary-card span {
  color: var(--muted);
  display: block;
  margin-bottom: 6px;
}

.route-time-grid {
  min-width: 100%;
}

.route-slot {
  background: #fcfdff;
}

.route-event-card {
  background: color-mix(in srgb, var(--event-color) 12%, white);
  border: 1px solid color-mix(in srgb, var(--event-color) 40%, white);
  border-left: 5px solid var(--event-color);
  border-radius: 8px;
  display: grid;
  gap: 8px;
  margin-bottom: 8px;
  padding: 10px;
}

.route-event-card a {
  color: var(--accent-strong);
  text-decoration: none;
}

.route-event-card a:hover {
  text-decoration: underline;
}

.route-event-top,
.route-links,
.route-actions-inline,
.route-payment-row {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: space-between;
}

.route-links select {
  min-width: 200px;
}

.route-actions-inline button {
  min-height: 34px;
}

.route-payment-row {
  border-top: 1px solid var(--line);
  padding-top: 8px;
}

.activity-feed {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

.activity-item {
  align-items: flex-start;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  display: grid;
  gap: 10px;
  grid-template-columns: 180px 1fr;
  padding: 12px 14px;
  text-align: left;
}

.activity-item:hover {
  background: #f8fafc;
}

.activity-item-time {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.activity-item-body small {
  color: var(--muted);
  display: block;
  margin-top: 4px;
}

.calendar-month-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(130px, 1fr));
  min-width: 920px;
}

.calendar-month-day {
  border-bottom: 1px solid var(--line);
  border-right: 1px solid var(--line);
  min-height: 130px;
  padding: 8px;
}

.calendar-month-day strong {
  display: block;
  margin-bottom: 6px;
}

.muted-day {
  background: #f8fafc;
  color: var(--muted);
}

.confirm-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 24px 80px rgba(15, 23, 42, 0.28);
  display: grid;
  gap: 14px;
  max-width: 420px;
  padding: 22px;
  width: min(420px, calc(100% - 32px));
}

.page-size-label {
  align-items: center;
  display: flex;
  flex-direction: row;
  gap: 8px;
}

.overlay {
  background: rgba(15, 23, 42, 0.35);
  inset: 0;
  position: fixed;
  z-index: 20;
}

.overlay[hidden] {
  display: none;
}

#confirm-overlay {
  display: grid;
  place-items: center;
}

#confirm-overlay[hidden] {
  display: none;
}

.detail-panel {
  background: var(--panel);
  border-left: 1px solid var(--line);
  box-shadow: -12px 0 32px rgba(15, 23, 42, 0.18);
  height: 100vh;
  margin-left: auto;
  max-width: 760px;
  overflow: auto;
  padding: 24px;
  width: min(760px, 100%);
}

.detail-form {
  display: grid;
  gap: 22px;
}

.detail-form h3 {
  margin: 0 0 12px;
}

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

.detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.product-line {
  border: 1px solid var(--line);
  border-radius: 7px;
  margin-bottom: 10px;
  padding: 12px;
}

.product-line small {
  color: var(--muted);
  display: block;
  margin-top: 4px;
}

.orders-table tbody tr {
  cursor: pointer;
}

.orders-table tbody tr:hover {
  background: #f8fafc;
}

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

  .sidebar {
    position: static;
  }

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

  .topbar,
  .panel-header {
    flex-direction: column;
  }

  .store-form,
  .filters-form,
  .detail-grid {
    grid-template-columns: 1fr;
  }
}
