:root {
  --ink: #0f172a; --mut: #64748b; --line: #e2e8f0; --soft: #f8fafc; --bg: #f1f5f9; --card: #fff;
  --accent: #2563eb; --accent-soft: #dbeafe; --ok: #15803d; --ok-soft: #dcfce7; --warn: #b45309; --warn-soft: #fef3c7;
  --bad: #b91c1c; --bad-soft: #fee2e2; --promo: #9a3412; --promo-soft: #ffedd5; --radius: 10px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--ink); font: 14px/1.5 -apple-system, "Segoe UI", Inter, Roboto, Arial, sans-serif; }
button, input, select { font: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }
h1 { font-size: 22px; margin: 0; }
h3 { margin: 0; font-size: 15px; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.muted { color: var(--mut); }
.small { font-size: 12px; }

.layout { display: flex; min-height: 100vh; }
.sidebar { width: 220px; flex: none; background: var(--card); border-right: 1px solid var(--line); display: flex; flex-direction: column; padding: 16px 12px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; gap: 10px; align-items: center; padding: 0 6px 18px; }
.brand b { display: block; font-size: 15px; } .brand small { color: var(--mut); }
.logo { width: 34px; height: 34px; border-radius: 9px; background: var(--accent); color: #fff; display: grid; place-items: center; font-weight: 700; }
nav a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; color: var(--ink); font-weight: 500; }
nav a svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
nav a:hover { background: var(--soft); }
nav a.on { background: var(--accent-soft); color: var(--accent); }
.count { margin-left: auto; background: var(--accent); color: #fff; border-radius: 10px; font-size: 11px; padding: 1px 7px; }
.count:empty { display: none; }
.side-foot { margin-top: auto; border-top: 1px solid var(--line); padding-top: 12px; }
.user { color: var(--mut); font-size: 12px; margin-top: 10px; padding: 0 6px; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.bar { height: 56px; background: var(--card); border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 16px; padding: 0 24px; position: sticky; top: 0; z-index: 5; }
.store-pick { display: flex; align-items: center; gap: 8px; color: var(--mut); }
.store-pick select { min-width: 200px; }
.today { color: var(--mut); margin-left: auto; }
select, input[type=search], input[type=text], input:not([type]) { border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; background: var(--card); }
.banner { background: var(--warn-soft); color: var(--warn); border-bottom: 1px solid #fcd34d; padding: 10px 24px; font-weight: 500; }
.banner.bad { background: var(--bad-soft); color: var(--bad); border-color: #fca5a5; }
main { padding: 24px; max-width: 1400px; width: 100%; outline: none; }

.btn { border: 1px solid var(--line); background: var(--card); border-radius: 8px; padding: 7px 14px; cursor: pointer; font-weight: 600; white-space: nowrap; }
.btn:hover:not(:disabled) { background: var(--soft); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover:not(:disabled) { background: #1d4ed8; }
.btn.ghost { background: var(--soft); }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .5; cursor: default; }
.link { background: none; border: 0; color: var(--accent); cursor: pointer; padding: 0; font-weight: 600; }
.icon { background: none; border: 0; cursor: pointer; font-size: 16px; color: var(--mut); padding: 4px 8px; }

.head { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.head .grow { flex: 1; min-width: 240px; }
.head p { margin: 4px 0 0; color: var(--mut); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.tiles { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile { padding: 14px 16px; }
.tile .label { color: var(--mut); font-weight: 500; }
.tile .big { font-size: 26px; font-weight: 700; margin: 2px 0; }
.tile.bad .big { color: var(--bad); } .tile.warn .big { color: var(--warn); }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 12px 14px; margin-bottom: 12px; }
.toolbar input[type=search] { min-width: 240px; }
.toolbar .right { margin-left: auto; color: var(--mut); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; background: var(--card); padding: 7px 12px; cursor: pointer; border-right: 1px solid var(--line); }
.seg button:last-child { border-right: 0; }
.seg button.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

table { border-collapse: collapse; width: 100%; }
th, td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { color: var(--mut); font-weight: 600; font-size: 12px; background: var(--soft); white-space: nowrap; }
td.r, th.r { text-align: right; }
tr.click { cursor: pointer; } tr.click:hover td { background: #f8fbff; }
tr.group td { background: var(--soft); font-weight: 700; font-size: 12px; color: var(--mut); letter-spacing: .03em; text-transform: uppercase; padding: 7px 12px; }
.table-wrap { overflow-x: auto; }
.meta { color: var(--mut); font-size: 12px; }
.tag { display: inline-block; font-size: 11px; font-weight: 700; border-radius: 4px; padding: 1px 6px; margin-right: 6px; background: var(--soft); border: 1px solid var(--line); color: var(--mut); }
.tag.em { background: var(--bad-soft); color: var(--bad); border-color: #fca5a5; }
.badge { display: inline-block; font-size: 12px; font-weight: 600; border-radius: 999px; padding: 2px 9px; background: var(--soft); border: 1px solid var(--line); }
.badge.approved { background: var(--ok-soft); color: var(--ok); border-color: #86efac; }
.badge.exported { background: var(--accent-soft); color: var(--accent); border-color: #93c5fd; }
.flag { display: inline-block; font-size: 12px; border-radius: 5px; padding: 1px 7px; margin: 1px 4px 1px 0; background: var(--warn-soft); color: var(--warn); }
.flag.bad { background: var(--bad-soft); color: var(--bad); }
.flag.promo { background: var(--promo-soft); color: var(--promo); }
.empty { padding: 40px; text-align: center; color: var(--mut); }

.crumbs { color: var(--mut); margin-bottom: 12px; }
.ohead { padding: 18px 20px; margin-bottom: 14px; }
.ohead .top { display: flex; gap: 16px; align-items: flex-start; flex-wrap: wrap; }
.ohead h1 { margin: 6px 0 2px; }
.ohead .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.facts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; border-top: 1px solid var(--line); margin-top: 14px; padding-top: 14px; }
.facts .label { color: var(--mut); font-size: 12px; } .facts .v { font-weight: 700; font-size: 16px; }
.note { border-radius: var(--radius); padding: 10px 14px; margin-bottom: 14px; background: var(--warn-soft); color: #78350f; border: 1px solid #fcd34d; }
.panel-head { display: flex; gap: 16px; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.panel-head h3 { margin-right: auto; }
.check { display: inline-flex; gap: 6px; align-items: center; cursor: pointer; }
.switch { display: inline-flex; gap: 8px; align-items: center; cursor: pointer; }
.switch input { appearance: none; width: 34px; height: 20px; background: var(--line); border-radius: 10px; position: relative; cursor: pointer; transition: background .15s; }
.switch input::after { content: ""; position: absolute; width: 16px; height: 16px; background: #fff; border-radius: 50%; top: 2px; left: 2px; transition: left .15s; }
.switch input:checked { background: var(--accent); } .switch input:checked::after { left: 16px; }
.art { background: none; border: 0; padding: 0; text-align: left; font-weight: 600; cursor: pointer; color: var(--ink); max-width: 280px; }
.art:hover { color: var(--accent); }
.manual { background: #f8fafc; }
.calc { background: #fbfaff; color: #334155; }
.stepper { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.stepper button { border: 0; background: var(--soft); width: 30px; cursor: pointer; }
.stepper button:disabled { cursor: default; opacity: .4; }
.stepper input { width: 56px; border: 0; border-left: 1px solid var(--line); border-right: 1px solid var(--line); border-radius: 0; text-align: center; padding: 5px 4px; }
.stepper.edited input { background: var(--warn-soft); font-weight: 700; }
.why b { font-weight: 600; }
.zero td { color: var(--mut); }

.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(760px, 100%); background: var(--card); box-shadow: -8px 0 30px rgba(15, 23, 42, .15); z-index: 20; overflow-y: auto; }
.drawer header { display: flex; gap: 12px; padding: 18px 22px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--card); z-index: 1; }
.drawer header h2 { margin: 0; font-size: 18px; } .drawer header .meta { margin-top: 2px; }
.drawer header .icon { margin-left: auto; align-self: flex-start; }
.drawer section { padding: 16px 22px; }
.drawer h4 { margin: 0 0 8px; font-size: 14px; }
.sugg { display: grid; grid-template-columns: 120px 1fr; gap: 16px; background: var(--soft); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.sugg .big { font-size: 32px; font-weight: 700; line-height: 1.1; }
.fgrid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px 16px; }
.fgrid .label { color: var(--mut); font-size: 12px; } .fgrid .v { font-weight: 700; }
.legend { display: flex; flex-wrap: wrap; gap: 12px; font-size: 12px; color: var(--mut); margin-bottom: 4px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.chart svg { width: 100%; height: auto; display: block; }
.build td { padding: 7px 10px; } .build tr.total td { font-weight: 700; border-top: 2px solid var(--ink); }

.month { display: flex; align-items: center; gap: 8px; }
.month b { min-width: 150px; text-align: center; font-size: 15px; }
.day { display: grid; grid-template-columns: 110px 1fr; gap: 16px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.day:last-child { border-bottom: 0; }
.day .date b { display: block; font-size: 15px; }
.item { display: flex; gap: 10px; align-items: flex-start; padding: 6px 0; flex-wrap: wrap; }
.item .what { flex: 1; min-width: 240px; }
.kind { font-size: 11px; font-weight: 700; border-radius: 4px; padding: 2px 7px; white-space: nowrap; }
.kind.public_holiday { background: var(--bad-soft); color: var(--bad); }
.kind.joint_leave { background: #fce7f3; color: #9d174d; }
.kind.retail_day { background: #ede9fe; color: #5b21b6; }
.kind.period { background: var(--ok-soft); color: var(--ok); }
.kind.promotion { background: var(--promo-soft); color: var(--promo); }
.kind.ai_tip { background: #e0e7ff; color: #3730a3; }
.kind.order_day { background: var(--soft); color: var(--mut); border: 1px solid var(--line); }
.tip { background: #f5f7ff; border: 1px solid #c7d2fe; border-radius: 8px; padding: 10px 12px; margin-top: 4px; }
.tip .act { margin-top: 6px; }
.tip .btns { display: flex; gap: 8px; margin-top: 8px; align-items: center; }

.chat { position: fixed; top: 0; right: 0; bottom: 0; width: min(440px, 100%); background: var(--card); box-shadow: -8px 0 30px rgba(15, 23, 42, .15); z-index: 30; display: flex; flex-direction: column; }
.chat header { display: flex; gap: 8px; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.chat header p { margin: 4px 0 0; color: var(--mut); font-size: 12px; }
.msgs { flex: 1; overflow-y: auto; padding: 16px 18px; display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 92%; padding: 10px 12px; border-radius: 12px; }
.msg.user { align-self: flex-end; background: var(--accent); color: #fff; }
.msg.bot { align-self: flex-start; background: var(--soft); border: 1px solid var(--line); }
.msg.bot p { margin: 0 0 6px; } .msg.bot ul { margin: 4px 0 6px; padding-left: 18px; }
.msg.wait { color: var(--mut); font-style: italic; }
.hint { color: var(--mut); font-size: 13px; }
.chat form { display: flex; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--line); }
.chat form input { flex: 1; }
.scrim { position: fixed; inset: 0; background: rgba(15, 23, 42, .25); z-index: 15; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 8px; z-index: 40; max-width: 90vw; }
.toast.bad { background: var(--bad); }
.skeleton { color: var(--mut); padding: 40px; text-align: center; }

@media (max-width: 1100px) { .tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); } .facts { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (max-width: 760px) {
  .layout { flex-direction: column; }
  .sidebar { width: auto; height: auto; position: static; flex-direction: row; align-items: center; padding: 8px 12px; gap: 8px; border-right: 0; border-bottom: 1px solid var(--line); }
  .brand { padding: 0; } .brand div { display: none; }
  nav { display: flex; gap: 2px; } nav a { padding: 7px 8px; font-size: 13px; }
  .side-foot { margin: 0 0 0 auto; border: 0; padding: 0; } .user { display: none; }
  .bar { padding: 0 16px; } .store-pick select { min-width: 0; }
  main { padding: 16px; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .facts, .fgrid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sugg { grid-template-columns: 1fr; }
  .day { grid-template-columns: 1fr; gap: 4px; }

}
#lines td:first-child { min-width: 240px; }
#lines .meta .flag { white-space: nowrap; }
.head .check { align-self: center; color: var(--mut); }

/* calendar month view */
.cal-layout { display: grid; grid-template-columns: minmax(0, 2.2fr) minmax(280px, 1fr); gap: 16px; align-items: start; }
.cal-head { display: flex; align-items: center; gap: 10px; padding: 12px 14px; flex-wrap: wrap; border-bottom: 1px solid var(--line); }
.cal-head b { min-width: 140px; text-align: center; font-size: 15px; }
.cal-head .legend { margin: 0 0 0 auto; }
.legend i.lg { width: 10px; height: 10px; border-radius: 2px; display: inline-block; margin-right: 5px; vertical-align: -1px; }
.cal-dow { display: grid; grid-template-columns: repeat(7, 1fr); border-bottom: 1px solid var(--line); }
.cal-dow span { padding: 6px 8px; font-size: 12px; font-weight: 600; color: var(--mut); }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); }
.cal-day { min-height: 104px; border: 0; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); background: var(--card); text-align: left; padding: 4px 0 6px; cursor: pointer; display: flex; flex-direction: column; gap: 2px; overflow: hidden; }
.cal-day:nth-child(7n) { border-right: 0; }
.cal-day:hover { background: #f8fbff; }
.cal-day.out { background: var(--soft); color: var(--mut); }
.cal-day.picked { box-shadow: inset 0 0 0 2px var(--accent); }
.cal-num { font-weight: 600; padding: 0 8px; font-size: 13px; }
.cal-day.today .cal-num { color: #fff; background: var(--accent); border-radius: 10px; margin-left: 4px; padding: 0 7px; align-self: flex-start; }
.chip { font-size: 11px; line-height: 16px; padding: 0 6px; margin: 0 4px; border-radius: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip.span { margin: 0 -1px; border-radius: 0; }
.chip.public_holiday, .lg.public_holiday { background: var(--bad-soft); color: var(--bad); }
.chip.joint_leave, .lg.joint_leave { background: #fce7f3; color: #9d174d; }
.chip.retail_day, .lg.retail_day { background: #ede9fe; color: #5b21b6; }
.chip.period, .lg.period { background: var(--ok-soft); color: var(--ok); }
.chip.promotion, .lg.promotion { background: var(--promo-soft); color: var(--promo); }
.chip.ai_tip, .lg.ai_tip { background: #e0e7ff; color: #3730a3; }
.more { font-size: 11px; color: var(--mut); padding: 0 8px; }
.side { padding: 16px 18px; position: sticky; top: 72px; max-height: calc(100vh - 90px); overflow-y: auto; }
.side h3 { margin-bottom: 8px; }
.side .item { padding: 8px 0; border-top: 1px solid var(--line); }
/* floating assistant button */
.fab { position: fixed; right: 24px; bottom: 24px; z-index: 12; display: inline-flex; gap: 8px; align-items: center; background: var(--accent); color: #fff; border: 0; border-radius: 999px; padding: 12px 18px; font-weight: 700; cursor: pointer; box-shadow: 0 8px 24px rgba(37, 99, 235, .35); }
.fab:hover { background: #1d4ed8; }
.fab svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; }
@media (max-width: 1000px) { .cal-layout { grid-template-columns: 1fr; } .side { position: static; max-height: none; } .cal-day { min-height: 72px; } }

.note.moq { background: var(--bad-soft); border-color: #fca5a5; color: #7f1d1d; }
.note.moq .opts { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.note.moq .opt { background: #fff; border: 1px solid #fca5a5; border-radius: 6px; padding: 3px 9px; }
.v.neg { color: var(--bad); }

tr.section td { background: #f1f5f9; color: var(--ink); text-transform: none; letter-spacing: 0; font-size: 13px; }
tr.section.promo td { background: var(--promo-soft); color: var(--promo); }
tr.section.promo td span { font-weight: 400; margin-left: 8px; }
.moqbar { display: block; height: 6px; background: var(--line); border-radius: 3px; margin-top: 4px; overflow: hidden; }
.moqbar i { display: block; height: 100%; background: var(--bad); }
.moqbar.ok i { background: var(--ok); }

.stepper.rounded input { background: #fde68a; font-weight: 700; }
.stepper.rounded { border-color: #f59e0b; box-shadow: 0 0 0 2px #fde68a; }
.qtycell .pack { font-size: 11px; color: var(--mut); margin-top: 2px; }
.qtycell .roundnote { font-size: 11px; color: var(--warn); font-weight: 600; margin-top: 2px; white-space: nowrap; }

/* assistant: floating window, page stays usable */
.chat { top: auto; left: auto; right: 24px; bottom: 88px; width: min(400px, calc(100vw - 32px)); height: min(560px, calc(100vh - 120px));
        border-radius: 14px; border: 1px solid var(--line); box-shadow: 0 16px 48px rgba(15, 23, 42, .22); overflow: hidden; z-index: 25; }
.chat header { cursor: default; background: var(--soft); }
.chat header h3 { font-size: 14px; } .chat header p { font-size: 11px; }
.chat.min { height: auto; }
.chat.min .msgs, .chat.min form, .chat.min header p { display: none; }
.chat.min header { padding: 10px 14px; }


/* minimum order */
.facts .fact-moq { border-radius: 10px; padding: 8px 12px; margin: -8px 0; }
.facts .fact-moq.bad { background: #fff5f5; border: 1px solid #fecaca; }
.facts .fact-moq.bad .label { color: #991b1b; font-weight: 600; }
.moq-now { font-weight: 700; font-size: 16px; } .moq-of { color: var(--mut); font-weight: 500; font-size: 13px; }
.fact-moq.bad .moq-now { color: #b91c1c; }
.moqbar { display: block; height: 6px; background: #e2e8f0; border-radius: 3px; margin: 6px 0 6px; overflow: hidden; }
.fact-moq.bad .moqbar { background: #fde2e2; }
.moqbar i { display: block; height: 100%; border-radius: 3px; background: linear-gradient(90deg, #f87171, #dc2626); }
.moqbar.ok i { background: linear-gradient(90deg, #4ade80, #16a34a); }
.pill { display: inline-block; font-size: 11px; font-weight: 700; border-radius: 999px; padding: 1px 8px; }
.pill.bad { background: #dc2626; color: #fff; } .pill.ok { background: var(--ok-soft); color: var(--ok); }
/* calculation view: group titles above their columns, plain like the rest of the table */
table.calc-view th.grp { text-align: center; font-weight: 600; color: var(--mut); padding-bottom: 2px; border-bottom: 0;
                         background: var(--soft); background-image: linear-gradient(var(--line), var(--line)); background-size: calc(100% - 16px) 1px;
                         background-position: center bottom 2px; background-repeat: no-repeat; }
table.calc-view tr.grp-row th[rowspan] { vertical-align: bottom; }
table.calc-view td[data-col="need"] b, table.calc-view td[data-col="expected"] b { color: var(--ink); }
/* promotion pop-up */
.promo-btn { border: 0; cursor: pointer; font: inherit; font-size: 12px; }
.promo-btn:hover { filter: brightness(.95); text-decoration: underline; }
.promo-pop { position: absolute; z-index: 30; width: 320px; background: var(--card); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 12px 32px rgba(15, 23, 42, .18); padding: 12px 14px; }
.promo-pop header { display: flex; gap: 8px; align-items: flex-start; margin-bottom: 6px; } .promo-pop header b { flex: 1; font-size: 13px; }
.promo-pop dl { display: grid; grid-template-columns: 110px 1fr; gap: 4px 10px; margin: 0; font-size: 13px; }
.promo-pop dt { color: var(--mut); } .promo-pop dd { margin: 0; font-weight: 600; }
.promo-pop p { margin: 0; font-size: 13px; }

table.calc-view th, table.calc-view td { padding: 8px 7px; }
table.calc-view td[data-col="article"] { min-width: 200px; max-width: 240px; }
table.calc-view .art { max-width: 220px; }
table.calc-view .stepper input { width: 40px; }
table.calc-view .stepper button { width: 24px; }
table.calc-view td[data-col="formula"] .meta { white-space: nowrap; }

/* dropdowns: own arrow with room on the right */
select { appearance: none; -webkit-appearance: none; padding: 7px 34px 7px 10px; cursor: pointer;
  background: var(--card) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") no-repeat right 12px center; }

/* ---------- tablet */
@media (max-width: 1100px) {
  .sidebar { width: 190px; }
  .facts { grid-template-columns: repeat(2, minmax(0, 1fr)); row-gap: 16px; }
  .cal-layout { grid-template-columns: 1fr; }
  .side { position: static; max-height: none; }
}
/* ---------- phone */
@media (max-width: 760px) {
  body { font-size: 13px; }
  .bar { height: auto; padding: 8px 12px; gap: 8px; flex-wrap: wrap; position: static; }
  .store-pick { flex: 1; } .store-pick select { flex: 1; width: 100%; }
  .today { display: none; }
  main { padding: 12px; }
  h1 { font-size: 19px; }
  .head { margin-bottom: 12px; gap: 10px; } .head .grow { min-width: 0; flex-basis: 100%; }
  .head p { font-size: 12px; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .tile { padding: 10px 12px; } .tile .big { font-size: 20px; } .tile .meta { display: none; }
  .tiles .tile:last-child { grid-column: span 2; }
  .toolbar { padding: 10px; gap: 8px; }
  .toolbar input[type=search] { min-width: 0; width: 100%; }
  .seg { display: flex; width: 100%; } .seg button { flex: 1; padding: 7px 4px; font-size: 12px; }
  .toolbar select { flex: 1; } .toolbar .right { margin-left: 0; font-size: 11px; width: 100%; }
  th, td { padding: 8px 8px; }
  /* PO list: vendor, value, status, attention */
  #list th:nth-child(3), #list td:nth-child(3), #list th:nth-child(4), #list td:nth-child(4),
  #list th:nth-child(5), #list td:nth-child(5) { display: none; }
  #list .tag { display: none; }
  /* PO detail */
  .ohead { padding: 14px; } .ohead .actions { margin-left: 0; width: 100%; } .ohead .actions .btn { flex: 1; }
  .facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .facts .fact-moq { grid-column: span 2; }
  .panel-head { gap: 10px; } .panel-head h3 { width: 100%; }
  #lines td[data-col="article"] { min-width: 150px; }
  #lines .art { max-width: 180px; }
  #lines th[data-col="stock"], #lines td[data-col="stock"], #lines th[data-col="onorder"], #lines td[data-col="onorder"],
  #lines th[data-col="why"], #lines td[data-col="why"] { display: none; }
  table.calc-view th[data-col="stock"], table.calc-view td[data-col="stock"], table.calc-view th[data-col="onorder"], table.calc-view td[data-col="onorder"] { display: table-cell; }
  /* article panel */
  .drawer header, .drawer section { padding-left: 14px; padding-right: 14px; }
  /* calendar: chips become coloured marks */
  .cal-head .legend { margin: 6px 0 0; width: 100%; }
  .cal-day { min-height: 54px; padding: 3px 0; }
  .cal-num { font-size: 12px; padding: 0 5px; }
  .chip { font-size: 0; height: 5px; padding: 0; margin: 0 3px; border-radius: 3px; }
  .chip.span { margin: 0 -1px; }
  .more { font-size: 9px; padding: 0 4px; }
  .day { grid-template-columns: 1fr; }
  /* assistant: bottom sheet; button as an icon */
  .chat { right: 0; left: 0; bottom: 0; width: 100%; height: 75vh; border-radius: 14px 14px 0 0; }
  .fab { right: 14px; bottom: 14px; padding: 12px; } .fab span { display: none; }
  .promo-pop { width: calc(100vw - 24px); left: 12px !important; }
}

.attn-m { display: none; margin-top: 4px; }
@media (max-width: 760px) {
  .sidebar { width: auto; }
  nav a { white-space: nowrap; }
  .attn-m { display: block; }
  #list th:nth-child(8), #list td:nth-child(8) { display: none; }
  #list td:nth-child(2) { width: 100%; }
}

@media (max-width: 760px) {
  #list th:nth-child(7), #list td:nth-child(7) { display: none; }
  #list th:first-child, #list td:first-child { width: 28px; padding-right: 0; }
}

/* phone: each order line becomes a card (the calculation view keeps its table and scrolls) */
@media (max-width: 760px) {
  #lines table:not(.calc-view) thead { display: none; }
  #lines table:not(.calc-view), #lines table:not(.calc-view) tbody { display: block; }
  #lines table:not(.calc-view) tr.section { display: block; }
  #lines table:not(.calc-view) tr.section td { display: block; }
  #lines table:not(.calc-view) tr[data-art] { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px 8px;
                                               padding: 10px 12px; border-bottom: 1px solid var(--line); }
  #lines table:not(.calc-view) tr[data-art] td { border: 0; padding: 0; text-align: left; }
  #lines table:not(.calc-view) td[data-col="article"] { grid-column: 1 / -1; min-width: 0; }
  #lines table:not(.calc-view) td[data-label]::before { content: attr(data-label); display: block; font-size: 10px; font-weight: 600; color: var(--mut); }
  #lines table:not(.calc-view) td[data-col="exp"] .meta { display: inline; margin-left: 4px; }
  #lines table:not(.calc-view) td[data-col="order"] { grid-column: span 2; }
  #lines table:not(.calc-view) td[data-col="stock"], #lines table:not(.calc-view) td[data-col="onorder"] { display: block; }
  #lines table:not(.calc-view) td[data-col="why"] { display: none; }
  #lines .art { max-width: none; }
}

.flag.new { background: #e0f2fe; color: #075985; }
.note.info { background: #f0f9ff; border-color: #bae6fd; color: #0c4a6e; }
/* collapsible sidebar */
.brand { position: relative; }
.side-toggle { margin-left: auto; padding: 4px; border-radius: 6px; }
.side-toggle svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; transition: transform .15s; }
.side-toggle:hover { background: var(--soft); }
body.side-min .sidebar { width: 68px; padding-left: 10px; padding-right: 10px; }
body.side-min .brand { flex-direction: column; padding-bottom: 12px; }
body.side-min .brand-text, body.side-min .nav-label, body.side-min .user { display: none; }
body.side-min .side-toggle { margin: 6px 0 0; } body.side-min .side-toggle svg { transform: rotate(180deg); }
body.side-min nav a { justify-content: center; position: relative; padding: 10px 0; }
body.side-min .count { position: absolute; top: 2px; right: 2px; margin: 0; font-size: 10px; padding: 0 5px; }
@media (max-width: 760px) { .side-toggle { display: none; } body.side-min .sidebar { width: auto; } body.side-min .nav-label { display: inline; } }

.tile-link { cursor: pointer; } .tile-link:hover { border-color: var(--accent); }
.em-count { display: inline-block; background: var(--bad); color: #fff; border-radius: 9px; font-size: 11px; padding: 0 6px; margin-left: 2px; }
.note.em-note { background: #fff7ed; border-color: #fed7aa; color: #7c2d12; }

.ohead .ototal { margin-left: auto; text-align: right; display: flex; flex-direction: column; padding-right: 8px; border-right: 1px solid var(--line); }
.ohead .ototal .label { font-size: 12px; color: var(--mut); }
.ohead .ototal b { font-size: 22px; line-height: 1.2; }
.ohead .ototal + .actions { margin-left: 0; align-self: center; }
@media (max-width: 760px) {
  .ohead .ototal { margin-left: 0; text-align: left; border-right: 0; padding: 0; width: 100%; }
}

table.calc-view td.why { min-width: 170px; font-size: 12px; }
table.calc-view td.why { min-width: 140px; }
table.calc-view td[data-col="article"] { min-width: 180px; }
