:root {
  color-scheme: light;
  --bg: #faf7f0;
  --paper: #fffdf8;
  --ink: #29251f;
  --muted: #706b63;
  --line: #d8d0c4;
  --accent: #e45c31;
  --accent-ink: #a64020;
  --cream: #f3ece0;
  --dark: #29251f;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  -webkit-font-smoothing: antialiased;
}
* { box-sizing: border-box; }
html { min-width: 320px; }
body { margin: 0; background: var(--bg); color: var(--ink); }
button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .55; }
a { color: inherit; }
[hidden] { display: none !important; }
::selection { background: #f4b49a; color: var(--ink); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
.skip-link { position: absolute; top: -80px; left: 16px; z-index: 100; padding: 12px 18px; border-radius: 10px; background: var(--dark); color: var(--paper); text-decoration: none; }
.skip-link:focus { top: 12px; }

.app-shell { min-height: 100vh; }
.sidebar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 32px; height: 78px; padding-inline: max(36px, calc((100vw - 1180px) / 2)); border-bottom: 1px solid rgb(216 208 196 / 75%); background: rgb(250 247 240 / 94%); backdrop-filter: blur(18px); }
.brand { display: inline-flex; align-items: center; gap: 10px; min-width: 0; white-space: nowrap; }
.brand-mark { display: flex; flex: none; align-items: center; justify-content: center; width: 36px; height: 36px; border-radius: 10px; background: var(--dark); color: var(--paper); font-size: 17px; font-weight: 850; line-height: 1; letter-spacing: -.10em; }
.brand-mark span { margin-inline: 1px; color: #f28a63; font-size: 14px; font-weight: 500; }
.brand-name { display: block; font-size: 17px; line-height: 1.05; font-weight: 850; letter-spacing: -.055em; }
.brand-subtitle { display: block; margin-top: 4px; color: var(--accent-ink); font-size: 11px; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }
.nav { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.nav-link { display: inline-flex; align-items: center; gap: 9px; min-height: 42px; padding: 0 15px; border: 1px solid transparent; border-radius: 11px; color: var(--ink); font-size: 13px; font-weight: 740; text-decoration: none; white-space: nowrap; }
.nav-link:hover, .nav-link.active { border-color: var(--line); background: var(--paper); }
.nav-link.active { color: var(--accent-ink); }
.nav-label-short { display: none; }
.nav-icon { color: var(--accent-ink); font-size: 18px; line-height: 1; font-weight: 400; }
.sidebar-note { display: none; }
.main-content { min-width: 0; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 58px; padding: 10px max(36px, calc((100vw - 1180px) / 2)); border-bottom: 1px solid var(--line); background: var(--paper); }
.breadcrumb { min-width: 0; color: var(--muted); font-size: 12px; font-weight: 650; overflow-wrap: anywhere; }
.breadcrumb span { margin: 0 9px; color: #a99e91; }
.topbar-actions { display: flex; align-items: center; gap: 14px; min-width: 0; }
.topbar-actions form { margin: 0; }
.topbar-label { color: #6f5142; font-size: 12px; font-weight: 700; white-space: nowrap; }
.logout-button { border: 0; background: transparent; padding: 9px 3px; color: var(--ink); font-size: 12px; font-weight: 750; white-space: nowrap; }
.logout-button:hover { color: var(--accent-ink); text-decoration: underline; }
.page-content { width: min(calc(100% - 72px), 1180px); margin: 0 auto; padding: 34px 0; }
.intro { max-width: 790px; margin-bottom: 20px; }
.eyebrow, .section-kicker { color: var(--accent-ink); font-size: 11px; font-weight: 850; letter-spacing: .16em; text-transform: uppercase; }
.eyebrow { display: flex; align-items: center; gap: 9px; }
.eyebrow-dot { display: inline-block; flex: none; width: 7px; height: 7px; background: var(--accent); }
.intro h1 { margin: 0 0 7px; font-size: clamp(28px, 2.8vw, 36px); line-height: 1.15; font-weight: 790; letter-spacing: -.05em; }
.intro h1 span { color: var(--accent-ink); }
.intro p { max-width: 650px; margin: 0; color: #5c554e; font-size: 14px; line-height: 1.5; }

.search-card, .results-card, .detail-card { min-width: 0; background: var(--paper); }
.search-card { padding: 22px 24px; margin-bottom: 20px; border: 1px solid var(--line); border-radius: 4px; }
.card-heading, .panel-heading, .detail-heading, .items-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 15px; }
.card-heading h2, .panel-heading h2 { margin: 0; font-size: 19px; font-weight: 760; letter-spacing: -.035em; }
.card-heading p { margin: 5px 0 0; color: var(--muted); font-size: 13px; line-height: 1.5; }
.search-form { display: grid; grid-template-columns: minmax(170px, 240px) minmax(0, 1fr) auto; align-items: end; gap: 13px; margin-top: 22px; }
.form-field { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.form-field label { color: #514a42; font-size: 12px; font-weight: 750; }
.form-field select, .form-field input { width: 100%; min-width: 0; height: 48px; padding: 0 13px; border: 1px solid #cbbfb3; border-radius: 3px; background: #fff; color: var(--ink); font-size: 14px; }
.form-field input::placeholder { color: #8e8175; }
.form-field select:focus, .form-field input:focus, .login-form input:focus { border-color: var(--accent); outline: 3px solid rgb(228 92 49 / 16%); outline-offset: 0; }
.form-field input[aria-invalid="true"] { border-color: #bc4c2c; background: #fff8f5; }
.button { display: inline-flex; align-items: center; justify-content: center; gap: 10px; min-height: 48px; padding: 0 17px; border: 1px solid transparent; border-radius: 3px; font-size: 13px; font-weight: 760; text-decoration: none; white-space: nowrap; transition: background .15s, border-color .15s; }
.button-primary { background: var(--dark); color: var(--paper); }
.button-primary:not(:disabled):hover { background: #40372f; }
.button-light { min-height: 40px; padding: 0 13px; border-color: var(--line); background: var(--paper); color: var(--ink); }
.button-light:not(:disabled):hover { border-color: var(--accent); background: var(--bg); }
.button-icon { color: #f28a63; font-size: 20px; font-weight: 500; line-height: 1; }
.field-help { margin: 13px 0 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
.message { margin: 15px 0 0; padding: 12px 14px; border: 1px solid #d5e3d5; border-radius: 9px; background: #f0f7ef; color: #36563a; font-size: 13px; line-height: 1.5; }
.message.error { border-color: #e8beb0; background: #fff0eb; color: #842d17; }

.workspace-grid { display: grid; grid-template-columns: minmax(265px, 330px) minmax(0, 1fr); align-items: start; gap: 0; min-width: 0; border: 1px solid var(--line); border-radius: 4px; background: var(--paper); overflow: hidden; }
.workspace-grid.direct-order { grid-template-columns: minmax(0, 1fr); }
.workspace-grid.direct-order .results-card { display: none; }
.workspace-grid.direct-order .detail-card { border-left: 0; }
.results-card, .detail-card { min-height: 0; overflow: hidden; }
.results-card { min-height: 215px; background: #fcf9f3; }
.detail-card { border-left: 1px solid var(--line); }
.panel-heading { padding: 23px 22px 18px; border-bottom: 1px solid var(--line); background: #f8f3eb; }
.panel-heading h2 { margin-top: 7px; font-size: 17px; }
.count-badge { display: inline-grid; place-items: center; min-width: 24px; height: 23px; padding: 0 6px; border-radius: 2px; background: var(--cream); color: var(--accent-ink); font-size: 12px; vertical-align: 1px; }
.results-context { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 9px; padding: 13px 19px; border-bottom: 1px solid var(--line); background: #fbf4ea; color: #5e5145; font-size: 12px; overflow-wrap: anywhere; }
.results-context strong { color: var(--ink); }
.results-context button { padding: 4px 0; border: 0; background: transparent; color: var(--accent-ink); font-size: 12px; font-weight: 750; text-decoration: underline; }
.results-list { padding: 0 22px; }
.result-item { display: block; width: 100%; margin: 0; padding: 16px 9px; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; background: transparent; color: var(--ink); text-align: left; overflow-wrap: anywhere; }
.result-item:last-child { border-bottom: 0; }
.result-item:hover, .result-item:focus-visible { background: #f6f1e9; }
.result-item.selected { padding-left: 6px; border-left: 3px solid var(--accent); background: #faf2e9; }
.result-item.selected .result-top { color: var(--accent-ink); }
.result-top { display: flex; align-items: start; justify-content: space-between; gap: 8px; font-size: 14px; font-weight: 760; }
.result-arrow { flex: none; color: var(--accent-ink); font-size: 18px; line-height: 1; font-weight: 400; }
.result-sub { display: block; margin-top: 5px; color: #60574f; font-size: 12px; line-height: 1.5; overflow-wrap: anywhere; }
.result-foot { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: start; gap: 5px 8px; margin-top: 10px; color: var(--muted); font-size: 12px; }
.result-foot strong { color: var(--accent-ink); font-size: 12px; }
.empty-state { padding: 30px 10px 34px; text-align: left; }
.empty-icon { display: none; }
.empty-state h3 { margin: 0 0 7px; font-size: 15px; }
.empty-state p { max-width: 330px; margin: 0; color: var(--muted); font-size: 12px; line-height: 1.6; }
.pagination { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 7px; padding: 12px; border-top: 1px solid var(--line); }
.pagination span { color: var(--muted); font-size: 12px; white-space: nowrap; }

.detail-empty { max-width: 470px; min-height: 215px; margin: 0; padding: 43px 26px; text-align: left; }
.detail-empty h2 { margin: 8px 0; font-size: 21px; letter-spacing: -.04em; }
.detail-empty p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.65; }
.detail-heading { padding: 24px 25px 19px; border-bottom: 1px solid var(--line); background: #fcf9f3; }
.detail-heading h2 { margin: 6px 0 4px; font-size: 25px; letter-spacing: -.05em; overflow-wrap: anywhere; }
#selected-order-number { scroll-margin-top: 90px; }
.detail-meta { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
.preview-badge { flex: none; padding: 7px 10px; border: 1px solid #ebc7a9; border-radius: 2px; background: #fff2df; color: #87511e; font-size: 11px; font-weight: 850; letter-spacing: .09em; }
.order-summary { margin: 0 25px; padding: 20px 0; border-bottom: 1px solid var(--line); }
.summary-heading { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px 14px; }
.pdf-status { display: inline-flex; align-items: center; gap: 7px; max-width: 100%; color: #5d554b; font-size: 11px; font-weight: 760; line-height: 1.35; }
.pdf-status::before { content: ""; flex: 0 0 7px; width: 7px; height: 7px; border-radius: 50%; background: #9b8f82; }
.pdf-status.is-ready { color: #285b3b; }
.pdf-status.is-ready::before { background: #32714a; }
.pdf-status.is-blocked { color: #784818; }
.pdf-status.is-blocked::before { background: #b97926; }
.pdf-status.is-working { color: #3b566d; }
.pdf-status.is-working::before { background: #54799a; }
.summary-grid { display: flex; flex-wrap: wrap; gap: 16px 24px; margin: 20px 0 0; }
.summary-grid > div { flex: 1 1 100px; min-width: 0; }
.summary-grid .summary-client { flex: 2 1 190px; }
.summary-grid dt { color: #695c51; font-size: 10px; font-weight: 820; letter-spacing: .09em; text-transform: uppercase; }
.summary-grid dd { margin: 4px 0 0; color: var(--ink); font-size: 16px; font-weight: 760; line-height: 1.35; overflow-wrap: anywhere; }
.summary-grid #summary-client { font-size: 14px; }
.summary-grid #summary-total { color: var(--accent-ink); }
.jump-to-pdf { display: none; }
.pending-card { margin: 21px 25px 0; padding: 15px 16px; border: 1px solid #e9c99c; border-radius: 3px; background: #fff8ed; }
.pending-head { display: flex; align-items: flex-start; gap: 11px; }
.pending-symbol { display: grid; flex: 0 0 22px; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: #b97926; color: #fff; font-size: 12px; font-weight: 800; }
.pending-head strong { color: #6b421c; font-size: 13px; }
.pending-head p { margin: 4px 0 0; color: #7c572f; font-size: 12px; line-height: 1.5; }
.pending-card ul { margin: 10px 0 0 31px; padding: 0; color: #6b421c; font-size: 12px; line-height: 1.6; }
.info-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px 25px; padding: 24px 25px 6px; }
.info-block { min-width: 0; overflow-wrap: anywhere; }
.info-block h3, .items-section h3 { margin: 0 0 12px; font-size: 14px; }
.info-block dl { display: grid; gap: 11px; margin: 0; }
.info-block dl > div { min-width: 0; }
.info-block dt { color: #756b61; font-size: 11px; font-weight: 800; letter-spacing: .07em; text-transform: uppercase; }
.info-block dd { margin: 4px 0 0; color: var(--ink); font-size: 13px; line-height: 1.5; overflow-wrap: anywhere; }
.info-block-wide { grid-column: 1 / -1; padding-top: 16px; border-top: 1px solid var(--line); }
.items-section { padding: 22px 25px 0; }
.items-heading { align-items: center; }
.items-heading h3 { margin: 0 0 12px; }
.muted-text { color: var(--muted); font-size: 12px; white-space: nowrap; }
.table-hint { display: none; margin: 0 0 10px; color: var(--muted); font-size: 12px; }
.table-scroll { max-width: 100%; overflow-x: auto; border: 1px solid var(--line); border-radius: 2px; scrollbar-color: #be9f8d var(--cream); }
table { width: 100%; min-width: 560px; border-collapse: collapse; }
th { padding: 11px; background: #f5eee5; color: #5d5147; font-size: 11px; font-weight: 800; letter-spacing: .06em; text-align: left; text-transform: uppercase; }
td { padding: 11px; border-top: 1px solid #eee5db; color: #3d3731; font-size: 12px; line-height: 1.5; vertical-align: top; }
th.numeric, td.numeric { text-align: right; white-space: nowrap; }
.item-name { display: block; color: var(--ink); font-weight: 740; overflow-wrap: anywhere; }
.item-code { display: block; margin-top: 4px; color: var(--muted); font-size: 11px; overflow-wrap: anywhere; }
.items-cards { display: none; }
.item-card { min-width: 0; padding: 10px 0; border-bottom: 1px solid var(--line); }
.item-card:first-child { border-top: 1px solid var(--line); }
.item-card-name { display: block; margin: 0; color: var(--ink); font-size: 13px; font-weight: 760; line-height: 1.35; overflow-wrap: anywhere; }
.item-card-code { display: block; margin: 3px 0 0; color: var(--muted); font-size: 11px; line-height: 1.3; overflow-wrap: anywhere; }
.item-card-values { display: grid; grid-template-columns: minmax(0, .8fr) repeat(2, minmax(0, 1fr)); gap: 7px; margin: 8px 0 0; padding-top: 8px; border-top: 1px solid #eee5db; }
.item-card-values > div { min-width: 0; }
.item-card-values dt { color: #5e534a; font-size: 11px; font-weight: 760; }
.item-card-values dd { margin: 2px 0 0; color: var(--ink); font-size: 12px; font-weight: 690; line-height: 1.3; overflow-wrap: anywhere; }
.item-card-values .item-card-total dd { color: var(--accent-ink); font-weight: 800; }
.item-card-total { text-align: right; }
.total-row { display: flex; align-items: center; justify-content: space-between; gap: 15px; margin: 17px 25px 0; padding: 16px 0; border-top: 1px solid var(--line); font-size: 13px; font-weight: 700; }
.total-row strong { color: var(--accent-ink); font-size: 20px; letter-spacing: -.04em; white-space: nowrap; }
.detail-actions { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 18px 25px; border-top: 1px solid var(--line); background: #f8f2e9; scroll-margin-top: 90px; }
.detail-actions p { max-width: 340px; margin: 0; color: #655b51; font-size: 12px; line-height: 1.5; }
.detail-actions .pdf-blocked-message { margin-top: 8px; color: #7c4419; font-size: 12px; font-weight: 680; }
.page-footer { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px 20px; padding: 24px 0 0; color: var(--muted); font-size: 12px; }
.module-status { max-width: 760px; padding: 24px; border: 1px solid var(--line); border-radius: 4px; background: var(--paper); }
.module-status h2 { margin: 8px 0; font-size: 19px; line-height: 1.3; letter-spacing: -.035em; }
.module-status p { max-width: 600px; margin: 0; color: var(--muted); font-size: 13px; line-height: 1.6; }

.login-body { display: flex; flex-direction: column; min-height: 100vh; background: var(--bg); }
.login-header { border-bottom: 1px solid var(--line); }
.login-header-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; width: min(calc(100% - 48px), 960px); min-height: 68px; margin: 0 auto; }
.login-header-label { color: var(--muted); font-size: 12px; font-weight: 650; }
.login-shell { display: grid; grid-template-columns: minmax(0, 1fr) minmax(300px, 390px); align-items: start; gap: clamp(35px, 6vw, 80px); flex: 1; width: min(calc(100% - 48px), 960px); margin: 0 auto; padding: clamp(44px, 9vh, 90px) 0 65px; }
.login-intro { min-width: 0; }
.login-intro h1 { margin: 13px 0 10px; font-size: clamp(30px, 3vw, 40px); line-height: 1.14; letter-spacing: -.05em; }
.login-intro > p { max-width: 370px; margin: 0; color: #5c554e; font-size: 14px; line-height: 1.65; }
.login-intro .login-scope { margin-top: 25px; padding-top: 15px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; }
.login-main { min-width: 0; padding: 26px; border: 1px solid var(--line); border-radius: 4px; background: var(--paper); }
.login-card { min-width: 0; }
.login-card h2 { margin: 0 0 7px; font-size: 24px; line-height: 1.2; letter-spacing: -.04em; }
.login-card > p { margin: 0 0 20px; color: var(--muted); font-size: 13px; line-height: 1.55; }
.login-card .login-error { margin: 0 0 17px; padding: 10px 12px; border-left: 3px solid #bc4c2c; background: #fff0eb; color: #842d17; font-size: 13px; line-height: 1.5; }
.login-form { display: flex; flex-direction: column; gap: 8px; }
.login-form label { margin-top: 8px; font-size: 13px; font-weight: 750; }
.login-form input { width: 100%; min-width: 0; height: 46px; padding: 0 12px; border: 1px solid #bfb5aa; border-radius: 2px; background: #fff; color: var(--ink); font-size: 14px; }
.login-form .button { width: 100%; margin-top: 14px; }
.login-card .login-footnote { margin: 18px 0 0; color: var(--muted); font-size: 12px; }
.csrf-error-card .button { margin-top: 5px; }
.login-footer { width: min(calc(100% - 48px), 960px); margin: 0 auto; padding: 15px 0 20px; border-top: 1px solid var(--line); color: var(--muted); font-size: 11px; }

@media (max-width: 1080px) {
  .sidebar, .topbar { padding-inline: 24px; }
  .page-content { width: min(calc(100% - 48px), 1180px); }
  .workspace-grid { grid-template-columns: minmax(225px, 300px) minmax(0, 1fr); }
  .detail-actions { align-items: flex-start; flex-direction: column; }
}
@media (max-width: 820px) {
  .workspace-grid { grid-template-columns: minmax(0, 1fr); }
  .results-card { border-bottom: 1px solid var(--line); }
  .detail-card { border-left: 0; }
  .results-card, .detail-card { min-height: 0; }
  .results-list { max-height: 390px; overflow-y: auto; }
  .detail-actions { flex-direction: row; align-items: center; }
}
@media (max-width: 760px) {
  .sidebar { gap: 10px; height: 68px; padding-inline: 17px; }
  .brand-mark { width: 33px; height: 33px; font-size: 16px; }
  .brand-name { font-size: 15px; }
  .brand-subtitle { font-size: 10px; }
  .nav-link { min-height: 40px; padding: 0 9px; font-size: 12px; }
  .nav-label-full { display: none; }
  .nav-label-short { display: inline; }
  .nav-icon { display: none; }
  .topbar { flex-wrap: wrap; gap: 5px 12px; padding: 10px 17px; }
  .topbar-actions { justify-content: space-between; width: 100%; }
  .topbar-label { font-size: 11px; white-space: normal; }
  .page-content { width: min(calc(100% - 34px), 1240px); padding-top: 25px; }
  .intro { margin-bottom: 17px; }
  .intro h1 { font-size: clamp(27px, 4.5vw, 34px); }
  .intro p { font-size: 13px; }
  .search-card { padding: 20px; }
  .search-form { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  .search-form .button { width: 100%; }
  .info-grid { grid-template-columns: minmax(0, 1fr); }
  .info-block-wide { grid-column: auto; }
  .table-hint { display: block; }
  .table-scroll { display: none; }
  .items-cards { display: block; }
  .jump-to-pdf { display: inline-flex; margin-top: 15px; color: var(--accent-ink); font-size: 12px; font-weight: 750; text-underline-offset: 3px; }
  .detail-actions { align-items: stretch; flex-direction: column; }
  .detail-actions .button { width: 100%; }
}
@media (max-width: 720px) {
  .login-shell { grid-template-columns: minmax(0, 1fr); align-content: start; gap: 24px; padding: 30px 0 40px; }
  .login-intro h1 { margin: 10px 0 7px; font-size: 30px; }
  .login-intro .login-scope { margin-top: 13px; padding-top: 0; border-top: 0; }
  .login-main { padding: 22px; }
  .login-card h2 { font-size: 20px; }
}
@media (max-width: 420px) {
  .page-content { width: calc(100% - 28px); padding-top: 28px; }
  .intro h1 { font-size: 28px; }
  .search-card { padding: 18px; }
  .card-heading h2 { font-size: 17px; }
  .panel-heading, .detail-heading, .info-grid, .items-section, .detail-actions { padding-left: 16px; padding-right: 16px; }
  .order-summary { margin-left: 16px; margin-right: 16px; padding: 17px 0; }
  .summary-grid { gap: 14px 12px; }
  .summary-grid .summary-client { flex-basis: 100%; }
  .summary-grid dd { font-size: 14px; }
  .pending-card { margin-left: 16px; margin-right: 16px; }
  .total-row { align-items: start; flex-direction: column; gap: 5px; margin-left: 16px; margin-right: 16px; }
  .preview-badge { padding: 6px 7px; font-size: 10px; }
  .login-header-inner, .login-shell, .login-footer { width: calc(100% - 32px); }
  .login-header-inner { min-height: 60px; }
  .login-header-label { display: none; }
  .login-shell { gap: 20px; padding: 24px 0 34px; }
  .login-intro h1 { font-size: 27px; }
  .login-main { padding: 20px 18px; }
  .module-status { padding: 20px 18px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
