:root {
  --bg: #f5f6f8; --card: #fff; --ink: #1d2433; --muted: #6b7385; --line: #e2e5eb;
  --brand: #1f3a5f; --accent: #2f6fdb; --ok: #1d7a46; --warn: #a15c00; --bad: #b42318;
}
* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--ink); background: var(--bg); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
h2 { font-size: 16px; margin: 0 0 10px; }
h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 18px 0 6px; }
.mono { font-family: ui-monospace, Consolas, monospace; }
.muted { color: var(--muted); }
.r { text-align: right; }
.neg { color: var(--bad); }
.pre { white-space: pre-wrap; }

.env-banner { text-align: center; font-weight: 600; padding: 4px; font-size: 12px; letter-spacing: .05em; }
.env-banner.demo { background: #f59e0b; color: #1d1300; }
.env-banner.trial { background: #7c3aed; color: #fff; }
.env-banner.live { background: var(--ok); color: #fff; }

.topbar { display: flex; align-items: center; gap: 24px; background: var(--brand); color: #fff; padding: 0 20px; height: 52px; }
.brand { color: #fff; font-weight: 700; font-size: 16px; white-space: nowrap; display: flex; align-items: center; gap: 10px; }
.brand .logo { width: 34px; height: 34px; background: #fff; border-radius: 7px; padding: 3px; }
.brand span { font-weight: 400; opacity: .75; }
.topbar nav { display: flex; gap: 4px; flex: 1; align-items: center; flex-wrap: wrap; }
.topbar nav a { color: #dfe7f3; padding: 6px 10px; border-radius: 6px; }
.topbar nav a.active, .topbar nav a:hover { background: rgba(255,255,255,.14); color: #fff; text-decoration: none; }
.topbar .later { color: rgba(255,255,255,.4); font-size: 12px; margin-left: 8px; }
.who { display: flex; gap: 10px; align-items: center; font-size: 13px; white-space: nowrap; }
.who .role { background: rgba(255,255,255,.18); padding: 1px 6px; border-radius: 4px; font-size: 11px; text-transform: uppercase; }
.who form { margin: 0; }
.who .link { color: #dfe7f3; }

main { max-width: 1280px; margin: 0 auto; padding: 20px; }
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.page-head p { width: 100%; margin: 4px 0 0; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 16px 18px; margin-bottom: 16px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 860px) { .two { grid-template-columns: 1fr; } .topbar { height: auto; flex-wrap: wrap; padding: 10px 16px; } }

.btn { display: inline-block; border: 1px solid var(--line); background: #fff; color: var(--ink); padding: 7px 12px; border-radius: 7px; font: inherit; cursor: pointer; }
.btn:hover { border-color: #c5cad4; text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.link { background: none; border: 0; padding: 0; font: inherit; color: var(--accent); cursor: pointer; }
button.link.danger { color: var(--bad); }
form.inline { display: inline; }

.tbl { width: 100%; border-collapse: collapse; background: var(--card); }
.tbl th, .tbl td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.tbl th { font-size: 12px; color: var(--muted); font-weight: 600; background: #fafbfc; }
.tbl th.r, .tbl td.r { text-align: right; font-variant-numeric: tabular-nums; }
.tbl.small td, .tbl.small th { padding: 5px 8px; font-size: 13px; }
.tbl tfoot th { color: var(--ink); background: #f0f2f5; }
.tbl tr.overdue td { background: #fff6ed; }
main > .tbl { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }

.filters { display: flex; gap: 8px; margin-bottom: 12px; align-items: center; flex-wrap: wrap; }
.filters input { flex: 1; min-width: 220px; }
input, select, textarea { font: inherit; padding: 7px 9px; border: 1px solid #cfd4dc; border-radius: 7px; background: #fff; color: var(--ink); width: 100%; }
.filters select, .filters input, .inline-form select, .inline-form input { width: auto; }
.inline-form { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--line); }

.form .grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px 18px; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field > span { font-weight: 600; font-size: 13px; }
.field small { color: var(--muted); font-size: 12px; }
.field .err { color: var(--bad); font-style: normal; font-size: 12px; }
.field.has-error input, .field.has-error select, .field.has-error textarea { border-color: var(--bad); }
.req { color: var(--bad); }
.check { display: flex; gap: 6px; align-items: center; margin-top: 12px; }
.check input { width: auto; }
.actions { display: flex; gap: 14px; align-items: center; margin-top: 18px; }

.kv { display: grid; grid-template-columns: 200px 1fr; gap: 6px 14px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.note { background: #f0f5ff; border-left: 3px solid var(--accent); padding: 8px 12px; color: #33415c; border-radius: 4px; font-size: 13px; }

.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 12px; border: 1px solid; }
.flash.success { background: #ecfdf3; border-color: #abefc6; color: #085d3a; }
.flash.error { background: #fef3f2; border-color: #fecdca; color: #912018; }
.flash.warning { background: #fffaeb; border-color: #fedf89; color: #93370d; }

.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; color: var(--ink); display: flex; flex-direction: column; }
a.stat:hover { border-color: var(--accent); text-decoration: none; }
.stat b { font-size: 24px; font-variant-numeric: tabular-nums; }
.stat span { color: var(--muted); font-size: 12px; }
.stat.attn { border-color: #fedf89; background: #fffaeb; }

.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; background: #eef0f4; color: #3c4557; white-space: nowrap; }
.s-confirmed, .s-received-at-warehouse, .s-delivered, .s-dispatched { background: #dcfae6; color: #085d3a; }
.s-awaiting-confirmation, .s-changes-received, .s-on-hold { background: #fef0c7; color: #93370d; }
.s-requires-review, .s-overdue { background: #fee4e2; color: #912018; }
.s-cancelled { background: #f2f4f7; color: #98a2b3; text-decoration: line-through; }
.s-in-transit, .s-booked, .s-allocated { background: #dbe8fe; color: #1d4ed8; }
.s-arrived-at-port, .s-released-awaiting-delivery { background: #e9e3ff; color: #5b21b6; }

.audit { margin-top: 8px; }
.audit summary { cursor: pointer; color: var(--muted); padding: 6px 0; }
.audit .mono { font-size: 11px; word-break: break-all; max-width: 600px; }

.login-card { max-width: 380px; margin: 80px auto; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 28px; }
.login-card form { display: flex; flex-direction: column; gap: 14px; margin-top: 16px; }

/* Phase 2: imports */
tr.dim td { opacity: .55; }
tr.detail-row td { background: #fafbfc; border-top: 0; }
.issues { margin: 0; padding-left: 18px; font-size: 13px; }
.issues li { margin: 2px 0; }
.issues .lvl-error b { color: var(--bad); }
.issues .lvl-warning b { color: var(--warn); }
.issues .lvl-info b { color: var(--muted); }
.pill { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.pill.ok { background: #dcfae6; color: #085d3a; }
.pill.warning { background: #fef0c7; color: #93370d; }
.pill.error { background: #fee4e2; color: #912018; }
.pill.info { background: #eef0f4; color: #3c4557; }
.scroll { overflow-x: auto; }
.s-validated { background: #dcfae6; color: #085d3a; }
.s-needs-review { background: #fef0c7; color: #93370d; }
.s-superseded { background: #f2f4f7; color: #98a2b3; }
.filters label { display: flex; gap: 8px; align-items: center; }

/* Warehouse space */
.alert { display: block; background: #fef3f2; border: 1px solid #fda29b; color: #7a271a; border-radius: 10px; padding: 12px 16px; margin-bottom: 16px; }
a.alert:hover { text-decoration: none; border-color: #b42318; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #fff; }
.seg a { padding: 6px 12px; color: var(--ink); border-left: 1px solid var(--line); }
.seg a:first-child { border-left: 0; }
.seg a.on { background: var(--brand); color: #fff; }
.chart-wrap { width: 100%; }
svg.chart { width: 100%; height: auto; display: block; }
svg.chart .grid { stroke: #eceef2; stroke-width: 1; }
svg.chart .axis { fill: #6b7385; font-size: 11px; }
svg.chart .line { fill: none; stroke: #2f6fdb; stroke-width: 2; stroke-linejoin: round; }
svg.chart .dot { fill: #2f6fdb; stroke: #fff; stroke-width: 2; }
svg.chart .dot.below { fill: #b42318; }
svg.chart .threshold { stroke: #b42318; stroke-width: 1.5; stroke-dasharray: 6 4; }
svg.chart .threshold-label { fill: #b42318; font-size: 11px; font-weight: 600; }
svg.chart .hit { fill: transparent; }
svg.chart .hit:hover { fill: rgba(47, 111, 219, .06); }
tr.below-row td { background: #fff6f5; }
.small-note { margin-top: 8px; }

/* Stock In */
.tbl th.c, .tbl td.c { text-align: center; }
.tick { color: #079455; font-weight: 700; font-size: 16px; }
.cross { color: #d92d20; font-weight: 700; font-size: 16px; }
td.order-no { font-weight: 700; font-size: 15px; white-space: nowrap; }

/* Emails */
.topbar .count { background: #f59e0b; color: #1d1300; border-radius: 999px; padding: 0 7px; font-size: 11px; font-weight: 700; margin-left: 4px; }
.seg.tabs { margin: 8px 0 12px; }
pre { background: #f4f5f7; padding: 8px 12px; border-radius: 6px; }

ul.summary{margin:0 0 6px;padding-left:4px;list-style:none}ul.summary li{padding:3px 0}

.pill.done{background:#e6e9ef;color:#3b4252;border-color:#c9ced8}
.badge.s-delivered{background:#e6e9ef;color:#3b4252}

/* Notes written next to stock on the WLR */
.notes-box { border-left: 4px solid #f79009; background: #fffaeb; }
.notes-box h2 { color: #93370d; }
.note-text { font-weight: 600; color: #93370d; }
.badge.note-flag { background: #fef0c7; color: #93370d; }
tr.has-note td { background: #fffaeb; }
