:root {
  color-scheme: dark;
  --bg: #07111f;
  --surface: #0d1b2d;
  --surface-2: #11243a;
  --surface-3: #172d46;
  --line: #233c58;
  --text: #f3f7fb;
  --muted: #91a6bc;
  --brand: #32b7ff;
  --brand-strong: #009cf2;
  --success: #36d19c;
  --warning: #ffc65a;
  --danger: #ff7e79;
  --shadow: 0 24px 70px rgba(0, 0, 0, .28);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { min-width: 320px; background: var(--bg); }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at 70% -10%, rgba(50, 183, 255, .17), transparent 36rem),
    linear-gradient(180deg, #081526 0, var(--bg) 30rem);
}

button, input { font: inherit; }

.app-shell { width: min(1480px, 100%); margin: 0 auto; padding: 0 28px 48px; }

.topbar {
  min-height: 82px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(145, 166, 188, .14);
}

.brand { display: inline-flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; }
.brand-mark {
  width: 42px; height: 42px; border-radius: 13px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--brand), #155bd9); font-weight: 900; font-size: 1.15rem;
  box-shadow: 0 10px 28px rgba(20, 137, 227, .3);
}
.brand strong { display: block; font-size: 1rem; letter-spacing: -.01em; }
.brand small { display: block; margin-top: 2px; color: var(--muted); font-size: .78rem; }

.connection { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: .86rem; }
.topbar-actions { display: flex; align-items: center; gap: 18px; }
.status-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--warning); box-shadow: 0 0 0 4px rgba(255, 198, 90, .1); }
.connection.online .status-dot { background: var(--success); box-shadow: 0 0 0 4px rgba(54, 209, 156, .1); }
.connection.offline .status-dot { background: var(--danger); box-shadow: 0 0 0 4px rgba(255, 126, 121, .1); }

main { display: grid; gap: 20px; }

