:root {
  color-scheme: light;
  --navy-950: #0f2b3b;
  --navy-900: #153448;
  --navy-800: #1f4c66;
  --blue-600: #2563eb;
  --blue-500: #3478f6;
  --blue-100: #e9f0ff;
  --ink-900: #172033;
  --ink-700: #44516b;
  --ink-500: #748099;
  --surface: #ffffff;
  --canvas: #f3f6fb;
  --line: #dde4ee;
  --green-700: #08765b;
  --green-100: #e7f7f1;
  --amber-700: #b85b05;
  --amber-100: #fff1df;
  --red-700: #b42318;
  --red-100: #feeceb;
  --shadow: 0 18px 50px rgba(34, 49, 72, 0.08);
  --radius: 18px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 0;
  background: var(--canvas);
  color: var(--ink-900);
  font-family: Inter, "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
}

button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.45; }

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 34px 24px 26px;
  background: linear-gradient(180deg, var(--navy-950), var(--navy-900));
  color: #d7e2ea;
}

.brand { display: flex; align-items: center; gap: 13px; padding: 0 4px 36px; }
.brand-mark {
  position: relative;
  width: 52px;
  height: 52px;
  flex: 0 0 52px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 17px 17px 17px 6px;
  background: linear-gradient(145deg, #3d91a5 0%, #245d79 62%, #163e59 100%);
  box-shadow: 0 12px 28px rgba(0, 15, 29, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.22);
}
.brand-mark::before { content: ""; position: absolute; width: 34px; height: 34px; top: -16px; right: -12px; border-radius: 50%; background: rgba(255, 211, 127, 0.2); }
.brand-mark svg { position: relative; width: 42px; height: 42px; }
.brand-mark path { fill: none; stroke-linecap: round; stroke-linejoin: round; }
.brand-arch { stroke: rgba(255, 255, 255, 0.96); stroke-width: 2.2; }
.brand-route { stroke: #78e0c2; stroke-width: 2.25; }
.brand-ground { stroke: rgba(255, 255, 255, 0.72); stroke-width: 2.1; }
.brand-sun { fill: #ffd37f; filter: drop-shadow(0 0 5px rgba(255, 211, 127, 0.42)); }
.brand-copy { min-width: 0; }
.brand-copy strong {
  display: block;
  color: #f8fbff;
  font-family: "Segoe UI Variable Display", "Aptos Display", "Microsoft YaHei", sans-serif;
  font-size: 18px;
  font-weight: 620;
  line-height: 1.05;
  letter-spacing: -0.025em;
  white-space: nowrap;
}
.brand-copy strong em { color: #78e0c2; font-style: normal; font-weight: 520; }
.brand-copy > span { display: block; margin-top: 7px; color: #9eb8c8; font-size: 8px; font-weight: 750; letter-spacing: 0.19em; white-space: nowrap; }

nav { display: grid; gap: 9px; }
.nav-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  border: 0;
  border-radius: 12px;
  color: #cad9e2;
  background: transparent;
  text-align: left;
}
.nav-item.active { color: white; background: #245a78; }
.nav-item span { color: #75a9ff; }

.demo-note { margin-top: auto; padding: 20px; border-radius: 16px; background: rgba(60, 131, 172, 0.23); }
.demo-note span, .demo-note small { display: block; color: #a8bfcc; }
.demo-note strong { display: block; margin: 9px 0 5px; color: white; font-size: 17px; }

.main-content { padding: 42px 52px 58px; overflow: hidden; }
.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 30px; margin-bottom: 28px; }
.eyebrow { margin: 0 0 7px; color: var(--ink-500); font-size: 11px; font-weight: 800; letter-spacing: 0.12em; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 6px; font-size: 34px; letter-spacing: -0.025em; }
h2 { margin-bottom: 0; font-size: 22px; }
.page-header > div > p:last-child { margin: 0; color: var(--ink-500); }
.data-source-status { margin-top: 8px !important; color: var(--green-700) !important; font-size: 12px; font-weight: 700; }
.data-source-status.offline { color: var(--ink-500) !important; }
.truth-summary { display: grid; gap: 8px; margin-top: 12px; padding: 13px 15px; border: 1px solid #cfe0f2; border-radius: 14px; background: linear-gradient(135deg, #f7fbff, #eef7f5); }
.truth-summary-main { display: flex; align-items: center; flex-wrap: wrap; gap: 9px; }
.truth-summary-kicker { color: var(--blue-600); font-size: 10px; font-weight: 850; letter-spacing: .12em; }
.truth-summary-main strong { font-size: 13px; }
.truth-summary-meta { display: flex; flex-wrap: wrap; gap: 6px 14px; color: var(--ink-700); font-size: 11px; }
.truth-summary > p { margin: 0; color: var(--ink-500); font-size: 11px; }
.disabled-link { opacity: .55; pointer-events: none; cursor: not-allowed; }
.order-link { display: inline; padding: 0; font-size: inherit; font-weight: 700; text-align: left; }
.inline-order-link { display: inline; padding: 0; font-size: inherit; }
.orders-table tbody tr[data-order-id] { cursor: pointer; }
.source-email-hint { align-self: center; max-width: 320px; }
.header-actions { display: flex; align-items: center; gap: 12px; }
.header-actions time { padding: 11px 15px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--ink-700); }

.primary-button, .secondary-button, .danger-button, .text-button, .icon-button {
  border-radius: 11px;
  border: 1px solid transparent;
  padding: 10px 15px;
  font-weight: 700;
}
.primary-button { color: white; background: var(--blue-600); }
.secondary-button { color: var(--ink-700); border-color: var(--line); background: white; }
.danger-button { margin-right: auto; color: var(--red-700); border-color: #f4c7c3; background: var(--red-100); }
.text-button { padding: 7px; color: var(--blue-600); background: transparent; }
.icon-button { padding: 2px 8px; font-size: 25px; color: var(--ink-500); background: transparent; }

.stats-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; margin-bottom: 26px; }
.stat-card { min-height: 126px; display: grid; grid-template-columns: auto 1fr; gap: 14px; align-items: start; padding: 22px; border: 1px solid var(--line); border-radius: var(--radius); background: white; box-shadow: var(--shadow); }
.stat-icon { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 13px; color: var(--blue-600); background: var(--blue-100); }
.stat-card.attention .stat-icon { color: var(--amber-700); background: var(--amber-100); }
.stat-card.tracking .stat-icon { color: var(--green-700); background: var(--green-100); }
.stat-label { color: var(--ink-500); font-size: 14px; }
.stat-value { display: inline-block; margin: 5px 10px 0 0; font-size: 31px; line-height: 1; }
.stat-meta { font-size: 12px; color: var(--ink-500); }

.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(360px, 0.8fr); gap: 26px; }
.panel, .decision-flow, .orders-table-wrap { padding: 24px; border: 1px solid var(--line); border-radius: var(--radius); background: white; box-shadow: var(--shadow); }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 18px; }
.count-label, .phase-label { color: var(--ink-500); font-size: 12px; }

.action-list, .upcoming-list { display: grid; gap: 12px; }
.action-card { padding: 18px; border: 1px solid var(--line); border-radius: 15px; background: #fbfcfe; }
.action-card.urgent { border-color: #f4c7c3; background: #fffafa; }
.action-top { display: flex; justify-content: space-between; gap: 16px; }
.action-card h3 { margin: 8px 0 6px; font-size: 18px; }
.action-card p { margin: 0; color: var(--ink-500); font-size: 13px; }
.badge { display: inline-flex; align-items: center; width: fit-content; padding: 5px 9px; border-radius: 999px; color: var(--ink-700); background: #edf1f7; font-size: 11px; font-weight: 800; }
.badge.red { color: var(--red-700); background: var(--red-100); }
.badge.amber { color: var(--amber-700); background: var(--amber-100); }
.badge.green { color: var(--green-700); background: var(--green-100); }
.action-card button { align-self: center; white-space: nowrap; }

.upcoming-item { display: grid; grid-template-columns: 66px 1fr auto; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.upcoming-item:last-child { border-bottom: 0; }
.date-tile { padding: 9px 6px; border-radius: 12px; background: #f4f7fb; text-align: center; }
.date-tile strong, .date-tile span { display: block; }
.date-tile strong { color: var(--blue-600); font-size: 15px; }
.date-tile span { margin-top: 2px; color: var(--ink-500); font-size: 10px; }
.upcoming-item h3 { margin: 0 0 4px; font-size: 14px; }
.upcoming-item p { margin: 0; color: var(--ink-500); font-size: 11px; }

.decision-flow { margin-top: 26px; }
.decision-flow ol { display: grid; grid-template-columns: repeat(3, 1fr); gap: 34px; margin: 0; padding: 2px 0 0; list-style: none; }
.decision-flow li { position: relative; display: grid; grid-template-columns: 42px 1fr; column-gap: 13px; align-items: center; }
.decision-flow li:not(:last-child)::after { content: ""; position: absolute; top: 21px; right: -26px; width: 18px; border-top: 2px solid #bccbe2; }
.decision-flow li > span { grid-row: span 2; width: 42px; height: 42px; display: grid; place-items: center; border-radius: 13px; color: var(--blue-600); background: var(--blue-100); }
.decision-flow li.done > span { color: var(--green-700); background: var(--green-100); }
.decision-flow li strong { font-size: 14px; }
.decision-flow li small { color: var(--ink-500); }

.hidden { display: none !important; }
.timeline-list { display: grid; gap: 1.25rem; }
.section-actions { display: flex; gap: .75rem; align-items: center; }
.view-shortcuts { margin-left: auto; align-self: center; white-space: nowrap; }
.timeline-month { display: grid; gap: .75rem; }
.timeline-month > h3 { margin: 0; color: var(--ink-900); }
.timeline-entry { display: grid; grid-template-columns: 7.5rem 1fr; gap: 1rem; align-items: stretch; }
.timeline-date { padding: 1rem .75rem; border-radius: .8rem; background: #f1f5fb; color: var(--ink-500); display: grid; align-content: center; gap: .3rem; }
.timeline-date strong { color: var(--blue-600); font-size: 1.05rem; }
.timeline-card { border: 1px solid var(--line); border-radius: .8rem; padding: 1rem; background: #fff; }
.timeline-location { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.timeline-entry.current-stay .timeline-card { border-color: #7acb9b; box-shadow: 0 0 0 2px rgba(63, 170, 107, .12); }
.timeline-gap { margin-left: 8.5rem; padding: .55rem .8rem; color: var(--ink-500); border-left: 2px dashed #b7c5d7; }
.timeline-alert { margin-top: .75rem; padding: .6rem .75rem; border-radius: .55rem; color: var(--red-700); background: var(--red-100); }
.checkbox-label { display: flex; align-items: center; gap: .45rem; white-space: nowrap; }
.disabled-view { position: relative; opacity: .52; pointer-events: none; }
.disabled-view::before { content: "本期未上线 · 暂不可用"; position: absolute; z-index: 2; top: 12px; right: 18px; padding: 7px 11px; border-radius: 999px; color: #667085; background: #eef1f5; font-size: 12px; font-weight: 800; }
.orders-toolbar { display: flex; justify-content: space-between; align-items: end; gap: 20px; margin-bottom: 18px; }
.filters { display: flex; align-items: end; gap: 12px; }
.order-filters { flex-wrap: wrap; justify-content: flex-end; }
.order-filters > label { min-width: 112px; }
.order-filters > label:last-of-type { min-width: 190px; }
.custom-range { display: flex; align-items: end; gap: 8px; }
.custom-range label { min-width: 126px; }
.filter-summary { margin: -6px 0 16px; color: var(--ink-500); font-size: 12px; }
.filters label, .form-grid label, .savings-controls label { display: grid; gap: 6px; color: var(--ink-500); font-size: 12px; font-weight: 700; }
.savings-controls { display: flex; align-items: end; gap: 12px; padding: 12px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.threshold-input { display: flex; align-items: center; overflow: hidden; border: 1px solid var(--line); border-radius: 10px; background: white; }
.threshold-input input { width: 96px; border: 0; border-radius: 0; }
.threshold-input strong { min-width: 42px; padding: 0 11px; color: var(--ink-700); text-align: center; }
input, select { min-height: 42px; border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px; color: var(--ink-900); background: white; outline: none; }
input:focus, select:focus { border-color: var(--blue-500); box-shadow: 0 0 0 3px rgba(52, 120, 246, 0.12); }
.orders-table-wrap { padding: 0; overflow-x: auto; }
.orders-table { width: 100%; min-width: 760px; border-collapse: collapse; }
.orders-table th, .orders-table td { padding: 15px 16px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.orders-table th { color: var(--ink-500); background: #f8fafc; font-size: 11px; letter-spacing: 0.04em; }
.orders-table td { font-size: 13px; }
.orders-table tbody tr:hover { background: #fbfcff; }
.orders-table tbody tr:last-child td { border-bottom: 0; }
.hotel-cell strong, .hotel-cell small { display: block; }
.hotel-cell small { margin-top: 3px; color: var(--ink-500); }

.order-dialog { width: min(760px, calc(100vw - 40px)); max-height: calc(100vh - 40px); border: 0; border-radius: 20px; padding: 0; box-shadow: 0 30px 90px rgba(21, 40, 63, 0.25); }
.order-dialog::backdrop { background: rgba(15, 31, 46, 0.46); backdrop-filter: blur(4px); }
.order-dialog form { padding: 25px; }
#order-dialog { width: min(860px, calc(100vw - 40px)); max-height: min(900px, calc(100vh - 40px)); margin: auto; border-radius: 20px; }
#order-dialog form { display: flex; flex-direction: column; max-height: min(900px, calc(100vh - 40px)); min-height: 0; padding: 25px 0 0; overflow: hidden; }
.dialog-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 20px; }
#order-dialog .dialog-header { flex: 0 0 auto; padding: 0 25px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 15px; }
#order-dialog .form-grid { flex: 1 1 auto; min-height: 0; overflow: auto; padding: 0 25px 4px; }
.form-grid .wide { grid-column: 1 / -1; }
.form-hint { margin: 16px 0 0; color: var(--ink-500); font-size: 12px; }
.dialog-actions { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 10px; margin-top: 22px; }
#order-dialog > form > .form-hint { flex: 0 0 auto; padding: 0 25px; }
#order-dialog .dialog-actions { flex: 0 0 auto; margin-top: 18px; padding: 15px 25px 25px; border-top: 1px solid var(--line); background: var(--surface); }
#order-dialog .dialog-actions .source-email-hint { flex: 1 1 220px; min-width: 180px; margin: 0; }
#order-dialog .dialog-actions .danger-button { margin-right: auto; }
.order-evidence-panel { display: grid; gap: 12px; margin-top: 5px; padding: 16px; border: 1px solid #cfe0f2; border-radius: 14px; background: #f8fbff; }
.evidence-panel-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.evidence-panel-heading h3 { margin: 0 0 4px; font-size: 17px; }
.evidence-panel-heading p { margin: 0; color: var(--ink-500); font-size: 11px; }
.evidence-ref-list { display: grid; gap: 9px; }
.evidence-ref { padding: 11px 12px; border: 1px solid var(--line); border-radius: 11px; background: #fff; }
.evidence-ref-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.evidence-ref-top strong, .evidence-ref-top small { display: block; }
.evidence-ref-top strong { color: var(--ink-900); font-size: 12px; }
.evidence-ref-top small { margin-top: 3px; color: var(--ink-500); font-size: 10px; }
.evidence-ref-fields { display: flex; flex-wrap: wrap; gap: 5px 12px; margin-top: 8px; color: var(--ink-700); font-size: 11px; }
.evidence-hash { display: block; margin-top: 7px; color: var(--ink-500); font-size: 10px; }
.evidence-comparison, .evidence-history { border-top: 1px solid #dfe8f2; padding-top: 10px; }
.evidence-comparison summary, .evidence-history summary { color: var(--blue-600); cursor: pointer; font-size: 12px; font-weight: 800; }
.evidence-table-wrap { margin-top: 9px; overflow-x: auto; }
.evidence-table-wrap table { width: 100%; min-width: 580px; border-collapse: collapse; background: #fff; }
.evidence-table-wrap th, .evidence-table-wrap td { padding: 8px 9px; border-bottom: 1px solid var(--line); color: var(--ink-700); font-size: 11px; text-align: left; vertical-align: top; }
.evidence-table-wrap th { color: var(--ink-500); font-weight: 800; }
.evidence-history ul { display: grid; gap: 7px; margin: 10px 0 0; padding: 0; list-style: none; }
.evidence-history li { display: grid; grid-template-columns: 110px 1fr auto; gap: 8px; align-items: baseline; color: var(--ink-700); font-size: 11px; }
.evidence-history li small { color: var(--ink-500); }

.wide-dialog { width: min(980px, calc(100vw - 40px)); }
.compact-dialog { width: min(620px, calc(100vw - 40px)); }
.dialog-body { padding: 25px; }
.three-columns { grid-template-columns: repeat(3, 1fr); }
.compact-stats { margin-bottom: 24px; }
.compact-stats .stat-card { min-height: 104px; padding: 18px; }
.content-grid { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(360px, 0.9fr); gap: 24px; }
.record-list { display: grid; gap: 13px; }
.record-card { padding: 17px; border: 1px solid var(--line); border-radius: 14px; background: #fbfcfe; }
.record-card h3 { margin: 7px 0 6px; font-size: 17px; }
.record-card p { margin: 5px 0 0; color: var(--ink-500); font-size: 12px; line-height: 1.55; }
.record-card .record-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.record-card .record-actions { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 13px; }
.record-meta { display: flex; flex-wrap: wrap; gap: 7px 12px; margin-top: 10px; color: var(--ink-500); font-size: 11px; }
.money-positive { color: var(--green-700); }
.money-negative { color: var(--red-700); }
.badge.neutral { color: var(--ink-700); background: #edf1f7; }
.decision-math { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 18px 0; }
.decision-math > div { padding: 14px; border-radius: 12px; background: #f4f7fb; }
.decision-math span, .decision-math strong { display: block; }
.decision-math span { color: var(--ink-500); font-size: 11px; }
.decision-math strong { margin-top: 5px; font-size: 18px; }
.issue-list { margin: 14px 0 0; padding-left: 20px; color: var(--amber-700); }
.safety-note { margin-top: 18px; padding: 13px 15px; border-radius: 11px; color: var(--ink-700); background: var(--blue-100); font-size: 12px; }
.status-control { display: flex; flex-wrap: wrap; gap: 7px; }
.quality-panel { margin-top: 24px; box-shadow: none; }
.quality-panel h3 { margin: 0 0 5px; font-size: 17px; }
.quality-card { background: #fcfcfd; }

.empty-state { padding: 36px 18px; border: 1px dashed var(--line); border-radius: 14px; color: var(--ink-500); text-align: center; }
.lineage-card { background: #fff; }
.lineage-hero { display: grid; align-content: start; min-width: 116px; padding: 10px 12px; border-radius: 12px; background: var(--blue-100); }
.lineage-checkin-label { color: var(--ink-500); font-size: 10px; font-weight: 800; letter-spacing: .08em; }
.lineage-checkin-date { margin-top: 3px; color: var(--blue-600); font-size: 20px; line-height: 1.1; }
.lineage-checkout { margin-top: 4px; color: var(--ink-500); font-size: 11px; }
.lineage-heading { min-width: 0; flex: 1; }
.lineage-address { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lineage-metrics { display: grid; gap: 3px; min-width: 180px; text-align: right; color: var(--ink-500); font-size: 11px; }
.lineage-metrics strong { color: var(--ink-900); font-size: 21px; }
.lineage-events { display: grid; gap: 9px; margin: 16px 0 0; padding: 14px 0 0 20px; border-top: 1px solid var(--line); }
.lineage-event { display: grid; grid-template-columns: 145px auto auto 1fr; align-items: center; gap: 9px; min-width: 0; font-size: 12px; }
.lineage-event-date, .lineage-event-stay { color: var(--ink-500); }
.lineage-event-stay { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lineage-details { margin-top: 14px; border-top: 1px solid var(--line); }
.lineage-details summary { padding: 12px 0 0; color: var(--blue-600); cursor: pointer; font-size: 12px; font-weight: 800; list-style-position: inside; }
.lineage-details[open] summary { color: var(--ink-700); }
.lineage-warning { margin-top: 13px; padding: 10px 12px; border-radius: 9px; color: var(--amber-700); background: var(--amber-100); font-size: 12px; }
.toast { position: fixed; right: 24px; bottom: 24px; z-index: 20; transform: translateY(20px); opacity: 0; pointer-events: none; padding: 12px 16px; border-radius: 11px; color: white; background: var(--navy-900); box-shadow: var(--shadow); transition: 160ms ease; }
.toast.show { transform: translateY(0); opacity: 1; }

@media (max-width: 1180px) {
  .main-content { padding-left: 32px; padding-right: 32px; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .upcoming-list { grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 22px; }
  .content-grid { grid-template-columns: 1fr; }
  .three-columns { grid-template-columns: repeat(2, 1fr); }
  .orders-toolbar { align-items: flex-start; }
  .order-filters { justify-content: flex-start; }
  .savings-controls { flex-wrap: wrap; justify-content: flex-end; }
}
@media (max-width: 760px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; padding: 18px; }
  .brand { padding-bottom: 18px; }
  nav { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .main-content { padding: 24px 18px 36px; }
  .page-header, .orders-toolbar { flex-direction: column; }
  .header-actions, .section-actions, .filters { width: 100%; flex-wrap: wrap; }
  .view-shortcuts { margin-left: 0; }
  .header-actions > *, .filters > * { flex: 1 1 150px; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .wide { grid-column: auto; }
  #order-dialog { width: calc(100vw - 20px); max-height: calc(100vh - 20px); }
  #order-dialog form { max-height: calc(100vh - 20px); padding-top: 18px; }
  #order-dialog .dialog-header, #order-dialog .form-grid, #order-dialog > form > .form-hint, #order-dialog .dialog-actions { padding-left: 18px; padding-right: 18px; }
  #order-dialog .dialog-actions .source-email-hint { flex-basis: 100%; order: 10; }
  #order-dialog .dialog-actions .danger-button { margin-right: 0; }
  .lineage-event { grid-template-columns: 1fr auto; }
  .lineage-event-stay { grid-column: 1 / -1; white-space: normal; }
  .lineage-metrics { min-width: 0; text-align: left; margin-top: 10px; }
  .lineage-hero { min-width: 100px; }
}

/* V4-W3 App terminal: a mobile-first Today experience backed by the same
   Current Truth state as the Web management terminal. */
body.app-terminal-mode { min-width: 320px; background: #f6f8fc; }
body.app-terminal-mode .app-shell { display: none; }
body.app-terminal-mode #order-dialog .dialog-actions,
body.app-terminal-mode #order-dialog #order-edit-hint { display: none; }
body.app-terminal-mode #order-dialog .order-evidence-panel { display: none; }
body.app-terminal-mode #order-dialog input,
body.app-terminal-mode #order-dialog select { cursor: default; }
.app-terminal { min-height: 100vh; color: #172033; background: #f6f8fc; }
.app-topbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 17px max(18px, calc((100vw - 720px) / 2)); border-bottom: 1px solid #e6ebf3; background: rgba(255,255,255,.94); backdrop-filter: blur(16px); }
.app-brand-lockup { display: flex; align-items: center; gap: 10px; min-width: 0; }
.app-brand-dot { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 12px 12px 12px 4px; color: #fff; background: linear-gradient(145deg, #3d91a5, #163e59); font-size: 15px; font-weight: 800; }
.app-brand-lockup strong, .app-brand-lockup span { display: block; }
.app-brand-lockup strong { font-size: 14px; letter-spacing: -.01em; }
.app-brand-lockup span { margin-top: 2px; color: #748099; font-size: 8px; font-weight: 800; letter-spacing: .15em; }
.app-topbar-actions { display: flex; align-items: center; gap: 7px; }
.app-sync-state { max-width: 155px; overflow: hidden; color: #748099; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.app-icon-action { width: 38px; height: 38px; padding: 0; border: 1px solid #dde4ee; border-radius: 12px; color: #2563eb; background: #fff; font-size: 14px; font-weight: 800; }
.app-content { width: min(100%, 720px); margin: 0 auto; padding: 29px 18px 104px; }
.app-greeting { margin-bottom: 22px; }
.app-overline { margin: 0 0 8px; color: #748099; font-size: 11px; font-weight: 800; letter-spacing: .12em; }
.app-greeting h1 { margin: 0 0 7px; font-size: clamp(29px, 7vw, 38px); letter-spacing: -.035em; }
.app-greeting p:last-child { margin: 0; color: #748099; font-size: 14px; }
.app-priority-action { margin: 0 0 15px; padding: 15px 16px; border: 1px solid #f4c7c3; border-radius: 16px; color: #8d241b; background: #fff8f7; font-size: 13px; line-height: 1.45; }
.app-priority-action strong { display: block; margin-bottom: 4px; font-size: 14px; }
body.app-terminal-mode .app-priority-action { display: none !important; }
.app-stay-hero { position: relative; overflow: hidden; min-height: 222px; padding: 22px; border-radius: 24px; color: #fff; background: linear-gradient(140deg, #153448 0%, #245a78 57%, #3d91a5 100%); box-shadow: 0 18px 38px rgba(21,52,72,.2); }
.app-stay-hero::after { content: ""; position: absolute; right: -35px; bottom: -58px; width: 190px; height: 190px; border: 1px solid rgba(255,255,255,.18); border-radius: 50%; box-shadow: 0 0 0 28px rgba(255,255,255,.04), 0 0 0 56px rgba(255,255,255,.03); }
.app-hero-label { position: relative; z-index: 1; display: inline-flex; padding: 6px 10px; border-radius: 999px; color: #d9fff3; background: rgba(6,43,60,.42); font-size: 11px; font-weight: 800; }
.app-stay-hero h2 { position: relative; z-index: 1; max-width: 85%; margin: 18px 0 7px; color: #fff; font-size: clamp(23px, 6vw, 31px); letter-spacing: -.025em; }
.app-hero-meta, .app-hero-address { position: relative; z-index: 1; margin: 0; color: rgba(255,255,255,.8); font-size: 13px; line-height: 1.55; }
.app-hero-address { max-width: 88%; margin-top: 12px; color: #fff; }
.app-hero-countdown { position: absolute; z-index: 1; right: 22px; top: 22px; color: #ffd37f; font-size: 12px; font-weight: 800; text-align: right; }
.app-hero-countdown strong { display: block; font-size: 28px; line-height: 1; }
.app-quick-actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; margin: 12px 0 31px; }
.app-quick-actions button { min-height: 46px; padding: 8px 6px; border: 1px solid #dde4ee; border-radius: 13px; color: #2563eb; background: #fff; font-size: 12px; font-weight: 800; }
.app-quick-actions button:disabled { color: #9ba7ba; background: #f4f6fa; }
.app-next-section { margin-top: 4px; }
.app-section-heading { display: flex; align-items: center; justify-content: space-between; gap: 15px; margin-bottom: 12px; }
.app-section-heading h2 { margin: 0; font-size: 19px; }
.app-text-action { padding: 5px; border: 0; color: #2563eb; background: transparent; font-size: 12px; font-weight: 800; }
.app-next-card, .app-summary-strip, .app-list-card, .app-me-card { padding: 17px; border: 1px solid #dde4ee; border-radius: 17px; background: #fff; box-shadow: 0 8px 24px rgba(34,49,72,.05); }
.app-next-card { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.app-next-card strong, .app-next-card span { display: block; }
.app-next-card strong { margin-bottom: 5px; font-size: 15px; }
.app-next-card span { color: #748099; font-size: 12px; line-height: 1.5; }
.app-next-date { min-width: 54px; color: #2563eb !important; font-size: 20px !important; font-weight: 800; text-align: center; }
.app-summary-strip { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 14px; margin-bottom: 13px; color: #748099; font-size: 12px; }
.app-summary-strip strong { color: #172033; font-size: 17px; }
.app-change-toolbar { display: flex; gap: 8px; margin: -5px 0 8px; }
.app-filter-chip { padding: 8px 12px; border: 1px solid #d9e1ec; border-radius: 999px; color: #687892; background: #fff; font-size: 11px; font-weight: 800; }
.app-filter-chip span { display: inline-block; min-width: 16px; margin-left: 4px; color: #2563eb; }
.app-filter-chip.active { border-color: #2563eb; color: #fff; background: #2563eb; }
.app-filter-chip.active span { color: #fff; }
.app-changes-summary { margin: 0 0 11px; color: #748099; font-size: 11px; }
.app-change-card { position: relative; overflow: hidden; border: 1px solid #dde4ee; border-radius: 17px; background: #fff; box-shadow: 0 8px 24px rgba(34,49,72,.05); }
.app-change-card.needs-action { border-color: #f0d7bc; }
.app-change-main { display: grid; grid-template-columns: 1fr auto; width: 100%; padding: 16px; border: 0; color: inherit; background: transparent; text-align: left; }
.app-change-main:hover { background: #f8fbff; }
.app-change-main-static { display: grid; }
.app-change-main-content { min-width: 0; }
.app-change-main-content > span, .app-change-main-content > strong { display: block; }
.app-change-type { margin-bottom: 5px; color: #2563eb !important; font-size: 10px !important; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; }
.app-change-main-content > strong { margin-bottom: 4px; color: #172033 !important; font-size: 14px !important; }
.app-change-main-content > span { color: #748099; font-size: 11px; line-height: 1.45; }
.app-change-association { margin: 8px 0 0; color: #52627a !important; font-size: 10px !important; }
.app-change-association strong { color: #08765b; }
.app-change-diff { display: grid !important; gap: 4px; margin-top: 9px; padding-top: 8px; border-top: 1px solid #edf1f6; }
.app-change-diff span { display: flex !important; justify-content: space-between; gap: 12px; color: #52627a !important; font-size: 10px !important; }
.app-change-diff em { color: #172033; font-style: normal; text-align: right; overflow-wrap: anywhere; }
.app-change-dismiss { width: 100%; padding: 9px 16px; border: 0; border-top: 1px solid #edf1f6; color: #2563eb; background: #fbfcfe; font-size: 11px; font-weight: 800; text-align: right; }
.app-change-dismiss:hover { background: #f3f7fd; }
.app-list { display: grid; gap: 10px; }
.app-list-card { display: grid; grid-template-columns: 58px 1fr auto; align-items: center; gap: 12px; }
.app-list-date { color: #2563eb; font-size: 13px; font-weight: 800; text-align: center; }
.app-list-card strong { display: block; margin-bottom: 5px; font-size: 14px; }
.app-list-card span { display: block; color: #748099; font-size: 11px; line-height: 1.45; }
.app-status-pill { justify-self: end; padding: 6px 8px; border-radius: 999px; color: #08765b; background: #e7f7f1; font-size: 10px; font-weight: 800; white-space: nowrap; }
.app-status-pill.amber { color: #b85b05; background: #fff1df; }
.app-status-pill.red { color: #b42318; background: #feeceb; }
.app-transition-card { display: grid; grid-template-columns: 28px 1fr; align-items: center; gap: 10px; margin: 1px 8px 1px 16px; padding: 10px 13px; border-left: 2px solid #b9c8dd; color: #52627a; background: #f1f5fa; font-size: 11px; }
.app-transition-card.gap { border-left-color: #d99128; background: #fff8eb; }
.app-transition-card.overlap { border-left-color: #d24d48; color: #9b2d2b; background: #fff3f2; }
.app-transition-card strong, .app-transition-card span { display: block; }
.app-transition-card strong { margin-bottom: 3px; font-size: 12px; }
.app-transition-marker { width: 24px; height: 24px; display: grid; place-items: center; border-radius: 8px; color: #fff; background: #7589a5; font-size: 13px; font-weight: 800; }
.app-transition-card.gap .app-transition-marker { background: #d99128; }
.app-transition-card.overlap .app-transition-marker { background: #d24d48; }
.app-empty { padding: 30px 18px; border: 1px dashed #cbd5e3; border-radius: 17px; color: #748099; background: rgba(255,255,255,.62); font-size: 13px; text-align: center; }
.app-me-card { display: grid; gap: 13px; }
.app-setting-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-bottom: 13px; border-bottom: 1px solid #edf1f6; font-size: 13px; }
.app-setting-row:last-child { padding-bottom: 0; border-bottom: 0; }
.app-setting-row span { color: #748099; }
.app-setting-row strong { color: #172033; text-align: right; }
.app-bottom-nav { position: fixed; z-index: 6; right: 0; bottom: 0; left: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); width: min(100%, 720px); margin: 0 auto; padding: 9px 12px calc(9px + env(safe-area-inset-bottom)); border-top: 1px solid #e6ebf3; background: rgba(255,255,255,.96); box-shadow: 0 -8px 24px rgba(34,49,72,.06); backdrop-filter: blur(16px); }
.app-bottom-nav button { display: grid; gap: 4px; justify-items: center; padding: 5px; border: 0; color: #9ba7ba; background: transparent; font-size: 10px; font-weight: 800; }
.app-bottom-nav button span:first-child { font-size: 19px; line-height: 1; }
.app-bottom-nav button.active { color: #2563eb; }
@media (min-width: 760px) { .app-content { padding-right: 0; padding-left: 0; } }

/* W3: mask all previously rendered private content while the session is
   missing, expired, or cannot be revalidated. */
.auth-lock-banner { min-height: 100vh; display: none; box-sizing: border-box; align-items: center; justify-content: center; flex-direction: column; gap: 8px; padding: 32px; color: #172033; background: #f6f8fc; text-align: center; }
.auth-lock-banner h1, .app-auth-locked h1 { margin: 0; font-size: 24px; }
.auth-lock-banner p, .app-auth-locked p { margin: 0; color: #748099; }
.auth-pin-form { display: grid; gap: 10px; width: min(100%, 320px); margin-top: 18px; text-align: left; }
.auth-pin-form label { color: #52627a; font-size: 12px; font-weight: 800; }
.auth-pin-form input { width: 100%; box-sizing: border-box; padding: 12px 14px; border: 1px solid #cbd5e3; border-radius: 10px; color: #172033; background: #fff; font: inherit; letter-spacing: .18em; }
.auth-pin-form button { padding: 12px 14px; border: 0; border-radius: 10px; color: #fff; background: #2563eb; font: inherit; font-weight: 800; cursor: pointer; }
.auth-pin-form button:disabled { opacity: .6; cursor: wait; }
.auth-form-status { min-height: 18px; margin: 0 !important; font-size: 12px; }
.auth-form-status[data-state="error"] { color: #b42318; }
.auth-form-status[data-state="success"] { color: #08765b; }
.auth-form-status[data-state="pending"] { color: #52627a; }
.auth-lock-banner.auth-checking .auth-pin-form, .app-auth-locked.auth-checking .auth-pin-form { display: none; }
body.auth-locked > .app-shell { display: none; }
body.auth-locked > .auth-lock-banner { display: flex; }
body.app-terminal-mode.auth-locked > .auth-lock-banner { display: none; }
.app-terminal.auth-locked .app-content, .app-terminal.auth-locked .app-bottom-nav, .app-terminal.auth-locked .app-topbar-actions { display: none; }
.app-auth-locked { min-height: 70vh; display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 8px; padding: 32px; color: #172033; background: #f6f8fc; text-align: center; }
.app-auth-locked.hidden, .auth-lock-banner.hidden { display: none; }
