:root {
  --bg: #f4f6fa; --surface: #ffffff; --surface-2: #f8f9fc; --border: #e3e7ef; --border-strong: #cfd6e3;
  --text: #16213a; --text-2: #4a5775; --muted: #7b87a1;
  --primary: #1f3a8a; --primary-2: #2c4fb8; --primary-soft: #e8edfb;
  --accent: #0f766e;
  --ok: #15803d; --ok-soft: #e7f6ec; --warn: #b45309; --warn-soft: #fdf3e2; --bad: #b91c1c; --bad-soft: #fdecec; --info: #1d4ed8; --info-soft: #e7eefd;
  --grey-soft: #eef0f5;
  --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.08);
  --shadow-lg: 0 12px 32px rgba(16,24,40,.18);
  --radius: 10px; --radius-sm: 7px;
  --sidebar: 236px;
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); font: 14px/1.45 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--primary-2); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: 22px; } h2 { font-size: 17px; } h3 { font-size: 15px; } h4 { font-size: 13px; color: var(--text-2); text-transform: uppercase; letter-spacing: .04em; }
small, .small { font-size: 12px; }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.row.end { justify-content: flex-end; }
.col { display: flex; flex-direction: column; gap: 10px; }
.grow { flex: 1; min-width: 0; }
.gap-lg { gap: 18px; }
.mt { margin-top: 14px; } .mt-sm { margin-top: 8px; } .mb { margin-bottom: 14px; }

