:root {
  --brown-900: #413935;
  --brown-700: #746560;
  --blue-500: #7ca0af;
  --blue-100: #e8f0f3;
  --cream: #f7f5f3;
  --white: #ffffff;
  --ink: #292421;
  --muted: #6e6662;
  --border: #ddd7d3;
  --success: #34745a;
  --warning: #a56b15;
  --danger: #a8453c;
  --shadow: 0 16px 42px rgba(65, 57, 53, 0.09);
  --radius: 18px;
}

* { box-sizing: border-box; }
html { color-scheme: light; scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--cream);
  color: var(--ink);
  font-family: Inter, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.5;
}
a { color: inherit; }
img { max-width: 100%; }
button, input, select, textarea { font: inherit; }
button, select { cursor: pointer; }

.topbar {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 50;
  height: 74px;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 28px;
  background: var(--white);
  border-bottom: 1px solid var(--border);
}
.menu-toggle {
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 12px;
  display: grid;
  place-content: center;
  gap: 5px;
  background: var(--brown-900);
}
.menu-toggle span { width: 21px; height: 2px; background: white; border-radius: 2px; transition: .2s ease; }
body.menu-open .menu-toggle span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
body.menu-open .menu-toggle span:nth-child(2) { opacity: 0; }
body.menu-open .menu-toggle span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; }
.brand img { width: 128px; height: 48px; object-fit: contain; object-position: left center; }
.brand-mark, .auth-mark, .setup-mark {
  display: grid;
  place-items: center;
  background: var(--blue-500);
  color: var(--white);
  font-weight: 800;
  letter-spacing: -.04em;
}
.brand-mark { width: 42px; height: 42px; border-radius: 50% 50% 46% 54%; }
.brand strong, .brand small { display: block; }
.brand strong { color: var(--brown-900); font-size: .96rem; }
.brand small { color: var(--muted); font-size: .74rem; }
.topbar-user { margin-left: auto; text-align: right; }
.topbar-user span, .topbar-user small { display: block; }
.topbar-user span { font-weight: 700; }
.topbar-user small { color: var(--muted); font-size: .76rem; }

.sidebar {
  position: fixed;
  z-index: 45;
  top: 74px;
  bottom: 0;
  left: 0;
  width: 292px;
  display: flex;
  flex-direction: column;
  padding: 18px;
  transform: translateX(-102%);
  transition: transform .24s ease;
  background: var(--brown-900);
  color: white;
  overflow-y: auto;
  box-shadow: var(--shadow);
}
body.menu-open .sidebar { transform: translateX(0); }
.sidebar nav { display: grid; gap: 6px; }
.sidebar a, .sidebar summary, .nav-logout {
  display: block;
  width: 100%;
  border: 0;
  border-radius: 10px;
  padding: 11px 13px;
  background: transparent;
  color: rgba(255,255,255,.86);
  text-decoration: none;
  text-align: left;
}
.sidebar a:hover, .sidebar a:focus-visible, .nav-logout:hover { background: rgba(255,255,255,.1); color: white; }
.sidebar .nav-item { font-weight: 750; color: white; background: rgba(124,160,175,.22); }
.sidebar summary { cursor: pointer; font-weight: 750; list-style: none; }
.sidebar summary::-webkit-details-marker { display: none; }
.sidebar summary::after { content: "⌄"; float: right; }
.sidebar details[open] summary::after { transform: rotate(180deg); }
.sidebar details a { margin-left: 12px; width: calc(100% - 12px); padding-block: 8px; font-size: .91rem; }
.logout-form { margin-top: auto; padding-top: 20px; border-top: 1px solid rgba(255,255,255,.15); }
.menu-backdrop { position: fixed; z-index: 40; inset: 74px 0 0; background: rgba(41,36,33,.35); opacity: 0; visibility: hidden; transition: .2s; }
body.menu-open .menu-backdrop { opacity: 1; visibility: visible; }

.app-main { min-height: calc(100vh - 54px); padding: 114px 32px 58px; }
.app-main > * { max-width: 1380px; margin-left: auto; margin-right: auto; }
.public-main { min-height: calc(100vh - 42px); }
.footer {
  min-height: 42px;
  padding: 12px 32px;
  display: flex;
  justify-content: space-between;
  gap: 20px;
  color: var(--brown-700);
  font-size: .78rem;
  border-top: 1px solid var(--border);
}

