/* TexOS360 · blue & white design system (blue shades follow the company colour) */
:root {
  --b950: #071a45; --b900: #0b2a6f; --b800: #12379a; --b700: #1d4ed8; --b600: #2563eb; --b500: #3b82f6; --b400: #60a5fa;
  --b200: #bfdbfe; --b100: #dbeafe; --b50: #eff6ff;
  --bg: #f4f7fd; --surface: #ffffff; --surface-2: #f8fafc; --text: #0f172a; --text-2: #334155; --muted: #64748b; --faint: #94a3b8;
  --border: #e2e8f0; --border-2: #cbd5e1;
  --green: #059669; --green-bg: #ecfdf5; --amber: #b45309; --amber-bg: #fffbeb; --red: #dc2626; --red-bg: #fef2f2;
  --purple: #7c3aed; --purple-bg: #f5f3ff; --indigo: #4f46e5; --indigo-bg: #eef2ff; --gray-bg: #f1f5f9;
  --radius: 12px; --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .06);
  --shadow: 0 1px 3px rgba(15, 23, 42, .06), 0 6px 16px -4px rgba(15, 23, 42, .08);
  --shadow-lg: 0 24px 48px -12px rgba(11, 42, 111, .28);
  --sidebar: 264px;
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: var(--font); font-size: 14px; line-height: 1.45; color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: var(--b700); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4 { margin: 0; letter-spacing: -.01em; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
:focus-visible { outline: 2px solid var(--b500); outline-offset: 2px; }

/* ---------- boot ---------- */
.boot { min-height: 100vh; display: flex; flex-direction: column; gap: 20px; align-items: center; justify-content: center; }
.boot .brand-mark { width: 56px; height: 56px; }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--b100); border-top-color: var(--b700); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- login ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1.05fr 1fr; background: #fff; }
.auth-brand { position: relative; overflow: hidden; color: #fff; padding: 48px 56px; display: flex; flex-direction: column; justify-content: space-between;
  background: radial-gradient(1200px 600px at -10% -20%, var(--b500) 0%, transparent 55%), radial-gradient(900px 500px at 110% 120%, var(--b400) 0%, transparent 50%), linear-gradient(150deg, var(--b900) 0%, var(--b800) 45%, var(--b700) 100%); }
