:root {
  --navy: #172036;
  --navy-2: #26324f;
  --yellow: #ffc82e;
  --yellow-soft: #fff6d9;
  --blue: #2759c7;
  --green: #138a5b;
  --red: #c73636;
  --ink: #1d273d;
  --muted: #68738a;
  --line: #dfe4ed;
  --surface: #ffffff;
  --canvas: #f4f6fa;
  --shadow: 0 14px 40px rgba(23, 32, 54, 0.1);
  --radius: 18px;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--canvas);
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--canvas); }
body { margin: 0; min-height: 100vh; background: var(--canvas); color: var(--ink); }
a { color: inherit; }
button, input, select, textarea { font: inherit; }
button, select { cursor: pointer; }
input, select, textarea {
  width: 100%;
  min-height: 48px;
  border: 1px solid #cfd6e3;
  border-radius: 11px;
  padding: 11px 13px;
  color: var(--ink);
  background: #fff;
  outline: none;
  transition: border-color .18s, box-shadow .18s;
}
input:focus, select:focus, textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(39, 89, 199, .12); }
textarea { resize: vertical; }
label { display: grid; gap: 7px; color: #3d4860; font-size: .9rem; font-weight: 700; }
label small, .hint { font-size: .78rem; font-weight: 500; color: var(--muted); }
h1, h2, p { margin-top: 0; }
h1 { color: var(--navy); letter-spacing: -.035em; }
h2 { color: var(--navy); letter-spacing: -.02em; }
.muted { color: var(--muted); line-height: 1.65; }
.eyebrow { color: var(--blue); font-weight: 900; letter-spacing: .13em; font-size: .72rem; margin-bottom: 9px; }
.brand-mark {
  display: block;
  width: 43px;
  height: 43px;
  flex: 0 0 auto;
  border: 2px solid rgba(255,255,255,.75);
  border-radius: 50%;
  object-fit: contain;
  background: #fff;
  box-shadow: 0 4px 12px rgba(0,0,0,.16);
}
.brand-mark.large { width: 92px; height: 92px; margin-bottom: 24px; border-color: #eef1f5; }

.app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  height: 72px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 24px;
  padding: 0 max(24px, calc((100vw - 1180px) / 2));
  color: #fff;
  background: rgba(23, 32, 54, .97);
  backdrop-filter: blur(14px);
  box-shadow: 0 1px 0 rgba(255,255,255,.08);
}
.brand { display: inline-flex; align-items: center; gap: 11px; text-decoration: none; justify-self: start; }
.brand > span:last-child { display: grid; line-height: 1; }
.brand strong { font-size: 1.02rem; letter-spacing: .08em; }
.brand small { color: #aeb8cc; font-size: .64rem; letter-spacing: .18em; margin-top: 5px; }
.desktop-nav { display: flex; align-items: center; gap: 6px; }
.desktop-nav a { padding: 10px 14px; border-radius: 9px; color: #d9deea; text-decoration: none; font-size: .9rem; font-weight: 700; }
.desktop-nav a:hover { color: #fff; background: rgba(255,255,255,.08); }
.user-menu { justify-self: end; display: flex; align-items: center; gap: 14px; }
.user-menu > span { display: grid; text-align: right; line-height: 1.2; }
.user-menu strong { font-size: .84rem; }
.user-menu small { color: #aeb8cc; font-size: .7rem; margin-top: 4px; }
.text-button { border: 0; border-left: 1px solid rgba(255,255,255,.14); padding: 6px 0 6px 14px; color: #c8d0df; background: transparent; }
.text-button:hover { color: #fff; }
.mobile-nav { display: none; }

.page-shell { width: min(1180px, calc(100% - 36px)); margin: 0 auto; padding: 46px 0 80px; }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 32px; margin-bottom: 26px; }
.page-heading h1 { font-size: clamp(2rem, 4vw, 3rem); margin-bottom: 8px; }
.page-heading > div:first-child > p:last-child { margin: 0; color: var(--muted); }
.compact-heading { align-items: center; }
.compact-heading h1 { font-size: 2.35rem; }
.rate-card { min-width: 250px; display: grid; grid-template-columns: 1fr 1fr; gap: 6px 16px; padding: 17px 19px; border-radius: 15px; color: #fff; background: var(--navy); box-shadow: var(--shadow); }
.rate-card > span { grid-column: 1 / -1; color: #aeb8cc; font-size: .72rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.rate-card strong { font-size: .93rem; }
.rate-card small { grid-column: 1 / -1; color: #aeb8cc; font-size: .7rem; }

.button { display: inline-flex; min-height: 46px; align-items: center; justify-content: center; gap: 7px; padding: 11px 17px; border: 1px solid transparent; border-radius: 11px; text-decoration: none; font-weight: 850; transition: transform .16s, box-shadow .16s, background .16s; }
.button:hover { transform: translateY(-1px); }
.button:disabled { opacity: .45; cursor: wait; transform: none; }
.button.primary { color: var(--navy); background: var(--yellow); box-shadow: 0 8px 18px rgba(255, 200, 46, .23); }
.button.primary:hover { background: #ffd34f; }
.button.secondary { color: var(--navy); border-color: #d4dae5; background: #fff; }
.button.secondary:hover { border-color: #acb6c9; box-shadow: 0 6px 16px rgba(23, 32, 54, .08); }
.button.full { width: 100%; }

.form-card { border: 1px solid #e0e5ee; border-radius: var(--radius); background: var(--surface); padding: 26px; box-shadow: 0 7px 24px rgba(23, 32, 54, .055); }
.order-form { display: grid; gap: 18px; }
.section-title { display: flex; align-items: center; gap: 13px; margin-bottom: 24px; }
.section-title > span { display: grid; place-items: center; width: 34px; height: 34px; flex: 0 0 auto; border-radius: 50%; color: var(--navy); background: var(--yellow); font-weight: 900; }
.section-title h2 { margin: 0; font-size: 1.16rem; }
.section-title p { margin: 3px 0 0; color: var(--muted); font-size: .82rem; }
.section-title.products-title .button { margin-left: auto; }
.field-grid { display: grid; gap: 17px; }
.field-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.field-grid .wide { grid-column: 1 / -1; }
.stack-form { display: grid; gap: 17px; }
fieldset { display: grid; gap: 16px; margin: 0; padding: 20px; border: 1px solid var(--line); border-radius: 14px; }
legend { padding: 0 8px; color: var(--navy); font-weight: 900; }

.product-loading { padding: 28px; border-radius: 12px; color: var(--muted); text-align: center; background: #f7f8fb; }
.product-loading.error { color: var(--red); background: #fff1f1; }
.product-rows { display: grid; gap: 16px; }
.product-row { position: relative; padding: 19px; border: 1px solid #dbe1eb; border-radius: 15px; background: #fbfcfe; }
.product-row-head { display: flex; align-items: center; gap: 9px; margin-bottom: 15px; }
.row-number { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 8px; color: #fff; background: var(--navy); font-size: .76rem; font-weight: 900; }
.product-row-head strong { font-size: .86rem; }
.remove-row { margin-left: auto; border: 0; color: var(--red); background: transparent; font-weight: 800; }
.product-picker { position: relative; z-index: 4; }
.product-search { padding-left: 40px; background-image: radial-gradient(circle at center, transparent 42%, #68738a 44%, #68738a 54%, transparent 56%); background-size: 15px 15px; background-repeat: no-repeat; background-position: 15px 15px; }
.product-results { position: absolute; top: calc(100% + 6px); left: 0; right: 0; max-height: 330px; overflow-y: auto; border-radius: 12px; background: #fff; box-shadow: 0 18px 45px rgba(23, 32, 54, .2); }
.product-results:empty { display: none; }
.product-result { display: grid; grid-template-columns: 68px 1fr; gap: 3px 10px; width: 100%; padding: 11px 13px; border: 0; border-bottom: 1px solid #edf0f5; text-align: left; color: var(--ink); background: #fff; }
.product-result:hover, .product-result:focus { background: var(--yellow-soft); }
.product-result strong { grid-row: 1 / 3; align-self: center; color: var(--blue); }
.product-result span { font-size: .84rem; font-weight: 700; }
.product-result small { color: var(--muted); font-size: .72rem; }
.no-result { margin: 0; padding: 18px; color: var(--muted); text-align: center; }
.selected-product-meta { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1px; margin: 12px 0; overflow: hidden; border: 1px solid #e2e6ef; border-radius: 10px; background: #e2e6ef; }
.selected-product-meta > span { display: grid; gap: 3px; padding: 9px 12px; background: #fff; }
.selected-product-meta small { color: var(--muted); font-size: .67rem; text-transform: uppercase; letter-spacing: .05em; }
.selected-product-meta strong { font-size: .81rem; }
.item-fields { display: grid; grid-template-columns: 1.5fr repeat(3, minmax(110px, .7fr)); gap: 12px; }
.line-total-wrap { display: flex; justify-content: flex-end; align-items: baseline; gap: 14px; margin-top: 15px; color: var(--muted); font-size: .8rem; }
.line-total-wrap strong { color: var(--navy); font-size: 1.1rem; }
.mobile-add { display: none; margin-top: 16px; width: 100%; }
.order-summary { display: grid; grid-template-columns: .75fr .75fr 1.5fr; gap: 1px; margin-top: 20px; overflow: hidden; border: 1px solid #dce2ec; border-radius: 14px; background: #dce2ec; }
.order-summary > div { display: grid; gap: 5px; padding: 17px; background: #f8f9fc; }
.order-summary span { color: var(--muted); font-size: .75rem; }
.order-summary strong { color: var(--navy); font-size: 1.25rem; }
.order-summary .grand-total { color: #fff; background: var(--navy); }
.order-summary .grand-total span, .order-summary .grand-total small { color: #aeb8cc; }
.order-summary .grand-total strong { color: var(--yellow); font-size: 1.45rem; }
.confirm-check { display: flex; align-items: flex-start; gap: 10px; margin: 18px 0; font-size: .84rem; font-weight: 600; }
.confirm-check input { width: 20px; min-height: 20px; margin: 0; accent-color: var(--blue); }
.submit-order { width: 100%; min-height: 58px; font-size: 1rem; }

.recent-section { margin-top: 38px; }
.section-heading-row { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 14px; }
.section-heading-row h2 { margin: 0; font-size: 1.2rem; }
.section-heading-row p { margin: 4px 0 0; color: var(--muted); font-size: .82rem; }
.section-heading-row > a { color: var(--blue); font-weight: 800; font-size: .85rem; }
.order-list { display: grid; gap: 9px; }
.order-list-item { display: grid; grid-template-columns: minmax(0, 1fr) 140px 220px; align-items: center; gap: 18px; min-height: 83px; padding: 15px 18px; border: 1px solid #e1e5ed; border-radius: 14px; text-decoration: none; background: #fff; box-shadow: 0 4px 14px rgba(23, 32, 54, .04); transition: border-color .16s, transform .16s, box-shadow .16s; }
.order-list.compact .order-list-item { grid-template-columns: 1fr 1fr; min-height: 72px; }
.order-list-item:hover { transform: translateY(-1px); border-color: #c3cada; box-shadow: 0 8px 20px rgba(23, 32, 54, .08); }
.order-list-item > div { display: grid; gap: 5px; }
.order-list-item strong { color: var(--navy); }
.order-list-item span, .order-list-item small { color: var(--muted); font-size: .8rem; }
.order-delivery { padding-left: 18px; border-left: 1px solid var(--line); }
.align-right { justify-items: end; text-align: right; }
.status { display: inline-flex; width: fit-content; padding: 5px 9px; border-radius: 999px; font-size: .68rem !important; font-weight: 850; }
.status.new { color: #9a6500; background: #fff2c6; }
.status.progress { color: #1c57b1; background: #e5efff; }
.status.ready { color: #087147; background: #dcf5e9; }
.status.done { color: #4f5869; background: #e9ecf1; }
.status.cancelled { color: #a02626; background: #ffe4e4; }
.filter-pills { display: flex; gap: 8px; margin: -4px 0 20px; overflow-x: auto; scrollbar-width: none; }
.filter-pills a { flex: 0 0 auto; padding: 8px 12px; border: 1px solid #d8dee8; border-radius: 999px; color: #5e697e; text-decoration: none; font-size: .77rem; font-weight: 750; background: #fff; }
.filter-pills a.active { color: #fff; border-color: var(--navy); background: var(--navy); }
.empty-state { padding: 70px 24px; border: 1px dashed #cbd3e0; border-radius: var(--radius); text-align: center; background: #fff; }

.detail-actions { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.detail-actions-buttons { display: flex; align-items: center; gap: 10px; }
.detail-actions-buttons form { margin: 0; }
.back-link { color: var(--blue); text-decoration: none; font-weight: 800; }
.order-slip { overflow: hidden; padding: 32px; border: 1px solid #dce2eb; border-radius: 20px; background: #fff; box-shadow: var(--shadow); }
.slip-header { display: flex; justify-content: space-between; align-items: center; gap: 24px; }
.slip-company { display: flex; align-items: center; gap: 16px; }
.slip-logo { display: block; flex: 0 0 68px; width: 68px; height: 68px; border: 1px solid #e2e7ee; border-radius: 50%; object-fit: contain; background: #fff; }
.slip-company h1 { margin: 0; color: var(--navy); font-size: 1.2rem; letter-spacing: .025em; }
.slip-company p { margin: 7px 0 0; color: var(--muted); font-size: .72rem; }
.slip-document { display: grid; gap: 7px; text-align: right; }
.slip-document h2 { margin: 0; color: var(--navy); font-size: 1.45rem; }
.slip-document strong { color: #456078; font-size: .78rem; }
.slip-document span { color: var(--muted); font-size: .72rem; }
.slip-accent { height: 4px; margin: 26px 0; background: #17446f; }
.slip-meta { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; padding: 1px; background: #e4e8ef; }
.slip-meta > div { display: grid; gap: 5px; min-height: 76px; padding: 16px 20px; background: #fff; }
.slip-meta span { color: var(--muted); font-size: .72rem; }
.slip-meta strong { font-size: .9rem; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { padding: 12px 14px; color: #667085; background: #f5f7fa; text-align: left; font-size: .72rem; letter-spacing: .02em; }
td { padding: 13px 14px; border-bottom: 1px solid #e7eaf0; font-size: .83rem; }
.slip-table { min-width: 980px; margin-top: 26px; }
.slip-table thead { color: #fff; background: #17446f; }
.slip-table th { color: #fff; background: transparent; }
.slip-table th:nth-last-child(-n+4), .slip-table td:nth-last-child(-n+4) { text-align: right; }
.slip-table td strong, .slip-table td small { display: block; }
.slip-table td small { margin-top: 5px; color: var(--muted); }
.slip-bottom { display: grid; grid-template-columns: 1fr 360px; gap: 46px; padding: 26px 0 8px; }
.slip-notes > span { color: var(--muted); font-size: .69rem; letter-spacing: .035em; text-transform: uppercase; }
.slip-notes > p { margin-top: 9px; line-height: 1.55; }
.exchange-note { margin-top: 18px; padding: 12px 14px; border-radius: 9px; color: #536176; background: #f4f7fa; font-size: .72rem; line-height: 1.6; }
.exchange-note span { color: var(--muted); }
.slip-totals { display: grid; gap: 8px; }
.slip-totals p { display: flex; justify-content: space-between; gap: 20px; margin: 0; padding: 8px 0; border-bottom: 1px solid var(--line); }
.slip-totals span { color: var(--muted); font-size: .82rem; }
.slip-totals .grand-total { margin-top: 1px; padding: 14px 0; border-top: 2px solid #17446f; border-bottom: 0; }
.slip-totals .grand-total span, .slip-totals .grand-total strong { color: #17446f; font-size: 1rem; }
.slip-footer { display: flex; justify-content: space-between; gap: 20px; margin-top: 20px; padding-top: 13px; border-top: 1px solid #dce2eb; color: var(--muted); font-size: .65rem; }
.status-panel { display: flex; justify-content: space-between; gap: 30px; align-items: center; margin-top: 18px; padding: 20px 24px; border-radius: 16px; color: #fff; background: var(--navy); }
.status-panel h2 { margin: 0; color: #fff; font-size: 1rem; }
.status-panel p { margin: 5px 0 0; color: #aeb8cc; font-size: .78rem; }
.status-panel form { display: flex; gap: 10px; }
.status-panel select { min-width: 230px; }
.print-button { margin: 0 0 18px auto; }

.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
.stat-grid > div { display: grid; gap: 7px; padding: 20px; border: 1px solid #e1e5ed; border-radius: 15px; background: #fff; }
.stat-grid span { color: var(--muted); font-size: .78rem; }
.stat-grid strong { color: var(--navy); font-size: 1.8rem; }
.admin-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-bottom: 18px; }
.admin-grid h2 { margin-bottom: 20px; font-size: 1.15rem; }
.admin-table-card { margin-bottom: 18px; }
.admin-table-card .table-wrap { max-height: 520px; }
.admin-table-card thead { position: sticky; top: 0; z-index: 2; }
.product-admin-table table { min-width: 800px; }
.table-search { width: min(290px, 100%); }
.table-search input { min-height: 42px; }

.login-page, .install-page { display: grid; min-height: 100vh; place-items: center; padding: 24px; background: radial-gradient(circle at 15% 15%, rgba(255,200,46,.12), transparent 28%), radial-gradient(circle at 85% 85%, rgba(39,89,199,.14), transparent 28%), var(--navy); }
.login-card, .install-card { width: min(460px, 100%); padding: 38px; border: 1px solid rgba(255,255,255,.12); border-radius: 24px; background: #fff; box-shadow: 0 25px 70px rgba(0,0,0,.28); }
.install-card { width: min(680px, 100%); }
.login-card h1, .install-card h1 { font-size: 1.9rem; margin-bottom: 10px; }
.secure-note { margin: 22px 0 0; color: var(--muted); text-align: center; font-size: .74rem; }
.alert, .toast { padding: 13px 15px; border-radius: 11px; font-size: .86rem; font-weight: 700; }
.alert { margin-bottom: 18px; }
.alert.error, .toast.error { color: #922a2a; background: #ffe7e7; }
.alert.success, .toast.success { color: #0c6a46; background: #dff6ec; }
.alert.warning, .toast.warning { color: #8b6100; background: #fff1c4; }
.toast { position: fixed; top: 84px; left: 50%; z-index: 100; width: min(560px, calc(100% - 30px)); transform: translateX(-50%); box-shadow: 0 14px 40px rgba(23,32,54,.16); animation: toast-in .25s ease-out; }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, -8px); } }

@media (max-width: 800px) {
  body { padding-bottom: 76px; }
  .app-header { height: 62px; grid-template-columns: 1fr auto; padding: 0 15px; }
  .app-header .brand-mark { width: 37px; height: 37px; border-radius: 10px; }
  .desktop-nav { display: none; }
  .user-menu > span { display: none; }
  .text-button { border-left: 0; padding-left: 0; }
  .mobile-nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 60; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; height: 69px; padding-bottom: env(safe-area-inset-bottom); border-top: 1px solid #e0e5ed; background: rgba(255,255,255,.96); backdrop-filter: blur(14px); box-shadow: 0 -8px 22px rgba(23,32,54,.08); }
  .mobile-nav a { display: grid; place-items: center; align-content: center; gap: 3px; color: #5e687c; text-decoration: none; font-size: .67rem; font-weight: 800; }
  .mobile-nav a span { color: var(--navy); font-size: 1.2rem; line-height: 1; }
  .page-shell { width: min(100% - 22px, 680px); padding: 25px 0 42px; }
  .page-heading { align-items: stretch; flex-direction: column; gap: 16px; }
  .page-heading h1 { font-size: 2rem; }
  .compact-heading .button { width: 100%; }
  .rate-card { min-width: 0; }
  .form-card { padding: 18px 14px; border-radius: 16px; }
  .section-title { align-items: flex-start; }
  .section-title.products-title .button { display: none; }
  .field-grid.two { grid-template-columns: 1fr; }
  .field-grid .wide { grid-column: auto; }
  .product-row { padding: 14px 11px; }
  .selected-product-meta { grid-template-columns: 1fr 1fr; }
  .selected-product-meta > span:last-child { grid-column: 1 / -1; }
  .item-fields { grid-template-columns: 1fr 1fr; }
  .color-field { grid-column: 1 / -1; }
  .mobile-add { display: inline-flex; }
  .order-summary { grid-template-columns: 1fr 1fr; }
  .order-summary .grand-total { grid-column: 1 / -1; }
  .order-list-item, .order-list.compact .order-list-item { grid-template-columns: 1fr auto; gap: 12px; padding: 14px; }
  .order-delivery { display: none !important; }
  .order-main small { max-width: 210px; }
  .filter-pills { margin-right: -11px; }
  .order-slip { padding: 20px 15px; }
  .slip-header { align-items: flex-start; }
  .slip-logo { flex-basis: 50px; width: 50px; height: 50px; }
  .slip-company { gap: 10px; }
  .slip-company h1 { font-size: .95rem; }
  .slip-company p { display: none; }
  .slip-document h2 { font-size: 1rem; }
  .slip-accent { margin: 20px 0; }
  .slip-meta { grid-template-columns: 1fr 1fr; }
  .slip-meta > div { padding: 13px; }
  .slip-bottom { grid-template-columns: 1fr; padding: 20px 17px; }
  .status-panel { align-items: stretch; flex-direction: column; }
  .status-panel form { flex-direction: column; }
  .status-panel select { min-width: 0; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .stat-grid > div { padding: 15px; }
  .admin-grid { grid-template-columns: 1fr; }
  .section-heading-row { align-items: stretch; flex-direction: column; }
  .table-search { width: 100%; }
  .login-card, .install-card { padding: 28px 22px; border-radius: 20px; }
  .toast { top: 70px; }
}

@media print {
  @page { size: A4; margin: 10mm; }
  :root, html, body { background: #fff !important; }
  body { padding: 0 !important; }
  .app-header, .mobile-nav, .toast, .print-button, .detail-actions, .status-panel { display: none !important; }
  .page-shell, .print-shell { width: 100% !important; margin: 0 !important; padding: 0 !important; }
  .order-slip { border: 0; border-radius: 0; box-shadow: none; }
  .order-slip { padding: 0; }
  .slip-logo, .slip-accent, .slip-table thead { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .slip-meta { grid-template-columns: repeat(3, 1fr); }
  .table-wrap { overflow: visible; }
  .slip-table { min-width: 0; font-size: 8pt; }
  .slip-table th, .slip-table td { padding: 6px; }
  .slip-bottom { grid-template-columns: 1fr 260px; gap: 24px; padding: 16px 0 0; }
  .status { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
