/* =====================================================================
   KXPL AEC INTELLIGENCE — Design tokens
   Brand values extracted from https://www.keplerxpvtltd.com/assets/main/css/style.css
   (:root --color-light/#effffb, --color-green/#50d890, --color-blue/#4f98ca,
    --color-dark/#272727, hovers #45c080 / #4088ba). Font: site system stack.
   ===================================================================== */
:root {
  /* Official KXPL palette (from website CSS) */
  --kx-light: #effffb;
  --kx-green: #50d890;
  --kx-blue: #4f98ca;
  --kx-dark: #272727;
  --kx-green-hover: #45c080;
  --kx-blue-hover: #4088ba;
  --kx-green-deep: #3daa70;       /* site: .service-link-mobile:hover */
  --kx-hero: #06151d;             /* site: rgba(6,21,29) hero overlay */
  --kx-teal-dark: #102e32;        /* site: .projects-hero */
  --kx-teal-ink: #173c3e;         /* site: .filter-intro p */
  --kx-gradient: linear-gradient(135deg, var(--kx-green), var(--kx-blue));

  /* Semantic tokens (light — default) */
  --primary: var(--kx-green);
  --primary-hover: var(--kx-green-hover);
  --primary-ink: #1f7a4c;         /* green darkened for text contrast on white */
  --secondary: var(--kx-blue);
  --secondary-hover: var(--kx-blue-hover);
  --secondary-ink: #2f6f9a;
  --accent: var(--kx-teal-dark);
  --bg: #f5fbf9;
  --bg-brand: var(--kx-light);
  --surface: #ffffff;
  --surface-2: #f3fbf8;           /* site: .project-filters */
  --surface-3: #eaf4f1;
  --text: var(--kx-dark);
  --text-2: #4d5b5a;
  --text-3: #607875;              /* site: .filter-intro span */
  --border: #d9ece5;              /* site: .project-filters border */
  --border-strong: #cde1d9;       /* site: .filter-btn border */
  --sidebar-bg: var(--kx-dark);
  --sidebar-text: #d5e5e1;
  --sidebar-muted: #8fa5a1;
  --shadow: 0 1px 2px rgba(39,39,39,.06), 0 4px 14px rgba(39,39,39,.06);
  --shadow-lg: 0 10px 40px rgba(39,39,39,.18);

  /* Status colours */
  --ok: #2e9e63;      --ok-bg: rgba(80,216,144,.14);
  --info: #2f6f9a;    --info-bg: rgba(79,152,202,.14);
  --warn: #b7791f;    --warn-bg: #fff4dd;
  --danger: #c0392b;  --danger-bg: #fdecea;
  --neutral: #607875; --neutral-bg: #eef3f2;
  --ai: #7b4fc9;      --ai-bg: #f1ebfb;

  --radius: 10px;
  --radius-sm: 6px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --sidebar-w: 248px;
  --header-h: 60px;
}
:root[data-theme="dark"] {
  --bg: #0d1a1d;
  --bg-brand: #0d1a1d;
  --surface: #13262a;
  --surface-2: #17302f;
  --surface-3: #1c3836;
  --text: #e6f2ef;
  --text-2: #b9d4ce;
  --text-3: #8fa5a1;
  --border: #24413f;
  --border-strong: #2f5250;
  --primary-ink: var(--kx-green);
  --secondary-ink: #7fb8de;
  --sidebar-bg: #081215;
  --shadow: 0 1px 2px rgba(0,0,0,.4);
  --ok-bg: rgba(80,216,144,.15); --info-bg: rgba(79,152,202,.18);
  --warn-bg: rgba(183,121,31,.2); --danger-bg: rgba(192,57,43,.22);
  --neutral-bg: #1c3836; --ai-bg: rgba(123,79,201,.22);
  --warn: #f0b552; --danger: #ff7b6b; --ok: #6be3a3; --info: #7fb8de; --ai: #b79af0;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: var(--font); color: var(--text); background: var(--bg); font-size: 14px; line-height: 1.45; }
a { color: var(--secondary-ink); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: 22px; } h2 { font-size: 17px; } h3 { font-size: 15px; } h4 { font-size: 13px; }
.mono { font-family: var(--mono); font-size: 12.5px; }
.muted { color: var(--text-3); }
.small { font-size: 12px; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }

/* ---------- Layout ---------- */
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }
.sidebar { background: var(--sidebar-bg); color: var(--sidebar-text); position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; }
.brand { padding: 16px 16px 12px; border-bottom: 1px solid rgba(239,255,251,.1); }
.brand .logo-box { background: #fff; border-radius: 8px; padding: 8px 10px; display: flex; align-items: center; justify-content: center; min-height: 52px; }
.brand .logo-box img { max-width: 100%; max-height: 76px; object-fit: contain; display: block; }
.brand .product { margin-top: 10px; font-weight: 700; font-size: 12.5px; letter-spacing: .08em; color: #fff; }
.brand .tagline { font-size: 10.5px; letter-spacing: .06em; color: var(--kx-green); text-transform: uppercase; }
.logo-placeholder { border: 2px dashed #c0392b; color: #c0392b; background: #fff7f6; border-radius: 6px; font-size: 10.5px; font-weight: 700; text-align: center; padding: 6px; line-height: 1.25; width: 100%; }
.logo-placeholder span { display: block; font-weight: 500; color: #7a2a21; }
.nav { padding: 8px 8px 16px; flex: 1; }
.nav-group { font-size: 10.5px; text-transform: uppercase; letter-spacing: .1em; color: var(--sidebar-muted); padding: 14px 10px 6px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 7px; color: var(--sidebar-text); font-size: 13.2px; }
.nav a:hover { background: rgba(239,255,251,.07); text-decoration: none; }
.nav a.active { background: rgba(80,216,144,.16); color: #fff; box-shadow: inset 3px 0 0 var(--kx-green); }
.nav a .num { font-size: 10px; color: var(--sidebar-muted); width: 16px; text-align: right; }
.nav svg { width: 16px; height: 16px; flex: none; opacity: .9; }
.sidebar-foot { padding: 12px 16px; font-size: 11px; color: var(--sidebar-muted); border-top: 1px solid rgba(239,255,251,.1); }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { height: var(--header-h); background: var(--surface); border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 12px; padding: 0 18px; position: sticky; top: 0; z-index: 20; }
.topbar .page-logo { height: 30px; display: none; }
.topbar .page-logo img { height: 30px; }
.topbar select, .topbar input { height: 34px; }
.search-wrap { position: relative; flex: 1; max-width: 460px; }
.search-wrap input { width: 100%; padding-left: 32px; }
.search-wrap svg { position: absolute; left: 9px; top: 9px; width: 16px; height: 16px; color: var(--text-3); }
.search-results { position: absolute; top: 40px; left: 0; right: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); max-height: 420px; overflow: auto; z-index: 50; }
.search-results .sr { padding: 8px 12px; border-bottom: 1px solid var(--border); cursor: pointer; }
.search-results .sr:hover { background: var(--surface-2); }
.search-results .sr .t { font-size: 11px; color: var(--text-3); text-transform: uppercase; letter-spacing: .05em; }
.topbar .spacer { flex: 1; }
.icon-btn { position: relative; width: 36px; height: 36px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; color: var(--text-2); }
.icon-btn:hover { background: var(--surface-2); }
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn .dot { position: absolute; top: -5px; right: -5px; min-width: 18px; height: 18px; padding: 0 4px; border-radius: 9px; background: var(--danger); color: #fff; font-size: 10.5px; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.user-chip { display: flex; align-items: center; gap: 8px; padding: 4px 10px 4px 4px; border: 1px solid var(--border); border-radius: 20px; cursor: pointer; background: var(--surface); }
.user-chip .av { width: 28px; height: 28px; border-radius: 50%; background: var(--kx-gradient); color: #fff; font-weight: 700; font-size: 12px; display: flex; align-items: center; justify-content: center; }
.user-chip .role { font-size: 11px; color: var(--text-3); }
.popover { position: absolute; right: 18px; top: 56px; width: 380px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); z-index: 60; max-height: 70vh; overflow: auto; }
.popover .ph { padding: 10px 14px; border-bottom: 1px solid var(--border); font-weight: 650; display: flex; justify-content: space-between; align-items: center; }

.content { padding: 20px 22px 40px; max-width: 1600px; width: 100%; }
.page-head { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head .titles { flex: 1; min-width: 260px; }
.page-head .sub { color: var(--text-3); margin-top: 3px; font-size: 13px; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.demo-banner { background: var(--warn-bg); color: var(--warn); border: 1px solid rgba(183,121,31,.3); border-radius: 8px; padding: 6px 12px; font-size: 12px; margin-bottom: 14px; display: flex; gap: 8px; align-items: center; }
.demo-banner b { font-weight: 700; }

/* ---------- Components ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-h { padding: 12px 16px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 10px; }
.card-h h3 { flex: 1; }
.card-b { padding: 14px 16px; }
.card-b.flush { padding: 0; }
.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
.g-2-1 { grid-template-columns: 2fr 1fr; }
@media (max-width: 1200px) { .g4 { grid-template-columns: repeat(2, minmax(0,1fr)); } .g3 { grid-template-columns: repeat(2, minmax(0,1fr)); } .g-2-1 { grid-template-columns: 1fr; } }
@media (max-width: 860px) { .app { grid-template-columns: 1fr; } .sidebar { position: fixed; left: -260px; width: 248px; z-index: 80; transition: left .2s; } .app.nav-open .sidebar { left: 0; } .g2,.g3,.g4 { grid-template-columns: 1fr; } .menu-btn { display: inline-flex !important; } .topbar .user-chip .meta { display: none; } }
@media (min-width: 861px) { .menu-btn { display: none !important; } }
.mb { margin-bottom: 14px; }
.mt { margin-top: 14px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

.kpi { padding: 14px 16px; cursor: pointer; position: relative; overflow: hidden; transition: transform .12s, box-shadow .12s; }
.kpi:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(39,39,39,.1); }
.kpi::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--kx-gradient); }
.kpi .lbl { font-size: 12px; color: var(--text-3); text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
.kpi .val { font-size: 24px; font-weight: 700; margin-top: 4px; letter-spacing: -.02em; }
.kpi .foot { font-size: 11.5px; color: var(--text-3); margin-top: 2px; }

.btn { display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--surface-2); }
.btn svg { width: 15px; height: 15px; }
.btn-primary { background: var(--kx-gradient); color: #fff; border: 0; }
.btn-primary:hover { background: linear-gradient(135deg, var(--kx-green-hover), var(--kx-blue-hover)); box-shadow: 0 4px 14px rgba(80,216,144,.4); }
.btn-dark { background: var(--kx-dark); color: var(--kx-light); border-color: var(--kx-dark); }
.btn-dark:hover { background: #3a3a3a; color: var(--kx-light); border-color: #3a3a3a; }
.btn-danger { color: var(--danger); border-color: rgba(192,57,43,.4); }
.btn-sm { height: 28px; padding: 0 10px; font-size: 12px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-link { background: none; border: 0; color: var(--secondary-ink); cursor: pointer; font: inherit; padding: 0; }

input, select, textarea { font: inherit; font-size: 13px; color: var(--text); background: var(--surface); border: 1px solid var(--border-strong); border-radius: 7px; padding: 6px 9px; min-height: 32px; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(80,216,144,.45); border-color: var(--kx-green); }
textarea { width: 100%; min-height: 70px; resize: vertical; }
label.f { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--text-2); font-weight: 600; }
label.f input, label.f select, label.f textarea { font-weight: 400; }
.form-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 12px; }
.form-grid .span2 { grid-column: span 2; } .form-grid .span3 { grid-column: 1 / -1; }
@media (max-width: 860px) { .form-grid { grid-template-columns: 1fr; } .form-grid .span2 { grid-column: auto; } }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 14px; overflow-x: auto; }
.tabs button { background: none; border: 0; padding: 9px 14px; font: inherit; font-size: 13px; font-weight: 600; color: var(--text-3); cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs button.active { color: var(--text); border-bottom-color: var(--kx-green); }

/* Tables */
.tbl-tools { display: flex; gap: 8px; align-items: center; padding: 10px 12px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.tbl-tools input[type=search] { width: 220px; }
.tbl-wrap { overflow: auto; max-height: 68vh; }
table.t { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 12.8px; }
table.t th { position: sticky; top: 0; z-index: 2; background: var(--surface-2); color: var(--text-2); font-weight: 650; text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; font-size: 11.5px; text-transform: uppercase; letter-spacing: .03em; cursor: pointer; user-select: none; }
table.t th.num, table.t td.num { text-align: right; font-variant-numeric: tabular-nums; }
table.t td { padding: 7px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
table.t tbody tr:hover td { background: var(--surface-2); }
table.t tr.clickable { cursor: pointer; }
table.t tfoot td { position: sticky; bottom: 0; background: var(--surface-3); font-weight: 700; border-top: 1px solid var(--border-strong); }
table.t tr.group td { background: var(--surface-3); font-weight: 700; }
table.t tr.deduct td { color: var(--danger); }
table.t input, table.t select { min-height: 26px; padding: 3px 6px; font-size: 12.5px; width: 100%; }
table.t input.n { text-align: right; width: 76px; }
.tbl-empty { padding: 30px; text-align: center; color: var(--text-3); }
.pager { display: flex; gap: 8px; align-items: center; padding: 8px 12px; font-size: 12px; color: var(--text-3); }

.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: 650; white-space: nowrap; background: var(--neutral-bg); color: var(--neutral); }
.b-ok { background: var(--ok-bg); color: var(--ok); }
.b-info { background: var(--info-bg); color: var(--info); }
.b-warn { background: var(--warn-bg); color: var(--warn); }
.b-danger { background: var(--danger-bg); color: var(--danger); }
.b-ai { background: var(--ai-bg); color: var(--ai); }
.b-demo { background: var(--warn-bg); color: var(--warn); border: 1px dashed currentColor; }

.alert { border-radius: 8px; padding: 10px 12px; font-size: 13px; display: flex; gap: 10px; align-items: flex-start; border: 1px solid transparent; }
.alert.warn { background: var(--warn-bg); color: #7a5414; border-color: rgba(183,121,31,.25); }
.alert.danger { background: var(--danger-bg); color: #8e2a20; border-color: rgba(192,57,43,.25); }
.alert.info { background: var(--info-bg); color: #24577a; border-color: rgba(79,152,202,.25); }
.alert.ok { background: var(--ok-bg); color: #1f6e45; }
:root[data-theme="dark"] .alert.warn { color: var(--warn); } :root[data-theme="dark"] .alert.danger { color: var(--danger); } :root[data-theme="dark"] .alert.info { color: var(--info); } :root[data-theme="dark"] .alert.ok { color: var(--ok); }
.backend-note { border: 1px dashed var(--secondary); background: var(--info-bg); color: var(--secondary-ink); border-radius: 8px; padding: 10px 12px; font-size: 12.5px; }
.backend-note b { color: var(--text); }

.chart-box { position: relative; height: 260px; }
.chart-box.tall { height: 320px; }
.list { display: flex; flex-direction: column; }
.list .li { padding: 9px 14px; border-bottom: 1px solid var(--border); display: flex; gap: 10px; align-items: flex-start; }
.list .li:last-child { border-bottom: 0; }
.health { display: flex; align-items: center; gap: 12px; }
.health .ring { width: 64px; height: 64px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 18px; }
.bar { height: 8px; border-radius: 4px; background: var(--surface-3); overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--kx-gradient); }
.kv { display: grid; grid-template-columns: 160px 1fr; gap: 6px 12px; font-size: 13px; }
.kv dt { color: var(--text-3); }
.kv dd { margin: 0; }
.steps { display: flex; gap: 0; align-items: center; flex-wrap: wrap; font-size: 11.5px; }
.steps span { padding: 3px 9px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text-3); }
.steps span:first-child { border-radius: 10px 0 0 10px; } .steps span:last-child { border-radius: 0 10px 10px 0; }
.steps span.on { background: var(--ok-bg); color: var(--ok); border-color: rgba(46,158,99,.35); font-weight: 700; }

/* Modal & toast */
.modal-bg { position: fixed; inset: 0; background: rgba(6,21,29,.55); z-index: 100; display: flex; align-items: flex-start; justify-content: center; padding: 5vh 16px; overflow: auto; }
.modal { background: var(--surface); border-radius: 12px; width: min(860px, 100%); box-shadow: var(--shadow-lg); }
.modal.wide { width: min(1200px, 100%); }
.modal-h { padding: 14px 18px; border-bottom: 1px solid var(--border); display: flex; align-items: center; }
.modal-h h2 { flex: 1; }
.modal-b { padding: 16px 18px; max-height: 72vh; overflow: auto; }
.modal-f { padding: 12px 18px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }
.toasts { position: fixed; bottom: 18px; right: 18px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--kx-dark); color: var(--kx-light); padding: 10px 14px; border-radius: 8px; box-shadow: var(--shadow-lg); font-size: 13px; max-width: 420px; border-left: 4px solid var(--kx-green); }
.toast.err { border-left-color: #ff7b6b; }

/* Assistant */
.chat { display: flex; flex-direction: column; height: calc(100vh - 210px); min-height: 420px; }
.chat-log { flex: 1; overflow: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.msg { max-width: 92%; padding: 10px 14px; border-radius: 12px; font-size: 13.5px; }
.msg.user { align-self: flex-end; background: var(--kx-dark); color: var(--kx-light); border-bottom-right-radius: 3px; }
.msg.bot { align-self: flex-start; background: var(--surface-2); border: 1px solid var(--border); border-bottom-left-radius: 3px; width: 92%; }
.msg.bot .meta { margin-top: 10px; padding-top: 8px; border-top: 1px dashed var(--border-strong); font-size: 12px; color: var(--text-2); display: grid; gap: 4px; }
.msg.bot table.t { margin-top: 8px; background: var(--surface); }
.chat-in { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--border); }
.chat-in input { flex: 1; height: 38px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--border-strong); background: var(--surface); border-radius: 14px; padding: 4px 10px; font-size: 12px; cursor: pointer; color: var(--text-2); }
.chip:hover { border-color: var(--kx-green); color: var(--text); }

.dropzone { border: 2px dashed var(--border-strong); border-radius: var(--radius); padding: 22px; text-align: center; color: var(--text-3); background: var(--surface-2); cursor: pointer; }
.dropzone.over { border-color: var(--kx-green); background: var(--ok-bg); }
canvas.diff { max-width: 100%; border: 1px solid var(--border); border-radius: 6px; background: #fff; }
.tree { font-size: 13px; }
.tree ul { list-style: none; padding-left: 18px; margin: 4px 0; }
.tree > ul { padding-left: 0; }
.tree li { padding: 2px 0; }
.empty-state { padding: 40px; text-align: center; color: var(--text-3); }
.formula { font-family: var(--mono); font-size: 12px; background: var(--surface-3); padding: 2px 6px; border-radius: 4px; }
@media print { .sidebar, .topbar, .page-head .actions, .tbl-tools { display: none !important; } .app { display: block; } }

/* =====================================================================
   V2 additions — collapsible navigation groups, Gantt, viewer, mobile, misc.
   Same KXPL tokens as V1; nothing above this line was changed.
   ===================================================================== */
.nav-sec .nav-group { display: flex; align-items: center; gap: 6px; width: 100%; background: none; border: 0; cursor: pointer; text-align: left; font: inherit; font-size: 10.5px; text-transform: uppercase; letter-spacing: .1em; color: var(--sidebar-muted); padding: 12px 10px 5px; }
.nav-sec .nav-group:hover { color: #fff; }
.nav-sec .gi { font-size: 9.5px; width: 16px; height: 16px; border-radius: 4px; background: rgba(239,255,251,.08); display: inline-flex; align-items: center; justify-content: center; letter-spacing: 0; }
.nav-sec .car { margin-left: auto; transition: transform .15s; }
.nav-sec.collapsed .car { transform: rotate(-90deg); }
.nav-sec.collapsed .nav-items { display: none; }
.nav a .num.new { width: auto; font-size: 9px; padding: 0 5px; border-radius: 6px; background: rgba(80,216,144,.18); color: var(--kx-green); }
.sync-pill { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 10px; border-radius: 15px; border: 1px solid var(--border); background: var(--surface); font-size: 12px; cursor: pointer; color: var(--text-2); }
.sync-pill svg { width: 14px; height: 14px; }
.sync-pill.pending { border-color: var(--warn); color: var(--warn); }
.sync-pill.offline { border-color: var(--danger); color: var(--danger); }
/* Gantt */
.gantt { position: relative; overflow: auto; max-height: 70vh; border-top: 1px solid var(--border); }
.gantt table { border-collapse: separate; border-spacing: 0; font-size: 12px; }
.gantt th, .gantt td { border-bottom: 1px solid var(--border); padding: 0 8px; height: 28px; white-space: nowrap; background: var(--surface); }
.gantt th { position: sticky; top: 0; z-index: 3; background: var(--surface-2); font-weight: 650; color: var(--text-2); }
.gantt td.lbl, .gantt th.lbl { position: sticky; left: 0; z-index: 2; max-width: 320px; overflow: hidden; text-overflow: ellipsis; border-right: 1px solid var(--border-strong); }
.gantt th.lbl { z-index: 4; }
.gantt td.tl { padding: 0; position: relative; }
.gantt .scale { display: flex; } .gantt .scale span { flex: none; border-left: 1px solid var(--border); font-size: 10.5px; padding-left: 3px; color: var(--text-3); overflow: hidden; }
.gbar { position: absolute; top: 8px; height: 12px; border-radius: 3px; background: var(--kx-blue); cursor: grab; }
.gbar.crit { background: var(--danger); }
.gbar.done { background: var(--ok); }
.gbar i { position: absolute; left: 0; top: 0; bottom: 0; background: rgba(0,0,0,.28); border-radius: 3px 0 0 3px; }
.gbase { position: absolute; top: 21px; height: 4px; border-radius: 2px; background: var(--text-3); opacity: .55; }
.gms { position: absolute; top: 7px; width: 13px; height: 13px; transform: rotate(45deg); background: var(--ai); }
.gtoday { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--kx-green); z-index: 1; pointer-events: none; }
.gantt tr.sum td { font-weight: 700; background: var(--surface-3); }
.gsum { position: absolute; top: 10px; height: 8px; background: var(--kx-dark); border-radius: 1px; }
:root[data-theme="dark"] .gsum { background: var(--kx-light); }
/* Heat cells for resource / allocation matrices */
.heat td.c { text-align: center; font-size: 11.5px; min-width: 54px; }
.heat .s-ok { background: var(--ok-bg); } .heat .s-warn { background: var(--warn-bg); } .heat .s-bad { background: var(--danger-bg); } .heat .s-info { background: var(--info-bg); }
/* Drawing viewer */
.viewer { display: grid; grid-template-columns: 280px 1fr; gap: 14px; }
.viewer.cmp .stage-wrap { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.stage { position: relative; overflow: hidden; background: #f4f6f6; border: 1px solid var(--border); border-radius: 8px; height: 68vh; cursor: grab; touch-action: none; }
.stage canvas.pg, .stage img.pg, .stage svg.pg { position: absolute; left: 0; top: 0; transform-origin: 0 0; background: #fff; box-shadow: 0 2px 10px rgba(0,0,0,.15); }
.stage svg.mk { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
.stage .wm { position: absolute; top: 10px; left: 50%; transform: translateX(-50%); background: rgba(192,57,43,.9); color: #fff; font-weight: 700; padding: 3px 12px; border-radius: 4px; z-index: 5; font-size: 12px; }
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.thumb { border: 1px solid var(--border); border-radius: 8px; padding: 6px; cursor: pointer; background: var(--surface); font-size: 11.5px; }
.thumb:hover { border-color: var(--kx-green); }
.thumb .ti { height: 100px; background: var(--surface-2); border-radius: 5px; display: flex; align-items: center; justify-content: center; overflow: hidden; color: var(--text-3); font-weight: 700; }
.thumb .ti img { max-width: 100%; max-height: 100%; }
.thumb.sup { opacity: .6; } .thumb.sup .ti { background: repeating-linear-gradient(45deg, var(--surface-2), var(--surface-2) 8px, var(--surface-3) 8px, var(--surface-3) 16px); }
.dlist { max-height: 68vh; overflow: auto; border: 1px solid var(--border); border-radius: 8px; }
.dlist .di { padding: 7px 10px; border-bottom: 1px solid var(--border); cursor: pointer; font-size: 12.5px; }
.dlist .di.on { background: var(--ok-bg); }
.toolbar { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }
.toolbar .btn.on { background: var(--ok-bg); border-color: var(--kx-green); }
/* Money trail */
.trail { display: flex; flex-direction: column; gap: 0; }
.trail .st { display: grid; grid-template-columns: 34px 1fr; gap: 10px; }
.trail .dot { width: 26px; height: 26px; border-radius: 50%; background: var(--surface-3); border: 2px solid var(--border-strong); display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; margin: 0 auto; }
.trail .st.on .dot { background: var(--kx-gradient); border-color: transparent; color: #fff; }
.trail .ln { width: 2px; background: var(--border-strong); margin: 0 auto; min-height: 16px; height: 100%; }
.trail .bx { padding: 4px 0 14px; }
.trail .bx .h { font-weight: 700; font-size: 13px; }
/* Mobile-first site app */
.m-shell { max-width: 520px; margin: 0 auto; }
.m-btn { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 64px; padding: 12px 16px; border-radius: 14px; border: 1px solid var(--border-strong); background: var(--surface); font: inherit; font-size: 17px; font-weight: 650; color: var(--text); cursor: pointer; margin-bottom: 10px; text-align: left; }
.m-btn svg { width: 26px; height: 26px; color: var(--primary-ink); }
.m-btn.primary { background: var(--kx-gradient); color: #fff; border: 0; } .m-btn.primary svg { color: #fff; }
.m-shell input, .m-shell select, .m-shell textarea { font-size: 16px; min-height: 44px; width: 100%; }
.m-shell label.f { font-size: 14px; }
.m-shell .form-grid { grid-template-columns: 1fr; }
.lang-sw button { border: 1px solid var(--border-strong); background: var(--surface); padding: 4px 10px; border-radius: 12px; cursor: pointer; font: inherit; font-size: 13px; }
.lang-sw button.on { background: var(--ok-bg); border-color: var(--kx-green); }
.recap td.num { font-variant-numeric: tabular-nums; }
.recap tr.tot td { font-weight: 800; background: var(--surface-3); }
.recap tr.sub td { font-weight: 700; }
.pill { display: inline-block; padding: 1px 7px; border-radius: 8px; font-size: 11px; background: var(--surface-3); }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 860px) { .viewer { grid-template-columns: 1fr; } .split { grid-template-columns: 1fr; } .viewer.cmp .stage-wrap { grid-template-columns: 1fr; } }
.gantt .grw { border-bottom: 1px solid var(--border); }
.gantt .glb { position: sticky; left: 0; z-index: 2; background: var(--surface); border-right: 1px solid var(--border-strong); padding: 0 8px; line-height: 28px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 12px; flex: none; }
.gantt .gh .glb, .gantt .gh .scale { background: var(--surface-2); font-weight: 650; line-height: 28px; }
.gantt .gh .glb { z-index: 5; }
.gantt .gtl { flex: none; background-image: linear-gradient(to right, var(--border) 1px, transparent 1px); background-size: 35px 100%; }
.gantt .garr { color: var(--text-3); z-index: 1; }
.clickable { cursor: pointer; }
.stage { user-select: none; -webkit-user-select: none; }
.stage svg.mk { pointer-events: none; }

/* ---------- V2 Phase 3: vendors & value engineering ---------- */
.chip.on { background: rgba(80,216,144,.18); border-color: var(--kx-green); color: var(--text); }
.chip input { display: none; }
.row.wrap { flex-wrap: wrap; }
.muted-row td { color: var(--text-2); background: var(--surface-2); }
.cmp-t th { text-align: left; vertical-align: top; }
.cmp-t td { vertical-align: top; }
.cmp-t td.best { background: rgba(80,216,144,.14); box-shadow: inset 3px 0 0 var(--kx-green); }
.ve-t label.f { margin-bottom: 6px; }
.ve-t .needs { border: 1px dashed var(--border-strong); border-radius: 8px; padding: 6px; }
.map-note { position: absolute; z-index: 500; left: 8px; bottom: 8px; background: var(--surface); border: 1px solid var(--border); padding: 4px 8px; border-radius: 6px; }
[data-map] { position: relative; background: var(--surface-2); }
.leaflet-container { font: inherit; }
.int-ok { color: var(--ok); } .int-fail { color: var(--danger); }

/* ---------- V2 Phase 4: contracts & billing ---------- */
.flow-strip { display: flex; gap: 4px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }
.flow-strip span:not(.badge) { padding: 4px 12px; border-radius: 14px; font-size: 12px; background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); }
.flow-strip span.done { background: rgba(80,216,144,.15); color: var(--text); border-color: rgba(80,216,144,.5); }
.flow-strip span.on { background: var(--kx-dark); color: var(--kx-light); border-color: var(--kx-dark); }
tr.err-row td { background: rgba(192,57,43,.08); }
tr.tot th, tr.tot td { border-top: 2px solid var(--border-strong); }

/* ---------- V2 Phase 5: site operations & mobile ---------- */
.m-app { max-width: 560px; margin: 0 auto; }
.m-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 14px; }
.m-head h2 { margin: 2px 0; }
.m-tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.m-tiles .m-btn { flex-direction: column; justify-content: center; text-align: center; min-height: 96px; margin: 0; }
.m-ic { font-size: 28px; line-height: 1; }
.m-task { padding: 12px 14px; border-radius: 10px; border: 1px solid var(--border); margin-bottom: 8px; background: var(--surface); }
.m-task.due { border-left: 4px solid var(--warn); } .m-task.ok { border-left: 4px solid var(--kx-green); }
.m-row { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-bottom: 6px; }
.m-row select, .m-row input { min-height: 38px; }
.m-row input.n { width: 80px; }
.lang-pick { min-height: 34px; border-radius: 8px; }
.voice { margin-top: 6px; }
@media (max-width: 640px) {
  .modal-bg { padding: 0; }
  .modal-bg .modal { width: 100vw !important; max-width: 100vw !important; height: 100vh; max-height: 100vh; border-radius: 0; }
  .m-row select, .m-row input, .m-row .m-lbl { flex: 1 1 45%; font-size: 16px; }
  .m-tiles .m-btn { min-height: 84px; font-size: 15px; }
  /* V1 top bar on phones: project picker shrinks, search collapses to its icon width, theme toggle hidden */
  .topbar { gap: 6px; padding: 0 8px; }
  .topbar #project-select { min-width: 0; flex: 1 1 auto; max-width: 52vw; }
  .topbar .search-wrap { flex: 0 0 36px; max-width: 36px; }
  .topbar .search-wrap:focus-within { position: absolute; left: 8px; right: 8px; max-width: none; z-index: 30; }
  .topbar .spacer, .topbar #theme-btn { display: none; }
  .content { padding-left: 12px; padding-right: 12px; }
  .m-head { flex-wrap: wrap; gap: 8px; }
}

.m-lbl { display: inline-flex; flex-direction: column; gap: 2px; font-size: 11px; color: var(--text-2); }
.m-lbl input { width: 100%; }
.neg { color: #c0392b; } .pos { color: #1e8e5a; }

/* V2.2 */
.kx-score { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.kx-score-bar { display: inline-block; width: 56px; height: 6px; border-radius: 3px; background: rgba(127,127,127,.2); overflow: hidden; }
.kx-score-bar i { display: block; height: 100%; border-radius: 3px; }
.gap { gap: 8px; flex-wrap: wrap; }
.row.gap { display: flex; align-items: center; }
.kx-role-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.kx-src { font-size: 12px; opacity: .8; border-left: 3px solid var(--line, #ccc); padding-left: 8px; margin-top: 6px; }
.chart-box.chart-empty { height: auto; min-height: 90px; display: flex; align-items: center; justify-content: center; }
/* V2.2 screens: cards built without card-h / card-b get the standard inner padding; wide tables scroll inside the card */
#view[data-v22] .card:not(.kpi):not(:has(> .card-h)):not(:has(> .card-b)) { padding: 14px 16px; }
#view[data-v22] .card { min-width: 0; overflow-x: auto; }

/* ---------- V2.3 KXPL CDE ---------- */
.cde-docs { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 14px; align-items: start; }
.cde-tree { max-height: 70vh; overflow: auto; }
.cde-fold { display: block; padding: 5px 8px; border-radius: 6px; cursor: pointer; color: var(--text); text-decoration: none; overflow-wrap: anywhere; }
.cde-fold:hover { background: var(--surface-2); }
.cde-fold.on { background: var(--ok-bg); font-weight: 600; box-shadow: inset 3px 0 0 #50D890; }
.cde-drop { border: 2px dashed var(--border-strong); text-align: center; color: var(--text-3); }
.cde-drop.over { border-color: #50D890; background: var(--ok-bg); }
.cde-pv { position: relative; display: inline-block; max-width: 100%; }
.cde-pin { position: absolute; width: 22px; height: 22px; margin: -11px 0 0 -11px; border-radius: 50%; background: #4F98CA; color: #fff; font-size: 11px; font-weight: 700; display: flex; align-items: center; justify-content: center; border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.35); pointer-events: auto; }
.cde-more { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px 0 0; border-top: 1px solid var(--border); margin-top: 10px; }
.cde-more.hidden { display: none; }
.bimv { display: flex; flex-direction: column; gap: 10px; }
.bimv-tools { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.bimv-tools label { display: inline-flex; gap: 4px; align-items: center; font-size: 12px; }
.bimv-body { display: grid; grid-template-columns: 260px minmax(0, 1fr) 300px; gap: 10px; align-items: start; }
.bimv-canvas { position: relative; height: 560px; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: #EFFFFB; }
.bimv-canvas canvas { display: block; width: 100% !important; height: 100% !important; }
.bimv-canvas:fullscreen { height: 100vh; border-radius: 0; }
.bimv-msg { position: absolute; left: 10px; top: 10px; right: 10px; background: rgba(255,255,255,.92); color: #272727; padding: 6px 10px; border-radius: 6px; font-size: 12px; pointer-events: none; }
.bimv-msg:empty { display: none; }
.bimv-tree, .bimv-props { max-height: 560px; overflow: auto; font-size: 12px; overflow-wrap: anywhere; }
.bimv-el { display: block; padding: 2px 6px; border-radius: 4px; cursor: pointer; }
.bimv-el:hover { background: var(--surface-2); }
.bimv-el.on { background: #50D890; color: #272727; font-weight: 600; }
.bimv-tr { padding-left: 10px; }
.bimv-status { min-height: 18px; }
@media (max-width: 1200px) { .bimv-body { grid-template-columns: 220px minmax(0, 1fr); } .bimv-props { grid-column: 1 / -1; max-height: none; } }
@media (max-width: 860px) { .cde-docs, .bimv-body { grid-template-columns: 1fr; } .bimv-canvas { height: 420px; } .bimv-tree { max-height: 260px; } .cde-tree { max-height: 240px; } }
.cde-docs > *, .bimv-body > * { min-width: 0; }
@media (max-width: 860px) { .cde-docs, .bimv-body { grid-template-columns: minmax(0, 1fr); } .cde-fold { white-space: normal; } }

/* ---------- Hosted mode: sign-in gate (js/core/hosted.js) ---------- */
#kx-gate { position: fixed; inset: 0; z-index: 10000; display: flex; align-items: center; justify-content: center; padding: 16px; background: linear-gradient(160deg, #effffb 0%, #e3f1fa 100%); overflow: auto; }
[data-theme="dark"] #kx-gate { background: linear-gradient(160deg, #0f1a1c 0%, #102e32 100%); }
.kx-gate-card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: 0 10px 40px rgba(16,46,50,.15); padding: 28px 26px 18px; text-align: center; }
.kx-gate-card form, .kx-gate-card .f { text-align: left; }
.kx-gate-card .f input { width: 100%; }
.kx-gate-logo { max-width: 180px; max-height: 110px; margin: 0 auto 10px; display: block; }
.kx-gate-title { font-weight: 700; letter-spacing: .06em; font-size: 15px; margin-bottom: 4px; }
.kx-gate-sub { color: var(--text-2); font-size: 13px; margin: 6px 0 14px; line-height: 1.5; }
.kx-gate-btn { width: 100%; justify-content: center; margin-top: 6px; padding: 10px; }
.kx-gate-msg { min-height: 18px; font-size: 12.5px; margin: 4px 0; }
.kx-gate-msg.err { color: var(--danger, #c0392b); }
.kx-gate-msg.ok { color: var(--text-3); }
.kx-gate-foot { margin-top: 18px; font-size: 11px; color: var(--text-3); }
.kx-gate-spin { width: 28px; height: 28px; margin: 8px auto; border: 3px solid var(--border); border-top-color: var(--kx-green, #50d890); border-radius: 50%; animation: kxspin 0.9s linear infinite; }
@keyframes kxspin { to { transform: rotate(360deg); } }
.stage svg.cad * { vector-effect: non-scaling-stroke; }

/* V2.6 sidebar: module search, group / ungroup, a subtle colour per main module */
.nav-tools { display: flex; gap: 6px; padding: 0 12px 8px; }
.nav-tools input { flex: 1; min-width: 0; height: 30px; font-size: 12.5px; background: rgba(239,255,251,.07); border: 1px solid rgba(239,255,251,.12); color: var(--sidebar-text); border-radius: 7px; padding: 0 9px; }
.nav-tools input::placeholder { color: var(--sidebar-muted); }
.nav-tg { width: 30px; height: 30px; border-radius: 7px; border: 1px solid rgba(239,255,251,.12); background: rgba(239,255,251,.07); color: var(--sidebar-text); cursor: pointer; font-size: 14px; }
.nav-tg.on { background: rgba(80,216,144,.2); color: #fff; }
.nav-sec .gi { background: color-mix(in srgb, var(--gc, #50d890) 30%, transparent); color: #fff; }
.nav-sec .nav-items a svg { color: var(--gc, currentColor); }
.nav-sec .nav-items a { box-shadow: inset 2px 0 0 color-mix(in srgb, var(--gc, transparent) 45%, transparent); }
.nav-sec .nav-items a.active { box-shadow: inset 3px 0 0 var(--gc, var(--kx-green)); }
.nav.flat .nav-group { display: none; }
.nav.flat .nav-sec.collapsed .nav-items { display: block; }
.nav a .grp { font-size: 9.5px; color: var(--sidebar-muted); margin-left: auto; }
.nav mark { background: rgba(80,216,144,.35); color: inherit; border-radius: 2px; }
.nav .nav-empty { padding: 10px 14px; font-size: 12px; color: var(--sidebar-muted); }
.sr-filters { display: flex; flex-wrap: wrap; gap: 4px; padding: 8px 10px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface); }
.sr-filters button { font-size: 11px; border: 1px solid var(--border); background: transparent; border-radius: 12px; padding: 2px 8px; cursor: pointer; color: inherit; }
.sr-filters button.on { background: var(--kx-green); border-color: var(--kx-green); color: #102e32; }
.t th .sort-hint { opacity: .35; font-size: .9em; }
.t th[data-s] { cursor: pointer; }
/* V2.6 organisation chart */
.org ul { list-style: none; margin: 0; padding-left: 26px; border-left: 1px dashed var(--border); }
.org > ul { padding-left: 0; border-left: 0; }
.org li { margin: 6px 0; position: relative; }
.org-card { display: inline-flex; gap: 10px; align-items: center; padding: 7px 12px 7px 8px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); cursor: pointer; min-width: 240px; }
.org-card:hover { border-color: var(--kx-green); }
.org-tg { width: 22px; height: 22px; border-radius: 6px; border: 1px solid var(--border); background: transparent; cursor: pointer; color: inherit; font-weight: 700; }

/* V2.6 PM: active-task badge and dashboard Gantt */
.act-badge { display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 20px; padding: 0 6px; margin-left: 6px; border-radius: 10px; border: 0; background: #e0a93c; color: #272727; font: 700 11px/1 inherit; cursor: pointer; vertical-align: middle; animation: kxpulse 2s infinite; }
.act-badge:hover { background: #f0b94c; }
@keyframes kxpulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(224,169,60,.5); } 50% { box-shadow: 0 0 0 4px rgba(224,169,60,0); } }
.gantt { font-size: 12px; }
.g-row { display: grid; grid-template-columns: 260px 1fr 120px 80px; gap: 8px; align-items: center; border-bottom: 1px solid var(--border); padding: 6px 0; }
.g-head { position: sticky; top: 0; background: var(--surface); z-index: 2; }
.g-lbl a { color: var(--text); text-decoration: none; }
.g-lbl a:hover { text-decoration: underline; }
.g-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.g-track { position: relative; height: 30px; background: repeating-linear-gradient(90deg, transparent 0 59px, var(--border) 59px 60px); border-radius: 4px; }
.g-head .g-track { background: none; }
.g-mon { position: absolute; top: 8px; font-size: 11px; color: var(--text-3); white-space: nowrap; transform: translateX(2px); border-left: 1px solid var(--border); padding-left: 3px; }
.g-today { position: absolute; top: -4px; bottom: -4px; width: 2px; background: #d64545; z-index: 1; pointer-events: none; }
.g-today span { position: absolute; top: -14px; left: -14px; font-size: 10px; color: #d64545; font-weight: 700; }
.g-bar { position: absolute; top: 7px; height: 16px; border: 1.5px solid; border-radius: 4px; overflow: hidden; }
.g-fill { height: 100%; opacity: .75; }
.g-plan { position: absolute; top: -2px; bottom: -2px; width: 2px; background: #272727; }
.g-ms { position: absolute; top: 9px; width: 12px; height: 12px; transform: translateX(-6px) rotate(45deg); border: 1px solid #fff; padding: 0; cursor: pointer; z-index: 2; }
.g-num { text-align: right; }
/* V2.6 notifications */
.n-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--kx-green, #50d890); margin-right: 6px; vertical-align: middle; }
.popover .li.unread { background: rgba(80,216,144,.08); }
/* V2.7 popup maximise / restore */
.modal-f .modal-max { margin-left: 4px; width: 32px; height: 32px; flex: none; }
.modal-bg.maxed { padding: 0; }
.modal-bg.maxed .modal { width: 100vw; max-width: none; min-height: 100vh; border-radius: 0; display: flex; flex-direction: column; }
.modal-bg.maxed .modal-b { max-height: none; flex: 1; }
/* V2.7 sidebar numbering (1.1, 1.2 …) and the main module holding the open page */
.nav a .sn { font-size: 10px; min-width: 26px; color: var(--sidebar-muted); font-variant-numeric: tabular-nums; flex: none; }
.nav a.active .sn { color: inherit; }
.nav-sec.collapsed.has-active > .nav-group { color: #fff; box-shadow: inset 3px 0 0 var(--gc, #50d890); }
.page-head .crumb { font-size: 11.5px; color: var(--text-3); margin-bottom: 2px; letter-spacing: .01em; }
/* V2.7 profile picture crop */
.crop-box { position: relative; border-radius: 8px; overflow: hidden; background: #ddd; touch-action: none; flex: none; }
.crop-box canvas { display: block; cursor: grab; }
.crop-mask { position: absolute; inset: 0; pointer-events: none; }
.crop-mask.circle { box-shadow: 0 0 0 999px rgba(0,0,0,.45); border-radius: 50%; }
.crop-mask.square { box-shadow: inset 0 0 0 2px rgba(255,255,255,.8); }
/* V2.7 compact role permission matrix */
.rm-tools { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; flex-wrap: wrap; }
.rm-wrap { max-height: 58vh; overflow: auto; border: 1px solid var(--border); border-radius: 8px; }
.modal-bg.maxed .rm-wrap { max-height: calc(100vh - 260px); }
table.rm { font-size: 12px; }
table.rm th, table.rm td { padding: 3px 8px; }
table.rm th { position: sticky; top: 0; background: var(--surface); z-index: 1; font-size: 11px; }
table.rm .c { text-align: center; width: 64px; }
table.rm tr.rm-g td { background: color-mix(in srgb, var(--kx-green, #50d890) 7%, var(--surface)); }
table.rm tr.rm-m td:first-child { padding-left: 30px; }
.rm-tg { border: 0; background: none; cursor: pointer; width: 18px; color: var(--text-3); padding: 0; }
#view > .crumb { font-size: 11.5px; color: var(--text-3); margin-bottom: 6px; }

/* V2.7 Module 7 step strip */
.e7-strip{display:grid;grid-template-columns:repeat(6,minmax(0,1fr));gap:6px}
.e7-step{display:block;padding:8px 10px;border:1px solid var(--border);border-radius:8px;background:var(--card,#fff);color:inherit;text-decoration:none;font-size:12.5px;line-height:1.5}
.e7-step.on{border-color:var(--primary,#0b6b5c);box-shadow:inset 0 -3px 0 var(--primary,#0b6b5c)}
.e7-step.off{opacity:.6}
@media (max-width:900px){.e7-strip{grid-template-columns:repeat(3,minmax(0,1fr))}}
@media (max-width:520px){.e7-strip{grid-template-columns:repeat(2,minmax(0,1fr))}}

/* V2.8 searchable dropdown (shared; every single-choice select) */
.kxs-pop { position: fixed; z-index: 3000; background: var(--surface); border: 1px solid var(--border-strong, var(--border)); border-radius: 8px; box-shadow: var(--shadow-lg); display: flex; flex-direction: column; overflow: hidden; min-width: 200px; }
.kxs-pop .kxs-q { margin: 6px; width: auto; height: 32px; }
.kxs-list { overflow: auto; flex: 1; padding-bottom: 4px; }
.kxs-o { padding: 6px 10px; cursor: pointer; font-size: 13px; line-height: 1.35; white-space: normal; }
.kxs-o.hi { background: color-mix(in srgb, var(--kx-green) 18%, var(--surface)); }
.kxs-o.sel { font-weight: 650; }
.kxs-o.dis { opacity: .45; cursor: default; }
.kxs-o mark { background: rgba(80,216,144,.45); color: inherit; padding: 0; border-radius: 2px; }
.kxs-g { padding: 6px 10px 2px; font-size: 11px; font-weight: 700; color: var(--text-3); text-transform: uppercase; letter-spacing: .03em; }
.kxs-none { padding: 10px; color: var(--text-3); font-size: 13px; }
/* V2.8 show / hide password */
.kx-pw { position: relative; display: block; width: 100%; }
.kx-pw > input { width: 100%; padding-right: 38px !important; }
.kx-eye { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); width: 30px; height: 30px; border: 0; background: transparent; color: var(--text-3); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; border-radius: 6px; padding: 0; }
.kx-eye:hover, .kx-eye:focus-visible { color: var(--text); background: color-mix(in srgb, var(--kx-green) 14%, transparent); }
.kx-eye svg { width: 18px; height: 18px; }
/* V2.8 logo opens Home */
[data-logo] { cursor: pointer; }
/* V2.8 upload widget: proportionate icon */
.dropzone > svg, .cde-drop > svg { width: 28px; height: 28px; display: block; margin: 0 auto 6px; }
/* V2.8 searchable multi-select */
.kxm { position: relative; }
.kxm-box { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; min-height: 36px; padding: 3px 6px; border: 1px solid var(--border-strong, var(--border)); border-radius: 8px; background: var(--surface); cursor: text; }
.kxm-chips { display: contents; }
.kxm-chip { display: inline-flex; align-items: center; gap: 4px; background: color-mix(in srgb, var(--kx-green) 18%, var(--surface)); border-radius: 12px; padding: 1px 4px 1px 9px; font-size: 12px; }
.kxm-chip button { border: 0; background: none; cursor: pointer; font-size: 14px; line-height: 1; color: var(--text-3); padding: 0 3px; }
.kxm-q { border: 0 !important; outline: none; flex: 1; min-width: 120px; height: 28px; background: transparent; box-shadow: none !important; }
.kxm-list { position: absolute; left: 0; right: 0; top: 100%; margin-top: 2px; z-index: 50; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow-lg); max-height: 240px; overflow: auto; padding: 4px 0; }
.kxm-o { display: flex !important; gap: 8px; align-items: center; padding: 5px 10px; font-size: 13px; cursor: pointer; font-weight: 400 !important; }
.kxm-o:hover { background: var(--surface-2); }
.kxm-o input { width: auto !important; height: auto !important; }
.kxm-none { padding: 8px 10px; color: var(--text-3); font-size: 13px; }
/* V2.8 CDE folder tree expand / collapse */
.cde-tg { display: inline-flex; width: 18px; height: 18px; align-items: center; justify-content: center; border: 0; background: none; cursor: pointer; color: var(--text-3); padding: 0; margin-right: 2px; font-size: 11px; flex: none; }
.cde-tg.sp { cursor: default; }
.cde-tg:hover { color: var(--text); }
/* V2.8 PM dashboard: readable dates, View button, responsive rows */
.g-row { grid-template-columns: minmax(200px, 280px) minmax(360px, 1fr) 120px 80px; }
.g-lbl { min-width: 0; }
.g-lbl a { display: block; overflow-wrap: anywhere; }
.g-dates { display: flex; flex-wrap: wrap; gap: 0 6px; line-height: 1.35; }
.g-view { margin-top: 3px; padding: 1px 8px; font-size: 11.5px; }
.g-head .g-mon { top: 0; }
.g-head .g-today > span { top: 15px; left: 3px; background: var(--surface); padding: 0 2px; }
/* V2.8 role matrix: fixed module column, even action columns, zebra rows, sticky header */
table.rm { table-layout: fixed; width: 100%; min-width: 700px; border-collapse: separate; border-spacing: 0; }
table.rm col.rm-mod { width: 260px; }
table.rm col.rm-c { width: auto; }
table.rm th.rm-mod, table.rm td:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
table.rm thead th { position: sticky; top: 0; z-index: 2; background: var(--surface-2, var(--surface)); border-bottom: 1px solid var(--border-strong, var(--border)); vertical-align: bottom; }
table.rm .c { width: auto; text-align: center; }
table.rm tbody tr.rm-m:nth-child(even) td { background: var(--surface-2, #f6faf8); }
table.rm tbody tr.rm-m:hover td { background: color-mix(in srgb, var(--kx-green) 9%, var(--surface)); }
table.rm input[type=checkbox] { width: 16px; height: 16px; margin: 2px 0 0; }
.btn.btn-ok { background: #3daa70; border-color: #3daa70; color: #fff; }
.btn.btn-ok:hover { background: #33925f; }
/* V2.8 full file viewer (CDE documents) */
.fv-bar { flex-wrap: wrap; gap: 4px; margin-bottom: 6px; }
.fv-main { display: flex; gap: 8px; align-items: stretch; }
.fv-stage { flex: 1; min-width: 0; }
.fv-side { width: 280px; flex: none; max-height: 72vh; overflow: auto; }
.modal-bg.maxed .fv-stage .stage { height: calc(100vh - 250px); }
.fv-cmp { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.fv-cmp .stage { height: calc(100vh - 230px); }
@media (max-width: 860px) { .fv-main { flex-direction: column; } .fv-side { width: auto; } .fv-cmp { grid-template-columns: 1fr; } .fv-cmp .stage { height: 45vh; } }
/* V2.8 Phase 2: live timers, due colours, header running timer, time log, threaded comments */
.kx-live { font-variant-numeric: tabular-nums; font-family: ui-monospace, Menlo, Consolas, monospace; white-space: nowrap; padding: 1px 6px; border-radius: 4px; }
.kx-live.on { font-weight: 700; }
.kx-live.green { background: rgba(61,170,112,.16); color: #1f7a4a; }
.kx-live.yellow { background: rgba(224,169,60,.22); color: #8a5d00; }
.kx-live.red { background: rgba(211,64,64,.16); color: #b02a2a; }
.kx-due { display: inline-block; width: 10px; height: 10px; border-radius: 50%; vertical-align: middle; }
.kx-due:not(.red):not(.yellow):not(.green) { display: none; }
.kx-due.green { background: #3daa70; } .kx-due.yellow { background: #e0a93c; } .kx-due.red { background: #d34040; animation: kxpulse 2s infinite; }
.run-timer { display: inline-flex; align-items: center; gap: 6px; max-width: 320px; height: 32px; padding: 0 10px; margin-right: 6px; border-radius: 16px; border: 1px solid var(--border); background: var(--card, #fff); color: inherit; cursor: pointer; font: inherit; font-size: 12px; }
.run-timer[hidden] { display: none; }
.run-timer .rt-dot { width: 8px; height: 8px; border-radius: 50%; background: #d34040; animation: kxpulse 1.4s infinite; }
.run-timer .rt-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 160px; }
@media (max-width: 640px) { .run-timer .rt-name { display: none; } }
.tk-log-t td, .tk-log-t th { font-size: 12px; } .tk-log-t tfoot td { border-top: 2px solid var(--border); }
.tk-thread { border-top: 1px solid var(--border); padding-top: 8px; }
.tk-cs { max-height: 340px; overflow: auto; margin: 6px 0; }
.tk-c { padding: 6px 0; border-bottom: 1px solid var(--border); }
.tk-r { margin: 6px 0 0 18px; padding-left: 10px; border-left: 3px solid var(--border); }
.tk-txt { white-space: pre-wrap; }
.tk-rbox { display: flex; gap: 6px; margin: 6px 0 0 18px; } .tk-rbox input { flex: 1; }
.tk-new { display: flex; gap: 6px; align-items: flex-end; } .tk-new textarea { flex: 1; }
/* V2.8 Phase 2 F: Module 7 method choice, AI progress, AI configuration */
.e7m-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; background: transparent; padding: 6px 12px; font: inherit; font-size: 13px; cursor: pointer; color: inherit; display: inline-flex; gap: 6px; align-items: center; }
.seg button + button { border-left: 1px solid var(--border); }
.seg button.on { background: var(--kx-green, #3daa70); color: #fff; font-weight: 600; }
.seg button svg { width: 15px; height: 15px; }
.seg button:disabled { opacity: .6; cursor: default; }
.e7m-man, .e7m-ai { margin-top: 8px; }
.ai-prog .ai-bar { height: 12px; border-radius: 6px; background: var(--border); overflow: hidden; }
.ai-prog .ai-bar span { display: block; height: 100%; background: linear-gradient(90deg, #3daa70, #2f8fbf); transition: width .45s ease; }
.ai-prog.fail .ai-bar span { background: #d34040; }
.ai-prog .ai-row { display: flex; gap: 10px; align-items: baseline; margin-top: 8px; flex-wrap: wrap; }
.ai-cfg dt { font-weight: 600; } .ai-cfg dd { margin: 0 0 8px; }
.ai-cfg .stat { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; }
.ai-cfg .stat::before { content: ''; width: 10px; height: 10px; border-radius: 50%; background: #d34040; }
.ai-cfg .stat.ok::before { background: #3daa70; }
/* V2.8 H: backup module picker, G: AI suggestion cards */
.bk-mods { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 4px 12px; max-height: 300px; overflow: auto; padding: 6px; border: 1px solid var(--border); border-radius: 8px; }
.bk-mods label { display: flex; gap: 6px; align-items: center; }
.ve-sugg .card { border-left: 3px solid var(--primary, #1f4e79); }

/* ---- V2.9 change request ---- */
/* CR 3: long text never cut */
.modal-f { flex-wrap: wrap; }
.modal-f .kx-reason { flex: 1 1 100%; width: 100%; min-height: 34px; resize: vertical; line-height: 1.4; overflow-wrap: anywhere; white-space: pre-wrap; }
td.kx-longcol { min-width: 220px; max-width: 460px; white-space: normal; }
.kx-wrap { white-space: pre-wrap; overflow-wrap: anywhere; }
.kx-clamp .kx-clamp-t { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; white-space: pre-wrap; overflow-wrap: anywhere; }
.kx-clamp.open .kx-clamp-t { display: block; -webkit-line-clamp: unset; overflow: visible; }
.kx-more { border: 0; background: none; color: var(--blue, #4f98ca); font: inherit; font-size: 11.5px; font-weight: 650; padding: 0; cursor: pointer; }
@media print { .kx-clamp .kx-clamp-t { display: block; -webkit-line-clamp: unset; overflow: visible; } .kx-more { display: none; } }
/* CR 4: phones / tablets — native pickers, 16px controls (no iOS zoom-in that hides the picker), nothing clipped */
@media (pointer: coarse) { select, input, textarea { font-size: 16px; } select { min-height: 40px; } table.t select, table.t input { font-size: 15px; min-height: 34px; } }
.modal-b .kxm { position: relative; } .kxm-list { z-index: 3001; }
/* CR 11: Billable / Non-billable chip toggle */
input.kx-seg-src { position: absolute; opacity: 0; width: 1px !important; height: 1px !important; pointer-events: none; }
.kx-seg { display: inline-flex; border: 1px solid var(--border-strong); border-radius: 999px; padding: 2px; background: var(--surface-2); gap: 2px; width: max-content; }
.kx-seg button { border: 0; background: transparent; color: var(--text-2); font: inherit; font-size: 12.5px; font-weight: 600; padding: 5px 12px; border-radius: 999px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; min-height: 28px; }
.kx-seg .kx-seg-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--border-strong); }
.kx-seg button.on[data-v="1"] { background: #50d890; color: #0f3d27; } .kx-seg button.on[data-v="1"] .kx-seg-dot { background: #0f3d27; }
.kx-seg button.on[data-v="0"] { background: var(--surface); color: var(--text); box-shadow: 0 0 0 1px var(--border-strong); } .kx-seg button.on[data-v="0"] .kx-seg-dot { background: var(--text-3); }
.kx-seg.dis { opacity: .6; } .kx-seg.dis button { cursor: default; }
label.kx-seg-label { position: relative; }

/* ---- V2.9 Company CRM (Titan CRM workflow): lead board, tasks calendar, project timeline ---- */
.kx-board { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 8px; align-items: flex-start; }
.kx-col { flex: 0 0 230px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; display: flex; flex-direction: column; max-height: 70vh; }
.kx-col.over { outline: 2px dashed var(--accent, #3cb7b0); }
.kx-col-h { padding: 8px 10px; border-bottom: 1px solid var(--border); }
.kx-col-b { padding: 6px; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; }
.kx-card { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 7px 8px; cursor: grab; font-size: 13px; }
.kx-card.drag { opacity: .5; }
.kx-card-st { margin-top: 4px; width: 100%; font-size: 12px; min-height: 28px; }
.kx-cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.kx-cal-h { font-size: 12px; font-weight: 600; text-align: center; padding: 4px 0; color: var(--muted, #6b7d7b); }
.kx-cal-d { min-height: 92px; border: 1px solid var(--border); border-radius: 8px; padding: 4px; font-size: 12px; overflow: hidden; }
.kx-cal-d.out { opacity: .45; }
.kx-cal-d.today { border-color: var(--accent, #3cb7b0); box-shadow: inset 0 0 0 1px var(--accent, #3cb7b0); }
.kx-cal-n { font-weight: 600; margin-bottom: 2px; }
.kx-cal-t { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; border-radius: 4px; padding: 1px 4px; margin-bottom: 2px; background: rgba(79,152,202,.14); cursor: pointer; }
.kx-cal-t.late { background: rgba(214,90,106,.18); color: var(--danger, #b03040); }
.kx-cal-t.done { text-decoration: line-through; opacity: .6; }
@media (max-width: 700px) { .kx-cal-d { min-height: 64px; } .kx-cal-t { font-size: 10px; } }
.kx-tl { display: flex; flex-direction: column; gap: 4px; }
.kx-tl-r { display: grid; grid-template-columns: minmax(90px, 220px) 1fr; gap: 8px; align-items: center; }
.kx-tl-n { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kx-tl-t { position: relative; height: 14px; background: rgba(127,127,127,.08); border-radius: 7px; }
.kx-tl-b { position: absolute; top: 2px; height: 10px; border-radius: 5px; background: #4f98ca; }
.kx-tl-b.b-ok { background: #50d890; } .kx-tl-b.b-warn { background: #e0a03c; } .kx-tl-b.b-danger { background: #d65a6a; } .kx-tl-b.b-grey { background: #9aa8a6; }
.kx-tl-now { position: absolute; top: -2px; bottom: -2px; width: 2px; background: var(--danger, #b03040); }
.kx-filters .f { margin: 0; min-width: 120px; }
.kx-seg button[aria-checked="true"]:not([data-v]) { background: var(--surface); color: var(--text); box-shadow: 0 0 0 1px var(--border-strong); }

/* V2.9 item 15 — CDE action menus, status flow, overview */
.kx-ctx { position: fixed; z-index: 2000; min-width: 200px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.18); padding: 4px; }
.kx-ctx button { display: block; width: 100%; text-align: left; background: none; border: 0; padding: 7px 10px; border-radius: 6px; color: var(--text); font: inherit; cursor: pointer; min-height: 36px; }
.kx-ctx button:hover:not([disabled]), .kx-ctx button:focus { background: var(--surface-2); outline: none; }
.kx-ctx button[disabled] { color: var(--muted); cursor: not-allowed; }
.kx-ctx button.danger:not([disabled]) { color: #c0392b; }
.kx-ctx hr { border: 0; border-top: 1px solid var(--border); margin: 4px 0; }
.cde-fm { float: right; background: none; border: 0; padding: 0 6px; cursor: pointer; color: var(--muted); font-size: 16px; line-height: 1; opacity: .35; }
.cde-fold:hover .cde-fm, .cde-fold.on .cde-fm, .cde-fm:focus { opacity: 1; }
@media (hover: none) { .cde-fm { opacity: .8; } }
.cde-dm { padding: 0 8px; }
.cde-flow { display: flex; flex-wrap: wrap; gap: 4px; }
.cde-flow span { padding: 3px 10px; border-radius: 999px; border: 1px solid var(--border); font-size: 12px; color: var(--muted); }
.cde-flow span.done { background: var(--surface-2); color: var(--text); }
.cde-flow span.cur { background: var(--kx-blue, #1f5fa8); border-color: transparent; color: #fff; font-weight: 600; }
.cde-v29 { border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; margin-bottom: 10px; }
.cde-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.cde-launch { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.cde-launch a { display: flex; flex-direction: column; gap: 2px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; color: inherit; text-decoration: none; }
.cde-launch a:hover { background: var(--surface-2); }
.cde-pick { max-height: 200px; overflow: auto; border: 1px solid var(--border); border-radius: 8px; padding: 4px 10px; columns: 2; }
.cde-pick label { display: flex; gap: 6px; align-items: center; padding: 2px 0; break-inside: avoid; }
@media (max-width: 640px) { .cde-pick { columns: 1; } }

/* V2.13 (Batch 4 item 1): Terms & Conditions screen after sign-in */
#kx-gate.kx-gate-wide .kx-gate-card { max-width: 860px; }
.kx-tc { text-align: left; }
.kx-tc .kx-gate-sub { text-align: center; }
.kx-tc-body { max-height: 52vh; overflow: auto; border: 1px solid var(--border); border-radius: 10px; padding: 14px 18px; background: var(--bg, #fff); font-size: 13px; line-height: 1.55; margin: 10px 0; }
.kx-tc-body h1, .kx-tc-body h2, .kx-tc-body h3 { font-size: 15px; margin: 12px 0 6px; }
.kx-tc-body table { border-collapse: collapse; } .kx-tc-body td, .kx-tc-body th { border: 1px solid var(--border); padding: 4px 6px; }
.kx-tc-chk { display: flex; gap: 8px; align-items: flex-start; font-size: 13px; margin: 6px 0; cursor: pointer; }
.kx-tc-chk input { margin-top: 3px; }
.tc-doc { max-height: 60vh; overflow: auto; border: 1px solid var(--border); border-radius: 8px; padding: 12px 16px; background: var(--surface); }
.kx-tc-body section.docx, .tc-doc section.docx { padding: 0 !important; width: auto !important; min-height: 0 !important; margin: 0 !important; box-shadow: none !important; background: transparent !important; }
.kx-tc-body .docx-wrapper, .tc-doc .docx-wrapper { padding: 0 !important; background: transparent !important; }
#kx-gate.kx-gate-wide .kx-gate-logo { max-height: 56px; width: auto; }
#kx-gate.kx-gate-wide .kx-gate-card { padding-top: 16px; }
@media (max-height: 760px) { .kx-tc-body { max-height: 42vh; } }

/* V2.13 Batch 4 items 7/8: Master Prompt Library page */
.pl-common{border:1px solid var(--border);border-left:4px solid var(--primary);border-radius:10px;background:var(--surface);padding:10px 14px}
.pl-common>summary{cursor:pointer;list-style-position:outside;padding:2px 0}
.pl-cbody{margin-top:10px}
.pl-intro{color:var(--text-2);margin-bottom:10px}
.pl-sh{font-weight:600;font-size:13px;margin:4px 0 6px;color:var(--accent)}
:root[data-theme="dark"] .pl-sh{color:var(--kx-green)}
.pl-ol{margin:0 0 10px;padding-left:20px;font-size:13px;line-height:1.5}
.pl-ol li{margin-bottom:3px}
.pl-hdr{white-space:pre-wrap;background:var(--surface-2);border:1px dashed var(--border-strong);padding:10px 12px;border-radius:8px;font-size:13px;line-height:1.5;margin-top:6px}
.pl-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(min(100%,360px),1fr));gap:12px;margin-top:6px}
.pl-card{border:1px solid var(--border);border-radius:10px;background:var(--surface);display:flex;flex-direction:column;min-width:0;box-shadow:0 1px 2px rgba(0,0,0,.04)}
.pl-card.pl-ret{opacity:.6}
.pl-h{display:flex;gap:10px;align-items:flex-start;padding:10px 12px;border-bottom:1px solid var(--border)}
.pl-code{flex:none;font-weight:700;font-size:12px;background:var(--kx-teal-dark);color:#fff;border-radius:6px;padding:3px 8px;letter-spacing:.02em}
.pl-t{font-weight:600;line-height:1.3}
.pl-cat{display:inline-block;margin-top:4px;font-size:11px;padding:1px 8px;border-radius:999px;background:rgba(79,152,202,.12);color:var(--secondary-ink)}
.pl-txt{white-space:pre-wrap;font-size:13px;line-height:1.55;padding:10px 12px;max-height:260px;overflow:auto;flex:1;word-break:break-word}
.pl-hv{max-height:none;border:1px solid var(--border);border-radius:8px;margin-top:6px}
.pl-txt mark.pl-f{background:rgba(80,216,144,.18);color:inherit;border-radius:3px;padding:0 2px}
.pl-meta{padding:0 12px 6px}
.pl-foot{display:flex;flex-wrap:wrap;gap:6px;padding:8px 12px;border-top:1px solid var(--border)}
.pl-foot .pl-done,.pl-common .pl-done{background:var(--primary);color:#fff;border-color:var(--primary)}
.pl-gen{display:grid;grid-template-columns:repeat(auto-fill,minmax(min(100%,320px),1fr));gap:10px}
.pl-gsec{border:1px solid var(--border);border-radius:8px;padding:8px 10px;background:var(--surface)}
.pl-gh{font-weight:600;margin-bottom:6px}
.pl-gi{display:flex;gap:8px;align-items:flex-start;font-size:13px;line-height:1.45;padding:3px 0;cursor:pointer}
.pl-gi input{margin-top:3px;flex:none}
.pl-gi input:checked+span{color:var(--text-3);text-decoration:line-through}
.pl-cl td{vertical-align:top;font-size:12.5px}
.pl-sg{margin-bottom:14px}
.pl-sgh{font-weight:600;margin:6px 0}

/* V2.13 Batch 4 item 6: QA/QC & EHS manuals as web content */
.md-wrap{display:grid;grid-template-columns:300px minmax(0,1fr);gap:16px;align-items:start;margin-top:10px}
.md-toc{position:sticky;top:70px;max-height:calc(100vh - 90px);overflow:auto;background:var(--surface);border:1px solid var(--border);border-radius:10px;padding:10px}
.md-srch input{width:100%}
.md-tocd>summary{font-weight:600;font-size:13px;margin:10px 0 6px;cursor:pointer;color:var(--text-2)}
.md-tc{margin:2px 0}
.md-tc>summary{list-style:none;cursor:pointer}
.md-tc>summary::-webkit-details-marker{display:none}
.md-tc>summary a{display:flex;gap:8px;align-items:flex-start;padding:6px 8px;border-radius:8px;color:var(--text);text-decoration:none;font-size:13px;line-height:1.3}
.md-tc>summary a small{display:block;font-size:11px;color:var(--text-3);text-transform:uppercase;letter-spacing:.04em}
.md-tc>summary a:hover,.md-tc>summary a.on{background:var(--surface-2)}
.md-tc>summary a.on{box-shadow:inset 3px 0 0 var(--primary)}
.md-ic{flex:none;width:26px;height:26px;border-radius:7px;display:grid;place-items:center;background:rgba(80,216,144,.14);color:var(--primary-ink)}
.md-ic svg{width:15px;height:15px}
.md-tc ol{margin:2px 0 6px 34px;padding:0;list-style:none;border-left:1px solid var(--border)}
.md-tc ol a{display:block;padding:3px 8px;font-size:12.5px;color:var(--text-2);text-decoration:none;line-height:1.35}
.md-tc ol a:hover,.md-tc ol a.on{color:var(--primary-ink);background:var(--surface-2)}
.md-rv{font-size:10px;color:var(--secondary-ink)}
.md-main{min-width:0}
.md-ch{display:flex;gap:12px;align-items:center;flex-wrap:wrap;background:var(--surface);border:1px solid var(--border);border-radius:10px;padding:12px 14px;margin-bottom:10px}
.md-ch h2{margin:2px 0;font-size:20px}
.md-chic{width:44px;height:44px;border-radius:12px;display:grid;place-items:center;background:var(--kx-gradient);color:#fff;flex:none}
.md-chic svg{width:22px;height:22px}
.md-chb{margin-left:auto;display:flex;gap:6px}
.md-sec{background:var(--surface);border:1px solid var(--border);border-radius:10px;margin-bottom:8px}
.md-sec>summary{cursor:pointer;padding:11px 14px;display:flex;gap:10px;align-items:center;flex-wrap:wrap;font-weight:600}
.md-sec[open]>summary{border-bottom:1px solid var(--border)}
.md-st{flex:1;min-width:0}
.md-rvb{font-size:11px;font-weight:500;padding:2px 8px;border-radius:999px;background:rgba(79,152,202,.13);color:var(--secondary-ink)}
.md-sb{padding:10px 14px 14px}
.md-tools{display:flex;gap:6px;justify-content:flex-end;margin-bottom:4px}
.md-doc{font-size:14px;line-height:1.6;overflow-wrap:anywhere}
.md-doc h3{font-size:16px;margin:16px 0 6px;color:var(--accent)}
.md-doc h4{font-size:14.5px;margin:14px 0 6px}
.md-doc h5,.md-doc h6{font-size:13.5px;margin:12px 0 4px}
:root[data-theme="dark"] .md-doc h3{color:var(--kx-green)}
.md-doc ul,.md-doc ol{padding-left:22px}
.md-doc mark,.md-res mark{background:rgba(255,213,79,.55);color:inherit;border-radius:2px}
.md-tw{overflow-x:auto;margin:10px 0;border:1px solid var(--border);border-radius:8px}
.md-doc table{border-collapse:collapse;width:100%;font-size:13px}
.md-doc th,.md-doc td{border:1px solid var(--border);padding:6px 8px;vertical-align:top;text-align:left}
.md-tw table{border:0}.md-tw tr>*:first-child{border-left:0}.md-tw tr>*:last-child{border-right:0}.md-tw thead tr:first-child>*{border-top:0}.md-tw tbody tr:last-child>*{border-bottom:0}
.md-doc thead th{background:var(--kx-teal-dark);color:#fff;font-weight:600}
.md-doc tbody tr:nth-child(even) td{background:var(--surface-2)}
.md-formw{border-style:dashed;border-color:var(--border-strong)}
.md-fh{display:flex;gap:8px;align-items:center;padding:7px 10px;background:var(--surface-2);border-bottom:1px dashed var(--border-strong);font-size:13px}
.md-fh svg{width:16px;height:16px}.md-fh button{margin-left:auto}
.md-formw thead th{background:var(--surface-2);color:var(--text)}
.md-formw td:empty{background:repeating-linear-gradient(0deg,transparent 0 22px,var(--border) 22px 23px)!important;min-width:80px;height:26px}
.md-call{border-radius:8px;padding:10px 12px;margin:10px 0;border:1px solid var(--border);border-left:4px solid var(--secondary);background:rgba(79,152,202,.08);font-size:13.5px}
.md-call.imp{border-left-color:#d9534f;background:rgba(217,83,79,.08)}
.md-ck{border:1px solid var(--border);border-radius:10px;margin:12px 0;overflow:hidden}
.md-ckh{display:flex;gap:8px;align-items:center;flex-wrap:wrap;padding:8px 12px;background:var(--surface-2);border-bottom:1px solid var(--border)}
.md-ckic{width:24px;height:24px;border-radius:6px;display:grid;place-items:center;background:var(--primary);color:#fff}.md-ckic svg{width:14px;height:14px}
.md-cki{display:flex;gap:10px;padding:10px 12px;border-bottom:1px solid var(--border)}
.md-cki[data-a="Yes"]{background:rgba(80,216,144,.08)}.md-cki[data-a="No"]{background:rgba(217,83,79,.07)}
.md-ckn{flex:none;width:30px;height:30px;border-radius:50%;display:grid;place-items:center;background:var(--surface-2);font-weight:600;font-size:12px}
.md-ckb{flex:1;min-width:0}
.md-ckt{font-weight:500}
.md-cka{font-size:12.5px;color:var(--text-2);margin-top:2px}.md-cka span{font-weight:600}
.md-ckc{display:flex;gap:8px;flex-wrap:wrap;margin-top:6px;align-items:center}
.md-ckc input{flex:1;min-width:160px;font-size:13px}
.md-seg{display:inline-flex;border:1px solid var(--border-strong);border-radius:8px;overflow:hidden}
.md-seg button{border:0;background:var(--surface);padding:5px 12px;font-size:12.5px;cursor:pointer;color:var(--text)}
.md-seg button+button{border-left:1px solid var(--border-strong)}
.md-seg button.on[data-v="Yes"]{background:var(--primary);color:#fff}.md-seg button.on[data-v="No"]{background:#d9534f;color:#fff}.md-seg button.on[data-v="N/A"]{background:var(--text-3);color:#fff}
.md-ckf{padding:6px 12px}
.md-res{background:var(--surface);border:1px solid var(--border);border-radius:10px;padding:6px}
.md-rh{padding:8px 10px}
.md-hit{display:block;padding:9px 10px;border-radius:8px;text-decoration:none;color:var(--text);border-top:1px solid var(--border)}
.md-hit:hover{background:var(--surface-2)}
.md-ht{font-weight:600;margin:2px 0}
.md-foot{margin:12px 2px}
.md-rte{border:1px solid var(--border-strong);border-radius:8px;overflow:hidden}
.md-tb{display:flex;flex-wrap:wrap;gap:4px;padding:6px;background:var(--surface-2);border-bottom:1px solid var(--border);position:sticky;top:0;z-index:2}
.md-tb button{border:1px solid var(--border);background:var(--surface);border-radius:6px;padding:4px 9px;font-size:12.5px;cursor:pointer;color:var(--text)}
.md-ed{min-height:45vh;max-height:62vh;overflow:auto;padding:12px 14px;outline:none;background:var(--surface)}
@media (max-width:900px){.md-wrap{grid-template-columns:1fr}.md-toc{position:static;max-height:none}.md-chb{margin-left:0}}
/* V2.13 Generate Cashflow layout */
.cfg-t td:first-child,.cfg-t th:first-child{white-space:nowrap}
@media (min-width: 1201px){.cfg-ch{grid-template-columns:minmax(0,1.4fr) minmax(0,1.4fr) minmax(0,1fr)}}
@media (max-width: 700px){.cfg-ch{grid-template-columns:1fr}}

/* ===== V2.14 Batch 5: avatars, welcome card, Running tasks indicator, chunked upload panel ===== */
.kx-av { display: inline-block; vertical-align: middle; border: 2px solid var(--bg, #fff); box-shadow: 0 1px 3px rgba(0,0,0,.15); }
.kx-av-i { display: inline-flex; align-items: center; justify-content: center; background: var(--kx-gradient); color: #fff; font-weight: 700; text-decoration: none; letter-spacing: .02em; }
#user-av.has-photo { background: none; padding: 0; overflow: hidden; }
.kx-welcome .card-b { background: linear-gradient(120deg, rgba(80,216,144,.10), rgba(79,152,202,.10)); border-radius: inherit; }
.kx-team { min-width: 220px; }
.kx-team-row { display: flex; flex-wrap: wrap; gap: 0; }
.kx-team-row > a { margin-right: -6px; transition: transform .12s; }
.kx-team-row > a:hover { transform: translateY(-3px); z-index: 1; }
.kx-tasks { position: fixed; right: 18px; bottom: 18px; z-index: 1200; }
.kx-tasks-btn { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-radius: 22px; border: 1px solid var(--border, #d6e6e2); background: var(--surface, #fff); color: inherit; box-shadow: 0 6px 20px rgba(0,0,0,.18); cursor: pointer; font: inherit; }
.kx-tasks-btn:hover { box-shadow: 0 8px 26px rgba(0,0,0,.24); }
.kx-spin { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--kx-blue); border-top-color: transparent; display: inline-block; animation: kx-spin .8s linear infinite; }
@keyframes kx-spin { to { transform: rotate(360deg); } }
.kx-upl { position: fixed; left: 18px; bottom: 18px; z-index: 1200; width: min(380px, calc(100vw - 36px)); background: var(--surface, #fff); color: inherit; border: 1px solid var(--border, #d6e6e2); border-radius: 12px; box-shadow: 0 6px 20px rgba(0,0,0,.18); padding: 10px 12px; max-height: 50vh; overflow: auto; }
.kx-upl-h { display: flex; flex-direction: column; gap: 2px; margin-bottom: 6px; }
.kx-upl-r { margin-top: 6px; }
.kx-upl .ai-bar { height: 6px; }
.kx-login-tc { display: flex; gap: 8px; align-items: flex-start; margin: 10px 0 4px; font-size: 13px; }
.kx-login-tc input { margin-top: 2px; }
button[data-signin]:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- V2.15 installable phone app ---------- */
.kx-pwa-banner { position: fixed; left: 10px; right: 10px; bottom: calc(10px + env(safe-area-inset-bottom, 0px)); z-index: 90; display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: var(--surface, #fff); color: var(--text, #272727); border: 1px solid var(--border, #d9e6e2); border-radius: 12px; box-shadow: 0 8px 28px rgba(39,39,39,.18); max-width: 560px; margin: 0 auto; }
.kx-pwa-banner img { border-radius: 9px; flex: 0 0 auto; }
.kx-pwa-banner .t { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; font-size: 13px; line-height: 1.3; }
.kx-pwa-banner .t span { color: var(--text-3, #5d6b67); font-size: 12px; }
.kx-pwa-banner .btn { flex: 0 0 auto; min-height: 38px; }
@media (max-width: 420px) { .kx-pwa-banner { flex-wrap: wrap; } .kx-pwa-banner .t { flex-basis: calc(100% - 50px); } .kx-pwa-banner .btn { flex: 1 1 40%; } }
.kx-pwa-steps { padding-left: 20px; line-height: 1.55; } .kx-pwa-steps li { margin-bottom: 6px; }
.kx-net { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: #fff4d6; color: #7a5300; border: 1px solid #f0d58a; white-space: nowrap; }
.kx-net::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: #d08a00; }
.kx-net[hidden] { display: none; }
@media print { .kx-pwa-banner, .kx-net { display: none !important; } }
/* phones: figure cards two across instead of one card per screen */
@media (max-width: 640px) {
  .g2:has(> .kpi), .g3:has(> .kpi), .g4:has(> .kpi) { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .kpi { padding: 10px 12px; } .kpi .val { font-size: 19px; } .kpi .lbl { font-size: 10.5px; letter-spacing: .03em; } .kpi .foot { font-size: 11px; }
}
/* installed app: room for the iPhone home bar */
.kx-installed .content { padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px)); }

/* V2.16 (audit D-22): controls large enough for a finger on tablets and phones */
@media (pointer: coarse), (max-width: 860px) { table.t input, table.t select { min-height: 36px; } .cde-fm { min-width: 40px; min-height: 40px; font-size: 20px; opacity: .8; } }
/* V2.16 Help & User Manual: pictures with numbered callouts, the "?" button */
.hm-fig{margin:12px 0;padding:0;text-align:center}
.hm-fig img{max-width:100%;height:auto;border:1px solid var(--border);border-radius:8px;cursor:zoom-in;background:#fff}
.hm-fig figcaption{font-size:12.5px;color:var(--text-2);margin-top:4px}
.hm-doc blockquote{margin:10px 0;padding:8px 12px;border-left:4px solid var(--kx-green,#50d890);background:var(--surface-2);border-radius:0 8px 8px 0}
.hm-doc table{width:100%}
.md-toc .md-tc>summary{display:block}
