:root {
  color-scheme: light;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "San Francisco", "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  color: #303030;
  background: #f1f1f1;
  font-size: 14px;
  --surface: #fff;
  --surface-secondary: #f7f7f7;
  --surface-active: #e3e3e3;
  --background: #f1f1f1;
  --text: #303030;
  --text-secondary: #616161;
  --border: #e3e3e3;
  --border-strong: #8a8a8a;
  --brand: #001a4b;
  --brand-hover: #092a65;
  --focus: #005bd3;
  --success-bg: #eaf7ed;
  --success-text: #0c5132;
  --warning-bg: #fff4e5;
  --warning-text: #8e4b10;
  --critical-bg: #fee9e8;
  --critical-text: #8e1f0b;
  --radius-control: 8px;
  --radius-card: 12px;
  --shadow-card: 0 1px 0 rgba(0, 0, 0, .05), 0 1px 3px rgba(0, 0, 0, .08);
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--background); color: var(--text); line-height: 1.45; }
a { color: #005bd3; }
button, input, select, textarea { font: inherit; }
button, select { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .55; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

.site-header { min-height: 72px; padding: 10px clamp(16px, 3vw, 32px); display: flex; align-items: center; gap: 28px; background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 5; }
.brand { width: 128px; padding: 8px 10px 7px; color: #fff; background: var(--brand); border-radius: var(--radius-control); box-shadow: var(--shadow-card); display: inline-flex; flex: 0 0 auto; flex-direction: column; align-items: center; line-height: 1; font-weight: 650; text-decoration: none; }
.brand img { display: block; width: 106px; height: auto; }
.brand small { width: 100%; margin-top: 6px; color: #fff; font-size: 9px; font-weight: 650; letter-spacing: .18em; text-align: center; }
.site-header nav { display: flex; align-items: center; gap: 4px; flex: 1; }
.site-header nav a { min-height: 32px; padding: 6px 12px; display: inline-flex; align-items: center; color: var(--text); background: transparent; border-radius: var(--radius-control); font-size: 13px; font-weight: 600; text-decoration: none; }
.site-header nav a:hover { background: var(--surface-secondary); }
.site-header nav a[aria-current="page"] { background: var(--surface-active); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .03); }
.account { display: flex; align-items: center; gap: 8px; color: var(--text-secondary); font-size: 13px; white-space: nowrap; }
.account form { margin: 0; }
.text-action { min-height: 30px; padding: 5px 10px; color: var(--text); background: var(--surface); border: 1px solid #ccc; border-radius: var(--radius-control); box-shadow: 0 1px 0 rgba(0, 0, 0, .05); font-weight: 600; text-decoration: none; }
.text-action:hover { background: var(--surface-secondary); }

.page, .narrow-page { width: min(1480px, calc(100% - 48px)); margin: 24px auto 64px; }
.narrow-page { max-width: 720px; }
.page-title { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; margin-bottom: 18px; }
h1, h2 { color: var(--text); margin-top: 0; letter-spacing: -.015em; }
h1 { margin-bottom: 4px; font-size: clamp(22px, 3vw, 28px); line-height: 1.25; font-weight: 700; }
h2 { margin-bottom: 12px; font-size: 16px; line-height: 1.3; font-weight: 650; }
p { margin-top: 0; }
.eyebrow { margin: 0 0 5px; color: var(--text-secondary); font-size: 11px; font-weight: 650; letter-spacing: .08em; }
.muted, small { color: var(--text-secondary); }
small { display: block; margin-top: 4px; font-size: 12px; }

.connection, .status-badge, .warning { min-height: 24px; padding: 3px 9px; display: inline-flex; align-items: center; gap: 6px; border: 0; border-radius: 999px; background: var(--surface-active); color: var(--text); font-size: 12px; font-weight: 550; line-height: 1.25; }
.connection::before { width: 7px; height: 7px; content: ""; border-radius: 50%; background: #8a8a8a; }
.connection.online { color: var(--success-text); background: var(--success-bg); }
.connection.online::before { background: #29845a; }
.status-badge.critical { color: var(--critical-text); background: var(--critical-bg); }
.status-badge.positive { color: var(--success-text); background: var(--success-bg); }
.status-badge.attention { color: var(--warning-text); background: var(--warning-bg); }
.warning { margin-top: 8px; color: var(--warning-text); background: var(--warning-bg); }

.toolbar { margin-bottom: 12px; padding: 12px; display: flex; gap: 8px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card); box-shadow: var(--shadow-card); }
.toolbar input { min-width: 320px; }
.hidden-orders-link, .orders-return-link { min-height: 36px; padding: 7px 12px; display: inline-flex; align-items: center; justify-content: center; border-radius: var(--radius-control); font-size: 13px; font-weight: 650; text-decoration: none; }
.hidden-orders-link { margin-left: 20px; color: var(--brand); background: #ffdc00; border: 1px solid #d3b700; }
.hidden-orders-link:hover { color: var(--brand); background: #f3cf00; }
.hidden-orders-link[aria-current="page"] { box-shadow: inset 0 0 0 2px var(--brand); }
.orders-return-link { color: var(--text); background: var(--surface); border: 1px solid #ccc; }
.orders-return-link:hover { color: var(--text); background: var(--surface-secondary); }
input, select, textarea { min-height: 36px; padding: 7px 10px; color: var(--text); background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-control); box-shadow: inset 0 1px 0 rgba(0, 0, 0, .02); }
input:hover, select:hover, textarea:hover { border-color: #616161; }
input:focus, select:focus, textarea:focus { border-color: var(--focus); outline: 2px solid rgba(0, 91, 211, .28); outline-offset: 0; }
textarea { width: 100%; resize: vertical; }
label { display: grid; gap: 6px; color: var(--text); font-size: 13px; font-weight: 600; }

.cta { min-height: 32px; padding: 6px 12px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; color: #fff; background: var(--brand); border: 1px solid rgba(0, 0, 0, .22); border-radius: var(--radius-control); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .16), 0 1px 0 rgba(0, 0, 0, .08); font-size: 13px; font-weight: 650; line-height: 1.2; text-decoration: none; }
.cta:hover { color: #fff; background: var(--brand-hover); }
.cta:active { box-shadow: inset 0 2px 4px rgba(0, 0, 0, .2); }
.cta.secondary { color: var(--text); background: var(--surface); border-color: #ccc; box-shadow: 0 1px 0 rgba(0, 0, 0, .05); }
.cta.secondary:hover { color: var(--text); background: var(--surface-secondary); border-color: #b5b5b5; }
.cta.compact { min-height: 30px; padding: 5px 9px; font-size: 12px; margin-top: 6px; }

.panel, .auth-panel, .print-hero { padding: 20px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card); box-shadow: var(--shadow-card); }
.panel + .table-wrap { margin-top: 16px; }
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card); box-shadow: var(--shadow-card); }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 13px 12px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--border); }
th { color: var(--text-secondary); background: var(--surface-secondary); font-size: 11px; font-weight: 650; letter-spacing: .035em; text-transform: uppercase; }
.table-heading-help { display: inline-flex; align-items: center; gap: 5px; }
.info-icon { width: 16px; height: 16px; display: inline-flex; align-items: center; justify-content: center; color: var(--brand); background: #e6edf7; border: 1px solid #a9b9d1; border-radius: 50%; font-size: 11px; font-weight: 750; line-height: 1; text-transform: lowercase; cursor: help; }
.info-icon:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
tbody tr { transition: background .12s ease; }
tbody tr:hover { background: #fafafa; }
tbody tr:last-child td { border-bottom: 0; }
.orders-table td:nth-child(1) { min-width: 145px; }
.orders-table td:nth-child(4), .orders-table td:nth-child(5) { min-width: 185px; }
.orders-table td:nth-child(6) { min-width: 200px; max-width: 280px; }
.orders-table td:nth-child(7) { min-width: 175px; }
.orders-table td:nth-child(5), .orders-table td:nth-child(6), .orders-table td:nth-child(7) { position: relative; padding-bottom: 52px; }
.orders-table .take-owner, .orders-table .add-comment, .orders-table td:nth-child(7) .cta.secondary { position: absolute; left: 12px; bottom: 13px; margin-top: 0; }
.order-created { display: flex; flex-wrap: wrap; column-gap: 4px; }
.order-created span { white-space: nowrap; }
@keyframes row-enter { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes row-updated { from { background: #eaf7ed; } to { background: transparent; } }
.orders-table tr.row-enter { animation: row-enter .28s ease-out both; }
.orders-table tr.row-updated { animation: row-updated .8s ease-out both; }
.orders-table tr.row-exit { opacity: 0; transform: translateY(-6px); transition: opacity .2s ease, transform .2s ease; }
.orders-table select { width: 100%; }
.save-state { color: #29845a; font-size: 11px; }
.empty { padding: 64px 24px; text-align: center; }
.empty h2 { font-size: 18px; }
.table-empty { padding: 36px 16px; color: var(--text-secondary); text-align: center; }

.alert { padding: 12px 14px; border: 1px solid transparent; border-radius: var(--radius-card); box-shadow: var(--shadow-card); }
.alert p:last-child, .alert ul:last-child { margin-bottom: 0; }
.alert.error { color: var(--critical-text); background: var(--critical-bg); border-color: #f4b5b0; }
.alert.success { color: var(--success-text); background: var(--success-bg); border-color: #a9d8bf; }
.alert.attention { color: var(--warning-text); background: var(--warning-bg); border-color: #e6b770; }
.print-lock { margin-bottom: 16px; display: flex; align-items: center; justify-content: space-between; gap: 20px; color: var(--warning-text); background: #fff4e5; border-color: #e6b770; }
.print-lock p { margin: 4px 0 0; }
.print-lock form { flex: 0 0 auto; }
.print-instructions { margin: -2px 0 22px; color: var(--text-secondary); }
.batch-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.batch-actions form { margin: 0; }
.batch-actions .cta { margin-top: 0; }
.batch-page-actions { display: flex; align-items: center; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.stack { display: grid; gap: 16px; }

.auth-shell { min-height: 100vh; padding: 24px; display: grid; place-items: center; background: var(--background); }
.auth-panel { width: min(420px, 100%); padding: 28px; }
.auth-brand { margin-bottom: 28px; }
.auth-panel > a { display: inline-block; margin-top: 16px; }
.form-grid { display: grid; grid-template-columns: repeat(3, minmax(170px, 1fr)); gap: 14px; align-items: end; }
.user-form { grid-template-columns: repeat(12, minmax(0, 1fr)); }
.user-form > label:nth-of-type(1), .user-form > label:nth-of-type(2), .user-form > label:nth-of-type(3) { grid-column: span 4; }
.user-form > label:nth-of-type(4), .user-form > label:nth-of-type(5) { grid-column: span 4; }
.user-form > .checkbox, .user-form > .cta { grid-column: span 2; }
.checkbox { min-height: 36px; display: flex; align-items: center; gap: 8px; }
.checkbox input { width: 16px; height: 16px; min-height: 0; padding: 0; }
.actions { min-width: 180px; }
.actions .cta { margin-right: 4px; }

.print-hero { margin-bottom: 24px; display: flex; align-items: center; gap: 14px; }
.print-hero strong { color: var(--text); font-size: 40px; line-height: 1; }
.print-hero form { margin-left: auto; }
.confirmation { margin-bottom: 20px; }
.confirmation .actions { display: flex; gap: 8px; }
.connection-note { margin-bottom: 0; }
.history-search { align-items: end; }
.history-search label { width: min(420px, 100%); }
.history-search input { width: 100%; }
.history-summary { margin: 0 0 12px; color: var(--text-secondary); }
.history-table td:nth-child(1) { min-width: 170px; }
.history-table td:nth-child(2) { min-width: 120px; }
.history-table td:nth-child(3) { min-width: 190px; }
.history-table td:nth-child(4) { min-width: 150px; }
.history-details { min-width: 260px; }

.help-links { margin-bottom: 16px; padding: 12px; display: flex; flex-wrap: wrap; gap: 8px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card); box-shadow: var(--shadow-card); }
.help-links a { min-height: 32px; padding: 6px 10px; display: inline-flex; align-items: center; color: var(--text); background: var(--surface-secondary); border: 1px solid var(--border); border-radius: var(--radius-control); font-size: 13px; font-weight: 600; text-decoration: none; }
.help-links a:hover { background: var(--surface-active); }
.help-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: stretch; }
.help-card { scroll-margin-top: 92px; }
.help-card p:last-child, .help-card ul:last-child, .help-card ol:last-child { margin-bottom: 0; }
.help-card ul, .help-card ol { margin: 0 0 14px; padding-left: 22px; }
.help-card li + li { margin-top: 5px; }
.help-card code { padding: 2px 5px; background: var(--surface-secondary); border-radius: 4px; font-size: 12px; }

dialog { width: min(560px, calc(100% - 24px)); padding: 0; border: 1px solid var(--border); border-radius: 14px; box-shadow: 0 20px 48px rgba(0, 0, 0, .22); }
dialog::backdrop { background: rgba(0, 0, 0, .38); }
.dialog-card { padding: 24px; display: grid; gap: 14px; position: relative; }
#contact-dialog { width: min(760px, calc(100% - 24px)); max-height: calc(100dvh - 24px); overflow-x: hidden; overflow-y: auto; }
.dialog-card.wide { width: 100%; max-width: 100%; }
.dialog-card.wide > *, .dialog-card.wide label { min-width: 0; }
#contact-body { min-height: 180px; max-height: min(42vh, 360px); overflow: auto; }
.dialog-close { position: absolute; right: 12px; top: 10px; width: 32px; height: 32px; padding: 0; border: 0; border-radius: var(--radius-control); background: transparent; color: var(--text); font-size: 24px; }
.dialog-close:hover { background: var(--surface-secondary); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }
.toast { position: fixed; bottom: 22px; right: 22px; max-width: 420px; padding: 12px 16px; background: #303030; color: #fff; border-radius: var(--radius-control); box-shadow: 0 8px 28px rgba(0, 0, 0, .22); opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 20; }
.toast.show { opacity: 1; }

.print-document { display: none; }
.print-order { page-break-after: always; padding: 8mm 12mm; color: #333; font: 12px/1.35 Arial, sans-serif; }
.print-order:last-child { page-break-after: auto; }
.print-header { display: flex; justify-content: space-between; align-items: center; padding-bottom: 12px; border-bottom: 1px solid #e5e5e5; text-align: right; }
.print-brand { color: #001a4b; font-size: 28px; font-weight: 800; letter-spacing: .06em; }
.print-intro { padding: 14px 0 4px; }
.print-intro h1 { margin-bottom: 4px; color: #333; font-size: 23px; }
.print-order p { margin-bottom: 6px; }
.print-order h2 { margin: 14px 0 6px; color: #333; font-size: 16px; }
.print-order h3 { margin: 0 0 3px; color: #555; font-size: 12px; }
.print-order table { margin: 6px 0; }
.print-order th, .print-order td { padding: 5px 6px; border-bottom: 1px solid #e5e5e5; }
.print-order th { color: #555; background: transparent; }
.print-product { display: flex; align-items: flex-start; gap: 8px; break-inside: avoid; page-break-inside: avoid; }
.print-product-image { flex: 0 0 60px; width: 60px; height: 60px; object-fit: contain; border: 1px solid #e5e5e5; border-radius: 4px; }
.print-totals { width: 280px; margin-left: auto !important; break-inside: avoid; page-break-inside: avoid; }
.print-totals th { width: 62%; text-align: right; }
.print-totals td { text-align: right; }
.print-totals .grand-total th, .print-totals .grand-total td { color: #111; font-size: 16px; border-top: 2px solid #777; }
.print-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 24px; }
.print-columns > div { break-inside: avoid; page-break-inside: avoid; }
.print-order footer { margin-top: 14px; padding-top: 8px; border-top: 1px solid #e5e5e5; color: #666; font-size: 11px; }

@media (max-width: 900px) {
  .site-header { align-items: flex-start; flex-wrap: wrap; gap: 10px 16px; }
  .site-header nav { order: 3; width: 100%; overflow-x: auto; }
  .account { margin-left: auto; }
  .page-title { align-items: flex-start; flex-direction: column; }
  .form-grid, .user-form { grid-template-columns: 1fr 1fr; }
  .user-form > label:nth-of-type(n), .user-form > .checkbox, .user-form > .cta { grid-column: auto; }
  .help-grid { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .page, .narrow-page { width: min(100% - 20px, 1480px); margin-top: 18px; }
  .brand { width: 118px; }
  .brand img { width: 96px; }
  .account > span { display: none; }
  .toolbar, .print-hero { align-items: stretch; flex-direction: column; }
  .print-lock { align-items: stretch; flex-direction: column; }
  .toolbar input { min-width: 0; width: 100%; }
  .hidden-orders-link { margin-left: 0; }
  .form-grid, .user-form { grid-template-columns: 1fr; }
  .print-hero form { margin-left: 0; }
}
@media print {
  @page { size: A4; margin: 0; }
  .site-header, .no-print, .toast { display: none !important; }
  body { background: #fff; }
  .print-document { display: block; }
}
