/*
 * Zestia OS · Operational foundation 1.0.06
 * Canonical visual contract for task-focused applications.
 * Keep the app copies byte-identical; run scripts/sync_ops_visual_foundation.py.
 */

:root {
  --zops-canvas: #f5f7fb;
  --zops-bg: var(--zops-canvas);
  --zops-surface: #ffffff;
  --zops-surface-soft: #f8fafc;
  --zops-ink: #111827;
  --zops-text: #334155;
  --zops-muted: #64748b;
  --zops-line: #dbe3ee;
  --zops-border: var(--zops-line);
  --zops-line-strong: #cbd5e1;
  --zops-brand: #3454e8;
  --zops-primary: var(--zops-brand);
  --zops-brand-strong: #253fc2;
  --zops-success: #0f8f78;
  --zops-warning: #f97316;
  --zops-danger: #dc2626;
  --zops-info: #2563eb;
  --zops-radius-sm: 8px;
  --zops-radius-md: 12px;
  --zops-radius-lg: 18px;
  --zops-shadow-surface: 0 2px 8px rgba(15, 23, 42, 0.06);
  --zops-shadow-sm: var(--zops-shadow-surface);
  --zops-shadow-raised: 0 18px 46px rgba(15, 23, 42, 0.12);
  --zops-font-ui: "Inter", "Avenir Next", "Segoe UI", system-ui, sans-serif;
  --zops-font-data: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  --zops-header-height: 64px;
  --zops-touch-target: 44px;
  --zops-control-height: 44px;
}

.zestia-ops-shell {
  /* Compatibility aliases while the legacy app layers are retired safely. */
  --bg: var(--zops-canvas);
  --surface: var(--zops-surface);
  --surface-alt: var(--zops-surface-soft);
  --card: var(--zops-surface);
  --text: var(--zops-ink);
  --muted: var(--zops-muted);
  --border: var(--zops-line);
  --accent: var(--zops-brand);
  --accent-dark: var(--zops-brand-strong);
  --accent-strong: var(--zops-brand-strong);
  --brand: var(--zops-brand);
  --danger: var(--zops-danger);
  --shadow: var(--zops-shadow-surface);
  --shadow-soft: var(--zops-shadow-surface);
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  overflow-x: hidden;
  background: var(--zops-canvas);
  color: var(--zops-ink);
  font-family: var(--zops-font-ui);
  line-height: 1.4;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

.zestia-ops-shell *,
.zestia-ops-shell *::before,
.zestia-ops-shell *::after {
  box-sizing: border-box;
}

.zestia-ops-shell :where(h1, h2, h3, h4, h5, h6, button, .button, .btn, input, select, textarea, summary) {
  font-family: var(--zops-font-ui);
}

.zops-skip-link,
.zestia-ops-skip-link {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 1000;
  padding: 10px 14px;
  border-radius: var(--zops-radius-sm);
  background: var(--zops-ink);
  color: #ffffff;
  font-weight: 800;
  text-decoration: none;
  transform: translateY(-160%);
  transition: transform 0.15s ease;
}

.zops-skip-link:focus,
.zestia-ops-skip-link:focus {
  transform: translateY(0);
}

.zestia-ops-shell .site-header.zestia-ops-header {
  position: sticky;
  top: 0;
  z-index: 80;
  display: grid;
  grid-template-columns: minmax(210px, auto) minmax(0, 1fr);
  align-items: center;
  gap: 16px;
  min-height: var(--zops-header-height);
  padding: 8px 18px;
  border: 0;
  border-bottom: 1px solid var(--zops-line);
  background: rgba(255, 255, 255, 0.96);
  color: var(--zops-ink);
  box-shadow: var(--zops-shadow-surface);
  backdrop-filter: blur(14px);
}

.zestia-ops-brand {
  display: inline-flex;
  min-width: 0;
  align-items: center;
  gap: 10px;
  color: var(--zops-ink);
  text-decoration: none;
}

.zestia-ops-shell .ops-product-brand {
  overflow-wrap: anywhere;
}

.zestia-ops-brand__mark {
  display: grid;
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  place-items: center;
  border-radius: 11px;
  background: var(--zops-ink);
  color: #ffffff;
  font-size: 18px;
  font-style: italic;
  font-weight: 950;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.16);
}

