/* ── Themes ──────────────────────────────────────────────────────────────
   Dark is the default (no data-theme). Light, Sepia and Midnight are opt-in
   via <html data-theme="…">, chosen in the topbar picker and stored per-browser.
   Every surface reads these ~14 tokens, so a theme is just a palette swap. */
:root, :root[data-theme="dark"] {           /* Dark — slate navy (default) */
  color-scheme: dark;
  --bg: #0f172a; --panel: #1e293b; --panel2: #172033; --border: #334155;
  --text: #e2e8f0; --heading: #ffffff; --muted: #94a3b8;
  --brand: #e11d2a; --brand2: #f59e0b; --ok: #34d399; --bad: #f87171;
  --link: #93c5fd; --code-bg: #0b1220; --code-text: #cbd5e1;
  --hl-bg: #4a3a12; --hl-fg: #ffe9a8;   /* marker highlight (dark) */
  /* chip/badge/tile system — every status pill, action tile and sunken input
     reads these instead of literal hex, so switching themes recolors them too */
  --surface-2: #0f1728; --chip-bg: #334155; --chip-fg: #cbd5e1; --chip-hover: #26344933;
  --tag-green-bg: #14532d; --tag-green-fg: #86efac; --tag-green-soft: #14532d33;
  --tag-red-bg: #45150f; --tag-red-fg: #fca5a5; --tag-red-soft: #45150f4d;
  --tag-amber-bg: #3f3f14; --tag-amber-fg: #fde68a; --tag-amber-soft: #7c2d1233; --tag-amber-border: #92660a;
  --tag-blue-bg: #1e3a5f; --tag-blue-fg: #bfdbfe; --tag-blue-soft: #1e3a8a33;
  --tag-purple-bg: #3b2a4a; --tag-purple-fg: #e9d5ff;
  --notice-bg: #172554; --notice-border: #1e3a8a; --notice-fg: #bfdbfe;
  --row-stale-bg: #2a1410; --imp-bg: #7c2d12; --imp-fg: #fed7aa;
}
:root[data-theme="light"] {                  /* Light — clean cool slate */
  color-scheme: light;
  --bg: #eef2f7; --panel: #ffffff; --panel2: #f6f9fc; --border: #d5dde8;
  --text: #26313f; --heading: #0f172a; --muted: #607089;
  --brand: #e11d2a; --brand2: #d97706; --ok: #059669; --bad: #dc2626;
  --link: #2563eb; --code-bg: #0f172a; --code-text: #e2e8f0;
  --hl-bg: #fff3a8; --hl-fg: #3a2f00;   /* marker highlight (light) */
  --surface-2: #e4e9f0; --chip-bg: #e2e8f0; --chip-fg: #475569; --chip-hover: #33415522;
  --tag-green-bg: #d1fae5; --tag-green-fg: #065f46; --tag-green-soft: #05966926;
  --tag-red-bg: #fee2e2; --tag-red-fg: #991b1b; --tag-red-soft: #dc262626;
  --tag-amber-bg: #fef3c7; --tag-amber-fg: #92400e; --tag-amber-soft: #d9770626; --tag-amber-border: #d97706;
  --tag-blue-bg: #dbeafe; --tag-blue-fg: #1e40af; --tag-blue-soft: #2563eb26;
  --tag-purple-bg: #ede9fe; --tag-purple-fg: #6b21a8;
  --notice-bg: #eff6ff; --notice-border: #bfdbfe; --notice-fg: #1e3a8a;
  --row-stale-bg: #fee2e2; --imp-bg: #fed7aa; --imp-fg: #7c2d12;
}
:root[data-theme="sepia"] {                  /* Sepia — warm parchment (Silk Road) */
  color-scheme: light;
  --bg: #ece0c8; --panel: #f8f1df; --panel2: #f2e8d1; --border: #d8c6a0;
  --text: #45392a; --heading: #2c2314; --muted: #877556;
  --brand: #b3241f; --brand2: #b3660a; --ok: #5b7a2e; --bad: #a33a25;
  --link: #1f6f78; --code-bg: #2c2314; --code-text: #efe6d2;
  --hl-bg: #f3d98a; --hl-fg: #3d2f10;   /* marker highlight (sepia) */
  --surface-2: #e3d5b0; --chip-bg: #e3d5b0; --chip-fg: #5c4a2f; --chip-hover: #45392a1a;
  --tag-green-bg: #dde7c0; --tag-green-fg: #3f5720; --tag-green-soft: #5b7a2e26;
  --tag-red-bg: #f0d2c9; --tag-red-fg: #7a2a1a; --tag-red-soft: #a33a2526;
  --tag-amber-bg: #f3dfab; --tag-amber-fg: #7a4a06; --tag-amber-soft: #b3660a26; --tag-amber-border: #b3660a;
  --tag-blue-bg: #d9e2e8; --tag-blue-fg: #2c4a5c; --tag-blue-soft: #1f6f7826;
  --tag-purple-bg: #e6d9ec; --tag-purple-fg: #5a3a70;
  --notice-bg: #f0e6cc; --notice-border: #d8c6a0; --notice-fg: #45392a;
  --row-stale-bg: #f0d2c9; --imp-bg: #b3660a; --imp-fg: #fdf0dc;
}
:root[data-theme="midnight"] {               /* Midnight — true-black OLED */
  color-scheme: dark;
  --bg: #000000; --panel: #0e0e14; --panel2: #07070b; --border: #26262f;
  --text: #e9e9f0; --heading: #ffffff; --muted: #8b8b98;
  --brand: #ff2f42; --brand2: #ffb020; --ok: #3ddc84; --bad: #ff6b6b;
  --link: #7cc4ff; --code-bg: #0e0e14; --code-text: #d6d6e0;
  --hl-bg: #3d3212; --hl-fg: #ffe9a8;   /* marker highlight (midnight) */
  --surface-2: #060609; --chip-bg: #1a1a22; --chip-fg: #d4d4dc; --chip-hover: #ffffff14;
  --tag-green-bg: #052e1a; --tag-green-fg: #4ade80; --tag-green-soft: #3ddc8433;
  --tag-red-bg: #33080a; --tag-red-fg: #ff8080; --tag-red-soft: #ff6b6b33;
  --tag-amber-bg: #332600; --tag-amber-fg: #ffcc4d; --tag-amber-soft: #ffb02033; --tag-amber-border: #ffb020;
  --tag-blue-bg: #0a1a33; --tag-blue-fg: #7dbbff; --tag-blue-soft: #7cc4ff33;
  --tag-purple-bg: #22102e; --tag-purple-fg: #d9a8ff;
  --notice-bg: #0a1a33; --notice-border: #163559; --notice-fg: #9dc4ff;
  --row-stale-bg: #33080a; --imp-bg: #7c2d12; --imp-fg: #ffd6ad;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--text); line-height: 1.6;
}
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
code { background: var(--code-bg); color: var(--code-text); padding: 2px 6px; border-radius: 5px; font-size: .9em; }

.devbar { background: var(--brand2); color: #1a1200; text-align: center; padding: 6px 10px; font-weight: 700; font-size: .82rem; }

/* ===== app shell: left sidebar + slim top bar + content (matches old app IA) ===== */
.shell { display: flex; align-items: flex-start; min-height: 100vh; }
.sidebar { flex: 0 0 218px; width: 218px; background: var(--panel2); border-right: 1px solid var(--border);
  position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; z-index: 40; }
.side-brand { display: flex; flex-direction: column; line-height: 1.1; padding: 18px 18px 14px; border-bottom: 1px solid var(--border); }
.brand-cn { font-size: 1.55rem; font-weight: 800; letter-spacing: .16em; color: #fff; background: linear-gradient(90deg, var(--brand), var(--brand2)); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.brand-sub { font-size: .68rem; color: var(--muted); letter-spacing: .04em; margin-top: 3px; }
.sidenav { display: flex; flex-direction: column; padding: 8px; gap: 2px; flex: 1; }
.sidelink { display: flex; align-items: center; gap: 11px; padding: 9px 11px; border-radius: 9px; color: var(--text); font-weight: 600; }
.sidelink:hover { background: var(--chip-hover); text-decoration: none; }
.sidelink .ico { flex: 0 0 22px; text-align: center; font-size: 1.1rem; color: var(--muted); }
/* A nav icon supplied as a picture: painted as a mask in the current text colour,
   so it dims, brightens and changes with the theme exactly as the glyphs do. */
.ico-img { display: inline-block; width: 1.05em; height: 1.05em; vertical-align: -.15em;
  background-color: currentColor;
  -webkit-mask: var(--ico) center / contain no-repeat; mask: var(--ico) center / contain no-repeat; }
.sidelink .lbl { display: flex; flex-direction: column; line-height: 1.12; }
.sidelink .lbl .cn { font-size: .62rem; color: var(--muted); margin: 1px 0 0; font-weight: 500; }
.sidelink.is-active { background: var(--brand); color: #fff; }
.sidelink.is-active .ico, .sidelink.is-active .lbl .cn { color: rgba(255,255,255,.85); }
.side-out { margin-top: auto; border-top: 1px solid var(--border); border-radius: 0; }
.side-out:hover { background: var(--tag-red-bg); color: var(--tag-red-fg); }
.shell-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; min-height: 100vh; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 10px 18px; background: var(--panel2);
  border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 30; min-height: 46px; }
.menu-btn { display: none; flex: 0 0 auto; background: var(--panel); color: var(--text); border: 1px solid var(--border);
  border-radius: 8px; width: 38px; height: 34px; font-size: 1.2rem; line-height: 1; cursor: pointer; }
.topbrand { display: none; flex: 0 0 auto; white-space: nowrap; font-weight: 800; letter-spacing: .14em; color: var(--heading);
  background: linear-gradient(90deg, var(--brand), var(--brand2)); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; font-size: 1.2rem; }
.nav-backdrop { position: fixed; inset: 0; background: rgba(2,6,15,.6); z-index: 39; }
/* right-hand cluster of topbar controls (view-as, old-system link, theme picker) —
   pushed right as a group so they wrap onto their own row together on mobile
   instead of each fighting for space (or overflowing) individually */
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
/* theme picker (top bar, right-aligned) */
/* super-admin "view as user" picker */
.viewas { display: inline-flex; align-items: center; gap: 6px; }
.viewas-ic { font-size: 1rem; line-height: 1; opacity: .85; }
.viewas select { background: var(--panel); color: var(--text); border: 1px solid var(--border); border-radius: 8px;
  padding: 5px 9px; font: inherit; font-size: .82rem; font-weight: 600; cursor: pointer; max-width: 210px; }
.viewas select:hover { border-color: var(--brand2); }
/* "viewing as" banner (read-only impersonation) */
.impbar { display: flex; align-items: center; justify-content: center; gap: 12px; flex-wrap: wrap;
  background: var(--imp-bg); color: var(--imp-fg); padding: 6px 14px; font-size: .84rem; font-weight: 600; }
.impbar b { color: inherit; } .impbar-role { opacity: .8; font-weight: 400; }
.impbar form { margin: 0; display: inline; }
.impbar-exit { background: var(--imp-fg); color: var(--imp-bg); border: 0; border-radius: 7px; padding: 4px 12px; font-weight: 700; font-size: .8rem; cursor: pointer; }
/* roles & permissions checkbox grid */
.permgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 8px 14px; margin-top: 6px; }
.permchk { display: flex; align-items: center; gap: 8px; font-size: .9rem; font-weight: 600; cursor: pointer; padding: 6px 8px; border: 1px solid var(--border); border-radius: 8px; background: var(--panel); }
.permchk input { width: 16px; height: 16px; accent-color: var(--brand); }
.lvlgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 8px 14px; margin-top: 6px; }
.lvlrow { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 6px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--panel); font-size: .9rem; font-weight: 600; }
.lvlsel { background: var(--panel2); color: var(--text); border: 1px solid var(--border); border-radius: 7px; padding: 4px 8px; font: inherit; font-size: .82rem; font-weight: 600; cursor: pointer; }
.lvlrow.permchk { justify-content: flex-start; gap: 8px; }
.theme-pick { display: inline-flex; align-items: center; gap: 6px; }
.theme-ic { font-size: 1rem; line-height: 1; opacity: .85; }
.theme-pick select { background: var(--panel); color: var(--text); border: 1px solid var(--border);
  border-radius: 8px; padding: 5px 26px 5px 9px; font: inherit; font-size: .82rem; font-weight: 600; cursor: pointer;
  -webkit-appearance: none; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%23888' stroke-width='1.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 9px center; }
