/* ===================== ACD brand shell styles =====================
   Red #EC1C24 · white · charcoal sidebar #16171b
   Fonts: Inter (Latin) + Hind Siliguri (Bengali). UI text = Banglish.
==================================================================== */
:root {
  --red: #EC1C24;
  --red-dark: #c4151c;
  --charcoal: #16171b;
  --charcoal-2: #1d1f25;
  --charcoal-3: #262931;
  --line: #2c2f38;
  --ink: #1f2430;
  --muted: #6b7280;
  --bg: #f4f5f7;
  --card: #ffffff;
  --radius: 14px;
  --sidebar-w: 248px;
  --shadow: 0 1px 3px rgba(16,17,27,.08), 0 8px 24px rgba(16,17,27,.06);
  font-synthesis: none;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Inter", "Hind Siliguri", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}
a { text-decoration: none; color: inherit; }
code { background:#eceef1; padding:1px 6px; border-radius:6px; font-size:.85em; }

/* ============================ layout ============================ */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: var(--charcoal);
  color: #d7dae1;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  border-right: 1px solid #0e0f12;
}

.brand {
  display: flex; align-items: center; gap: 12px;
  padding: 18px 18px 16px;
  border-bottom: 1px solid var(--line);
}
.logo-tile {
  background: #fff;
  border-radius: 12px;
  padding: 7px;
  width: 46px; height: 46px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 8px rgba(0,0,0,.35);
  flex: 0 0 auto;
}
.logo-tile img { width: 100%; height: 100%; object-fit: contain; border-radius: 6px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-name { font-weight: 700; font-size: 18px; color: #fff; letter-spacing: .5px; }
.brand-sub { font-size: 11px; color: #8b909c; margin-top: 2px; }

.nav { flex: 1; overflow-y: auto; padding: 10px 10px 16px; }
.nav-group { margin-bottom: 14px; }
.nav-group-label {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .9px;
  color: #6c7280; padding: 8px 10px 6px; font-weight: 600;
}
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 11px; border-radius: 9px;
  color: #c2c6cf; font-size: 14px; font-weight: 500;
  transition: background .12s, color .12s;
}
.nav-item:hover { background: var(--charcoal-3); color: #fff; }
.nav-item.active { background: var(--red); color: #fff; box-shadow: 0 2px 10px rgba(236,28,36,.4); }
.nav-ico {
  width: 16px; height: 16px; flex: 0 0 16px; border-radius: 4px;
  background: currentColor; opacity: .55;
  -webkit-mask-size: contain; mask-size: contain;
  -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat;
}
.nav-item.active .nav-ico { opacity: 1; }

.sidebar-foot {
  padding: 12px 16px; font-size: 11px; color: #6c7280;
  border-top: 1px solid var(--line); display: flex; align-items: center; gap: 8px;
}
.dot { width: 8px; height: 8px; border-radius: 50%; background: #2ecc71; display: inline-block; box-shadow: 0 0 0 3px rgba(46,204,113,.18); }

/* ============================ main ============================ */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: 62px; background: #fff; border-bottom: 1px solid #e7e9ee;
  display: flex; align-items: center; gap: 14px; padding: 0 22px;
  position: sticky; top: 0; z-index: 20;
}
.topbar-title { font-size: 17px; font-weight: 600; margin: 0; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 16px; }
.sync-chip {
  display: inline-flex; align-items: center; gap: 7px;
  background: #f0f3f1; color: #1f7a44; font-size: 12px; font-weight: 600;
  padding: 6px 11px; border-radius: 20px;
}
.user { display: flex; align-items: center; gap: 8px; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; background: var(--red);
  color: #fff; font-weight: 700; font-size: 14px;
  display: flex; align-items: center; justify-content: center;
}
.user-name { font-weight: 600; font-size: 14px; }
.user-role { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.logout { font-size: 12px; color: var(--red); font-weight: 600; margin-left: 6px; }
.logout:hover { text-decoration: underline; }
.hamburger { display: none; font-size: 22px; cursor: pointer; color: var(--ink); }

.content { padding: 24px; max-width: 1280px; width: 100%; }

/* ============================ KPI cards ============================ */
.kpi-grid {
  display: grid; gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  margin-bottom: 22px;
}
.kpi-card {
  background: var(--card); border-radius: var(--radius); padding: 18px 18px 16px;
  box-shadow: var(--shadow); border: 1px solid #edeff3; position: relative; overflow: hidden;
}
.kpi-card::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--red);
}
.kpi-label { font-size: 12.5px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .4px; }
.kpi-value { font-size: 30px; font-weight: 700; margin: 6px 0 2px; color: var(--ink); }
.kpi-hint { font-size: 11.5px; color: #9aa1ad; }

.panel {
  background: var(--card); border-radius: var(--radius); padding: 20px 22px;
  box-shadow: var(--shadow); border: 1px solid #edeff3;
}
.panel h3 { margin: 0 0 6px; font-size: 16px; }
.muted { color: var(--muted); font-size: 14px; line-height: 1.6; margin: 0; }

/* ============================ stub page ============================ */
.stub { display: flex; align-items: flex-start; justify-content: center; padding-top: 24px; }
.stub-card {
  background: var(--card); border-radius: var(--radius); padding: 38px 40px;
  box-shadow: var(--shadow); border: 1px solid #edeff3; max-width: 560px; width: 100%; text-align: center;
}
.stub-badge {
  display: inline-block; background: rgba(236,28,36,.1); color: var(--red);
  font-size: 11px; font-weight: 700; letter-spacing: .6px; text-transform: uppercase;
  padding: 5px 12px; border-radius: 20px; margin-bottom: 16px;
}
.stub-card h2 { margin: 0 0 10px; font-size: 22px; }
.stub-blurb { color: var(--ink); font-size: 15px; margin: 0 0 14px; }
.stub-note { color: var(--muted); font-size: 13px; line-height: 1.6; margin: 0; }

/* ============================ flash ============================ */
.flash { padding: 11px 15px; border-radius: 10px; margin-bottom: 14px; font-size: 14px; font-weight: 500; }
.flash-error { background: #fdecec; color: #b3151c; border: 1px solid #f6c5c7; }
.flash-success { background: #eafaf0; color: #1f7a44; border: 1px solid #bce8cd; }

/* ============================================================
   ACD CANONICAL BUTTON SYSTEM  (source: ACD_button_system.html)
   Crystal-clear brand red (#EC1C24), 3D liquid-glass body,
   smooth (slow) flip to vivid green (#16C15A) on success.
   ONE source of truth: .btn (all templates swept to .btn; no old classes).
   ============================================================ */
:root{
  --acd-red:   236,28,36;     /* #EC1C24  exact brand red */
  --acd-green: 22,193,90;     /* #16C15A  vivid success green */
  --acd-btn-t: .85s cubic-bezier(.45,.05,.2,1);   /* smooth, slightly slow switch */
}

.btn{
  --c: var(--acd-red);
  position:relative; isolation:isolate;
  display:inline-flex; align-items:center; justify-content:center; gap:.5em;
  padding:.74em 1.5em;
  font:600 15px/1 'Inter', system-ui, sans-serif;
  color:#fff; text-shadow:0 1px 2px rgba(0,0,0,.38); white-space:nowrap;
  border:none;
  border-radius:16px; cursor:pointer; user-select:none;
  /* layered glass: top specular -> convex body shade -> bottom reflected light -> solid brand colour */
  background:
    linear-gradient(180deg, rgba(255,255,255,.60) 0%, rgba(255,255,255,.20) 11%, rgba(255,255,255,0) 40%),
    linear-gradient(0deg,   rgba(255,255,255,.22) 0%, rgba(255,255,255,0) 24%),
    linear-gradient(180deg, rgba(255,255,255,.14) 0%, rgba(0,0,0,0) 34%, rgba(0,0,0,.20) 100%),
    rgb(var(--c));
  box-shadow:
    0 10px 26px rgba(var(--c),.50),       /* coloured ambient glow */
    0 3px 8px  rgba(0,0,0,.22),           /* contact shadow (lift) */
    inset 0 1px 1px rgba(255,255,255,.95),/* bright top edge */
    inset 0 3px 7px rgba(255,255,255,.30),/* inner top sheen */
    inset 0 -3px 7px rgba(0,0,0,.30),     /* inner bottom shade (convex) */
    inset 0 0 0 1px rgba(255,255,255,.22);/* crisp glass rim */
  transition: background var(--acd-btn-t), box-shadow var(--acd-btn-t),
              color var(--acd-btn-t),
              transform .15s ease, filter .15s ease;
}
.btn:hover{ transform:translateY(-2px); filter:brightness(1.05) saturate(1.04); }
.btn:active{ transform:translateY(0) scale(.97); }
.btn:focus-visible{ outline:2px solid rgba(var(--c),.8); outline-offset:3px; }
.btn[disabled]{ opacity:.45; cursor:not-allowed; filter:saturate(.55); transform:none; }

/* SUCCESS state — smooth (slow) morph red -> green, same 3D treatment */
.btn.is-success{ --c: var(--acd-green); }

/* size + layout variants */
.btn-sm{ padding:.52em 1.05em; font-size:13px; border-radius:13px; }
.btn-lg{ padding:.92em 1.9em;  font-size:17px; border-radius:20px; }
.btn-header{ font-size:16px; padding:.82em 1.7em; }   /* dashboard header actions: bigger, bold */
.btn-block{ width:100%; }
.btn .ic{ font-size:1.05em; line-height:0; }
/* dashboard header actions read bigger/bolder app-wide (Zihad: "boro font,
   colourful, sundor visible"). Small/ghost-xs buttons keep their compact size. */
.panel-head .btn:not(.btn-sm):not(.sm):not(.xs),
.panel-head .btn-primary:not(.sm):not(.xs),
.panel-head .btn-ghost:not(.sm):not(.xs){ font-size:16px; padding:.82em 1.7em; }

/* ============================ login ============================ */
.login-body {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(1200px 600px at 50% -10%, #23252d, var(--charcoal));
  padding: 24px;
}
.login-card {
  background: #fff; border-radius: 18px; padding: 36px 34px;
  width: 100%; max-width: 380px; text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,.4);
}
.login-logo { width: 64px; height: 64px; margin: 0 auto 14px; }
.login-title { font-size: 28px; font-weight: 700; margin: 0; letter-spacing: 1px; }
.login-sub { color: var(--muted); font-size: 13px; margin: 4px 0 22px; }
.login-form { display: flex; flex-direction: column; gap: 14px; text-align: left; }
.login-form label { font-size: 13px; font-weight: 600; color: #3a3f4b; display: flex; flex-direction: column; gap: 6px; }
.login-form input {
  padding: 11px 13px; border: 1px solid #d6d9e0; border-radius: 10px; font-size: 15px;
  font-family: inherit; transition: border .12s, box-shadow .12s;
}
.login-form input:focus { outline: none; border-color: var(--red); box-shadow: 0 0 0 3px rgba(236,28,36,.15); }
.login-form .btn-primary { margin-top: 6px; }
.login-foot { color: #9aa1ad; font-size: 11.5px; margin: 18px 0 0; }

/* ============================ mobile ============================ */
.nav-toggle-cb, .nav-scrim { display: none; }
@media (max-width: 860px) {
  .hamburger { display: block; }
  .sidebar {
    position: fixed; z-index: 60; left: 0; top: 0; height: 100vh;
    transform: translateX(-100%); transition: transform .2s ease;
  }
  .nav-toggle-cb:checked ~ .layout .sidebar { transform: translateX(0); }
  .nav-toggle-cb:checked ~ .nav-scrim {
    display: block; position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 50;
  }
  .content { padding: 18px 16px; }
}

/* simple icon masks (inline SVG data-URIs) */
.ico-grid     { -webkit-mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path fill='%23000' d='M3 3h8v8H3zm10 0h8v8h-8zM3 13h8v8H3zm10 0h8v8h-8z'/></svg>"); mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path fill='%23000' d='M3 3h8v8H3zm10 0h8v8h-8zM3 13h8v8H3zm10 0h8v8h-8z'/></svg>"); }
.ico-inbox    { -webkit-mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path fill='%23000' d='M5 3h14l2 11v7H3v-7zm.6 9h3.4l1 3h4l1-3h3.4L18 5H6z'/></svg>"); mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path fill='%23000' d='M5 3h14l2 11v7H3v-7zm.6 9h3.4l1 3h4l1-3h3.4L18 5H6z'/></svg>"); }
.ico-globe    { -webkit-mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path fill='%23000' d='M12 2a10 10 0 100 20 10 10 0 000-20m0 2c1.7 0 3 2.6 3 6H9c0-3.4 1.3-6 3-6M5 10h2c0 1.4.1 2.8.4 4H5.7A8 8 0 015 10m4 6h6c-.6 2.4-1.7 4-3 4s-2.4-1.6-3-4m8.3 0c.3-1.2.4-2.6.4-4H17a18 18 0 01-.4 4z'/></svg>"); mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path fill='%23000' d='M12 2a10 10 0 100 20 10 10 0 000-20m0 2c1.7 0 3 2.6 3 6H9c0-3.4 1.3-6 3-6M5 10h2c0 1.4.1 2.8.4 4H5.7A8 8 0 015 10m4 6h6c-.6 2.4-1.7 4-3 4s-2.4-1.6-3-4m8.3 0c.3-1.2.4-2.6.4-4H17a18 18 0 01-.4 4z'/></svg>"); }
.ico-truck    { -webkit-mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path fill='%23000' d='M3 5h11v9H3zm12 3h4l2 3v3h-6zM6 18a2 2 0 11.001-4.001A2 2 0 016 18m11 0a2 2 0 11.001-4.001A2 2 0 0117 18'/></svg>"); mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path fill='%23000' d='M3 5h11v9H3zm12 3h4l2 3v3h-6zM6 18a2 2 0 11.001-4.001A2 2 0 016 18m11 0a2 2 0 11.001-4.001A2 2 0 0117 18'/></svg>"); }
.ico-box      { -webkit-mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path fill='%23000' d='M12 2l9 5v10l-9 5-9-5V7zm0 2.3L5 8l7 3.8L19 8zM5 10v6l6 3.3v-6.6zm14 0l-6 3.3v6.6L19 16z'/></svg>"); mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path fill='%23000' d='M12 2l9 5v10l-9 5-9-5V7zm0 2.3L5 8l7 3.8L19 8zM5 10v6l6 3.3v-6.6zm14 0l-6 3.3v6.6L19 16z'/></svg>"); }
.ico-map      { -webkit-mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path fill='%23000' d='M9 2L3 4v18l6-2 6 2 6-2V2l-6 2-6-2m0 2.2l6 2v13.6l-6-2z'/></svg>"); mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path fill='%23000' d='M9 2L3 4v18l6-2 6 2 6-2V2l-6 2-6-2m0 2.2l6 2v13.6l-6-2z'/></svg>"); }
.ico-tag      { -webkit-mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path fill='%23000' d='M2 12l10-10h8v8L10 20zm14-7a2 2 0 100 4 2 2 0 000-4'/></svg>"); mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path fill='%23000' d='M2 12l10-10h8v8L10 20zm14-7a2 2 0 100 4 2 2 0 000-4'/></svg>"); }
.ico-mirror   { -webkit-mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path fill='%23000' d='M11 2h2v20h-2zM4 5h5v14H4zm11 0h5v14h-5z'/></svg>"); mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path fill='%23000' d='M11 2h2v20h-2zM4 5h5v14H4zm11 0h5v14h-5z'/></svg>"); }
.ico-chart    { -webkit-mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path fill='%23000' d='M3 3h2v18H3zm4 8h3v10H7zm5-6h3v16h-3zm5 9h3v7h-3z'/></svg>"); mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path fill='%23000' d='M3 3h2v18H3zm4 8h3v10H7zm5-6h3v16h-3zm5 9h3v7h-3z'/></svg>"); }
.ico-send     { -webkit-mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path fill='%23000' d='M2 3l20 9-20 9 5-9zm0 0'/></svg>"); mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path fill='%23000' d='M2 3l20 9-20 9 5-9zm0 0'/></svg>"); }
.ico-database { -webkit-mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path fill='%23000' d='M12 2c5 0 8 1.6 8 3.5S17 9 12 9 4 7.4 4 5.5 7 2 12 2m8 6.5C20 10.4 17 12 12 12s-8-1.6-8-3.5V12c0 1.9 3 3.5 8 3.5s8-1.6 8-3.5zm0 6C20 16.4 17 18 12 18s-8-1.6-8-3.5V18c0 1.9 3 3.5 8 3.5s8-1.6 8-3.5z'/></svg>"); mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path fill='%23000' d='M12 2c5 0 8 1.6 8 3.5S17 9 12 9 4 7.4 4 5.5 7 2 12 2m8 6.5C20 10.4 17 12 12 12s-8-1.6-8-3.5V12c0 1.9 3 3.5 8 3.5s8-1.6 8-3.5zm0 6C20 16.4 17 18 12 18s-8-1.6-8-3.5V18c0 1.9 3 3.5 8 3.5s8-1.6 8-3.5z'/></svg>"); }
.ico-users    { -webkit-mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path fill='%23000' d='M9 11a4 4 0 100-8 4 4 0 000 8m6 0a3 3 0 100-6 3 3 0 000 6M2 20c0-3.3 3.1-5 7-5s7 1.7 7 5zm14.5 0c-.1-1.9-.9-3.4-2.2-4.5 3 .3 5.7 1.8 5.7 4.5z'/></svg>"); mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path fill='%23000' d='M9 11a4 4 0 100-8 4 4 0 000 8m6 0a3 3 0 100-6 3 3 0 000 6M2 20c0-3.3 3.1-5 7-5s7 1.7 7 5zm14.5 0c-.1-1.9-.9-3.4-2.2-4.5 3 .3 5.7 1.8 5.7 4.5z'/></svg>"); }