.auth-brand::after { content: ''; position: absolute; inset: 0; background-image: repeating-linear-gradient(45deg, rgba(255,255,255,.04) 0 2px, transparent 2px 14px), repeating-linear-gradient(-45deg, rgba(255,255,255,.03) 0 2px, transparent 2px 14px); pointer-events: none; }
.auth-brand > * { position: relative; z-index: 1; }
.brand-row { display: flex; align-items: center; gap: 14px; }
.brand-row img, .brand-row .brand-mark { width: 48px; height: 48px; border-radius: 12px; display: block; flex: none; object-fit: contain; }
.brand-row img { background: #fff; }
.brand-row img.brand-mark, .sidebar .brand img.brand-mark, .boot img.brand-mark, .pr-head img.brand-mark { background: none; box-shadow: none; }
.brand-name { font-weight: 800; font-size: 22px; letter-spacing: -.02em; }
.brand-sub { font-size: 13px; opacity: .8; }
.auth-hero h1 { font-size: 40px; line-height: 1.1; font-weight: 800; letter-spacing: -.03em; max-width: 520px; }
.auth-hero p { font-size: 16px; opacity: .85; max-width: 480px; margin: 16px 0 28px; }
.auth-points { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 24px; max-width: 520px; }
.auth-points div { display: flex; gap: 10px; align-items: center; font-size: 14px; opacity: .95; }
.auth-points svg { flex: none; width: 18px; height: 18px; color: var(--b200); }
.auth-foot { font-size: 12px; opacity: .7; }
.auth-form-wrap { display: flex; align-items: center; justify-content: center; padding: 40px 24px; }
.auth-card { width: 100%; max-width: 400px; }
.auth-card h2 { font-size: 26px; font-weight: 800; }
.auth-card .lead { color: var(--muted); margin: 6px 0 28px; }
.auth-card .field { margin-bottom: 16px; }
.auth-card .btn { width: 100%; justify-content: center; height: 44px; font-size: 15px; }
.pay-card { max-width: 440px; }
.pay-card .lead { margin-bottom: 20px; }
.pay-plan { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; padding: 14px 16px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2, #f8fafc); }
.pay-plan span { flex: 1; font-weight: 600; }
.pay-plan b { font-size: 20px; font-weight: 800; }
.pay-plan small { color: var(--muted); }
.pay-bank { margin-top: 12px; padding: 14px 16px; border: 1px solid var(--border); border-radius: 12px; }
.pay-bank pre { margin-top: 6px; font: inherit; font-size: 14px; white-space: pre-wrap; color: var(--text-2, inherit); }
.pay-help { margin: 16px 0 10px; font-size: 14px; color: var(--muted); }
.pay-contacts { display: grid; gap: 6px; margin-bottom: 20px; font-size: 14px; }
.pay-contacts a { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; }
.pay-contacts svg { width: 16px; height: 16px; }
.auth-secure { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; margin-top: 22px; }
.auth-secure svg { width: 16px; height: 16px; color: var(--green); }
.pw-wrap { position: relative; }
.pw-wrap .input { padding-right: 44px; }
.pw-toggle { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); border: 0; background: none; color: var(--muted); padding: 6px; cursor: pointer; border-radius: 6px; }
.pw-toggle:hover { background: var(--gray-bg); color: var(--text-2); }
.pw-toggle { width: 34px; height: 34px; display: flex; align-items: center; justify-content: center; padding: 0; }
.pw-toggle svg { width: 19px; height: 19px; display: block; flex: none; }
.pw-rules { list-style: none; padding: 0; margin: 8px 0 0; display: grid; gap: 4px; font-size: 12px; color: var(--muted); }
.pw-rules li.ok { color: var(--green); }
.pw-rules li::before { content: '○ '; }
.pw-rules li.ok::before { content: '✓ '; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; overflow-y: auto; color: rgba(255,255,255,.86); background: linear-gradient(180deg, var(--b900) 0%, var(--b800) 100%); display: flex; flex-direction: column; scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.2) transparent; }
.sidebar .brand { display: flex; align-items: center; gap: 12px; padding: 20px 20px 18px; color: #fff; border-bottom: 1px solid rgba(255,255,255,.08); }
.sidebar .brand > div { min-width: 0; }
.sidebar .brand img, .sidebar .brand .brand-mark { width: 38px; height: 38px; border-radius: 10px; display: block; flex: none; object-fit: contain; }
.sidebar .brand img { background: #fff; }
.sidebar .brand b { display: block; font-size: 16px; font-weight: 800; letter-spacing: -.01em; }
.sidebar .brand small { display: block; font-size: 11px; line-height: 1.35; color: rgba(255,255,255,.62); letter-spacing: .04em; text-transform: uppercase; }
.nav { padding: 10px 10px 24px; flex: 1; }
.nav-group { margin-top: 6px; }
.nav-group > button { all: unset; box-sizing: border-box; width: 100%; display: flex; align-items: center; justify-content: space-between; cursor: pointer; padding: 10px 12px 6px; font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: rgba(255,255,255,.55); }
.nav-group > button svg { width: 14px; height: 14px; transition: transform .2s; }
.nav-group.collapsed > button svg { transform: rotate(-90deg); }
.nav-group.collapsed .nav-items { display: none; }
.nav a { display: flex; align-items: center; gap: 11px; padding: 8px 12px; margin: 1px 0; border-radius: 9px; color: rgba(255,255,255,.86); font-weight: 500; font-size: 13.5px; text-decoration: none; transition: background .15s, color .15s; }
.nav a svg { width: 18px; height: 18px; flex: none; opacity: .85; }
.nav a:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav a.active { background: #fff; color: var(--b800); font-weight: 600; box-shadow: 0 4px 14px rgba(0,0,0,.18); }
.nav a.active svg { opacity: 1; color: var(--b700); }
.nav .badge { margin-left: auto; background: #f43f5e; color: #fff; font-size: 11px; font-weight: 700; border-radius: 999px; padding: 1px 7px; min-width: 20px; text-align: center; }
.nav a.active .badge { background: var(--b700); }
.sidebar .side-foot { padding: 14px 20px; font-size: 11px; color: rgba(255,255,255,.55); border-top: 1px solid rgba(255,255,255,.08); }
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 30; height: 64px; background: rgba(255,255,255,.92); backdrop-filter: blur(10px); border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 12px; padding: 0 24px; }
.topbar .menu-btn { display: none; }
.gsearch { position: relative; flex: 1; max-width: 460px; }
.gsearch .input { padding-left: 38px; background: var(--surface-2); border-color: transparent; height: 40px; }
.gsearch .input:focus { background: #fff; border-color: var(--b400); }
.gsearch > svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 17px; height: 17px; color: var(--faint); }
.gsearch-results { position: absolute; top: 46px; left: 0; right: 0; background: #fff; border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); max-height: 420px; overflow: auto; padding: 6px; }
.gsearch-results .grp { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; padding: 8px 10px 4px; }
.gsearch-results a { display: block; padding: 8px 10px; border-radius: 8px; color: var(--text); }
.gsearch-results a:hover, .gsearch-results a.hl { background: var(--b50); text-decoration: none; }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.top-clock { display: flex; align-items: center; gap: 8px; height: 40px; padding: 0 12px; margin-right: 4px; border-radius: 10px; background: var(--b50); border: 1px solid var(--b100); color: var(--b900); white-space: nowrap; user-select: none; }
.top-clock > svg { width: 18px; height: 18px; color: var(--b600); flex: none; }
.top-clock > div { display: flex; flex-direction: column; line-height: 1.15; }
.top-clock .tc-time { font-size: 14px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: .01em; }
.top-clock .tc-date { font-size: 11px; color: var(--muted); }
@media (max-width: 900px) { .top-clock .tc-date { display: none; } }
@media (max-width: 640px) { .top-clock { padding: 0 8px; gap: 6px; margin-right: 0; } .top-clock > svg { display: none; } .top-clock .tc-time { font-size: 13px; } }
.icon-btn { position: relative; width: 40px; height: 40px; display: inline-flex; align-items: center; justify-content: center; border: 0; background: transparent; color: var(--text-2); border-radius: 10px; cursor: pointer; }
.icon-btn:hover { background: var(--gray-bg); }
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn .dot { position: absolute; top: 6px; right: 6px; background: #f43f5e; color: #fff; font-size: 10px; font-weight: 700; border-radius: 999px; min-width: 17px; height: 17px; padding: 0 4px; display: flex; align-items: center; justify-content: center; border: 2px solid #fff; }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 4px 10px 4px 4px; border-radius: 999px; border: 1px solid var(--border); background: #fff; cursor: pointer; }
.user-chip:hover { border-color: var(--b200); background: var(--b50); }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: linear-gradient(135deg, var(--b500), var(--b800)); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 12px; flex: none; }
.user-chip .who { line-height: 1.15; }
.user-chip .who b { display: block; font-size: 13px; }
.user-chip .who small { color: var(--muted); font-size: 11px; }
.content { padding: 24px; max-width: 1600px; width: 100%; margin: 0 auto; }
.pay-banner { display: flex; align-items: center; gap: 10px; padding: 10px 24px; background: var(--amber-bg); color: var(--amber); border-bottom: 1px solid var(--border); font-size: 13.5px; }
.pay-banner svg { width: 16px; height: 16px; flex: none; }
.brand-logo-preview { width: 96px; height: 96px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: #fff; display: grid; place-items: center; overflow: hidden; }
.brand-logo-preview img, .brand-logo-preview .brand-mark { max-width: 100%; max-height: 100%; object-fit: contain; width: 72px; height: 72px; display: block; }

/* ---------- dropdown / popover ---------- */
.popover { position: absolute; right: 0; top: 48px; background: #fff; border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); z-index: 50; min-width: 220px; overflow: hidden; }
.popover .pop-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; border-bottom: 1px solid var(--border); font-weight: 700; }
.popover .menu-item { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; padding: 10px 14px; border: 0; background: none; cursor: pointer; color: var(--text); }
.popover .menu-item:hover { background: var(--b50); text-decoration: none; }
.popover .menu-item svg { width: 17px; height: 17px; color: var(--muted); }
.notif-list { width: 380px; max-width: calc(100vw - 32px); max-height: 440px; overflow: auto; }
.notif { display: flex; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--border); cursor: pointer; color: var(--text); }
.notif:hover { background: var(--surface-2); text-decoration: none; }
.notif.unread { background: var(--b50); }
.notif .n-ic { width: 32px; height: 32px; border-radius: 9px; background: var(--b100); color: var(--b700); display: flex; align-items: center; justify-content: center; flex: none; }
.notif .n-ic svg { width: 16px; height: 16px; }
.notif b { display: block; font-size: 13px; font-weight: 600; }
.notif small { color: var(--muted); font-size: 12px; }

/* ---------- page header ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head h1 { font-size: 24px; font-weight: 800; }
.page-head .sub { color: var(--muted); margin-top: 4px; }
.crumbs { font-size: 12px; color: var(--muted); margin-bottom: 6px; display: flex; gap: 6px; align-items: center; }
.crumbs a { color: var(--muted); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; gap: 8px; height: 38px; padding: 0 16px; border-radius: 10px; border: 1px solid var(--border); background: #fff; color: var(--text-2); font-weight: 600; font-size: 13.5px; cursor: pointer; white-space: nowrap; transition: background .15s, border-color .15s, box-shadow .15s, transform .05s; }
.btn:hover { background: var(--surface-2); border-color: var(--border-2); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn svg { width: 17px; height: 17px; }
.btn.primary { background: linear-gradient(180deg, var(--b600), var(--b700)); color: #fff; border-color: var(--b700); box-shadow: 0 1px 0 rgba(255,255,255,.2) inset, 0 4px 12px -2px color-mix(in srgb, var(--b700), transparent 55%); }
.btn.primary:hover { background: linear-gradient(180deg, var(--b700), var(--b800)); }
.btn.success { background: var(--green); color: #fff; border-color: var(--green); }
.btn.success:hover { background: #047857; }
.btn.danger { color: var(--red); border-color: #fecaca; }
.btn.danger:hover { background: var(--red-bg); }
.btn.danger.solid { background: var(--red); color: #fff; border-color: var(--red); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--gray-bg); }
.btn.sm { height: 32px; padding: 0 12px; font-size: 12.5px; border-radius: 8px; }
.btn.xs { height: 26px; padding: 0 9px; font-size: 12px; border-radius: 7px; gap: 5px; }
.btn.xs svg { width: 14px; height: 14px; }
.btn[disabled] { opacity: .55; pointer-events: none; }
.btn .spinner { width: 16px; height: 16px; border-width: 2px; }

/* ---------- cards ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.card-head h3 { font-size: 15px; font-weight: 700; }
.card-head .hint { color: var(--muted); font-size: 12px; }
.card-body { padding: 18px; }
.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }

/* ---------- KPI ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi { display: flex; gap: 14px; align-items: flex-start; padding: 16px 18px; color: var(--text); background: #fff; border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); transition: box-shadow .15s, transform .15s, border-color .15s; }
.kpi:hover { text-decoration: none; box-shadow: var(--shadow); transform: translateY(-1px); border-color: var(--b200); }
.kpi .k-ic { width: 42px; height: 42px; border-radius: 12px; display: flex; align-items: center; justify-content: center; flex: none; }
.kpi .k-ic svg { width: 21px; height: 21px; }
.kpi .k-label { color: var(--muted); font-size: 12.5px; font-weight: 600; }
.kpi .k-val { font-size: 24px; font-weight: 800; letter-spacing: -.02em; margin-top: 2px; }
.kpi .k-sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.tone-blue .k-ic { background: var(--b100); color: var(--b700); }
.tone-indigo .k-ic { background: var(--indigo-bg); color: var(--indigo); }
.tone-green .k-ic { background: var(--green-bg); color: var(--green); }
.tone-amber .k-ic { background: var(--amber-bg); color: var(--amber); }
.tone-red .k-ic { background: var(--red-bg); color: var(--red); }
.welcome { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding: 22px 24px; margin-bottom: 18px; border-radius: 16px; color: #fff; background: radial-gradient(600px 200px at 90% -40%, color-mix(in srgb, var(--b200), transparent 50%), transparent 60%), linear-gradient(120deg, var(--b900), var(--b700)); box-shadow: var(--shadow); }
.welcome h1 { font-size: 22px; font-weight: 800; }
.welcome p { margin: 4px 0 0; opacity: .85; }
.welcome .btn { background: rgba(255,255,255,.14); border-color: rgba(255,255,255,.25); color: #fff; }
.welcome .btn:hover { background: rgba(255,255,255,.24); }

/* ---------- charts ---------- */
.bars { display: grid; gap: 10px; }
.bar-row { display: grid; grid-template-columns: 130px 1fr 80px; gap: 10px; align-items: center; font-size: 13px; }
.bar-row .lbl { color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-row .track { background: var(--b50); border-radius: 999px; height: 10px; overflow: hidden; }
.bar-row .fill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--b500), var(--b700)); }
.bar-row .val { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.cols-chart svg { width: 100%; height: 220px; display: block; }
.legend { display: flex; gap: 16px; font-size: 12px; color: var(--muted); margin-top: 8px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.empty { text-align: center; color: var(--muted); padding: 36px 16px; }
.empty svg { width: 40px; height: 40px; color: var(--b200); margin-bottom: 8px; }
.empty b { display: block; color: var(--text-2); margin-bottom: 4px; }

/* ---------- toolbar / filters ---------- */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.toolbar .search { position: relative; flex: 1 1 240px; max-width: 360px; }
.toolbar .search .input { padding-left: 34px; }
.toolbar .search svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--faint); }
.toolbar select.input, .toolbar input[type=date].input { width: auto; min-width: 140px; }
.toolbar .spacer { flex: 1; }

/* ---------- table ---------- */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
table.data th { position: sticky; top: 0; background: var(--surface-2); color: var(--muted); font-weight: 600; font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; user-select: none; }
table.data th.sortable { cursor: pointer; }
table.data th.sortable:hover { color: var(--b700); }
table.data th .arrow { display: inline-block; margin-left: 4px; color: var(--b600); }
table.data td { padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; white-space: nowrap; max-width: 320px; overflow: hidden; text-overflow: ellipsis; }
table.data tbody tr { transition: background .1s; }
table.data tbody tr.click { cursor: pointer; }
table.data tbody tr:hover { background: #f7faff; }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data tfoot td { font-weight: 700; background: var(--b50); border-bottom: 0; }
table.data tr:last-child td { border-bottom: 0; }
table.data td.wrap { white-space: normal; }
.cell-strong { font-weight: 600; color: var(--text); }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; border-top: 1px solid var(--border); color: var(--muted); font-size: 13px; flex-wrap: wrap; }
.pager .pg { display: flex; gap: 6px; align-items: center; }
.progress { display: flex; align-items: center; gap: 8px; min-width: 110px; }
.progress .track { flex: 1; height: 7px; background: var(--gray-bg); border-radius: 999px; overflow: hidden; }
.progress .fill { height: 100%; background: linear-gradient(90deg, var(--b500), var(--b700)); border-radius: 999px; }
.progress .fill.done { background: var(--green); }
.progress span { font-size: 12px; color: var(--text-2); width: 34px; text-align: right; }

/* ---------- pills ---------- */
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--gray-bg); color: var(--text-2); white-space: nowrap; }
.pill::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .8; }
.pill.green { background: var(--green-bg); color: var(--green); }
.pill.blue { background: var(--b50); color: var(--b700); }
.pill.amber { background: var(--amber-bg); color: var(--amber); }
.pill.red { background: var(--red-bg); color: var(--red); }
.pill.purple { background: var(--purple-bg); color: var(--purple); }
.pill.indigo { background: var(--indigo-bg); color: var(--indigo); }
.tag { display: inline-block; padding: 2px 8px; border-radius: 6px; background: var(--b50); color: var(--b800); font-size: 11.5px; font-weight: 600; }