/* ---------- layout ---------- */
.app { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100vh; }
.sidebar { background: #111c3a; color: #cdd5ea; position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; }
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 18px 14px; color: #fff; }
.brand .logo { width: 34px; height: 34px; border-radius: 9px; background: linear-gradient(135deg,#3b5bdb,#12b886); display: grid; place-items: center; font-weight: 800; font-size: 13px; letter-spacing: .02em; }
.brand b { display: block; font-size: 15px; }
.brand span { font-size: 11px; color: #8d99ba; }
.nav { padding: 6px 10px; display: flex; flex-direction: column; gap: 2px; }
.nav .sec { font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em; color: #6f7ca0; padding: 14px 10px 6px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: #cdd5ea; font-weight: 500; text-decoration: none; }
.nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav a.active { background: #22306a; color: #fff; }
.nav a .ico { width: 18px; text-align: center; opacity: .9; }
.nav a .cnt { margin-left: auto; background: #3b5bdb; color: #fff; border-radius: 999px; font-size: 11px; padding: 1px 7px; font-weight: 600; }
.nav a .cnt.red { background: #e03131; }
.sidebar .me { margin-top: auto; padding: 14px 16px; border-top: 1px solid rgba(255,255,255,.08); font-size: 12.5px; }
.sidebar .me b { color: #fff; display: block; }
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 20; background: rgba(244,246,250,.92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 12px; padding: 10px 24px; }
.topbar .search { flex: 1; max-width: 520px; position: relative; }
.topbar .search input { width: 100%; padding-left: 34px; background: var(--surface); }
.topbar .search::before { content: '⌕'; position: absolute; left: 12px; top: 50%; transform: translateY(-52%); color: var(--muted); font-size: 16px; }
.icon-btn { position: relative; border: 1px solid var(--border); background: var(--surface); border-radius: 9px; height: 36px; min-width: 36px; display: inline-grid; place-items: center; cursor: pointer; font-size: 16px; color: var(--text-2); padding: 0 9px; }
.icon-btn:hover { border-color: var(--border-strong); }
.icon-btn .dot { position: absolute; top: -5px; right: -5px; background: #e03131; color: #fff; font-size: 10.5px; font-weight: 700; border-radius: 999px; padding: 1px 5px; min-width: 18px; text-align: center; }
.live { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.live i { width: 8px; height: 8px; border-radius: 50%; background: #adb5bd; display: inline-block; }
.live.on i { background: #2f9e44; box-shadow: 0 0 0 3px rgba(47,158,68,.18); }
.content { padding: 22px 24px 60px; max-width: 1500px; width: 100%; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head p { margin: 4px 0 0; color: var(--text-2); }
.hamburger { display: none; }

/* ---------- cards ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 16px 18px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.card-body { padding: 16px 18px; }
.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.kpi { padding: 14px 16px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); cursor: pointer; transition: transform .08s; }
.kpi:hover { transform: translateY(-1px); border-color: var(--border-strong); }
.kpi .v { font-size: 26px; font-weight: 700; letter-spacing: -.02em; margin-top: 2px; }
.kpi .l { font-size: 12px; color: var(--text-2); font-weight: 500; }
.kpi .s { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.kpi.bad { border-left: 4px solid var(--bad); } .kpi.bad .v { color: var(--bad); }
.kpi.warn { border-left: 4px solid var(--warn); } .kpi.warn .v { color: var(--warn); }
.kpi.ok { border-left: 4px solid var(--ok); }
.kpi.info { border-left: 4px solid var(--info); }

/* ---------- buttons & inputs ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); padding: 7px 13px; border-radius: 8px; font: 500 13.5px var(--font); cursor: pointer; white-space: nowrap; text-decoration: none !important; }
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-2); }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.bad { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.warn { background: #d97706; border-color: #d97706; color: #fff; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--grey-soft); }
.btn.sm { padding: 4px 9px; font-size: 12.5px; border-radius: 7px; }
.btn.lg { padding: 10px 18px; font-size: 14.5px; }
input, select, textarea { font: 14px var(--font); color: var(--text); border: 1px solid var(--border-strong); border-radius: 8px; padding: 7px 10px; background: #fff; width: 100%; min-width: 0; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary-2); box-shadow: 0 0 0 3px rgba(44,79,184,.14); }
input:disabled, select:disabled, textarea:disabled { background: var(--surface-2); color: var(--text-2); }
input[type=checkbox] { width: 17px; height: 17px; accent-color: var(--primary); }
textarea { min-height: 70px; resize: vertical; }
label.f { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; font-weight: 550; color: var(--text-2); }
label.f .req { color: var(--bad); }
label.chk { display: flex; align-items: center; gap: 8px; font-size: 13.5px; font-weight: 500; color: var(--text); padding: 6px 0; cursor: pointer; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px 14px; }
.form-grid .wide { grid-column: 1 / -1; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.filters select, .filters input { width: auto; min-width: 130px; }
.seg { display: inline-flex; border: 1px solid var(--border-strong); border-radius: 9px; overflow: hidden; background: var(--surface); }
.seg button { border: 0; background: transparent; padding: 7px 13px; font: 500 13px var(--font); cursor: pointer; color: var(--text-2); border-right: 1px solid var(--border); }
.seg button:last-child { border-right: 0; }
.seg button.on { background: var(--primary); color: #fff; }
.seg button .n { font-size: 11px; background: rgba(0,0,0,.08); border-radius: 99px; padding: 0 6px; margin-left: 4px; }
.seg button.on .n { background: rgba(255,255,255,.22); }

/* ---------- chips & badges ---------- */
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 600; background: var(--grey-soft); color: var(--text-2); white-space: nowrap; line-height: 1.6; }
.chip.ok { background: var(--ok-soft); color: var(--ok); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.bad { background: var(--bad-soft); color: var(--bad); }
.chip.info { background: var(--info-soft); color: var(--info); }
.chip.dark { background: #1f2a4a; color: #fff; }
.chip.outline { background: transparent; border: 1px solid var(--border-strong); }
.dp { display: inline-flex; flex-direction: column; align-items: flex-start; padding: 3px 9px; border-radius: 8px; font-weight: 700; font-size: 12px; line-height: 1.25; white-space: nowrap; }
.dp small { font-weight: 500; font-size: 10.5px; opacity: .85; }
.dp.ok { background: var(--ok-soft); color: var(--ok); }
.dp.warn { background: var(--warn-soft); color: var(--warn); }
.dp.crit { background: #ffe3e3; color: #c92a2a; }
.dp.bad { background: #c92a2a; color: #fff; }
.dp.na { background: var(--grey-soft); color: var(--muted); font-weight: 600; }
.prio-Critical { color: #c92a2a; font-weight: 700; } .prio-High { color: #d9480f; font-weight: 650; } .prio-Medium { color: var(--text-2); } .prio-Low { color: var(--muted); }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; font-size: 13px; }
table.t th { text-align: left; font-weight: 600; font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 9px 12px; border-bottom: 1px solid var(--border); background: var(--surface-2); white-space: nowrap; position: sticky; top: 0; }
table.t td { padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
table.t tr:last-child td { border-bottom: 0; }
table.t tr.click { cursor: pointer; }
table.t tr.click:hover td { background: #f6f8fd; }
table.t td.num, table.t th.num { text-align: right; white-space: nowrap; }
.empty { padding: 36px 16px; text-align: center; color: var(--muted); }
.empty b { display: block; color: var(--text-2); font-size: 15px; margin-bottom: 4px; }
.pager { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; border-top: 1px solid var(--border); font-size: 12.5px; color: var(--muted); }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; }
.tabs button { border: 0; background: transparent; padding: 10px 14px; font: 550 13.5px var(--font); color: var(--text-2); cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs button:hover { color: var(--text); }
.tabs button.on { color: var(--primary); border-bottom-color: var(--primary); }
.tabs button .n { font-size: 11px; background: var(--grey-soft); border-radius: 99px; padding: 0 6px; margin-left: 4px; color: var(--text-2); }

/* ---------- order page ---------- */
.order-head { display: grid; grid-template-columns: 1fr auto; gap: 16px; align-items: start; }
.order-head .id { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; color: var(--primary); font-weight: 700; }
.order-head h1 { font-size: 20px; margin: 3px 0 6px; }
.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px 18px; margin-top: 14px; }
.facts div span { display: block; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
.facts div b { font-weight: 600; font-size: 13.5px; }
.dp-big { text-align: center; border-radius: 12px; padding: 12px 18px; min-width: 150px; }
.dp-big .n { font-size: 30px; font-weight: 800; letter-spacing: -.03em; line-height: 1; }
.dp-big .l { font-size: 12px; font-weight: 600; margin-top: 4px; }
.dp-big .d { font-size: 11.5px; opacity: .8; margin-top: 2px; }
.dp-big.ok { background: var(--ok-soft); color: var(--ok); }
.dp-big.warn { background: var(--warn-soft); color: var(--warn); }
.dp-big.crit { background: #ffe3e3; color: #c92a2a; }
.dp-big.bad { background: #c92a2a; color: #fff; }
.dp-big.na { background: var(--grey-soft); color: var(--text-2); }
.tracker { display: flex; gap: 4px; overflow-x: auto; padding: 4px 2px 8px; scrollbar-width: thin; }
.tracker button { flex: 0 0 auto; border: 1px solid var(--border); background: var(--surface); border-radius: 8px; padding: 6px 9px; cursor: pointer; text-align: left; min-width: 86px; font: 12px var(--font); color: var(--text-2); }
.tracker button b { display: block; font-size: 10.5px; color: var(--muted); font-weight: 700; }
.tracker button.s-approved { background: var(--ok-soft); border-color: #b2e0c1; color: var(--ok); }
.tracker button.s-active, .tracker button.s-in_progress { background: var(--info-soft); border-color: #b9ccf7; color: var(--info); font-weight: 600; }
.tracker button.s-submitted { background: #f3e8ff; border-color: #dcc3fb; color: #7e22ce; font-weight: 600; }
.tracker button.s-returned, .tracker button.s-on_hold { background: var(--warn-soft); border-color: #f5d49b; color: var(--warn); font-weight: 600; }
.tracker button.s-rejected { background: var(--bad-soft); border-color: #f3b4b4; color: var(--bad); }
.tracker button.sel { outline: 2px solid var(--primary); outline-offset: 1px; }
.stage-layout { display: grid; grid-template-columns: 270px 1fr; gap: 16px; align-items: start; }
.stage-list { display: flex; flex-direction: column; gap: 3px; max-height: 75vh; overflow-y: auto; position: sticky; top: 70px; }
.stage-list button { display: grid; grid-template-columns: 26px 1fr auto; gap: 8px; align-items: center; border: 1px solid transparent; background: transparent; border-radius: 8px; padding: 7px 8px; text-align: left; cursor: pointer; font: 13px var(--font); color: var(--text); }
.stage-list button:hover { background: var(--surface-2); }
.stage-list button.sel { background: var(--primary-soft); border-color: #c5d1f5; }
.stage-list .num { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 11.5px; background: var(--grey-soft); color: var(--muted); }
.stage-list .num.approved { background: var(--ok); color: #fff; }
.stage-list .num.active, .stage-list .num.in_progress { background: var(--info); color: #fff; }
.stage-list .num.submitted { background: #7e22ce; color: #fff; }
.stage-list .num.returned, .stage-list .num.on_hold { background: #d97706; color: #fff; }
.stage-list .num.rejected { background: var(--bad); color: #fff; }
.stage-list .who { font-size: 11px; color: var(--muted); display: block; }
.st-status { font-size: 11px; }
.banner { border-radius: 9px; padding: 10px 14px; font-size: 13px; display: flex; gap: 10px; align-items: flex-start; }
.banner.bad { background: var(--bad-soft); color: #8a1c1c; border: 1px solid #f3c1c1; }
.banner.warn { background: var(--warn-soft); color: #7a4a06; border: 1px solid #f3d6a4; }
.banner.info { background: var(--info-soft); color: #1e3a8a; border: 1px solid #c9d7fb; }
.banner.ok { background: var(--ok-soft); color: #14532d; border: 1px solid #bfe5cc; }
.banner b { font-weight: 700; }
.checklist { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.checklist li::before { content: '✕'; color: var(--bad); font-weight: 800; margin-right: 8px; }
.checklist.ok li::before { content: '✓'; color: var(--ok); }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: grid; grid-template-columns: 112px 14px 1fr; gap: 10px; padding: 0 0 14px; position: relative; }
.timeline li .when { font-size: 11.5px; color: var(--muted); text-align: right; line-height: 1.35; }
.timeline li .when b { display: block; color: var(--text-2); font-weight: 600; }
.timeline li .dotc { position: relative; }
.timeline li .dotc::before { content: ''; position: absolute; left: 3px; top: 5px; width: 9px; height: 9px; border-radius: 50%; background: var(--primary-2); }
.timeline li .dotc::after { content: ''; position: absolute; left: 7px; top: 16px; bottom: -14px; width: 1px; background: var(--border-strong); }
.timeline li:last-child .dotc::after { display: none; }
.timeline li .what b { font-weight: 650; }
.timeline li .what .meta { font-size: 11.5px; color: var(--muted); }

/* ---------- lists ---------- */
.list-item { display: flex; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--border); align-items: flex-start; }
.list-item:last-child { border-bottom: 0; }
.list-item.unread { background: #f5f8ff; }
.list-item .ic { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; background: var(--grey-soft); flex: 0 0 auto; font-size: 15px; }
.list-item .ic.bad { background: var(--bad-soft); } .list-item .ic.warn { background: var(--warn-soft); } .list-item .ic.ok { background: var(--ok-soft); } .list-item .ic.info { background: var(--info-soft); }
.action-card { display: grid; grid-template-columns: 1fr auto; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.action-card:last-child { border-bottom: 0; }
.action-card.overdue { border-left: 4px solid var(--bad); }
.action-card.returned { border-left: 4px solid #d97706; }
.action-card .t { font-weight: 650; font-size: 14px; }
.action-card .sub { color: var(--text-2); font-size: 12.5px; margin-top: 2px; }
.bar { height: 8px; background: var(--grey-soft); border-radius: 99px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--primary-2); border-radius: 99px; }
.stage-bars { display: flex; flex-direction: column; gap: 7px; }
.stage-bars .r { display: grid; grid-template-columns: 170px 1fr 36px; gap: 10px; align-items: center; font-size: 12.5px; cursor: pointer; }
.stage-bars .r:hover b { text-decoration: underline; }

/* ---------- overlays ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(15,23,42,.5); z-index: 100; display: grid; place-items: center; padding: 20px; animation: fade .12s; }
.modal { background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-lg); width: 100%; max-width: 560px; max-height: 90vh; display: flex; flex-direction: column; }
.modal.wide { max-width: 920px; }
.modal .mh { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.modal .mb { padding: 18px 20px; overflow-y: auto; }
.modal .mf { padding: 12px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }
.toasts { position: fixed; right: 18px; bottom: 18px; z-index: 200; display: flex; flex-direction: column; gap: 8px; max-width: 380px; }
.toast { background: #1f2a4a; color: #fff; padding: 11px 14px; border-radius: 10px; box-shadow: var(--shadow-lg); font-size: 13px; animation: pop .15s; cursor: pointer; }
.toast b { display: block; }
.toast.bad { background: #b91c1c; } .toast.ok { background: #166534; } .toast.warn { background: #92400e; }
.dropdown { position: absolute; right: 0; top: 44px; width: 400px; max-width: calc(100vw - 24px); background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg); z-index: 60; max-height: 70vh; overflow-y: auto; }

/* ---------- login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: radial-gradient(1200px 600px at 20% -10%, #2c4fb8 0%, transparent 60%), radial-gradient(900px 500px at 110% 110%, #0f766e 0%, transparent 55%), #0f1a38; }
.login { width: 100%; max-width: 400px; background: #fff; border-radius: 16px; padding: 30px; box-shadow: 0 30px 60px rgba(0,0,0,.35); }
.login .brand { padding: 0 0 18px; color: var(--text); }
.login .brand span { color: var(--muted); }
.err { color: var(--bad); font-size: 13px; min-height: 18px; }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .stage-layout { grid-template-columns: 1fr; }
  .stage-list { position: static; max-height: none; flex-direction: row; overflow-x: auto; }
  .stage-list button { min-width: 190px; }
  .g4 { grid-template-columns: repeat(2, minmax(0,1fr)); }
}
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 260px; z-index: 90; transform: translateX(-100%); transition: transform .18s; }
  .app.nav-open .sidebar { transform: none; box-shadow: var(--shadow-lg); }
  .hamburger { display: inline-grid; }
  .topbar { padding: 8px 12px; }
  .content { padding: 16px 14px 60px; }
  .g2, .g3, .g4 { grid-template-columns: 1fr; }
  .order-head { grid-template-columns: 1fr; }
  .live span { display: none; }
  .stage-bars .r { grid-template-columns: 120px 1fr 30px; }
  .timeline li { grid-template-columns: 80px 14px 1fr; }
}
@media print { .sidebar, .topbar, .no-print { display: none !important; } .app { display: block; } }

/* ---------------- chat */
.chatbox { display: flex; flex-direction: column; height: 520px; min-height: 320px; }
.chat-msgs { flex: 1; overflow-y: auto; padding: 14px 16px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); }
.chat-day { text-align: center; margin: 12px 0 8px; }
.chat-msg { display: flex; gap: 10px; margin-top: 10px; align-items: flex-start; }
.chat-msg.grouped { margin-top: 3px; }
.chat-msg .av, .av.sm { width: 32px; height: 32px; border-radius: 50%; color: #fff; font-size: 12px; font-weight: 700; display: grid; place-items: center; flex: none; }
.chat-msg.grouped .av { visibility: hidden; height: 0; }
.av.sm { width: 26px; height: 26px; font-size: 11px; }
.bubble-wrap { min-width: 0; max-width: min(720px, 85%); }
.chat-msg .who { font-size: 12.5px; margin-bottom: 2px; } .chat-msg .who span { color: var(--muted); margin-left: 8px; font-size: 11.5px; }
.bubble { position: relative; background: var(--surface); border: 1px solid var(--border); padding: 7px 11px; border-radius: 4px 12px 12px 12px; word-wrap: break-word; overflow-wrap: anywhere; }
.chat-msg.mine .bubble { background: #eef3ff; border-color: #d5def8; }
.chat-msg.tagged .bubble { background: #fff8e1; border-color: #f2d27a; }
.bubble .del { display: none; position: absolute; top: -9px; right: -9px; width: 20px; height: 20px; border-radius: 50%; border: 1px solid var(--border-strong); background: #fff; color: var(--muted); font-size: 10px; cursor: pointer; padding: 0; }
.bubble:hover .del { display: block; }
.mention { color: var(--primary-2); font-weight: 600; background: var(--primary-soft); border-radius: 4px; padding: 0 3px; }
.mention.me { background: #fde68a; color: #7c4a03; }
.chat-compose { position: relative; display: flex; gap: 8px; align-items: flex-end; padding: 10px 0 4px; }
.chat-compose textarea { flex: 1; resize: none; min-height: 40px; max-height: 160px; font: inherit; padding: 9px 12px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); }
.chat-compose textarea:focus { outline: 2px solid var(--primary-soft); border-color: var(--primary-2); }
.chat-hint { padding: 0 2px 4px; } .chat-main .chat-hint { padding: 0 14px 10px; }
.mention-pop { position: absolute; bottom: calc(100% + 4px); left: 0; width: min(360px, 100%); background: #fff; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); z-index: 20; overflow: hidden; }
.mention-pop .opt { display: flex; gap: 9px; align-items: center; padding: 7px 10px; cursor: pointer; }
.mention-pop .opt.on, .mention-pop .opt:hover { background: var(--primary-soft); }
.mention-stack { position: fixed; right: 18px; top: 70px; z-index: 220; display: flex; flex-direction: column; gap: 10px; width: min(380px, calc(100vw - 32px)); }
.mention-card { background: #fff; border: 1px solid #f2d27a; border-left: 5px solid #f59e0b; border-radius: 10px; box-shadow: var(--shadow-lg); animation: pop .2s; overflow: hidden; }
.mention-card .mc-head { display: flex; justify-content: space-between; gap: 8px; padding: 10px 14px 4px; font-weight: 650; }
.mention-card .x { border: 0; background: none; cursor: pointer; color: var(--muted); font-size: 14px; }
.mention-card .mc-body { padding: 2px 14px 6px; white-space: pre-wrap; max-height: 140px; overflow: auto; }
.mention-card .mc-actions { display: flex; gap: 6px; padding: 0 14px 12px; }
@media (max-width: 860px) { .mention-stack { top: auto; bottom: 16px; right: 16px; left: 16px; width: auto; } }

.tag-btn { font-weight: 700; white-space: nowrap; }
.send-btn { white-space: nowrap; }
.mention-pop { max-height: 280px; overflow-y: auto; }
@media (max-width: 860px) {
  .chat-compose textarea { font-size: 16px; }
  .tag-btn, .send-btn { padding-left: 10px; padding-right: 10px; }
}

.mention-card { max-width: 100%; box-sizing: border-box; }
.mention-card .mc-head span, .mention-card .mc-body { overflow-wrap: anywhere; min-width: 0; }
@media (max-width: 860px) { .mention-stack { left: 12px; right: 12px; bottom: 12px; max-height: 70vh; } }
.mention-stack > * { flex: none; }
@media (max-width: 860px) { .mention-stack { overflow-y: auto; } }
/* phones: never let a wide table make the whole page wider than the screen */
.main, .content, .card { min-width: 0; }
@media (max-width: 860px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .g2, .g3, .g4 { grid-template-columns: minmax(0, 1fr); }
  .table-wrap { overflow-x: auto; }
}
@media (max-width: 860px) { .modal, .modal.wide { width: auto; max-width: calc(100vw - 20px); } }

/* ---------- OMS v2 additions ---------- */
.missing { color: var(--muted); font-style: italic; font-size: 12.5px; }
.chip.purple { background: #f3e8ff; color: #7e22ce; }
.tracker button.s-completed, .tracker button.s-skipped { background: var(--ok-soft); border-color: #b2e0c1; color: var(--ok); }
.tracker button.s-assigned, .tracker button.s-pending { background: var(--info-soft); border-color: #b9ccf7; color: var(--info); font-weight: 600; }
.tracker button.s-sent_back, .tracker button.s-waiting_info { background: var(--warn-soft); border-color: #f5d49b; color: var(--warn); font-weight: 600; }
.stage-list .num.completed, .stage-list .num.skipped { background: var(--ok); color: #fff; }
.stage-list .num.assigned, .stage-list .num.pending { background: var(--info); color: #fff; }
.stage-list .num.sent_back, .stage-list .num.waiting_info { background: #d97706; color: #fff; }
.doc-row { display: flex; gap: 10px; align-items: center; padding: 9px 12px; border-bottom: 1px solid var(--border); }
.doc-row:last-child { border-bottom: 0; }
.login .tabs { margin-bottom: 14px; }
.spinner { width: 22px; height: 22px; border: 3px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin .8s linear infinite; margin: 30px auto; }
@keyframes spin { to { transform: rotate(360deg); } }
.kv-list { display: grid; grid-template-columns: 180px 1fr; gap: 6px 14px; font-size: 13px; }
.kv-list > span:nth-child(odd) { color: var(--muted); }
.card-foot { padding: 12px 18px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--radius) var(--radius); }
.banner.purple { background: #f6efff; color: #5b1a99; border: 1px solid #e2cdfb; }
.banner ul.checklist li { margin: 2px 0; }
.card-body h4 { margin-bottom: 8px; }
.split { display: grid; grid-template-columns: minmax(300px, 420px) 1fr; gap: 14px; align-items: start; }
@media (max-width: 900px) { .split { grid-template-columns: 1fr; } }
.chat-side button { display: flex; width: 100%; text-align: left; gap: 8px; align-items: center; border: 0; background: none; padding: 8px 12px; cursor: pointer; font: inherit; border-radius: 7px; }
.chat-side button:hover { background: var(--surface-2); }
.chat-side button.sel { background: var(--primary-soft); }
.chat-side .unread { margin-left: auto; background: var(--bad); color: #fff; border-radius: 10px; font-size: 11px; padding: 1px 7px; }
.notif-row.unread { background: #f5f8ff; }
.notif-row.unread b::before { content: '● '; color: var(--primary-2); }
.chat-day span { background: var(--grey-soft); color: var(--text-2); font-size: 11.5px; font-weight: 600; padding: 2px 10px; border-radius: 999px; }
.perm-grid { display: flex; flex-direction: column; }
.action-card.sel { background: var(--primary-soft); box-shadow: inset 3px 0 0 var(--primary); }
.avatar { width: 34px; height: 34px; border-radius: 50%; color: #fff; font-weight: 700; font-size: 12px; display: grid; place-items: center; flex: none; }
.chat-split { grid-template-columns: 280px 1fr; }
@media (max-width: 900px) { .chat-split { grid-template-columns: 1fr; } .chat-split .chat-side { max-height: 220px; overflow-y: auto; } .chatbox { height: 60vh; } }
.tabs a { text-decoration: none !important; }
.kv-list { overflow-wrap: anywhere; }
@media (max-width: 600px) { .kv-list { grid-template-columns: 1fr; gap: 2px; } .kv-list > span:nth-child(odd) { margin-top: 6px; font-size: 11.5px; } .page-head h1 { font-size: 19px; } .split { grid-template-columns: minmax(0,1fr); } }