h1, h2, h3, p { margin-top: 0; }
h1, h2, h3 { color: var(--brown-900); line-height: 1.16; }
h1 { margin-bottom: 10px; font-size: clamp(2rem, 4vw, 3.2rem); letter-spacing: -.045em; }
h2 { font-size: 1.22rem; }
p { color: var(--muted); }
.eyebrow { margin-bottom: 8px; color: var(--blue-500); font-size: .75rem; font-weight: 850; text-transform: uppercase; letter-spacing: .16em; }
.muted, .hint { color: var(--muted); }
.hint { font-size: .84rem; }
.page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 32px; margin-bottom: 28px; }
.page-header.compact { align-items: center; }
.page-header p { max-width: 740px; margin-bottom: 0; }
.header-actions { display: flex; gap: 12px; }

.panel, .metric-card, .product-card, .shipment-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 2px 12px rgba(65,57,53,.035);
}
.panel { padding: 24px; margin-bottom: 24px; }
.panel-heading { display: flex; justify-content: space-between; gap: 16px; align-items: center; margin-bottom: 16px; }
.panel-heading h2, .panel-heading p { margin-bottom: 0; }
.panel-heading a { color: var(--blue-500); font-weight: 700; text-decoration: none; }
.content-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(300px, 1fr); gap: 24px; }
.metric-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; margin-bottom: 24px; }
.metric-card { min-height: 146px; padding: 22px; display: flex; flex-direction: column; }
.metric-card.accent { background: var(--blue-500); border-color: var(--blue-500); color: white; }
.metric-card span { font-size: .84rem; font-weight: 700; }
.metric-card strong { margin-block: auto; color: var(--brown-900); font-size: 2.6rem; line-height: 1; }
.metric-card.accent strong { color: white; }
.metric-card a { align-self: flex-start; font-weight: 750; font-size: .84rem; }
.version-number { font-size: 1.5rem !important; }
.version-pill, .format-badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 8px 13px;
  background: var(--blue-100);
  color: var(--brown-900);
  font-weight: 800;
  white-space: nowrap;
}
.format-badge.small { padding: 5px 9px; font-size: .72rem; }