/* ---------- forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label { font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.field > label .req { color: var(--red); margin-left: 2px; }
.field .help { font-size: 12px; color: var(--muted); }
.field .err { font-size: 12px; color: var(--red); font-weight: 500; }
.field.has-err .input { border-color: #fca5a5; background: #fff8f8; }
.input { width: 100%; height: 38px; padding: 0 12px; border: 1px solid var(--border-2); border-radius: 9px; background: #fff; outline: none; transition: border-color .15s, box-shadow .15s; }
.input:focus { border-color: var(--b500); box-shadow: 0 0 0 3px rgba(59,130,246,.18); }
.input[disabled], .input[readonly] { background: var(--surface-2); color: var(--muted); }
textarea.input { height: auto; min-height: 84px; padding: 10px 12px; resize: vertical; }
select.input { padding-right: 30px; appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 18px; }
.form-grid .full { grid-column: 1 / -1; }
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; height: 38px; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .tr { width: 40px; height: 22px; border-radius: 999px; background: var(--border-2); position: relative; transition: background .15s; flex: none; }
.switch .tr::after { content: ''; position: absolute; left: 3px; top: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: var(--shadow-sm); transition: transform .15s; }
.switch input:checked + .tr { background: var(--b600); }
.switch input:checked + .tr::after { transform: translateX(18px); }
.switch input:focus-visible + .tr { outline: 2px solid var(--b500); outline-offset: 2px; }
.combo { position: relative; }
.combo .input { padding-right: 56px; }
.combo .clear { position: absolute; right: 30px; top: 50%; transform: translateY(-50%); border: 0; background: none; color: var(--faint); cursor: pointer; padding: 4px; display: flex; }
.combo .clear svg { width: 14px; height: 14px; }
.combo .chev { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--muted); pointer-events: none; }
.combo-list { position: absolute; z-index: 80; left: 0; right: 0; top: calc(100% + 4px); background: #fff; border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow-lg); max-height: 260px; overflow: auto; padding: 4px; }
.combo-list div { padding: 8px 10px; border-radius: 7px; cursor: pointer; font-size: 13px; }
.combo-list div:hover, .combo-list div.hl { background: var(--b50); color: var(--b800); }
.combo-list .none { color: var(--muted); cursor: default; }
.combo-list .none:hover { background: none; color: var(--muted); }
.checks { display: flex; flex-wrap: wrap; gap: 8px; }
.check { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border: 1px solid var(--border); border-radius: 8px; cursor: pointer; font-size: 13px; background: #fff; }
.check:has(input:checked) { border-color: var(--b400); background: var(--b50); color: var(--b800); }

/* ---------- drawer & modal ---------- */
.backdrop { position: fixed; inset: 0; z-index: 100; background: rgba(7,26,69,.45); backdrop-filter: blur(2px); animation: fade .15s ease; }
@keyframes fade { from { opacity: 0; } }
.drawer { position: fixed; z-index: 101; top: 0; right: 0; bottom: 0; width: min(760px, 100vw); background: #fff; box-shadow: var(--shadow-lg); display: flex; flex-direction: column; animation: slide .22s cubic-bezier(.2,.8,.2,1); }
@keyframes slide { from { transform: translateX(40px); opacity: 0; } }
.drawer-head, .modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 22px; border-bottom: 1px solid var(--border); }
.drawer-head h2, .modal-head h2 { font-size: 18px; font-weight: 800; }
.drawer-head .sub { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.drawer-body { flex: 1; overflow-y: auto; padding: 22px; }
.drawer-foot, .modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 22px; border-top: 1px solid var(--border); background: var(--surface-2); }
.modal { position: fixed; z-index: 101; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 48px); background: #fff; border-radius: 16px; box-shadow: var(--shadow-lg); display: flex; flex-direction: column; animation: pop .18s ease; }
.modal.wide { width: min(980px, calc(100vw - 32px)); }
@keyframes pop { from { transform: translate(-50%, -48%) scale(.98); opacity: 0; } }
.modal-body { padding: 20px 22px; overflow-y: auto; }
.form-alert { padding: 10px 14px; border-radius: 10px; background: var(--red-bg); color: var(--red); font-weight: 500; margin-bottom: 16px; border: 1px solid #fecaca; }
.info-alert { padding: 12px 14px; border-radius: 10px; background: var(--b50); color: var(--b900); border: 1px solid var(--b100); margin-bottom: 16px; display: flex; gap: 10px; align-items: flex-start; }
.info-alert svg { width: 18px; height: 18px; flex: none; color: var(--b600); margin-top: 1px; }
.warn-alert { padding: 12px 14px; border-radius: 10px; background: var(--amber-bg); color: #78350f; border: 1px solid #fde68a; margin-bottom: 16px; display: flex; gap: 10px; align-items: flex-start; }
.warn-alert svg { width: 18px; height: 18px; flex: none; color: var(--amber); margin-top: 1px; }
.secret { font-family: ui-monospace, Consolas, monospace; font-size: 18px; font-weight: 700; letter-spacing: .04em; padding: 14px; text-align: center; background: var(--b50); border: 1px dashed var(--b400); border-radius: 10px; color: var(--b900); user-select: all; }
/* two-step sign-in */
.otp-input { font-family: ui-monospace, Consolas, monospace; font-size: 22px; letter-spacing: .3em; text-align: center; }
.qr-box { display: flex; justify-content: center; padding: 12px; margin: 4px 0 12px; background: #fff; border: 1px solid var(--border); border-radius: 10px; }
.qr-box img { display: block; width: 190px; height: 190px; }
.setup-key { font-family: ui-monospace, Consolas, monospace; font-weight: 700; color: var(--b900); background: var(--b50); padding: 1px 6px; border-radius: 5px; user-select: all; overflow-wrap: anywhere; }
.steps-list { margin: 0 0 12px; padding-left: 20px; line-height: 1.8; color: var(--text-2); }
.recovery-codes { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-bottom: 12px; }
.recovery-codes code { font-family: ui-monospace, Consolas, monospace; font-size: 15px; font-weight: 600; text-align: center; padding: 8px; background: var(--gray-bg); border: 1px solid var(--border); border-radius: 8px; user-select: all; }

/* ---------- detail ---------- */
.detail-head { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; flex-wrap: wrap; margin-bottom: 16px; }
.detail-head h1 { font-size: 24px; font-weight: 800; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.kv { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 0; }
.kv > div { padding: 12px 18px; border-bottom: 1px solid var(--border); border-right: 1px solid var(--border); min-width: 0; }
.kv dt { font-size: 11.5px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.kv dd { margin: 4px 0 0; font-weight: 500; overflow-wrap: anywhere; }
.kv dd.long { white-space: pre-wrap; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); padding: 0 10px; overflow-x: auto; }
.tabs button { border: 0; background: none; padding: 12px 14px; font-weight: 600; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap; display: flex; gap: 6px; align-items: center; }
.tabs button:hover { color: var(--b700); }
.tabs button.active { color: var(--b700); border-bottom-color: var(--b700); }
.tabs .count { background: var(--gray-bg); color: var(--muted); border-radius: 999px; font-size: 11px; padding: 0 7px; }
.tabs button.active .count { background: var(--b100); color: var(--b700); }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 18px 26px; }
.timeline li::before { content: ''; position: absolute; left: 7px; top: 18px; bottom: 0; width: 2px; background: var(--border); }
.timeline li:last-child::before { display: none; }
.timeline .dot { position: absolute; left: 0; top: 3px; width: 16px; height: 16px; border-radius: 50%; background: var(--b100); border: 3px solid #fff; box-shadow: 0 0 0 1px var(--b200); }
.timeline .dot.green { background: var(--green); box-shadow: 0 0 0 1px var(--green); }
.timeline .dot.red { background: var(--red); box-shadow: 0 0 0 1px var(--red); }
.timeline .dot.purple { background: var(--purple); box-shadow: 0 0 0 1px var(--purple); }
.timeline .when { color: var(--muted); font-size: 12px; }
.timeline .what { font-weight: 600; }
.timeline .note { margin-top: 4px; padding: 8px 10px; background: var(--surface-2); border-radius: 8px; font-size: 13px; white-space: pre-wrap; }
.changes { font-size: 12px; color: var(--muted); margin-top: 4px; }
.changes code { background: var(--gray-bg); padding: 1px 5px; border-radius: 4px; color: var(--text-2); }
.approval-banner { display: flex; gap: 14px; align-items: center; justify-content: space-between; flex-wrap: wrap; padding: 14px 18px; border-radius: var(--radius); margin-bottom: 16px; border: 1px solid #fde68a; background: var(--amber-bg); }
.approval-banner.green { border-color: #a7f3d0; background: var(--green-bg); }
.approval-banner.red { border-color: #fecaca; background: var(--red-bg); }
.approval-banner.purple { border-color: #ddd6fe; background: var(--purple-bg); }
.approval-banner b { display: block; }
.approval-banner small { color: var(--text-2); }
.comment { display: flex; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.comment:last-child { border-bottom: 0; }
.comment .body { white-space: pre-wrap; margin-top: 2px; }
.files { display: grid; gap: 8px; }
.file { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; }
.file .f-ic { width: 36px; height: 36px; border-radius: 9px; background: var(--b50); color: var(--b700); display: flex; align-items: center; justify-content: center; flex: none; }
.file .f-ic svg { width: 18px; height: 18px; }
.file .meta { flex: 1; min-width: 0; }
.file .meta b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file .meta small { color: var(--muted); }
.dropzone { border: 2px dashed var(--b200); border-radius: 12px; padding: 18px; text-align: center; color: var(--muted); background: var(--b50); cursor: pointer; margin-bottom: 12px; }
.dropzone:hover, .dropzone.over { border-color: var(--b500); color: var(--b800); }

/* ---------- reports ---------- */
.report-groups { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.report-link { display: flex; gap: 12px; padding: 12px 14px; border-radius: 10px; color: var(--text); }
.report-link:hover { background: var(--b50); text-decoration: none; }
.report-link svg { width: 18px; height: 18px; color: var(--b600); flex: none; margin-top: 2px; }
.report-link b { display: block; font-size: 13.5px; }
.report-link small { color: var(--muted); }
.params { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; padding: 14px; border-bottom: 1px solid var(--border); }
.params .field { min-width: 170px; }

/* ---------- messages ---------- */
.chat { display: grid; grid-template-columns: 320px 1fr; height: calc(100vh - 64px - 48px - 70px); min-height: 460px; overflow: hidden; }
.threads { border-right: 1px solid var(--border); overflow-y: auto; }
.thread { display: flex; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--border); cursor: pointer; color: var(--text); }
.thread:hover { background: var(--surface-2); text-decoration: none; }
.thread.active { background: var(--b50); }
.thread .t-main { flex: 1; min-width: 0; }
.thread b { display: block; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thread small { color: var(--muted); display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thread .unread { background: var(--b700); color: #fff; font-size: 11px; font-weight: 700; border-radius: 999px; padding: 0 7px; height: 19px; align-self: center; }
.convo { display: flex; flex-direction: column; min-width: 0; }
.convo-head { padding: 14px 18px; border-bottom: 1px solid var(--border); }
.convo-head small { color: var(--muted); }
.msgs { flex: 1; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 10px; background: linear-gradient(180deg, #fbfdff, #f5f8fe); }
.msg { max-width: 72%; align-self: flex-start; }
.msg .bubble { padding: 10px 14px; border-radius: 14px 14px 14px 4px; background: #fff; border: 1px solid var(--border); white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.me { align-self: flex-end; }
.msg.me .bubble { background: linear-gradient(180deg, var(--b600), var(--b700)); color: #fff; border-color: transparent; border-radius: 14px 14px 4px 14px; }
.msg .meta { font-size: 11px; color: var(--muted); margin: 3px 6px; }
.msg.me .meta { text-align: right; }
.composer { display: flex; gap: 10px; padding: 12px; border-top: 1px solid var(--border); }
.composer textarea { min-height: 42px; height: 42px; resize: none; }

/* ---------- roles matrix ---------- */
.matrix th, .matrix td { text-align: center; }
.matrix td:first-child, .matrix th:first-child { text-align: left; }
.matrix input { width: 17px; height: 17px; accent-color: var(--b700); cursor: pointer; }
.role-list a { display: flex; justify-content: space-between; align-items: center; padding: 11px 14px; border-bottom: 1px solid var(--border); color: var(--text); }
.role-list a:hover { background: var(--surface-2); text-decoration: none; }
.role-list a.active { background: var(--b50); color: var(--b800); font-weight: 600; box-shadow: inset 3px 0 0 var(--b700); }

/* ---------- toasts ---------- */
#toasts { position: fixed; z-index: 200; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 10px; max-width: calc(100vw - 40px); }
.toast { display: flex; gap: 10px; align-items: flex-start; min-width: 280px; max-width: 420px; padding: 12px 14px; border-radius: 12px; background: #0f172a; color: #fff; box-shadow: var(--shadow-lg); animation: slideup .2s ease; }
.toast svg { width: 18px; height: 18px; flex: none; margin-top: 1px; }
.toast.success svg { color: #34d399; }
.toast.error { background: #7f1d1d; }
.toast.error svg { color: #fca5a5; }
@keyframes slideup { from { transform: translateY(10px); opacity: 0; } }

/* ---------- misc ---------- */
.muted { color: var(--muted); }
.mt { margin-top: 16px; }
.mb { margin-bottom: 16px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.between { justify-content: space-between; }
.list-plain { list-style: none; margin: 0; padding: 0; }
.mini-row { display: flex; justify-content: space-between; gap: 10px; padding: 10px 18px; border-bottom: 1px solid var(--border); color: var(--text); align-items: center; }
.mini-row:last-child { border-bottom: 0; }
a.mini-row:hover { background: var(--surface-2); text-decoration: none; }
.mini-row b { font-weight: 600; }
.mini-row small { color: var(--muted); display: block; }
.ann { padding: 14px 18px; border-bottom: 1px solid var(--border); }
.ann:last-child { border-bottom: 0; }
.ann b { display: block; }
.ann p { margin: 4px 0 0; white-space: pre-wrap; color: var(--text-2); }
.ann small { color: var(--muted); }
.mobile-only { display: none; }
.kbd { font-family: ui-monospace, Consolas, monospace; font-size: 12px; background: var(--gray-bg); border: 1px solid var(--border); border-radius: 5px; padding: 1px 5px; }

/* ---------- responsive ---------- */
@media (max-width: 1180px) { .grid.cols-3 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 1024px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 120; left: 0; top: 0; width: 280px; transform: translateX(-100%); transition: transform .22s ease; box-shadow: var(--shadow-lg); }
  .shell.nav-open .sidebar { transform: none; }
  .shell.nav-open::after { content: ''; position: fixed; inset: 0; z-index: 110; background: rgba(7,26,69,.45); }
  .topbar .menu-btn { display: inline-flex; }
  .grid.cols-2, .grid.cols-3 { grid-template-columns: 1fr; }
  .auth { grid-template-columns: 1fr; }
  .auth-brand { padding: 28px 24px; }
  .auth-hero h1 { font-size: 28px; }
  .auth-points { display: none; }
  .chat { grid-template-columns: 1fr; height: auto; }
  .chat .threads { max-height: 260px; border-right: 0; border-bottom: 1px solid var(--border); }
}
@media (max-width: 640px) {
  .content { padding: 16px; }
  .topbar { padding: 0 12px; gap: 6px; }
  .user-chip .who { display: none; }
  .user-chip { padding: 4px; }
  .form-grid { grid-template-columns: 1fr; }
  .page-head h1 { font-size: 20px; }
  .kpi .k-val { font-size: 20px; }
  .bar-row { grid-template-columns: 90px 1fr 64px; }
  .toolbar .search { max-width: none; }
  .drawer-body { padding: 16px; }
  .msg { max-width: 90%; }
  .mobile-only { display: initial; }
}

/* ---------- print ---------- */
#print-root { display: none; }
@media print {
  @page { margin: 12mm; }
  body { background: #fff; font-size: 11px; }
  body.printing #app, body.printing #overlays, body.printing #toasts { display: none !important; }
  body.printing #print-root { display: block; }
  .pr-head { display: flex; justify-content: space-between; align-items: flex-start; border-bottom: 3px solid var(--b700); padding-bottom: 10px; margin-bottom: 14px; }
  .pr-head .co { display: flex; gap: 10px; align-items: center; }
  .pr-head img, .pr-head .brand-mark { width: 42px; height: 42px; display: block; }
  .pr-head h1 { font-size: 18px; color: var(--b900); }
  .pr-head .addr { font-size: 10px; color: #475569; }
  .pr-title { text-align: right; }
  .pr-title h2 { font-size: 16px; color: var(--b700); text-transform: uppercase; letter-spacing: .06em; }
  .pr-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 24px; margin-bottom: 14px; }
  .pr-box { border: 1px solid #cbd5e1; border-radius: 6px; padding: 8px 10px; }
  .pr-box h4 { font-size: 10px; color: #64748b; text-transform: uppercase; letter-spacing: .05em; margin-bottom: 4px; }
  table.pr { width: 100%; border-collapse: collapse; }
  table.pr th { background: var(--b700) !important; color: #fff !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; font-size: 10px; text-align: left; padding: 5px 6px; }
  table.pr td { border-bottom: 1px solid #e2e8f0; padding: 5px 6px; font-size: 10.5px; }
  table.pr td.num, table.pr th.num { text-align: right; }
  table.pr tfoot td { font-weight: 700; border-top: 2px solid var(--b700); background: var(--b50) !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .pr-foot { margin-top: 28px; display: flex; justify-content: space-between; gap: 24px; font-size: 10px; color: #475569; }
  .pr-sign { margin-top: 40px; display: flex; justify-content: space-between; gap: 30px; }
  .pr-sign div { flex: 1; border-top: 1px solid #94a3b8; padding-top: 4px; text-align: center; font-size: 10px; }
  .pr-small { font-size: 9.5px; color: #64748b; margin-top: 10px; }
}

/* ================= v1.1 additions: chat, alerts, prints, mobile ================= */
.bottom-nav { display: none; }
.f-thumb { width: 44px; height: 44px; border-radius: 9px; object-fit: cover; flex: none; border: 1px solid var(--border); }
.alert-card .k-ic { width: 34px; height: 34px; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center; }
.alert-card .k-ic svg { width: 18px; height: 18px; }
.k-ic.tone-red { background: var(--red-bg); color: var(--red); }
.k-ic.tone-amber { background: var(--amber-bg); color: var(--amber); }
.alert-card.red { border-top: 3px solid var(--red); }
.alert-card.amber { border-top: 3px solid #f59e0b; }

/* team chat */
.chat { display: grid; grid-template-columns: 320px 1fr; height: calc(100vh - 64px - 48px); min-height: 480px; overflow: hidden; }
.chat-side { display: flex; flex-direction: column; border-right: 1px solid var(--border); min-height: 0; background: #fbfcff; }
.chat-side-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 14px 10px; }
.chat-side-head b { font-size: 16px; }
.chat .threads { flex: 1; overflow-y: auto; border-right: 0; }
.th-sec { padding: 12px 16px 6px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.th-empty { padding: 4px 16px 10px; color: var(--faint); font-size: 12.5px; }
.chat .thread { border-bottom: 0; border-radius: 10px; margin: 1px 8px; padding: 9px 10px; align-items: center; }
.avatar.team { background: linear-gradient(135deg, var(--b400), var(--b700)); font-size: 15px; border-radius: 10px; }
.convo-head { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--border); background: #fff; }
.convo-head .actions { flex-wrap: nowrap; }
.day-sep { text-align: center; margin: 6px 0; }
.day-sep span { background: #fff; border: 1px solid var(--border); color: var(--muted); font-size: 11.5px; font-weight: 600; padding: 2px 10px; border-radius: 999px; }
.msg .bubble { position: relative; display: grid; gap: 8px; }
.msg .txt { white-space: pre-wrap; overflow-wrap: anywhere; }
.msg-del { position: absolute; top: -8px; right: -8px; width: 24px; height: 24px; border-radius: 50%; border: 1px solid var(--border); background: #fff; color: var(--muted); display: none; align-items: center; justify-content: center; cursor: pointer; padding: 0; }
.msg-del svg { width: 13px; height: 13px; }
.msg:hover .msg-del, .msg:focus-within .msg-del { display: flex; }
.ref-card { display: flex; gap: 10px; align-items: center; padding: 9px 11px; border-radius: 10px; background: var(--b50); border: 1px solid var(--b100); color: var(--b900); text-decoration: none; min-width: 220px; }
.ref-card:hover { text-decoration: none; border-color: var(--b400); }
.ref-card b { display: block; font-size: 13px; }
.ref-card small { color: var(--b700); font-size: 11.5px; }
.rc-ic { width: 32px; height: 32px; border-radius: 8px; background: #fff; color: var(--b700); display: flex; align-items: center; justify-content: center; flex: none; }
.rc-ic svg { width: 17px; height: 17px; }
.msg.me .ref-card { background: rgba(255,255,255,.14); border-color: rgba(255,255,255,.3); color: #fff; }
.msg.me .ref-card small { color: rgba(255,255,255,.8); }
.chat-img { max-width: 260px; max-height: 220px; border-radius: 10px; display: block; object-fit: cover; }
.composer { align-items: flex-end; background: #fff; }
.composer .btn.ghost { padding: 0 10px; }

/* printing additions */
@media print {
  .pr-words { margin: 8px 0; padding: 6px 10px; border: 1px dashed var(--b200); border-radius: 6px; font-size: 10.5px; font-weight: 600; color: var(--b900); }
  .pr-h3 { font-size: 12px; color: var(--b900); margin: 14px 0 6px; text-transform: uppercase; letter-spacing: .05em; }
  table.pr.kvp th { background: var(--b50) !important; color: var(--b900) !important; width: 18%; font-weight: 600; border-bottom: 1px solid #e2e8f0; }
  table.pr.kvp td { width: 32%; }
  .pr-result { margin-top: 10px; font-size: 14px; }
  table.pr tr, .pr-box { page-break-inside: avoid; }
  table.pr thead { display: table-header-group; }
  .pr-meta { grid-template-columns: 1fr 1fr; }
}

/* ================= phones & tablets ================= */
@media (max-width: 1024px) {
  .shell { padding-bottom: calc(64px + env(safe-area-inset-bottom)); }
  .bottom-nav { display: flex; position: fixed; z-index: 90; left: 0; right: 0; bottom: 0; height: calc(60px + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); background: rgba(255,255,255,.97); backdrop-filter: blur(10px); border-top: 1px solid var(--border); box-shadow: 0 -4px 16px rgba(15,23,42,.06); }
  .bottom-nav .bt { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 11px; font-weight: 600; color: var(--muted); text-decoration: none; border: 0; background: none; cursor: pointer; }
  .bottom-nav .bt.active { color: var(--b700); }
  .bt-ic { position: relative; display: flex; }
  .bt-ic svg { width: 22px; height: 22px; }
  .bt-ic .dot { position: absolute; top: -5px; right: -9px; background: #f43f5e; color: #fff; font-size: 10px; font-weight: 700; border-radius: 999px; min-width: 16px; height: 16px; padding: 0 4px; display: flex; align-items: center; justify-content: center; }
  .chat { grid-template-columns: 1fr; height: calc(100vh - 64px - 32px - 64px); }
  .chat.has-active .chat-side { display: none; }
  .chat:not(.has-active) .convo { display: none; }
  .chat .threads { max-height: none; }
  .report-groups { grid-template-columns: 1fr; }
  #toasts { bottom: calc(76px + env(safe-area-inset-bottom)); }
}
@media (max-width: 640px) {
  body { font-size: 15px; }
  .input, select.input, textarea.input { font-size: 16px; height: 44px; } /* no iOS zoom, bigger touch targets */
  textarea.input { height: auto; }
  .btn { height: 42px; }
  .btn.sm { height: 36px; }
  .btn.xs { height: 32px; }
  .gsearch .input { height: 40px; font-size: 15px; }
  .gsearch .input::placeholder { color: transparent; }
  .page-head { align-items: stretch; }
  .page-head .actions { width: 100%; }
  .page-head .actions > .btn, .page-head .actions > div { flex: 1 1 auto; justify-content: center; }
  .page-head .actions > div > .btn { width: 100%; justify-content: center; }
  .detail-head .actions { width: 100%; }
  .detail-head .actions > .btn, .detail-head .actions > div { flex: 1 1 calc(50% - 8px); justify-content: center; }
  .detail-head .actions > div > .btn { width: 100%; justify-content: center; }
  .detail-head h1 { font-size: 20px; }
  .toolbar { gap: 8px; }
  .toolbar > * { flex: 1 1 100%; }
  .toolbar select.input, .toolbar input[type=date].input { min-width: 0; flex: 1 1 calc(50% - 4px); }
  .toolbar .spacer { display: none; }
  .kpis { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpi { flex-direction: column; gap: 8px; padding: 14px; }
  .kpi .k-ic { width: 36px; height: 36px; }
  .welcome { padding: 18px; }
  .welcome .actions { width: 100%; }
  .welcome .actions .btn { flex: 1 1 auto; justify-content: center; }
  .kv { grid-template-columns: 1fr 1fr; }
  .kv > div { padding: 10px 12px; }
  .drawer { width: 100vw; }
  .modal { width: calc(100vw - 20px); max-height: calc(100vh - 20px); }
  .modal.wide { width: calc(100vw - 20px); }
  .tabs button { padding: 12px 10px; }
  .pager { justify-content: center; }
  .popover { position: fixed; left: 10px; right: 10px; top: 70px; }
  .notif-list { width: auto; }
  .chat-img { max-width: 100%; }
  .msg { max-width: 88%; }
  .msg-del { display: flex; }
  .convo-head .actions .btn { padding: 0 10px; }
  /* tables become cards on phones */
  table.data.cards thead { display: none; }
  table.data.cards, table.data.cards tbody, table.data.cards tr, table.data.cards td, table.data.cards tfoot { display: block; width: 100%; }
  table.data.cards tbody tr { margin: 10px; width: auto; border: 1px solid var(--border); border-radius: 12px; padding: 6px 12px; background: #fff; box-shadow: var(--shadow-sm); }
  table.data.cards td { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 1px dashed var(--border); white-space: normal; max-width: none; text-align: right; overflow: visible; }
  table.data.cards td::before { content: attr(data-label); color: var(--muted); font-size: 12px; font-weight: 600; text-align: left; flex: none; max-width: 45%; }
  table.data.cards td:first-child { font-weight: 700; color: var(--b800); font-size: 15px; }
  table.data.cards td:last-child { border-bottom: 0; }
  table.data.cards td.is-empty { display: none; }
  table.data.cards td.num { text-align: right; }
  table.data.cards td .progress { min-width: 140px; }
  table.data.cards tfoot tr { margin: 10px; width: auto; border-radius: 12px; padding: 6px 12px; background: var(--b50); }
  table.data.cards tfoot td { background: transparent; }
  /* only tables shown as cards stop scrolling; every other table scrolls inside its card */
  .table-wrap:has(> table.cards) { overflow-x: visible; }
}

table.data tr.strong td { font-weight: 700; background: var(--b50); }
@media print { table.pr tr.strong td { font-weight: 700; background: var(--b50) !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; } }

/* amount inputs show their currency symbol */
.money-wrap { position: relative; }
.money-wrap .money-sym { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--b700); font-weight: 700; font-size: 13px; pointer-events: none; }
.money-wrap.has-sym .input { padding-left: 46px; }

/* empty states: icon above the text, always centred */
.empty { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; }
.empty > svg { display: block; margin: 0 0 4px; flex: none; }
.empty b { margin-bottom: 0; }

/* slim, unobtrusive horizontal scrollbars for tab bars and wide tables */
.tabs { scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.table-wrap { scrollbar-width: thin; scrollbar-color: var(--border-2) transparent; }
.table-wrap::-webkit-scrollbar { height: 6px; }
.table-wrap::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 6px; }

/* upload drop zone: compact icon above the text */
.dropzone { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.dropzone > svg { width: 30px; height: 30px; flex: none; color: var(--b600); margin-bottom: 2px; }
.dropzone small { font-size: 12px; }

/* ================= chat header, roles page ================= */
.convo-head .ch-info { flex: 1; min-width: 0; }
.convo-head .ch-title, .convo-head .ch-sub { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.convo-head .ch-title { font-size: 15px; }
.convo-head .ch-sub { color: var(--muted); font-size: 12px; }
.convo-head .actions { flex: none; flex-wrap: nowrap; gap: 6px; }
.roles-grid { grid-template-columns: minmax(220px, 280px) minmax(0, 1fr); }
.grid > * { min-width: 0; }

/* ================= Team Chat: chat-app style conversation ================= */
.chat .thread.active { background: #eef2f7; }
.chat .thread .unread { background: var(--b700); border-radius: 999px; min-width: 20px; text-align: center; }
.msgs.wa { gap: 0; padding: 12px 7% 16px; background-color: #eef2f8; background-image: radial-gradient(rgba(29, 78, 216, .07) 1px, transparent 1.2px); background-size: 16px 16px; }
.msgs.wa .msg { max-width: 68%; margin-top: 10px; display: flex; flex-direction: column; align-items: flex-start; align-self: flex-start; }
.msgs.wa .msg.me { align-self: flex-end; align-items: flex-end; }
.msgs.wa .msg.cont { margin-top: 2px; }
.msgs.wa .wa-row { display: flex; align-items: center; gap: 6px; max-width: 100%; }
.msgs.wa .bubble { position: relative; display: block; min-width: 72px; max-width: 100%; padding: 6px 9px 7px; border: 0; border-radius: 8px; background: #fff; color: #111b21; box-shadow: 0 1px .5px rgba(11, 20, 26, .13); }
.msgs.wa .msg.me .bubble { background: #dbe8ff; color: #111b21; border-radius: 8px; }
.msgs.wa .msg:not(.cont):not(.me) .bubble { border-top-left-radius: 0; }
.msgs.wa .msg.me:not(.cont) .bubble { border-top-right-radius: 0; }
.msgs.wa .msg:not(.cont):not(.me) .bubble::before { content: ''; position: absolute; top: 0; left: -8px; border-right: 8px solid #fff; border-bottom: 10px solid transparent; }
.msgs.wa .msg.me:not(.cont) .bubble::before { content: ''; position: absolute; top: 0; right: -8px; border-left: 8px solid #dbe8ff; border-bottom: 10px solid transparent; }
.msgs.wa .bubble > * + * { margin-top: 4px; }
.msgs.wa .txt { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14.2px; line-height: 19px; }
.wa-meta { float: right; position: relative; top: 7px; margin: -6px 0 0 12px; display: inline-flex; align-items: center; gap: 4px; font-size: 11px; line-height: 15px; color: #667781; white-space: nowrap; user-select: none; }
.wa-meta i { font-style: normal; }
.wa-meta-row { display: flex; justify-content: flex-end; }
.wa-meta-row .wa-meta { float: none; top: 0; margin: 0; }
.wa-tick { color: #8696a0; font-size: 12px; letter-spacing: -4px; padding-right: 4px; font-weight: 700; }
.wa-tick.read { color: var(--b600); }
.wa-name { font-size: 12.8px; font-weight: 600; line-height: 18px; }
.wa-fwd { display: flex; align-items: center; gap: 4px; font-size: 12px; color: #667781; font-style: italic; }
.wa-fwd svg { width: 14px; height: 14px; }
.wa-quote { display: block; padding: 5px 10px 6px; border-left: 4px solid var(--b600); border-radius: 6px; background: rgba(11, 20, 26, .05); font-size: 12.8px; line-height: 17px; cursor: pointer; min-width: 0; }
.wa-quote b { display: block; font-weight: 600; }
.wa-quote span { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; color: #54656f; white-space: pre-wrap; overflow-wrap: anywhere; }
.wa-deleted { display: flex; align-items: center; gap: 6px; color: #8696a0; font-style: italic; font-size: 13.5px; }
.wa-deleted svg { width: 15px; height: 15px; flex: none; }
.wa-deleted .wa-meta { float: none; top: 0; margin: 0 0 0 8px; font-style: normal; }
.wa-more { position: absolute; z-index: 2; top: 3px; right: 3px; width: 24px; height: 22px; display: flex; align-items: center; justify-content: center; padding: 0; border: 0; border-radius: 6px; cursor: pointer; color: #54656f; background: inherit; box-shadow: -8px 0 8px -2px #fff; opacity: 0; transition: opacity .12s; }
.msg.me .wa-more { box-shadow: -8px 0 8px -2px #dbe8ff; }
.wa-more svg { width: 18px; height: 18px; }
.bubble:hover .wa-more, .wa-more:focus-visible { opacity: 1; }
.wa-react-btn { flex: none; width: 28px; height: 28px; display: flex; align-items: center; justify-content: center; padding: 0; border: 0; border-radius: 50%; cursor: pointer; color: #54656f; background: rgba(255, 255, 255, .9); box-shadow: 0 1px 2px rgba(11, 20, 26, .15); opacity: 0; transition: opacity .12s; }
.wa-react-btn svg { width: 17px; height: 17px; }
.msg:hover .wa-react-btn, .wa-react-btn:focus-visible { opacity: 1; }
@media (hover: none) { .wa-more { opacity: 1; } }
.wa-reacts { position: relative; z-index: 1; display: inline-flex; align-items: center; gap: 1px; margin: -4px 10px 0; padding: 1px 6px; border: 1px solid #e9edef; border-radius: 12px; background: #fff; box-shadow: 0 1px 2px rgba(11, 20, 26, .12); font-size: 14px; line-height: 20px; cursor: pointer; }
.wa-reacts.mine { background: #e7f3ff; border-color: #cfe5ff; }
.wa-reacts small { margin-left: 3px; font-size: 11.5px; color: #667781; }
.msgs.wa .msg.flash .bubble { animation: waflash 1.4s ease; }
@keyframes waflash { 0%, 55% { box-shadow: 0 0 0 3px rgba(59, 158, 232, .55); } }
.msgs.wa .day-sep { margin: 14px 0 4px; }
.msgs.wa .day-sep span { background: #fff; border: 0; color: #54656f; font-size: 12px; font-weight: 500; padding: 5px 12px; border-radius: 8px; box-shadow: 0 1px .5px rgba(11, 20, 26, .13); }
.msgs.wa .chat-img { max-width: 300px; max-height: 300px; border-radius: 6px; }
.msgs.wa .ref-card { background: rgba(11, 20, 26, .04); border-color: rgba(11, 20, 26, .08); min-width: 200px; }
.msgs.wa .msg.me .ref-card { background: rgba(255, 255, 255, .55); border-color: rgba(11, 20, 26, .08); color: var(--b900); }
.msgs.wa .msg.me .ref-card small { color: var(--b700); }
.msgs.wa.drop { outline: 3px dashed var(--b500); outline-offset: -10px; }
.wa-empty { margin: auto; background: #fff; border-radius: 8px; padding: 10px 16px; box-shadow: 0 1px .5px rgba(11, 20, 26, .13); color: #54656f; }
.wa-replybar { display: flex; align-items: center; gap: 8px; padding: 8px 12px 0; background: #f0f2f5; border-top: 1px solid var(--border); }
.wa-replybar .wa-quote { flex: 1; background: #fff; cursor: default; }
.convo .composer { background: #f0f2f5; border-top: 0; align-items: flex-end; gap: 4px; }
.wa-replybar[style*="none"] + .composer { border-top: 1px solid var(--border); }
.convo .composer textarea.input { border: 0; border-radius: 8px; background: #fff; min-height: 42px; padding: 11px 12px; box-shadow: none; }
.convo .composer .btn.ghost { color: #54656f; padding: 0 8px; height: 42px; }
.convo .composer .btn.ghost svg { width: 22px; height: 22px; }
.wa-send { width: 42px; height: 42px; padding: 0; justify-content: center; border-radius: 50%; flex: none; }
/* floating menu, reaction bar and emoji picker */
.wa-float { position: fixed; z-index: 400; background: #fff; border-radius: 12px; box-shadow: 0 2px 5px rgba(11, 20, 26, .26), 0 10px 28px rgba(11, 20, 26, .16); animation: fade .12s ease; }
.wa-menu { padding: 6px 0; min-width: 190px; }
.wa-menu button { display: flex; align-items: center; gap: 12px; width: 100%; padding: 9px 18px; border: 0; background: none; cursor: pointer; font-size: 14px; color: #111b21; text-align: left; }
.wa-menu button:hover { background: #f5f6f6; }
.wa-menu button svg { width: 17px; height: 17px; color: #54656f; }
.wa-menu button.danger, .wa-menu button.danger svg { color: var(--red); }
.wa-reactbar { display: flex; align-items: center; gap: 2px; padding: 5px 6px; border-radius: 28px; }
.wa-reactbar button { width: 40px; height: 40px; display: flex; align-items: center; justify-content: center; padding: 0; border: 0; border-radius: 50%; background: none; cursor: pointer; font-size: 24px; transition: transform .12s ease, background .12s; }
.wa-reactbar button:hover { transform: scale(1.18); background: #f0f2f5; }
.wa-reactbar button.on { background: #dfe5e7; }
.wa-reactbar button.more { width: 32px; height: 32px; color: #54656f; background: #f0f2f5; margin-left: 2px; }
.wa-reactbar button.more svg { width: 18px; height: 18px; }
.wa-picker { width: 332px; padding: 8px; }
.wa-etabs { display: flex; gap: 2px; padding-bottom: 6px; margin-bottom: 6px; border-bottom: 1px solid #e9edef; }
.wa-etabs button { flex: 1; height: 34px; border: 0; border-radius: 8px; background: none; cursor: pointer; font-size: 19px; opacity: .55; }
.wa-etabs button.on { opacity: 1; background: #f0f2f5; }
.wa-egrid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px; max-height: 232px; overflow-y: auto; }
.wa-egrid button { height: 38px; border: 0; border-radius: 8px; background: none; cursor: pointer; font-size: 23px; line-height: 1; padding: 0; }
.wa-egrid button:hover { background: #f0f2f5; }
.wa-rx-big { font-size: 24px; border: 0; background: none; padding: 0 4px; cursor: pointer; }
span.wa-rx-big { cursor: default; }
.wa-fwd-list { max-height: 360px; overflow-y: auto; margin: 0 -8px; }
.wa-fwd-row { display: flex; align-items: center; gap: 12px; padding: 8px; border-radius: 8px; cursor: pointer; }
.wa-fwd-row:hover { background: var(--surface-2); }
.wa-fwd-row input { width: 18px; height: 18px; accent-color: var(--b700); flex: none; }
.wa-fwd-row b { display: block; font-size: 14px; font-weight: 500; }
.wa-fwd-row small { color: var(--muted); font-size: 12px; }
@media (max-width: 1024px) {
  /* the bottom bar already has Chat, so the top bar drops its messages icon */
  .topbar .top-actions > a.icon-btn[href="#/messages"] { display: none; }
  .topbar .gsearch { min-width: 40px; }
  .chat { grid-template-columns: minmax(0, 1fr); }
  .chat-side, .convo { min-width: 0; }
  .roles-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 380px) {
  .topbar { gap: 4px; padding: 0 8px; }
  .topbar .top-actions { gap: 2px; }
  .topbar .icon-btn { width: 36px; }
  .user-chip > svg { display: none; }
  .user-chip { padding: 2px; border: 0; }
  .top-clock { padding: 0 6px; }
  .top-clock .tc-time { font-size: 12.5px; }
}
@media (max-width: 640px) {
  .hide-sm { display: none; }
  .convo-head { padding: 8px 10px; gap: 8px; }
  .convo-head .btn.sm { padding: 0 10px; gap: 4px; }
  .convo-head .avatar { width: 34px; height: 34px; }
  /* chat uses the full phone width, like a chat app */
  .card.chat { margin: -16px -16px 0; border-radius: 0; border-left: 0; border-right: 0; height: calc(100dvh - 64px - 64px - env(safe-area-inset-bottom)); min-height: 360px; }
  .convo .composer { padding: 8px 6px; gap: 2px; }
  .convo .composer .btn.ghost { width: 34px; padding: 0; justify-content: center; }
  .convo .composer .btn.ghost svg { width: 21px; height: 21px; }
  .convo .composer textarea.input { flex: 1; min-width: 0; padding: 10px 12px; }
  .wa-send { width: 40px; height: 40px; }
  .wa-replybar { padding: 8px 8px 0; }
  .msgs.wa { padding: 10px 10px 14px; }
  .msgs.wa .msg { max-width: 86%; }
  .msgs.wa .chat-img { max-width: 100%; }
  .wa-react-btn { display: none; }
  .wa-picker { width: calc(100vw - 24px); }
}