/* ===================== Phase 3 — Supply / CRM Stock ===================== */
.subtabs { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 18px;
  border-bottom: 2px solid #e7e9ee; }
.subtab { padding: 9px 16px; font-size: 14px; font-weight: 600; color: var(--muted);
  border-bottom: 2px solid transparent; margin-bottom: -2px; border-radius: 8px 8px 0 0; }
.subtab:hover { color: var(--ink); background: #f0f1f4; }
.subtab.active { color: var(--red); border-bottom-color: var(--red); }

.panel-head { display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.panel-head h3 { margin: 0; }

/* legacy size modifiers map onto the glass body (sm/xs = smaller pill) */
.btn.sm, .btn-primary.sm, .btn-ghost.sm { padding:.52em 1.05em; font-size:13px; border-radius:13px; }
.btn.xs, .btn-primary.xs, .btn-ghost.xs { padding:.4em .85em; font-size:12px; border-radius:11px; }
.link { color: var(--red); font-weight: 600; }
.link:hover { text-decoration: underline; }
.hide { display: none !important; }
.small { font-size: 12px; }

/* tables */
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th, table.data td { padding: 9px 11px; text-align: left;
  border-bottom: 1px solid #eef0f3; vertical-align: middle; }
table.data thead th { font-size: 11.5px; text-transform: uppercase; letter-spacing: .4px;
  color: var(--muted); background: #fafbfc; position: sticky; top: 0; }
table.data tbody tr:hover { background: #fafbfc; }
table.data .r { text-align: right; }
table.data.lines input { width: 100%; }
.num { text-align: right; }
.pos { color: #1f7a44; }
.neg { color: var(--red); }
td.pos, td.neg { font-weight: 600; }

/* pills */
.pill { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 11.5px;
  font-weight: 600; background: #eef0f3; color: #4b5563; text-transform: lowercase; }
.pill.active { background: #eafaf0; color: #1f7a44; }
.pill.inactive, .pill.discontinued, .pill.reversed { background: #f3f4f6; color: #9aa1ad; }
.pill.posted { background: #eafaf0; color: #1f7a44; }
.pill.draft { background: #fff7e6; color: #b67a00; }
.pill.ttype { background: rgba(236,28,36,.08); color: var(--red); text-transform: uppercase; }
.pill.mv-PURCHASE_IN { background: #eafaf0; color: #1f7a44; text-transform: none; }
.pill.mv-SUPPLIER_RETURN_OUT { background: #fdecec; color: var(--red); text-transform: none; }
.pill.mv-MANUAL_ADJUST { background: #fff7e6; color: #b67a00; text-transform: none; }

/* forms */
.grid-form { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  align-items: end; margin-bottom: 18px; padding: 16px; background: #fafbfc;
  border: 1px solid #eef0f3; border-radius: 12px; }
.grid-form.one { grid-template-columns: 1fr; }
.grid-form label, .inline-edit label { display: flex; flex-direction: column; gap: 6px;
  font-size: 13px; font-weight: 600; color: #3a3f4b; }
.grid-form input, .grid-form select, .inline-edit input, .inline-edit select,
.search input, .search select {
  padding: 9px 11px; border: 1px solid #d6d9e0; border-radius: 9px; font-size: 14px;
  font-family: inherit; }
.grid-form input:focus, .grid-form select:focus { outline: none; border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(236,28,36,.12); }
.inline-edit { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.inline-edit.sm input { width: 90px; }
.search { display: flex; gap: 8px; align-items: center; }
.lines-foot { display: flex; align-items: center; justify-content: space-between;
  margin: 6px 0 14px; }
.memo-total { font-size: 15px; }
.memo-total strong, .kpi-inline .big { font-size: 18px; color: var(--ink); }

/* kpi inline strip */
.kpi-inline { display: flex; gap: 26px; flex-wrap: wrap; padding: 14px 16px;
  background: #fafbfc; border: 1px solid #eef0f3; border-radius: 12px; margin-bottom: 16px; }
.kpi-inline > div { display: flex; flex-direction: column; gap: 3px; }
.kpi-inline .muted { font-size: 11.5px; text-transform: uppercase; letter-spacing: .4px; }
.big.pos { color: #1f7a44; }

/* memo two-column layout + sticky preview */
.memo-layout { display: grid; grid-template-columns: 1.6fr 1fr; gap: 18px; align-items: start; }
.sticky-preview { position: sticky; top: 78px; }
.img-preview { border: 1px dashed #d6d9e0; border-radius: 10px; min-height: 240px;
  display: flex; align-items: center; justify-content: center; padding: 10px; text-align: center; }
.img-preview img { max-width: 100%; max-height: 70vh; border-radius: 8px; }
@media (max-width: 900px) { .memo-layout { grid-template-columns: 1fr; }
  .sticky-preview { position: static; } }

/* invoice print */
.invoice-head { display: flex; align-items: baseline; justify-content: space-between;
  border-bottom: 2px solid var(--ink); padding-bottom: 10px; margin-bottom: 14px; }
.invoice-head h2 { margin: 0; }
.inv-no { font-weight: 700; color: var(--red); }
@media print {
  .sidebar, .topbar, .subtabs, .no-print { display: none !important; }
  .content { padding: 0; } .panel { box-shadow: none; border: none; }
}

/* ===================== Phase 4b — Order Block Builder ===================== */
.builder { display: grid; grid-template-columns: 1.4fr 1fr; gap: 18px; align-items: start; }
.builder-col { display: flex; flex-direction: column; gap: 16px; }
.builder .panel { margin: 0; }
.msg { width: 100%; font-family: inherit; font-size: 14px; padding: 11px 12px;
  border: 1px solid #d6d9e0; border-radius: 10px; resize: vertical; margin-bottom: 10px; }
.msg:focus { outline: none; border-color: var(--red); box-shadow: 0 0 0 3px rgba(236,28,36,.12); }
.grid-form .span2 { grid-column: 1 / -1; }
#parseNote { margin-left: 10px; }

.sku-row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; flex-wrap: wrap; }
.sku-row .sku-pick { flex: 1 1 200px; padding: 9px 11px; border: 1px solid #d6d9e0;
  border-radius: 9px; font-size: 14px; }
.sku-row .sku-pick:focus { outline: none; border-color: var(--red); box-shadow: 0 0 0 3px rgba(236,28,36,.12); }
.sku-row .sku-pick.bad { border-color: var(--red); background: #fff6f6; }
.sku-row .sku-qty { width: 70px; padding: 9px; border: 1px solid #d6d9e0; border-radius: 9px; }
.sku-sale { font-weight: 600; font-size: 13px; min-width: 78px; }
.sku-stock { font-size: 12px; color: var(--muted); min-width: 72px; }
.sku-stock .warn, .warn { color: var(--red); font-weight: 600; }

.block-preview { background: #16171b; color: #e8eaee; padding: 16px 18px; border-radius: 10px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 13.5px; line-height: 1.7;
  white-space: pre-wrap; word-break: break-word; margin: 0 0 8px; min-height: 150px; }
.copied { color: #1f7a44; font-weight: 700; font-size: 13px; opacity: 0; transition: opacity .2s; margin-left: 8px; }
.copied.show { opacity: 1; }
@media (max-width: 980px) { .builder { grid-template-columns: 1fr; }
  .builder .sticky-preview { position: static; } }

/* ===================== Phase 4b fixes — memo verify + zoom ===================== */
.img-preview img.zoomable, .img-preview .zoomable { cursor: zoom-in; }
.zoom-overlay { position: fixed; inset: 0; background: rgba(10,11,14,.88); z-index: 200;
  display: none; align-items: center; justify-content: center; overflow: hidden; }
.zoom-overlay.show { display: flex; }
.zoom-overlay img { max-width: 92vw; max-height: 92vh; cursor: grab; transform-origin: center;
  user-select: none; border-radius: 6px; box-shadow: 0 10px 40px rgba(0,0,0,.5); }
.zoom-overlay img:active { cursor: grabbing; }

/* B2/B3 memo verification box */
.verify-box { background: #fafbfc; border: 1px solid #eef0f3; border-radius: 12px;
  padding: 14px 16px; margin: 6px 0 14px; max-width: 420px; }
.verify-box .vrow { display: flex; justify-content: space-between; align-items: baseline;
  padding: 5px 0; font-size: 14px; }
.verify-box .vrow span small { color: var(--muted); font-weight: 400; }
.verify-box .vrow strong { font-size: 15px; }
.verify-box .vrow.total { border-top: 1px solid #e7e9ee; margin-top: 4px; padding-top: 9px; }
.verify-box .vrow.total strong { font-size: 18px; color: var(--red); }
.verify-box .vinput { display: flex; flex-direction: column; gap: 6px; margin-top: 10px;
  font-size: 13px; font-weight: 600; color: #3a3f4b; }
.verify-box .vinput input { padding: 9px 11px; border: 1px solid #d6d9e0; border-radius: 9px; font-size: 14px; }
.match-hint { margin-top: 8px; font-size: 13px; font-weight: 600; min-height: 18px; }
.match-hint.ok { color: #1f7a44; }
.match-hint.bad { color: var(--red); }

/* ===================== Phase 4c — return invoice + in-box zoom ===================== */
/* in-box memo zoom (stays contained; no full-page overlay) */
.img-preview.zoomable-box { overflow: hidden; position: relative; }
.zoom-inbox { transform-origin: center center; cursor: zoom-in; max-width: 100%;
  max-height: 60vh; will-change: transform; user-select: none; }

/* return invoice */
.invoice-sheet { display: flex; flex-direction: column; gap: 22px; }
.invoice-copy { background: #fff; border: 1px solid #e7e9ee; border-radius: 12px;
  padding: 26px 28px; box-shadow: var(--shadow); }
.inv-brand { display: flex; align-items: center; gap: 14px; border-bottom: 2px solid var(--ink);
  padding-bottom: 14px; margin-bottom: 14px; }
.inv-logo { width: 54px; height: 54px; box-shadow: 0 1px 4px rgba(0,0,0,.18); }
.inv-brand-name { font-size: 22px; font-weight: 700; letter-spacing: .3px; }
.inv-copy-tag { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; }
.inv-title-row { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 14px; }
.inv-heading { margin: 0; font-size: 20px; color: var(--red); }
.invoice-copy .inv-no { font-weight: 700; }
.inv-total-row td { border-top: 2px solid #e7e9ee; font-size: 15px; }
.inv-signatures { display: flex; justify-content: space-between; gap: 40px; margin-top: 48px; }
.sig-box { flex: 1; text-align: center; }
.sig-line { border-top: 1px solid #555; margin-bottom: 6px; }
.sig-label { font-weight: 700; font-size: 14px; }
.sig-sub { font-size: 12px; color: var(--muted); }

@media print {
  .sidebar, .topbar, .subtabs, .no-print { display: none !important; }
  .content { padding: 0; max-width: none; }
  .invoice-copy { border: none; box-shadow: none; border-radius: 0; padding: 10px 4px; }
  .invoice-copy.print-break { page-break-before: always; }
}

/* ===================== Phase 5 — Orders / Pull / CAPI ===================== */
h4.sub { margin: 20px 0 8px; font-size: 13px; text-transform: uppercase;
  letter-spacing: .5px; color: var(--muted); }
hr.sep { border: none; border-top: 1px solid #e7e9ee; margin: 22px 0 16px; }
.pill.isd { background: #eafaf0; color: #1f7a44; text-transform: uppercase; }
.pill.osd { background: #fff7e6; color: #b67a00; text-transform: uppercase; }
.pill.flagbad { background: #fdecec; color: var(--red); }
.pill.src-builder { background: #eef2ff; color: #3b5bdb; }
.pill.src-messenger { background: #e7f5ff; color: #1971c2; }
.pill.src-website { background: #f3f0ff; color: #7048e8; }
.pill.src-builder-messenger { background: #e6fcf5; color: #0ca678; }
.pill.capi-sent { background: #eafaf0; color: #1f7a44; }
.pill.capi-pending { background: #f1f3f5; color: #868e96; }
.pill.capi-failed { background: #fdecec; color: var(--red); }
.pill.capi-skipped { background: #fff7e6; color: #b67a00; }

/* ===================== Phase 5b — Chat History / matrix / sandbox ===================== */
.insight { background: #fff7e6; border: 1px solid #ffe8b3; color: #8a5800;
  padding: 10px 14px; border-radius: 10px; font-weight: 600; font-size: 14px; margin: 4px 0 16px; }
.matrix-wrap { overflow-x: auto; }
table.matrix th { text-align: center; }
table.matrix td.cell-on { background: #eef2ff; color: #3b5bdb; font-weight: 600; }
table.matrix td.cell-max { background: var(--red); color: #fff; font-weight: 700; }
table.matrix tr.mtot td, table.matrix tr.mtot th { background: #fafbfc; }
.bars { display: flex; flex-direction: column; gap: 7px; max-width: 560px; }
.bar-row { display: flex; align-items: center; gap: 10px; }
.bar-lbl { width: 18px; font-weight: 700; }
.bar-track { flex: 1; height: 16px; background: #eef0f3; border-radius: 8px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--red); border-radius: 8px; }
.bar-val { width: 70px; font-size: 12.5px; color: var(--muted); text-align: right; }
.msg.code { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 13px; }
.save-inline { display: flex; gap: 8px; align-items: center; }
.save-inline input { padding: 7px 10px; border: 1px solid #d6d9e0; border-radius: 8px; font-size: 13px; }
.saved-scripts { margin: 12px 0; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.sandbox-result { margin-top: 14px; }
.sb-ok { color: #1f7a44; font-weight: 700; margin-bottom: 8px; }
.sb-bad { background: #fdecec; color: var(--red); border: 1px solid #f6c5c7;
  padding: 11px 14px; border-radius: 10px; font-weight: 600; }

/* ===================== Phase 5 — live pull progress ===================== */
.pull-progress { border-left: 4px solid var(--red); }
.pull-progress .resolved { color: #1f7a44; font-weight: 600; margin-bottom: 10px; }
.pbar { height: 12px; background: #eef0f3; border-radius: 8px; overflow: hidden; margin: 6px 0 14px; }
.pbar-fill { height: 100%; width: 12%; background: var(--red); border-radius: 8px;
  transition: width .5s ease; }
.pull-progress .kpi-inline { margin-bottom: 10px; }
#ppDone a.link { white-space: nowrap; }

/* ===================== Phase 5 fixes — chat raw view + CAPI raw ===================== */
.ready-btns { margin-top: 10px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.chat-scroll { max-height: 460px; overflow: auto; border: 1px solid #eef0f3; border-radius: 10px; }
.chat-scroll table.data thead th { position: sticky; top: 0; z-index: 1; }
.msg-cell { max-width: 460px; white-space: pre-wrap; word-break: break-word; }
td.raw { max-width: 380px; }
td.raw .warn { display: block; font-weight: 600; }

/* ===================== Phase 6b — Token station + Handover ===================== */
.ts-head { display:flex; justify-content:space-between; align-items:center; background:var(--charcoal);
  color:#fff; padding:12px 16px; border-radius:12px 12px 0 0; }
.ts-clock { font-variant-numeric:tabular-nums; font-size:13px; color:#c2c6cf; }
.ts-tabs { display:flex; gap:2px; background:#fafbfc; border:1px solid #e7e9ee; border-top:none; }
.ts-tab { padding:9px 16px; border:none; background:transparent; font-weight:600; font-size:14px;
  color:var(--muted); cursor:pointer; border-bottom:2px solid transparent; }
.ts-tab.active { color:var(--red); border-bottom-color:var(--red); background:#fff; }
.ts-pane { border:1px solid #e7e9ee; border-top:none; padding:16px; background:#fff; border-radius:0 0 12px 12px; }
.ts-counts { display:flex; gap:24px; margin-bottom:12px; font-size:14px; }
.ts-actions { display:flex; gap:8px; align-items:center; flex-wrap:wrap; margin-bottom:12px; }
.ts-size { display:grid; grid-template-columns:1.3fr 1fr; gap:18px; }
.ts-controls { display:grid; grid-template-columns:1fr 1fr; gap:10px; }
.ts-controls label { display:flex; flex-direction:column; gap:4px; font-size:12px; font-weight:600; color:#3a3f4b; }
.ts-controls input { padding:7px 9px; border:1px solid #d6d9e0; border-radius:8px; }
.ts-controls > button { grid-column:1/-1; }
.ts-preview-wrap { border:1px dashed #d6d9e0; border-radius:10px; padding:12px; }
/* the printable label */
.label { border:2px solid #000; background:#fff; box-sizing:border-box; margin:0 auto; overflow:hidden; }
table.lbl { width:100%; height:100%; border-collapse:collapse; table-layout:fixed; }
table.lbl td { border:1px solid #000; padding:2px 4px; vertical-align:middle; color:#000; }
table.lbl td.lh { text-align:center; font-weight:800; letter-spacing:.5px; }
table.lbl td.lk { font-weight:700; background:#f2f2f2; text-align:left; }
table.lbl td.lv { text-align:left; word-break:break-word; overflow-wrap:anywhere; }
table.lbl td.lnum { letter-spacing:.5px; white-space:normal; }
table.lbl td.lbar { text-align:center; padding:2px; }
table.lbl td.lbar svg rect { fill:#000; }
.print-area { display:none; }

/* handover */
.ho-grid { display:grid; grid-template-columns:1fr 1fr; gap:16px; margin-bottom:14px; }
.ho-lbl { display:flex; flex-direction:column; gap:6px; font-weight:600; font-size:13px; }
.ho-lbl input, .ho-lbl textarea { padding:10px 12px; border:1px solid #d6d9e0; border-radius:9px; font-size:15px; font-family:inherit; }
#scanBox { font-size:18px; letter-spacing:.5px; }
.ho-counts { margin-top:10px; font-size:14px; }
.memo-sheet { border:1px solid #e7e9ee; border-radius:10px; padding:14px; }
.memo-title { font-weight:700; margin-bottom:8px; }
.memo-foot { margin-top:10px; font-weight:700; }
tr.row-cancel td { background:#fdecec; color:#b3151c; }
.warn { color:#b67a00; }

@media print {
  .sidebar, .topbar, .subtabs, .no-print, .ts-tabs, .ts-head { display:none !important; }
  .content { padding:0; max-width:none; }
  .print-area { display:block; }
  .print-area .label { page-break-after:always; }
  .panel { box-shadow:none; border:none; }
}

/* ===================== Phase 7 — Moderator / Employees / Central ===================== */
tr.row-changed td { background:#fff7e6; }
.user-perm { border:1px solid #eef0f3; border-radius:10px; padding:12px 14px; margin-bottom:10px; background:#fafbfc; }
.up-head { display:flex; gap:10px; align-items:center; flex-wrap:wrap; margin-bottom:8px; }
.up-role { padding:5px 8px; border:1px solid #d6d9e0; border-radius:7px; }
.up-perms { display:flex; gap:8px 16px; flex-wrap:wrap; }
.up-chk { font-size:12.5px; display:flex; gap:5px; align-items:center; font-weight:500; color:#3a3f4b; }
