:root {
  color-scheme: light;
  --neon-cyan: #0d8d85;
  --neon-magenta: #b42368;
  --neon-violet: #6d4bd1;
  --neon-lime: #15803d;
  --neon-amber: #a65b00;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --glow-cyan: 0 0 0 1px rgba(13,141,133,.18), 0 0 18px rgba(13,141,133,.08);
  --brand-900: #073e3c;
  --brand-800: #095651;
  --brand-700: #0d6f67;
  --brand-600: #12857a;
  --brand-100: #dff4ef;
  --brand-50: #f0faf7;
  --ink-950: #10211f;
  --ink-800: #263c39;
  --ink-600: #5e706d;
  --ink-500: #778783;
  --bg: #f4f7f6;
  --surface: #fff;
  --surface-2: #f8faf9;
  --surface-glass: rgba(255,255,255,.96);
  --surface-glass-strong: rgba(255,255,255,.97);
  --table-head: #f6f9f8;
  --table-alt: #fbfcfc;
  --line: #dce5e2;
  --line-strong: #cbd8d4;
  --blue: #2563eb;
  --blue-bg: #eff6ff;
  --green: #15803d;
  --green-bg: #f0fdf4;
  --amber: #a65b00;
  --amber-bg: #fff8e8;
  --red: #b42318;
  --red-bg: #fff1f0;
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 18px;
  --shadow-sm: 0 1px 2px rgba(16, 33, 31, .05), 0 5px 18px rgba(16, 33, 31, .04);
  --shadow-md: 0 20px 60px rgba(7, 62, 60, .14);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --neon-cyan: #22d3ee;
  --neon-magenta: #ff2e9a;
  --neon-violet: #a855f7;
  --neon-lime: #7cff6b;
  --neon-amber: #ffb020;
  --glow-cyan: 0 0 0 1px rgba(34,211,238,.4), 0 0 18px rgba(34,211,238,.25);
  --brand-900: #dcfffd;
  --brand-800: #7ffcf7;
  --brand-700: #22d3ee;
  --brand-600: #14cfc9;
  --brand-100: #102f38;
  --brand-50: #0b2028;
  --ink-950: #e9fbff;
  --ink-800: #c6d9e4;
  --ink-600: #8499ad;
  --ink-500: #677d93;
  --bg: #05070a;
  --surface: #0b111a;
  --surface-2: #0f1725;
  --surface-glass: rgba(8,14,22,.94);
  --surface-glass-strong: rgba(8,14,22,.98);
  --table-head: #0d1823;
  --table-alt: #09131c;
  --line: #1b2740;
  --line-strong: #2a3a5c;
  --blue: #79a8ff;
  --blue-bg: #111e3a;
  --green: #7cff6b;
  --green-bg: #09271d;
  --amber: #ffd166;
  --amber-bg: #31250c;
  --red: #ff667f;
  --red-bg: #35121c;
  --shadow-sm: 0 0 0 1px rgba(32,245,237,.025), 0 12px 28px rgba(0,0,0,.22);
  --shadow-md: 0 25px 90px rgba(0,0,0,.62), 0 0 38px rgba(32,245,237,.07);
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--bg); }
body { margin: 0; color: var(--ink-950); background: var(--bg); line-height: 1.45; }
:root[data-theme="dark"] body {
  background-image: linear-gradient(rgba(32,245,237,.025) 1px, transparent 1px), linear-gradient(90deg, rgba(32,245,237,.025) 1px, transparent 1px), radial-gradient(circle at 76% -15%, rgba(129,74,255,.13), transparent 38%);
  background-size: 36px 36px, 36px 36px, auto;
}
:root[data-theme="dark"] body::before { content: ""; position: fixed; z-index: 999; inset: 0; pointer-events: none; opacity: .08; background: repeating-linear-gradient(0deg, transparent 0 3px, rgba(255,255,255,.035) 3px 4px); }
button, input, select, textarea { font: inherit; }
button { border: 0; cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .5; }
input, select, textarea {
  width: 100%; min-height: 42px; padding: 9px 11px;
  color: var(--ink-950); background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm); outline: none; transition: border-color .16s, box-shadow .16s;
}
textarea { min-height: 110px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--brand-600); box-shadow: 0 0 0 3px rgba(18, 133, 122, .12); }
:root[data-theme="dark"] input:focus, :root[data-theme="dark"] select:focus, :root[data-theme="dark"] textarea:focus { box-shadow: 0 0 0 3px rgba(32,245,237,.12), 0 0 22px rgba(32,245,237,.08); }
input[type="checkbox"] { width: 17px; min-height: 17px; accent-color: var(--brand-700); }
label { display: grid; gap: 6px; color: var(--ink-800); font-size: 13px; font-weight: 700; }
h1, h2, h3, h4, p { margin-top: 0; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.muted, .hint { color: var(--ink-600); }
.hint { margin: 0; font-size: 12px; }
.style-hint { min-height: 34px; color: var(--ink-600); font-size: 11px; font-weight: 550; line-height: 1.4; }
.small { font-size: 12px; }
.wide { width: 100%; }
.span-2 { grid-column: 1 / -1; }
.danger-text { color: var(--red); }

.primary, .secondary, .danger, .icon-button, .ghost, .text-button {
  min-height: 40px; border-radius: var(--radius-sm); font-weight: 750;
  transition: transform .12s, background .16s, border-color .16s, box-shadow .16s;
}
.primary:active, .secondary:active, .danger:active, .icon-button:active { transform: scale(.98); }
.primary { padding: 9px 15px; color: #fff; background: var(--brand-700); box-shadow: 0 5px 12px rgba(13, 111, 103, .16); }
.primary:hover { background: var(--brand-800); box-shadow: 0 7px 18px rgba(13, 111, 103, .22); }
.secondary { padding: 9px 14px; color: var(--ink-800); background: var(--surface); border: 1px solid var(--line-strong); }
.secondary:hover { color: var(--brand-800); border-color: #9fbab4; background: var(--brand-50); }
.danger { padding: 9px 14px; color: #fff; background: var(--red); }
.danger:hover { background: #912018; }
.icon-button { display: grid; place-items: center; width: 40px; padding: 0; color: var(--ink-600); background: var(--surface-2); border: 1px solid var(--line); font-size: 20px; }
.icon-button:hover { color: var(--brand-800); background: var(--brand-50); }
.text-button { min-height: 30px; padding: 3px 5px; color: var(--brand-700); background: transparent; }
.text-button:hover { color: var(--brand-900); text-decoration: underline; }
:root[data-theme="dark"] .primary { color: #001313; background: linear-gradient(135deg, var(--neon-cyan), #28c9ff); box-shadow: 0 0 18px rgba(32,245,237,.17); }
:root[data-theme="dark"] .primary:hover { background: linear-gradient(135deg, #85fffa, var(--neon-cyan)); box-shadow: 0 0 24px rgba(32,245,237,.3); }
:root[data-theme="dark"] .secondary { background: #0b141e; border-color: #284555; }
:root[data-theme="dark"] .secondary:hover { color: var(--neon-cyan); border-color: rgba(32,245,237,.62); background: #0d2028; box-shadow: 0 0 16px rgba(32,245,237,.08); }
:root[data-theme="dark"] .danger { color: #fff; background: linear-gradient(135deg, #d9305a, var(--red)); }

.login-screen {
  position: relative; isolation: isolate; min-height: 100vh; display: grid; place-items: center;
  padding: 28px; overflow: hidden; background: linear-gradient(145deg, #062f2e 0%, #0b625b 55%, #119287 100%);
}
.login-screen::before { content: ""; position: absolute; inset: 0; z-index: -2; opacity: .14; background-image: linear-gradient(rgba(255,255,255,.3) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.3) 1px, transparent 1px); background-size: 42px 42px; }
.login-orb { position: absolute; z-index: -1; border-radius: 999px; filter: blur(2px); background: rgba(151, 244, 220, .13); }
.login-orb-one { width: 500px; height: 500px; left: -170px; top: -190px; }
.login-orb-two { width: 370px; height: 370px; right: -70px; bottom: -130px; border: 1px solid rgba(255,255,255,.18); }
.login-panel { width: min(450px, 100%); display: grid; gap: 19px; padding: 34px; border: 1px solid rgba(255,255,255,.22); border-radius: 22px; background: var(--surface-glass-strong); box-shadow: 0 28px 90px rgba(3, 32, 30, .34); }
.login-panel h1 { margin-bottom: 6px; font-size: clamp(26px, 4vw, 34px); line-height: 1.15; letter-spacing: -.025em; }
.login-panel p { margin-bottom: 0; }
.login-brand, .brand { display: flex; align-items: center; gap: 12px; }
.login-brand { padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.login-brand small, .brand small { display: block; margin-top: 1px; color: var(--ink-500); }
.brand-mark { display: grid; place-items: center; flex: 0 0 43px; height: 43px; color: #fff; background: linear-gradient(145deg, #23b9a7, #087268); border-radius: 12px; font-weight: 900; }
.password-row { display: grid; grid-template-columns: 1fr 42px; gap: 7px; }

.app { min-height: 100vh; display: grid; grid-template-columns: 248px minmax(0, 1fr); transition: grid-template-columns .22s ease; }
.sidebar { position: sticky; top: 0; height: 100vh; display: grid; grid-template-rows: auto 1fr auto; gap: 28px; padding: 22px 16px; color: #e9f4f2; background: #102725; }
:root[data-theme="dark"] .sidebar { background: linear-gradient(180deg, #070b12 0%, #09121b 65%, #070a10 100%); border-right: 1px solid rgba(32,245,237,.17); box-shadow: 16px 0 55px rgba(0,0,0,.2); }
.sidebar-toggle { position: absolute; z-index: 3; top: 28px; right: -14px; width: 29px; min-height: 29px; display: grid; place-items: center; padding: 0; color: var(--brand-800); background: var(--surface); border: 1px solid var(--line-strong); border-radius: 999px; box-shadow: var(--shadow-sm); font-size: 22px; line-height: 1; transition: color .16s, background .16s, border-color .16s, transform .16s; }
.sidebar-toggle:hover { color: var(--brand-900); background: var(--brand-50); border-color: var(--brand-600); transform: scale(1.06); }
.sidebar-toggle:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(18,133,122,.22), var(--shadow-sm); }
:root[data-theme="dark"] .sidebar-toggle { color: var(--neon-cyan); background: #0b141e; border-color: #284555; box-shadow: 0 0 16px rgba(32,245,237,.12); }
.sidebar .brand { padding: 0 7px; }
.sidebar .brand small { color: #9bb4b0; }
.sidebar nav { display: grid; align-content: start; gap: 6px; }
.sidebar nav button { display: flex; align-items: center; gap: 11px; width: 100%; min-height: 44px; padding: 10px 12px; color: #c9d8d5; background: transparent; border-radius: 9px; text-align: left; }
.sidebar nav button:hover { color: #fff; background: rgba(255,255,255,.07); }
.sidebar nav button.active { color: #fff; background: linear-gradient(90deg, rgba(32, 174, 159, .24), rgba(32, 174, 159, .08)); box-shadow: inset 3px 0 #3dd2c0; }
:root[data-theme="dark"] .sidebar nav button.active { color: var(--neon-cyan); background: linear-gradient(90deg, rgba(32,245,237,.15), rgba(165,108,255,.06)); box-shadow: inset 2px 0 var(--neon-cyan), 0 0 22px rgba(32,245,237,.06); }
.nav-icon { display: grid; place-items: center; width: 22px; color: #7fd8ce; font-size: 18px; }
.sidebar-foot { display: grid; grid-template-columns: auto 1fr; gap: 4px 8px; align-items: center; padding: 13px 7px 0; color: #9bb4b0; border-top: 1px solid rgba(255,255,255,.1); }
.status-dot { width: 8px; height: 8px; background: #42d392; border-radius: 50%; box-shadow: 0 0 0 4px rgba(66,211,146,.12); }
.ghost { grid-column: 1 / -1; margin-top: 7px; padding: 8px 0; color: #d5e3e0; background: transparent; text-align: left; }
.ghost:hover { color: #fff; }

@media (min-width: 851px) {
  .app.sidebar-collapsed { grid-template-columns: 76px minmax(0, 1fr); }
  .sidebar-collapsed .sidebar { padding: 18px 11px; }
  .sidebar-collapsed .sidebar .brand > div,
  .sidebar-collapsed .sidebar nav button span:last-child,
  .sidebar-collapsed .sidebar-foot small,
  .sidebar-collapsed .sidebar-foot .status-dot { display: none; }
  .sidebar-collapsed .sidebar .brand { padding: 0; justify-content: center; }
  .sidebar-collapsed .sidebar nav button { justify-content: center; padding: 10px; }
  .sidebar-collapsed .sidebar-foot { display: block; padding: 10px 0 0; }
  .sidebar-collapsed .ghost { font-size: 0; text-align: center; }
  .sidebar-collapsed .ghost::after { content: "↪"; font-size: 21px; }
}

.main { min-width: 0; padding: 24px 28px 44px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 18px; max-width: 1540px; margin: 0 auto 20px; }
.topbar h2 { margin: 0; font-size: 28px; line-height: 1.15; letter-spacing: -.025em; }
.topbar-actions { display: flex; align-items: center; gap: 9px; }
.topbar .primary, .theme-toggle { white-space: nowrap; }
.theme-toggle { display: inline-flex; align-items: center; gap: 8px; }
.theme-icon { display: inline-grid; place-items: center; width: 18px; font-size: 17px; line-height: 1; }
.eyebrow { margin-bottom: 5px; color: var(--brand-700); font-size: 11px; font-weight: 900; letter-spacing: .12em; text-transform: uppercase; }
.view { max-width: 1540px; margin: 0 auto; }
.toast { position: fixed; z-index: 90; top: 20px; left: 50%; width: min(520px, calc(100% - 32px)); padding: 12px 16px; color: #fff; background: var(--brand-800); border-radius: var(--radius); box-shadow: var(--shadow-md); transform: translateX(-50%); text-align: center; font-weight: 700; }
.toast.danger { background: var(--red); }
.toast.warn { background: var(--amber); }

.stats { display: grid; grid-template-columns: repeat(5, minmax(145px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { position: relative; min-height: 116px; padding: 18px; overflow: hidden; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.stat::after { content: ""; position: absolute; right: -20px; bottom: -29px; width: 80px; height: 80px; border-radius: 50%; background: var(--brand-50); }
.stat-icon { display: grid; place-items: center; width: 32px; height: 32px; margin-bottom: 10px; color: var(--brand-700); background: var(--brand-100); border-radius: 9px; font-size: 17px; }
.stat span { display: block; color: var(--ink-600); font-size: 12px; font-weight: 700; }
.stat strong { display: block; margin-top: 2px; font-size: 25px; line-height: 1.1; }
.stat strong { font-family: var(--font-mono); }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 18px 19px; border-bottom: 1px solid var(--line); }
.panel-head h3, .panel-head p, .section-head h3, .section-head p { margin-bottom: 0; }
.panel-head h3, .section-head h3 { font-size: 17px; }
.actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.filters { display: grid; grid-template-columns: minmax(230px, 1fr) 230px auto; gap: 9px; align-items: center; }
.search-field { position: relative; }
.search-field::before { content: "⌕"; position: absolute; z-index: 1; left: 12px; top: 9px; color: var(--ink-500); font-size: 18px; }
.search-field input { padding-left: 36px; }
.count-pill { display: inline-grid; place-items: center; min-width: 24px; height: 24px; padding: 0 7px; color: var(--brand-800); background: var(--brand-100); border-radius: 999px; font-size: 12px; font-weight: 850; }
.table-wrap { width: 100%; overflow-x: auto; }
.dossier-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
.dossier-table th { position: sticky; z-index: 1; top: 0; padding: 11px 12px; color: var(--ink-600); background: var(--table-head); border-bottom: 1px solid var(--line); font-size: 11px; font-weight: 850; letter-spacing: .035em; text-align: left; text-transform: uppercase; white-space: nowrap; }
.dossier-table th { font-family: var(--font-mono); }
.dossier-table td { padding: 13px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.dossier-table tbody tr:nth-child(even) { background: var(--table-alt); }
.dossier-table tbody tr:hover { background: var(--brand-50); }
.dossier-table tbody tr:last-child td { border-bottom: 0; }
.dossier-table td small { display: block; margin-top: 3px; color: var(--ink-600); }
.check-cell { width: 46px; text-align: center !important; }
.action-cell { width: 1%; white-space: nowrap; }
.record-link { display: block; min-height: 28px; padding: 0; color: var(--ink-950); background: transparent; text-align: left; font-weight: 850; }
.record-link { font-family: var(--font-mono); }
.record-link:hover { color: var(--brand-700); }
.company-flow-cell { min-width: 190px; }
.company-flow-main { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.flow-classification { display: inline-flex; align-items: center; width: fit-content; padding: 3px 7px; color: var(--ink-600); background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; font-size: 9px; font-weight: 850; letter-spacing: .025em; line-height: 1.2; white-space: nowrap; }
.flow-classification.vn { color: #b3261e; background: #ffe9e7; border-color: #f5c2bd; }
.row-actions { display: flex; justify-content: flex-end; gap: 6px; }
.row-actions button { min-height: 32px; padding: 5px 9px; }
.row-actions .danger-icon { color: var(--red); font-size: 19px; }
.row-actions .danger-icon:hover { color: #fff; background: var(--red); border-color: var(--red); }
.badge { display: inline-flex; align-items: center; gap: 7px; padding: 5px 9px; color: var(--ink-800); background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; font-size: 11px; font-weight: 800; white-space: nowrap; }
.badge i { width: 7px; height: 7px; background: var(--ink-500); border-radius: 50%; }
.badge.ok { color: var(--green); background: var(--green-bg); border-color: #c7ebd2; }
.badge.ok i { background: var(--green); }
.badge.info { color: var(--blue); background: var(--blue-bg); border-color: #cbdcff; }
.badge.info i { background: var(--blue); }
.badge.warn { color: var(--amber); background: var(--amber-bg); border-color: #f2d492; }
.badge.warn i { background: #d18400; }
.badge.danger { color: var(--red); background: var(--red-bg); border-color: #f6c7c3; }
.badge.danger i { background: var(--red); }
.badge.forced { border-style: dashed; }
.badge.forced i { background: transparent; box-shadow: inset 0 0 0 2px currentColor; }
.empty { padding: 34px 18px; color: var(--ink-600); text-align: center; }
.empty-icon { display: grid; place-items: center; width: 48px; height: 48px; margin: 0 auto 10px; color: var(--brand-700); background: var(--brand-50); border-radius: 15px; font-size: 24px; }

.detail-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 16px; padding: 20px; background: linear-gradient(135deg, var(--surface), var(--brand-50)); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.party-email-route { display:flex; align-items:center; gap:14px; margin-top:12px; }
.party-email-route > div { display:grid; gap:2px; min-width:210px; padding:10px 12px; background:var(--surface-2); border:1px solid var(--line); border-radius:10px; }
.party-email-route span { color:var(--ink-500); font-size:10px; font-weight:800; letter-spacing:.08em; text-transform:uppercase; }
.party-email-route a { color:var(--brand-700); font-size:12px; overflow-wrap:anywhere; }
.party-email-route b { color:var(--brand-600); }
.detail-title-row { display: flex; align-items: center; gap: 10px; margin-bottom: 5px; flex-wrap: wrap; }
.detail-title-row h3 { margin: 0; font-size: 23px; }
.summary-grid { display: grid; grid-template-columns: repeat(4, minmax(160px, 1fr)); gap: 10px; margin-bottom: 16px; }
.info-box { min-height: 85px; padding: 15px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.info-box span { display: block; margin-bottom: 6px; color: var(--ink-600); font-size: 11px; font-weight: 800; text-transform: uppercase; }
.info-box strong { display: block; overflow-wrap: anywhere; font-size: 14px; }
.detail-grid { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(320px, .75fr); gap: 16px; }
.detail-grid > .panel { min-width: 0; }
.section-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 18px 19px 10px; }
.pipeline { display: grid; grid-template-columns: repeat(4, minmax(145px, 1fr)); gap: 10px; align-items: stretch; padding: 12px 19px 20px; }
.pipeline.pipeline-vn { grid-template-columns:repeat(6, minmax(132px, 1fr)); overflow-x:auto; }
.pipeline-step { min-height: 125px; padding: 16px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); }
.pipeline-step { position: relative; width: 100%; color: inherit; text-align: left; }
.pipeline-step:not(:last-child)::before { content: ""; position: absolute; z-index: 2; top: 32px; left: calc(100% + 1px); width: 10px; height: 1px; background: var(--line-strong); }
.pipeline-step:hover { border-color: var(--brand-600); transform: translateY(-1px); }
.pipeline-step.automated::after { content: "AUTO"; position: absolute; top: 10px; right: 10px; color: var(--neon-violet); font-size: 9px; font-weight: 900; letter-spacing: .1em; }
.pipeline-step.current, .pipeline-step.done { background: var(--brand-50); border-color: var(--line-strong); }
.pipeline-step.done { border-color: color-mix(in srgb, var(--green) 48%, var(--line)); box-shadow: 0 0 14px color-mix(in srgb, var(--green) 12%, transparent); }
.pipeline-step.current { animation: current-step-pulse 2.2s ease-in-out infinite; }
.pipeline-step strong { display: block; margin-bottom: 5px; }
.pipeline-step > span { display: grid; place-items: center; width: 25px; height: 25px; margin-bottom: 10px; color: var(--brand-800); background: var(--brand-100); border-radius: 7px; font-size: 11px; font-weight: 900; }
.pipeline-step small, .pipeline-step em { display: block; }
.pipeline-step small { min-height: 35px; color: var(--ink-600); }
.pipeline-step em { margin-top: 8px; color: var(--brand-700); font-size: 11px; font-style: normal; font-weight: 800; }
@keyframes current-step-pulse { 0%, 100% { box-shadow: none; } 50% { box-shadow: var(--glow-cyan); } }
.flow-arrow { display: grid; place-items: center; color: #9aaca8; font-size: 20px; }
.completion-note { margin: 0 19px 19px; padding: 12px; color: var(--green); background: var(--green-bg); border: 1px solid #c7ebd2; border-radius: var(--radius-sm); font-weight: 750; }
.completion-note.forced { border-style: dashed; font-weight: 650; line-height: 1.5; }
.file-list { display: grid; gap: 8px; padding: 5px 19px 19px; }
.file-row { display: grid; grid-template-columns: 38px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 10px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 9px; }
.file-row strong, .file-row small { display: block; }
.file-row small { margin-top: 2px; color: var(--ink-600); }
.file-row .signature-file-state { color: var(--green); font-weight: 800; }
.windows-signer-panel { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 12px; align-items: center; margin: 0 22px 16px; padding: 14px 16px; color: var(--ink-950); background: var(--brand-50); border: 1px solid var(--line-strong); border-left: 3px solid var(--neon-cyan); border-radius: var(--radius); }
.windows-signer-panel.verified { background: var(--green-bg); border-color: #b8dfc5; border-left-color: var(--green); }
.windows-signer-panel strong, .windows-signer-panel p { margin: 0; }
.windows-signer-panel p { margin-top: 3px; color: var(--ink-600); font-size: 12px; }
.signer-state-icon { display: grid; place-items: center; min-width: 38px; height: 38px; padding: 0 7px; color: var(--brand-800); background: var(--surface); border: 1px solid var(--line-strong); border-radius: 10px; font: 900 10px/1 var(--font-mono); }
.windows-signer-panel.verified .signer-state-icon, .windows-signer-dialog-state.verified .signer-state-icon { color: var(--green); }
.windows-signer-dialog-state { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 12px; align-items: center; padding: 14px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); }
.windows-signer-dialog-state.is-danger { color: var(--red); border-color: #efb5b5; background: var(--red-bg); }
.windows-signer-dialog-state.is-danger p { color: var(--ink-800); }
.windows-signer-dialog-state strong, .windows-signer-dialog-state p { margin: 0; }
.windows-signer-dialog-state p { margin-top: 4px; color: var(--ink-600); font-size: 12px; }
.windows-signer-admin-help { margin-top: 14px; padding: 13px 14px; color: var(--ink-800); background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); }
.windows-signer-admin-help strong, .windows-signer-admin-help p, .windows-signer-guide-title, .windows-signer-first-run { margin: 0; }
.windows-signer-admin-help p, .windows-signer-first-run { margin-top: 5px; color: var(--ink-600); font-size: 12px; line-height: 1.5; }
.windows-signer-setup { margin-top: 14px; padding: 0 2px; }
.windows-signer-guide-title { margin-top: 16px; color: var(--ink-800); font-size: 13px; font-weight: 800; }
.windows-signer-steps { display: grid; gap: 10px; margin: 16px 0; padding-left: 22px; color: var(--ink-800); font-size: 13px; }
.preview-automation { display: flex; flex: 1; align-items: center; gap: 8px; min-width: 0; font-size: 12px; color: var(--ink-600); }
.preview-automation select { max-width: 420px; min-width: 0; }
.windows-signer-agent-link { margin-top: 14px; padding: 12px 14px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); }
.windows-signer-launch-url { display: block; margin: 8px 0 10px; padding: 8px 10px; color: var(--ink-800); background: var(--brand-50); border: 1px dashed var(--line-strong); border-radius: 8px; font-size: 11px; line-height: 1.5; word-break: break-all; user-select: all; }
.pdf-icon { display: grid; place-items: center; width: 36px; height: 40px; color: #fff; background: #d74c3c; border-radius: 6px; font-size: 10px; font-weight: 900; }
.email-preview { margin: 5px 19px 19px; padding: 14px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); }
.email-preview h4 { margin-bottom: 8px; }
.source-pill, .role-pill { display: inline-flex; align-items: center; width: fit-content; padding: 4px 8px; color: var(--brand-800); background: var(--brand-100); border-radius: 999px; font-size: 10px; font-weight: 850; }
.source-codex-cli { color: var(--neon-cyan); border: 1px solid rgba(32,245,237,.25); }
.source-claude { color: var(--neon-violet); border: 1px solid rgba(165,108,255,.3); }
.source-library { color: var(--amber); border: 1px solid rgba(255,209,102,.25); }
.source-fallback { color: var(--neon-magenta); border-color: rgba(255,46,154,.34); }
.inline-alert { margin: 8px 0 12px; padding: 8px 10px; border-radius: 8px; font-size: 12px; line-height: 1.45; }
.inline-alert.warning { color: #8a4b08; background: #fff4dc; border: 1px solid #f1cf92; }
.language-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
.language-card { min-width: 0; padding: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 9px; }
.language-card h5 { margin: 0 0 7px; }
.language-card p { margin-bottom: 7px; overflow-wrap: anywhere; white-space: pre-wrap; }
.language-card.translation { background: var(--surface-2); }

.email-ledger { margin-top: 16px; overflow: hidden; }
.email-record-list { display: grid; gap: 12px; padding: 16px 19px 19px; }
.email-record-card { scroll-margin-top: 18px; padding: 16px; overflow: hidden; background: var(--surface-2); border: 1px solid var(--line); border-left: 3px solid var(--ink-500); border-radius: var(--radius); transition: border-color .2s, box-shadow .2s, transform .2s; }
.email-record-card.tone-sent { border-left-color: var(--green); }
.email-record-card.tone-scheduled { border-left-color: var(--neon-violet); }
.email-record-card.tone-draft { border-left-color: var(--neon-cyan); }
.email-record-card.tone-failed { border-left-color: var(--red); }
.email-record-head { display: grid; grid-template-columns: auto minmax(0, 1fr) minmax(180px, auto); gap: 13px; align-items: start; }
.email-record-head h4, .email-record-head p { margin-bottom: 0; overflow-wrap: anywhere; }
.mail-index { display: grid; place-items: center; width: 36px; height: 36px; color: var(--brand-800); background: var(--brand-100); border: 1px solid var(--line-strong); border-radius: 8px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 11px; font-weight: 900; }
.email-route { margin-top: 5px; color: var(--ink-600); font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 11px; }
.message-id { display: block; margin-top: 4px; color: var(--ink-500); font-family: var(--font-mono); font-size: 9px; overflow-wrap: anywhere; }
.email-record-state { display: grid; justify-items: end; gap: 7px; }
.record-state { padding: 5px 8px; border: 1px solid var(--line); border-radius: 5px; color: var(--ink-600); background: var(--surface); font-size: 10px; font-weight: 850; text-align: right; }
.record-state.sent { color: var(--green); border-color: rgba(77,255,156,.28); }
.record-state.scheduled { color: var(--neon-violet); border-color: rgba(165,108,255,.3); }
.record-state.draft { color: var(--brand-700); border-color: rgba(32,245,237,.28); }
.record-state.failed { color: var(--red); border-color: rgba(255,102,127,.3); }
.schedule-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.email-record-details { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.email-record-details > summary, .archived-email-history > summary { color: var(--brand-700); cursor: pointer; font-size: 12px; font-weight: 800; }
.email-record-details .email-preview, .archived-email-history .email-preview { max-width: 100%; margin: 8px 0 0; overflow-x: auto; white-space: pre-wrap; overflow-wrap: anywhere; word-break: break-word; }
.email-record-details .language-card { overflow: hidden; }
.archived-email-history { margin: 0 19px 19px; padding: 14px; background: var(--surface-2); border: 1px dashed var(--line-strong); border-radius: var(--radius); }
.archived-email-history section { margin-top: 13px; padding: 13px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; }
.archived-email-history section > h4 { color: var(--ink-600); font-size: 12px; }
.archived-email-history article { display: grid; gap: 3px; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--line); }
.archived-email-history small { color: var(--ink-600); }
.control-actions { padding: 17px 19px; }
.attention-flash { animation: attention-flash 1.45s ease-out; }
@keyframes attention-flash { 0%, 30% { border-color: var(--neon-cyan); box-shadow: 0 0 0 3px rgba(32,245,237,.14), 0 0 30px rgba(32,245,237,.18); } 100% { box-shadow: none; } }

.company-grid { display: grid; grid-template-columns: repeat(2, minmax(300px, 1fr)); gap: 12px; padding: 16px; }
.company-card { min-width: 0; padding: 16px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); }
.company-card-head { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.company-card-head > .badge { align-self: flex-start; min-height: 30px; padding: 6px 10px; border-radius: 6px; }
.company-card-head > .mailbox-status { max-width: 155px; justify-content: center; line-height: 1.25; text-align: center; white-space: normal; }
.mailbox-status i { flex: none; }
.company-card h4 { margin: 0 0 4px; overflow-wrap: anywhere; }
.company-card p { margin-bottom: 5px; color: var(--ink-600); font-size: 13px; overflow-wrap: anywhere; }
.company-card dl { display: grid; grid-template-columns: 84px 1fr; gap: 7px 10px; margin: 0 0 14px; font-size: 12px; }
.company-card dt { color: var(--ink-600); font-weight: 750; }
.company-card dd { margin: 0; overflow-wrap: anywhere; }
.role-pill.provider { color: #075e54; background: #dff6f0; }
.role-pill.client { color: #2855a5; background: #eaf1ff; }

/* Cờ VN trên thẻ công ty: đứng cạnh role-pill, cùng chiều cao, đủ tương phản ở cả hai theme. */
.vn-flag { display: inline-flex; align-items: center; gap: 4px; width: fit-content; margin-left: 6px; padding: 4px 8px; color: #b3261e; background: #ffe9e7; border: 1px solid #f5c2bd; border-radius: 999px; font-size: 10px; font-weight: 850; letter-spacing: .02em; }

/* Ô tick trong form công ty: label mặc định là grid nên checkbox phải tự bố cục lại. */
.checkbox-field { display: flex; align-items: flex-start; gap: 10px; font-weight: 600; }
.checkbox-field input[type="checkbox"] { width: 18px; height: 18px; margin-top: 1px; flex: none; accent-color: var(--brand-600, #0f766e); }
.bank-vn-note { margin: 0; padding: 10px 12px; color: var(--muted, #64748b); background: var(--surface-2, rgba(148, 163, 184, .12)); border-radius: 10px; font-size: 12px; line-height: 1.5; }
.bank-currency-panel { min-width: 0; margin: 8px 0 16px; padding: 14px; border: 1px solid var(--line-strong); border-radius: 12px; background: var(--surface-2); }
.bank-currency-panel legend { padding: 0 6px; font-weight: 700; }
.bank-currency-panel > button { margin-top: 12px; }
.bank-currency-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 12px; }
.bank-currency-head div { display: grid; gap: 3px; }
.bank-currency-head strong { font-size: 13px; }
.bank-currency-head small { color: var(--ink-600); font-size: 11px; }
.bank-currency-head > span { padding: 3px 8px; border: 1px solid var(--line-strong); border-radius: 999px; color: var(--neon-cyan); font-size: 10px; font-weight: 800; letter-spacing: .08em; }
.timeline { display: grid; gap: 0; padding: 8px 19px 20px; }
.timeline-item { position: relative; display: grid; grid-template-columns: 18px minmax(0,1fr); gap: 11px; padding-bottom: 17px; }
.timeline-item:not(:last-child)::before { content: ""; position: absolute; left: 6px; top: 13px; bottom: -1px; width: 1px; background: var(--line-strong); }
.timeline-dot { z-index: 1; width: 13px; height: 13px; margin-top: 3px; background: var(--brand-600); border: 3px solid var(--brand-100); border-radius: 50%; }
.timeline-item p { margin-bottom: 2px; }
.timeline-item small { color: var(--ink-600); }

.dialog { width: min(680px, calc(100% - 28px)); max-height: calc(100vh - 32px); padding: 0; overflow: auto; color: var(--ink-950); background: var(--surface); border: 0; border-radius: var(--radius-lg); box-shadow: 0 30px 100px rgba(5, 43, 40, .3); }
.dialog::backdrop { background: rgba(7, 27, 26, .58); backdrop-filter: blur(3px); }
.dialog-wide { width: min(920px, calc(100% - 28px)); }
.dialog-preview { width: min(1280px, calc(100% - 28px)); }
.dialog-compact { width: min(520px, calc(100% - 28px)); }
.dialog-body { display: grid; gap: 14px; padding: 20px 22px; }
.confirm-dialog { width: min(500px, calc(100% - 28px)); overflow: hidden; }
.confirm-content { padding: 27px 28px 20px; text-align: center; }
.confirm-content h3 { margin-bottom: 8px; font-size: 22px; }
.confirm-content > p:not(.eyebrow) { color: var(--ink-600); }
.confirm-icon { display: grid; place-items: center; width: 48px; height: 48px; margin: 0 auto 14px; color: var(--brand-800); background: var(--brand-100); border: 1px solid var(--line-strong); border-radius: 10px; font-size: 23px; font-weight: 900; }
.confirm-dialog.confirm-danger .confirm-icon { color: var(--red); background: var(--red-bg); border-color: rgba(255,102,127,.35); }
.confirm-consequence { margin: 14px 0 0; padding: 11px; color: var(--amber) !important; background: var(--amber-bg); border: 1px solid rgba(255,209,102,.24); border-radius: var(--radius-sm); font-size: 12px; }
.dialog-head { position: sticky; z-index: 3; top: 0; display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 19px 22px; background: var(--surface-glass); border-bottom: 1px solid var(--line); backdrop-filter: blur(10px); }
.dialog-head h3 { margin: 0; font-size: 20px; }
.form-sections { display: grid; gap: 12px; padding: 17px 22px; background: var(--surface-2); }
.form-section { padding: 17px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.section-title { display: flex; justify-content: space-between; gap: 14px; margin-bottom: 15px; padding-bottom: 13px; border-bottom: 1px solid var(--line); }
.section-title > div { display: flex; align-items: center; gap: 9px; }
.section-title h4, .section-title p { margin: 0; }
.section-title p { color: var(--ink-600); font-size: 12px; text-align: right; }
.section-index { display: grid; place-items: center; width: 29px; height: 29px; color: var(--brand-800); background: var(--brand-100); border-radius: 8px; font-size: 11px; font-weight: 900; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid > label { align-self: start; align-content: start; }
.derived-box { display: flex; gap: 10px; margin: 0; padding: 12px; color: var(--brand-900); background: var(--brand-50); border: 1px solid var(--line-strong); border-radius: var(--radius-sm); font-size: 12px; }
.derived-box > span:first-child { font-size: 18px; }
.bank-section { transform-origin: top; transition: opacity .16s, transform .16s; }
.bank-section.is-hidden { display: none; opacity: 0; transform: translateY(-5px); }
.dialog-actions { position: sticky; z-index: 3; bottom: 0; display: flex; justify-content: flex-end; gap: 9px; padding: 15px 22px; background: var(--surface-glass-strong); border-top: 1px solid var(--line); backdrop-filter: blur(10px); }
.preview-toolbar { display: flex; align-items: flex-start; gap: 10px; padding: 14px 22px; background: var(--surface-2); border-bottom: 1px solid var(--line); }
.preview-toolbar label { width: 340px; }
.preview-toolbar > button { margin-top: 23px; }
.preview-safe-note { align-self: center; margin-left: auto; padding: 7px 10px; color: var(--green); background: var(--green-bg); border: 1px solid #c7ebd2; border-radius: 999px; font-size: 11px; font-weight: 800; }
.preview-generation-progress { display: grid; gap: 11px; margin: 14px 22px 0; padding: 14px 16px; color: var(--ink-950); background: linear-gradient(135deg, var(--brand-50), var(--surface-2)); border: 1px solid var(--line-strong); border-left: 3px solid var(--neon-cyan); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.preview-progress-head { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 11px; align-items: center; }
.preview-progress-head strong, .preview-progress-head small { display: block; }
.preview-progress-head small { margin-top: 2px; color: var(--ink-600); font-size: 11px; }
.preview-progress-icon { display: grid; place-items: center; width: 31px; height: 31px; color: var(--brand-700); background: var(--brand-100); border: 1px solid var(--line-strong); border-radius: 8px; font-size: 17px; animation: spin 1.2s linear infinite; }
.preview-progress-count { color: var(--brand-700); font-family: var(--font-mono); font-size: 12px; font-weight: 900; }
.preview-progress-track { height: 5px; overflow: hidden; background: var(--line); border-radius: 999px; }
.preview-progress-track > span { display: block; width: 0; height: 100%; background: linear-gradient(90deg, var(--neon-cyan), var(--neon-violet)); border-radius: inherit; box-shadow: 0 0 13px rgba(34,211,238,.35); transition: width .3s ease; }
.preview-complete { display: grid; min-width: 0; background: var(--surface-2); }
.preview-documents, .preview-email-suite { min-width: 0; padding: 20px 22px; }
.preview-documents { border-bottom: 1px solid var(--line); }
.preview-documents .file-list { grid-template-columns: repeat(3, minmax(0, 1fr)); padding: 0; }
.preview-email-suite { background: var(--surface); }
.preview-section-title { display: flex; gap: 10px; margin-bottom: 15px; }
.preview-section-title > span { display: grid; place-items: center; width: 28px; height: 28px; color: var(--brand-800); background: var(--brand-100); border-radius: 8px; font-size: 11px; font-weight: 900; }
.preview-section-title h4, .preview-section-title p { margin: 0; }
.preview-section-title p { color: var(--ink-600); font-size: 12px; }
.email-suite { display: grid; gap: 14px; min-width: 0; }
.email-step-card { min-width: 0; padding: 16px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); }
.email-step-head { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 13px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.email-step-head > span { flex: 0 0 auto; padding: 5px 8px; color: var(--brand-800); background: var(--brand-100); border-radius: 6px; font-size: 10px; font-weight: 900; letter-spacing: .04em; }
.email-step-head h4, .email-step-head p { margin: 0; overflow-wrap: anywhere; }
.email-step-head p { margin-top: 3px; color: var(--ink-600); font-size: 12px; }
.email-step-card .email-preview { max-width: 100%; margin: 8px 0 0; overflow-x: auto; white-space: pre-wrap; overflow-wrap: anywhere; word-break: break-word; }
.email-step-card .language-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.email-step-card .language-card { min-width: 0; overflow: hidden; }
.compact-preview .language-grid { grid-template-columns: 1fr; }

.loading-overlay { position: fixed; z-index: 200; inset: 0; display: grid; place-items: center; padding: 20px; background: rgba(8, 32, 30, .55); backdrop-filter: blur(4px); }
.loading-card { width: min(330px, 100%); display: grid; justify-items: center; gap: 8px; padding: 27px; color: var(--ink-950); background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-md); text-align: center; }

/* Document template center */
.template-hero { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; margin-bottom: 14px; padding: 22px 24px; overflow: hidden; background: linear-gradient(135deg, var(--surface), var(--brand-50)); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); }
.template-hero h3 { margin-bottom: 7px; font-size: 25px; letter-spacing: -.025em; }
.template-hero p:not(.eyebrow) { max-width: 780px; margin-bottom: 0; color: var(--ink-600); }
.template-hero .actions { flex: none; }
.template-flow-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; align-items: start; }
.template-flow-panel { min-width: 0; overflow: hidden; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); }
.template-flow-head { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 18px; background: var(--surface-2); border-bottom: 1px solid var(--line); }
.template-flow-head h3, .template-flow-head p { margin-bottom: 0; }
.template-flow-head h3 { font-size: 17px; }
.template-flow-head p:not(.eyebrow) { color: var(--ink-600); font-size: 11px; }
.template-flow-icon { display: grid; place-items: center; width: 39px; height: 39px; color: var(--brand-800); background: var(--brand-100); border: 1px solid var(--line); border-radius: 11px; font-size: 18px; }
.template-flow-count { padding: 5px 8px; color: var(--green); background: var(--green-bg); border: 1px solid rgba(21,128,61,.22); border-radius: 999px; font-size: 10px; font-weight: 850; white-space: nowrap; }
.template-card-list { display: grid; gap: 9px; padding: 11px; }
.template-card { display: grid; gap: 10px; padding: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); transition: border-color .16s, transform .16s, box-shadow .16s; }
.template-card:hover { border-color: var(--line-strong); transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.template-card-head { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.template-card-head h4 { margin: 2px 0 0; font-size: 14px; line-height: 1.3; }
.template-type { color: var(--brand-700); font-size: 10px; font-weight: 850; letter-spacing: .04em; text-transform: uppercase; }
.template-status { display: inline-flex; align-items: center; gap: 5px; padding: 4px 7px; color: var(--ink-600); background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; font-size: 9px; font-weight: 850; white-space: nowrap; }
.template-status i { width: 6px; height: 6px; background: currentColor; border-radius: 50%; }
.template-status.active { color: var(--green); background: var(--green-bg); }
.template-description, .template-card-note { margin: 0; color: var(--ink-600); font-size: 11px; }
.template-card-note { padding: 7px 9px; background: var(--surface-2); border-radius: 7px; }
.template-card-actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; padding-top: 2px; }
.template-replace-body { display: grid; gap: 12px; background: var(--surface-2); }
.template-current-slot { display: grid; gap: 3px; padding: 14px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.template-current-slot > span { color: var(--brand-700); font-size: 10px; font-weight: 850; letter-spacing: .04em; text-transform: uppercase; }
.template-current-slot > strong { font-size: 16px; }
.template-current-slot > small { color: var(--ink-600); }
.template-upload-field { display: grid; gap: 8px; padding: 15px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.template-upload-field > span { font-weight: 800; }
.template-upload-field > span b { margin-left: 5px; color: var(--brand-700); font-size: 9px; letter-spacing: .035em; text-transform: uppercase; }
.template-upload-field.optional > span b { color: var(--ink-500); }
.template-upload-field input[type="file"] { padding: 9px; background: var(--surface-2); border-style: dashed; }
.template-upload-field small { color: var(--ink-600); font-size: 11px; line-height: 1.45; }
.template-safety-note { margin: 0; }
:root[data-theme="dark"] .template-hero { background: linear-gradient(135deg, rgba(34,211,238,.055), rgba(168,85,247,.045)); }
:root[data-theme="dark"] .template-card:hover { border-color: #315c70; box-shadow: 0 0 24px rgba(34,211,238,.045); }
:root[data-theme="dark"] .template-flow-icon { box-shadow: inset 0 0 18px rgba(34,211,238,.06); }

:root[data-theme="dark"] .badge.ok { border-color: #286843; }
:root[data-theme="dark"] .badge.info { border-color: #31578d; }
:root[data-theme="dark"] .badge.warn { border-color: #725426; }
:root[data-theme="dark"] .badge.danger { border-color: #713532; }
:root[data-theme="dark"] .badge.violet { color: var(--neon-violet); background: #211735; border-color: #51377c; }
:root[data-theme="dark"] .badge.violet i { background: var(--neon-violet); }
:root[data-theme="dark"] .badge.auto { border-color: rgba(165,108,255,.65); box-shadow: 0 0 14px rgba(165,108,255,.12); }
:root[data-theme="dark"] .badge.auto i { animation: neon-pulse 1.8s ease-in-out infinite; }
:root[data-theme="dark"] .role-pill.provider { color: #80e6d5; background: #17463f; }
:root[data-theme="dark"] .role-pill.client { color: #9fc1ff; background: #1b3156; }
:root[data-theme="dark"] .flow-classification.vn { color: #ffaaa3; background: rgba(239,68,68,.12); border-color: rgba(248,113,113,.32); }
:root[data-theme="dark"] .inline-alert.warning { color: #ffd189; background: #3b2b12; border-color: #725426; }
:root[data-theme="dark"] .preview-safe-note, :root[data-theme="dark"] .completion-note { border-color: #286843; }
:root[data-theme="dark"] .preview-generation-progress { background: linear-gradient(135deg, rgba(34,211,238,.07), rgba(168,85,247,.045)); border-color: #24465b; box-shadow: 0 0 22px rgba(34,211,238,.055); }
:root[data-theme="dark"] .windows-signer-panel { background: linear-gradient(135deg, rgba(34,211,238,.08), rgba(168,85,247,.04)); border-color: #24465b; }
:root[data-theme="dark"] .windows-signer-panel.verified { background: rgba(34,197,94,.08); border-color: #286843; }
:root[data-theme="dark"] .panel, :root[data-theme="dark"] .stat, :root[data-theme="dark"] .info-box, :root[data-theme="dark"] .detail-head { box-shadow: var(--shadow-sm); }
:root[data-theme="dark"] .panel:hover, :root[data-theme="dark"] .stat:hover { border-color: #294b5c; }
:root[data-theme="dark"] .stat::after { width: 100px; height: 100px; background: radial-gradient(circle, rgba(32,245,237,.12), transparent 68%); }
:root[data-theme="dark"] .email-preview { color: #bffdf7; background: #050a0f; border-color: #183543; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; line-height: 1.58; }
:root[data-theme="dark"] .email-record-card:hover { border-color: #2c5768; box-shadow: 0 0 25px rgba(32,245,237,.055); }
:root[data-theme="dark"] .dialog { border: 1px solid rgba(32,245,237,.19); box-shadow: var(--shadow-md); }
:root[data-theme="dark"] .dialog::backdrop { background: rgba(0,3,8,.76); }
:root[data-theme="dark"] .toast { color: #001313; background: var(--neon-cyan); box-shadow: 0 0 30px rgba(32,245,237,.25); }
:root[data-theme="dark"] .toast.danger { color: #fff; background: var(--red); box-shadow: 0 0 28px rgba(255,102,127,.2); }
:root[data-theme="dark"] .toast.warn { color: #1c1300; background: var(--amber); box-shadow: 0 0 28px rgba(255,209,102,.2); }
@keyframes neon-pulse { 0%, 100% { opacity: .45; box-shadow: 0 0 0 rgba(165,108,255,0); } 50% { opacity: 1; box-shadow: 0 0 9px var(--neon-violet); } }
.loading-card small { color: var(--ink-600); }
.spinner { width: 36px; height: 36px; margin-bottom: 5px; border: 3px solid var(--brand-100); border-top-color: var(--brand-700); border-radius: 50%; animation: spin .75s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 1180px) {
  .stats { grid-template-columns: repeat(3, 1fr); }
  .summary-grid { grid-template-columns: repeat(2, 1fr); }
  .detail-grid { grid-template-columns: 1fr; }
  .pipeline-step { min-height: 0; }
  .template-flow-grid { grid-template-columns: 1fr; }
}
@media (max-width: 850px) {
  .sidebar-toggle { display: none; }
  .app { grid-template-columns: 76px minmax(0,1fr); }
  .sidebar { padding: 18px 11px; }
  .sidebar .brand > div, .sidebar nav button span:last-child, .sidebar-foot small, .sidebar-foot .status-dot { display: none; }
  .sidebar .brand { padding: 0; justify-content: center; }
  .sidebar nav button { justify-content: center; padding: 10px; }
  .sidebar-foot { display: block; padding: 10px 0 0; }
  .ghost { font-size: 0; text-align: center; }
  .ghost::after { content: "↪"; font-size: 21px; }
  .main { padding: 20px 18px 38px; }
  .filters { grid-template-columns: 1fr 180px; }
  .filters .actions { grid-column: 1 / -1; }
  .company-grid { grid-template-columns: 1fr; }
  .preview-documents .file-list { grid-template-columns: 1fr; }
  .windows-signer-panel { grid-template-columns: auto 1fr; margin-inline: 12px; }
  .windows-signer-panel > button { grid-column: 1 / -1; }
}
@media (max-width: 620px) {
  .app { display: block; padding-bottom: 70px; }
  .sidebar { position: fixed; z-index: 40; top: auto; right: 0; bottom: 0; left: 0; width: auto; height: 66px; display: block; padding: 7px 10px; border-top: 1px solid rgba(255,255,255,.12); }
  .sidebar .brand, .sidebar-foot { display: none; }
  .sidebar nav { display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px; }
  .sidebar nav button { display: grid; justify-items: center; gap: 0; min-height: 52px; padding: 3px 6px; font-size: 10px; text-align: center; }
  .sidebar nav button span:last-child { display: block; }
  .nav-icon { height: 22px; font-size: 17px; }
  .main { padding: 17px 12px 28px; }
  .topbar { align-items: flex-start; }
  .topbar h2 { font-size: 23px; }
  .topbar .eyebrow { display: none; }
  .topbar .primary { min-height: 38px; padding: 8px 10px; font-size: 12px; }
  .theme-toggle { min-width: 40px; min-height: 38px; padding: 8px 10px; }
  .theme-label { display: none; }
  .stats { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .stat { min-height: 95px; padding: 13px; }
  .stat-icon { margin-bottom: 5px; }
  .filters { grid-template-columns: 1fr; }
  .filters .actions { grid-column: auto; }
  .panel-head, .detail-head { display: grid; }
  .party-email-route { display:grid; grid-template-columns:1fr; }
  .party-email-route > b { transform:rotate(90deg); justify-self:start; margin-left:16px; }
  .detail-head .actions { justify-content: stretch; }
  .detail-head .actions button { flex: 1; }
  .summary-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .pipeline { grid-template-columns: 1fr; gap: 8px; }
  .pipeline-step:not(:last-child)::before { top: 100%; left: 31px; width: 1px; height: 8px; }
  .flow-arrow { transform: rotate(90deg); }
  .language-grid { grid-template-columns: 1fr; }
  .email-record-head { grid-template-columns: auto minmax(0, 1fr); }
  .email-record-state { grid-column: 1 / -1; justify-items: start; padding-left: 49px; }
  .schedule-actions { justify-content: flex-start; }
  .email-step-card .language-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .section-title { display: block; }
  .section-title p { margin-top: 7px; text-align: left; }
  .dialog-actions { flex-wrap: wrap; }
  .dialog-actions button { flex: 1; }
  .preview-toolbar { display: grid; grid-template-columns: 1fr auto; align-items: end; }
  .preview-toolbar label { width: auto; }
  .preview-toolbar > button { margin-top: 0; }
  .preview-safe-note { grid-column: 1 / -1; margin: 0; text-align: center; }
  .preview-generation-progress { margin: 10px 12px 0; }
  .login-panel { padding: 25px 20px; }
  .template-hero { display: grid; align-items: start; padding: 17px; }
  .template-hero .actions { width: 100%; }
  .template-hero .actions button { flex: 1; }
  .template-flow-head { grid-template-columns: auto minmax(0, 1fr); }
  .template-flow-count { grid-column: 2; justify-self: start; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}


/* --- Widget trạng thái Codex ở topbar ------------------------------------ */
.codex-status { width: min(440px, 42vw); display: grid; gap: 5px; padding: 8px 12px; color: var(--ink-950); text-align: left; background: var(--surface-1, rgba(148,163,184,.10)); border: 1px solid var(--line, rgba(148,163,184,.28)); border-radius: 12px; box-shadow: none; }
.codex-status:hover { border-color: var(--brand-500); background: var(--surface-2); }
.codex-status:focus-visible { outline: none; border-color: var(--brand-600); box-shadow: 0 0 0 3px rgba(18,133,122,.14); }
.codex-head { min-width: 0; display: flex; align-items: center; gap: 8px; }
.codex-dot { width: 9px; height: 9px; flex: none; border-radius: 50%; background: #94a3b8; box-shadow: 0 0 0 3px rgba(148,163,184,.18); }
.codex-status.is-ready .codex-dot { background: #16a34a; box-shadow: 0 0 0 3px rgba(22,163,74,.18); }
.codex-status.is-degraded .codex-dot { background: #f59e0b; box-shadow: 0 0 0 3px rgba(245,158,11,.20); }
.codex-status.is-error .codex-dot { background: #dc2626; box-shadow: 0 0 0 3px rgba(220,38,38,.20); }
.codex-id { min-width: 0; flex: 1; display: flex; flex-direction: column; line-height: 1.2; }
.codex-id strong { overflow: hidden; font-size: 11.5px; font-weight: 800; letter-spacing: .01em; text-overflow: ellipsis; white-space: nowrap; }
.codex-id small { overflow: hidden; color: var(--muted, #64748b); font-size: 9.5px; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }
.codex-plan { flex: none; padding: 2px 6px; color: var(--brand-800); background: var(--brand-50); border: 1px solid var(--line); border-radius: 999px; font-size: 9px; font-weight: 800; }
.codex-account-quotas { display: grid; gap: 3px; }
.codex-quota-row { display: grid; grid-template-columns: 40px minmax(70px, 1fr) 33px 102px; align-items: center; gap: 7px; font-size: 9.5px; font-variant-numeric: tabular-nums; }
.codex-quota-row[hidden], .codex-dialog-quota[hidden] { display: none; }
.codex-quota-row > span { color: var(--ink-700); font-weight: 800; }
.codex-quota-row > strong { text-align: right; font-size: 9.5px; }
.codex-quota-row > small { overflow: hidden; color: var(--ink-500); font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }
.codex-bar { height: 6px; background: rgba(148,163,184,.28); border-radius: 999px; overflow: hidden; }
.codex-bar > i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #f5b027, #f59e0b); border-radius: 999px; transition: width .35s ease; }
.codex-status.is-error .codex-bar > i { background: linear-gradient(90deg, #ef4444, #dc2626); }
.codex-mailflow { margin: 0; overflow: hidden; color: var(--ink-500); font-size: 9px; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }
.codex-status.is-off { opacity: .62; }
.codex-dialog { width: min(640px, calc(100% - 28px)); }
.codex-dialog-body { gap: 18px; }
.codex-dialog-summary { display: grid; gap: 10px; padding: 15px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-md); }
.codex-dialog-summary.is-ready .codex-dot { background: #16a34a; box-shadow: 0 0 0 3px rgba(22,163,74,.18); }
.codex-dialog-summary.is-degraded .codex-dot { background: #f59e0b; box-shadow: 0 0 0 3px rgba(245,158,11,.20); }
.codex-dialog-summary.is-error .codex-dot { background: #dc2626; box-shadow: 0 0 0 3px rgba(220,38,38,.20); }
.codex-dialog-summary > div:first-child { min-width: 0; display: flex; align-items: center; gap: 9px; }
.codex-dialog-summary > div:first-child > div { min-width: 0; flex: 1; display: grid; }
.codex-dialog-summary > div:first-child strong, .codex-dialog-summary > div:first-child small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.codex-dialog-summary > div:first-child small { color: var(--ink-500); }
.codex-dialog-quota { display: grid; grid-template-columns: 52px minmax(90px, 1fr) 38px 132px; align-items: center; gap: 10px; font-size: 12px; font-variant-numeric: tabular-nums; }
.codex-dialog-quota > span { font-weight: 800; }
.codex-dialog-quota > strong { text-align: right; }
.codex-dialog-quota > small { color: var(--ink-500); }
.codex-auth-section { display: grid; gap: 13px; }
.codex-auth-section h4 { margin-bottom: 3px; font-size: 16px; }
.codex-auth-or { display: flex; align-items: center; gap: 10px; color: var(--ink-500); font-size: 11px; font-weight: 750; text-transform: uppercase; }
.codex-auth-or::before, .codex-auth-or::after { content: ""; height: 1px; flex: 1; background: var(--line); }
.success-text { color: var(--green); }
:root[data-theme="dark"] .codex-plan { color: var(--neon-cyan); background: rgba(32,245,237,.08); border-color: rgba(32,245,237,.22); }
@media (max-width: 1120px) {
  .codex-status { width: 330px; }
  .codex-quota-row { grid-template-columns: 38px minmax(55px, 1fr) 30px; }
  .codex-quota-row > small { display: none; }
}
@media (max-width: 900px) {
  .codex-status { width: auto; min-width: 150px; }
  .codex-account-quotas, .codex-mailflow, .codex-plan { display: none; }
}
@media (max-width: 520px) {
  .codex-dialog-quota { grid-template-columns: 46px minmax(70px, 1fr) 34px; }
  .codex-dialog-quota > small { grid-column: 2 / -1; }
}

/* --- Chọn vùng ký cho Party B ------------------------------------------- */
.windows-signer-place { margin: 14px 0; }
.windows-signer-place-hint { margin: 2px 0 10px; font-size: 13px; opacity: .78; }
.windows-signer-place-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 8px; }
.windows-signer-page-label { font-size: 13px; opacity: .8; min-width: 92px; text-align: center; }
.windows-signer-canvas { position: relative; display: inline-block; max-width: 100%; overflow: auto; max-height: 46vh; border: 1px solid rgba(127, 127, 127, .35); border-radius: 8px; background: #fff; cursor: crosshair; touch-action: none; }
.windows-signer-canvas img { display: block; max-width: 100%; height: auto; user-select: none; -webkit-user-drag: none; }
.windows-signer-box { position: absolute; border: 2px solid #12b5cb; background: rgba(18, 181, 203, .16); border-radius: 3px; pointer-events: none; }
.windows-signer-place-value { margin-top: 8px; font-size: 12.5px; opacity: .75; font-variant-numeric: tabular-nums; }

/* --- Ký số online bằng chứng thư .pfx ------------------------------------ */
.signer-online { margin: 14px 0; padding: 14px; border: 1px solid rgba(127, 127, 127, .3); border-radius: 10px; }
.signer-online-hint { margin: 2px 0 12px; font-size: 13px; opacity: .8; }
.signer-online-fields { display: grid; gap: 10px; margin-bottom: 12px; }
.signer-online-field { display: grid; gap: 4px; font-size: 13px; }
.signer-online-field span { font-weight: 700; opacity: .85; }
.signer-online-field input { padding: 9px 10px; border: 1px solid rgba(127, 127, 127, .38); border-radius: 8px; background: transparent; color: inherit; font: inherit; }
.windows-signer-alt { margin-top: 12px; }
.windows-signer-alt > summary { cursor: pointer; font-size: 13px; opacity: .78; padding: 6px 0; }
@media (min-width: 560px) { .signer-online-fields { grid-template-columns: 1fr 1fr; } }

.signing-current { margin: 0 0 10px; padding: 9px 11px; border-radius: 8px; font-size: 13px; background: rgba(18,181,203,.1); border: 1px solid rgba(18,181,203,.32); }

/* --- Trang vận hành (operator.html) -------------------------------------- */
.operator-app { min-height: 100vh; display: flex; flex-direction: column; background: var(--bg, transparent); }
.operator-topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 22px; border-bottom: 1px solid var(--line, rgba(127,127,127,.3)); }
.operator-topbar-right { display: flex; align-items: center; gap: 10px; }
.operator-main { width: min(860px, 100%); margin: 0 auto; padding: 20px 16px 60px; display: grid; gap: 16px; }
.operator-guide ol { margin: 8px 0 0; padding-left: 20px; display: grid; gap: 6px; font-size: 13.5px; line-height: 1.55; }
.operator-list { display: grid; gap: 16px; }
.operator-card { display: grid; gap: 12px; }
.operator-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.operator-card-head h3 { margin: 2px 0; }
.operator-file-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 10px 12px; border: 1px solid var(--line, rgba(127,127,127,.3)); border-radius: 10px; }
.operator-file-label { display: grid; gap: 4px; }
.operator-file-status { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.operator-ack { margin-top: 2px; font-size: 13px; line-height: 1.5; }
.operator-error { margin: 0; }
.operator-started-note { margin: 0; }
/* Dòng đếm hồ sơ đã chạy: có mặt để trấn an, không để đọc kỹ. */
.operator-done-note { margin: 2px 0 0; text-align: center; opacity: .7; }

/* --- Chế độ vận hành: cùng app, chỉ thấy màn hình được phép --------------- */
body.operator-mode #nav button { display: none; }
body.operator-mode .sidebar-toggle { display: none; }
body.operator-mode .topbar-codex, body.operator-mode #codex-status { display: none; }
.operator-guide ol { margin: 0; padding-left: 18px; }
.operator-guide li { margin: 6px 0; }

/* Khay việc nền -----------------------------------------------------------
   Nằm góc dưới phải, không chặn thao tác nào: người vận hành mở hồ sơ khác
   trong lúc AI vẫn đang viết mail cho hồ sơ này. */
.task-tray { position: fixed; right: 18px; bottom: 18px; z-index: 60; width: min(340px, calc(100vw - 36px)); border-radius: 12px; border: 1px solid rgba(127, 127, 127, .28); background: var(--surface, #fff); box-shadow: 0 12px 32px rgba(0, 0, 0, .18); overflow: hidden; }
.task-tray-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 9px 12px; font-size: 13px; border-bottom: 1px solid rgba(127, 127, 127, .2); }
.task-tray-list { list-style: none; margin: 0; padding: 6px; display: grid; gap: 6px; max-height: 260px; overflow-y: auto; }
.task-tray.is-collapsed .task-tray-list { display: none; }
.task-tray-item { padding: 8px 10px; border-radius: 9px; background: rgba(127, 127, 127, .09); display: grid; gap: 5px; }
.task-tray-item strong { font-size: 12.5px; font-weight: 600; }
.task-tray-item small { font-size: 11.5px; opacity: .75; }
.task-tray-bar { height: 4px; border-radius: 999px; background: rgba(127, 127, 127, .25); overflow: hidden; }
.task-tray-bar > i { display: block; height: 100%; border-radius: 999px; background: var(--accent, #2563eb); transition: width .25s ease; }
.task-tray-item.is-error { background: rgba(220, 38, 38, .12); }
.task-tray-item.is-error .task-tray-bar > i { background: #dc2626; }
.task-tray-item.is-done .task-tray-bar > i { background: #16a34a; }
/* Chữ ký đúng về mật mã nhưng chứng thư không nối được tới CA tin cậy. */
.signature-untrusted { color: #d97706; font-weight: 600; }

/* Ảnh chữ ký / con dấu trong danh bạ -------------------------------------
   Trước đây chỉ có một dòng chữ ghi tên file, dài tới mức không đọc nổi và
   không cho biết ảnh thật trông ra sao — đủ để một tấm ảnh chân dung nằm im
   trong ô chữ ký mà không ai nhận ra. Giờ luôn thấy ảnh đang lưu. */
.asset-field { display: grid; gap: 6px; }
.asset-label { font-size: 12px; font-weight: 600; opacity: .85; }
.asset-box { display: flex; align-items: center; gap: 10px; padding: 8px; border: 1px solid rgba(127, 127, 127, .3); border-radius: 10px; background: rgba(127, 127, 127, .06); }
.asset-thumb { flex: 0 0 auto; width: 64px; height: 44px; border-radius: 7px; border: 1px dashed rgba(127, 127, 127, .4); display: grid; place-items: center; overflow: hidden; background: repeating-conic-gradient(rgba(127,127,127,.16) 0% 25%, transparent 0% 50%) 50% / 12px 12px; }
.asset-thumb img { max-width: 100%; max-height: 100%; object-fit: contain; display: block; }
.asset-thumb-empty { font-size: 10.5px; opacity: .6; }
.asset-meta { min-width: 0; flex: 1 1 auto; display: grid; gap: 2px; }
.asset-meta strong { font-size: 12.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.asset-meta small { font-size: 11px; opacity: .72; }
.asset-actions { flex: 0 0 auto; display: flex; gap: 6px; }
.asset-box.is-pending { border-color: rgba(37, 99, 235, .55); background: rgba(37, 99, 235, .08); }
.asset-box.is-cleared { border-color: rgba(220, 38, 38, .5); background: rgba(220, 38, 38, .08); }

/* Chứng thư ký số trong danh bạ ------------------------------------------
   Trước đây chỉ in nguyên chuỗi DN thô ra màn hình, kiểu
   "1.2.840.113549.1.9.1=support@…,CN=Thang Quoc Tran" — không ai đọc được
   đó là chứng thư của ai, do đâu cấp, còn hạn bao lâu. */
.cert-box { border: 1px solid rgba(127, 127, 127, .3); border-radius: 10px; background: rgba(127, 127, 127, .06); padding: 10px; display: grid; gap: 8px; }
.cert-head { display: flex; align-items: center; gap: 10px; }
.cert-icon { flex: 0 0 auto; width: 40px; height: 40px; border-radius: 9px; display: grid; place-items: center; font-size: 19px; background: rgba(127, 127, 127, .14); }
.cert-meta { min-width: 0; flex: 1 1 auto; display: grid; gap: 2px; }
.cert-meta strong { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cert-meta small { font-size: 11.5px; opacity: .75; }
/* display:grid thắng thuộc tính [hidden] của trình duyệt, nên bảng chứng
   thư của công ty mở trước đó vẫn hiện khi mở công ty khác. */
.cert-facts[hidden] { display: none; }
.cert-facts { margin: 0; padding: 8px 0 0; border-top: 1px solid rgba(127, 127, 127, .22); display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; font-size: 11.5px; }
.cert-facts dt { opacity: .65; }
.cert-facts dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.cert-facts dd.cert-warn { color: #d97706; font-weight: 600; }
.cert-facts dd.cert-bad { color: #dc2626; font-weight: 600; }
.cert-box.is-pending { border-color: rgba(37, 99, 235, .55); background: rgba(37, 99, 235, .08); }
.cert-box.is-cleared { border-color: rgba(220, 38, 38, .5); background: rgba(220, 38, 38, .08); }

/* Hồ sơ đang có việc nền chạy ---------------------------------------------
   Một hồ sơ chỉ được một người điều khiển tại một thời điểm, và cả hai vai
   trò phải nhìn thấy cùng một tiến trình. */
.running-note, .operator-running { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 10px; border: 1px solid rgba(37, 99, 235, .45); background: rgba(37, 99, 235, .09); }
.running-note > div, .operator-running > div { display: grid; gap: 4px; min-width: 0; flex: 1 1 auto; }
.running-note strong, .operator-running strong { font-size: 13px; }
.running-note p, .operator-running small { margin: 0; font-size: 11.5px; opacity: .78; }
.spinner.small { width: 16px; height: 16px; flex: 0 0 auto; }
.operator-running .task-tray-bar { margin: 2px 0; }

/* Ghi chú sức khoẻ tài khoản Codex: số liệu hạn mức có thể là bản cache cũ,
   phải nói ra chứ không được hiện im như số mới. */
.codex-health-note { margin: 6px 0 0; font-size: 11.5px; opacity: .75; line-height: 1.45; }
.codex-health-note.is-bad { color: #dc2626; opacity: 1; font-weight: 600; }

/* --- Sửa email trước khi gửi ---------------------------------------------- */
.email-edit-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); }
.email-edit-tools .email-instruction { flex: 1 1 260px; min-width: 200px; padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; background: transparent; color: inherit; font: inherit; font-size: 12.5px; }
.email-fallback-note { margin: 8px 0 0; font-size: 12.5px; color: var(--amber, #b06f00); }
#email-edit-form textarea { width: 100%; padding: 9px 10px; border: 1px solid var(--line); border-radius: 8px; background: transparent; color: inherit; font: inherit; font-family: var(--font-mono, monospace); font-size: 12.5px; line-height: 1.5; resize: vertical; }


/* --- Ô xem trước con dấu chữ ký trong Danh bạ ---------------------------- */
.stamp-preview { display: flex; flex-direction: column; gap: 6px; padding: 12px 14px; background: var(--surface-1, rgba(148,163,184,.10)); border: 1px solid var(--line, rgba(148,163,184,.28)); border-radius: 10px; }
.stamp-preview-label { color: var(--muted, #64748b); font-size: 11px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.stamp-preview code { font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; font-size: 12.5px; letter-spacing: .01em; }
.stamp-preview-note { font-size: 11.5px; font-weight: 600; line-height: 1.45; }
.stamp-preview-note.ok { color: #16a34a; }
.stamp-preview-note.warn { color: #d97706; }


/* --- Mốc thời gian ký & gửi --------------------------------------------- */
.signing-timeline ul { display: flex; flex-direction: column; gap: 10px; margin: 0; padding: 0; list-style: none; }
.signing-timeline li { display: flex; align-items: center; flex-wrap: wrap; gap: 10px 22px; padding: 12px 14px; background: var(--surface-1, rgba(148,163,184,.10)); border: 1px solid var(--line, rgba(148,163,184,.24)); border-radius: 10px; }
.signing-timeline li > div { display: flex; flex-direction: column; gap: 2px; min-width: 150px; }
.signing-timeline li strong { font-size: 11px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; color: var(--muted, #64748b); }
.signing-timeline li span { font-size: 14px; font-weight: 700; font-variant-numeric: tabular-nums; }
.signing-timeline .gap { margin-left: auto; padding: 4px 10px; border-radius: 999px; font-size: 11.5px; font-style: normal; font-weight: 800; }
.signing-timeline .gap.ok { color: #15803d; background: rgba(22,163,74,.14); }
.signing-timeline .gap.warn { color: #b45309; background: rgba(245,158,11,.16); }
.signing-timeline .gap.bad { color: #b91c1c; background: rgba(220,38,38,.16); }

.windows-signer-panel .signed-at { margin: 4px 0 0; font-size: 12px; font-weight: 600; line-height: 1.5; }
.windows-signer-panel .signed-at.ok { color: var(--muted, #64748b); }
.windows-signer-panel .signed-at.warn { color: #b45309; }

/* label { display: grid } thắng thuộc tính [hidden] — cùng bẫy đã gây lỗi
   .cert-facts. Chặn sẵn để lần sau ai ẩn một label bằng [hidden] vẫn đúng. */
label[hidden] { display: none; }
.company-card-flags:empty { display: none; }
.company-card-flags { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 2px; }

/* Lịch gửi kế tiếp trong danh sách hồ sơ: nhãn bước ở trên, giờ và đếm ngược ở dưới. */
.next-send-cell strong { display: block; font-size: 13px; }
.next-send-cell small { display: block; color: var(--ink-600); font-size: 11px; }

/* ---- Kịch bản khung sườn ---- */
.script-panel .script-tabs { display: flex; gap: 6px; }
.script-tab { padding: 6px 14px; border-radius: 999px; border: 1px solid var(--line); background: transparent; color: var(--ink-600); cursor: pointer; font-size: 12px; }
.script-tab.active { background: var(--accent-soft, rgba(56,189,248,.14)); color: var(--accent, #38bdf8); border-color: currentColor; }
.script-flow-note { margin: 0 0 14px; font-size: 12px; color: var(--ink-600); }
.script-step-grid { display: grid; gap: 12px; }
.script-step { border: 1px solid var(--line); border-radius: 12px; padding: 14px; }
.script-step-head { display: flex; gap: 12px; align-items: center; margin-bottom: 8px; }
.script-step-index { width: 28px; height: 28px; border-radius: 9px; display: grid; place-items: center; background: var(--accent-soft, rgba(56,189,248,.14)); color: var(--accent, #38bdf8); font-weight: 700; font-size: 12px; flex: none; }
.script-step-head h4 { margin: 0; font-size: 14px; }
.script-direction { font-size: 11px; color: var(--ink-600); letter-spacing: .04em; }
.script-scenario { margin: 0 0 10px; font-size: 13px; line-height: 1.55; }
.script-chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 6px; }
.script-chip-label { font-size: 11px; color: var(--ink-600); min-width: 74px; }
.script-chip { font-size: 11px; padding: 3px 9px; border-radius: 999px; border: 1px solid var(--line); }
.script-chip.ok { color: #34d399; border-color: rgba(52,211,153,.35); }
.script-chip.no { color: #f87171; border-color: rgba(248,113,113,.35); }
.script-rules { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
.script-rules h4 { margin: 0 0 8px; font-size: 13px; }
.script-rules ul { margin: 0; padding-left: 18px; font-size: 12px; color: var(--ink-600); line-height: 1.8; }

/* ---- Kho bộ mail ---- */
.library-group-title { margin: 18px 0 10px; font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-600); }
.mailset-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.mailset-card { border: 1px solid var(--line); border-radius: 12px; padding: 14px; display: flex; flex-direction: column; gap: 8px; }
.mailset-card.is-off { opacity: .55; }
.mailset-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.mailset-head h4 { margin: 4px 0 0; font-size: 14px; }
.mailset-origin { font-size: 10px; letter-spacing: .08em; text-transform: uppercase; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--line); }
.mailset-origin.builtin { color: var(--ink-600); }
.mailset-origin.custom { color: var(--accent, #38bdf8); border-color: currentColor; }
.mailset-description { margin: 0; font-size: 12px; color: var(--ink-600); }
.mailset-voice { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; margin: 0; font-size: 11px; }
.mailset-voice dt { color: var(--ink-600); }
.mailset-voice dd { margin: 0; }
.mailset-bodies { margin: 0; font-size: 11px; color: var(--ink-600); }
.mailset-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: auto; }
.mailset-toggle input { width: 34px; height: 18px; }

/* ---- Dialog soạn bộ mail ---- */
.mailset-steps { display: grid; gap: 8px; }
.mailset-step { border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; }
.mailset-step summary { cursor: pointer; font-size: 12px; }
.mailset-step .form-grid { margin-top: 10px; }
.placeholder-list code { font-size: 11px; padding: 1px 5px; border-radius: 5px; border: 1px solid var(--line); margin-right: 3px; }
.mailset-check { margin: 12px 0; display: grid; gap: 10px; }
.mailset-errors { border: 1px solid rgba(248,113,113,.4); border-radius: 10px; padding: 12px; }
.mailset-errors h5 { margin: 0 0 6px; color: #f87171; font-size: 13px; }
.mailset-errors ul { margin: 0 0 8px; padding-left: 18px; font-size: 12px; line-height: 1.7; }
.mailset-ok { border: 1px solid rgba(52,211,153,.4); border-radius: 10px; padding: 10px 12px; }
.mailset-ok h5 { margin: 0; color: #34d399; font-size: 13px; }
.mailset-preview-list { display: grid; gap: 10px; }
.mailset-preview h5 { margin: 0 0 6px; font-size: 12px; color: var(--ink-600); }