.button {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: 11px;
  padding: 10px 16px;
  font-weight: 760;
  text-decoration: none;
  transition: transform .12s ease, background .12s ease;
}
.button:hover { transform: translateY(-1px); }
.button.primary { background: var(--brown-900); color: white; }
.button.secondary { background: var(--blue-100); color: var(--brown-900); border-color: #cbdce2; }
.button.ghost { background: transparent; color: var(--brown-700); border-color: var(--border); }
.button.small { min-height: 34px; padding: 6px 10px; font-size: .78rem; }
.link-button { border: 0; padding: 0; background: transparent; color: var(--brown-900); font-weight: 750; text-align: left; }

.messages { position: fixed; z-index: 80; top: 86px; right: 20px; width: min(420px, calc(100vw - 40px)); }
.message { margin-bottom: 8px; padding: 13px 16px; border-radius: 12px; color: white; box-shadow: var(--shadow); background: var(--brown-900); }
.message.success { background: var(--success); }
.message.error { background: var(--danger); }

.responsive-table { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { padding: 11px 12px; color: var(--brown-700); font-size: .72rem; text-align: left; text-transform: uppercase; letter-spacing: .07em; border-bottom: 1px solid var(--border); }
td { padding: 14px 12px; vertical-align: top; border-bottom: 1px solid #ebe7e4; font-size: .91rem; }
td strong, td small { display: block; }
td small { margin-top: 2px; color: var(--muted); }
tbody tr:last-child td { border-bottom: 0; }
code { font-size: .84em; }
.status { display: inline-flex; align-items: center; border-radius: 999px; padding: 5px 9px; background: #eeeae7; color: var(--brown-700); font-size: .73rem; font-weight: 800; white-space: nowrap; }
.status-open, .status-partial_transit, .status-queued { background: #fff0d4; color: #84520d; }
.status-packed, .status-shipped, .status-transit, .status-validated { background: var(--blue-100); color: #315867; }
.status-delivered, .status-installed { background: #e2f1e9; color: #256046; }
.status-cancelled, .status-failed, .status-rejected { background: #f7e3e0; color: #8a3028; }
.empty-state { padding: 34px 18px; text-align: center; }
.empty-state strong { color: var(--brown-900); font-size: 1.1rem; }
.empty-state p { margin: 4px 0 0; }

.quick-panel { display: grid; align-content: start; gap: 10px; }
.quick-panel a, .quick-panel .link-button { display: block; padding: 12px 14px; border-radius: 11px; background: var(--cream); text-decoration: none; }
.quick-panel form { margin: 0; }
.filter-bar { display: flex; gap: 8px; margin: -6px 0 18px; }
.filter-bar a { padding: 7px 12px; border-radius: 999px; text-decoration: none; font-size: .82rem; font-weight: 750; }
.filter-bar a.active { background: var(--brown-900); color: white; }

.search-panel { background: var(--brown-900); }
.search-form > label { display: block; color: white; font-size: 1.1rem; font-weight: 750; margin-bottom: 12px; }
.search-form > div { display: flex; gap: 10px; }
.search-form input { flex: 1; min-height: 54px; border: 0; }
.search-form .button { background: var(--blue-500); }
.search-results { display: grid; gap: 14px; }
.product-card { padding: 22px; display: flex; justify-content: space-between; align-items: center; gap: 24px; }
.product-card small { color: var(--blue-500); font-weight: 750; }
.product-card h2 { margin: 5px 0; }
.product-card p { margin-bottom: 0; }
.product-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }

.stack-form { display: grid; gap: 18px; }
.inline-form { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.inline-form label { font-weight: 750; }
.inline-form select { min-width: 320px; }
.form-panel.narrow { max-width: 760px; }
.form-grid { display: grid; gap: 16px; }
.form-grid.two { grid-template-columns: repeat(2, 1fr); }
.field { display: grid; gap: 6px; }
.field label { color: var(--brown-900); font-size: .86rem; font-weight: 760; }
.field label span { color: var(--danger); margin-left: 3px; }
.field small { color: var(--muted); }
.field .error { color: var(--danger); font-weight: 650; }
input, select, textarea {
  width: 100%;
  min-height: 44px;
  border: 1px solid #cfc8c4;
  border-radius: 10px;
  padding: 10px 12px;
  background: white;
  color: var(--ink);
}
textarea { resize: vertical; }
input[type="checkbox"], input[type="radio"] { width: 18px; min-height: 18px; }
input:focus, select:focus, textarea:focus { outline: 3px solid rgba(124,160,175,.24); border-color: var(--blue-500); }
.has-error input, .has-error select, .has-error textarea { border-color: var(--danger); }
.form-actions { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 8px; }
.form-actions.right { justify-content: flex-end; }
.form-errors, .info-box, .summary-box { border-radius: 12px; padding: 14px 16px; }
.form-errors { background: #f7e3e0; color: #8a3028; }
.info-box { background: var(--blue-100); }
.info-box p { margin: 4px 0 0; }
.summary-box { background: var(--cream); border: 1px solid var(--border); }
.summary-box ul { margin-bottom: 0; }
.quantity-input { width: 130px; }

.shipment-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.shipment-card { padding: 22px; }
.shipment-card > header { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.shipment-card h2 { margin: 3px 0 0; }
.shipment-card header small { color: var(--muted); }
.shipment-card dl { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding-block: 16px; margin: 0; }
.shipment-card dl div { padding: 10px; border-radius: 10px; background: var(--cream); }
.shipment-card dt { color: var(--muted); font-size: .72rem; text-transform: uppercase; }
.shipment-card dd { margin: 3px 0 0; font-weight: 700; }
.item-list { padding: 0; list-style: none; }
.item-list li { display: flex; justify-content: space-between; gap: 14px; padding: 9px 0; border-bottom: 1px solid var(--border); }
.tracking-link { display: block; margin: 13px 0; color: #315867; font-weight: 750; }
.shipment-actions { display: grid; grid-template-columns: 1fr 170px auto; gap: 8px; padding-top: 14px; border-top: 1px solid var(--border); }

.recognition-card dl div { display: grid; grid-template-columns: 145px 1fr; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--border); }
.recognition-card dt { color: var(--muted); }
.recognition-card dd { margin: 0; font-weight: 750; }
.timeline { padding: 0; list-style: none; counter-reset: step; }
.timeline li { position: relative; padding: 0 0 20px 42px; counter-increment: step; }
.timeline li::before { content: counter(step); position: absolute; left: 0; top: -2px; width: 28px; height: 28px; display: grid; place-items: center; border-radius: 50%; background: var(--blue-500); color: white; font-weight: 800; }
.timeline li:not(:last-child)::after { content: ""; position: absolute; left: 13px; top: 28px; bottom: 0; border-left: 2px solid var(--blue-100); }
.timeline strong, .timeline span { display: block; }
.timeline span { color: var(--muted); font-size: .85rem; }

.auth-shell, .setup-shell { min-height: calc(100vh - 42px); display: grid; place-items: center; padding: 36px 20px; background: var(--cream); }
.auth-card { width: min(460px, 100%); padding: 36px; border-radius: 24px; background: white; border: 1px solid var(--border); box-shadow: var(--shadow); }
.auth-brand { display: flex; align-items: center; gap: 13px; margin-bottom: 30px; }
.auth-brand img { max-width: 180px; max-height: 68px; object-fit: contain; }
.auth-brand p { margin: 0; font-weight: 700; }
.auth-mark { width: 58px; height: 58px; border-radius: 50% 50% 46% 54%; }
.setup-shell { display: block; }
.setup-header, .setup-card { width: min(980px, 100%); margin-inline: auto; }
.setup-header { display: flex; align-items: center; gap: 22px; margin-bottom: 22px; }
.setup-header p { margin-bottom: 0; }
.setup-mark { flex: 0 0 auto; width: 74px; height: 74px; border-radius: 50% 50% 46% 54%; font-size: 1.4rem; }
.setup-card { padding: 30px; background: white; border: 1px solid var(--border); border-radius: 24px; box-shadow: var(--shadow); }
.stepper { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; padding: 0; margin: 0 0 34px; list-style: none; }
.stepper li { position: relative; padding-top: 9px; color: var(--muted); font-size: .75rem; font-weight: 750; border-top: 4px solid var(--border); }
.stepper li.active, .stepper li.done { color: var(--brown-900); border-color: var(--blue-500); }
.setup-step { display: none; min-height: 360px; }
.setup-step.active { display: block; }
.setup-actions { display: flex; justify-content: space-between; align-items: center; padding-top: 18px; margin-top: 12px; border-top: 1px solid var(--border); }

@media (min-width: 1080px) {
  body.menu-open .app-main { padding-left: 324px; }
  .app-main { transition: padding-left .24s ease; }
}

@media (max-width: 920px) {
  .content-grid, .metric-grid, .shipment-grid { grid-template-columns: 1fr; }
  .metric-grid { grid-template-columns: repeat(3, 1fr); }
  .shipment-actions { grid-template-columns: 1fr; }
}

@media (max-width: 700px) {
  .topbar { height: 66px; padding-inline: 14px; gap: 10px; }
  .sidebar { top: 66px; width: min(88vw, 320px); }
  .menu-backdrop { inset-block-start: 66px; }
  .topbar-user { display: none; }
  .brand strong { max-width: 150px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
  .app-main { padding: 92px 14px 42px; }
  .footer { padding-inline: 14px; }
  .page-header { display: block; }
  .page-header .button, .header-actions { margin-top: 16px; width: 100%; }
  .metric-grid { grid-template-columns: 1fr; }
  .metric-card { min-height: 118px; }
  .panel, .shipment-card, .product-card { padding: 18px; }
  .product-card { display: block; }
  .product-actions { margin-top: 16px; justify-content: stretch; }
  .product-actions .button { flex: 1; }
  .form-grid.two { grid-template-columns: 1fr; }
  .search-form > div { display: grid; }
  .inline-form { display: grid; }
  .inline-form select { min-width: 0; }
  .stepper { gap: 4px; }
  .stepper li { font-size: 0; }
  .stepper li::after { content: attr(data-step-indicator); font-size: .76rem; }
  .setup-header { align-items: flex-start; }
  .setup-mark { width: 54px; height: 54px; }
  .setup-card { padding: 20px; }
  .setup-step { min-height: 0; }
  .form-actions { align-items: stretch; flex-direction: column-reverse; }
  .form-actions .button { width: 100%; }
  .responsive-table table { min-width: 760px; }
  .recognition-card dl div { grid-template-columns: 1fr; gap: 2px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
