:root {
  --bg: #f4f5f1;
  --surface: #ffffff;
  --ink: #171916;
  --muted: #70756d;
  --line: #e3e6df;
  --lime: #d9ff57;
  --lime-dark: #b9eb20;
  --red: #dc3b3b;
  --orange: #e88c28;
  --blue: #4774e7;
  --green: #24875e;
  --shadow: 0 14px 40px rgba(20, 24, 17, .07);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--bg);
}

* { box-sizing: border-box; }
html { min-height: 100%; }
body { margin: 0; min-height: 100vh; background: var(--bg); }
a { color: inherit; }
button, input, textarea { font: inherit; }
button { cursor: pointer; }
code { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: .88em; }

.topbar {
  height: 76px; padding: 0 max(24px, calc((100vw - 1240px) / 2)); display: flex;
  align-items: center; justify-content: space-between; background: rgba(255,255,255,.92);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20;
  backdrop-filter: blur(14px);
}
.brand { display: inline-flex; align-items: center; gap: 12px; text-decoration: none; }
.brand-mark { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; background: var(--ink); color: var(--lime); font-weight: 900; letter-spacing: -.04em; }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 14px; letter-spacing: .055em; }
.brand small { margin-top: 2px; font-size: 12px; color: var(--muted); }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.role-badge { padding: 7px 10px; border-radius: 999px; background: #eef0eb; color: #555b51; font-size: 12px; font-weight: 750; }
.outbox-badge { padding: 7px 10px; border-radius: 999px; background: #fff0d8; color: #925716; font-size: 12px; font-weight: 750; }
.topbar-actions form { margin: 0; }

.page { max-width: 1240px; margin: 0 auto; padding: 42px 24px 80px; }
.page-login { max-width: none; padding: 0; }
.eyebrow { color: #718222; font-size: 12px; font-weight: 850; letter-spacing: .16em; }
h1, h2, p { margin-top: 0; }
h1 { font-size: clamp(34px, 5vw, 54px); line-height: .98; letter-spacing: -.055em; margin-bottom: 12px; }
h2 { font-size: 20px; letter-spacing: -.025em; }
.muted { color: var(--muted); }
.flash { padding: 14px 18px; margin-bottom: 20px; border: 1px solid #d8e4ad; border-radius: 14px; background: #f7ffe0; color: #43510c; }

.button { border: 1px solid transparent; border-radius: 12px; min-height: 44px; padding: 10px 16px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; font-weight: 760; transition: transform .15s, background .15s, opacity .15s; }
.button:hover { transform: translateY(-1px); }
.button-primary { background: var(--lime); color: #1b210b; border-color: #c6ee43; }
.button-primary:hover { background: var(--lime-dark); }
.button-dark { background: var(--ink); color: white; }
.button-ghost { background: transparent; border-color: var(--line); }
.button-small { min-height: 34px; padding: 6px 11px; font-size: 13px; }
.button-wide { width: 100%; }
.button.is-loading { opacity: .62; pointer-events: none; }

.login-shell { min-height: 100vh; display: grid; grid-template-columns: 1.15fr .85fr; background: #171916; }
.login-copy { color: white; padding: clamp(50px, 9vw, 130px); display: flex; flex-direction: column; justify-content: center; position: relative; overflow: hidden; }
.login-copy::after { content: ""; position: absolute; width: 520px; height: 520px; border-radius: 50%; background: var(--lime); filter: blur(4px); opacity: .13; right: -210px; bottom: -250px; }
.login-copy h1 { font-size: clamp(46px, 6vw, 84px); max-width: 760px; margin: 20px 0 28px; }
.login-copy > p { color: #bfc4ba; max-width: 590px; font-size: 19px; line-height: 1.55; }
.login-features { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 26px; }
.login-features span { border: 1px solid #41453e; border-radius: 999px; padding: 10px 14px; color: #e5e8e1; font-size: 13px; }
.login-card { align-self: center; justify-self: center; width: min(420px, calc(100% - 44px)); padding: 38px; border-radius: 24px; background: white; box-shadow: var(--shadow); }
.brand-login { margin-bottom: 38px; }
.login-card h2 { font-size: 34px; margin-bottom: 8px; }
.login-card label, .note-label { display: grid; gap: 7px; margin: 20px 0; font-size: 13px; font-weight: 750; }
.login-card input, .searchbar input, textarea { width: 100%; border: 1px solid #daddd5; border-radius: 12px; background: #fbfcfa; color: var(--ink); outline: none; }
.login-card input { height: 50px; padding: 0 14px; }
.login-card input:focus, .searchbar input:focus, textarea:focus { border-color: #a7ca32; box-shadow: 0 0 0 3px rgba(199,238,67,.22); }
.form-error { background: #ffe7e4; color: #8f2821; padding: 12px; border-radius: 10px; margin-top: 16px; }
.access-panel { max-width: 620px; }
.access-panel form { display: grid; gap: 16px; margin-top: 22px; }
.access-panel label { display: grid; gap: 7px; font-size: 13px; font-weight: 750; }
.access-panel input { width: 100%; height: 50px; padding: 0 14px; border: 1px solid #daddd5; border-radius: 12px; background: #fbfcfa; outline: none; }
.access-panel input:focus { border-color: #a7ca32; box-shadow: 0 0 0 3px rgba(199,238,67,.22); }
.access-hint { margin: 0; font-size: 13px; line-height: 1.5; }
.demo-hint { margin: 16px 0 0; text-align: center; font-size: 12px; color: var(--muted); }

.page-heading, .order-heading { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; margin-bottom: 30px; }
.page-heading h1, .order-heading h1 { margin: 8px 0 10px; }
.page-heading p { margin-bottom: 0; }

.status-tabs { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 18px; scrollbar-width: thin; }
.status-tab { flex: 0 0 auto; padding: 10px 13px; border: 1px solid var(--line); border-radius: 11px; background: white; color: #53584f; text-decoration: none; font-size: 13px; }
.status-tab b { margin-left: 7px; color: var(--ink); }
.status-tab.active { background: var(--ink); color: white; border-color: var(--ink); }
.status-tab.active b { color: var(--lime); }
.searchbar { display: grid; grid-template-columns: 1fr auto auto; gap: 10px; margin-bottom: 22px; }
.searchbar input { height: 46px; padding: 0 15px; }
.order-filters { display: grid; grid-template-columns: minmax(210px, 1.5fr) repeat(4, minmax(135px, .75fr)); gap: 12px; align-items: end; margin-bottom: 24px; padding: 16px; border: 1px solid var(--line); border-radius: 16px; background: white; }
.order-filters label { display: grid; gap: 6px; min-width: 0; color: var(--muted); font-size: 11px; font-weight: 760; }
.order-filters input, .order-filters select { width: 100%; height: 42px; padding: 0 11px; border: 1px solid #daddd5; border-radius: 10px; background: #fbfcfa; color: var(--ink); outline: none; }
.order-filters input:focus, .order-filters select:focus { border-color: #a7ca32; box-shadow: 0 0 0 3px rgba(199,238,67,.18); }
.filter-sort { grid-column: span 2; }
.filter-actions { display: flex; gap: 8px; grid-column: span 2; }
.filter-actions .button { flex: 1; }

.order-list { display: grid; gap: 10px; }
.order-card { min-height: 104px; display: grid; grid-template-columns: 1.25fr 1fr .7fr 1fr 28px; align-items: center; gap: 20px; padding: 18px 20px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); text-decoration: none; transition: border-color .15s, transform .15s, box-shadow .15s; }
.order-card:hover { border-color: #c9d19e; transform: translateY(-1px); box-shadow: 0 10px 28px rgba(24,28,20,.055); }
.order-main { display: flex; flex-wrap: wrap; align-items: center; gap: 9px; }
.order-number { font-size: 18px; font-weight: 850; }
.pill { display: inline-flex; padding: 6px 9px; border-radius: 999px; font-size: 11px; font-weight: 800; white-space: nowrap; background: #edf0e8; color: #555b51; }
.pill-new { background: #edf1ff; color: #3556ae; }
.pill-picking { background: #fff0d8; color: #925716; }
.pill-packed { background: #e8f4ff; color: #316f9e; }
.pill-ready { background: #e0f7e8; color: #176642; }
.pill-courier_called { background: #e7f1ff; color: #235f9d; }
.pill-handed_over { background: #e9ebe7; color: #515650; }
.pill-supplier { background: #fff0d8; color: #925716; }
.pill-delivery { background: #e8f1ff; color: #285e9b; }
.pill-issue { background: #ffe4e1; color: #9c2d25; }
.pill-stage-new { background: #edf1ff; color: #3556ae; }
.pill-stage-handed_over { background: #fff0d8; color: #925716; }
.pill-stage-supplier { background: #fff0d8; color: #925716; }
.pill-stage-delivery { background: #e8f1ff; color: #285e9b; }
.pill-stage-delivered { background: #e0f7e8; color: #176642; }
.pill-stage-completed { background: #e9ebe7; color: #515650; }
.pill-stage-cancelled { background: #ffe4e1; color: #9c2d25; }
.pill-supplier_confirmed { background: #e0f7e8; color: #176642; }
.status-delivered { border-color: #a8d5bb; }
.status-completed { border-color: #cfd3ca; }
.station-code { width: 100%; color: var(--muted); overflow: hidden; text-overflow: ellipsis; }
.order-person { min-width: 0; }
.order-person strong, .order-person span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.order-person span { margin-top: 5px; color: var(--muted); font-size: 13px; }
.order-meta { display: flex; flex-wrap: wrap; gap: 8px 13px; font-size: 13px; color: var(--muted); }
.order-meta b { color: var(--ink); }
.order-date { flex-basis: 100%; }
.order-created { margin: 10px 0 0; color: var(--muted); font-size: 13px; }
.order-delivery { display: flex; align-items: flex-start; gap: 9px; font-size: 13px; color: #5f655c; line-height: 1.4; }
.delivery-dot { flex: 0 0 auto; width: 8px; height: 8px; border-radius: 50%; background: #68a83e; margin-top: 5px; }
.order-arrow { font-size: 22px; color: #9da298; }
.empty-state { padding: 72px 20px; text-align: center; border: 1px dashed #ccd0c7; border-radius: 20px; color: var(--muted); }
.empty-state h2 { color: var(--ink); margin: 15px 0 7px; }
.empty-icon { width: 50px; height: 50px; display: grid; place-items: center; margin: auto; border-radius: 50%; background: var(--lime); color: #314000; font-size: 22px; }

.back-link { display: inline-block; margin-bottom: 22px; color: var(--muted); text-decoration: none; font-size: 14px; }
.heading-badges { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
.delivery-state { color: var(--muted); font-size: 13px; }
.detail-grid { display: grid; grid-template-columns: minmax(0, 1fr) 350px; gap: 22px; align-items: start; }
.detail-main, .detail-side { display: grid; gap: 18px; }
.detail-side { position: sticky; top: 96px; }
.panel { border: 1px solid var(--line); border-radius: 18px; background: white; padding: 22px; box-shadow: 0 8px 26px rgba(24,28,20,.025); }
.panel h2 { margin-bottom: 0; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 18px; }
.panel-heading > span { color: var(--muted); font-size: 13px; }
.items-list { display: grid; }
.item-row { display: grid; grid-template-columns: 70px minmax(0,1fr) 60px 100px; gap: 15px; align-items: center; padding: 16px 0; border-top: 1px solid #edf0ea; }
.item-row:first-child { border-top: 0; padding-top: 2px; }
.item-row img, .item-placeholder { width: 70px; height: 70px; border-radius: 12px; background: #f1f2ee; object-fit: contain; }
.item-placeholder { display: grid; place-items: center; color: #a7aca2; font-weight: 850; }
.item-info { min-width: 0; }
.item-info strong { display: block; line-height: 1.35; }
.item-info span { display: block; color: var(--muted); font-size: 12px; margin-top: 5px; }
.item-qty { font-size: 17px; font-weight: 800; text-align: center; }
.item-price { text-align: right; font-weight: 700; }
.order-total { display: flex; justify-content: space-between; padding-top: 18px; border-top: 1px solid var(--line); font-size: 18px; }
.info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin: 0; }
.info-grid div, .tech-list div { min-width: 0; }
.info-grid dt, .tech-list dt { color: var(--muted); font-size: 12px; margin-bottom: 6px; }
.info-grid dd, .tech-list dd { margin: 0; font-weight: 650; line-height: 1.45; overflow-wrap: anywhere; }
.info-grid a { color: #456a00; }
.info-wide { grid-column: 1 / -1; }
.places-list { display: grid; gap: 10px; }
.place-card { display: grid; grid-template-columns: 1.3fr .6fr .8fr; gap: 15px; padding: 15px; border-radius: 12px; background: #f6f7f4; }
.place-card span, .place-card strong { display: block; }
.place-card span { color: var(--muted); font-size: 11px; margin-bottom: 5px; }
.place-card strong { font-size: 13px; overflow-wrap: anywhere; }

.action-panel h2 { margin-bottom: 18px; }
.availability-form, .availability-confirmed { margin-bottom: 18px; padding: 15px; border-radius: 12px; background: #f5fbdc; border: 1px solid #d8e7a0; }
.availability-form p { margin: 0 0 12px; color: #5f6840; font-size: 13px; line-height: 1.45; }
.availability-confirmed strong, .availability-confirmed span { display: block; }
.availability-confirmed strong { color: #176642; font-size: 14px; }
.availability-confirmed span { margin-top: 7px; color: #5f6840; font-size: 12px; line-height: 1.45; }
.status-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.status-choice { position: relative; }
.status-choice input { position: absolute; opacity: 0; pointer-events: none; }
.status-choice span { min-height: 42px; display: grid; place-items: center; padding: 8px; border: 1px solid var(--line); border-radius: 10px; background: #fafbf9; color: #5d6259; text-align: center; font-size: 12px; font-weight: 760; cursor: pointer; }
.status-choice input:checked + span { border-color: var(--ink); background: var(--ink); color: white; box-shadow: inset 0 -3px 0 var(--lime); }
.note-label textarea { resize: vertical; padding: 11px; min-height: 78px; }
.compact-panel h2 { margin-bottom: 16px; }
.tech-list { display: grid; gap: 15px; margin: 0; }
.tech-list code { font-size: 11px; }
.timeline { display: grid; gap: 15px; }
.timeline-row { display: grid; grid-template-columns: 10px 1fr; gap: 10px; }
.timeline-row > span { width: 8px; height: 8px; margin-top: 4px; border-radius: 50%; background: var(--lime-dark); }
.timeline-row strong, .timeline-row small { display: block; }
.timeline-row strong { font-size: 13px; }
.timeline-row small { margin-top: 4px; color: var(--muted); font-size: 11px; }
.supplier-panel { border-color: #d6dfb1; }
.supplier-state { padding: 6px 9px; border-radius: 999px; background: #eef0eb; color: #555b51; font-size: 11px; font-weight: 800; }
.supplier-state-ready_to_submit, .supplier-state-ready { background: #e0f7e8; color: #176642; }
.supplier-state-submitted, .supplier-state-accepted, .supplier-state-assembling { background: #edf1ff; color: #3556ae; }
.supplier-state-mapping_required, .supplier-state-unavailable, .supplier-state-error { background: #ffe4e1; color: #9c2d25; }
.supplier-note { color: var(--muted); font-size: 13px; line-height: 1.45; }
.supplier-error { margin-bottom: 12px; padding: 11px; border-radius: 10px; background: #ffe8e5; color: #8f2821; font-size: 12px; line-height: 1.45; }
.supplier-lines { display: grid; gap: 8px; margin-bottom: 14px; }
.supplier-line { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; padding: 11px; border: 1px solid var(--line); border-radius: 11px; }
.supplier-line strong, .supplier-line span { display: block; }
.supplier-line span { margin-top: 3px; color: var(--muted); font-size: 11px; line-height: 1.35; }
.supplier-line-ok { border-color: #cce1d4; background: #f6fcf8; }
.supplier-line-error { border-color: #efd0cc; background: #fff8f7; }
.supplier-line-meta { text-align: right; white-space: nowrap; }
.supplier-comment { margin: 12px 0; }
.supplier-comment summary { cursor: pointer; color: #456a00; font-size: 12px; font-weight: 750; }
.supplier-comment pre { padding: 11px; border-radius: 10px; background: #f6f7f4; white-space: pre-wrap; overflow-wrap: anywhere; font: 11px/1.45 ui-monospace, SFMono-Regular, Consolas, monospace; }
.supplier-external { font-size: 13px; }
.supplier-submit-form { display: grid; gap: 10px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.supplier-refresh-form { margin-top: 9px; }
.supplier-submit-form label { display: grid; gap: 6px; color: var(--muted); font-size: 11px; font-weight: 750; }
.supplier-submit-form input { width: 100%; height: 42px; padding: 0 11px; border: 1px solid #daddd5; border-radius: 10px; background: #fbfcfa; }
.supplier-submit-form small { color: #925716; text-align: center; }
.button:disabled { opacity: .5; cursor: not-allowed; transform: none; }

@media (max-width: 960px) {
  .login-shell { grid-template-columns: 1fr; padding: 50px 0; }
  .login-copy { display: none; }
  .order-card { grid-template-columns: 1fr 1fr .8fr 28px; }
  .order-delivery { grid-column: 1 / -1; }
  .detail-grid { grid-template-columns: 1fr; }
  .detail-side { position: static; grid-template-columns: 1fr 1fr; }
  .action-panel { grid-row: span 2; }
  .order-filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 680px) {
  .topbar { height: 66px; padding: 0 15px; }
  .brand small { display: none; }
  .page { padding: 28px 15px 60px; }
  .page-heading, .order-heading { align-items: stretch; flex-direction: column; }
  .page-heading .button, .order-heading .button { width: 100%; }
  h1 { font-size: 38px; }
  .searchbar { grid-template-columns: 1fr auto; }
  .searchbar .button-ghost { grid-column: 1 / -1; }
  .order-filters { grid-template-columns: 1fr; }
  .filter-sort, .filter-actions { grid-column: auto; }
  .order-card { grid-template-columns: 1fr auto; gap: 13px; padding: 16px; }
  .order-main, .order-person, .order-meta, .order-delivery { grid-column: 1 / -1; }
  .order-arrow { grid-column: 2; grid-row: 1; }
  .panel { padding: 17px; border-radius: 15px; }
  .item-row { grid-template-columns: 54px minmax(0,1fr) 45px; }
  .item-row img, .item-placeholder { width: 54px; height: 54px; }
  .item-price { display: none; }
  .info-grid, .detail-side { grid-template-columns: 1fr; }
  .info-wide { grid-column: auto; }
  .place-card { grid-template-columns: 1fr 1fr; }
  .place-card div:first-child { grid-column: 1 / -1; }
  .login-card { padding: 28px 22px; }
}

@media print {
  .topbar, .button, .back-link, .action-panel { display: none !important; }
  .page { max-width: none; padding: 0; }
  .detail-grid { display: block; }
  .panel { break-inside: avoid; box-shadow: none; margin-bottom: 12px; }
}
