/* ==========================================================================
   Company portal – layout on top of the shop's design tokens (styles.css)
   ========================================================================== */
body.portal { background: var(--paper); }
.portal [hidden] { display: none !important; }

.brand-line { display: inline-flex; align-items: center; gap: 8px; font: 700 14px/1 var(--font-display); font-stretch: 112%; text-transform: uppercase; text-decoration: none; color: var(--ink); }
.brand-line b { font-weight: 900; }
.brand-line .tag { margin-left: 6px; }

/* ---- Login ---- */
.auth { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.auth-card { width: min(420px, 100%); background: var(--surface); border: 1px solid var(--line); padding: 28px 24px; display: grid; gap: 16px; }
.auth-card h1 { font-weight: 800; font-stretch: 110%; font-size: 26px; text-transform: uppercase; }
.auth-card form { display: grid; gap: 14px; }

/* ---- Shell ---- */
.shell { display: grid; grid-template-columns: 1fr; grid-template-rows: 56px 1fr; min-height: 100dvh; }
.topbar {
  grid-column: 1 / -1; position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 12px; padding: 0 16px;
  background: var(--surface); border-bottom: 1px solid var(--line);
}
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.user-btn { display: grid; text-align: right; background: none; border: 0; cursor: pointer; font-size: 13px; font-weight: 600; line-height: 1.2; }
.user-btn small { font-weight: 400; color: var(--muted); }
.menu-btn { display: inline-grid; }

.sidenav {
  position: fixed; inset: 56px auto 0 0; width: 230px; z-index: 30;
  background: var(--surface); border-right: 1px solid var(--line); padding: 12px 8px;
  transform: translateX(-100%); transition: transform .2s; overflow-y: auto;
}
.sidenav.is-open { transform: none; }
.sidenav a {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 10px 12px; border-radius: var(--radius); text-decoration: none; font-size: 14px; font-weight: 500; color: var(--ink-2);
}
.sidenav a:hover { background: var(--stage); color: var(--ink); }
.sidenav a.is-active { background: var(--ink); color: var(--paper); }
.nav-badge { min-width: 20px; padding: 2px 6px; font-size: 11px; border-radius: var(--radius); background: var(--accent); color: #fff; text-align: center; }

.view { padding: 20px 16px 48px; min-width: 0; }
@media (min-width: 960px) {
  .shell { grid-template-columns: 230px 1fr; }
  .menu-btn { display: none; }
  .sidenav { position: sticky; top: 56px; height: calc(100dvh - 56px); transform: none; grid-row: 2; }
  .view { padding: 28px 32px 64px; grid-column: 2; }
}

/* ---- Notifications ---- */
.bell-wrap { position: relative; }
.bell { position: relative; }
.bell-count { position: absolute; top: 2px; right: 0; min-width: 18px; height: 18px; padding: 0 4px; display: grid; place-items: center; font-size: 11px; font-weight: 700; color: #fff; background: var(--accent); border-radius: 9px; }
.bell-panel {
  position: absolute; right: 0; top: 46px; width: min(380px, calc(100vw - 24px)); max-height: 70vh; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--line-strong); z-index: 60;
}
.bell-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.bell-head .link-btn { margin: 0; }
.desktop-notify { width: 100%; padding: 10px; border: 0; border-bottom: 1px solid var(--line); background: var(--stage); cursor: pointer; font-size: 13px; }
.bell-list { list-style: none; margin: 0; padding: 0; }
.bell-list li a { display: block; padding: 12px 14px; border-bottom: 1px solid var(--line); text-decoration: none; }
.bell-list li a:hover { background: var(--paper); }
.bell-list li.is-unread a { box-shadow: inset 3px 0 0 var(--accent); }
.bell-list strong { display: block; font-size: 14px; }
.bell-list span { display: block; font-size: 13px; color: var(--ink-2); margin-top: 2px; }
.bell-list time { display: block; font-size: 12px; color: var(--muted); margin-top: 4px; }
.bell-empty { padding: 20px 14px; color: var(--muted); font-size: 14px; }

/* ---- View building blocks ---- */
.view-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px 24px; margin-bottom: 20px; }
.view-head h1 { font-weight: 800; font-stretch: 110%; font-size: clamp(1.6rem, 4vw, 2.2rem); text-transform: uppercase; }
.view-head p { color: var(--muted); font-size: 14px; margin-top: 6px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.toolbar input[type="search"], .toolbar select, .toolbar input[type="number"] {
  min-height: 40px; padding: 8px 10px; border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--surface); font-size: 14px;
}
.panel { background: var(--surface); border: 1px solid var(--line); padding: 18px; margin-bottom: 18px; min-width: 0; }
.panel h2 { font: 800 15px/1.2 var(--font-display); font-stretch: 108%; text-transform: uppercase; margin-bottom: 14px; }
.panel h3 { font-size: 14px; margin: 14px 0 8px; }
.grid-2 { display: grid; gap: 18px; }
@media (min-width: 1100px) { .grid-2 { grid-template-columns: 1fr 1fr; } .grid-2 > .panel { margin-bottom: 0; } }
.split { display: grid; gap: 18px; align-items: start; }
@media (min-width: 1200px) { .split { grid-template-columns: minmax(0, 3fr) minmax(320px, 2fr); } }

/* Tables */
.table-wrap { overflow-x: auto; margin: 0 -18px; padding: 0 18px; }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
table.data th { text-align: left; font: 600 11px/1.2 var(--font-body); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); padding: 8px 10px; border-bottom: 2px solid var(--ink); white-space: nowrap; }
table.data td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.data tr:hover td { background: var(--paper); }
/* override the shop's decorative .num style */
table.data .num { text-align: right; color: inherit; font: inherit; letter-spacing: normal; white-space: nowrap; }
table.data td:first-child, table.data td:nth-child(2) { white-space: nowrap; }
table.data input[type="number"], table.data input[type="text"], table.data input[type="email"], table.data select {
  min-height: 34px; padding: 4px 8px; border: 1px solid var(--line-strong); border-radius: var(--radius); font-size: 14px; background: #fff; max-width: 100%;
}
table.data input[type="number"] { width: 84px; }
td.thumb img { width: 44px; height: 44px; object-fit: contain; background: var(--stage); }
.empty { padding: 24px 0; color: var(--muted); text-align: center; }

