/* =====================================================================
   ALP BOT — Design System
   ===================================================================== */

:root {
  color-scheme: light;
  --bg: #f4f6fa;
  --bg-soft: #eef1f6;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --surface-muted: #f2f4f8;
  --text: #0f172a;
  --ink: #1e293b;
  --muted: #64748b;
  --muted-soft: #94a3b8;
  --line: #e2e8f0;
  --line-strong: #cbd5e1;
  --accent: #0b8a82;
  --accent-dark: #066e67;
  --accent-soft: #e6f6f4;
  --accent-soft-border: #b9e1dc;
  --danger: #b42318;
  --danger-soft: #fee4e2;
  --danger-soft-border: #f5b5ae;
  --warn: #b54708;
  --warn-soft: #fff4e3;
  --warn-soft-border: #f4d2a1;
  --ok: #047857;
  --ok-soft: #dcfae6;
  --ok-soft-border: #a6d8bb;
  --info: #1d6cd1;
  --info-soft: #e8f1fc;
  --info-soft-border: #b9d3f0;
  --ring: rgba(11, 138, 130, 0.32);
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04), 0 1px 3px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.06), 0 2px 4px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 12px 24px rgba(15, 23, 42, 0.08), 0 4px 10px rgba(15, 23, 42, 0.04);
  --shadow-xl: 0 24px 48px rgba(15, 23, 42, 0.16), 0 8px 16px rgba(15, 23, 42, 0.08);
  --radius-xs: 5px;
  --radius-sm: 7px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  --transition: 160ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* =====================================================================
   ORDERS
   ===================================================================== */

.orders-page main {
  display: grid;
  gap: 20px;
}

.orders-control-strip {
  align-items: start;
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(0, 1fr) 340px;
}

.orders-settings-panel,
.orders-credentials-panel,
.orders-ledger,
.order-details-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
}

.orders-settings-panel,
.orders-credentials-panel {
  display: grid;
  gap: 16px;
  padding: 18px;
}

.orders-settings-head,
.orders-ledger-head {
  align-items: center;
  display: flex;
  gap: 14px;
  justify-content: space-between;
}

.orders-settings-head h2,
.orders-credentials-panel h2,
.orders-ledger-head h2 {
  font-size: 18px;
}

.connection-status {
  align-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  display: inline-flex;
  font-weight: 800;
  gap: 8px;
  margin-top: 8px;
  padding: 8px 10px;
}

.connection-check {
  align-items: center;
  background: var(--surface-muted);
  border-radius: 999px;
  color: var(--muted);
  display: inline-flex;
  font-size: 12px;
  height: 20px;
  justify-content: center;
  line-height: 1;
  width: 20px;
}

.connection-status[data-status="connected"] {
  background: var(--ok-soft);
  border-color: var(--ok-soft-border);
  color: var(--ok);
}

.connection-status[data-status="connected"] .connection-check {
  background: var(--ok);
  color: #ffffff;
}

.connection-status[data-status="missing"],
.connection-status[data-status="checking"] {
  background: var(--warn-soft);
  border-color: var(--warn-soft-border);
  color: var(--warn);
}

.orders-settings-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.orders-global-grid {
  grid-template-columns: repeat(2, minmax(0, 180px));
}

.orders-message-field {
  grid-column: span 2;
}

.orders-toggle-row,
.orders-actions,
.orders-filter-group {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.orders-actions {
  justify-content: flex-start;
}

.inline-setting {
  border-radius: var(--radius-sm);
  justify-content: flex-start;
  margin-top: 8px;
  width: fit-content;
}

.orders-filter-group {
  justify-content: flex-end;
}

.switch-control {
  align-items: center;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex;
  font-weight: 800;
  gap: 8px;
  padding: 7px 12px;
}

.switch-control input,
.workspace-pill input {
  accent-color: var(--accent);
}

.workspace-picker {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  display: grid;
  gap: 10px;
  padding: 12px;
}

.workspace-picker-head {
  align-items: baseline;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: space-between;
}

.workspace-picker-head span {
  color: var(--ink);
  font-weight: 800;
}

.workspace-picker-head small {
  color: var(--muted);
}

.workspace-pill-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.workspace-pill {
  align-items: center;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex;
  gap: 7px;
  min-height: 34px;
  padding: 6px 10px;
}

.workspace-pill span {
  font-weight: 700;
}

.workspace-pill em {
  color: var(--muted);
  font-style: normal;
}

.orders-profile-manager {
  border-top: 1px solid var(--line);
  display: grid;
  gap: 14px;
  padding-top: 16px;
}

.profile-toolbar {
  align-items: center;
  display: flex;
  gap: 12px;
  justify-content: space-between;
}

.profile-toolbar h3 {
  font-size: 15px;
  margin: 0;
}

.profile-toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.profile-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.profile-chip {
  align-items: center;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--ink);
  cursor: pointer;
  display: inline-grid;
  gap: 3px;
  min-width: 152px;
  padding: 9px 11px;
  text-align: right;
}

.profile-chip[aria-selected="true"] {
  background: var(--accent-soft);
  border-color: var(--accent-soft-border);
  box-shadow: inset 3px 0 0 var(--accent);
}

.profile-chip span {
  font-weight: 900;
}

.profile-chip small {
  color: var(--muted);
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-chip em {
  color: var(--ok);
  font-size: 11px;
  font-style: normal;
  font-weight: 800;
}

.profile-chip em.muted {
  color: var(--muted);
}

.profile-editor {
  display: grid;
  gap: 12px;
}

.profile-switch-field .switch-control {
  justify-content: center;
  min-height: 42px;
}

.danger-action {
  color: var(--danger);
}

.danger-action:hover {
  background: var(--danger-soft);
  border-color: var(--danger-soft-border);
}

.orders-metrics {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(7, minmax(0, 1fr));
}

.metric-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  display: grid;
  gap: 4px;
  min-height: 92px;
  padding: 14px;
}

.metric-card span,
.metric-card small {
  color: var(--muted);
  font-size: 12px;
}

.metric-card strong {
  color: var(--ink);
  font-size: 22px;
  line-height: 1.15;
}

.orders-ledger {
  overflow: hidden;
}

.orders-ledger-head {
  border-bottom: 1px solid var(--line);
  padding: 18px;
}

.order-status-refresh {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
  margin-inline-start: auto;
}

.order-status-refresh span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.orders-table-wrap {
  overflow: auto;
}

.orders-table {
  border-collapse: collapse;
  table-layout: auto;
  width: 100%;
}

.orders-table th,
.orders-table td {
  border-bottom: 1px solid var(--line);
  font-size: 13px;
  padding: 10px 10px;
  text-align: right;
  vertical-align: middle;
}