.theme-pick select:hover { border-color: var(--brand2); }
.theme-pick select:focus-visible { outline: 2px solid var(--brand2); outline-offset: 1px; }

/* Chinese accent text — small, muted, "a touch of Chinese" on an English UI */
.cn { font-size: .82em; color: var(--muted); font-weight: 500; margin-left: 6px; }
h2 .cn { font-size: .8rem; }
.devbar .cn { color: inherit; opacity: .72; margin-left: 4px; }

.wrap { max-width: 1180px; margin: 0 auto; width: 100%; padding: 26px 26px 60px; }
h1 { font-size: 1.7rem; margin: 8px 0 4px; }
.h1-sub { font-size: .95rem; color: var(--muted); font-weight: 500; margin-left: 8px; }
h2 { font-size: 1.18rem; margin: 34px 0 12px; padding-bottom: 6px; border-bottom: 1px solid var(--border); }
.lead { color: var(--muted); margin: 6px 0 20px; }
.muted { color: var(--muted); }
.crumb { color: var(--muted); font-size: .85rem; margin: 0 0 6px; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin: 8px 0 6px; }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; }
.card .k { color: var(--muted); font-size: .74rem; letter-spacing: .04em; }
.card .v { font-size: 1.35rem; font-weight: 800; margin-top: 5px; }
.ok { color: var(--ok); } .bad { color: var(--bad); }

.note { margin: 16px 0; padding: 14px 16px; background: var(--notice-bg); border: 1px solid var(--notice-border); border-radius: 12px; color: var(--notice-fg); }
.bad-note { background: var(--tag-red-bg); border-color: var(--bad); color: var(--tag-red-fg); }
.note-ok { background: var(--tag-green-bg); border-color: var(--tag-green-bg); color: var(--tag-green-fg); }

ul.good { margin: 8px 0; padding-left: 20px; }
ul.good li { margin: 6px 0; }

.finding { background: var(--panel); border: 1px solid var(--border); border-left: 4px solid var(--brand2); border-radius: 10px; padding: 14px 16px; margin: 14px 0; }
.finding p { margin: 6px 0; }
.finding-head { font-weight: 700; font-size: 1.02rem; margin-bottom: 4px; }
.sev { display: inline-block; min-width: 26px; text-align: center; font-size: .72rem; font-weight: 800; padding: 2px 7px; border-radius: 6px; margin-right: 8px; color: #1a1200; }
.sev-high { background: var(--bad); color: #2a0a0a; }
.sev-med { background: var(--brand2); }
.sev-low { background: var(--chip-bg); color: var(--chip-fg); }

ol.discuss, .next { color: var(--muted); }
ol.discuss li { margin: 8px 0; }

.doclist { display: flex; flex-direction: column; gap: 12px; margin-top: 14px; }
.docitem { display: block; background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 16px 18px; color: var(--text); }
.docitem:hover { border-color: var(--brand2); text-decoration: none; }
.docitem-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.docitem-title { font-size: 1.1rem; font-weight: 700; }
.docitem-en { color: var(--muted); font-size: .85rem; }
.docitem-date { margin-left: auto; color: var(--muted); font-size: .8rem; }
.docitem-desc { color: var(--muted); margin-top: 6px; font-size: .92rem; }

.tablewrap { overflow-x: auto; }
.mtable { width: 100%; border-collapse: collapse; margin: 8px 0; font-size: .93rem; }
.mtable th, .mtable td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--border); }
.mtable th { color: var(--muted); font-weight: 600; font-size: .82rem; letter-spacing: .03em; }
.mtable tbody tr:hover { background: var(--panel2); }
.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .78rem; font-weight: 600; background: var(--chip-bg); color: var(--chip-fg); }
.pill-next { background: var(--brand2); color: #1a1200; }

/* parties list */
.filterbar { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0 18px; align-items: center; }
.filterbar input[type=search], .filterbar select { background: var(--panel); color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; font-size: .9rem; }
.filterbar input[type=search] { min-width: 0; flex: 1 1 220px; }
/* A label that wraps its own control ("From <input>"), as opposed to the bare
   labels sitting beside a sibling select. inline-flex keeps the caption and the
   field on one centre line instead of letting the input hang off the text
   baseline. */
.filterbar label.fld { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: .9rem; white-space: nowrap; }
/* Date fields in a filter bar, opt-in per bar via .fb-dates. Opt-in rather than
   plain `.filterbar input[type=date]` because several bars elsewhere pair a date
   with a bare text input that this stylesheet has never styled — theming the date
   globally would leave those bars half-styled, which is worse than leaving them
   alone. Add fb-dates to a bar once its other fields are themed too.
   The padding is 7px, not the 8px its neighbours use: a date input's inner
   editable fields make its content box ~2px taller, so equal padding would leave
   it standing proud of the search box beside it. The native picker needs no
   re-colouring — every theme declares color-scheme, so the browser draws its
   indicator light or dark to match. */
.filterbar.fb-dates input[type=date] { background: var(--panel); color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 7px 10px; font-size: .9rem; line-height: normal; }
.filterbar select, .ss { max-width: 100%; }
.filterbar button { background: var(--brand); color: #fff; border: 0; border-radius: 8px; padding: 8px 18px; font-weight: 600; cursor: pointer; }
.filterbar .clearlink { color: var(--muted); font-size: .85rem; }
.filterbar .exportlink { color: var(--ok); font-size: .85rem; font-weight: 600; margin-left: auto; }
.pname { font-weight: 600; }
.cn2 { display: block; color: var(--muted); font-size: .82rem; margin-top: 2px; }
.wx { color: #1aad19; font-weight: 600; }
.modchip { display: inline-block; background: var(--chip-bg); color: var(--chip-fg); border-radius: 6px; padding: 1px 7px; font-size: .72rem; margin: 1px 3px 1px 0; }
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .74rem; font-weight: 700; }
.badge.on { background: var(--tag-green-bg); color: var(--tag-green-fg); }
.badge.off { background: var(--tag-red-bg); color: var(--tag-red-fg); }
h1 .badge { vertical-align: middle; margin-left: 8px; font-size: .6rem; }
.pager { display: flex; gap: 16px; align-items: center; justify-content: center; margin: 20px 0; color: var(--muted); }
.pager a { padding: 6px 14px; background: var(--panel); border: 1px solid var(--border); border-radius: 8px; }
/* party detail */
.fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 8px 22px; margin-top: 10px; }
.frow { display: flex; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--border); }
.frow .fk { color: var(--muted); min-width: 120px; font-size: .85rem; }
.frow .fv { font-weight: 500; }