/* Badges & flags (status always text + colour, never colour alone) */
.badge { display: inline-block; padding: 3px 8px; font-size: 12px; font-weight: 600; border-radius: var(--radius); background: var(--stage); color: var(--ink-2); white-space: nowrap; }
.badge.s-received { background: #e9eefc; color: #1d3c8f; }
.badge.s-proof_sent { background: #fff3d6; color: #7a5200; }
.badge.s-approved { background: #e3f4ea; color: #1f6b43; }
.badge.s-in_production { background: #ece5ff; color: #4b2aa8; }
.badge.s-shipped, .badge.s-sent, .badge.s-confirmed { background: #dff4f8; color: #0b5f70; }
.badge.s-delivered, .badge.s-received-po, .badge.s-printed { background: #e3f4ea; color: #1f6b43; }
.badge.s-cancelled { background: #f3f3f0; color: #6e6e68; text-decoration: line-through; }
.badge.s-draft, .badge.s-planned { background: var(--stage); }
.flag { font-size: 12px; font-weight: 600; white-space: nowrap; }
.flag.is-late { color: var(--err); }
.flag.is-today { color: #a35b00; }
.flag::before { content: ""; display: inline-block; width: 8px; height: 8px; margin-right: 6px; border-radius: 50%; background: currentColor; vertical-align: 1px; }
.flag.is-ok::before { background: var(--ok); }
.stock-low, table.data .num.stock-low { color: var(--err); font-weight: 700; }

/* Detail view */
.detail-head { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin-bottom: 16px; }
.detail-head h1 { font-weight: 800; font-stretch: 108%; font-size: 24px; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; font-size: 14px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.form-row { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); align-items: end; margin-bottom: 12px; }
.item-card { display: grid; grid-template-columns: 96px 1fr; gap: 14px; padding: 14px 0; border-top: 1px solid var(--line); }
.item-card > img { width: 96px; height: 96px; object-fit: cover; background: var(--stage); }
.prints-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 8px; }
.print-chip { display: grid; gap: 4px; width: 110px; font-size: 12px; }
.print-chip img { width: 110px; height: 80px; object-fit: contain; background: repeating-conic-gradient(#f2f1ec 0 25%, #fff 0 50%) 0 0 / 14px 14px; border: 1px solid var(--line); }
.timeline { list-style: none; margin: 0; padding: 0; font-size: 14px; }
.timeline li { padding: 8px 0 8px 14px; border-left: 2px solid var(--line); }
.timeline time { display: block; font-size: 12px; color: var(--muted); }
pre.roster { white-space: pre-wrap; font: 13px/1.5 ui-monospace, Consolas, monospace; background: var(--paper); padding: 10px; border: 1px solid var(--line); }

/* KPI tiles */
.kpis { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); margin-bottom: 18px; }
.kpi { background: var(--surface); border: 1px solid var(--line); padding: 14px 16px; }
.kpi-label { font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.kpi-value { font: 800 26px/1.15 var(--font-display); font-stretch: 104%; margin-top: 6px; font-variant-numeric: tabular-nums; }
.kpi-delta { font-size: 12px; margin-top: 4px; color: var(--muted); }
.kpi-delta.up { color: var(--ok); }
.kpi-delta.down { color: var(--err); }
a.kpi { text-decoration: none; display: block; }
a.kpi:hover { border-color: var(--ink); }

/* Charts */
.chart { position: relative; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .grid line { stroke: var(--line); stroke-width: 1; }
.chart .axis text { fill: var(--muted); font-size: 11px; font-family: var(--font-body); }
.chart .bar { fill: var(--ink); }
.chart .bar.is-hover { fill: var(--accent); }
.chart-tip { position: absolute; pointer-events: none; background: var(--ink); color: var(--paper); font-size: 12px; padding: 6px 8px; border-radius: var(--radius); white-space: nowrap; transform: translate(-50%, -100%); margin-top: -8px; }
.hbars { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.hbar { display: grid; grid-template-columns: minmax(90px, 140px) 1fr auto; gap: 10px; align-items: center; font-size: 13px; }
.hbar-track { height: 12px; background: var(--paper); }
.hbar-fill { height: 100%; background: var(--ink); border-radius: 0 4px 4px 0; min-width: 2px; }
.hbar-label { display: flex; align-items: center; gap: 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar-value { font-variant-numeric: tabular-nums; color: var(--ink-2); }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; box-shadow: inset 0 0 0 1px rgba(0,0,0,.2); background: var(--c); }
details.table-view summary { cursor: pointer; font-size: 13px; color: var(--ink-2); margin-top: 10px; }

/* Print / nesting */
.nest-preview { background: repeating-conic-gradient(#f2f1ec 0 25%, #fff 0 50%) 0 0 / 16px 16px; border: 1px solid var(--line-strong); overflow: auto; max-height: 70vh; }
.nest-preview svg { display: block; }
.nest-stats { display: flex; flex-wrap: wrap; gap: 8px 20px; font-size: 14px; margin: 10px 0; }
.nest-stats strong { font-variant-numeric: tabular-nums; }

/* Wide modal */
.modal-wide[open] { width: min(760px, calc(100vw - 24px)); }
.check-grid { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 14px; }
.check-grid label { display: inline-flex; align-items: center; gap: 6px; }
.secret { font-family: ui-monospace, Consolas, monospace; background: var(--paper); padding: 8px 10px; border: 1px dashed var(--line-strong); user-select: all; }
.demo-banner { position: sticky; top: 0; z-index: 100; padding: 6px 16px; background: var(--accent); color: #fff; font-size: 13px; font-weight: 600; text-align: center; }
hr { border: 0; border-top: 1px solid var(--line); margin: 8px 0; }