.orders-table th {
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.orders-table td {
  color: var(--ink);
}

.orders-table tbody tr:hover {
  background: var(--surface-soft);
}

.orders-table th.col-actions,
.orders-table td.col-actions {
  text-align: left;
  white-space: nowrap;
  width: 1%;
}

.orders-table th.col-select,
.orders-table td.col-select {
  text-align: center;
  white-space: nowrap;
  width: 1%;
}

.orders-table .col-select input[type="checkbox"] {
  cursor: pointer;
  height: 16px;
  width: 16px;
}

.orders-table th.col-status,
.orders-table td.col-status {
  white-space: nowrap;
  width: 1%;
}

.orders-table th.col-numeric,
.orders-table td.col-numeric {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.orders-table td.col-customer {
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.orders-table td.col-profile-agent {
  line-height: 1.25;
  max-width: 190px;
}

.orders-table td.col-profile-agent small {
  color: var(--muted);
  display: block;
  font-size: 11px;
  margin-top: 3px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.orders-table td.col-route bdi {
  display: inline-block;
  white-space: normal;
}

.orders-table td.col-price {
  line-height: 1.3;
}

.orders-table td.col-price .price-gross {
  color: var(--muted);
  display: block;
  font-size: 11px;
  text-decoration: line-through;
}

.orders-table td.col-time {
  color: var(--ink);
  font-size: 12px;
  line-height: 1.35;
  white-space: nowrap;
}

.orders-table td.col-time .time-clock {
  color: var(--muted);
  display: block;
  font-size: 11px;
}

.orders-pagination {
  align-items: center;
  border-top: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: space-between;
  padding: 12px 4px 0;
}

.orders-pagination-summary {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.orders-pagination-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.orders-page-button {
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--muted);
  cursor: pointer;
  display: inline-flex;
  font-size: 12px;
  font-weight: 800;
  height: 32px;
  justify-content: center;
  min-width: 32px;
  padding: 0 9px;
}

.orders-page-button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.orders-page-button[aria-current="page"] {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

.status-badge {
  border: 1px solid var(--line);
  border-radius: 999px;
  display: inline-flex;
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
  padding: 6px 9px;
}

.status-ok {
  background: var(--ok-soft);
  border-color: var(--ok-soft-border);
  color: var(--ok);
}

.status-warn {
  background: var(--warn-soft);
  border-color: var(--warn-soft-border);
  color: var(--warn);
}

.status-danger {
  background: var(--danger-soft);
  border-color: var(--danger-soft-border);
  color: var(--danger);
}

.status-info {
  background: var(--info-soft);
  border-color: var(--info-soft-border);
  color: var(--info);
}

.status-muted {
  background: var(--surface-muted);
  border-color: var(--line-strong);
  color: var(--muted);
}

.status-note {
  color: var(--muted);
  display: block;
  font-size: 11px;
  font-weight: 700;
  margin-top: 5px;
  white-space: normal;
}

.manual-import-badge {
  background: var(--surface-muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  display: inline-flex;
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
  margin-inline-start: 6px;
  padding: 5px 8px;
  white-space: nowrap;
}

.compact-action {
  min-height: 32px;
  padding: 6px 10px;
}

.small-empty {
  font-size: 13px;
  padding: 10px;
}

.order-details-drawer {
  inset: 0 0 0 auto;
  max-width: min(760px, 94vw);
  position: fixed;
  width: 760px;
  z-index: 80;
}

.order-details-panel {
  display: grid;
  grid-template-rows: auto 1fr;
  height: 100vh;
  overflow: hidden;
}

.order-details-body {
  display: grid;
  gap: 16px;
  overflow: auto;
  padding: 18px;
}

.order-details-summary {
  display: grid;
  gap: 14px;
}

.order-details-summary dl {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin: 0;
}

.order-details-summary dl > div {
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  display: grid;
  gap: 4px;
  padding: 10px;
}

.order-details-summary dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.order-details-summary dd {
  color: var(--ink);
  font-weight: 800;
  margin: 0;
  overflow-wrap: anywhere;
}

.order-events {
  display: grid;
  gap: 8px;
}

.order-events h3 {
  font-size: 15px;
}

.order-event {
  align-items: start;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  display: grid;
  gap: 2px;
  padding: 10px;
}

.order-event time {
  color: var(--muted);
  direction: ltr;
  font-size: 12px;
}

.order-event span {
  color: var(--ink);
}

.order-event-error {
  background: var(--danger-soft);
  border-color: var(--danger-soft-border);
}

.order-event-warn {
  background: var(--warn-soft);
  border-color: var(--warn-soft-border);
}

.order-event-success {
  background: var(--ok-soft);
  border-color: var(--ok-soft-border);
}

.order-activity-panel {
  margin-top: 0;
}

.order-activity-log {
  overflow: auto;
}

.order-log-grid {
  min-width: 1040px;
  width: 100%;
}

.order-log-grid-header,
.order-log-grid-row {
  display: grid;
  grid-template-columns: 150px 96px 120px 110px minmax(220px, 0.8fr) minmax(340px, 1.2fr);
}

.order-log-grid-header > div,
.order-log-grid-row > div {
  align-items: center;
  border-bottom: 1px solid var(--line);
  display: flex;
  min-width: 0;
  padding: 10px 12px;
  text-align: right;
}

.order-log-grid-header > div {
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.order-log-grid-row:hover > div {
  background: var(--surface-soft);
}

.order-log-message {
  color: var(--ink);
  font-weight: 700;
  overflow-wrap: anywhere;
}

.order-log-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.order-log-action {
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink-soft);
  display: inline-flex;
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
  padding: 6px 8px;
}

.order-log-grid-row > div:last-child {
  align-items: flex-start;
  display: grid;
  gap: 4px;
}

.order-log-grid-row > div:last-child .status-badge {
  width: fit-content;
}

.order-json-details {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px;
}

.order-json-details summary {
  cursor: pointer;
  font-weight: 800;
}

.order-json-details pre {
  background: #0f172a;
  border-radius: var(--radius-sm);
  color: #e2e8f0;
  font-size: 12px;
  margin: 12px 0 0;
  max-height: 420px;
  overflow: auto;
  padding: 12px;
  white-space: pre-wrap;
}

@media (max-width: 1180px) {
  .orders-control-strip,
  .orders-settings-grid {
    grid-template-columns: 1fr;
  }

  .orders-message-field {
    grid-column: auto;
  }

  .orders-metrics {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .orders-settings-head,
  .orders-ledger-head,
  .profile-toolbar,
  .order-status-refresh,
  .orders-filter-group {
    align-items: stretch;
    flex-direction: column;
  }

  .orders-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .order-details-summary dl {
    grid-template-columns: 1fr;
  }
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  background-image:
    radial-gradient(1200px 600px at 100% -100px, rgba(11, 138, 130, 0.06), transparent 60%),
    radial-gradient(900px 500px at -100px 100%, rgba(29, 108, 209, 0.05), transparent 65%);
  color: var(--text);
  direction: rtl;
  font-family: "Segoe UI", "Heebo", "Rubik", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.45;
  min-height: 100vh;
}

body.modal-open,
body.profile-open {
  overflow: hidden;
}

h1, h2, h3, h4 {
  color: var(--ink);
  margin: 0;
}

p {
  color: var(--muted);
  margin: 4px 0 0;
}

main {
  margin: 0 auto;
  max-width: 1480px;
  padding: 24px 32px 48px;
}

.eyebrow,
.section-label {
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.section-label {
  color: var(--muted);
}

.sr-only {
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  height: 1px;
  margin: -1px;
  overflow: hidden;
  padding: 0;
  position: absolute;
  white-space: nowrap;
  width: 1px;
}

.muted {
  color: var(--muted);
}

/* =====================================================================
   TOPBAR
   ===================================================================== */

.topbar {
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: saturate(180%) blur(10px);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 30;
}

.topbar-inner {
  align-items: center;
  display: flex;
  gap: 20px;
  justify-content: space-between;
  margin: 0 auto;
  max-width: 1480px;
  min-height: 72px;
  padding: 14px 32px;
}

.brand {
  align-items: center;
  display: flex;
  gap: 14px;
  min-width: 0;
}

.brand-mark {
  align-items: center;
  background: linear-gradient(135deg, var(--accent), #14b8a6);
  border-radius: var(--radius-md);
  box-shadow: 0 4px 12px rgba(11, 138, 130, 0.25);
  color: #ffffff;
  display: inline-flex;
  flex-shrink: 0;
  height: 40px;
  justify-content: center;
  width: 40px;
}

.brand-text {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.brand-text h1 {
  font-size: 19px;
  font-weight: 800;
  letter-spacing: -0.01em;
  line-height: 1.2;
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand-text p {
  color: var(--muted);
  font-size: 12px;
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar-side {
  align-items: center;
  display: flex;
  flex-shrink: 0;
  gap: 10px;
}

/* TOTP card */
.totp-card {
  --otp-progress: 0%;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  color: inherit;
  column-gap: 10px;
  cursor: pointer;
  display: grid;
  font: inherit;
  grid-template-areas:
    "label    label"
    "code     countdown";
  grid-template-columns: auto 1fr;
  min-height: 0;
  overflow: hidden;
  padding: 6px 12px 8px;
  position: relative;
  row-gap: 1px;
  text-align: start;
  transition: border-color var(--transition), background var(--transition), box-shadow var(--transition);
}

.totp-card:hover {
  background: var(--surface-soft);
  border-color: var(--line-strong);
}

.totp-card:focus-visible {
  border-color: var(--accent);
  outline: 3px solid var(--ring);
  outline-offset: 1px;
}

.totp-card:active {
  transform: translateY(1px);
}

.totp-card.copied {
  background: var(--ok-soft);
  border-color: var(--ok-soft-border);
}

.totp-card.copied span {
  color: var(--ok);
}

.totp-card.copied span::after {
  content: " · הועתק ✓";
}

.totp-card.copied strong {
  color: var(--ok);
}

.totp-card.copied::after {
  background: var(--ok);
}

.totp-card::after {
  background: var(--accent);
  bottom: 0;
  content: "";
  height: 2px;
  inset-inline-start: 0;
  position: absolute;
  transition: width 200ms linear;
  width: var(--otp-progress);
}

.totp-card span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  grid-area: label;
  letter-spacing: 0.04em;
  line-height: 1.2;
  text-transform: uppercase;
}

.totp-card em {
  align-self: end;
  color: var(--muted);
  font-size: 10px;
  font-style: normal;
  font-weight: 700;
  grid-area: countdown;
  justify-self: end;
  line-height: 1;
  padding-bottom: 1px;
  white-space: nowrap;
}

.totp-card strong {
  color: var(--ink);
  direction: ltr;
  font-size: 16px;
  font-weight: 900;
  grid-area: code;
  letter-spacing: 0.6px;
  line-height: 1.1;
  text-align: left;
}

.totp-card.warning {
  background: var(--warn-soft);
  border-color: var(--warn-soft-border);
}

.totp-card.warning::after {
  background: var(--warn);
}

/* Status pill */
.status {
  background: var(--accent-soft);
  border: 1px solid var(--accent-soft-border);
  border-radius: var(--radius-md);
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.02em;
  min-width: 130px;
  padding: 8px 14px;
  text-align: center;
}

/* Topbar action group */
.topbar-actions {
  align-items: center;
  display: flex;
  gap: 6px;
}

.icon-button {
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  color: var(--ink);
  cursor: pointer;
  display: inline-flex;
  font: inherit;
  font-weight: 700;
  gap: 8px;
  min-height: 38px;
  padding: 0 12px;
  position: relative;
  transition: background var(--transition), border-color var(--transition), transform var(--transition), color var(--transition);
}

.icon-button:hover {
  background: var(--surface-soft);
  border-color: var(--line-strong);
  color: var(--accent-dark);
}

.icon-button:focus-visible {
  border-color: var(--accent);
  outline: 3px solid var(--ring);
  outline-offset: 1px;
}

.icon-button:active {
  transform: translateY(1px);
}

.icon-button svg {
  color: var(--accent);
  flex-shrink: 0;
}

.icon-button-label {
  font-size: 13px;
}

.icon-button-badge {
  background: var(--accent-soft);
  border: 1px solid var(--accent-soft-border);
  border-radius: 999px;
  color: var(--accent-dark);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.02em;
  line-height: 1;
  margin-inline-start: 2px;
  max-width: 220px;
  overflow: hidden;
  padding: 3px 8px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.icon-button-badge.muted {
  background: var(--surface-muted);
  border-color: var(--line);
  color: var(--muted);
}

.icon-button-badge.warning {
  background: var(--warn-soft);
  border-color: var(--warn-soft-border);
  color: var(--warn);
}

/* User menu */
.user-menu {
  position: relative;
}

.user-chip {
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink);
  cursor: pointer;
  display: inline-flex;
  font: inherit;
  gap: 9px;
  min-height: 38px;
  padding: 3px 12px 3px 4px;
  transition: background var(--transition), border-color var(--transition);
}

.user-chip:hover {
  background: var(--surface-soft);
  border-color: var(--line-strong);
}

.user-chip:focus-visible {
  border-color: var(--accent);
  outline: 3px solid var(--ring);
  outline-offset: 1px;
}

.user-avatar {
  align-items: center;
  background: linear-gradient(135deg, var(--accent), #14b8a6);
  border-radius: 50%;
  color: #ffffff;
  display: inline-flex;
  flex-shrink: 0;
  font-size: 13px;
  font-weight: 800;
  height: 30px;
  justify-content: center;
  text-transform: uppercase;
  width: 30px;
}

.user-chip-text {
  display: grid;
  line-height: 1.15;
  text-align: start;
}

.user-chip-label {
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
}

.user-chip-email {
  color: var(--ink);
  font-size: 12px;
  font-weight: 800;
  max-width: 170px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-menu-popover {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  display: grid;
  gap: 2px;
  inset-inline-end: 0;
  margin-top: 8px;
  min-width: 220px;
  padding: 6px;
  position: absolute;
  top: 100%;
  z-index: 40;
}

.user-menu-popover[hidden] {
  display: none;
}

.user-menu-item {
  align-items: center;
  background: transparent;
  border: 0;
  border-radius: var(--radius-sm);
  color: var(--ink);
  cursor: pointer;
  display: flex;
  font: inherit;
  font-weight: 700;
  gap: 10px;
  min-height: 36px;
  padding: 0 12px;
  text-align: start;
  transition: background var(--transition);
  width: 100%;
}

.user-menu-item:hover {
  background: var(--surface-muted);
}

.user-menu-item svg {
  color: var(--muted);
  flex-shrink: 0;
}

.user-menu-item-danger {
  color: var(--danger);
}

.user-menu-item-danger:hover {
  background: var(--danger-soft);
}

.user-menu-item-danger svg {
  color: var(--danger);
}

/* =====================================================================
   TOOLBAR
   ===================================================================== */

.toolbar {
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 4px;
  padding: 14px 16px;
}

.toolbar-group {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.toolbar-workspace {
  align-items: center;
}

.toolbar-button-group {
  align-items: stretch;
  display: inline-flex;
  gap: 6px;
}

.toolbar-actions {
  margin-inline-start: auto;
}

.toolbar-workspace .workspace-field.field {
  align-items: center;
  display: flex;
  flex-direction: row;
  gap: 8px;
  min-width: 0;
}

.toolbar-workspace .workspace-field.field > label {
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  margin: 0;
  text-transform: uppercase;
  white-space: nowrap;
}

.workspace-field select {
  min-width: 220px;
}

.workspace-switcher {
  align-items: center;
  background: var(--surface-muted);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  display: inline-flex;
  gap: 4px;
  min-height: 38px;
  padding: 3px;
}

.workspace-tab {
  background: transparent;
  border: 0;
  border-radius: var(--radius-sm);
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  min-height: 30px;
  padding: 0 16px;
  transition: background var(--transition), color var(--transition);
}

.workspace-tab:hover {
  background: rgba(255, 255, 255, 0.7);
  color: var(--ink);
}

.workspace-tab.active {
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  color: var(--accent-dark);
}

/* =====================================================================
   BUTTONS
   ===================================================================== */

button {
  align-items: center;
  background: var(--accent);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: #ffffff;
  cursor: pointer;
  display: inline-flex;
  font: inherit;
  font-weight: 700;
  gap: 8px;
  justify-content: center;
  min-height: 38px;
  padding: 0 18px;
  transition: background var(--transition), border-color var(--transition), color var(--transition), transform var(--transition), box-shadow var(--transition);
  white-space: nowrap;
}

a.primary-button,
a.secondary-button,
a.danger-button,
a.ghost-button {
  align-items: center;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: inline-flex;
  font: inherit;
  font-weight: 700;
  gap: 8px;
  justify-content: center;
  min-height: 38px;
  padding: 0 18px;
  transition: background var(--transition), border-color var(--transition), color var(--transition), transform var(--transition), box-shadow var(--transition);
  white-space: nowrap;
}

button[hidden],
[hidden] {
  display: none !important;
}

button:hover {
  background: var(--accent-dark);
}

button:focus-visible {
  outline: 3px solid var(--ring);
  outline-offset: 2px;
}

button:active {
  transform: translateY(1px);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

button svg {
  flex-shrink: 0;
}

.primary-button {
  background: var(--accent);
}

.primary-button:hover {
  background: var(--accent-dark);
  box-shadow: 0 4px 14px rgba(11, 138, 130, 0.32);
}

.secondary-button {
  background: var(--surface);
  border-color: var(--line);
  color: var(--ink);
}

.secondary-button:hover {
  background: var(--surface-soft);
  border-color: var(--line-strong);
}

.secondary-button:disabled {
  background: var(--surface);
  color: var(--muted);
  cursor: not-allowed;
}

.secondary-button.loading {
  background: var(--ink);
  border-color: var(--ink);
  color: #ffffff;
}

.secondary-button.loading::before {
  animation: spin 800ms linear infinite;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-radius: 50%;
  border-top-color: #ffffff;
  content: "";
  height: 14px;
  width: 14px;
}

.ghost-button {
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--ink);
  font-weight: 700;
  min-height: 34px;
  padding: 0 12px;
}

.ghost-button:hover {
  background: var(--surface-soft);
  border-color: var(--line-strong);
}

.ghost-button:focus-visible {
  border-color: var(--accent);
  outline: 3px solid var(--ring);
}

.ghost-button:disabled {
  background: var(--surface);
  color: var(--muted);
  cursor: not-allowed;
}

.danger-button {
  background: var(--danger);
  border-color: var(--danger);
  color: #ffffff;
}

.danger-button:hover {
  background: #912018;
  border-color: #912018;
}

.danger-button.active {
  box-shadow: 0 0 0 3px rgba(180, 35, 24, 0.18);
}

.danger-button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.danger-button.loading::before {
  animation: spin 800ms linear infinite;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-radius: 50%;
  border-top-color: #ffffff;
  content: "";
  height: 14px;
  width: 14px;
}

.nav-button {
  text-decoration: none;
}

.log-trigger {
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  color: var(--ink);
  cursor: pointer;
  display: inline-flex;
  font: inherit;
  font-weight: 700;
  gap: 8px;
  min-height: 38px;
  padding: 0 14px;
  transition: background var(--transition), border-color var(--transition);
}

.log-trigger:hover {
  background: var(--surface-soft);
  border-color: var(--line-strong);
}

.log-trigger svg {
  color: var(--accent);
  flex-shrink: 0;
}

.filter-button {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--ink);
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  min-height: 32px;
  padding: 0 12px;
  transition: background var(--transition), border-color var(--transition), color var(--transition), transform var(--transition);
}

.filter-button:hover {
  background: var(--surface-soft);
  border-color: var(--line-strong);
}

.filter-button:active {
  transform: scale(0.98);
}

.filter-button.active {
  background: var(--ink);
  border-color: var(--ink);
  color: #ffffff;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* =====================================================================
   FORMS
   ===================================================================== */

.field {
  display: grid;
  gap: 6px;
}

label,
.field label {
  align-items: center;
  color: var(--muted);
  display: flex;
  font-size: 12px;
  font-weight: 700;
  gap: 6px;
  letter-spacing: 0.01em;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="date"],
input[type="number"],
select,
textarea {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--text);
  font: inherit;
  min-height: 38px;
  min-width: 220px;
  padding: 8px 11px;
  transition: border-color var(--transition), box-shadow var(--transition);
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="date"]:focus,
input[type="number"]:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--ring);
  outline: none;
}

textarea {
  line-height: 1.5;
  min-height: 82px;
  resize: vertical;
}

select {
  cursor: pointer;
}

input[type="checkbox"] {
  accent-color: var(--accent);
  height: 16px;
  width: 16px;
}

.toggle {
  align-items: center;
  cursor: pointer;
  display: inline-flex;
  font-weight: 700;
  gap: 9px;
  min-height: 38px;
}

.toggle span {
  color: var(--ink);
}

.compact-field input,
.compact-field select {
  min-width: 140px;
}

.secret-status {
  background: var(--surface-muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.04em;
  padding: 3px 8px;
  text-transform: uppercase;
}

.secret-status.configured {
  background: var(--ok-soft);
  border-color: var(--ok-soft-border);
  color: var(--ok);
}

/* =====================================================================
   APP MODAL SYSTEM
   ===================================================================== */

.app-modal {
  align-items: flex-start;
  display: flex;
  inset: 0;
  justify-content: center;
  overflow-y: auto;
  padding: 48px 24px;
  position: fixed;
  z-index: 50;
}

.app-modal[hidden] {
  display: none;
}

.app-modal-backdrop {
  background: rgba(15, 23, 42, 0.45);
  cursor: pointer;
  inset: 0;
  position: fixed;
  z-index: 0;
}

.app-modal-card {
  animation: modalIn 200ms cubic-bezier(0.16, 1, 0.3, 1);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  display: flex;
  flex-direction: column;
  margin-block: auto;
  max-height: calc(100vh - 96px);
  overflow: hidden;
  position: relative;
  width: 100%;
  z-index: 1;
}

.app-modal-card-small { max-width: 560px; }
.app-modal-card-medium { max-width: 820px; }
.app-modal-card-large { max-width: 1100px; }

@keyframes modalIn {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.app-modal-head {
  align-items: flex-start;
  border-bottom: 1px solid var(--line);
  display: flex;
  flex-shrink: 0;
  gap: 16px;
  justify-content: space-between;
  padding: 22px 28px 18px;
}

.app-modal-head-text {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.app-modal-head-text h2 {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.01em;
  line-height: 1.2;
  margin: 0;
}

.app-modal-head-text p {
  color: var(--muted);
  font-size: 13px;
  margin: 0;
}

.icon-close {
  align-items: center;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--muted);
  cursor: pointer;
  display: inline-flex;
  flex-shrink: 0;
  height: 36px;
  justify-content: center;
  padding: 0;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
  width: 36px;
}

.icon-close:hover {
  background: var(--surface-muted);
  border-color: var(--line-strong);
  color: var(--ink);
}

.icon-close:focus-visible {
  border-color: var(--accent);
  outline: 3px solid var(--ring);
}

.app-modal-body {
  overflow: visible;
  padding: 22px 28px;
}

.app-modal-body-scroll {
  overflow-y: auto;
}

.app-modal-footer {
  align-items: center;
  background: var(--surface-soft);
  border-top: 1px solid var(--line);
  display: flex;
  flex-shrink: 0;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: flex-end;
  padding: 16px 28px;
}

.app-modal-footer span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  margin-inline-end: auto;
}

/* =====================================================================
   USER SETTINGS (inside modal)
   ===================================================================== */

.user-settings-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.user-settings-grid .field input {
  min-width: 0;
  width: 100%;
}

/* =====================================================================
   MONITOR (inside modal)
   ===================================================================== */

.monitor-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

.monitor-enabled-toggle {
  background: var(--accent-soft);
  border: 1px solid var(--accent-soft-border);
  border-radius: var(--radius-md);
  color: var(--accent-dark);
  grid-column: 1 / -1;
  padding: 12px 14px;
}

.monitor-enabled-toggle span {
  color: var(--accent-dark);
  font-weight: 800;
}

.monitor-grid .field input,
.monitor-grid .field select {
  min-width: 0;
  width: 100%;
}

.monitor-workspaces-field {
  grid-column: 1 / -1;
}

.monitor-workspaces-field select {
  min-height: 92px;
}

.monitor-fixes {
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  display: grid;
  gap: 10px;
  grid-column: 1 / -1;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin: 0;
  padding: 14px 16px 12px;
}

.monitor-fixes legend {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.06em;
  padding: 0 6px;
  text-transform: uppercase;
}

/* =====================================================================
   WORKSPACE EDITOR (inside modal)
   ===================================================================== */

.workspace-editor-section {
  border-bottom: 1px solid var(--line);
  padding: 18px 0 22px;
}

.workspace-editor-section:first-child {
  padding-top: 0;
}

.workspace-editor-section:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.workspace-section-title {
  color: var(--ink);
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.02em;
  margin: 0 0 12px;
}

.workspace-editor-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.workspace-editor-grid .field {
  min-width: 0;
}

.workspace-editor-grid .field input {
  min-width: 0;
  width: 100%;
}

.workspace-name-field {
  grid-column: span 2;
}

.workspace-api-field {
  grid-column: span 2;
}

.workspace-class-field input {
  text-transform: uppercase;
}

.workspace-restriction-code-field {
  align-items: flex-start;
  display: flex;
  flex-direction: column;
}

.workspace-restriction-code-toggle {
  min-height: 42px;
  width: fit-content;
}

.workspace-editor-grid .workspace-restriction-code-toggle input {
  height: 16px;
  min-width: 16px;
  width: 16px;
}

.workspace-restriction-code-toggle strong {
  background: var(--surface-muted);
  border-radius: 999px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1;
  padding: 4px 7px;
}

.workspace-restriction-code-toggle:has(input:checked) strong {
  background: var(--accent-soft);
  color: var(--accent);
}

.workspace-status-desc-field,
.workspace-airline-mappings-field {
  grid-column: span 2;
}

.workspace-status-desc-field textarea,
.workspace-airline-mappings-field textarea {
  min-height: 74px;
  min-width: 0;
  width: 100%;
}

.workspace-detect-button {
  margin-top: 14px;
}

.workspace-rules {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.workspace-direction-filter {
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.workspace-rule-panel {
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.workspace-rule-head {
  align-items: center;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 8px;
  justify-content: space-between;
  padding: 12px 14px;
}

.workspace-rule-head h3 {
  font-size: 14px;
  margin: 0;
}

.workspace-rule-head p {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  margin: 4px 0 0;
}

.rule-column-head,
.direction-column-head {
  background: var(--surface-muted);
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  display: grid;
  font-size: 11px;
  font-weight: 800;
  gap: 8px;
  letter-spacing: 0.04em;
  padding: 8px 12px;
  text-transform: uppercase;
}

.rule-column-head {
  grid-template-columns: 72px 72px minmax(116px, 1fr) minmax(116px, 1fr) 68px;
}

.direction-column-head {
  grid-template-columns: minmax(120px, 1fr) 68px;
}

.rule-list,
.direction-list {
  display: grid;
  gap: 8px;
  padding: 10px;
}

.rule-row,
.direction-row {
  align-items: center;
  display: grid;
  gap: 8px;
}

.rule-row {
  grid-template-columns: 72px 72px minmax(116px, 1fr) minmax(116px, 1fr) 68px;
}

.direction-row {
  grid-template-columns: minmax(120px, 1fr) 68px;
}

.rule-row input,
.direction-row input {
  min-width: 0;
  width: 100%;
}

.rule-field,
.direction-field {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.rule-field span,
.direction-field span {
  color: var(--muted);
  display: none;
  font-size: 11px;
  font-weight: 800;
}

.rule-row .remove-rule,
.direction-row .remove-ignored-direction {
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--danger);
  min-height: 36px;
  padding: 0 10px;
}

.rule-row .remove-rule:hover,
.direction-row .remove-ignored-direction:hover {
  background: var(--danger-soft);
  border-color: var(--danger-soft-border);
}

.rule-empty {
  color: var(--muted);
  font-weight: 600;
  padding: 14px;
  text-align: center;
}

/* =====================================================================
   PROCESS PANEL
   ===================================================================== */

.process-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  margin-top: 16px;
  overflow: hidden;
}

.process-head {
  align-items: center;
  background: linear-gradient(180deg, var(--surface) 0%, var(--surface-soft) 100%);
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 16px;
  justify-content: space-between;
  padding: 14px 18px;
}

.process-head h2 {
  font-size: 16px;
  margin: 0;
}

.process-head-actions {
  align-items: center;
  display: flex;
  gap: 10px;
}

.process-state {
  align-items: center;
  display: flex;
  gap: 10px;
}

.process-state span {
  background: var(--accent-soft);
  border: 1px solid var(--accent-soft-border);
  border-radius: 999px;
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 800;
  max-width: 360px;
  overflow: hidden;
  padding: 5px 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.process-state strong {
  background: var(--ink);
  border-radius: var(--radius-xs);
  color: #ffffff;
  display: inline-grid;
  font-size: 13px;
  font-weight: 900;
  min-width: 52px;
  padding: 5px 8px;
  place-items: center;
}

.process-toggle {
  min-height: 32px;
  padding-inline: 12px;
  white-space: nowrap;
}

.process-stop {
  min-height: 32px;
  padding-inline: 14px;
  white-space: nowrap;
}

.process-progress {
  background: var(--surface-muted);
  height: 5px;
  overflow: hidden;
}

.process-progress span {
  background: linear-gradient(90deg, var(--accent) 0%, #2db8b0 55%, #e0a12b 100%);
  display: block;
  height: 100%;
  transition: width 240ms cubic-bezier(0.23, 1, 0.32, 1);
  width: 0%;
}

.process-terminal {
  background:
    radial-gradient(circle at top left, rgba(11, 138, 130, 0.18), transparent 35%),
    #0f1620;
  color: #d6e3dc;
  direction: ltr;
  font-family: Consolas, "SFMono-Regular", "Cascadia Code", monospace;
  font-size: 12px;
  height: 200px;
  line-height: 1.55;
  overflow-y: auto;
  padding: 12px 16px;
  scrollbar-gutter: stable;
}

.process-panel.collapsed .process-terminal {
  display: none;
}

.terminal-line {
  align-items: baseline;
  display: grid;
  gap: 9px;
  grid-template-columns: 72px 70px minmax(0, 1fr);
  min-height: 22px;
}

.terminal-time {
  color: #7f91a1;
  font-variant-numeric: tabular-nums;
}

.terminal-prompt {
  color: #69d3c8;
  font-weight: 800;
}

.terminal-prompt::before {
  color: #e0a12b;
  content: ">";
  margin-right: 5px;
}

.terminal-message {
  color: #dbe7e2;
  overflow-wrap: anywhere;
  text-align: right;
}

.terminal-info .terminal-message,
.terminal-info .terminal-prompt {
  color: #a9e0f6;
}

.terminal-success .terminal-message,
.terminal-success .terminal-prompt {
  color: #93e2ad;
}

.terminal-error .terminal-message,
.terminal-error .terminal-prompt {
  color: #ffb4ac;
}

.process-panel[data-status="completed"] .process-state strong {
  background: var(--ok);
}

.process-panel[data-status="cancelling"] .process-state strong,
.process-panel[data-status="cancelled"] .process-state strong {
  background: var(--warn);
}

.process-panel[data-status="failed"] .process-state strong {
  background: var(--danger);
}

/* =====================================================================
   METRICS
   ===================================================================== */

.metrics {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  margin-top: 16px;
}

.metric {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  min-height: 92px;
  padding: 16px 18px;
  position: relative;
  transition: transform var(--transition), box-shadow var(--transition);
}

.metric:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.metric.success {
  border-color: var(--ok-soft-border);
}

.metric.success::before {
  background: var(--ok);
}

.metric.warning {
  border-color: var(--warn-soft-border);
}

.metric.warning::before {
  background: var(--warn);
}

.metric.danger {
  border-color: var(--danger-soft-border);
}

.metric.danger::before {
  background: var(--danger);
}

.metric::before {
  background: var(--accent);
  border-radius: 999px;
  content: "";
  display: block;
  height: 4px;
  margin-bottom: 12px;
  width: 28px;
}

.metric strong {
  color: var(--ink);
  display: block;
  font-size: 28px;
  font-weight: 900;
  line-height: 1.1;
  margin-bottom: 6px;
}

.metric span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

/* =====================================================================
   WORKSPACE / PROJECT
   ===================================================================== */

.workspace {
  margin-top: 16px;
}

.project {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  margin-bottom: 16px;
  overflow: hidden;
}

.project-header {
  align-items: center;
  background: linear-gradient(180deg, var(--surface) 0%, var(--surface-soft) 100%);
  border-bottom: 1px solid var(--line);
  column-gap: 16px;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  padding: 10px 16px;
  row-gap: 8px;
}

.project-heading {
  display: flex;
  align-items: baseline;
  flex-shrink: 0;
  gap: 8px;
}

.project-heading .section-label {
  color: var(--muted);
  font-size: 10px;
}

.project-header h2 {
  font-size: 15px;
  font-weight: 800;
  margin: 0;
}

.project-side {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  justify-content: flex-end;
  margin-inline-start: auto;
}

.project-actions {
  align-items: center;
  color: var(--muted);
  display: inline-flex;
  flex-wrap: wrap;
  font-size: 12px;
  font-weight: 700;
  gap: 8px;
}

.project-actions-info {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.delete-mode-note {
  background: var(--danger-soft);
  border: 1px solid var(--danger-soft-border);
  border-radius: 999px;
  color: #912018;
  font-size: 11px;
  font-weight: 800;
  padding: 3px 9px;
}

.project-summary {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
}

.project-summary span {
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-size: 12px;
  padding: 3px 9px;
}

.project-summary strong {
  color: var(--ink);
  font-weight: 800;
}

.empty,
.error {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  color: var(--muted);
  padding: 32px;
  text-align: center;
}

.error {
  color: var(--danger);
}

.loading-state {
  align-items: center;
  display: grid;
  gap: 8px;
  justify-items: center;
}

.loading-state strong {
  color: var(--ink);
  font-size: 15px;
}

.loading-state small {
  color: var(--muted);
  font-size: 12px;
}

.loading-spinner {
  animation: spin 800ms linear infinite;
  border: 3px solid rgba(37, 99, 235, 0.16);
  border-radius: 999px;
  border-top-color: var(--accent);
  display: inline-block;
  height: 24px;
  width: 24px;
}

.clear-row {
  color: var(--ok);
  font-weight: 700;
  padding: 22px;
  text-align: center;
}

/* =====================================================================
   GRIDS / TABLES
   ===================================================================== */

.table-wrap {
  direction: ltr;
  overflow-x: auto;
}

.sync-grid-wrap {
  direction: rtl;
  overflow-x: auto;
}

.sync-grid {
  direction: rtl;
  min-width: 1116px;
  width: 100%;
}

.deals-grid {
  direction: rtl;
  min-width: 1180px;
  width: 100%;
}

.grid-header,
.grid-row {
  display: grid;
  grid-template-columns: 92px minmax(96px, 1.1fr) minmax(100px, 1fr) minmax(86px, 0.85fr) minmax(72px, 0.75fr) minmax(82px, 0.8fr) 88px 132px minmax(94px, 0.9fr) 76px 58px minmax(104px, 0.85fr);
}

.deals-grid-header,
.deals-grid-row {
  display: grid;
  grid-template-columns: 92px minmax(140px, 0.95fr) 94px minmax(100px, 0.85fr) minmax(148px, 1fr) 70px 72px 118px 142px 118px minmax(112px, 0.9fr);
}

.grid-header > div,
.grid-row > div,
.deals-grid-header > div,
.deals-grid-row > div {
  align-items: center;
  border-bottom: 1px solid var(--line);
  display: flex;
  min-height: 44px;
  min-width: 0;
  overflow: hidden;
  padding: 10px 10px;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.grid-header > div,
.deals-grid-header > div {
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.grid-header > .revivo-zone,
.grid-header > .alp-zone,
.deals-grid-header > .revivo-zone,
.deals-grid-header > .alp-zone {
  align-items: flex-start;
  flex-direction: column;
  justify-content: center;
}

.grid-header span,
.deals-grid-header span {
  color: var(--ink);
  direction: ltr;
  display: block;
  font-size: 11px;
  line-height: 1.1;
  margin-bottom: 2px;
}

.grid-row:hover > div,
.deals-grid-row:hover > div {
  background: var(--surface-muted);
}

.flight-row,
.deal-row {
  cursor: pointer;
  transition: background var(--transition);
}

.row-number {
  color: var(--muted);
  font-weight: 800;
  justify-content: center;
  text-align: center;
}

.select-all-cell {
  justify-content: center;
}

.select-project-button,
.select-deals-project-button,
.select-ideas-project-button {
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-xs);
  color: var(--ink);
  display: inline-flex;
  font-size: 11px;
  font-weight: 800;
  gap: 5px;
  justify-content: center;
  line-height: 1;
  min-height: 28px;
  padding: 0 8px;
}

.select-project-button:hover,
.select-deals-project-button:hover,
.select-ideas-project-button:hover {
  background: var(--surface-soft);
  border-color: var(--line-strong);
}

.select-project-button[aria-pressed="true"],
.select-deals-project-button[aria-pressed="true"],
.select-ideas-project-button[aria-pressed="true"] {
  background: var(--accent-soft);
  border-color: var(--accent-soft-border);
  color: var(--accent-dark);
}

.select-project-button:disabled,
.select-deals-project-button:disabled,
.select-ideas-project-button:disabled {
  background: var(--surface-muted);
  color: var(--muted);
  cursor: not-allowed;
}

.select-all-box {
  align-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  display: inline-flex;
  font-size: 11px;
  height: 14px;
  justify-content: center;
  line-height: 1;
  width: 14px;
}

.select-project-button[aria-pressed="true"] .select-all-box,
.select-deals-project-button[aria-pressed="true"] .select-all-box,
.select-ideas-project-button[aria-pressed="true"] .select-all-box {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

.row-select-cell {
  gap: 7px;
}

.row-selector {
  cursor: pointer;
  flex: 0 0 auto;
  margin: 0;
}

.row-selector:disabled {
  cursor: not-allowed;
  opacity: 0.35;
}

table {
  border-collapse: collapse;
  direction: rtl;
  min-width: 1080px;
  table-layout: fixed;
  width: 100%;
}

.sync-table .col-status { width: 136px; }
.sync-table .col-route { width: 132px; }
.sync-table .col-date { width: 106px; }
.sync-table .col-time { width: 88px; }
.sync-table .col-flight { width: 96px; }
.sync-table .col-small { width: 72px; }
.sync-table .col-class-seats { width: 112px; }
.sync-table .col-id { width: 96px; }
.sync-table .col-confidence { width: 108px; }

th,
td {
  border-bottom: 1px solid var(--line);
  overflow: hidden;
  padding: 10px 10px;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

th {
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

th span {
  color: var(--ink);
  direction: ltr;
  display: block;
  font-size: 11px;
  line-height: 1.1;
  margin-bottom: 2px;
}

/* Zones */
.revivo-zone { background-color: var(--info-soft); }
.alp-zone { background-color: #f1f9f1; }
.control-zone { background-color: var(--warn-soft); }

td.revivo-zone,
td.alp-zone,
td.control-zone,
.grid-row > .revivo-zone,
.grid-row > .alp-zone,
.grid-row > .control-zone {
  border-right: 1px solid var(--line);
}

/* =====================================================================
   BADGES / STATUS
   ===================================================================== */

.badge {
  border-radius: 999px;
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  padding: 3px 9px;
}

.deal-status-cell {
  align-items: center;
  display: inline-flex;
  flex-wrap: wrap;
  gap: 5px;
  max-width: 100%;
  min-width: 0;
  overflow: hidden;
}

.availability-note-pill {
  background: var(--surface-muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink);
  display: inline-block;
  font-size: 11px;
  font-weight: 800;
  max-width: 100%;
  min-width: 0;
  overflow: hidden;
  padding: 2px 8px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.synced,
.deleted {
  background: var(--ok-soft);
  color: var(--ok);
}

.past_date {
  background: var(--surface-muted);
  border: 1px solid var(--line);
  color: var(--muted);
}

.inventory_mismatch,
.airline_mismatch,
.time_mismatch,
.block_low_inventory,
.previous_block_relevant,
.price_mismatch,
.one_way_penalty_missing,
.flight_number_mismatch,
.missing_flight_number,
.price_range,
.price_missing {
  background: var(--warn-soft);
  color: var(--warn);
}

.missing,
.ambiguous,
.duplicate_deal,
.alp_error,
.missing_flight {
  background: var(--danger-soft);
  color: var(--danger);
}

.badge.ready {
  background: var(--accent-soft);
  border: 1px solid var(--accent-soft-border);
  color: var(--accent-dark);
}

.badge.created {
  background: var(--ok-soft);
  border: 1px solid var(--ok-soft-border);
  color: var(--ok);
}

.badge.create_error {
  background: var(--danger-soft);
  border: 1px solid var(--danger-soft-border);
  color: var(--danger);
}

.badge.existing_missing_flight_numbers {
  background: var(--warn-soft);
  border: 1px solid var(--warn-soft-border);
  color: var(--warn);
}

.badge.has-error {
  background: var(--danger-soft);
  color: var(--danger);
}

.code,
.number {
  direction: ltr;
  display: inline-block;
  font-family: "Segoe UI", Arial, sans-serif;
  text-align: left;
}

.number {
  min-width: 28px;
  text-align: center;
}

td.number {
  font-weight: 700;
}

.availability-pair,
.block-summary {
  align-items: center;
  direction: ltr;
  display: inline-flex;
  gap: 4px;
  justify-content: center;
  max-width: 100%;
}

.availability-main,
.block-count {
  font-weight: 800;
}

.availability-total {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.positive {
  color: var(--ok);
  font-weight: 800;
}

.negative {
  color: var(--danger);
  font-weight: 800;
}

.danger-text {
  color: var(--danger);
}

/* =====================================================================
   BLOCK POPOVER
   ===================================================================== */

.block-cell {
  justify-content: center;
  overflow: visible !important;
  position: relative;
}

.block-code-shell {
  align-items: center;
  direction: ltr;
  display: inline-flex;
  gap: 2px;
}

.block-code-button {
  background: transparent;
  border: 0;
  color: var(--accent-dark);
  cursor: pointer;
  direction: ltr;
  font: inherit;
  font-weight: 800;
  min-height: 0;
  padding: 0 2px;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.block-code-button:hover,
.block-code-button[aria-expanded="true"] {
  background: transparent;
  color: var(--accent);
}

.block-code-text {
  direction: ltr;
  font-weight: 800;
}

.block-popover {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  color: var(--text);
  direction: rtl;
  min-width: 250px;
  padding: 8px;
  position: absolute;
  right: 8px;
  text-align: right;
  top: calc(100% - 2px);
  white-space: normal;
  z-index: 12;
}

.block-popover-title {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  padding: 4px 6px 8px;
}

.block-popover-row {
  align-items: center;
  border: 1px solid transparent;
  border-radius: var(--radius-xs);
  display: grid;
  gap: 8px;
  grid-template-columns: minmax(70px, 1fr) 72px 72px;
  min-height: 34px;
  padding: 6px 8px;
}

.block-popover-row.selected {
  background: var(--accent-soft);
  border-color: var(--accent-soft-border);
}

.block-popover-row span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.block-popover-row .code {
  color: var(--ink);
  font-weight: 800;
}

/* =====================================================================
   DRAWERS (Log, Profile)
   ===================================================================== */

.drawer-backdrop {
  background: rgba(15, 23, 42, 0.45);
  inset: 0;
  position: fixed;
  z-index: 20;
}

.update-log-drawer {
  animation: drawerIn 240ms cubic-bezier(0.16, 1, 0.3, 1);
  background: var(--surface);
  box-shadow: var(--shadow-xl);
  display: flex;
  flex-direction: column;
  height: 100vh;
  max-width: 1040px;
  overflow: hidden;
  position: fixed;
  right: 0;
  top: 0;
  width: min(1040px, 96vw);
  z-index: 21;
}

.update-log-drawer[hidden] {
  display: none;
}

@keyframes drawerIn {
  from { transform: translateX(40px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

.update-log-panel {
  background: var(--surface);
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.log-header {
  align-items: center;
  background: linear-gradient(180deg, var(--surface) 0%, var(--surface-soft) 100%);
  border-bottom: 1px solid var(--line);
  display: flex;
  flex-shrink: 0;
  gap: 16px;
  justify-content: space-between;
  padding: 18px 24px;
  position: sticky;
  top: 0;
  z-index: 2;
}

.log-header h2 {
  font-size: 18px;
  margin: 0;
}

.log-header-actions {
  display: flex;
  gap: 8px;
}

.refresh-log,
.close-log {
  min-height: 34px;
}

.update-log {
  flex: 1;
  overflow: auto;
  padding: 0 4px 24px;
}

.update-log:not(.update-log-drawer .update-log) {
  overflow-x: auto;
}

.log-empty {
  color: var(--muted);
  font-weight: 600;
  padding: 24px;
  text-align: center;
}

.log-grid {
  min-width: 980px;
  width: 100%;
}

.log-grid-header,
.log-grid-row {
  display: grid;
  grid-template-columns: 140px 104px 78px 112px 132px 140px minmax(180px, 1fr);
}

.log-grid-header > div,
.log-grid-row > div {
  align-items: center;
  border-bottom: 1px solid var(--line);
  display: flex;
  min-height: 42px;
  min-width: 0;
  overflow: hidden;
  padding: 9px 10px;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.log-grid-header > div {
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.log-grid-row:hover > div {
  background: var(--surface-muted);
}

.log-time {
  color: var(--muted);
  direction: ltr;
  font-weight: 700;
}

.log-grid-row small {
  color: var(--muted);
  display: inline-block;
  margin-right: 6px;
}

.log-grid-row > div:last-child {
  align-items: flex-start;
  flex-direction: column;
  gap: 5px;
  overflow: visible;
  white-space: normal;
}

.inventory-change {
  align-items: center;
  direction: ltr;
  display: inline-flex;
  gap: 7px;
}

.inventory-change b:last-child {
  color: var(--ok);
}

.log-entry-type {
  background: var(--ok-soft);
  border: 1px solid var(--ok-soft-border);
  border-radius: 999px;
  color: var(--ok);
  display: inline-flex;
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
  padding: 6px 9px;
}

.log-entry-type.error {
  background: var(--danger-soft);
  border-color: var(--danger-soft-border);
  color: var(--danger);
}

.log-entry-type.warn {
  background: var(--warn-soft);
  border-color: var(--warn-soft-border);
  color: var(--warn);
}

.log-entry-type.info {
  background: var(--info-soft);
  border-color: var(--info-soft-border);
  color: var(--info);
}

.log-entry-type.success {
  background: var(--ok-soft);
  border-color: var(--ok-soft-border);
  color: var(--ok);
}

.log-action-text {
  color: var(--ok);
  font-weight: 800;
}

.log-meta {
  color: var(--muted);
  font-weight: 700;
}

.log-error-text {
  color: var(--danger);
  font-weight: 800;
  overflow-wrap: anywhere;
}

.log-error-change b:last-child {
  color: var(--danger);
}

.log-block-transition {
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  display: grid;
  gap: 0;
  min-width: 0;
  overflow: hidden;
  width: 100%;
}

.block-transition-head {
  align-items: center;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  padding: 10px 12px;
}

.block-transition-arrow {
  align-items: center;
  background: var(--accent-soft);
  border: 1px solid var(--accent-soft-border);
  border-radius: 999px;
  color: var(--accent-dark);
  display: inline-flex;
  font-size: 12px;
  font-weight: 800;
  gap: 8px;
  padding: 4px 12px;
}

.block-transition-code {
  direction: ltr;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.block-transition-icon {
  flex-shrink: 0;
  height: 10px;
  width: 18px;
}

.block-transition-summary {
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
}

.deal-log-details {
  display: grid;
  gap: 0;
  list-style: none;
  margin: 0;
  padding: 0;
}

.deal-log-details li {
  align-items: center;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  column-gap: 14px;
  display: flex;
  flex-wrap: wrap;
  font-size: 12px;
  padding: 8px 12px;
  row-gap: 4px;
}

.deal-log-details li:last-child {
  border-bottom: 0;
}

.deal-log-details li:nth-child(even) {
  background: rgba(255, 255, 255, 0.5);
}

.deal-log-price {
  margin-inline-start: auto;
}

.deal-log-id {
  color: var(--muted);
  font-weight: 700;
  white-space: nowrap;
}

.deal-log-id small {
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  margin-inline-end: 2px;
  text-transform: uppercase;
}

.deal-log-id .code {
  color: var(--ink);
  font-size: 12px;
  font-weight: 800;
}

.deal-log-route {
  color: var(--ink);
  font-weight: 700;
}

.deal-log-route .code {
  font-size: 12px;
  font-weight: 700;
}

.deal-log-date {
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 700;
}

.deal-log-price {
  align-items: center;
  direction: ltr;
  display: inline-flex;
  gap: 6px;
  justify-content: flex-end;
}

.price-old {
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 700;
  text-decoration: line-through;
  text-decoration-color: rgba(100, 116, 139, 0.5);
}

.price-arrow {
  color: var(--muted);
  flex-shrink: 0;
  height: 10px;
  width: 18px;
}

.price-new {
  color: var(--ok);
  font-size: 13px;
  font-weight: 900;
}

.deal-log-details .deal-log-error {
  background: var(--danger-soft);
}

.deal-log-details .deal-log-error .price-new {
  color: var(--danger);
}

.deal-log-error-text {
  color: var(--danger);
  font-size: 11.5px;
  font-style: normal;
  font-weight: 700;
  grid-column: 1 / -1;
  overflow-wrap: anywhere;
}

.log-time-transition {
  align-items: center;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--ink);
  display: inline-flex;
  font-size: 12px;
  font-weight: 800;
  gap: 8px;
  padding: 5px 10px;
}

.log-time-transition small {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.log-time-transition .code {
  color: var(--muted);
  direction: ltr;
  font-weight: 700;
}

.log-time-transition strong.code {
  color: var(--ok);
  font-weight: 900;
}

/* =====================================================================
   FLIGHT PROFILE
   ===================================================================== */

.flight-profile {
  animation: drawerInLeft 240ms cubic-bezier(0.16, 1, 0.3, 1);
  background: var(--surface-soft);
  border-right: 1px solid var(--line);
  box-shadow: var(--shadow-xl);
  height: 100vh;
  left: 0;
  max-width: 760px;
  overflow-y: auto;
  position: fixed;
  top: 0;
  width: min(760px, 96vw);
  z-index: 21;
}

@keyframes drawerInLeft {
  from { transform: translateX(-40px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

.profile-shell {
  display: grid;
  gap: 18px;
  padding: 18px 24px 32px;
}

.profile-top {
  align-items: center;
  background: var(--surface-soft);
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 14px;
  justify-content: space-between;
  margin: -18px -24px 0;
  padding: 16px 24px;
  position: sticky;
  top: 0;
  z-index: 2;
}

.profile-content {
  display: grid;
  gap: 16px;
}

/* Flight profile sections */
.fp-hero {
  background: linear-gradient(180deg, var(--surface) 0%, #f1f7f6 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  display: grid;
  gap: 14px;
  padding: 20px 22px;
}

.fp-hero-main {
  display: grid;
  gap: 6px;
}

.fp-hero-eyebrow {
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.fp-hero-route {
  align-items: center;
  color: var(--ink);
  display: inline-flex;
  font-weight: 800;
  gap: 14px;
  letter-spacing: 0.02em;
}

.fp-airport {
  font-size: 30px;
  font-weight: 900;
  line-height: 1;
}

.fp-arrow {
  color: var(--accent);
  flex-shrink: 0;
  height: 16px;
  width: 32px;
}

.fp-hero-meta {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin: 0;
}

.fp-meta-item {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  display: grid;
  gap: 4px;
  padding: 12px 14px;
}

.fp-meta-item dt {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.fp-meta-item dd {
  font-size: 15px;
  font-weight: 800;
  margin: 0;
}

.fp-hero-badges {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.fp-chip {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
  padding: 4px 11px;
}

.fp-compare {
  align-items: stretch;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  display: grid;
  gap: 0;
  grid-template-columns: 1fr auto 1fr;
  overflow: hidden;
}

.fp-compare-side {
  display: grid;
  gap: 4px;
  padding: 18px 20px;
}

.fp-side-revivo {
  background: var(--info-soft);
}

.fp-side-alp {
  background: #f1f9f1;
}

.fp-side-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.fp-side-value {
  color: var(--ink);
  font-size: 26px;
  font-weight: 900;
  line-height: 1.1;
  word-break: break-word;
}

.fp-side-sub {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.fp-compare-delta {
  align-items: center;
  border-left: 1px solid var(--line);
  border-right: 1px solid var(--line);
  display: grid;
  gap: 4px;
  justify-items: center;
  min-width: 130px;
  padding: 18px 20px;
  text-align: center;
}

.fp-delta-label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.fp-delta-value {
  font-size: 28px;
  font-weight: 900;
  line-height: 1;
}

.fp-delta-caption {
  font-size: 12px;
  font-weight: 800;
}

.fp-delta-success {
  background: var(--ok-soft);
}

.fp-delta-success .fp-delta-value,
.fp-delta-success .fp-delta-caption {
  color: var(--ok);
}

.fp-delta-warning {
  background: var(--warn-soft);
}

.fp-delta-warning .fp-delta-value,
.fp-delta-warning .fp-delta-caption {
  color: var(--warn);
}

.fp-delta-neutral .fp-delta-value,
.fp-delta-neutral .fp-delta-caption {
  color: var(--muted);
}

.fp-panels {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.fp-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  display: grid;
  gap: 12px;
  padding: 16px;
  position: relative;
}

.fp-panel::before {
  border-top-left-radius: var(--radius-lg);
  border-top-right-radius: var(--radius-lg);
  content: "";
  height: 3px;
  left: 0;
  position: absolute;
  right: 0;
  top: 0;
}

.fp-panel-revivo::before {
  background: var(--info);
}

.fp-panel-alp::before {
  background: var(--accent);
}

.fp-panel-head {
  align-items: center;
  display: flex;
  gap: 10px;
  justify-content: space-between;
}

.fp-panel-head h3 {
  font-size: 15px;
  margin: 0;
}

.fp-panel-tag {
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  padding: 3px 10px;
}

.fp-edit-link {
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
}

.fp-edit-link:hover {
  text-decoration: underline;
}

.fp-stats {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin: 0;
}

.fp-stat {
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  display: grid;
  gap: 4px;
  padding: 10px 12px;
}

.fp-stat dt {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.fp-stat dd {
  font-size: 15px;
  font-weight: 800;
  margin: 0;
  overflow-wrap: anywhere;
}

.fp-stat-hero {
  background: var(--surface);
  border-color: var(--info-soft-border);
}

.fp-panel-alp .fp-stat-hero {
  border-color: var(--accent-soft-border);
}

.fp-stat-hero dd {
  font-size: 20px;
}

.fp-stat-wide {
  grid-column: 1 / -1;
}

.fp-stat-wide dd {
  font-size: 13px;
  white-space: normal;
}

.fp-subhead {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.fp-blocks {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  display: grid;
  gap: 12px;
  padding: 16px;
}

.fp-blocks-head {
  align-items: center;
  display: flex;
  gap: 10px;
  justify-content: space-between;
}

.fp-blocks-head h3 {
  font-size: 15px;
  margin: 0;
}

.fp-blocks-scroll {
  overflow-x: auto;
}

.fp-blocks-table {
  border-collapse: collapse;
  direction: rtl;
  min-width: 100%;
  table-layout: auto;
  width: 100%;
}

.fp-blocks-table th,
.fp-blocks-table td {
  border-bottom: 1px solid var(--line);
  padding: 8px 10px;
  text-align: right;
}

.fp-blocks-table th {
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.fp-col-num { font-variant-numeric: tabular-nums; }
.fp-col-pnr,
.fp-col-internal {
  direction: ltr;
}

.fp-strong {
  font-weight: 800;
}

.soft-note {
  background: var(--warn-soft);
  border: 1px solid var(--warn-soft-border);
  border-radius: var(--radius-sm);
  color: var(--warn);
  padding: 10px 12px;
}

.soft-inline {
  color: var(--muted);
}

/* =====================================================================
   DEAL-RELATED COMPONENTS
   ===================================================================== */

/* SCENARIO LEG — structured leg display inside scenarios table */
.scenario-leg {
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  display: grid;
  gap: 5px;
  min-width: 180px;
  padding: 9px 11px;
  text-align: start;
}

.scenario-leg.is-unavailable {
  background: var(--danger-soft);
  border-color: var(--danger-soft-border);
}

.scenario-leg.is-missing {
  align-items: center;
  background: var(--surface-muted);
  border-style: dashed;
  color: var(--muted);
  display: flex;
  font-size: 12px;
  font-style: italic;
  font-weight: 700;
  justify-content: center;
  min-height: 60px;
  text-align: center;
}

.scenario-leg-top {
  align-items: baseline;
  display: flex;
  gap: 10px;
  justify-content: space-between;
}

.scenario-leg-route {
  color: var(--ink);
  direction: ltr;
  font-size: 14px;
  font-weight: 900;
  letter-spacing: 0.02em;
  line-height: 1.1;
}

.scenario-leg-flight {
  color: var(--accent-dark);
  direction: ltr;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.scenario-leg.is-unavailable .scenario-leg-flight {
  color: var(--danger);
}

.scenario-leg-when {
  align-items: baseline;
  color: var(--ink);
  direction: ltr;
  display: flex;
  font-size: 12px;
  font-weight: 700;
  gap: 8px;
  justify-content: space-between;
}

.scenario-leg-when .code {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.scenario-leg-time {
  color: var(--accent-dark);
  font-weight: 800;
}

.scenario-leg-foot {
  align-items: center;
  border-top: 1px dashed var(--line);
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: space-between;
  margin-top: 1px;
  padding-top: 6px;
}

.scenario-leg.is-unavailable .scenario-leg-foot {
  border-top-color: var(--danger-soft-border);
}

.scenario-leg-block {
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  display: inline-flex;
  font-size: 11px;
  font-weight: 700;
  gap: 4px;
  padding: 2px 9px;
}

.scenario-leg-block .code {
  color: var(--ink);
  font-weight: 800;
}

.scenario-leg-avail {
  background: var(--accent-soft);
  border: 1px solid var(--accent-soft-border);
  border-radius: 999px;
  color: var(--accent-dark);
  font-size: 11px;
  font-weight: 800;
  padding: 2px 10px;
}

.scenario-leg-avail.is-empty {
  background: var(--danger-soft);
  border-color: var(--danger-soft-border);
  color: var(--danger);
}

.deal-note,
.idea-note {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.deal-notes,
.deal-notes-list {
  display: grid;
  gap: 4px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.deal-notes-item {
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-xs);
  font-size: 12px;
  padding: 4px 8px;
}

.deal-alert-panel {
  background: var(--warn-soft);
  border: 1px solid var(--warn-soft-border);
  border-radius: var(--radius-md);
  display: grid;
  gap: 8px;
  padding: 12px 14px;
}

.deal-alert-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.deal-alert-chip {
  background: #ffffff;
  border: 1px solid var(--warn-soft-border);
  border-radius: 999px;
  color: var(--warn);
  font-size: 11px;
  font-weight: 800;
  padding: 3px 9px;
}

.deal-alert-note {
  color: var(--warn);
  font-size: 12px;
  font-weight: 700;
}

.deal-scenarios-table {
  border-collapse: collapse;
  direction: rtl;
  min-width: 920px;
  table-layout: auto;
  width: 100%;
}

.deal-scenarios-table thead th {
  background: var(--surface-soft);
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.04em;
  padding: 10px 12px;
  text-align: right;
  text-transform: uppercase;
  white-space: nowrap;
}

.deal-scenarios-table tbody td {
  border-bottom: 1px solid var(--line);
  padding: 10px 12px;
  text-align: right;
  vertical-align: middle;
}

.deal-scenarios-table tbody tr:last-child td {
  border-bottom: 0;
}

.deal-scenarios-table tbody tr:hover td {
  background: var(--surface-soft);
}

.deal-scenarios-table .fp-col-num {
  direction: ltr;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  text-align: center;
  white-space: nowrap;
}

.deal-scenarios-table .fp-col-num.fp-strong {
  color: var(--accent-dark);
  font-size: 14px;
  font-weight: 900;
}

.deal-scenarios-table td:first-child {
  font-weight: 800;
  white-space: nowrap;
}

/* MINI-TABLE — small flat table inside profile panels */
.mini-table-wrap {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.mini-table {
  border-collapse: collapse;
  direction: rtl;
  table-layout: auto;
  width: 100%;
}

.mini-table thead th {
  background: var(--surface-soft);
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.04em;
  padding: 8px 12px;
  text-align: right;
  text-transform: uppercase;
  white-space: nowrap;
}

.mini-table tbody td {
  border-bottom: 1px solid var(--line);
  font-size: 12px;
  padding: 8px 12px;
  text-align: right;
}

.mini-table tbody tr:last-child td {
  border-bottom: 0;
}

.mini-table tbody tr:hover td {
  background: var(--surface-soft);
}

.mini-table .number {
  direction: ltr;
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  text-align: end;
}

.mini-table .code {
  color: var(--accent-dark);
  font-weight: 800;
}

.time-alert-panel {
  background: var(--warn-soft);
  border: 1px solid var(--warn-soft-border);
  border-radius: var(--radius-md);
  color: var(--warn);
  padding: 12px 14px;
}

.leg-availability {
  align-items: center;
  display: inline-flex;
  gap: 4px;
}

/* =====================================================================
   DEAL-IDEAS PAGE EXTRAS
   ===================================================================== */

.template-manager-toolbar {
  align-items: end;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  display: flex;
  gap: 12px;
  margin-bottom: 18px;
  padding: 12px 14px;
}

.template-manager-toolbar .field {
  flex: 1;
  min-width: 0;
}

.template-manager-toolbar select {
  min-width: 0;
  width: 100%;
}

.deal-template-form {
  display: grid;
  gap: 14px;
}

.deal-template-form input,
.deal-template-form select,
.deal-template-form textarea {
  min-width: 0;
  width: 100%;
}

.template-feature-control {
  display: flex;
  gap: 8px;
}

.template-feature-control select {
  flex: 1;
}

.template-feature-refresh {
  min-height: 40px;
  white-space: nowrap;
}

.template-message {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-align: start;
}

.template-choice-backdrop {
  background: rgba(15, 23, 42, 0.45);
  inset: 0;
  position: fixed;
  z-index: 50;
}

.template-choice-backdrop[hidden] {
  display: none;
}

.template-choice-dialog {
  align-items: center;
  display: flex;
  inset: 0;
  justify-content: center;
  padding: 32px 24px;
  position: fixed;
  z-index: 51;
}

.template-choice-dialog[hidden] {
  display: none;
}

.template-choice-panel {
  animation: modalIn 200ms cubic-bezier(0.16, 1, 0.3, 1);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  display: grid;
  gap: 0;
  max-height: calc(100vh - 64px);
  max-width: 720px;
  overflow: hidden;
  width: 100%;
}

.template-choice-head {
  align-items: center;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 12px;
  justify-content: space-between;
  padding: 20px 24px 16px;
}

.template-choice-head h2 {
  font-size: 18px;
  margin: 0;
}

.template-choice-body {
  display: grid;
  gap: 14px;
  padding: 20px 24px;
}

.template-choice-preview {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.template-choice-preview > div {
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  display: grid;
  gap: 6px;
  padding: 12px;
}

.template-choice-preview span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.template-choice-preview pre {
  color: var(--ink);
  font-family: Consolas, "SFMono-Regular", monospace;
  font-size: 12px;
  line-height: 1.5;
  margin: 0;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.template-choice-actions {
  align-items: center;
  background: var(--surface-soft);
  border-top: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: flex-end;
  padding: 14px 24px;
}

.template-choice-actions span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  margin-inline-end: auto;
}

.creation-log-grid {
  direction: rtl;
  min-width: 1280px;
  width: 100%;
}

.creation-log-grid-header,
.creation-log-grid-row {
  display: grid;
  grid-template-columns: 152px 104px 96px minmax(150px, 1fr) 96px minmax(160px, 1fr) minmax(180px, 1.2fr);
}

.creation-log-grid-header > div,
.creation-log-grid-row > div {
  align-items: center;
  border-bottom: 1px solid var(--line);
  display: flex;
  min-height: 48px;
  min-width: 0;
  overflow: hidden;
  padding: 10px 10px;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.creation-log-grid-header > div {
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.creation-log-grid-row:hover > div {
  background: var(--surface-muted);
}

/* =====================================================================
   DEAL IDEAS — CARD LIST
   ===================================================================== */

.ideas-list {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  padding: 16px;
}

.idea-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  display: grid;
  gap: 14px;
  overflow: hidden;
  padding: 14px 16px;
  position: relative;
  transition: border-color var(--transition), box-shadow var(--transition), transform var(--transition);
}

.idea-card::before {
  background: var(--line);
  content: "";
  inset-inline-start: 0;
  position: absolute;
  top: 0;
  bottom: 0;
  width: 4px;
}

.idea-card.is-ready {
  border-color: var(--accent-soft-border);
}

.idea-card.is-ready::before {
  background: var(--accent);
}

.idea-card.is-created {
  border-color: var(--ok-soft-border);
  background: linear-gradient(180deg, #ffffff 0%, var(--ok-soft) 220%);
}

.idea-card.is-created::before {
  background: var(--ok);
}

.idea-card.is-error {
  border-color: var(--danger-soft-border);
  background: linear-gradient(180deg, #ffffff 0%, var(--danger-soft) 240%);
}

.idea-card.is-error::before {
  background: var(--danger);
}

.idea-card.is-warning {
  border-color: var(--warn-soft-border);
  background: linear-gradient(180deg, #ffffff 0%, var(--warn-soft) 240%);
}

.idea-card.is-warning::before {
  background: var(--warn);
}

.idea-card.is-locked {
  background: var(--surface-soft);
  opacity: 0.94;
}

.idea-card.is-locked::before {
  background: var(--muted-soft);
}

.idea-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

/* HEAD: select + status/type + price */
.idea-card-head {
  align-items: center;
  display: grid;
  gap: 8px;
  grid-template-columns: auto 1fr auto;
}

.idea-card-select {
  align-items: center;
  background: var(--surface-muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex;
  font-weight: 800;
  gap: 8px;
  padding: 4px 12px 4px 8px;
  transition: background var(--transition), border-color var(--transition);
  user-select: none;
}

.idea-card-select:hover {
  background: var(--surface);
  border-color: var(--line-strong);
}

.idea-card-select input {
  cursor: pointer;
  height: 16px;
  margin: 0;
  width: 16px;
}

.idea-card-select input:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.idea-card-num {
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.idea-card-tags {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.idea-card-type {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.idea-card-price {
  align-items: flex-end;
  display: grid;
  gap: 2px;
  justify-items: end;
  text-align: end;
}

.idea-card-price strong {
  color: var(--accent-dark);
  font-size: 18px;
  font-weight: 900;
  letter-spacing: -0.01em;
  line-height: 1.1;
}

.idea-card-price small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

/* ROUTE */
.idea-card-route {
  border-block: 1px solid var(--line);
  display: grid;
  gap: 6px;
  padding: 12px 0;
}

.idea-card.is-locked .idea-card-route {
  border-color: var(--line);
}

.idea-card-airports {
  align-items: center;
  color: var(--ink);
  display: inline-flex;
  flex-wrap: wrap;
  font-weight: 800;
  gap: 8px;
  justify-content: flex-start;
}

.airport-code {
  color: var(--ink);
  font-size: 22px;
  font-weight: 900;
  letter-spacing: 0.02em;
  line-height: 1;
}

.airport-arrow {
  color: var(--accent);
  flex-shrink: 0;
  height: 14px;
  width: 28px;
}

.airport-return-mark {
  color: var(--muted);
  font-size: 16px;
  font-weight: 800;
}

.airport-return {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.idea-card-dates {
  align-items: center;
  color: var(--ink);
  display: inline-flex;
  flex-wrap: wrap;
  font-size: 13px;
  font-weight: 700;
  gap: 8px;
}

.idea-date {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.idea-date-arrow {
  color: var(--muted);
}

.idea-date-nights {
  background: var(--accent-soft);
  border-radius: 999px;
  color: var(--accent-dark);
  font-size: 11px;
  font-weight: 800;
  margin-inline-start: 4px;
  padding: 2px 9px;
}

.idea-date-oneway {
  background: var(--surface-muted);
  border-radius: 999px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  padding: 2px 9px;
}

/* LEGS */
.idea-card-legs {
  display: grid;
  gap: 8px;
  grid-template-columns: 1fr;
}

.idea-card-legs.has-return {
  grid-template-columns: 1fr 1fr;
}

.idea-leg-card {
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  display: grid;
  gap: 4px;
  padding: 10px 12px;
  position: relative;
}

.idea-leg-card[data-leg="outbound"] {
  border-color: var(--info-soft-border);
}

.idea-leg-card[data-leg="return"] {
  border-color: var(--accent-soft-border);
}

.idea-leg-head {
  align-items: center;
  display: flex;
  gap: 8px;
  justify-content: space-between;
}

.idea-leg-label {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.idea-leg-card[data-leg="outbound"] .idea-leg-label {
  color: var(--info);
}

.idea-leg-card[data-leg="return"] .idea-leg-label {
  color: var(--accent-dark);
}

.idea-leg-tag {
  background: var(--warn-soft);
  border: 1px solid var(--warn-soft-border);
  border-radius: 999px;
  color: var(--warn);
  font-size: 10px;
  font-weight: 800;
  padding: 2px 7px;
}

.idea-leg-flight {
  align-items: baseline;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: space-between;
}

.idea-leg-num {
  color: var(--ink);
  direction: ltr;
  font-size: 14px;
  font-weight: 900;
}

.idea-leg-time {
  color: var(--ink);
  direction: ltr;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  font-weight: 800;
}

.idea-leg-route {
  color: var(--muted);
  direction: ltr;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.idea-leg-card.is-empty {
  align-items: center;
  background: var(--surface-muted);
  border-style: dashed;
  display: flex;
  justify-content: space-between;
}

.idea-leg-empty {
  color: var(--muted-soft);
  font-size: 16px;
  font-weight: 700;
}

/* FOOT */
.idea-card-foot {
  display: grid;
  gap: 10px;
}

.idea-card-info-grid {
  display: grid;
  gap: 8px;
  grid-template-columns: 1fr 1fr;
}

.idea-card-info-item {
  align-items: baseline;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  display: flex;
  gap: 8px;
  justify-content: space-between;
  padding: 6px 10px;
}

.idea-card-info-label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.idea-card-info-value {
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
}

.idea-card-availability {
  color: var(--accent-dark);
  font-size: 15px;
  font-weight: 900;
}

.idea-card-notes {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.idea-card-note {
  background: var(--surface-muted);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--ink);
  font-size: 11.5px;
  font-weight: 700;
  padding: 4px 9px;
}

.idea-card.is-error .idea-card-note {
  background: var(--danger-soft);
  border-color: var(--danger-soft-border);
  color: var(--danger);
}

.idea-card.is-warning .idea-card-note {
  background: var(--warn-soft);
  border-color: var(--warn-soft-border);
  color: var(--warn);
}

.idea-card.is-created .idea-card-note {
  background: var(--ok-soft);
  border-color: var(--ok-soft-border);
  color: var(--ok);
}

.idea-card-note-link {
  color: var(--accent-dark);
  font-weight: 800;
  text-decoration: none;
}

.idea-card-note-link:hover {
  text-decoration: underline;
}

.creation-deal-link {
  color: var(--accent-dark);
  font-weight: 800;
  text-decoration: none;
}

.creation-deal-link:hover {
  text-decoration: underline;
}

.creation-log-legs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

/* =====================================================================
   LOGIN PAGE
   ===================================================================== */

.login-page {
  align-items: center;
  display: flex;
  justify-content: center;
  min-height: 100vh;
  padding: 32px 16px;
}

.login-shell {
  margin: auto;
  max-width: 420px;
  width: 100%;
}

.login-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  display: grid;
  gap: 20px;
  padding: 32px 32px 28px;
}

.login-brand {
  display: grid;
  gap: 6px;
  justify-items: center;
  text-align: center;
}

.login-brand .brand-mark {
  margin-bottom: 4px;
}

.login-brand h1 {
  font-size: 24px;
  font-weight: 800;
  margin: 0;
}

.login-brand p {
  color: var(--muted);
  font-size: 13px;
  margin: 0;
}

.login-form {
  display: grid;
  gap: 14px;
}

.login-form input {
  min-width: 0;
  width: 100%;
}

.login-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 4px;
}

.login-actions span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  margin-inline-end: auto;
  text-align: start;
}

.login-actions button {
  min-width: 120px;
}

/* =====================================================================
   RESPONSIVE — Tablet (≤ 1100px)
   ===================================================================== */

@media (max-width: 1100px) {
  main {
    padding: 20px 24px 40px;
  }

  .topbar-inner {
    flex-wrap: wrap;
    gap: 14px;
    padding: 14px 20px;
  }

  .toolbar {
    gap: 12px;
  }

  .toolbar-actions {
    margin-inline-start: 0;
  }

  .workspace-editor-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .workspace-rules {
    grid-template-columns: 1fr;
  }

  .fp-panels {
    grid-template-columns: 1fr;
  }
}

/* =====================================================================
   RESPONSIVE — Tablet portrait / Large phone (≤ 820px)
   ===================================================================== */

@media (max-width: 820px) {
  html, body {
    overflow-x: hidden;
  }

  body {
    font-size: 14px;
  }

  main {
    padding: 16px 14px 80px;
  }

  /* TOPBAR — Compact two-row mobile layout */
  .topbar {
    background: var(--surface);
    backdrop-filter: none;
    position: static;
  }

  .topbar-inner {
    align-items: stretch;
    flex-direction: column;
    gap: 12px;
    min-height: 0;
    padding: 12px 14px;
    padding-top: max(12px, env(safe-area-inset-top));
  }

  .brand {
    align-items: center;
    gap: 10px;
    justify-content: space-between;
  }

  .brand-mark {
    height: 36px;
    width: 36px;
  }

  .brand-text {
    flex: 1;
    gap: 1px;
  }

  .brand-text h1 {
    font-size: 16px;
    white-space: normal;
  }

  .brand-text p {
    display: none;
  }

  /* Topbar-side - TOTP gets the room, status shrinks to a small chip */
  .topbar-side {
    align-items: stretch;
    display: grid;
    gap: 8px;
    grid-template-columns: 1fr auto;
  }

  .totp-card {
    grid-column: 1 / 2;
    padding: 6px 12px 7px;
  }

  .totp-card strong {
    font-size: 15px;
  }

  .status {
    align-items: center;
    display: inline-flex;
    grid-column: 2 / 3;
    justify-content: center;
    min-width: 0;
    padding: 6px 12px;
    white-space: nowrap;
  }

  .topbar-actions {
    display: flex;
    grid-column: 1 / -1;
    gap: 6px;
  }

  .topbar-actions > * {
    flex: 1 1 auto;
  }

  .icon-button {
    justify-content: center;
    min-height: 44px;
    padding: 0 10px;
  }

  .icon-button-label {
    font-size: 12px;
  }

  .icon-button-badge {
    display: none;
  }

  .user-menu {
    flex: 0 0 auto;
  }

  .user-chip {
    min-height: 44px;
    padding: 3px;
  }

  .user-chip-text {
    display: none;
  }

  .user-chip svg {
    display: none;
  }

  .user-menu-popover {
    inset-inline-end: 0;
    min-width: 200px;
  }

  /* TOOLBAR */
  .toolbar {
    flex-direction: column;
    align-items: stretch;
    border-radius: var(--radius-md);
    padding: 12px;
  }

  .toolbar > *,
  .toolbar-group {
    width: 100%;
  }

  .toolbar-workspace {
    align-items: stretch;
    flex-direction: column;
  }

  .workspace-field {
    width: 100%;
  }

  .workspace-field select {
    min-width: 0;
    width: 100%;
  }

  .toolbar-button-group {
    display: flex;
    gap: 6px;
    width: 100%;
  }

  .toolbar-button-group .ghost-button {
    flex: 1 1 0;
    justify-content: center;
    min-height: 42px;
  }

  .workspace-switcher {
    display: flex;
    min-height: 44px;
    padding: 4px;
    width: 100%;
  }

  .workspace-tab {
    flex: 1 1 0;
    font-size: 14px;
    min-height: 36px;
  }

  .toolbar-actions {
    display: grid;
    gap: 8px;
    grid-template-columns: 1fr 1fr;
  }

  .toolbar-actions > * {
    flex: unset;
    justify-content: center;
    min-height: 44px;
  }

  .toolbar-actions .primary-button {
    grid-column: 1 / -1;
  }

  /* FORMS - avoid iOS zoom */
  input[type="text"],
  input[type="email"],
  input[type="password"],
  input[type="date"],
  input[type="number"],
  select,
  textarea {
    font-size: 16px;
    max-width: 100%;
    min-height: 44px;
    min-width: 0;
    width: 100%;
  }

  /* MODALS - full screen on mobile */
  .app-modal {
    overflow: hidden;
    padding: 0;
  }

  .app-modal-card {
    animation: modalInMobile 240ms cubic-bezier(0.16, 1, 0.3, 1);
    border-radius: 0;
    box-shadow: none;
    height: 100dvh;
    margin: 0;
    max-height: 100dvh;
    max-width: 100%;
    width: 100%;
  }

  @keyframes modalInMobile {
    from { transform: translateY(20px); opacity: 0.7; }
    to { transform: translateY(0); opacity: 1; }
  }

  .app-modal-card-small,
  .app-modal-card-medium,
  .app-modal-card-large {
    max-width: 100%;
  }

  .app-modal-head {
    padding: 16px 18px 14px;
    padding-top: max(16px, env(safe-area-inset-top));
    position: sticky;
    top: 0;
    z-index: 2;
  }

  .app-modal-head-text h2 {
    font-size: 18px;
  }

  .app-modal-head-text p {
    font-size: 12px;
  }

  .app-modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 18px;
  }

  .app-modal-body-scroll {
    overflow-y: auto;
  }

  .app-modal-footer {
    background: var(--surface);
    border-top: 1px solid var(--line);
    padding: 12px 18px;
    padding-bottom: max(12px, env(safe-area-inset-bottom));
    position: sticky;
    bottom: 0;
    z-index: 2;
  }

  .app-modal-footer > * {
    flex: 1 1 auto;
  }

  .app-modal-footer span {
    flex: 1 1 100%;
    margin-inline-end: 0;
    text-align: start;
  }

  .app-modal-footer button {
    min-height: 44px;
  }

  /* User settings */
  .user-settings-grid {
    grid-template-columns: 1fr;
  }

  /* Monitor */
  .monitor-grid {
    grid-template-columns: 1fr;
  }

  .monitor-fixes {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  /* Workspace editor */
  .workspace-editor-section {
    padding: 16px 0 18px;
  }

  .workspace-section-title {
    font-size: 13px;
  }

  .workspace-editor-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .workspace-name-field,
  .workspace-api-field,
  .workspace-airline-mappings-field,
  .workspace-status-desc-field {
    grid-column: 1 / -1;
  }

  .rule-row,
  .direction-row {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    grid-template-columns: 1fr 1fr;
    padding: 10px;
    row-gap: 8px;
  }

  .direction-row {
    grid-template-columns: 1fr;
  }

  .rule-field span,
  .direction-field span {
    display: block;
  }

  .rule-row .remove-rule,
  .direction-row .remove-ignored-direction {
    grid-column: 1 / -1;
    min-height: 40px;
    width: 100%;
  }

  .rule-column-head,
  .direction-column-head {
    display: none;
  }

  /* METRICS */
  .metrics {
    gap: 8px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .metric {
    min-height: 72px;
    padding: 12px 14px;
  }

  .metric strong {
    font-size: 22px;
  }

  /* PROJECT */
  .project-header {
    align-items: stretch;
    flex-direction: column;
    gap: 8px;
    padding: 10px 12px;
  }

  .project-heading {
    align-items: baseline;
    gap: 6px;
  }

  .project-header h2 {
    font-size: 14px;
  }

  .project-side {
    align-items: stretch;
    margin-inline-start: 0;
  }

  .project-actions {
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: space-between;
    width: 100%;
  }

  .project-actions-info {
    font-size: 11.5px;
  }

  .project-summary {
    flex-wrap: wrap;
    gap: 5px;
    justify-content: flex-start;
    width: 100%;
  }

  .project-summary span {
    flex: 0 1 auto;
    font-size: 11.5px;
    padding: 3px 8px;
  }

  /* TABLES & GRIDS - touch scroll with shadow indicators */
  .sync-grid-wrap,
  .table-wrap,
  .update-log,
  .fp-blocks-scroll {
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
    overflow-x: auto;
    scrollbar-gutter: stable;
  }

  .sync-grid-wrap,
  .table-wrap {
    background:
      linear-gradient(to left, var(--surface) 30%, rgba(255,255,255,0)) 0 0,
      linear-gradient(to right, var(--surface) 30%, rgba(255,255,255,0)) 100% 0,
      linear-gradient(to left, rgba(15,23,42,0.08), rgba(15,23,42,0)) 0 0,
      linear-gradient(to right, rgba(15,23,42,0.08), rgba(15,23,42,0)) 100% 0;
    background-attachment: local, local, scroll, scroll;
    background-repeat: no-repeat;
    background-size: 32px 100%, 32px 100%, 16px 100%, 16px 100%;
  }

  .grid-row > div,
  .grid-header > div,
  .deals-grid-row > div,
  .deals-grid-header > div,
  .creation-log-grid-row > div,
  .creation-log-grid-header > div,
  .log-grid-row > div,
  .log-grid-header > div {
    min-height: 48px;
  }

  .row-select-cell {
    justify-content: center;
  }

  .select-project-button,
  .select-deals-project-button,
  .select-ideas-project-button,
  .filter-button {
    min-height: 36px;
  }

  /* DEAL TEMPLATE */
  .deal-template-form {
    grid-template-columns: 1fr;
  }

  .template-feature-control {
    flex-direction: column;
  }

  .template-manager-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .template-manager-toolbar button {
    width: 100%;
  }

  /* TEMPLATE CHOICE */
  .template-choice-dialog {
    padding: 0;
  }

  .template-choice-panel {
    border-radius: 0;
    height: 100dvh;
    max-height: 100dvh;
    max-width: 100%;
    width: 100%;
  }

  .template-choice-head {
    position: sticky;
    top: 0;
    z-index: 2;
  }

  .template-choice-body {
    flex: 1;
    overflow-y: auto;
  }

  .template-choice-actions {
    bottom: 0;
    padding: 12px 18px;
    padding-bottom: max(12px, env(safe-area-inset-bottom));
    position: sticky;
    z-index: 2;
  }

  .template-choice-actions span {
    flex: 1 1 100%;
    text-align: start;
  }

  .template-choice-actions button {
    flex: 1;
    min-height: 44px;
  }

  .template-choice-preview {
    grid-template-columns: 1fr;
  }

  /* DRAWERS */
  .update-log-drawer,
  .flight-profile {
    box-shadow: none;
    height: 100dvh;
    left: 0;
    max-width: none;
    right: 0;
    width: 100vw;
  }

  .update-log-drawer {
    animation: drawerInUp 240ms cubic-bezier(0.16, 1, 0.3, 1);
  }

  @keyframes drawerInUp {
    from { transform: translateY(40px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
  }

  .log-header {
    padding: 14px 16px;
    padding-top: max(14px, env(safe-area-inset-top));
  }

  .log-header-actions {
    display: grid;
    gap: 6px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
  }

  .log-header-actions button {
    min-height: 40px;
    width: 100%;
  }

  .log-grid-header,
  .log-grid-row,
  .creation-log-grid-header,
  .creation-log-grid-row {
    min-width: 980px;
  }

  /* DEAL IDEAS — single column card stack on mobile */
  .ideas-list {
    gap: 10px;
    grid-template-columns: 1fr;
    padding: 12px;
  }

  .idea-card {
    padding: 12px 14px;
  }

  .idea-card-head {
    grid-template-columns: auto 1fr;
    row-gap: 8px;
  }

  .idea-card-price {
    align-items: flex-end;
    grid-column: 1 / -1;
    border-top: 1px dashed var(--line);
    padding-top: 8px;
    flex-direction: row;
    justify-content: space-between;
  }

  .idea-card-price strong {
    font-size: 20px;
  }

  .idea-card-route {
    padding: 10px 0;
  }

  .airport-code {
    font-size: 20px;
  }

  .idea-card-legs.has-return {
    grid-template-columns: 1fr;
  }

  .idea-leg-card {
    padding: 9px 11px;
  }

  .idea-leg-flight {
    justify-content: space-between;
  }

  .idea-card-info-grid {
    grid-template-columns: 1fr 1fr;
  }

  /* FLIGHT PROFILE — mobile-friendly */
  .flight-profile {
    background: var(--bg);
  }

  .profile-shell {
    gap: 12px;
    padding: 0 14px 80px;
  }

  .profile-top {
    align-items: center;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    box-shadow: var(--shadow-sm);
    display: flex;
    gap: 10px;
    justify-content: space-between;
    margin: 0 -14px 14px;
    padding: 12px 14px;
    padding-top: max(12px, env(safe-area-inset-top));
    position: sticky;
    top: 0;
    z-index: 5;
  }

  .profile-top .section-label {
    color: var(--accent);
    font-size: 11px;
  }

  .profile-top .close-profile {
    background: var(--surface-soft);
    border: 1px solid var(--line);
    font-size: 13px;
    font-weight: 800;
    min-height: 38px;
    padding: 0 16px;
  }

  /* HERO — compact route card */
  .fp-hero {
    background: linear-gradient(135deg, #ffffff 0%, var(--accent-soft) 100%);
    border: 1px solid var(--accent-soft-border);
    padding: 16px 14px;
  }

  .fp-hero-eyebrow {
    font-size: 11px;
  }

  .fp-hero-route {
    gap: 10px;
    justify-content: center;
  }

  .fp-airport {
    font-size: 28px;
  }

  .fp-arrow {
    height: 14px;
    width: 26px;
  }

  .fp-hero-meta {
    gap: 8px;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .fp-meta-item {
    padding: 8px 10px;
  }

  .fp-meta-item dt {
    font-size: 10px;
  }

  .fp-meta-item dd {
    font-size: 13px;
  }

  .fp-hero-badges {
    gap: 6px;
    justify-content: center;
  }

  /* COMPARE — stacked with delta as separator */
  .fp-compare {
    grid-template-columns: 1fr;
    overflow: hidden;
  }

  .fp-compare-side {
    padding: 14px 16px;
  }

  .fp-side-value {
    font-size: 24px;
  }

  .fp-compare-delta {
    background: var(--surface-muted);
    border-bottom: 1px solid var(--line);
    border-left: 0;
    border-right: 0;
    border-top: 1px solid var(--line);
    flex-direction: row;
    gap: 8px;
    grid-template-columns: 1fr auto;
    justify-content: center;
    padding: 8px 16px;
  }

  .fp-compare-delta .fp-delta-label {
    font-size: 11px;
    margin-inline-end: auto;
  }

  .fp-delta-value {
    font-size: 18px;
  }

  .fp-delta-caption {
    font-size: 11px;
  }

  /* PANELS — single column compact */
  .fp-panels {
    grid-template-columns: 1fr;
  }

  .fp-panel {
    padding: 14px;
  }

  .fp-panel-head {
    gap: 8px;
  }

  .fp-panel-head h3 {
    font-size: 14px;
  }

  .fp-stats {
    gap: 6px;
    grid-template-columns: 1fr 1fr;
  }

  .fp-stat {
    padding: 8px 10px;
  }

  .fp-stat dt {
    font-size: 10px;
  }

  .fp-stat dd {
    font-size: 13px;
  }

  .fp-stat-hero dd {
    font-size: 17px;
  }

  /* BLOCKS — keep horizontal scroll but make table easier to read */
  .fp-blocks {
    padding: 14px;
  }

  .fp-blocks-head h3 {
    font-size: 14px;
  }

  .fp-blocks-table th,
  .fp-blocks-table td {
    font-size: 12px;
    padding: 8px 10px;
  }

  /* Deal scenarios table */
  .deal-scenarios-table th,
  .deal-scenarios-table td {
    font-size: 12px;
    padding: 8px 10px;
  }

  /* PROCESS PANEL */
  .process-head {
    align-items: stretch;
    flex-direction: column;
    gap: 10px;
    padding: 12px 14px;
  }

  .process-head-actions {
    align-items: stretch;
    flex-direction: column;
    gap: 8px;
  }

  .process-state {
    justify-content: space-between;
    width: 100%;
  }

  .process-state span {
    flex: 1;
    max-width: none;
  }

  .process-toggle {
    width: 100%;
  }

  .process-terminal {
    font-size: 11.5px;
    height: 230px;
    padding: 11px 12px;
  }

  .terminal-line {
    grid-template-columns: 64px 62px minmax(0, 1fr);
  }

  /* TOGGLES inside modals/panels */
  .toggle {
    align-items: center;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    min-height: 44px;
    padding: 8px 12px;
  }

  .monitor-enabled-toggle {
    background: var(--accent-soft);
  }

  /* LOGIN */
  .login-page {
    align-items: stretch;
    padding: 0;
  }

  .login-shell {
    margin: 0;
    max-width: none;
  }

  .login-panel {
    border: 0;
    border-radius: 0;
    box-shadow: none;
    margin: auto;
    max-width: 480px;
    padding: 28px 24px;
    padding-top: max(40px, env(safe-area-inset-top));
    padding-bottom: max(28px, env(safe-area-inset-bottom));
    width: 100%;
  }
}

/* =====================================================================
   RESPONSIVE — Phone portrait (≤ 480px)
   ===================================================================== */

@media (max-width: 480px) {
  main {
    padding: 14px 12px 80px;
  }

  .topbar-inner {
    padding: 10px 12px;
  }

  .brand-text h1 {
    font-size: 15px;
  }

  .totp-card span,
  .totp-card em {
    font-size: 9px;
  }

  .totp-card strong {
    font-size: 14px;
  }

  .status {
    font-size: 11px;
  }

  .topbar-actions {
    flex-wrap: nowrap;
  }

  .icon-button-label {
    display: none;
  }

  .icon-button {
    flex: 1 1 0;
    min-width: 0;
    padding: 0 8px;
  }

  .user-menu {
    flex: 0 0 auto;
  }

  .toolbar {
    padding: 10px;
  }

  .toolbar-actions {
    grid-template-columns: 1fr;
  }

  .toolbar-actions > * {
    grid-column: 1 / -1;
  }

  .toolbar-button-group {
    flex-direction: column;
  }

  .metrics {
    grid-template-columns: 1fr 1fr;
  }

  .metric {
    padding: 12px;
  }

  .metric strong {
    font-size: 20px;
  }

  .metric span {
    font-size: 11px;
  }

  .project-header {
    padding: 12px;
  }

  .project-header h2 {
    font-size: 16px;
  }

  .project-summary span {
    font-size: 12px;
    padding: 5px 8px;
  }

  .fp-hero {
    padding: 14px;
  }

  .fp-airport {
    font-size: 22px;
  }

  .fp-hero-meta,
  .fp-stats {
    grid-template-columns: 1fr;
  }

  .fp-side-value {
    font-size: 20px;
  }

  .app-modal-head {
    padding: 14px 16px 12px;
  }

  .app-modal-head-text h2 {
    font-size: 17px;
  }

  .app-modal-body {
    padding: 14px 16px;
  }

  .app-modal-footer {
    padding: 10px 16px;
    padding-bottom: max(10px, env(safe-area-inset-bottom));
  }

  .workspace-editor-grid {
    grid-template-columns: 1fr;
  }

  .monitor-fixes {
    grid-template-columns: 1fr;
  }

  .rule-row,
  .direction-row {
    grid-template-columns: 1fr;
  }

  .login-brand h1 {
    font-size: 22px;
  }
}

/* =====================================================================
   TOUCH-SPECIFIC ENHANCEMENTS
   ===================================================================== */

@media (hover: none) and (pointer: coarse) {
  /* Larger tap targets, no hover transforms */
  button:active,
  .icon-button:active,
  .ghost-button:active,
  .filter-button:active {
    transform: none;
  }

  .grid-row:hover > div,
  .deals-grid-row:hover > div,
  .deal-ideas-grid-row:hover > div,
  .creation-log-grid-row:hover > div,
  .log-grid-row:hover > div {
    background: transparent;
  }

  .grid-row:active > div,
  .deals-grid-row:active > div,
  .deal-ideas-grid-row:active > div {
    background: var(--surface-muted);
  }

  .metric:hover {
    transform: none;
  }
}

/* =====================================================================
   ORDERS — v2 REDESIGN (2026-05) — refined / less bulky
   Cleaner hierarchy, hero strip, sectioned settings, polished cards.
   ===================================================================== */

.orders-main {
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(0, 1fr);
}

/* Settings tab contains the 2-col grid for engine + revivo */
.orders-settings-row {
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr);
}

@media (max-width: 1180px) {
  .orders-settings-row {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* ---- HERO ---- */

.orders-hero {
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  display: grid;
  gap: 12px;
  grid-column: 1 / -1;
  grid-template-columns: minmax(0, 1fr) auto auto;
  padding: 8px 16px;
  position: relative;
}

.orders-hero::before {
  background: var(--accent);
  border-radius: var(--radius-md) 0 0 var(--radius-md);
  content: "";
  inset: 0 auto 0 0;
  opacity: 0.85;
  position: absolute;
  width: 3px;
}
[dir="rtl"] .orders-hero::before {
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  inset: 0 0 0 auto;
}

.orders-hero-info {
  display: grid;
  gap: 1px;
  min-width: 0;
}

.hero-eyebrow {
  color: var(--accent);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.orders-hero-info h2 {
  color: var(--ink);
  font-size: 15px;
  font-weight: 800;
  letter-spacing: -0.005em;
  line-height: 1.2;
  margin: 0;
}

/* Engine switch in the hero */

.hero-engine-switch {
  align-items: center;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 10px;
  cursor: pointer;
  display: inline-flex;
  gap: 10px;
  min-height: 38px;
  padding: 4px 10px;
  position: relative;
  transition: background 160ms, border-color 160ms, box-shadow 160ms;
  user-select: none;
}

.hero-engine-switch:hover {
  border-color: var(--accent-soft-border);
}

.hero-engine-switch input {
  height: 1px;
  inset: 0;
  margin: 0;
  opacity: 0;
  pointer-events: none;
  position: absolute;
  width: 1px;
}

.hero-engine-track {
  background: var(--line-strong);
  border-radius: 999px;
  display: inline-block;
  flex: none;
  height: 22px;
  position: relative;
  transition: background 200ms cubic-bezier(0.4, 0, 0.2, 1);
  width: 40px;
}

.hero-engine-knob {
  background: #ffffff;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.18);
  height: 16px;
  position: absolute;
  right: 3px;
  top: 3px;
  transition: transform 220ms cubic-bezier(0.4, 0, 0.2, 1);
  width: 16px;
}

.hero-engine-switch input:checked ~ .hero-engine-track {
  background: var(--ok);
}

.hero-engine-switch input:checked ~ .hero-engine-track .hero-engine-knob {
  transform: translateX(-18px);
}

.hero-engine-switch input:focus-visible ~ .hero-engine-track {
  box-shadow: 0 0 0 3px var(--ring);
}

.hero-engine-copy {
  display: grid;
  gap: 0;
  line-height: 1.2;
}

.hero-engine-copy strong {
  color: var(--ink);
  font-size: 12.5px;
  font-weight: 800;
}

.hero-engine-state {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.hero-engine-state .state-on,
.hero-engine-state .state-off {
  display: none;
}

.hero-engine-switch:has(input:checked) .state-on {
  color: var(--ok);
  display: inline;
}

.hero-engine-switch:not(:has(input:checked)) .state-off {
  color: var(--muted);
  display: inline;
}

.orders-hero-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

/* ---- CARDS (settings + revivo + ledger) ---- */

.orders-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.orders-settings-card {
  grid-column: 1;
}

#revivoCredentialsForm.orders-credentials-card {
  grid-column: 2;
}

.orders-card-head {
  align-items: center;
  background: var(--surface-soft);
  border-bottom: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: space-between;
  padding: 12px 16px;
}

.orders-card-head h2 {
  color: var(--ink);
  font-size: 14.5px;
  font-weight: 800;
  letter-spacing: -0.003em;
  margin: 1px 0 0;
}

.orders-card-head .section-label {
  font-size: 10px;
  letter-spacing: 0.08em;
}

.orders-card-body {
  display: grid;
  gap: 16px;
  padding: 16px;
}

/* ---- SUBSECTIONS inside settings card ---- */

.orders-subsection {
  display: grid;
  gap: 10px;
}

.orders-subsection + .orders-subsection {
  border-top: 1px solid var(--line);
  padding-top: 16px;
}

.subsection-head {
  align-items: flex-end;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: space-between;
}

.subsection-head > div:first-child,
.profile-toolbar > div:first-child {
  display: grid;
  gap: 1px;
}

.subsection-eyebrow {
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.orders-subsection h3,
.profile-toolbar h3 {
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
  margin: 0;
}

/* ---- FIELD GRIDS (replaces the dense orders-settings-grid) ---- */

.orders-fields-grid {
  display: grid;
  gap: 10px 12px;
}

.orders-fields-grid.orders-grid-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.orders-fields-grid.orders-grid-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.orders-fields-grid.orders-grid-4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.orders-fields-grid .orders-field-wide {
  grid-column: span 2;
}

.orders-fields-grid .orders-field-wide-3 {
  grid-column: span 3;
}

/* ---- FIELDSETS ---- */

.orders-fieldset {
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 10px 12px 12px;
}

.orders-fieldset legend {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 3px 10px;
  text-transform: uppercase;
}

.orders-fieldset .field,
.orders-credentials-body .field,
.orders-subsection .field {
  min-width: 0;
}

.orders-fieldset .field input,
.orders-fieldset .field select,
.orders-fieldset .field textarea,
.orders-credentials-body .field input,
.orders-subsection .field input,
.orders-subsection .field select {
  background: var(--surface);
  min-width: 0;
  width: 100%;
}

/* ---- REVIVO CREDENTIALS card ---- */

.orders-credentials-head {
  flex-direction: column;
  align-items: stretch;
}

.orders-credentials-head .connection-status {
  margin-top: 4px;
  width: 100%;
}

.orders-credentials-body {
  gap: 14px;
}

.revivo-doc-status {
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 600;
  margin: 0;
  padding: 10px 12px;
}

.orders-credentials-body .orders-actions {
  margin-top: 4px;
}

/* ---- METRIC CARDS upgraded with icon slot + accent border ---- */

.orders-metrics {
  gap: 8px;
}

.metric-card {
  align-items: start;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  box-shadow: none;
  display: grid;
  gap: 2px 10px;
  grid-template-columns: 28px 1fr;
  grid-template-rows: auto auto auto;
  min-height: 0;
  padding: 10px 12px;
  position: relative;
  transition: border-color 160ms, background 160ms;
}

.metric-card:hover {
  background: var(--surface-soft);
  border-color: var(--line-strong);
  transform: none;
}

.metric-card-icon {
  align-items: center;
  background: var(--surface-soft);
  border-radius: 6px;
  color: var(--muted);
  display: inline-flex;
  grid-row: 1 / span 3;
  height: 28px;
  justify-content: center;
  width: 28px;
}

.metric-card-icon svg {
  height: 14px;
  width: 14px;
}

.metric-card .metric-card-label,
.metric-card .metric-card-helper {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.3;
}

.metric-card .metric-card-label {
  font-weight: 700;
  letter-spacing: 0.01em;
}

.metric-card .metric-card-value {
  color: var(--ink);
  font-size: 18px;
  font-weight: 800;
  line-height: 1.1;
  margin-top: 1px;
}

.metric-card-accent { border-color: var(--line); }

.metric-card-ok .metric-card-icon { background: var(--ok-soft); color: var(--ok); }
.metric-card-warn .metric-card-icon { background: var(--warn-soft); color: var(--warn); }
.metric-card-danger .metric-card-icon { background: var(--danger-soft); color: var(--danger); }
.metric-card-info .metric-card-icon { background: var(--info-soft); color: var(--info); }
.metric-card-accent .metric-card-icon { background: var(--accent-soft); color: var(--accent); }

.metric-card-accent { border-color: var(--accent-soft-border); }
.metric-card-ok .metric-card-value { color: var(--ok); }
.metric-card-warn .metric-card-value { color: var(--warn); }
.metric-card-danger .metric-card-value { color: var(--danger); }
.metric-card-info .metric-card-value { color: var(--info); }

.profitability-metrics {
  border-bottom: 1px solid var(--line);
  gap: 8px;
  padding: 12px 16px;
}

.profitability-tools {
  align-items: end;
}

.profitability-filter-group input[type="date"] {
  min-width: 132px;
}

.orders-table td.col-profit {
  font-weight: 800;
}

.orders-table td.col-profit small {
  color: var(--muted);
  display: block;
  font-size: 11px;
  font-weight: 600;
  margin-top: 3px;
}

.orders-table td.col-profit.profit-positive bdi {
  color: var(--ok);
}

.orders-table td.col-profit.profit-negative bdi,
.orders-table td.col-profit.profit-error bdi {
  color: var(--danger);
}

.orders-table td.col-profit.profit-muted bdi {
  color: var(--muted);
}

/* ---- LEDGER head v2 ---- */

.orders-ledger.orders-card {
  border-radius: var(--radius-md);
}

.orders-ledger > .orders-ledger-head {
  align-items: center;
  background: var(--surface-soft);
  border-bottom: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: space-between;
  padding: 10px 16px;
}

.orders-ledger-title {
  display: grid;
  gap: 1px;
}

.orders-ledger-title h2 {
  font-size: 14.5px;
  font-weight: 800;
  margin: 0;
}

.orders-ledger-title .section-label {
  font-size: 10px;
  letter-spacing: 0.08em;
}

.orders-ledger-tools {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.order-status-refresh {
  align-items: center;
  background: transparent;
  border: none;
  display: inline-flex;
  flex-wrap: nowrap;
  gap: 10px;
  height: 34px;
  margin: 0;
  padding: 0;
}

.order-status-refresh span {
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: 0.01em;
}

.order-status-refresh .compact-action {
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink);
  font-size: 11.5px;
  font-weight: 600;
  gap: 6px;
  height: 28px;
  min-height: 0;
  padding: 0 12px;
  transition: background var(--transition), border-color var(--transition);
}

.order-status-refresh .compact-action:hover {
  background: var(--surface-soft);
  border-color: var(--line-strong);
}

.order-status-refresh .compact-action svg {
  color: var(--muted);
}

.orders-ledger-head .orders-filter-group {
  gap: 8px;
}

.orders-ledger-head .orders-filter-group .field {
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  display: flex;
  flex-direction: row;
  gap: 0;
  height: 34px;
  padding: 0 4px 0 4px;
}

.orders-ledger-head .orders-filter-group .field label {
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 700;
  margin: 0;
  padding: 0 10px 0 6px;
  white-space: nowrap;
}

.orders-ledger-head .orders-filter-group .field input,
.orders-ledger-head .orders-filter-group .field select {
  background: transparent;
  border: none;
  border-radius: 999px;
  font-size: 12.5px;
  height: 26px;
  min-height: 0;
  min-width: 0;
  padding: 0 10px;
}

.orders-ledger-head .orders-filter-group .field input:focus,
.orders-ledger-head .orders-filter-group .field select:focus {
  box-shadow: none;
  outline: none;
}

.orders-ledger-head .orders-filter-group .compact-field {
  min-width: 0;
}

.orders-ledger-head .orders-filter-group .compact-field select {
  min-width: 110px;
  padding-inline-end: 22px;
}

.orders-ledger-head .orders-filter-group .search-field input {
  min-width: 220px;
}

.orders-ledger-head .orders-ledger-title {
  align-self: center;
}

/* Profile chip polish */

.profile-list {
  margin: 0;
}

.profile-chip {
  transition: border-color 160ms, transform 160ms, box-shadow 160ms;
}

.profile-chip:hover {
  border-color: var(--accent-soft-border);
  transform: translateY(-1px);
}

.profile-chip[aria-selected="true"] {
  box-shadow: 0 0 0 2px var(--accent-soft), var(--shadow-sm);
}

/* Workspaces inside fieldset look tighter */

.orders-fieldset .workspace-picker {
  background: var(--surface);
  padding: 12px;
}

/* ---- PROFILES TAB (master-detail) ---- */

.orders-profiles-card {
  overflow: hidden;
}

.orders-profiles-head {
  flex-direction: row;
  align-items: center;
}

.orders-profiles-head .profile-toolbar-actions {
  display: flex;
  gap: 6px;
}

.orders-profiles-layout {
  display: grid;
  grid-template-columns: minmax(220px, 280px) 1fr;
}

.orders-profiles-sidebar {
  background: var(--surface-soft);
  border-inline-end: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px;
}

.orders-profiles-sidebar-head {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 2px 4px 8px;
}

.orders-profiles-sidebar-head span {
  color: var(--ink);
  font-size: 12.5px;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.orders-profiles-sidebar-head small {
  color: var(--muted);
  font-size: 10.5px;
}

.orders-profiles-sidebar .profile-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 0;
}

.orders-profiles-sidebar .profile-chip {
  align-items: stretch;
  border-radius: var(--radius-sm);
  display: grid;
  gap: 2px;
  min-width: 0;
  padding: 9px 12px;
  text-align: start;
  width: 100%;
}

.orders-profiles-sidebar .profile-chip span {
  font-size: 13px;
  font-weight: 800;
}

.orders-profiles-sidebar .profile-chip small {
  font-size: 11px;
  max-width: 100%;
}

.orders-profiles-sidebar .profile-chip em {
  align-self: flex-start;
  font-size: 10px;
  margin-top: 2px;
}

.orders-profiles-sidebar .profile-chip[aria-selected="true"] {
  background: var(--surface);
  border-color: var(--accent);
  box-shadow: inset 3px 0 0 var(--accent);
}

.orders-profiles-editor {
  background: var(--surface);
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.orders-profiles-editor .profile-editor {
  display: grid;
  gap: 10px;
  padding: 14px 16px;
}

.orders-profiles-editor .profile-editor .orders-fieldset {
  gap: 8px;
  padding: 10px 12px 12px;
}

.orders-profiles-editor .profile-editor .orders-fields-grid {
  gap: 8px 12px;
}

.orders-profiles-editor .profile-editor .field {
  gap: 4px;
}

.orders-profiles-editor .profile-editor .field label {
  font-size: 11.5px;
}

.orders-profiles-editor .profile-editor .field input,
.orders-profiles-editor .profile-editor .field select,
.orders-profiles-editor .profile-editor .field textarea {
  min-height: 32px;
  padding: 6px 10px;
  font-size: 13px;
  min-width: 0;
}

.orders-profiles-editor .profile-editor .field textarea {
  min-height: 68px;
  resize: vertical;
}

.orders-profiles-editor .profile-editor .agent-list-field {
  align-content: start;
}

.orders-profiles-editor .profile-editor .agent-list-control {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.orders-profiles-editor .profile-editor .agent-list-empty {
  align-items: center;
  background: var(--surface-soft);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-sm);
  color: var(--muted);
  display: flex;
  font-size: 12.5px;
  font-weight: 700;
  min-height: 32px;
  padding: 6px 10px;
}

.orders-profiles-editor .profile-editor .agent-list-row {
  align-items: center;
  display: grid;
  gap: 6px;
  grid-template-columns: minmax(0, 1fr) 32px;
}

.orders-profiles-editor .profile-editor .agent-list-row input {
  width: 100%;
}

.orders-profiles-editor .profile-editor .agent-list-remove {
  background: var(--surface);
  border-color: var(--line);
  color: var(--muted);
  font-size: 18px;
  height: 32px;
  line-height: 1;
  min-height: 32px;
  padding: 0;
  width: 32px;
}

.orders-profiles-editor .profile-editor .agent-list-remove:hover {
  background: var(--danger-soft);
  border-color: var(--danger-soft-border);
  color: var(--danger);
}

.orders-profiles-editor .profile-editor .agent-list-actions {
  align-items: center;
  display: flex;
  gap: 6px;
  justify-content: flex-start;
  margin-top: 2px;
  position: relative;
  width: fit-content;
}

.orders-profiles-editor .profile-editor .agent-add-button {
  justify-self: start;
  min-height: 32px;
}

.orders-profiles-editor .profile-editor .agent-add-button span:first-child {
  align-items: center;
  background: var(--accent-soft);
  border-radius: 999px;
  color: var(--accent-dark);
  display: inline-flex;
  font-size: 16px;
  height: 18px;
  justify-content: center;
  line-height: 1;
  width: 18px;
}

.orders-profiles-editor .profile-editor .agent-help {
  display: inline-flex;
  position: relative;
  z-index: 22;
}

.orders-profiles-editor .profile-editor .agent-help summary {
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  cursor: pointer;
  display: inline-flex;
  font-size: 13px;
  font-weight: 900;
  height: 28px;
  justify-content: center;
  line-height: 1;
  list-style: none;
  transition: background var(--transition), border-color var(--transition), color var(--transition), box-shadow var(--transition);
  width: 28px;
}

.orders-profiles-editor .profile-editor .agent-help summary::-webkit-details-marker {
  display: none;
}

.orders-profiles-editor .profile-editor .agent-help summary:hover,
.orders-profiles-editor .profile-editor .agent-help[open] summary {
  background: var(--accent-soft);
  border-color: var(--accent-soft-border);
  color: var(--accent-dark);
}

.orders-profiles-editor .profile-editor .agent-help summary:focus-visible {
  outline: 3px solid var(--ring);
  outline-offset: 2px;
}

.orders-profiles-editor .profile-editor .agent-help-popover {
  background: var(--ink);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  color: #ffffff;
  font-size: 12.5px;
  font-weight: 700;
  line-height: 1.55;
  left: 0;
  max-width: min(330px, 76vw);
  padding: 10px 12px;
  position: absolute;
  top: calc(100% + 8px);
  white-space: normal;
  width: max-content;
  z-index: 20;
}

.orders-profiles-editor .profile-editor .agent-help-popover::before {
  background: var(--ink);
  content: "";
  height: 10px;
  left: 9px;
  position: absolute;
  top: -5px;
  transform: rotate(45deg);
  width: 10px;
}

.orders-profiles-editor .profile-editor .profile-switch-field {
  justify-self: start;
}

.orders-profiles-editor .profile-editor .profile-switch-field .switch-control {
  min-height: 32px;
  padding: 4px 14px;
  font-size: 12.5px;
  font-weight: 700;
  width: fit-content;
}

.orders-profiles-editor .profile-editor .toggle.inline-setting {
  font-size: 12px;
  font-weight: 600;
  gap: 6px;
  margin-top: 4px;
  min-height: 0;
  white-space: nowrap;
}

.orders-profiles-editor .profile-editor .profile-contact-toggle input[type="checkbox"] {
  height: 14px;
  width: 14px;
}

.orders-profiles-editor .profile-editor .orders-fieldset .workspace-picker {
  padding: 10px;
  gap: 8px;
}

.profile-delete-card .app-modal-head {
  border-bottom-color: var(--danger-soft-border);
}

.profile-delete-warning {
  background: var(--danger-soft);
  border: 1px solid var(--danger-soft-border);
  border-radius: var(--radius-sm);
  color: var(--danger);
  display: grid;
  gap: 6px;
  padding: 14px 16px;
}

.profile-delete-warning strong {
  color: var(--ink);
  font-size: 15px;
}

.profile-delete-warning span {
  font-size: 13px;
  font-weight: 700;
}

@media (max-width: 900px) {
  .orders-profiles-layout {
    grid-template-columns: 1fr;
  }

  .orders-profiles-sidebar {
    border-bottom: 1px solid var(--line);
    border-inline-end: none;
  }
}

/* ---- TABS NAV + PANELS ---- */

.orders-tabs {
  align-items: center;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  box-shadow: none;
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  padding: 0;
  position: relative;
}

.orders-tab {
  align-items: center;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  color: var(--muted);
  cursor: pointer;
  display: inline-flex;
  flex: 0 0 auto;
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  gap: 7px;
  justify-content: center;
  margin-bottom: -1px;
  min-height: 36px;
  padding: 8px 16px;
  transition: color 160ms, border-color 160ms;
}

.orders-tab:hover {
  color: var(--ink);
}

.orders-tab:focus-visible {
  box-shadow: 0 0 0 3px var(--ring);
  outline: none;
}

.orders-tab[aria-selected="true"] {
  background: transparent;
  border-color: var(--accent);
  color: var(--ink);
  font-weight: 800;
}

.orders-tab[aria-selected="true"] svg {
  color: var(--accent);
}

.orders-tab svg {
  color: var(--muted-soft);
  flex: none;
}

.orders-tab-panels {
  display: block;
}

.orders-tab-panel[hidden] {
  display: none !important;
}

.orders-tab-panel {
  animation: ordersTabFade 220ms cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes ordersTabFade {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Scrollable region inside each panel so the page itself stops scrolling */
.orders-tab-scroll {
  max-height: calc(100vh - 400px);
  min-height: 240px;
  overflow: auto;
}

/* Tighten panel when process panel is visible (it pushes content down) */
.process-panel:not([hidden]) ~ .orders-tab-panels .orders-tab-scroll {
  max-height: calc(100vh - 560px);
}

/* Make the activity log scroll independently */
.order-activity-log {
  overflow: visible;
}

/* ---- RESPONSIVE ---- */

@media (max-width: 1180px) {
  .orders-hero {
    grid-template-columns: minmax(0, 1fr);
  }

  .orders-hero-actions {
    justify-content: flex-start;
  }

  .orders-fields-grid.orders-grid-3 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .orders-fields-grid.orders-grid-4 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .orders-fields-grid .orders-field-wide,
  .orders-fields-grid .orders-field-wide-3 {
    grid-column: span 2;
  }

  .orders-metrics {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 900px) {
  .orders-tabs {
    flex-wrap: wrap;
  }

  .orders-tab {
    flex: 1 1 100%;
  }

  .orders-tab-scroll {
    max-height: none;
  }
}

@media (max-width: 720px) {
  .orders-hero {
    padding: 18px;
  }

  .orders-hero-info h2 {
    font-size: 20px;
  }

  .orders-fields-grid.orders-grid-2,
  .orders-fields-grid.orders-grid-3,
  .orders-fields-grid.orders-grid-4 {
    grid-template-columns: minmax(0, 1fr);
  }

  .orders-fields-grid .orders-field-wide,
  .orders-fields-grid .orders-field-wide-3 {
    grid-column: auto;
  }

  .orders-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .orders-ledger > .orders-ledger-head {
    align-items: stretch;
    flex-direction: column;
  }

  .orders-ledger-tools {
    flex-direction: column;
    align-items: stretch;
  }
}

/* =====================================================================
   MOBILE — Orders ledger & activity log: table/grid → readable cards
   (≤ 720px) — no horizontal scrolling, one tap-friendly card per row.
   ===================================================================== */

@media (max-width: 720px) {
  /* ---- Orders tabs → 2×2 segmented control (all tabs visible, no scroll) ---- */
  .orders-tabs {
    background: var(--surface);
    border: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    display: grid;
    gap: 4px;
    grid-template-columns: 1fr 1fr;
    padding: 4px;
  }

  .orders-tab {
    border: none;
    border-radius: var(--radius-sm);
    flex: unset;
    font-size: 12.5px;
    gap: 6px;
    justify-content: center;
    margin-bottom: 0;
    min-height: 44px;
    padding: 8px 10px;
  }

  .orders-tab[aria-selected="true"] {
    background: var(--accent-soft);
    border: none;
    color: var(--accent);
  }

  /* ---- Orders ledger table → card stack ---- */
  .orders-table-wrap {
    overflow: visible;
  }

  .orders-table,
  .orders-table tbody,
  .orders-table tr,
  .orders-table td {
    display: block;
    min-width: 0;
    width: auto;
  }

  .orders-table thead {
    display: none;
  }

  .orders-table tbody {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 12px;
  }

  .orders-table tr {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    padding: 12px 14px 8px;
    position: relative;
  }

  .orders-table tbody tr:hover {
    background: var(--surface);
  }

  .orders-table td {
    align-items: baseline;
    border-bottom: 1px solid var(--line);
    display: flex;
    font-size: 13px;
    gap: 14px;
    justify-content: space-between;
    max-width: none;
    overflow: visible;
    padding: 8px 0;
    text-align: start;
    white-space: normal;
  }

  .orders-table td:last-child,
  .orders-table td.col-status {
    border-bottom: none;
  }

  .orders-table td::before {
    color: var(--muted);
    content: attr(data-label);
    flex: 0 0 auto;
    font-size: 11px;
    font-weight: 800;
    white-space: nowrap;
  }

  .orders-table td > bdi {
    text-align: end;
  }

  /* Card header: status badge (start) + actions button pinned to the end */
  .orders-table td.col-status {
    border-bottom: 1px solid var(--line);
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: flex-start;
    margin-bottom: 4px;
    padding: 0 0 10px;
    padding-inline-end: 76px;
  }

  .orders-table td.col-status::before {
    display: none;
  }

  .orders-table td.col-status .status-note {
    flex: 1 0 100%;
    white-space: normal;
  }

  .orders-table td.col-actions {
    border: none;
    inset-block-start: 11px;
    inset-inline-end: 14px;
    padding: 0;
    position: absolute;
    width: auto;
  }

  .orders-table td.col-actions::before {
    display: none;
  }

  .orders-table td.col-actions .compact-action {
    min-height: 34px;
  }

  /* Multi-line cells stack their values under the label */
  .orders-table td.col-profile-agent,
  .orders-table td.col-price,
  .orders-table td.col-time {
    align-items: stretch;
    flex-direction: column;
    gap: 3px;
  }

  .orders-table td.col-profile-agent::before,
  .orders-table td.col-price::before,
  .orders-table td.col-time::before {
    align-self: flex-start;
  }

  .orders-table td.col-profile-agent small {
    margin-top: 0;
  }

  .orders-table td.col-price .price-gross,
  .orders-table td.col-time .time-clock {
    display: inline;
    font-size: 12px;
  }

  /* ---- Activity log grid → card stack ---- */
  .order-log-grid {
    min-width: 0;
  }

  .order-log-grid-header {
    display: none;
  }

  .order-log-grid-body {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 12px;
  }

  .order-log-grid-row {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    padding: 12px 14px;
  }

  .order-log-grid-row:hover > div {
    background: transparent;
  }

  .order-log-grid-row > div {
    align-items: baseline;
    border-bottom: 1px solid var(--line);
    display: flex;
    gap: 14px;
    justify-content: space-between;
    padding: 8px 0;
    text-align: start;
  }

  .order-log-grid-row > div:first-child {
    padding-top: 0;
  }

  .order-log-grid-row > div:last-child {
    border-bottom: none;
    padding-bottom: 0;
  }

  .order-log-grid-row > div::before {
    color: var(--muted);
    content: attr(data-label);
    flex: 0 0 auto;
    font-size: 11px;
    font-weight: 800;
    white-space: nowrap;
  }

  /* Actions chips + summary stack under their label */
  .order-log-grid-row > div[data-label="פעולות שבוצעו"],
  .order-log-grid-row > div[data-label="סיכום טיפול"] {
    align-items: stretch;
    flex-direction: column;
    gap: 6px;
  }

  .order-log-grid-row > div[data-label="פעולות שבוצעו"]::before,
  .order-log-grid-row > div[data-label="סיכום טיפול"]::before {
    align-self: flex-start;
  }

  /* ---- Dashboard sync & deals grids → card stack ---- */
  .sync-grid-wrap {
    background: none;
    overflow-x: visible;
  }

  .sync-grid,
  .deals-grid {
    min-width: 0;
    width: auto;
  }

  .grid-header,
  .deals-grid-header {
    display: none;
  }

  .grid-body,
  .deals-grid-body {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 12px;
  }

  .grid-row,
  .deals-grid-row {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    grid-template-columns: none;
    padding: 10px 14px 12px;
  }

  .grid-row > div,
  .deals-grid-row > div {
    align-items: baseline;
    background: transparent;
    border: none;
    border-bottom: 1px solid var(--line);
    display: flex;
    gap: 14px;
    justify-content: space-between;
    min-height: 0;
    padding: 7px 0;
    text-align: start;
  }

  .grid-row > div:last-child,
  .deals-grid-row > div:last-child {
    border-bottom: none;
    padding-bottom: 0;
  }

  .grid-row > div::before,
  .deals-grid-row > div::before {
    color: var(--muted);
    content: attr(data-label);
    flex: 0 0 auto;
    font-size: 11px;
    font-weight: 800;
    white-space: nowrap;
  }

  /* Card header: selection checkbox + row number, full-width on top */
  .grid-row > .row-select-cell,
  .deals-grid-row > .row-select-cell {
    border-bottom: 1px solid var(--line);
    gap: 10px;
    justify-content: flex-start;
    margin-bottom: 4px;
    padding: 0 0 10px;
  }

  .grid-row > .row-select-cell::before,
  .deals-grid-row > .row-select-cell::before {
    display: none;
  }

  .grid-row > .row-select-cell > span,
  .deals-grid-row > .row-select-cell > span {
    color: var(--muted);
    font-weight: 800;
  }

  /* Cells whose value wraps get their value on a line below the label */
  .grid-row > .block-cell {
    align-items: stretch;
    flex-direction: column;
    gap: 4px;
  }

  .grid-row > .block-cell::before {
    align-self: flex-start;
  }

  .block-popover {
    inset-inline-start: 0;
  }

  /* ---- Update-log & creation-log grids → card stack ---- */
  .log-grid,
  .creation-log-grid {
    min-width: 0;
    width: auto;
  }

  .log-grid-header,
  .creation-log-grid-header {
    display: none;
  }

  .log-grid-body,
  .creation-log-grid-body {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 12px;
  }

  .log-grid-row,
  .creation-log-grid-row {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    grid-template-columns: none;
    min-width: 0;
    padding: 10px 14px 12px;
  }

  .log-grid-row > div,
  .creation-log-grid-row > div {
    align-items: baseline;
    border: none;
    border-bottom: 1px solid var(--line);
    display: flex;
    gap: 14px;
    justify-content: space-between;
    min-height: 0;
    padding: 7px 0;
    text-align: start;
  }

  .log-grid-row > div:last-child,
  .creation-log-grid-row > div:last-child {
    border-bottom: none;
    padding-bottom: 0;
  }

  .log-grid-row > div::before,
  .creation-log-grid-row > div::before {
    color: var(--muted);
    content: attr(data-label);
    flex: 0 0 auto;
    font-size: 11px;
    font-weight: 800;
    white-space: nowrap;
  }

  /* "תיקון" / "טיסות" detail cells stack their value under the label */
  .log-grid-row > div[data-label="תיקון"],
  .creation-log-grid-row > div[data-label="טיסות"] {
    align-items: stretch;
    flex-direction: column;
    gap: 6px;
  }

  .log-grid-row > div[data-label="תיקון"]::before,
  .creation-log-grid-row > div[data-label="טיסות"]::before {
    align-self: flex-start;
  }
}