/* ledger */
.btnlink { display: inline-block; background: var(--brand); color: #fff; padding: 7px 16px; border-radius: 8px; font-weight: 600; }
.btnlink:hover { text-decoration: none; opacity: .92; }
.btnlink.btnlink-alt { background: var(--chip-bg); color: var(--chip-fg); }
.mtable.ledger td.num, .mtable.ledger th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.mtable td.ledger-note { font-size: .82rem; white-space: normal; word-break: break-word; }
/* Ledger column budget: Details carries the note plus the shipment/container
   line, so it takes the slack. Date and Type/Ref are allowed to wrap onto a
   second line instead of holding the table open; the date and the reference
   themselves are kept unbreakable by .nowrap spans inside those cells. */
.mtable.ledger th:nth-child(1), .mtable.ledger td:nth-child(1) { width: 6rem; }
.mtable.ledger th:nth-child(2), .mtable.ledger td:nth-child(2) { width: 8rem; }
.mtable.ledger th:nth-child(3), .mtable.ledger td:nth-child(3) { width: 45%; }
.mtable .nowrap { white-space: nowrap; }
.mtable td.num.bad, .closing .bad, .card .v.bad { color: var(--tag-red-fg); }
.ltype { display: inline-block; padding: 1px 8px; border-radius: 6px; font-size: .72rem; font-weight: 700; }
.lt-voucher { background: var(--tag-blue-bg); color: var(--tag-blue-fg); }
.lt-bilty   { background: var(--tag-amber-bg); color: var(--tag-amber-fg); }
.lt-bill    { background: var(--tag-purple-bg); color: var(--tag-purple-fg); }
.closing { font-size: .95rem; }
.pendtot td { font-weight: 700; border-top: 2px solid var(--border); }
/* consignment stage pills */
.stpill { display: inline-block; padding: 1px 9px; border-radius: 999px; font-size: .72rem; font-weight: 700; white-space: nowrap; }
.st-early { background: var(--chip-bg); color: var(--chip-fg); }
.st-mid   { background: var(--tag-amber-bg); color: var(--tag-amber-fg); }
.st-late  { background: var(--tag-green-bg); color: var(--tag-green-fg); }
h1 .stpill { font-size: .6rem; vertical-align: middle; margin-left: 8px; }
tr.is-archived td { opacity: .55; }
/* consignment workflow board */
.mtable.board td { vertical-align: top; }
.mtable.board tr.row-stale td { background: var(--row-stale-bg); }
.bcell-cons .stpill { margin-left: 6px; }
.linkage { margin-top: 6px; display: flex; flex-wrap: wrap; gap: 3px 6px; }
.linkage .lk, .linkage .lk-id { font-size: .72rem; color: var(--muted); background: var(--chip-bg); border-radius: 5px; padding: 1px 6px; }
.linkage .lk-ship { color: var(--tag-blue-fg); } .linkage .lk-bl { color: var(--tag-green-fg); } .linkage .lk-khi { color: var(--tag-purple-fg); } .linkage .lk-bilty { color: var(--tag-green-fg); }
.bcell-wf .wfbadge { display: inline-block; background: var(--chip-bg); color: var(--text); border-radius: 6px; padding: 2px 9px; font-size: .74rem; font-weight: 700; }
.wfnext { color: var(--brand2); font-size: .78rem; margin-top: 4px; }
.wfnext-btn { display: inline-block; background: var(--brand); color: #fff; font-size: .78rem; font-weight: 600;
  border-radius: 7px; padding: 5px 10px; margin-top: 4px; text-decoration: none; }
.wfnext-btn:hover { filter: brightness(1.1); text-decoration: none; color: #fff; }
.wfdays { display: inline-block; margin-top: 5px; font-size: .7rem; color: var(--muted); }
.wfdays.hot { color: var(--tag-red-fg); font-weight: 700; }
.blockers { margin-top: 5px; display: flex; flex-wrap: wrap; gap: 4px; }
.blk { font-size: .68rem; background: var(--tag-red-bg); color: var(--tag-red-fg); border-radius: 5px; padding: 1px 6px; }
.blk.ok { background: var(--tag-green-bg); color: var(--tag-green-fg); }
.bcell-metrics .mchip { display: inline-block; font-size: .72rem; color: var(--muted); background: var(--chip-bg); border-radius: 5px; padding: 2px 7px; margin: 1px 2px; }
.bcell-metrics .mchip b { color: var(--text); }
.wfactions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.wfaction-form { display: inline; margin: 0; }
.wfaction-back { display: inline-flex; align-items: center; gap: 6px; }
.wf-reason { background: var(--panel2); color: var(--text); border: 1px solid var(--border); border-radius: 7px;
  padding: 5px 8px; font-size: .8rem; width: 220px; }
.wfbtn { border: 0; border-radius: 7px; padding: 5px 12px; font-size: .78rem; font-weight: 600; cursor: pointer; }
.wfbtn-go { background: var(--brand); color: #fff; }
.wfbtn-back { background: var(--tag-red-bg); color: var(--tag-red-fg); }
.wfbtn:hover { filter: brightness(1.1); }
/* On the leave decision the two buttons mean opposite things, and the shared
   'primary' colour is the same red as Reject — so they read as one choice twice.
   Only here: approve takes the positive colour. */
.leave-act .wfbtn-go { background: var(--ok); color: #05261a; }
/* the same decision, taken straight from the list */
.leaverow-act { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.leaverow-act input[name=notes] { flex: 1 1 150px; min-width: 120px; padding: 5px 9px; font: inherit;
  font-size: .78rem; border: 1px solid var(--border); border-radius: 7px; background: var(--panel2); color: var(--text); }
.leaverow-act input.is-bad { border-color: var(--bad); }
.leaverow-act .wfbtn-go { background: var(--ok); color: #05261a; }
.leaverow-act .wfbtn { white-space: nowrap; }
@media (max-width: 767px) { .leaverow-act input[name=notes] { flex: 1 1 100%; } }

/* ===== Attendance read day by day ===== */
.daygrp + .daygrp .dayhead td { border-top: 14px solid transparent; background-clip: padding-box; }
.dayhead td { background: var(--panel2); padding: 10px 14px; border-left: 3px solid var(--brand);
  border-radius: 8px 8px 0 0; }
.dayhead-d { font-weight: 800; font-size: 1rem; color: var(--heading); margin-right: 10px; }
.dayhead-s { font-size: .82rem; color: var(--muted); }
.dayhead-s b { font-weight: 700; }
.dayhead-only { float: right; font-size: .76rem; font-weight: 600; }
@media (max-width: 560px) { .dayhead-only { float: none; display: block; margin-top: 4px; } }

/* ===== Customer portal access (staff side) ===== */
.portal-creds { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 10px; margin: 12px 0 0; }
.portal-creds > div { background: var(--panel2); border: 1px solid var(--border); border-radius: 10px; padding: 9px 12px; }
.portal-creds .k { display: block; font-size: .7rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-bottom: 3px; }
.portal-creds b { color: var(--heading); font-size: .95rem; overflow-wrap: anywhere; }
.portal-pw { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .06em; font-size: 1.05rem !important; }
.portal-msg { width: 100%; max-width: 520px; padding: 10px 12px; font: inherit; font-size: .85rem;
  border: 1px solid var(--border); border-radius: 9px; background: var(--panel2); color: var(--text); resize: vertical; }
.wfovr { display: inline-block; background: linear-gradient(90deg,var(--brand),var(--brand2)); color: #fff; border-radius: 5px; padding: 1px 7px; font-size: .68rem; font-weight: 700; }
/* "super-admin only" sign — marks any item hidden from staff & admins. Only ever
   seen by super admins, so it reads as "visible to you (super admin) alone". */
.saonly { display: inline-flex; align-items: center; gap: 3px; vertical-align: middle; margin-left: 6px; padding: 1px 7px; border-radius: 999px; font-size: .62rem; font-weight: 700; letter-spacing: .02em; text-transform: uppercase; color: #fbbf24; background: rgba(251,191,36,.12); border: 1px solid rgba(251,191,36,.45); cursor: help; white-space: nowrap; }
.saonly .cn { font-size: .66rem; letter-spacing: 0; }
.wfhistory { display: flex; flex-direction: column; gap: 5px; }
.wfh-item { background: var(--panel); border: 1px solid var(--border); border-left: 3px solid var(--brand); border-radius: 7px; padding: 7px 12px; font-size: .85rem; }
.edithistory { display: flex; flex-direction: column; gap: 5px; }
.eh-item { background: var(--panel); border: 1px solid var(--border); border-left: 3px solid var(--muted); border-radius: 7px; padding: 7px 12px; font-size: .85rem; }
/* data-entry grid */
.de-table input { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); border-radius: 5px; padding: 5px 6px; font: inherit; font-size: .82rem; width: 100%; min-width: 84px; }
.de-table input.de-num { min-width: 62px; text-align: right; }
/* Dropdowns in a data-entry grid, opt-in per table via .de-sel. The rule above
   only ever named <input>, so a <select> fell back to the browser's own control:
   grey, square-cornered, 19px tall against the 33px boxes beside it and sitting
   6px low. Same paint as .de-table input. Padding is 6px rather than 5px top and
   bottom because a select's content box is shorter at the same font size, so
   equal padding would leave it short of its neighbours (measured: 7px lands on
   the same 33px as the inputs, 5px would come out at 29px). */
.de-table.de-sel select { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); border-radius: 5px; padding: 7px 6px; font: inherit; font-size: .82rem; width: 100%; min-width: 0; }
.de-table.de-sel td, .de-table.de-sel th { vertical-align: middle; }
/* Rows read from a bank statement come in pairs — the statement's own line and
   its counter entry. Each pair is headed by the date and amount the statement
   gave, and consecutive pairs alternate a faint band, so a long import reads as
   transactions rather than as one wall of boxes. Colours come from the theme,
   so all four themes stay legible. */
.de-table .ve-grp td { border-top: 2px solid var(--border); background: none;
  padding: 9px 6px 5px; font-size: .78rem; }
.de-table tbody tr.ve-grp:first-child td { border-top: 0; padding-top: 2px; }
.ve-grp-d { color: var(--brand2); font-weight: 700; letter-spacing: .02em; }
.ve-grp-a { margin-left: 10px; font-weight: 700; font-size: .92rem; letter-spacing: .01em;
  padding: 2px 9px; border-radius: 999px; }
/* Money in and money out each keep their own tint across the whole transaction —
   its heading and both of its rows — so the two never blur into each other. The
   tints are the theme's soft tags, faint on purpose. */
.de-table tr.ve-grp.is-in td, .de-table tr.ve-pair.is-in td   { background: var(--tag-green-soft); }
.de-table tr.ve-grp.is-out td, .de-table tr.ve-pair.is-out td { background: var(--tag-red-soft); }
.ve-grp-a.is-in  { color: var(--tag-green-fg); background: var(--tag-green-bg); }
.ve-grp-a.is-out { color: var(--tag-red-fg); background: var(--tag-red-bg); }
.de-table .ve-date, .de-table .ve-date-h { white-space: nowrap; font-size: .76rem; color: var(--muted);
  width: 1%; padding-right: 10px; }
.de-table .ve-date input { min-width: 122px; font-size: .78rem; }
/* A searchable dropdown in that grid: the native select is hidden and a button
   stands in for it, so it takes the same compact paint as the selects above. */
.de-table.de-sel .ss { display: block; width: 100%; min-width: 0; }
.de-table.de-sel .ss-field { font-size: .82rem; padding: 7px 22px 7px 6px; border-radius: 5px;
  background: var(--surface-2); font-weight: 400; }
.de-table.de-sel .ss-field::after { right: 7px; }
.de-table td { padding: 3px 4px; }
.de-del { background: var(--tag-red-bg); color: var(--tag-red-fg); border: 0; border-radius: 5px; width: 22px; height: 22px; cursor: pointer; font-weight: 700; }
.de-del:hover { filter: brightness(1.2); }
.de-add { background: var(--tag-green-bg); color: var(--tag-green-fg); border: 0; border-radius: 5px;
  width: 22px; height: 22px; cursor: pointer; font-weight: 700; margin-right: 4px; }
.de-add:hover { filter: brightness(1.2); }
.ve-acts { white-space: nowrap; }
/* what a split transaction has not accounted for yet */
.ve-grp-left { color: var(--bad); font-weight: 700; margin-left: 12px; }
/* accounts sub-nav */
.subnav { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 4px 0 16px; padding-bottom: 10px; border-bottom: 1px solid var(--border); }
.subtab { padding: 6px 14px; border-radius: 8px; color: var(--text); font-weight: 600; }
.subtab.is-active { background: var(--brand); color: #fff; }
.subtab:hover { background: var(--panel2); text-decoration: none; }
.curpick { margin-left: auto; color: var(--muted); font-size: .85rem; }
.curchip { display: inline-block; padding: 3px 9px; margin-left: 4px; border-radius: 999px; background: var(--panel); border: 1px solid var(--border); color: var(--text); font-size: .78rem; }
.curchip.is-active { background: var(--brand2); color: #1a1200; border-color: var(--brand2); font-weight: 700; }
/* HR two-column layout */
.hr-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }
@media (max-width: 720px) { .hr-cols { grid-template-columns: 1fr; } }
/* party notes (first write feature) */
.notes-form { display: flex; gap: 8px; align-items: flex-start; margin: 10px 0 16px; }
.notes-form textarea { flex: 1; background: var(--panel); color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; font: inherit; resize: vertical; }
.notes-form button { background: var(--brand); color: #fff; border: 0; border-radius: 8px; padding: 9px 18px; font-weight: 600; cursor: pointer; white-space: nowrap; }
.noteslist { display: flex; flex-direction: column; gap: 8px; }
.noteitem { background: var(--panel); border: 1px solid var(--border); border-left: 3px solid var(--brand2); border-radius: 8px; padding: 10px 14px; }
.noteitem-body { line-height: 1.5; }
.noteitem-meta { color: var(--muted); font-size: .78rem; margin-top: 5px; }
/* party edit form */
.editform { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 20px; max-width: 780px; margin-top: 12px; }
.efield { display: flex; flex-direction: column; gap: 4px; }
.efield-wide { grid-column: 1 / -1; }
.ef-label { color: var(--muted); font-size: .82rem; }
.ef-badge { background: var(--brand2); color: #1a1200; border-radius: 5px; padding: 0 6px; font-size: .68rem; font-weight: 700; }
.editform input, .editform textarea, .editform select { background: var(--panel); color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; font: inherit; }
.editform-actions { grid-column: 1 / -1; display: flex; gap: 14px; align-items: center; margin-top: 4px; }
.editform-actions button { background: var(--brand); color: #fff; border: 0; border-radius: 8px; padding: 9px 22px; font-weight: 600; cursor: pointer; }
@media (max-width: 600px) { .editform { grid-template-columns: 1fr; } }
/* home KPIs */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin: 18px 0 8px; }
.kpi { display: block; background: var(--panel); border: 1px solid var(--border); border-radius: 14px; padding: 18px 20px; color: var(--text); }
.kpi:hover { border-color: var(--brand2); text-decoration: none; transform: translateY(-1px); }
.kpi-n { font-size: 2rem; font-weight: 800; line-height: 1; }
.kpi-l { margin-top: 6px; font-weight: 600; }
.kpi-s { margin-top: 4px; color: var(--muted); font-size: .82rem; }
.pipeline { display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: 8px; }
.pstage { display: block; border-radius: 10px; padding: 12px 10px; text-align: center; color: var(--text); border: 1px solid var(--border); }
.pstage:hover { text-decoration: none; filter: brightness(1.12); }
.pstage.st-early { background: var(--surface-2); } .pstage.st-mid { background: var(--tag-amber-soft); } .pstage.st-late { background: var(--tag-green-soft); }
.pstage-n { font-size: 1.5rem; font-weight: 800; }
.pstage-l { font-size: .68rem; color: var(--muted); margin-top: 3px; line-height: 1.2; }

.foot { text-align: center; color: var(--muted); font-size: .8rem; padding: 20px; border-top: 1px solid var(--border); }
/* ===== consignment workflow dashboard (ported from old CI board, dark-themed) ===== */
/* scope bar */
.cscope { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin: 4px 0 14px; padding: 8px 12px; background: var(--panel); border: 1px solid var(--border); border-radius: 10px; }
.cscope-lbl { font-size: .68rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.cscope-link { padding: 5px 12px; border-radius: 8px; color: var(--text); font-weight: 600; border: 1px solid transparent; }
.cscope-link.on { background: var(--tag-green-bg); color: var(--tag-green-fg); border-color: var(--tag-green-bg); }
.cscope-link:hover { text-decoration: none; background: var(--panel2); }
.cscope-form { margin: 0; }
.cscope select, .cscope-search input { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px; font: inherit; font-size: .85rem; }
.cscope-search { margin: 0; flex: 1; min-width: 200px; }
.cscope-search input { width: 100%; }
.cscope .exportlink { margin-left: auto; }
/* stepped pipeline */
.cpipe { display: flex; align-items: stretch; flex-wrap: wrap; gap: 6px; margin: 0 0 12px; padding: 12px; background: var(--panel); border: 1px solid var(--border); border-radius: 12px; overflow-x: auto; }
.cpipe-arrow { align-self: center; color: var(--muted); font-size: 1.1rem; }
.cpipe-step { display: flex; flex-direction: column; gap: 2px; min-width: 108px; padding: 9px 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); text-align: left; cursor: pointer; }
a.cpipe-step:hover { text-decoration: none; filter: brightness(1.18); border-color: var(--brand2); }
.cpipe-step--cons { border-left: 3px solid var(--ok); }
.cpipe-step--ship { border-left: 3px solid #818cf8; }
.cpipe-step.info { cursor: default; opacity: .9; }
.cpipe-step.is-empty { opacity: .4; }
.cpipe-step.on { outline: 2px solid var(--brand2); }
.cpipe-count { font-size: 1.4rem; font-weight: 800; line-height: 1; }
.cpipe-label { font-size: .74rem; font-weight: 600; }
.cpipe-sub { font-size: .64rem; color: var(--muted); }
/* quick-filter chips */
.cchips { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 16px; }
.cchip { padding: 5px 13px; border-radius: 999px; background: var(--panel); border: 1px solid var(--border); color: var(--text); font-size: .8rem; font-weight: 600; }
.cchip:hover { text-decoration: none; background: var(--panel2); }
.cchip.on { background: var(--brand); color: #fff; border-color: var(--brand); }
.cchip--wait { border-color: var(--tag-amber-border); color: var(--brand2); }
.cchip--wait.on { background: var(--brand2); color: #1a1200; border-color: var(--brand2); }
/* row lifecycle badge + since */
.lcbadge { display: inline-block; font-size: .68rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; white-space: nowrap; vertical-align: middle; }
.lcbadge.lc-cons { background: var(--tag-green-bg); color: var(--tag-green-fg); border: 1px solid var(--tag-green-bg); }
.lcbadge.lc-ship { background: var(--tag-blue-bg); color: var(--tag-blue-fg); border: 1px solid var(--tag-blue-bg); }
.cnum { display: inline-flex; align-items: center; padding: 3px 9px; border-radius: 7px; background: var(--tag-green-bg); color: var(--tag-green-fg) !important; font-weight: 700; white-space: nowrap; }
.cons-since { display: inline-block; font-size: .68rem; font-weight: 700; padding: 1px 7px; border-radius: 999px; background: var(--chip-bg); color: var(--muted); vertical-align: middle; }
.cons-since.hot { background: var(--tag-red-bg); color: var(--tag-red-fg); }
.lk-split { background: var(--tag-purple-bg) !important; color: var(--tag-purple-fg) !important; }
/* action tiles — wrap into a compact block so the extra tiles don't widen the table */
.bcell-actions { display: flex; flex-wrap: wrap; align-content: flex-start; max-width: 250px; }
.atile { display: inline-flex; align-items: center; gap: 3px; margin: 2px 3px 2px 0; padding: 4px 9px; border-radius: 7px; background: var(--surface-2); border: 1px solid var(--border); color: var(--text); font-size: .74rem; font-weight: 600; }
.atile:hover { text-decoration: none; filter: brightness(1.25); border-color: var(--brand2); }
.atile--go { border-left: 2px solid #22c55e; }
.atile--edit { border-left: 2px solid #38bdf8; }
.atile--bilty { border-left: 2px solid #34d399; }
.atile--bilty.is-set { background: var(--tag-green-bg); color: var(--tag-green-fg); }
.atile--split { border-left: 2px solid #c084fc; }
.atile--ship { border-left: 2px solid #818cf8; }
.atile--wa { border-left: 2px solid #25d366; }
.atile--exp { border-left: 2px solid #f59e0b; }
.atile--gate { border-left: 2px solid #a3a3a3; }
.atile--logs { border-left: 2px solid #64748b; }
.atile--pack { border-left: 2px solid #38bdf8; }
.atile--sum { border-left: 2px solid #2dd4bf; }
.atile--load { border-left: 2px solid #818cf8; }
.atile.is-disabled { opacity: .45; cursor: not-allowed; }
.atile-badge { display: inline-flex; align-items: center; justify-content: center; min-width: 15px; height: 15px; padding: 0 4px; border-radius: 999px; background: var(--brand2); color: #1a1200; font-size: .62rem; font-weight: 800; }

/* ============================================================
   RESPONSIVE / MOBILE
   Strict width rules (no horizontal page scroll), tightened
   fonts, horizontal-scroll pipeline, and the workflow board
   collapses from a 6-col table into stacked cards.
   ============================================================ */
img, video, canvas, iframe { max-width: 100%; height: auto; }
.tablewrap { -webkit-overflow-scrolling: touch; }

@media (max-width: 860px) {
  html, body { max-width: 100%; overflow-x: hidden; }
  body { font-size: 15px; }

  /* off-canvas sidebar: hidden by default, hamburger reveals it */
  .menu-btn { display: block; }
  .topbrand { display: block; font-size: 1.05rem; letter-spacing: .08em; }
  .topbar { padding: 8px 12px; gap: 8px 10px; flex-wrap: wrap; }
  /* view-as / old-system / theme cluster: own full-width row, right-aligned,
     each control still free to wrap further if it doesn't all fit */
  .topbar-actions { flex: 1 1 100%; margin-left: 0; }
  .viewas select { max-width: 160px; }
  .sidebar { position: fixed; top: 0; left: 0; height: 100vh; transform: translateX(-100%);
    transition: transform .22s ease; box-shadow: 2px 0 18px rgba(0,0,0,.45); }
  body.nav-open .sidebar { transform: translateX(0); }
  body:not(.nav-open) .nav-backdrop { display: none; }
  .brand-cn { font-size: 1.35rem; letter-spacing: .12em; }
  .brand-sub { font-size: .66rem; }

  /* page container + headings */
  .wrap { padding: 16px 13px 44px; }
  h1 { font-size: 1.35rem; }
  .h1-sub { font-size: .82rem; margin-left: 6px; }
  h2 { font-size: 1.06rem; margin: 24px 0 10px; }
  .lead { font-size: .92rem; }

  /* filter bars + scope bar: full-width, stacked controls */
  .filterbar input[type=search], .filterbar select, .filterbar label.fld,
  .cscope select, .cscope-search, .cscope-search input,
  .cscope-form { width: 100%; min-width: 0; flex: 1 1 100%; }
  .filterbar label.fld input[type=date] { flex: 1 1 auto; min-width: 0; }
  .filterbar button { width: 100%; }
  .filterbar .exportlink, .cscope .exportlink { margin-left: 0; }
  .cscope-link { flex: 1 1 auto; text-align: center; }
  .notes-form { flex-direction: column; }
  .notes-form button { width: 100%; }

  /* pipeline -> clean horizontal-scroll strip */
  .cpipe { flex-wrap: nowrap; overflow-x: auto; gap: 4px; padding: 10px; }
  .cpipe-step { min-width: 94px; padding: 7px 9px; flex: 0 0 auto; }
  .cpipe-count { font-size: 1.15rem; }
  .cpipe-label { font-size: .68rem; }
  .cpipe-sub { font-size: .58rem; }
  .cpipe-arrow { font-size: .9rem; }
  .cchip { font-size: .74rem; padding: 4px 10px; }

  /* wide tables -> stacked cards (.board = consignment workflow; .stack = the
     other wide lists, cell labels filled from the headers by kit.js) */
  .mtable.board, .mtable.board tbody, .mtable.board tr, .mtable.board td,
  .mtable.stack, .mtable.stack tbody, .mtable.stack tr, .mtable.stack td { display: block; width: 100%; }
  .mtable.board thead, .mtable.stack thead { display: none; }
  .mtable.board tr, .mtable.stack tr { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; margin-bottom: 12px; padding: 12px 14px; }
  .mtable.board tr:hover, .mtable.stack tr:hover { background: var(--panel); }
  .mtable.board tr.row-stale { background: var(--row-stale-bg); }
  .mtable.board tr.row-stale td { background: transparent; }
  .mtable.board td, .mtable.stack td { border-bottom: none; padding: 5px 0; text-align: left !important; }
  .mtable.board td[data-label], .mtable.stack td[data-label] { border-top: 1px solid var(--border); padding-top: 8px; margin-top: 4px; }
  .mtable.board td[data-label]::before, .mtable.stack td[data-label]::before { content: attr(data-label); display: block; font-size: .6rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-bottom: 3px; }
  .mtable.stack td:first-child { font-weight: 700; font-size: 1.02rem; }        /* first column = card title */
  .mtable.stack td.num { font-variant-numeric: tabular-nums; }
  .mtable.stack tr[data-norow] td { text-align: center !important; color: var(--muted); }
  .bcell-actions .atile { margin-bottom: 4px; }

  /* generic data tables: tighter */
  .mtable { font-size: .85rem; }
  .mtable th, .mtable td { padding: 7px 8px; }

  /* grids */
  .cards { grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; }
  .card { min-width: 0; }               /* allow shrink so long money values don't overflow */
  .card .v { overflow-wrap: anywhere; }
  .fields { grid-template-columns: 1fr; }
  .curpick { margin-left: 0; width: 100%; }
}

@media (max-width: 480px) {
  .cards { grid-template-columns: 1fr; } /* full-width cards: big money numbers never clip */
  .card .v { font-size: 1.2rem; }
  .kpi-n { font-size: 1.6rem; }
  .brand-sub { display: none; }
  .devbar { font-size: .72rem; padding: 5px 8px; }
  h1 { font-size: 1.2rem; }
  .cpipe-step { min-width: 86px; }
}

/* ===== sign-in page + sign-out ===== */
.loginwrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.logincard { width: 100%; max-width: 360px; background: var(--panel); border: 1px solid var(--border); border-radius: 16px; padding: 30px 28px 24px; box-shadow: 0 20px 60px -30px rgba(0,0,0,.8); display: flex; flex-direction: column; }
.login-brand { text-align: center; }
.login-brand .brand-cn { font-size: 2.1rem; letter-spacing: .16em; }
.login-sub { text-align: center; color: var(--muted); font-size: .8rem; margin: 2px 0 20px; }
.logincard .ef-label { margin: 10px 0 4px; }
.logincard input { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); border-radius: 9px; padding: 10px 12px; font: inherit; }
.logincard input:focus { outline: 2px solid var(--brand2); border-color: var(--brand2); }
.logincard button { margin-top: 18px; background: var(--brand); color: #fff; border: 0; border-radius: 9px; padding: 11px; font-weight: 700; font-size: .95rem; cursor: pointer; }
.logincard button:hover { filter: brightness(1.08); }
.login-foot { color: var(--muted); font-size: .72rem; text-align: center; margin: 14px 0 0; }

/* ===== consignment photo grid ===== */
.photogrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; margin: 10px 0; }
.photogrid img { width: 100%; height: 120px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); background: var(--surface-2); }
.photogrid a:hover img { border-color: var(--brand2); }

/* ===================================================================== */
/* Component kit (0B) — vanilla dark equivalents of DataTables / Select2 */
/* / SweetAlert / Lightbox. Enhances markup; server filter+paginate stay. */
/* ===================================================================== */

/* --- 1. sortable table headers --- */
.mtable th.is-sortable { cursor: pointer; user-select: none; padding-right: 22px; position: relative; }
.mtable th.is-sortable:hover { color: var(--text); }
.mtable th.is-sortable::after { content: '⇅'; position: absolute; right: 8px; opacity: .35; font-size: .8em; }
.mtable th.is-sortable[aria-sort="ascending"]::after { content: '↑'; opacity: 1; color: var(--brand2); }
.mtable th.is-sortable[aria-sort="descending"]::after { content: '↓'; opacity: 1; color: var(--brand2); }
.mtable th.is-sortable:focus-visible { outline: 2px solid var(--brand2); outline-offset: -2px; }

/* --- What is being loaded onto a shipment --------------------------------
   A running count of what has been ticked, stuck to the top of the list so it
   stays readable while the list is scrolled. Quiet until something is ticked,
   then it takes the ok colour: this is the number a container is filled to. */
.loadtot { position: fixed; left: 218px; right: 0; bottom: 0; z-index: 45;   /* over the page, clear of the sidebar */
  display: flex; flex-wrap: wrap; gap: 16px 28px; align-items: baseline;
  padding: 12px 18px; background: var(--panel); border-top: 2px solid var(--border);
  box-shadow: 0 -6px 20px rgba(0,0,0,.18); }
.loadtot b { font-size: 1.35rem; font-weight: 800; color: var(--muted); }
.loadtot span { color: var(--muted); font-size: .82rem; }
.loadtot.is-on { border-top-color: var(--ok); }
.loadtot.is-on b { color: var(--ok); }
.loadtot.is-on .loadtot-n b { color: var(--heading); }
/* room at the foot of the page so the bar never sits on top of the last row or
   the Create button */
.loadtot-space { height: 86px; }
@media (max-width: 860px) { .loadtot { left: 0; } }
@media (max-width: 640px) { .loadtot { gap: 8px 18px; padding: 9px 12px; } .loadtot b { font-size: 1.1rem; } }
@media print { .loadtot, .loadtot-space { display: none; } }

/* The day's line on the clock: asked with the clock-in, shown back once the day
   is running, and rewritable while it lasts. */
.vclock-task-lbl { display: block; font-size: .82rem; color: var(--muted); margin: 6px 0 4px; }
.vclock-task-in { width: 100%; box-sizing: border-box; background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; font: inherit; font-size: .88rem;
  resize: vertical; margin-bottom: 8px; }
.vclock-task-in:focus { outline: none; border-color: var(--brand2); }
/* The clock is a flex row, so the day's line takes a row of its own rather than
   being squeezed in beside the buttons and cut off at the edge. */
.vclock-task { flex: 1 0 100%; width: 100%; margin-top: 10px; padding-top: 10px;
  border-top: 1px solid var(--border); }
.vclock-task .vclock-brk { margin-top: 8px; }
/* the clock-in form carries the box, so it needs more than a button's width */
.vclock-act:has(.vclock-task-in) { flex: 1 1 340px; max-width: 460px; }
.vclock-task-now { font-size: .88rem; line-height: 1.45; white-space: pre-wrap; }
/* The day as a list: each entry with the time it was written. Written entries are
   read-only — there is nothing to click on them, which is the point. */
.vclock-task-list { list-style: none; margin: 6px 0 0; padding: 0; }
.vclock-task-list li { display: flex; gap: 10px; align-items: baseline; padding: 4px 0;
  font-size: .88rem; line-height: 1.45; border-top: 1px solid var(--border); white-space: pre-wrap; }
.vclock-task-list li:first-child { border-top: 0; }
.vclock-task-at, .tasklog-at { flex: 0 0 auto; font-variant-numeric: tabular-nums; font-size: .76rem;
  font-weight: 700; color: var(--muted); }
/* the same list, tighter, inside HR's attendance sheet */
.tasklog { list-style: none; margin: 0; padding: 0; }
.tasklog li { display: flex; gap: 8px; align-items: baseline; padding: 2px 0; line-height: 1.4;
  white-space: pre-wrap; }
.tasklog li + li { border-top: 1px dashed var(--border); padding-top: 4px; margin-top: 2px; }
.vclock-task-k { display: inline-block; font-size: .72rem; font-weight: 700; letter-spacing: .06em;
  text-transform: uppercase; color: var(--muted); margin-right: 8px; }

/* The party on/off switch: green while the party is usable, red once it is off,
   so a glance down the action column says which parties are still in play. */
.act-i.act-pw { color: var(--ok); border: 0; background: var(--tag-green-soft); cursor: pointer; font: inherit; }
/* The power mark is drawn, not typed: the character for it (⏻) is a coloured
   emoji on some systems, a hairline glyph on others and a blank box on a few, so
   it looked like a different button on different machines. This is the same shape
   everywhere and takes the button's own colour. */
.pw-ic { width: 1.05em; height: 1.05em; vertical-align: -.16em; fill: none;
  stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.act-i.act-pw.is-off { color: var(--bad); background: var(--tag-red-soft); }
.act-i.act-pw:hover { filter: brightness(1.15); }

/* --- Carry Queries: answered or not, at a glance ---------------------------
   The board's whole job is to separate "we still owe this customer an answer"
   from "answered, the ball is theirs". The row carries a faint tint of the
   theme's own tags, and the status chip at the end says it in words; a row that
   has gone past the day it should have been answered gets a red spine as well,
   so late is louder than merely pending without shouting a second colour. */
.mtable tr.q-pending td { background: var(--tag-red-soft); }
.mtable tr.q-replied td { background: var(--tag-green-soft); }
.mtable tr.q-closed  td { opacity: .72; }
.mtable tr.is-late td:first-child { box-shadow: inset 4px 0 0 var(--bad); }
.qchip { display: inline-block; padding: 2px 9px; border-radius: 999px; font-weight: 700; font-size: .78rem; }
.qchip-us       { background: var(--tag-red-bg);   color: var(--tag-red-fg); }
.qchip-customer { background: var(--tag-green-bg); color: var(--tag-green-fg); }
.qchip-won      { background: var(--tag-green-bg); color: var(--tag-green-fg); }
.qchip-lost     { background: var(--chip-bg);      color: var(--chip-fg); }

/* --- 2. searchable select (≈ Select2) --- */
.ss { position: relative; display: inline-block; min-width: 180px; }
.ss-native { position: absolute; opacity: 0; width: 100%; height: 100%; pointer-events: none; }
.ss .ss-field { width: 100%; text-align: left; background: var(--panel); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px; padding: 8px 30px 8px 11px; font: inherit; font-weight: 400;
  cursor: pointer; position: relative; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ss-field::after { content: '▾'; position: absolute; right: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.ss-field.is-placeholder { color: var(--muted); }
.ss.is-open .ss-field { border-color: var(--brand2); }
.ss-pop { position: absolute; z-index: 60; top: calc(100% + 4px); left: 0; min-width: 100%;
  background: var(--panel2); border: 1px solid var(--border); border-radius: 10px; padding: 6px;
  box-shadow: 0 12px 30px rgba(0,0,0,.5); }
.ss-search { width: 100%; box-sizing: border-box; background: var(--bg); color: var(--text);
  border: 1px solid var(--border); border-radius: 7px; padding: 7px 10px; font: inherit; margin-bottom: 6px; }
.ss-search:focus { outline: none; border-color: var(--brand2); }
.ss-list { max-height: 240px; overflow-y: auto; overflow-x: hidden; }
.ss-opt { padding: 7px 10px; border-radius: 6px; cursor: pointer; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; }
.ss-opt:hover, .ss-opt.is-active { background: var(--chip-hover); }
.ss-opt.is-selected { color: var(--brand2); font-weight: 600; }
.ss-empty { padding: 8px 10px; color: var(--muted); font-size: .88rem; }

/* --- 3. modal + confirm (≈ SweetAlert) --- */
body.modal-lock { overflow: hidden; }
.modal-back { position: fixed; inset: 0; z-index: 80; background: rgba(2,6,15,.66);
  display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal { width: 100%; max-width: 440px; background: var(--panel); border: 1px solid var(--border);
  border-radius: 14px; box-shadow: 0 24px 60px rgba(0,0,0,.6); overflow: hidden;
  animation: modalpop .16s ease-out; }
@keyframes modalpop { from { transform: translateY(8px) scale(.98); opacity: 0; } to { transform: none; opacity: 1; } }
.modal.is-danger { border-top: 3px solid var(--brand); }
.modal-head { padding: 16px 20px 4px; font-size: 1.1rem; font-weight: 700; color: var(--heading); }
.modal-body { padding: 8px 20px 16px; color: var(--text); line-height: 1.5; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 12px 20px 18px; }
.modal-foot button, .btn-primary, .btn-ghost, .btn-danger {
  border: 0; border-radius: 9px; padding: 9px 18px; font: inherit; font-weight: 600; cursor: pointer; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-danger { background: var(--bad); color: #2a0a0a; }
.btn-ghost { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn-primary:hover, .btn-danger:hover { filter: brightness(1.08); }
.btn-ghost:hover { background: var(--chip-hover); }

/* --- 4. image lightbox --- */
.lightbox { position: fixed; inset: 0; z-index: 90; background: rgba(2,6,15,.9);
  display: flex; align-items: center; justify-content: center; padding: 40px; }
.lb-fig { margin: 0; max-width: 92vw; max-height: 88vh; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.lb-fig img { max-width: 100%; max-height: 82vh; object-fit: contain; border-radius: 8px; box-shadow: 0 10px 40px rgba(0,0,0,.6); }
.lb-cap { color: var(--text); font-size: .9rem; text-align: center; }
.lb-close { position: absolute; top: 16px; right: 18px; }
.lb-nav { font-size: 2rem; line-height: 1; padding: 4px 14px; }
.lb-close, .lb-nav { background: rgba(30,41,59,.7); color: #fff; border: 1px solid rgba(255,255,255,.25);
  border-radius: 10px; cursor: pointer; }
.lb-close:hover, .lb-nav:hover { background: rgba(30,41,59,.92); color: #fff; }
.lb-nav { position: relative; }

@media (max-width: 620px) {
  .ss { min-width: 100%; display: block; }
  .lightbox { padding: 12px; }
  .lb-nav { font-size: 1.5rem; padding: 2px 9px; }
}

/* ===================================================================== */
/* Dashboard quick search — the bar reuses .filterbar, so only the results
   need styling. auto-fit grid: as many module columns as fit, collapsing to a
   single column on a phone without a breakpoint of its own. */
.dash-search { margin: 4px 0 14px; }
.dash-search input[type=search] { flex: 1 1 320px; }
.dsr-wrap { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 12px; margin: 0 0 18px; }
.dsr-group { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; min-width: 0; }
.dsr-head { display: flex; align-items: baseline; gap: 6px; margin-bottom: 4px; font-size: .86rem; color: var(--heading); }
.dsr-head .seeall { margin-left: auto; white-space: nowrap; }
.dsr-row { display: block; padding: 6px 8px; border-radius: 8px; }
.dsr-row:hover { background: var(--panel2); text-decoration: none; }
.dsr-t { display: block; font-weight: 600; font-size: .87rem; overflow-wrap: anywhere; }
.dsr-s { display: block; color: var(--muted); font-size: .75rem; overflow-wrap: anywhere; }

/* ===================================================================== */
/* Parties module (Phase 1) — old Party Dashboard IA, dark translation    */
/* ===================================================================== */
.pt-hero { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem;
  flex-wrap: wrap; margin: 4px 0 18px; padding: 20px 22px; border: 1px solid var(--border);
  border-radius: 12px; background: linear-gradient(135deg, var(--panel) 0%, var(--panel2) 100%); }
.pt-hero h1 { margin: 0; }
.pt-eyebrow { display: block; margin-bottom: 6px; color: var(--brand2); font-size: .74rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.pt-eyebrow .cn { color: var(--brand2); opacity: .8; }
.pt-lead { margin: 6px 0 0; color: var(--muted); }
.pt-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.pt-actions .btn-primary { text-decoration: none; display: inline-block; }
.pt-actions .btn-primary:hover { text-decoration: none; }

.pt-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 12px; margin: 0 0 20px; }
.pt-stat { display: flex; align-items: center; gap: 14px; padding: 15px 16px; background: var(--panel);
  border: 1px solid var(--border); border-radius: 12px; }
.pt-stat-ic { display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto;
  width: 46px; height: 46px; border-radius: 12px; font-size: 1.3rem; background: var(--chip-hover); }
.pt-stat-ic.ic-total { background: var(--tag-blue-soft); } .pt-stat-ic.ic-mobile { background: var(--tag-green-soft); }
.pt-stat-ic.ic-wechat { background: var(--tag-green-soft); } .pt-stat-ic.ic-new { background: var(--tag-amber-soft); }
.pt-stat-k { display: block; margin-bottom: 4px; color: var(--muted); font-size: .72rem; font-weight: 700; letter-spacing: .03em; text-transform: uppercase; }
.pt-stat strong { display: block; color: var(--heading); font-size: 1.5rem; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.1; }
.pt-stat-note { display: block; margin-top: 3px; color: var(--muted); font-size: .68rem; font-weight: 400; }

.pt-card { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.pt-card-head { display: flex; align-items: center; justify-content: space-between; gap: 16px;
  flex-wrap: wrap; padding: 14px 18px; border-bottom: 1px solid var(--border); background: var(--panel2); }
.pt-card-head h4 { margin: 0; font-size: 1.05rem; font-weight: 700; color: var(--heading); }
.pt-card-head .filterbar { margin: 0; }
.pt-card .tablewrap { padding: 0 4px; }
.text-left { text-align: left; }

.pt-table td { vertical-align: middle; }
.pt-cell { display: flex; align-items: center; gap: 11px; }
.pt-avatar { display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto;
  width: 38px; height: 38px; border-radius: 50%; color: #fff; font-size: .82rem; font-weight: 800; text-transform: uppercase; }
.pt-name { font-weight: 700; color: var(--text); }
.pt-sub { color: var(--muted); font-size: .78rem; margin-top: 2px; }
.pt-badge-off { display: inline-block; margin-left: 6px; padding: 1px 7px; border-radius: 999px;
  background: var(--tag-red-bg); color: var(--tag-red-fg); font-size: .62rem; font-weight: 800; text-transform: uppercase; vertical-align: middle; }
.pt-inactive .pt-cell, .pt-inactive .pt-type, .pt-inactive .pt-contact { opacity: .55; }
.pt-type { display: inline-block; font-weight: 700; font-size: .86rem; }
.pt-cur { color: var(--muted); font-size: .74rem; margin-top: 2px; }
.pt-contact { font-size: .86rem; }
.pt-line { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.pt-ic { font-size: .82rem; opacity: .9; }
.pt-miss, .pt-miss .pt-ic { color: var(--tag-red-fg); }
.pt-addr { max-width: 260px; margin-top: 3px; color: var(--muted); font-size: .76rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ua-badge { display: inline-block; padding: 3px 10px; border-radius: 999px; background: var(--tag-blue-soft);
  color: var(--tag-blue-fg); border: 1px solid var(--tag-blue-bg); font-size: .74rem; font-weight: 700; white-space: nowrap; }
.ua-badge.is-none { background: var(--chip-hover); color: var(--muted); border-color: var(--border); }
.pt-actions-strip { display: inline-flex; align-items: center; gap: 6px; }
.act-i { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px;
  border-radius: 8px; background: var(--chip-hover); color: var(--tag-blue-fg); font-size: 1rem; }
.act-i:hover { background: var(--panel2); color: var(--heading); text-decoration: none; }
.pt-empty { text-align: center; color: var(--muted); padding: 28px; }

/* Phones: force a single column even when a page sets grid-template-columns
   inline (inline styles otherwise beat the media query and overflow). */
@media (max-width: 560px) { .pt-stats { grid-template-columns: 1fr !important; } }
@media (max-width: 620px) {
  .pt-card-head { flex-direction: column; align-items: stretch; }
  .pt-card-head .filterbar { flex-direction: column; align-items: stretch; }
  .pt-addr { max-width: 200px; }
}

/* --- remote-modal fragments (board data-entry/bilty/split in a modal) --- */
.modal.is-wide { max-width: 880px; }
.modal-body .frag > h1, .modal-body .frag > .crumb { display: none; }  /* modal-head carries the title */
.modal-body .frag > .note { margin-top: 0; }
.modal-body .tablewrap { max-height: 58vh; overflow: auto; }
.frag-load { padding: 32px 16px; text-align: center; color: var(--muted); }

/* ===== Shipments module (Phase 3) — reuses .pt-hero/.pt-card/.cpipe/.mtable.board ===== */
.shp-search { display: flex; gap: 6px; margin: 0; }
.shp-search input[type=search] { background: var(--panel); color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; font-size: .9rem; min-width: 240px; }
.shp-search button { background: var(--brand); color: #fff; border: 0; border-radius: 8px; padding: 8px 16px; font-weight: 600; cursor: pointer; }
.shp-search .clearlink { align-self: center; color: var(--muted); padding: 0 4px; }
.shp-stage { display: inline-block; margin-left: 8px; padding: 1px 9px; border: 1px solid; border-radius: 999px; font-size: .68rem; font-weight: 700; vertical-align: middle; }
.shp-sub { color: var(--muted); font-size: .78rem; margin-top: 2px; }
.shp-kv { display: block; font-size: .84rem; white-space: nowrap; }
.shp-kv b { color: var(--muted); font-weight: 600; margin-right: 4px; font-size: .74rem; }

/* ===== Unified Accounts (Phase 4) — reuses .pt-hero/.pt-card/.cchip ===== */
.ua-pending { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px;
  margin: 0 0 16px; padding: 10px 14px; border: 1px solid var(--tag-amber-border); border-radius: 10px;
  background: var(--tag-amber-bg); color: var(--tag-amber-fg); font-size: .86rem; }
.ua-pending strong { font-variant-numeric: tabular-nums; }
.cchip-sep { display: inline-block; width: 1px; align-self: stretch; margin: 2px 4px; background: var(--border); }
.pt-actions .btn-ghost { text-decoration: none; display: inline-flex; align-items: center; }
.pt-actions .btn-ghost:hover { text-decoration: none; }
.ua-balance td.num { font-variant-numeric: tabular-nums; }
/* All-modules overview (super only): per-currency net breakdown + row module tag */
.ua-modnet { display: flex; flex-wrap: wrap; gap: 8px 18px; margin-top: 6px; }
.ua-modnet-i { font-size: 1rem; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ua-modnet-i b { font-weight: 600; color: var(--muted); margin-right: 4px; font-size: .8rem; text-transform: uppercase; letter-spacing: .02em; }
.ua-modnet-i .ok { color: var(--ok); } .ua-modnet-i .bad { color: var(--bad); }
.ua-modtag { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: .72rem; font-weight: 700; color: var(--tag-amber-fg); background: var(--tag-amber-soft); border: 1px solid var(--tag-amber-border); }

/* ===== HR module (Phase 5) — old HR dashboard IA: stat row + employee card grid ===== */
.hr-stats .pt-stat { border-left: 3px solid var(--border); }
a.pt-stat { text-decoration: none; color: inherit; }
a.pt-stat:hover { border-color: var(--brand); }
.pt-stat.tone-ok   { border-left-color: var(--ok); }
.pt-stat.tone-warn { border-left-color: var(--brand2); }
.pt-stat.tone-info { border-left-color: var(--tag-blue-fg); }
.pt-stat.tone-brand{ border-left-color: var(--brand); }
.pt-stat.tone-ok .pt-stat-ic   { background: var(--tag-green-soft); }
.pt-stat.tone-warn .pt-stat-ic { background: var(--tag-amber-soft); }
.pt-stat.tone-info .pt-stat-ic { background: var(--tag-blue-soft); }
.pt-stat.tone-brand .pt-stat-ic{ background: var(--tag-red-bg); }
.hr-of { color: var(--muted); font-size: .9rem; font-weight: 600; }

/* widened with the bigger photo, so a name still has room beside it */
.hr-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 12px; padding: 14px; }
.hr-emp-card { border: 1px solid var(--border); border-radius: 12px; background: var(--panel2); padding: 13px 14px; display: flex; flex-direction: column; gap: 10px; }
.hr-emp-card.is-former { opacity: .62; }
.hr-emp-top { display: flex; align-items: flex-start; gap: 11px; }
.hr-emp-id { flex: 1; min-width: 0; }
.hr-emp-id .pt-name { display: inline; }
.hr-emp-meta { color: var(--muted); font-size: .78rem; margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hr-emp-top .badge { flex: 0 0 auto; align-self: flex-start; }
.hr-emp-actions { display: flex; flex-wrap: wrap; gap: 6px; border-top: 1px solid var(--border); padding-top: 10px; }
.hr-emp-actions a { display: inline-flex; align-items: center; gap: 4px; padding: 5px 11px; border-radius: 8px;
  background: var(--chip-hover); color: var(--tag-blue-fg); font-size: .8rem; font-weight: 600; }
.hr-emp-actions a:hover { background: var(--panel2); color: var(--heading); text-decoration: none; }

@media (max-width: 900px) { .hr-stats { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px) { .hr-grid { grid-template-columns: 1fr; } }

/* ===== Party detail/edit (Phase 1 finish) — profile header ===== */
.pt-profile { display: flex; align-items: center; gap: 16px; }
.pt-avatar-lg { width: 60px; height: 60px; font-size: 1.3rem; flex: 0 0 auto; }
.pt-hero .pt-profile h1 { margin: 4px 0 2px; }
@media (max-width: 620px) { .pt-profile { align-items: flex-start; } .pt-avatar-lg { width: 48px; height: 48px; font-size: 1.05rem; } }

/* ===================================================================== */
/* Role dashboards (super/admin/user) — vanilla charts, no chart library  */
/* ===================================================================== */
.dash-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; margin: 0 0 16px; }
.chart-card { display: flex; flex-direction: column; }
.chart-body { padding: 15px 18px 18px; }
.chart-note { margin: 12px 0 0; font-size: .8rem; color: var(--tag-amber-fg); }

/* horizontal bar chart */
.chart-bars { display: flex; flex-direction: column; gap: 7px; }
.cbar-row { display: grid; grid-template-columns: 118px 1fr 92px; align-items: center; gap: 10px; font-size: .82rem; }
.cbar-label { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cbar-track { height: 16px; background: var(--surface-2); border-radius: 6px; overflow: hidden; position: relative; }
.cbar-fill { height: 100%; border-radius: 6px; min-width: 2px; }
.cbar-val { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.cbar-val.bad { color: var(--tag-red-fg); }
.chart-bars.signed .cbar-track.centre { overflow: visible; }
.chart-bars.signed .cbar-track.centre::before { content: ''; position: absolute; left: 50%; top: -2px; bottom: -2px; width: 1px; background: var(--border); }
.cbar-fill.pos { position: absolute; top: 0; background: var(--ok); }
.cbar-fill.neg { position: absolute; top: 0; background: var(--bad); }
/* balances can be very large — let the value column size to content so it never clips */
.chart-bars.signed .cbar-row { grid-template-columns: 84px minmax(50px, 1fr) auto; }
.chart-bars.signed .cbar-val { padding-left: 12px; font-size: .8rem; }

/* donut (conic-gradient) + legend */
.donut-wrap { display: flex; align-items: center; gap: 22px; flex-wrap: wrap; }
.donut { width: 140px; height: 140px; border-radius: 50%; position: relative; flex: 0 0 auto; }
.donut-hole { position: absolute; inset: 22px; background: var(--panel); border-radius: 50%; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.donut-n { font-size: 1.4rem; font-weight: 800; color: var(--heading); line-height: 1; }
.donut-s { font-size: .68rem; color: var(--muted); margin-top: 2px; }
.dleg { display: flex; flex-direction: column; gap: 7px; flex: 1; min-width: 130px; }
.dleg-row { display: grid; grid-template-columns: 14px 1fr auto; align-items: center; gap: 9px; font-size: .85rem; }
.dleg-dot { width: 11px; height: 11px; border-radius: 3px; }
.dleg-lbl { color: var(--muted); }
.dleg-val { font-weight: 700; font-variant-numeric: tabular-nums; }

/* trend (SVG area+line) */
.trend { width: 100%; height: auto; display: block; }
.trend .trend-x { fill: var(--muted); font-size: 9px; }
.trend .trend-v { fill: var(--text); font-size: 8px; font-weight: 700; }

/* user quick links */
.dash-links { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; padding: 14px; }
.dash-link { display: flex; align-items: center; gap: 11px; padding: 13px 15px; border: 1px solid var(--border); border-radius: 11px; background: var(--panel2); color: var(--text); font-weight: 700; }
.dash-link:hover { border-color: var(--brand2); text-decoration: none; }
.dash-link-ic { font-size: 1.25rem; color: var(--muted); flex: 0 0 auto; }
.dash-link .cn { display: block; font-size: .62rem; color: var(--muted); font-weight: 500; margin-top: 1px; }

@media (max-width: 900px) { .dash-grid { grid-template-columns: 1fr; } }

/* AJAX list search — dim results region while fetching */
[data-ajax-results] { transition: opacity .12s ease; }
[data-ajax-results].is-loading { opacity: .45; pointer-events: none; }

/* ===================================================================== */
/* Printable reports (packing list, expense/bilty summary)               */
/* ===================================================================== */
.report-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin: 4px 0 16px; }
.report-meta { color: var(--muted); font-size: .88rem; line-height: 1.7; }
.report-meta b { color: var(--text); }
.print-btn { background: var(--panel); color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 8px 16px; font: inherit; font-weight: 600; cursor: pointer; }
.print-btn:hover { border-color: var(--brand2); }
.report-section-title { font-weight: 700; margin: 18px 0 6px; color: var(--heading); }
.grand { font-weight: 800; }
.mtable tfoot th, .mtable tfoot td { border-top: 2px solid var(--border); font-weight: 800; }

@media print {
  .devbar, .sidebar, .topbar, .foot, .no-print, .nav-backdrop { display: none !important; }
  .shell, .shell-main, .wrap { display: block !important; max-width: none !important; margin: 0 !important; padding: 0 !important; }
  body { background: #fff !important; color: #000 !important; }
  .report, .report * { color: #000 !important; }
  .pt-card, .mtable, .card { background: #fff !important; border-color: #999 !important; }
  .mtable th, .mtable td { border-color: #ccc !important; color: #000 !important; }
  a { color: #000 !important; text-decoration: none; }
  .wfovr, .muted { color: #555 !important; }
}

/* ===== HR attendance clock (self clock-in/out) ===== */
.vclock { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; margin: 0 0 16px;
  padding: 16px 20px; background: linear-gradient(145deg, var(--panel) 0%, var(--panel2) 100%);
  border: 1px solid var(--border); border-radius: 14px; }
.vclock-face { min-width: 150px; }
.vclock-time { font-size: 1.9rem; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: .04em; color: var(--heading); line-height: 1; }
.vclock-date { font-size: .78rem; color: var(--muted); margin-top: 4px; }
.vclock-status { display: flex; flex-direction: column; gap: 3px; flex: 1; min-width: 160px; }
.vclock-badge { font-weight: 700; font-size: .9rem; }
.vclock-badge.in { color: var(--ok); }
.vclock-badge.out { color: var(--muted); }
.vclock-badge.off { color: var(--tag-blue-fg); }
.vclock-since { font-size: .8rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.vclock-act button { border: 0; border-radius: 9px; padding: 11px 26px; font: inherit; font-weight: 700; cursor: pointer; }
.vclock-act .btn-primary { background: var(--ok); color: #05261a; }
.vclock-act .btn-danger { background: var(--bad); color: #2a0a0a; }
.vclock-act button:hover { filter: brightness(1.08); }
@media (max-width: 560px) { .vclock { gap: 12px; } .vclock-act { width: 100%; } .vclock-act button { width: 100%; } }

/* ===== Self-service leave (apply; HR decides) ===== */
.vleave { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; margin: 0 0 16px;
  padding: 12px 20px; background: var(--panel); border: 1px solid var(--border); border-radius: 14px; }
.vleave-face { display: flex; align-items: center; gap: 10px; min-width: 150px; color: var(--heading); }
.vleave-ic { font-size: 1.4rem; }
.vleave-face b { font-size: 1rem; display: block; }
.vleave-face .cn { font-size: .74rem; color: var(--muted); }
.vleave-status { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 160px; }
.vleave-badge { font-weight: 700; font-size: .9rem; }
.vleave-badge.wait { color: var(--hl-fg); }
.vleave-badge.ok { color: var(--ok); }
.vleave-badge.no { color: var(--bad); }
.vleave-badge.off { color: var(--muted); }
.vleave-note { font-size: .8rem; color: var(--muted); }
.vleave-act .btn-ghost { display: inline-block; padding: 9px 22px; font-weight: 700; }
@media (max-width: 560px) { .vleave { gap: 12px; } .vleave-act, .vleave-act .btn-ghost { width: 100%; text-align: center; } }

/* ---- Review & approve popup (stage 3) — reads as sections, colours from tokens
        so it follows whichever theme the account is on. ---- */
.rv-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 12px; }
.rv-chip { background: var(--panel2); border: 1px solid var(--border); border-radius: 999px;
           padding: 4px 11px; font-size: .78rem; color: var(--muted); white-space: nowrap; }
.rv-chip b { color: var(--text); font-weight: 700; margin-left: 3px; }
.rv-h { display: flex; align-items: center; gap: 8px; font-size: .95rem; margin: 18px 0 8px; }
.rv-n { display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px;
        border-radius: 50%; background: var(--brand); color: #fff; font-size: .72rem; font-weight: 700; flex: 0 0 auto; }
.rv-table { font-size: .82rem; }
.rv-table td, .rv-table th { white-space: nowrap; }
.rv-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
              margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--border); }
.rv-act-form { display: inline-flex; align-items: center; gap: 6px; margin: 0; }
.rv-act-back .wf-reason { min-width: 15rem; }
@media (max-width: 640px) {
  .rv-actions, .rv-act-form { width: 100%; }
  .rv-act-form .wfbtn { flex: 1 1 auto; }
  .rv-act-back .wf-reason { flex: 1 1 auto; min-width: 0; }
}

/* Packing list: the customer is what the person reading the sheet looks for first,
   so it carries the weight rather than sitting greyed out beside the reference.
   Kept dark on paper too — the print sheet is the copy that gets handed over. */
.report-section-title .pk-party { font-weight: 800; font-size: 1.05em;
                                  color: var(--hl-fg); background: var(--hl-bg);
                                  margin-left: 8px; padding: 2px 9px; border-radius: 5px;
                                  border-left: 3px solid var(--brand); }
/* On paper the tint prints as flat grey, so the highlight becomes a box instead —
   the packing list is handed over printed as often as it is read on screen. */
@media print {
  .report-section-title .pk-party { color: #000; background: transparent;
                                    border: 1.5px solid #000; border-left-width: 3px; }
}

/* Attendance clock: break state and today's total */
.vclock-badge.brk { background: var(--hl-bg); color: var(--hl-fg); }
.vclock-worked { display: block; margin-top: 4px; font-size: .82rem; color: var(--muted); }
.vclock-worked b { color: var(--text); }

/* Starting a break asks what it is for. Closed, the <summary> is the old "Start
   break" button and takes the same room; open, it becomes a small panel. The
   marker is removed on both the modern and the WebKit-only selector — one alone
   leaves a stray triangle in some browsers. */
.vclock-brk > summary { list-style: none; cursor: pointer; display: inline-block;
                        border: 1px solid var(--border); border-radius: 9px; padding: 11px 26px;
                        font-weight: 700; color: var(--text); background: transparent; }
.vclock-brk > summary::-webkit-details-marker { display: none; }
.vclock-brk > summary::marker { content: ''; }
.vclock-brk > summary:hover { background: var(--chip-hover); }
.vclock-brk[open] > summary { border-radius: 9px 9px 0 0; border-bottom-color: transparent; }
.vclock-brk[open] > form { border: 1px solid var(--border); border-radius: 0 9px 9px 9px;
                           background: var(--panel2); padding: 12px; margin-top: -1px; max-width: 340px; }
.vclock-brk-lbl { display: block; font-size: .8rem; font-weight: 700; color: var(--muted); margin-bottom: 5px; }
.vclock-brk-in { width: 100%; box-sizing: border-box; padding: 9px 11px; font: inherit;
                 color: var(--text); background: var(--panel); border: 1px solid var(--border); border-radius: 8px; }
.vclock-brk-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 9px 0 11px; }
.brkchip { border: 1px solid var(--border); background: transparent; color: var(--muted);
           border-radius: 999px; padding: 5px 12px; font: inherit; font-size: .8rem; cursor: pointer; }
.brkchip:hover { background: var(--chip-hover); color: var(--text); }
/* the panel's own submit sits full width so it is not mistaken for a chip */
.vclock-brk[open] > form > .btn-ghost { width: 100%; padding: 9px 0; }
@media (max-width: 560px) { .vclock-brk, .vclock-brk > summary,
                            .vclock-brk[open] > form { width: 100%; max-width: none; text-align: center; }
                            .vclock-brk-lbl, .vclock-brk-in { text-align: left; } }

/* Why the break was taken, under its total on HR's attendance sheet */
.brkwhy { display: block; white-space: normal; text-align: right;
          font-size: .74rem; line-height: 1.45; color: var(--muted); margin-top: 3px; }

/* Staff photo — on the employee record and wherever staff are listed */
.staffcard { display: flex; align-items: flex-start; gap: 16px; margin: 0 0 14px; flex-wrap: wrap; }
.staffphoto { width: 104px; height: 104px; border-radius: 12px; object-fit: cover;
              border: 1px solid var(--border); background: var(--panel2); display: block; }
.staffphoto-none { display: inline-flex; align-items: center; justify-content: center;
                   font-weight: 800; font-size: 2rem; color: #fff; background: var(--brand); }
.staffcard-act { font-size: .85rem; }
.pt-avatar img { width: 100%; height: 100%; border-radius: inherit; object-fit: cover; display: block; }

/* HR portal cards: the photo carries the recognition, so it is given real room —
   a rounded square rather than a small circle, because a portrait crops better
   that way — and the name is highlighted so a face and a name are what the eye
   lands on. Scoped to the HR card; the parties list keeps its small circle. */
.hr-emp-card .pt-avatar { width: 76px; height: 76px; border-radius: 12px; font-size: 1.6rem;
                          border: 1px solid var(--border); overflow: hidden; }
.hr-emp-card .pt-name { font-weight: 800; font-size: 1.02rem; color: var(--hl-fg);
                        background: var(--hl-bg); padding: 2px 9px; border-radius: 5px;
                        border-left: 3px solid var(--brand); line-height: 1.7;
                        /* a long name wraps; without this the highlight paints one
                           ragged block across both lines instead of hugging each */
                        -webkit-box-decoration-break: clone; box-decoration-break: clone; }
.hr-emp-card .pt-name:hover { text-decoration: none; filter: brightness(1.08); }
.hr-emp-top { gap: 14px; }
@media print {
  .hr-emp-card .pt-name { color: #000; background: transparent; border: 1.5px solid #000; border-left-width: 3px; }
}