.search-panel { padding: 54px 0 12px; }
.search-heading { display: flex; justify-content: space-between; align-items: end; gap: 20px; margin-bottom: 22px; }
.eyebrow { color: var(--brand); font-size: .75rem; letter-spacing: .16em; font-weight: 800; margin: 0 0 8px; }
h1 { margin: 0; font-size: clamp(2rem, 4vw, 3.7rem); line-height: 1; letter-spacing: -.052em; }
.shortcut { color: var(--muted); font-size: .78rem; padding-bottom: 5px; white-space: nowrap; }
kbd { border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px; padding: 2px 5px; background: var(--surface); color: #c9d6e3; margin-right: 3px; }

.search-box {
  min-height: 72px; display: flex; align-items: center; gap: 14px; padding: 9px 9px 9px 22px;
  background: rgba(17, 36, 58, .92); border: 1px solid #2e506f; border-radius: 18px; box-shadow: var(--shadow);
  transition: border-color .18s, box-shadow .18s;
}
.search-box:focus-within { border-color: var(--brand); box-shadow: 0 0 0 4px rgba(50, 183, 255, .11), var(--shadow); }
.search-box svg { width: 24px; height: 24px; fill: none; stroke: var(--brand); stroke-width: 2; flex: 0 0 auto; }
.search-box input { min-width: 0; flex: 1; background: transparent; border: 0; outline: 0; color: var(--text); font-size: 1.08rem; }
.search-box input::placeholder { color: #7890a7; }
.search-button { align-self: stretch; border: 0; border-radius: 12px; padding: 0 28px; background: var(--brand); color: #001a2d; font-weight: 850; cursor: pointer; transition: transform .15s, background .15s; }
.search-button:hover { background: #64caff; }
.search-button:active { transform: translateY(1px); }
.clear-button { width: 34px; height: 34px; border: 0; border-radius: 50%; color: var(--muted); background: var(--surface-3); font-size: 1.4rem; cursor: pointer; }

.search-modes { display: flex; flex-wrap: wrap; gap: 8px; border: 0; padding: 14px 0 0; margin: 0; }
.search-modes legend { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.search-modes input { position: absolute; opacity: 0; pointer-events: none; }
.search-modes span { display: block; padding: 8px 13px; border-radius: 10px; border: 1px solid transparent; color: var(--muted); font-size: .88rem; font-weight: 650; cursor: pointer; transition: .15s; }
.search-modes input:checked + span { color: #dff4ff; background: rgba(50, 183, 255, .13); border-color: rgba(50, 183, 255, .34); }
.search-modes input:focus-visible + span { outline: 2px solid var(--brand); outline-offset: 2px; }

.results-panel { background: rgba(13, 27, 45, .86); border: 1px solid var(--line); border-radius: 19px; overflow: hidden; box-shadow: 0 20px 55px rgba(0,0,0,.16); }
.results-header { min-height: 79px; padding: 19px 24px; display: flex; align-items: center; justify-content: space-between; gap: 16px; border-bottom: 1px solid var(--line); }
.results-header h2 { font-size: 1rem; margin: 0 0 4px; }
.results-header p { margin: 0; color: var(--muted); font-size: .84rem; }
.legend { color: var(--muted); font-size: .78rem; display: flex; gap: 7px; align-items: center; }
.stock-swatch { width: 8px; height: 8px; background: var(--success); border-radius: 50%; }

.table-wrap { width: 100%; overflow: auto; }
table { width: 100%; border-collapse: collapse; }
th { padding: 13px 20px; color: #8ea6bd; text-align: left; font-size: .73rem; text-transform: uppercase; letter-spacing: .08em; background: rgba(7, 17, 31, .5); }
td { padding: 16px 20px; border-top: 1px solid rgba(35, 60, 88, .7); font-size: .9rem; vertical-align: middle; }
tbody tr { transition: background .14s; }
tbody tr:hover { background: rgba(50, 183, 255, .055); }
.numeric { text-align: right; font-variant-numeric: tabular-nums; }
.product-name { display: block; max-width: 560px; color: var(--text); font-weight: 720; line-height: 1.35; }
.product-meta { display: flex; gap: 7px; flex-wrap: wrap; margin-top: 5px; color: var(--muted); font-size: .76rem; }
.code { font-family: "Cascadia Code", Consolas, monospace; color: #bcd0e2; }
.reference { color: #c5d6e7; }
.location { display: inline-block; padding: 5px 8px; border: 1px solid #31506e; border-radius: 7px; color: #c6d8e8; font-family: "Cascadia Code", Consolas, monospace; font-size: .78rem; }
.stock { display: inline-block; min-width: 65px; padding: 5px 9px; border-radius: 9px; text-align: center; font-weight: 780; color: var(--danger); background: rgba(255, 126, 121, .1); }
.stock.available { color: var(--success); background: rgba(54, 209, 156, .1); }
.price { color: #fff; font-weight: 850; font-size: 1rem; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.add-button { border: 1px solid rgba(50, 183, 255, .42); border-radius: 9px; padding: 8px 12px; background: rgba(50, 183, 255, .12); color: #a9e1ff; font-weight: 760; cursor: pointer; }
.add-button:hover:not(:disabled) { color: #001a2d; background: var(--brand); }
.add-button:disabled { border-color: var(--line); color: #61768b; background: rgba(35, 60, 88, .25); cursor: not-allowed; }
.add-button.compact { width: 36px; height: 36px; padding: 0; border-radius: 10px; font-size: 1.25rem; }
.card-actions { display: flex; align-items: center; gap: 10px; }
.relation { display: inline-flex; align-items: center; margin-left: 4px; padding: 2px 6px; border: 1px solid var(--line); border-radius: 999px; font-size: .65rem; font-weight: 750; letter-spacing: .02em; }
.relation.equivalent { border-color: rgba(50, 183, 255, .5); color: #a9e1ff; background: rgba(50, 183, 255, .1); }
.relation.similar { border-color: rgba(244, 184, 79, .5); color: #ffd88d; background: rgba(244, 184, 79, .1); }

.cart-toggle { display: inline-flex; align-items: center; gap: 8px; min-height: 42px; padding: 7px 9px 7px 13px; border: 1px solid var(--line); border-radius: 12px; color: var(--text); background: var(--surface); font-weight: 720; cursor: pointer; }
.cart-toggle:hover { border-color: #386181; background: var(--surface-2); }
.cart-toggle svg { width: 19px; height: 19px; fill: none; stroke: var(--brand); stroke-width: 1.8; }
.cart-toggle strong { display: grid; min-width: 27px; height: 27px; padding: 0 6px; place-items: center; border-radius: 8px; color: #001a2d; background: var(--brand); font-size: .78rem; }

.drawer-overlay { position: fixed; inset: 0; z-index: 30; background: rgba(1, 8, 16, .68); backdrop-filter: blur(3px); }
.cart-drawer { position: fixed; z-index: 40; top: 0; right: 0; width: min(470px, 100%); height: 100vh; display: flex; flex-direction: column; padding: 24px; background: #091727; border-left: 1px solid var(--line); box-shadow: -25px 0 70px rgba(0, 0, 0, .35); transform: translateX(103%); visibility: hidden; transition: transform .22s ease, visibility .22s; overflow-y: auto; }
.cart-drawer.open { transform: translateX(0); visibility: visible; }
.drawer-open { overflow: hidden; }
.cart-header { display: flex; justify-content: space-between; align-items: start; gap: 16px; }
.cart-header .eyebrow { margin-bottom: 5px; }
.cart-header h2 { margin: 0; font-size: 1.55rem; }
.icon-button { width: 40px; height: 40px; border: 1px solid var(--line); border-radius: 11px; color: var(--muted); background: var(--surface); font-size: 1.45rem; cursor: pointer; }
.readonly-notice { display: grid; gap: 3px; margin: 20px 0; padding: 13px 15px; border: 1px solid rgba(50, 183, 255, .3); border-radius: 12px; background: rgba(50, 183, 255, .08); }
.readonly-notice strong { color: #bce8ff; font-size: .86rem; }
.readonly-notice span { color: var(--muted); font-size: .78rem; }
.cart-empty { margin: auto 0; padding: 45px 20px; text-align: center; color: var(--muted); }
.cart-empty > span { width: 48px; height: 48px; display: grid; place-items: center; margin: 0 auto 12px; border: 1px solid var(--line); border-radius: 15px; color: var(--brand); font-size: 1.5rem; }
.cart-empty strong { display: block; color: var(--text); }
.cart-empty p { margin: 6px 0 0; font-size: .84rem; }
.cart-items { display: grid; gap: 10px; }
.cart-item { padding: 14px; border: 1px solid var(--line); border-radius: 13px; background: var(--surface); }
.cart-item-top, .cart-item-bottom { display: flex; justify-content: space-between; gap: 12px; }
.cart-item-top strong { display: block; font-size: .86rem; line-height: 1.3; }
.cart-item-top small { display: block; margin-top: 4px; color: var(--muted); font-family: "Cascadia Code", Consolas, monospace; font-size: .7rem; }
.cart-item-bottom { align-items: center; margin-top: 13px; }
.remove-item { flex: 0 0 auto; width: 27px; height: 27px; border: 0; border-radius: 8px; color: var(--muted); background: var(--surface-3); cursor: pointer; }
.quantity-control { display: flex; align-items: center; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
.quantity-control button { width: 32px; height: 31px; border: 0; color: var(--text); background: var(--surface-3); cursor: pointer; }
.quantity-control input { width: 44px; height: 31px; border: 0; border-left: 1px solid var(--line); border-right: 1px solid var(--line); outline: 0; text-align: center; color: var(--text); background: var(--surface-2); }
.quantity-control input::-webkit-inner-spin-button { appearance: none; }
.cart-form { display: grid; gap: 13px; margin-top: 18px; padding-top: 17px; border-top: 1px solid var(--line); }
.cart-total-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 3px; }
.cart-total-row span { color: var(--muted); }
.cart-total-row strong { color: var(--success); font-size: 1.45rem; }
.cart-form label { display: grid; gap: 6px; color: #c5d6e7; font-size: .78rem; font-weight: 690; }
.cart-form label > span { color: var(--muted); font-weight: 500; }
.cart-form input, .cart-form select, .cart-form textarea { width: 100%; border: 1px solid var(--line); border-radius: 9px; padding: 10px 11px; outline: 0; color: var(--text); background: var(--surface); font-size: .86rem; resize: vertical; }
.cart-form input:focus, .cart-form select:focus, .cart-form textarea:focus { border-color: var(--brand); }
.printer-box { display: grid; gap: 9px; margin-top: 4px; padding: 12px; border: 1px solid var(--line); border-radius: 11px; background: rgba(17, 36, 58, .6); }
.printer-state { display: flex; align-items: center; gap: 10px; }
.printer-dot { width: 9px; height: 9px; flex: 0 0 auto; border-radius: 50%; background: var(--warning); }
.printer-state.available .printer-dot { background: var(--success); }
.printer-state.unavailable .printer-dot { background: var(--danger); }
.printer-state strong, .printer-state small { display: block; }
.printer-state strong { font-size: .8rem; }
.printer-state small { margin-top: 2px; color: var(--muted); font-size: .71rem; }
.print-button { min-height: 48px; border: 0; border-radius: 11px; color: #001a2d; background: var(--success); font-weight: 850; cursor: pointer; }
.print-button:disabled { color: #667b90; background: var(--surface-3); cursor: not-allowed; }
.clear-cart-button { border: 0; padding: 7px; color: var(--muted); background: transparent; font-size: .8rem; cursor: pointer; }

.message-state { padding: 72px 20px; text-align: center; }
.message-icon { width: 56px; height: 56px; margin: 0 auto 14px; display: grid; place-items: center; border-radius: 18px; color: var(--brand); background: rgba(50, 183, 255, .09); font-size: 2rem; }
.message-state h3 { margin: 0 0 6px; font-size: 1rem; }
.message-state p { margin: 0; color: var(--muted); font-size: .87rem; }
.mobile-results { display: none; }
.toast { position: fixed; left: 50%; bottom: 22px; transform: translate(-50%, 20px); padding: 12px 16px; background: #eaf7ff; color: #07111f; border-radius: 11px; opacity: 0; pointer-events: none; transition: .2s; font-weight: 700; box-shadow: var(--shadow); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 720px) {
  .app-shell { padding: 0 14px 28px; }
  .topbar { min-height: 69px; }
  .connection span:last-child { display: none; }
  .topbar-actions { gap: 8px; }
  .cart-toggle > span { display: none; }
  .search-panel { padding-top: 34px; }
  .shortcut { display: none; }
  h1 { font-size: 2.2rem; }
  .search-box { min-height: 62px; padding-left: 16px; gap: 9px; }
  .search-button { padding: 0 16px; font-size: .86rem; }
  .search-box input { font-size: 1rem; }
  .search-modes { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
  .search-modes::-webkit-scrollbar { display: none; }
  .search-modes label { flex: 0 0 auto; }
  .results-header { padding: 17px 16px; }
  .legend { display: none; }
  .table-wrap { display: none !important; }
  .mobile-results[hidden] { display: none; }
  .mobile-results { display: grid; }
  .product-card { padding: 17px 16px; border-top: 1px solid var(--line); }
  .product-card:first-child { border-top: 0; }
  .card-top { display: flex; justify-content: space-between; gap: 12px; align-items: start; }
  .product-card h3 { margin: 0; font-size: .96rem; line-height: 1.35; }
  .product-card .price { white-space: nowrap; }
  .card-details { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 14px; }
  .detail-label { color: var(--muted); font-size: .69rem; text-transform: uppercase; letter-spacing: .07em; margin-bottom: 4px; }
  .detail-value { color: #c6d8e8; font-size: .82rem; }
  .cart-drawer { padding: 18px 15px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