.zestia-ops-brand__copy {
  display: grid;
  min-width: 0;
  gap: 3px;
  line-height: 1;
}

.zestia-ops-brand__wordmark {
  overflow: hidden;
  color: var(--zops-ink);
  font-size: 20px;
  font-style: italic;
  font-weight: 950;
  letter-spacing: -0.045em;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.zestia-ops-brand__wordmark span {
  color: var(--zops-brand);
}

.zestia-ops-brand__copy small {
  overflow: hidden;
  max-width: 390px;
  color: var(--zops-muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.045em;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

/* KDS still ships a legacy brand layer with more specific selectors. The
   operational foundation wins deliberately so Cocina and Reparto expose the
   same product identity and only vary the workstation label. */
.zestia-ops-shell--kds .kds-product-brand {
  display: inline-flex;
  min-width: 0;
  align-items: center;
  gap: 10px;
}

.zestia-ops-shell--kds .kds-product-brand .ops-product-brand__mark {
  display: grid;
}

.zestia-ops-shell--kds .kds-product-brand .ops-product-brand__copy {
  display: grid;
  min-width: 0;
  gap: 3px;
  line-height: 1;
}

.zestia-ops-shell--kds .kds-product-brand .ops-product-brand__wordmark {
  color: var(--zops-ink);
  font-family: var(--zops-font-ui);
  font-size: 20px;
  letter-spacing: -0.045em;
  line-height: 1;
}

.zestia-ops-shell--kds .kds-product-brand .ops-product-brand__copy small {
  max-width: 390px;
  margin: 0;
  font-size: 10px;
  letter-spacing: 0.045em;
  line-height: 1;
}

.zestia-ops-header__actions {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.zestia-ops-status {
  display: inline-flex;
  min-height: 32px;
  flex: 0 0 auto;
  align-items: center;
  gap: 7px;
  padding: 6px 10px;
  border: 1px solid #bde7dc;
  border-radius: 999px;
  background: #effcf8;
  color: #0c6a5a;
  font-size: 11px;
  font-weight: 850;
  white-space: nowrap;
}

.zestia-ops-status::before {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--zops-success);
  box-shadow: 0 0 0 3px rgba(15, 143, 120, 0.12);
  content: "";
}

.zestia-ops-status--idle {
  border-color: var(--zops-line);
  background: var(--zops-surface-soft);
  color: var(--zops-muted);
}

.zestia-ops-status--idle::before {
  background: #94a3b8;
  box-shadow: none;
}

.zestia-ops-shell .main-nav.zestia-ops-nav {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 4px;
  margin: 0;
  overflow-x: auto;
  scrollbar-width: none;
}

.zestia-ops-shell .main-nav.zestia-ops-nav::-webkit-scrollbar {
  display: none;
}

.zestia-ops-shell .main-nav.zestia-ops-nav a {
  display: inline-flex;
  min-height: var(--zops-control-height);
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 9px 12px;
  border: 1px solid transparent;
  border-radius: var(--zops-radius-md);
  background: transparent;
  color: var(--zops-text);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0;
  text-decoration: none;
  white-space: nowrap;
  box-shadow: none;
}

.zestia-ops-shell .main-nav.zestia-ops-nav a:hover {
  border-color: var(--zops-line);
  background: var(--zops-surface-soft);
  color: var(--zops-ink);
  transform: none;
}

.zestia-ops-shell .main-nav.zestia-ops-nav a.is-active,
.zestia-ops-shell .main-nav.zestia-ops-nav a[aria-current="page"] {
  border-color: var(--zops-ink);
  background: var(--zops-ink);
  color: #ffffff;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.14);
}

.zestia-ops-shell .content.zestia-ops-main {
  width: 100%;
  max-width: none;
  min-height: calc(100vh - var(--zops-header-height));
  min-height: calc(100dvh - var(--zops-header-height));
  margin: 0 auto;
  padding: 16px;
}

.zestia-ops-shell--rider .content.zestia-ops-main {
  max-width: 1440px;
  padding-bottom: max(40px, env(safe-area-inset-bottom));
}

.zestia-ops-shell :where(.panel, .card, .ticket, .station-switch, .route-card, .delivery-card) {
  border-color: var(--zops-line);
  background: var(--zops-surface);
  color: var(--zops-ink);
  box-shadow: var(--zops-shadow-surface);
}

.zestia-ops-shell :where(button, .button, .btn, input, select, textarea) {
  min-height: var(--zops-control-height);
  font: inherit;
}

.zestia-ops-shell :where(button, .button, .btn) {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 9px 13px;
  border: 1px solid var(--zops-ink);
  border-radius: var(--zops-radius-sm);
  background: var(--zops-ink);
  color: #ffffff;
  font-size: 13px;
  font-weight: 850;
  line-height: 1.15;
  text-decoration: none;
  box-shadow: none;
  cursor: pointer;
}

.zestia-ops-shell :where(button, .button, .btn):hover:not(:disabled) {
  border-color: var(--zops-brand);
  background: var(--zops-brand);
  color: #ffffff;
  filter: none;
  transform: none;
  box-shadow: none;
}

.zestia-ops-shell :where(.secondary, .ghost, .button.ghost, .btn.secondary) {
  border-color: var(--zops-line-strong);
  background: var(--zops-surface);
  color: var(--zops-ink);
}

/* Legacy rider/KDS styles use selectors with more specificity. Keep the
   shared secondary action readable even while those layers are retired. */
.zestia-ops-shell button.secondary,
.zestia-ops-shell button.ghost,
.zestia-ops-shell .button.secondary,
.zestia-ops-shell .button.ghost,
.zestia-ops-shell .btn.secondary,
.zestia-ops-shell .btn.ghost {
  border-color: var(--zops-line-strong);
  background: var(--zops-surface);
  color: var(--zops-ink);
}

.zestia-ops-shell :where(button, .button, .btn):disabled {
  opacity: 0.48;
  cursor: not-allowed;
}

.zestia-ops-shell :where(input, select, textarea) {
  padding: 9px 11px;
  border: 1px solid var(--zops-line-strong);
  border-radius: var(--zops-radius-sm);
  background: var(--zops-surface);
  color: var(--zops-ink);
  box-shadow: none;
}

.zestia-ops-shell :where(button, a, input, select, textarea, summary):focus-visible {
  outline: 3px solid rgba(52, 84, 232, 0.48);
  outline-offset: 2px;
}

.zestia-ops-shell :where(.muted, .panel-sub, .kpi-meta) {
  color: var(--zops-muted);
}

.zestia-ops-shell :where(.badge, .pill, .chip) {
  border-radius: 999px;
  letter-spacing: 0;
}

.zestia-ops-shell .alert {
  border-color: #fecaca;
  background: #fff1f2;
  color: #9f1239;
}

.zestia-ops-shell--rider {
  --zops-control-height: 48px;
}

.zestia-ops-shell--rider :where(button, .button, .btn, input, select, textarea) {
  min-height: 48px;
}

.zestia-ops-shell--kds {
  --zops-control-height: 48px;
}

.zestia-ops-shell--kds .main-nav.zestia-ops-nav a {
  min-height: 44px;
}

.zestia-ops-shell--kds .kds-workbar__filter {
  border-color: transparent;
  background: var(--zops-surface-soft);
  color: var(--zops-text);
}

.zestia-ops-shell--kds .kds-workbar__filter strong {
  color: var(--zops-ink);
}

.zestia-ops-shell--kds .kds-workbar__filter.is-active {
  border-color: var(--zops-ink);
  background: var(--zops-ink);
  color: #ffffff;
}

.zestia-ops-shell--kds .kds-workbar__filter.is-active strong {
  color: #ffffff;
}

.zestia-ops-shell--kds .kds-workbar__deadline {
  grid-template-areas:
    "time label countdown"
    "time meta meta"
    "status status status";
  grid-template-columns: auto minmax(0, 1fr) auto;
}

.zestia-ops-shell--kds .kds-workbar__deadline .kitchen-deadline-board__time {
  grid-area: time;
}

.zestia-ops-shell--kds .kds-workbar__deadline .kitchen-deadline-board__label {
  grid-area: label;
}

.zestia-ops-shell--kds .kds-workbar__deadline .kitchen-deadline-board__countdown {
  grid-area: countdown;
  justify-self: end;
  white-space: nowrap;
}

.zestia-ops-shell--kds .kds-workbar__deadline .kitchen-deadline-board__meta {
  grid-area: meta;
}

.zestia-ops-shell--kds .kds-workbar__deadline .kitchen-deadline-board__status {
  grid-area: status;
}

.zestia-ops-shell .kds-fullscreen-toggle {
  min-height: var(--zops-control-height);
  margin: 0;
  border-color: var(--zops-line-strong);
  background: var(--zops-surface);
  color: var(--zops-ink);
  white-space: nowrap;
}

.zestia-ops-shell .kds-fullscreen-toggle.is-active {
  border-color: var(--zops-brand);
  background: var(--zops-brand);
  color: #ffffff;
}

.rider-command-bar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 0.62fr);
  gap: 12px;
  align-items: stretch;
  margin-bottom: 14px;
  padding: 14px;
  border: 1px solid var(--zops-line);
  border-radius: var(--zops-radius-lg);
  background: var(--zops-surface);
  box-shadow: var(--zops-shadow-surface);
}

.rider-command-bar__title {
  display: grid;
  align-content: center;
  gap: 3px;
}

.rider-command-bar__eyebrow,
.rider-next-action span {
  color: var(--zops-muted);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.rider-command-bar h1 {
  margin: 0;
  font-size: clamp(25px, 3vw, 38px);
  letter-spacing: -0.045em;
}

.rider-command-bar p {
  margin: 0;
  color: var(--zops-muted);
}

.rider-next-action {
  display: grid;
  min-height: 84px;
  align-content: center;
  gap: 4px;
  padding: 12px 14px;
  border: 1px solid #bde7dc;
  border-left: 5px solid var(--zops-success);
  border-radius: var(--zops-radius-md);
  background: #effcf8;
  color: #0c5f52;
}

.rider-next-action strong {
  font-size: 17px;
  line-height: 1.2;
}

.rider-insights {
  padding: 0 !important;
  overflow: hidden;
}

.rider-insights__summary {
  display: flex;
  min-height: 52px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  cursor: pointer;
  list-style: none;
}

.rider-insights__summary::-webkit-details-marker {
  display: none;
}

.rider-insights__summary::after {
  color: var(--zops-muted);
  content: "+";
  font-size: 24px;
  font-weight: 500;
}

.rider-insights[open] .rider-insights__summary::after {
  content: "−";
}

.rider-insights__summary strong,
.rider-insights__summary small {
  display: block;
}

.rider-insights__summary small {
  margin-top: 2px;
  color: var(--zops-muted);
}

.rider-insights > :not(summary) {
  margin: 0 14px 14px;
}

.zestia-ops-shell--rider .rider-layout {
  grid-template-columns: minmax(280px, 330px) minmax(0, 1fr);
  gap: 14px;
}

.zestia-ops-shell--rider .route-box {
  border-color: var(--zops-line);
  background: var(--zops-surface);
  color: var(--zops-ink);
  box-shadow: var(--zops-shadow-surface);
}

.zestia-ops-shell--rider .stat-card {
  border: 1px solid var(--zops-line);
  background: var(--zops-surface);
  color: var(--zops-ink);
  box-shadow: var(--zops-shadow-surface);
}

.zestia-ops-shell--kds .kds-rush__row--head {
  border: 1px solid var(--zops-line);
  background: var(--zops-surface-soft);
  color: var(--zops-ink);
  box-shadow: inset 0 -1px 0 var(--zops-line);
}

.zestia-ops-shell--kds .kds-rush__row--head :where(strong, span, small) {
  color: var(--zops-text);
}

.zestia-ops-shell--rider .scan-modal {
  z-index: 200;
  background: rgba(15, 23, 42, 0.72);
  backdrop-filter: blur(5px);
}

.zestia-ops-shell--rider .scan-modal__card {
  border: 1px solid var(--zops-line);
  border-radius: var(--zops-radius-lg);
  box-shadow: var(--zops-shadow-raised);
}

.zestia-ops-shell--rider :where(.gps-status, .qr-status, .scan-modal__status) {
  min-height: 24px;
}

.zestia-ops-shell--rider details.stack > summary {
  display: flex;
  min-height: 44px;
  align-items: center;
  cursor: pointer;
}

.zestia-ops-shell--rider .task-card {
  border-left: 4px solid var(--zops-line-strong);
}

.zestia-ops-shell--rider .task-card:has(.badge--warn) {
  border-left-color: var(--zops-warning);
}

.zestia-ops-shell--rider .task-card:has(.badge--ok) {
  border-left-color: var(--zops-success);
}

.zestia-ops-shell--rider .task-actions button[type="submit"] {
  min-height: 52px;
  padding-inline: 18px;
  background: var(--zops-success);
  border-color: var(--zops-success);
}

.zestia-ops-shell--rider .task-head h3,
.zestia-ops-shell--rider .cashbox__amount,
.zestia-ops-shell--kds :where(.ticket-number, .kitchen-stat strong, time) {
  font-family: var(--zops-font-data);
  font-variant-numeric: tabular-nums;
}

.zestia-ops-shell--kds .kds-workbar__lucia .lucia-status span {
  display: block;
  overflow: hidden;
  max-width: 100%;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.kds-browser-fullscreen .site-header.zestia-ops-header {
  position: static;
}

.kds-browser-fullscreen .zestia-ops-header__actions,
.kds-focus .zestia-ops-header__actions {
  flex-wrap: nowrap;
}

@media (max-width: 980px) {
  .zestia-ops-shell .site-header.zestia-ops-header {
    grid-template-columns: 1fr;
    gap: 7px;
    padding: 8px 12px;
  }

  .zestia-ops-header__actions {
    width: 100%;
    justify-content: flex-start;
  }

  .zestia-ops-shell .main-nav.zestia-ops-nav {
    flex: 1 1 auto;
  }

  .zestia-ops-shell--rider .rider-layout {
    grid-template-columns: 1fr;
  }

  .zestia-ops-shell--rider .rider-layout > .stack:first-child {
    order: 2;
  }

  .zestia-ops-shell--rider .rider-layout > .stack:nth-child(2) {
    order: 1;
  }
}

@media (max-width: 680px) {
  :root {
    --zops-header-height: 112px;
  }

  .zestia-ops-shell .site-header.zestia-ops-header {
    position: sticky;
    display: grid;
    align-items: stretch;
    min-height: 0;
    overflow: visible;
  }

  .zestia-ops-brand__mark {
    width: 34px;
    height: 34px;
    flex-basis: 34px;
    border-radius: 9px;
  }

  .zestia-ops-brand__wordmark {
    font-size: 18px;
  }

  .zestia-ops-brand__copy small {
    max-width: calc(100vw - 84px);
    font-size: 9px;
  }

  .zestia-ops-header__actions {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
  }

  .zestia-ops-shell .main-nav.zestia-ops-nav {
    grid-column: 1 / -1;
    width: 100%;
  }

  .zestia-ops-status {
    display: none;
  }

  .zestia-ops-shell .content.zestia-ops-main {
    min-height: 0;
    padding: 10px;
  }

  .zestia-ops-shell--kds .kds-workbar__lucia {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .zestia-ops-shell--kds .kds-workbar__lucia .lucia-status {
    grid-column: 1 / -1;
  }

  .rider-command-bar {
    grid-template-columns: 1fr;
    padding: 11px;
  }

  .rider-command-bar p {
    display: none;
  }

  .rider-next-action {
    min-height: 72px;
  }

  .zestia-ops-shell--rider .panel,
  .zestia-ops-shell--rider .card {
    padding: 12px;
  }

  .zestia-ops-shell--rider .task-actions :where(button, .button, input, select) {
    width: 100%;
  }

  .zestia-ops-shell--rider .cashbox__controls {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .zestia-ops-shell--rider .cashbox__paid {
    max-width: none;
  }

  .kds-browser-fullscreen .site-header.zestia-ops-header,
  .kds-focus .site-header.zestia-ops-header {
    position: relative;
  }
}

@media (prefers-reduced-motion: reduce) {
  .zestia-ops-shell *,
  .zestia-ops-shell *::before,
  .zestia-ops-shell *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

@media print {
  .zestia-ops-header,
  .zestia-ops-skip-link {
    display: none !important;
  }

  .zestia-ops-shell .content.zestia-ops-main {
    padding: 0;
  }
}
