:root {
  color-scheme: light;
  --ink: #151821;
  --muted: #6f7684;
  --line: #e4e7ec;
  --paper: #ffffff;
  --canvas: #f4f5f7;
  --violet: #7a2d8c;
  --violet-dark: #5d1f6d;
  --violet-soft: #f1e8f4;
  --green: #1f8b63;
  --amber: #a66c10;
  --red: #b63f50;
  font-family:
    Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--canvas); color: var(--ink); }
button, input { font: inherit; }
button { cursor: pointer; }
.app-shell { min-height: 100vh; display: grid; grid-template-columns: 236px 1fr; }
.sidebar {
  position: sticky; top: 0; height: 100vh; padding: 26px 18px;
  background: #151821; color: white; display: flex; flex-direction: column;
}
.brand { display: flex; gap: 12px; align-items: center; padding: 0 8px 28px; }
.brand strong, .brand small { display: block; }
.brand small { color: #9aa2b2; margin-top: 2px; }
.brand-mark {
  width: 42px; height: 42px; border-radius: 13px; display: grid; place-items: center;
  background: linear-gradient(145deg, #9f4caf, #61226f); color: white; font-weight: 800;
  box-shadow: 0 9px 30px rgba(122, 45, 140, .35);
}
.brand-mark.large { width: 58px; height: 58px; border-radius: 18px; font-size: 19px; }
nav { display: grid; gap: 6px; }
.nav-item {
  color: #aeb5c3; background: transparent; border: 0; text-align: left;
  padding: 12px 14px; border-radius: 11px; font-weight: 650;
}
.nav-item:hover, .nav-item.active { color: white; background: #272b36; }
.side-status { margin-top: auto; color: #aeb5c3; font-size: 13px; padding: 12px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #78808e; display: inline-block; margin-right: 8px; }
.dot.ok { background: #50d89b; box-shadow: 0 0 0 4px rgba(80,216,155,.1); }
main { min-width: 0; padding: 30px 34px 60px; }
.topbar { display: flex; justify-content: space-between; gap: 20px; align-items: center; margin-bottom: 26px; }
.topbar h1 { margin: 4px 0 0; font-size: clamp(25px, 3vw, 35px); }
.eyebrow { margin: 0; color: var(--violet); font-size: 11px; letter-spacing: .12em; font-weight: 800; }
.top-actions, .action-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.button { border: 0; border-radius: 11px; padding: 10px 15px; font-weight: 750; transition: .18s ease; }
.button:disabled { opacity: .5; cursor: wait; }
.button.primary { color: white; background: var(--violet); box-shadow: 0 7px 18px rgba(122,45,140,.18); }
.button.primary:hover { background: var(--violet-dark); transform: translateY(-1px); }
.button.secondary { color: var(--ink); background: var(--paper); border: 1px solid var(--line); }
.button.ghost { color: var(--muted); background: transparent; }
.button.danger { color: white; background: var(--red); }
.button.wide { width: 100%; padding: 13px; }
.mode-badge, .pill { padding: 7px 10px; border-radius: 999px; background: var(--violet-soft); color: var(--violet); font-weight: 750; font-size: 12px; }
.section { display: none; }
.section.active { display: block; }
.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.metric-card, .panel {
  background: var(--paper); border: 1px solid var(--line); border-radius: 18px;
  box-shadow: 0 8px 32px rgba(30, 34, 42, .045);
}
.metric-card { padding: 18px 20px; min-height: 130px; }
.metric-card.accent { background: linear-gradient(145deg, #7a2d8c, #9f4caf); color: white; border: none; }
.metric-card span, .metric-card small { display: block; color: var(--muted); }
.metric-card.accent span, .metric-card.accent small { color: rgba(255,255,255,.8); }
.metric-card strong { display: block; margin: 10px 0 3px; font-size: 33px; }
.panel-grid { display: grid; grid-template-columns: 1.25fr .75fr; gap: 14px; margin: 14px 0; }
.panel { padding: 21px; margin-bottom: 14px; }
.panel-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 15px; margin-bottom: 12px; }
.panel h2 { margin: 4px 0 0; font-size: 20px; }
.muted { color: var(--muted); line-height: 1.55; }
.health-list { margin: 0; display: grid; gap: 11px; }
.health-list div { display: flex; justify-content: space-between; gap: 16px; padding-bottom: 9px; border-bottom: 1px solid var(--line); }
.health-list dt { color: var(--muted); }
.health-list dd { margin: 0; font-weight: 700; text-align: right; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; }
table { width: 100%; border-collapse: collapse; min-width: 760px; font-size: 13px; }
th { text-align: left; color: var(--muted); background: #f8f9fa; font-size: 11px; letter-spacing: .04em; text-transform: uppercase; }
th, td { padding: 12px 13px; border-bottom: 1px solid var(--line); }
tr:last-child td { border-bottom: 0; }
.status { display: inline-flex; padding: 5px 8px; border-radius: 999px; font-weight: 750; font-size: 11px; background: #eef0f3; }
.status.new { background: #e8f4ee; color: var(--green); }
.status.unmapped, .status.wrong_warehouse, .status.cancelled { background: #fbeaec; color: var(--red); }
.status.in_supply, .status.stickers_ready { background: #fff3dc; color: var(--amber); }
.status.delivered, .status.documents_ready, .status.delivering { background: #e8f4ee; color: var(--green); }
.supply-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(310px, 1fr)); gap: 14px; }
.supply-card { background: white; border: 1px solid var(--line); border-radius: 18px; padding: 20px; }
.supply-card h3 { margin: 6px 0; }
.supply-card .details { display: grid; gap: 7px; margin: 18px 0; color: var(--muted); font-size: 13px; }
.documents { display: flex; flex-wrap: wrap; gap: 7px; margin: 13px 0; }
.documents a { text-decoration: none; color: var(--violet); background: var(--violet-soft); padding: 7px 9px; border-radius: 8px; font-size: 12px; font-weight: 700; }
.alert { padding: 13px 15px; margin-bottom: 14px; border-radius: 12px; color: #7d2635; background: #fbeaec; border: 1px solid #f4cbd2; }
.hidden { display: none !important; }
.login-overlay { position: fixed; inset: 0; background: rgba(13,15,20,.76); backdrop-filter: blur(8px); display: grid; place-items: center; padding: 20px; z-index: 20; }
.login-card { width: min(420px, 100%); background: white; border-radius: 22px; padding: 30px; box-shadow: 0 30px 80px rgba(0,0,0,.3); }
.login-card h2 { margin-bottom: 5px; }
.login-card label { display: grid; gap: 7px; margin: 22px 0 14px; color: var(--muted); font-size: 13px; font-weight: 700; }
.login-card input { border: 1px solid #cfd4dc; border-radius: 11px; padding: 12px 13px; outline: none; }
.login-card input:focus { border-color: var(--violet); box-shadow: 0 0 0 3px var(--violet-soft); }
.form-error { min-height: 19px; color: var(--red); text-align: center; font-size: 13px; }
.toast { position: fixed; right: 24px; bottom: 24px; max-width: 360px; padding: 13px 16px; background: #151821; color: white; border-radius: 12px; opacity: 0; transform: translateY(10px); pointer-events: none; transition: .2s; z-index: 30; }
.toast.show { opacity: 1; transform: translateY(0); }

@media (max-width: 960px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; align-items: center; padding: 12px 16px; overflow-x: auto; }
  .brand { padding: 0; min-width: max-content; }
  .brand small { display: none; }
  nav { display: flex; margin-left: 12px; }
  .side-status { display: none; }
  main { padding: 22px 18px 50px; }
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .panel-grid { grid-template-columns: 1fr; }
}

@media (max-width: 620px) {
  .sidebar { align-items: flex-start; }
  .brand strong { display: none; }
  .brand-mark { width: 38px; height: 38px; }
  .nav-item { padding: 10px 11px; font-size: 13px; }
  .topbar { align-items: flex-start; }
  .top-actions { justify-content: flex-end; }
  .top-actions .mode-badge { order: 3; }
  .metric-grid { grid-template-columns: 1fr 1fr; gap: 9px; }
  .metric-card { min-height: 112px; padding: 15px; }
  .metric-card strong { font-size: 28px; }
  .panel { padding: 16px; }
}
