:root {
  --ink: #0b2436;
  --navy: #0b3856;
  --blue: #174f7c;
  --blue-2: #256d9b;
  --pale-blue: #e8f2f9;
  --green: #2c7a57;
  --pale-green: #e8f4df;
  --amber: #9b6418;
  --red: #b12d37;
  --purple: #6651a3;
  --muted: #617383;
  --border: #d5e1e9;
  --surface: #ffffff;
  --canvas: #f3f7fa;
  --shadow: 0 16px 40px rgba(11, 56, 86, .09);
  --radius: 16px;
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  color: var(--ink);
  background: var(--canvas);
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--canvas); }
body { margin: 0; min-height: 100vh; font-size: 16px; line-height: 1.45; background: var(--canvas); }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
input, select, textarea { color: var(--ink); }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 240px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 24px 18px; background: linear-gradient(180deg, #0a304a 0%, #071f31 100%); color: white; display: flex; flex-direction: column; z-index: 20; }
.brand { display: flex; align-items: center; gap: 11px; min-height: 54px; color: #dcecf7; line-height: 1.15; font-size: .92rem; letter-spacing: .01em; }
.brand img { width: 60px; height: 42px; object-fit: contain; padding: 4px; border-radius: 9px; background: white; }
.brand strong { color: white; font-size: 1rem; }
.unit-card { margin: 25px 0 20px; padding: 14px; border: 1px solid rgba(255,255,255,.13); border-radius: 12px; background: rgba(255,255,255,.06); display: grid; gap: 4px; }
.unit-card strong { font-size: .93rem; }
.unit-card small { color: #adcadb; font-size: .78rem; }
.eyebrow { color: var(--blue-2); font-size: .72rem; font-weight: 800; letter-spacing: .11em; text-transform: uppercase; }
.eyebrow.light { color: #a8d4ee; }
.unit-card .eyebrow { color: #8fc4e2; font-size: .65rem; }
.main-nav { display: grid; gap: 5px; }
.main-nav a { display: flex; align-items: center; gap: 11px; min-height: 45px; padding: 0 12px; border-radius: 10px; color: #c7dce8; font-size: .91rem; font-weight: 600; transition: .16s ease; }
.main-nav a span { width: 20px; text-align: center; color: #8fc4e2; font-size: 1.15rem; }
.main-nav a:hover, .main-nav a.active { color: white; background: rgba(255,255,255,.11); }
.main-nav a.active { box-shadow: inset 3px 0 #63b3df; }
.logout-form { margin-top: auto; }
.nav-logout { width: 100%; min-height: 42px; border: 1px solid rgba(255,255,255,.14); color: #d6e5ee; background: transparent; border-radius: 9px; cursor: pointer; }
.nav-logout:hover { background: rgba(255,255,255,.08); }
.main-column { min-width: 0; }
.content { width: min(1440px, 100%); margin: 0 auto; padding: 34px clamp(20px, 3.3vw, 48px) 60px; }
.mobile-header { display: none; }

.page-header { margin-bottom: 26px; }
.page-header h1 { margin: 5px 0 6px; font-size: clamp(1.65rem, 2.5vw, 2.35rem); line-height: 1.12; letter-spacing: -.035em; }
.page-header p { max-width: 720px; margin: 0; color: var(--muted); }
.page-header.compact h1 { font-size: clamp(1.55rem, 2vw, 2rem); }
.split-header { display: flex; align-items: end; justify-content: space-between; gap: 22px; }
.header-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.button { min-height: 44px; padding: 0 17px; border: 1px solid transparent; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; font-weight: 750; font-size: .9rem; cursor: pointer; transition: transform .12s ease, box-shadow .12s ease, background .12s ease; }
.button:hover { transform: translateY(-1px); }
.button-primary { color: white; background: var(--blue); box-shadow: 0 8px 18px rgba(23,79,124,.2); }
.button-primary:hover { background: #103f65; }
.button-secondary { color: var(--blue); background: white; border-color: #aec8da; }
.button-secondary:hover { background: #f3f8fb; }
.button-quiet { color: var(--muted); background: transparent; border-color: var(--border); }
.button-block { width: 100%; }
.text-link, .row-link { color: var(--blue); font-weight: 750; font-size: .88rem; white-space: nowrap; }

.metric-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 15px; margin-bottom: 20px; }
.metric-card { position: relative; overflow: hidden; display: grid; min-height: 132px; padding: 18px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: 0 8px 26px rgba(11,56,86,.05); }
.metric-card::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--blue); }
.metric-card span { color: var(--muted); font-size: .81rem; font-weight: 750; }
.metric-card strong { align-self: center; font-size: 2rem; line-height: 1; letter-spacing: -.04em; }
.metric-card small { color: #7e8f9c; font-size: .74rem; }
.metric-card.accent-amber::before { background: #d5932f; }.metric-card.accent-green::before { background: #3d9b70; }.metric-card.accent-purple::before { background: #7c67ba; }

.panel { margin-bottom: 20px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.panel-heading { padding: 20px 22px 16px; display: flex; align-items: end; justify-content: space-between; gap: 16px; }
.panel-heading h2 { margin: 3px 0 0; font-size: 1.18rem; }
.panel.no-top-radius { border-radius: 0 0 var(--radius) var(--radius); }
.filter-panel { margin-bottom: -1px; border-radius: var(--radius) var(--radius) 0 0; box-shadow: none; }
.filter-form, .catalog-search, .inline-form { padding: 18px 20px; display: flex; align-items: end; gap: 12px; }
.grow { flex: 1; }
.field { display: grid; gap: 6px; min-width: 180px; }
.field > span { color: #42596a; font-size: .73rem; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; }
.field input, .field select, .field textarea { width: 100%; min-height: 44px; padding: 9px 11px; border: 1px solid #bdcfdb; border-radius: 9px; background: #fff; outline: none; transition: border .15s ease, box-shadow .15s ease; }
.field textarea { resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus, .table-input:focus { border-color: #397da8; box-shadow: 0 0 0 3px rgba(57,125,168,.14); }
.field-help { margin: 7px 0 0; color: var(--muted); font-size: .8rem; }

.table-wrap { overflow-x: auto; }
.data-table, .order-entry-table { width: 100%; border-collapse: collapse; }
.data-table th, .data-table td { padding: 13px 15px; border-top: 1px solid #e2eaf0; text-align: left; vertical-align: middle; font-size: .87rem; }
.data-table th { color: #496173; background: #f8fafc; font-size: .7rem; letter-spacing: .045em; text-transform: uppercase; white-space: nowrap; }
.data-table td small { display: block; margin-top: 2px; color: var(--muted); }
.data-table tbody tr:hover { background: #f8fbfd; }
.status { display: inline-flex; align-items: center; min-height: 27px; padding: 3px 9px; border-radius: 999px; font-size: .72rem; font-weight: 800; white-space: nowrap; color: var(--blue); background: var(--pale-blue); }
.status-sent { color: #245f88; background: #e3f0f8; }.status-separating { color: #875914; background: #fff0ce; }.status-ready { color: #236b4b; background: #e1f2e7; }.status-dispatched { color: #57438f; background: #ece8fa; }.status-received { color: #256341; background: #dcefe4; }.status-draft { color: #647381; background: #edf1f4; }.status-cancelled { color: #8e3540; background: #f8e4e6; }
.empty-state { padding: 48px 20px; text-align: center; color: var(--muted); }
.empty-state strong { display: block; color: var(--ink); font-size: 1rem; }.empty-state p { margin: 5px 0 0; }
.alert { margin-bottom: 18px; padding: 13px 16px; border: 1px solid #afd0b7; border-radius: 11px; color: #245f3e; background: #eaf6ed; font-weight: 650; }
.alert-error { color: #88303a; border-color: #e2abb0; background: #fdeced; }

.sheet-card { overflow: visible; margin-bottom: 18px; border: 1px solid #7eaccd; border-radius: 13px; background: white; box-shadow: var(--shadow); }
.sheet-title { min-height: 68px; padding: 11px 18px 10px 150px; color: white; background: var(--blue); border-radius: 12px 12px 0 0; text-align: center; display: grid; place-content: center; position: relative; }
.sheet-logo { position: absolute; left: 14px; top: 10px; width: 118px; height: 48px; padding: 4px 8px; border-radius: 7px; object-fit: contain; background: white; }
.sheet-title span { font-weight: 850; letter-spacing: .02em; }.sheet-title small { margin-top: 3px; color: #d8eaf5; font-size: .72rem; }
.sheet-meta { display: grid; grid-template-columns: 1.2fr 1fr .8fr; }
.sheet-meta > div, .sheet-meta > label { min-height: 54px; margin: 0; padding: 8px 11px; border-right: 1px solid #a8c7dd; border-bottom: 1px solid #a8c7dd; display: grid; grid-template-columns: 95px 1fr; align-items: center; gap: 8px; }
.sheet-meta span { color: var(--blue); font-size: .68rem; font-weight: 850; letter-spacing: .04em; }
.sheet-meta strong { font-size: .9rem; }.sheet-meta input { min-width: 0; width: 100%; border: 0; padding: 7px 8px; background: #fff7d8; }
.sheet-band { padding: 7px 12px; color: white; background: var(--blue); text-align: center; font-size: .72rem; font-weight: 850; letter-spacing: .04em; }
.product-search-area { position: relative; padding: 15px 16px 11px; background: #f3f8fb; }
.product-search-field input { background: #fff9df; }
.search-results { position: absolute; left: 16px; top: 77px; z-index: 12; width: min(720px, calc(100% - 32px)); max-height: 330px; overflow-y: auto; border: 1px solid #abc6d8; border-radius: 10px; background: white; box-shadow: 0 18px 42px rgba(9,44,66,.2); }
.search-result { width: 100%; padding: 11px 13px; border: 0; border-bottom: 1px solid #e3ebf1; background: white; display: grid; grid-template-columns: 82px 1fr 90px; gap: 10px; text-align: left; cursor: pointer; }
.search-result:hover, .search-result:focus { background: #edf6fb; }.search-result strong { color: var(--blue); }.search-result small { color: var(--muted); text-align: right; }
.order-entry-wrap { min-height: 250px; }
.order-entry-table { min-width: 700px; table-layout: fixed; }
.order-entry-table th:nth-child(1) { width: 6%; }.order-entry-table th:nth-child(2) { width: 11%; }.order-entry-table th:nth-child(3) { width: 27%; }.order-entry-table th:nth-child(4) { width: 13%; }.order-entry-table th:nth-child(5) { width: 18%; }.order-entry-table th:nth-child(6) { width: 13%; }.order-entry-table th:nth-child(7) { width: 12%; }
.order-entry-table th { padding: 10px 9px; color: white; background: var(--navy); border-right: 1px solid rgba(255,255,255,.28); font-size: .7rem; text-align: center; text-transform: uppercase; }
.order-entry-table td { padding: 8px 9px; border: 1px solid #b8d1e3; background: white; font-size: .84rem; }
.order-entry-table tbody tr:nth-child(odd) td:not(.quantity-cell):not(.similar-cell) { background: var(--pale-blue); }
.order-entry-table .quantity-cell, .order-entry-table .similar-cell { background: var(--pale-green); }
.order-entry-table input[type=number] { width: 100%; min-width: 92px; padding: 8px; border: 1px solid #a8c78f; border-radius: 7px; background: white; }
.similar-control { display: flex; align-items: center; justify-content: center; gap: 7px; white-space: nowrap; }
.order-entry-table td:last-child { padding-left: 4px; padding-right: 4px; text-align: center; }
.remove-item { border: 0; color: var(--red); background: transparent; cursor: pointer; font-size: .7rem; font-weight: 800; }
.table-empty { padding: 54px 18px; color: var(--muted); text-align: center; }
.notes-panel { padding: 18px; }
.sticky-actions { position: sticky; bottom: 14px; z-index: 10; padding: 13px 15px; border: 1px solid #cadbe6; border-radius: 13px; background: rgba(255,255,255,.96); box-shadow: 0 14px 35px rgba(11,56,86,.17); display: flex; align-items: center; justify-content: space-between; gap: 16px; backdrop-filter: blur(10px); }
.sticky-actions > span { color: var(--muted); font-size: .84rem; }.sticky-actions > div { display: flex; gap: 10px; }

.order-status-strip { margin-bottom: 18px; padding: 12px 16px; border: 1px solid var(--border); border-radius: 12px; background: white; display: flex; align-items: center; gap: 18px; color: var(--muted); font-size: .85rem; }
.order-detail-panel { overflow: hidden; }
.detail-table { min-width: 1080px; }.detail-table td:nth-child(2) { min-width: 245px; }.detail-table td:last-child { min-width: 225px; }
.yes-chip, .no-chip { display: inline-flex; padding: 3px 8px; border-radius: 6px; font-size: .72rem; font-weight: 850; }.yes-chip { color: #256341; background: #dff1e5; }.no-chip { color: #697985; background: #edf1f4; }
.stock-zero { color: var(--red); font-weight: 850; }
.stock-warning { display: block; margin-bottom: 4px; color: var(--red); font-weight: 800; }
.similar-highlight { padding: 6px 8px; border-radius: 9px; background: #fbe9ea; }
.table-input { width: 100%; min-height: 36px; margin: 2px 0; padding: 6px 8px; border: 1px solid #bfd0db; border-radius: 7px; outline: none; }.qty-input { min-width: 90px; }.note-input { margin-top: 5px; }
.processing-panel { padding: 18px 20px; }.processing-grid { display: flex; align-items: end; gap: 14px; }.processing-grid .button { margin-bottom: 1px; }
.receipt-callout { margin-bottom: 20px; padding: 18px 20px; border: 1px solid #acd0b7; border-radius: 14px; background: #ecf7ef; display: flex; justify-content: space-between; align-items: center; gap: 20px; }.receipt-callout p { margin: 3px 0 0; color: #526b5b; }
.two-column-detail { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }.description-list { margin: 0; padding: 0 22px 22px; }.description-list dt { margin-top: 12px; color: var(--muted); font-size: .75rem; font-weight: 800; text-transform: uppercase; }.description-list dd { margin: 4px 0 0; }
.timeline { margin: 0; padding: 0 22px 22px; list-style: none; }.timeline li { position: relative; padding: 0 0 17px 22px; }.timeline li > span { position: absolute; left: 0; top: 5px; width: 9px; height: 9px; border-radius: 50%; background: var(--blue-2); }.timeline li:not(:last-child)::before { content: ""; position: absolute; left: 4px; top: 15px; bottom: 1px; width: 1px; background: #c8d9e4; }.timeline strong, .timeline small { display: block; }.timeline small { margin-top: 3px; color: var(--muted); }

.admin-grid { display: grid; grid-template-columns: minmax(280px,.75fr) minmax(480px,1.5fr); gap: 20px; }.admin-grid > :last-child { grid-column: 1 / -1; }.stack-form { padding: 0 22px 22px; display: grid; gap: 13px; }.branch-list { margin: 0; padding: 0 20px 12px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; list-style: none; }.branch-list li { padding: 11px 12px; border: 1px solid var(--border); border-radius: 9px; display: flex; align-items: center; gap: 10px; }.branch-list li span { min-width: 60px; color: var(--blue); font-size: .75rem; font-weight: 850; }
.password-reset-form { display: flex; align-items: center; gap: 8px; }.password-reset-form input { min-width: 150px; }
.nav-badge { display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 20px; margin-left: 6px; padding: 0 6px; border-radius: 999px; background: var(--red); color: #fff; font-size: .7rem; font-weight: 800; }
.push-prompt { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; padding: 14px 18px; border: 1px solid #aec8da; border-radius: var(--radius); background: var(--pale-blue); }.push-prompt p { margin: 0; color: var(--blue); font-weight: 750; font-size: .88rem; }
.chat-layout { display: grid; grid-template-columns: minmax(220px,.65fr) minmax(420px,1.35fr); gap: 20px; align-items: start; }
.branch-select-list { margin: 0; padding: 0 12px 16px; list-style: none; display: grid; gap: 4px; }.branch-select-list a { display: block; padding: 10px 12px; border-radius: 9px; font-size: .88rem; font-weight: 700; }.branch-select-list a:hover { background: #f3f8fb; }.branch-select-list a.active { background: var(--pale-blue); color: var(--blue); }
.chat-panel { display: flex; flex-direction: column; }
.chat-thread { flex: 1; overflow-y: auto; padding: 6px 22px; display: flex; flex-direction: column; gap: 10px; max-height: 55vh; min-height: 220px; }
.chat-bubble { max-width: 78%; padding: 10px 14px; border-radius: 14px; background: #f2f6f8; }.chat-bubble strong { display: block; color: var(--muted); font-size: .72rem; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; }.chat-bubble p { margin: 4px 0 0; white-space: pre-wrap; word-break: break-word; }.chat-bubble small { display: block; margin-top: 6px; color: var(--muted); font-size: .7rem; }
.chat-bubble-matrix { align-self: flex-end; background: var(--pale-blue); }
.chat-bubble-branch { align-self: flex-start; }
.chat-form { display: flex; gap: 10px; align-items: flex-end; padding: 16px 22px 22px; border-top: 1px solid var(--border); margin-top: 14px; }.chat-form textarea { flex: 1; min-height: 46px; max-height: 140px; padding: 10px 12px; border: 1px solid #bdcfdb; border-radius: 9px; resize: vertical; }
.chat-empty { padding: 20px 22px; color: var(--muted); }
.error-page { min-height: 60vh; display: grid; place-content: center; text-align: center; }.error-code { color: #afc7d7; font-size: 5rem; font-weight: 900; line-height: 1; }.error-page h1 { margin: 8px 0; }.error-page p { margin: 0 0 20px; color: var(--muted); }

.auth-body { background: #eef4f8; }
.login-layout { min-height: 100vh; display: grid; grid-template-columns: minmax(380px, .9fr) 1.1fr; }
.login-brand-panel { position: relative; overflow: hidden; padding: clamp(32px, 6vw, 80px); color: white; background: linear-gradient(145deg, #0a2e47 0%, #15577f 100%); display: flex; flex-direction: column; justify-content: space-between; }
.login-brand-panel::after { content: ""; position: absolute; right: -160px; bottom: -190px; width: 520px; height: 520px; border: 70px solid rgba(255,255,255,.055); border-radius: 50%; }
.login-logo { width: 155px; padding: 10px; border-radius: 14px; background: white; box-shadow: 0 16px 40px rgba(0,0,0,.14); }
.login-brand-panel h1 { max-width: 580px; margin: 10px 0 14px; font-size: clamp(2.1rem, 4vw, 4.25rem); line-height: 1.02; letter-spacing: -.055em; }.login-brand-panel p { max-width: 520px; color: #c8dfed; font-size: 1.05rem; }
.connection-note { z-index: 1; display: flex; align-items: center; gap: 9px; color: #cfe4ef; font-size: .83rem; }.connection-note span { width: 9px; height: 9px; border-radius: 50%; background: #5fd298; box-shadow: 0 0 0 5px rgba(95,210,152,.14); }
.login-form-panel { padding: 30px; display: grid; place-content: center; }.login-card { width: min(410px, 90vw); padding: 32px; border: 1px solid var(--border); border-radius: 19px; background: white; box-shadow: 0 24px 70px rgba(11,56,86,.13); display: grid; gap: 17px; }.login-heading h2 { margin: 5px 0 3px; font-size: 1.65rem; }.login-heading p { margin: 0; color: var(--muted); }.login-help { color: var(--muted); text-align: center; }

@media (max-width: 1080px) {
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .admin-grid { grid-template-columns: 1fr; }.admin-grid > :last-child { grid-column: auto; }
  .chat-layout { grid-template-columns: 1fr; }
  .sheet-meta { grid-template-columns: 1fr 1fr; }
  .two-column-detail { grid-template-columns: 1fr; }
  .login-brand-panel h1 { font-size: 3rem; }
}

@media (max-width: 760px) {
  .app-shell { display: block; }
  .sidebar { position: fixed; left: -260px; width: 240px; transition: left .2s ease; box-shadow: 16px 0 38px rgba(0,0,0,.22); }.sidebar.open { left: 0; }
  .mobile-header { position: sticky; top: 0; z-index: 15; min-height: 58px; padding: 0 15px; color: white; background: var(--navy); display: flex; align-items: center; gap: 13px; font-weight: 750; }
  .icon-button { width: 40px; height: 40px; border: 0; color: white; background: transparent; font-size: 1.25rem; }
  .content { padding: 24px 14px 46px; }
  .split-header { align-items: flex-start; flex-direction: column; }.split-header .button { width: 100%; }
  .metric-grid { grid-template-columns: 1fr 1fr; gap: 10px; }.metric-card { min-height: 118px; }
  .filter-form, .catalog-search, .inline-form, .processing-grid { align-items: stretch; flex-direction: column; }.field { width: 100%; min-width: 0; }
  .push-prompt { flex-direction: column; align-items: stretch; text-align: center; }
  .chat-form { flex-direction: column; align-items: stretch; }.chat-bubble { max-width: 92%; }
  .sheet-title { padding-left: 16px; }.sheet-logo { display: none; }.sheet-meta { grid-template-columns: 1fr; }.sheet-meta > div, .sheet-meta > label { grid-template-columns: 90px 1fr; }
  .sticky-actions { position: static; align-items: stretch; flex-direction: column; }.sticky-actions > div { display: grid; grid-template-columns: 1fr; }
  .order-status-strip { align-items: flex-start; flex-direction: column; gap: 8px; }
  .receipt-callout { align-items: stretch; flex-direction: column; }.receipt-callout .button { width: 100%; }
  .branch-list { grid-template-columns: 1fr; }
  .login-layout { grid-template-columns: 1fr; }.login-brand-panel { min-height: 310px; padding: 28px; gap: 36px; }.login-brand-panel h1 { font-size: 2.35rem; }.login-logo { width: 125px; }.login-form-panel { padding: 20px 14px 38px; }.login-card { padding: 24px; }
}

@media (max-width: 430px) {
  .metric-grid { grid-template-columns: 1fr; }
  .search-result { grid-template-columns: 64px 1fr; }.search-result small { grid-column: 2; text-align: left; }
}

@media print {
  .sidebar, .mobile-header, .page-header, .sticky-actions, .button, .alert { display: none !important; }
  .app-shell { display: block; }.content { padding: 0; }.panel, .sheet-card { box-shadow: none; break-inside: avoid; }
}
