/* =========================================================================
 * Operiaz — styles. Light theme by default, dark theme via [data-theme=dark].
 * All colours are tokens on :root so a theme is a single block of overrides.
 * ========================================================================= */
:root {
  color-scheme: light;
  --bg: #f4f4f1;
  --surface: #fcfcfb;
  --surface-2: #f0efec;
  --border: #e1e0d9;
  --border-strong: #c3c2b7;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #7a7872;
  --primary: #1c5cab;
  --primary-ink: #ffffff;
  --primary-soft: #cde2fb;
  --danger: #b42f2f;
  --good: #0ca30c;
  --warn: #c98500;
  --late: #d03b3b;
  --shadow: 0 1px 2px rgba(11, 11, 11, .06), 0 4px 14px rgba(11, 11, 11, .05);
  --radius: 8px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
:root[data-theme="dark"] {   /* industrial graphite + safety orange (pre-prototype theme) */
  color-scheme: dark;
  --bg: #111315;
  --surface: #1b1f23;
  --surface-2: #23282e;
  --border: #2e343b;
  --border-strong: #454d56;
  --ink: #e6e8ea;
  --ink-2: #b8bfc6;
  --muted: #8b949e;
  --primary: #f59e0b;
  --primary-ink: #111315;
  --primary-soft: #3a2a0c;
  --danger: #ef4444;
  --good: #22c55e;
  --warn: #eab308;
  --late: #ef4444;
  --shadow: 0 1px 0 rgba(0, 0, 0, .5);
  --radius: 4px;
}
/* orange is light: dark ink on anything filled with --primary */
:root[data-theme="dark"] :is(.btn.primary, .seg button.on, button.chip.on, .view-chip.on button, .menu-row.on button, .wel-n) { color: var(--primary-ink); }

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 14px/1.45 var(--font); color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: var(--primary); }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 22px; font-weight: 650; }
h2 { font-size: 15px; font-weight: 620; }
h3 { font-size: 14px; font-weight: 620; margin: 18px 0 8px; }
.mono { font-family: var(--mono); font-size: 12.5px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.empty { color: var(--muted); font-style: italic; padding: 12px 0; margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* ---------- layout ---------- */
.app { display: flex; height: 100vh; overflow: hidden; }
.ico { width: 18px; height: 18px; fill: currentColor; flex: none; }
.main-col { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.home-btn { display: flex; align-items: center; gap: 10px; flex: none; color: var(--ink); font-weight: 650; font-size: 15px; text-decoration: none; }
.home-btn:hover { text-decoration: none; }
.home-btn .logo { width: 30px; height: 30px; }
.topbar { display: flex; align-items: center; gap: 10px; padding: 8px 16px; background: var(--surface); border-bottom: 1px solid var(--border); position: relative; z-index: 20; }
.view { flex: 1; overflow-y: auto; padding: 20px 24px 60px; }

.search-box { position: relative; flex: 1; max-width: 520px; }
.search-box input { width: 100%; padding: 8px 12px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface-2); }
.search-results { position: absolute; top: 100%; left: 0; right: 0; margin: 4px 0 0; padding: 4px 0; list-style: none; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow); max-height: 70vh; overflow-y: auto; z-index: 50; }
.search-results a { display: block; padding: 6px 12px; color: var(--ink); text-decoration: none; }
.search-results a:hover { background: var(--surface-2); }
.sr-h { padding: 6px 12px 2px; font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); }
.sr-empty, .sr-foot { padding: 6px 12px; color: var(--muted); font-size: 12px; }
.sr-foot { border-top: 1px solid var(--border); margin-top: 4px; }
.me-box { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.me-box select { max-width: 190px; padding: 6px 8px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); }
.bell { position: relative; }
.bell-count { position: absolute; top: 0; right: 0; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 9px; background: var(--late); color: #fff; font-size: 10.5px; font-weight: 700; line-height: 17px; text-align: center; }
.lang-btn { font-weight: 700; min-width: 44px; }

/* ---------- buttons & forms ---------- */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--ink); border-radius: 6px; cursor: pointer; font-weight: 520; white-space: nowrap; text-decoration: none; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger-ghost { border-color: transparent; background: transparent; color: var(--danger); }
.btn.danger-ghost:hover { background: rgba(208, 59, 59, .1); }
.btn.sm { padding: 4px 9px; font-size: 12.5px; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.file-btn { position: relative; }
.icon-btn { border: 0; background: transparent; width: 36px; height: 36px; border-radius: 6px; cursor: pointer; font-size: 20px; line-height: 1; display: inline-flex; align-items: center; justify-content: center; color: var(--ink-2); }
.icon-btn:hover { background: var(--surface-2); }
.btn-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 0 0 12px; }
.seg { display: inline-flex; border: 1px solid var(--border-strong); border-radius: 6px; overflow: hidden; }
.seg button { border: 0; background: var(--surface); padding: 5px 12px; cursor: pointer; }
.seg button.on { background: var(--primary); color: #fff; }
.search-inline { display: flex; gap: 6px; }
.search-inline input { padding: 6px 10px; border: 1px solid var(--border-strong); border-radius: 6px; min-width: 220px; background: var(--surface); }
.inline-sel { display: inline-flex; gap: 6px; align-items: center; font-size: 12.5px; color: var(--muted); }
.inline-sel select, .page-head select { padding: 6px 8px; border: 1px solid var(--border-strong); border-radius: 6px; background: var(--surface); max-width: 280px; }

.form-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px 14px; }
.fld { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.fld.full, .form-grid > .full { grid-column: 1 / -1; }
.fld.half { grid-column: span 2; }
.fld-l { font-size: 12px; font-weight: 600; color: var(--ink-2); }
.req { color: var(--late); }
.fld input:not([type=checkbox]):not([type=color]):not([type=range]), .fld select, .fld textarea, .tbl input:not([type=checkbox]):not([type=color]), .tbl select {
  width: 100%; padding: 7px 9px; border: 1px solid var(--border-strong); border-radius: 6px; background: var(--surface);
}
.fld textarea { resize: vertical; }
.fld select.multi { min-height: 90px; }
.help { color: var(--muted); font-size: 11.5px; }
fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px 12px; margin: 0; }
legend { font-weight: 600; font-size: 12.5px; padding: 0 4px; }
.checklist { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 2px 12px; max-height: 150px; overflow-y: auto; border: 1px solid var(--border); border-radius: 6px; padding: 6px 8px; }
.chk { display: inline-flex; gap: 6px; align-items: center; cursor: pointer; font-size: 13px; }
.chk.block { display: flex; padding: 5px 0; }
.check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 0 16px; margin-bottom: 12px; }
.form-error { color: var(--danger); background: rgba(208, 59, 59, .08); border: 1px solid rgba(208, 59, 59, .35); border-radius: 6px; padding: 8px 10px; margin: 12px 0 0; font-weight: 550; }
h3.sub { margin: 6px 0 -2px; padding-top: 10px; border-top: 1px solid var(--border); }

/* ---------- page structure ---------- */
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head p { margin: 4px 0 0; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 14px; box-shadow: var(--shadow); min-width: 0; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.callout { background: var(--surface-2); border-left: 3px solid var(--primary); padding: 8px 12px; border-radius: 4px; margin: 0 0 12px; }
.callout.ok { border-left-color: var(--good); }
.error-box pre { white-space: pre-wrap; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: thin; }
.tab { border: 0; background: transparent; padding: 8px 12px; cursor: pointer; color: var(--ink-2); border-bottom: 2px solid transparent; white-space: nowrap; font-weight: 520; }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.page-tabs { margin-bottom: 14px; }
ul.plain { list-style: none; padding: 0; margin: 0; }
ul.plain li { padding: 5px 0; border-bottom: 1px dashed var(--border); }

/* ---------- badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 10px; font-size: 11.5px; font-weight: 600; white-space: nowrap;
  color: var(--ink); background: color-mix(in srgb, var(--c, #898781) 16%, transparent); border: 1px solid color-mix(in srgb, var(--c, #898781) 45%, transparent); }
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--c, #898781); }
.badge.outline { background: transparent; border-color: var(--border-strong); color: var(--ink-2); }
.badge.outline::before, .badge.late::before { display: none; }
.badge.late { background: var(--late); border-color: var(--late); color: #fff; }
.badge.sm { font-size: 10px; padding: 0 5px; }
.svc { display: inline-block; padding: 1px 7px; border-radius: 4px; font-size: 11.5px; font-weight: 600; white-space: nowrap; color: var(--ink); background: color-mix(in srgb, var(--c) 14%, transparent); border-left: 3px solid var(--c); }
.prio { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.prio::before { content: ""; width: 10px; height: 10px; border-radius: 2px; background: var(--c); }
.prio-critical { color: var(--late); }
.late-txt { color: var(--late); font-weight: 600; }
.late-pill { display: inline-block; background: var(--late); color: #fff; font-size: 10.5px; font-weight: 700; padding: 0 5px; border-radius: 8px; margin-left: 3px; }
.pdca-tag { display: inline-block; width: 22px; text-align: center; border-radius: 4px; font-weight: 700; font-size: 12px; color: #fff; }
.pdca-P { background: #2a78d6; } .pdca-D { background: #eb6834; } .pdca-C { background: #1baf7a; } .pdca-A { background: #4a3aa7; }
.qcd { display: inline-flex; gap: 3px; }
.qcd-i { width: 22px; height: 22px; display: inline-flex; align-items: center; justify-content: center; border-radius: 4px; font-size: 11px; font-weight: 700; border: 1px solid var(--border-strong); color: var(--muted); }
.qcd-i.lvl1 { background: #fde9b8; color: #6b4a00; border-color: #eda100; }
.qcd-i.lvl2 { background: #f7c7b2; color: #7a2a0b; border-color: #ec835a; }
.qcd-i.lvl3 { background: #d03b3b; color: #fff; border-color: #d03b3b; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 3px 4px 3px 10px; border-radius: 14px; background: var(--primary-soft); color: var(--ink); font-size: 12.5px; border: 0; }
button.chip { padding: 4px 12px; cursor: pointer; background: var(--surface); border: 1px solid var(--border-strong); }
button.chip.on { background: var(--primary); color: #fff; border-color: var(--primary); }
.chip-x { border: 0; background: transparent; cursor: pointer; font-size: 15px; line-height: 1; padding: 0 5px; color: var(--ink-2); border-radius: 50%; }
.chip-x:hover { background: rgba(0,0,0,.1); }
.views-bar { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 10px; }
.view-chip { display: inline-flex; align-items: center; border: 1px solid var(--border-strong); border-radius: 14px; background: var(--surface); }
.view-chip button:first-child { border: 0; background: transparent; padding: 3px 4px 3px 10px; cursor: pointer; font-size: 12.5px; }
.view-chip.on { background: var(--primary); border-color: var(--primary); }
.view-chip.on button { color: #fff; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { text-align: left; font-size: 11.5px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .3px; padding: 7px 8px; border-bottom: 1px solid var(--border-strong); white-space: nowrap; background: var(--surface); }
.tbl td { padding: 7px 8px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.tbl tr.clickable { cursor: pointer; }
.tbl tr.clickable:hover td { background: var(--surface-2); }
.tbl tr.row-late td:first-child { box-shadow: inset 3px 0 0 var(--late); }
.title-cell { min-width: 220px; max-width: 420px; }
.th-sort { border: 0; background: transparent; font: inherit; color: inherit; text-transform: inherit; letter-spacing: inherit; cursor: pointer; padding: 0; }
.th-sort.on { color: var(--primary); }
.flags { white-space: nowrap; font-size: 12px; color: var(--ink-2); }
.flags span { margin-right: 4px; }
.meter-cell { min-width: 110px; white-space: nowrap; }
.meter-cell small { margin-left: 6px; color: var(--muted); font-variant-numeric: tabular-nums; }
.meter { display: inline-block; vertical-align: middle; width: 70px; height: 6px; border-radius: 3px; background: var(--surface-2); border: 1px solid var(--border); overflow: hidden; }
.meter-fill { display: block; height: 100%; border-radius: 3px; }
.matrix td.hot { background: color-mix(in srgb, #2a78d6 calc(var(--o) * 45%), transparent); font-weight: 700; }

/* ---------- KPIs & charts ---------- */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(138px, 1fr)); gap: 10px; margin-bottom: 16px; }
.kpi { text-align: left; border: 1px solid var(--border); background: var(--surface); border-radius: var(--radius); padding: 10px 12px; cursor: pointer; display: flex; flex-direction: column; gap: 2px; box-shadow: var(--shadow); border-top: 3px solid var(--border-strong); }
.kpi:hover { border-color: var(--primary); }
.kpi.static { cursor: default; }
.kpi-v { font-size: 22px; font-weight: 680; line-height: 1.1; }
.kpi-l { font-size: 11.5px; color: var(--muted); font-weight: 550; }
.kpi.bad { border-top-color: var(--late); } .kpi.bad .kpi-v { color: var(--late); }
.kpi.warn { border-top-color: #fab219; }
.kpi.good { border-top-color: var(--good); }
.kpi-grid.small .kpi-v { font-size: 18px; }
/* Home launcher */
.app-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.app-tile { display: flex; gap: 14px; align-items: flex-start; padding: 16px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); color: var(--ink); text-decoration: none; transition: transform .12s, border-color .12s; }
.app-tile:hover { border-color: var(--primary); transform: translateY(-2px); text-decoration: none; }
.app-ico { flex: none; width: 52px; height: 52px; border-radius: 12px; display: grid; place-items: center; background: #1c5cab; }
.app-ico .ico { width: 28px; height: 28px; fill: #fff; }
.app-txt { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.app-txt b { font-size: 15px; }
.app-stat { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; font-size: 12.5px; font-weight: 600; }
.app-alert { color: var(--danger); }
.app-dashboard .app-ico { background: #1c5cab; } .app-projects .app-ico { background: #e8871e; } .app-actions .app-ico { background: #2e9d5b; }
.app-milestones .app-ico { background: #8e44ad; } .app-planning .app-ico { background: #00897b; } .app-pdca .app-ico { background: #d64550; }
.app-changes .app-ico { background: #3f51b5; } .app-analytics .app-ico { background: #f2b01e; } .app-settings .app-ico { background: #607d8b; }
.app-account .app-ico { background: #795548; } .app-console .app-ico { background: #263238; }
@media (max-width: 600px) { .app-grid { grid-template-columns: 1fr 1fr; gap: 10px; } .app-tile { flex-direction: column; align-items: center; text-align: center; padding: 14px 8px; } .app-txt .muted { display: none; } .app-stat { justify-content: center; } }
.chart-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); gap: 14px; }
.chart-grid .card { margin: 0; }
.chart-card.span2 { grid-column: span 2; }
.chart-svg { width: 100%; height: auto; display: block; }
.chart-svg .grid { stroke: var(--border); stroke-width: 1; }
.chart-svg .axis { stroke: var(--border-strong); stroke-width: 1; }
.chart-svg .target { stroke: var(--good); stroke-width: 1.5; stroke-dasharray: 5 4; }
.chart-svg .tick { fill: var(--muted); font-size: 11.5px; }
.chart-svg .dot { stroke: var(--surface); stroke-width: 2; }
.chart-svg rect:hover, .donut path:hover { opacity: .8; }
.hbar { display: flex; flex-direction: column; gap: 5px; }
.hbar-row { display: grid; grid-template-columns: minmax(90px, 38%) 1fr 44px; gap: 8px; align-items: center; font-size: 12.5px; padding: 1px 2px; border-radius: 4px; }
.hbar-row.clickable { cursor: pointer; }
.hbar-row.clickable:hover { background: var(--surface-2); }
.hbar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-2); }
.hbar-track { height: 12px; background: transparent; position: relative; }
.hbar-fill { display: block; height: 100%; border-radius: 0 4px 4px 0; min-width: 2px; }
.hbar-value { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.donut-wrap { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.donut { width: 150px; height: 150px; flex: none; }
.donut-total { font-size: 17px; font-weight: 700; fill: var(--ink); }
.donut-sub { font-size: 7px; fill: var(--muted); }
.donut-wrap .legend { flex-direction: column; flex: 1; min-width: 140px; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 8px; font-size: 12px; color: var(--ink-2); }
.legend-item { display: inline-flex; align-items: center; gap: 5px; }
.swatch { width: 10px; height: 10px; border-radius: 2px; flex: none; }
.ms-progress { display: flex; flex-direction: column; gap: 8px; }
.msp-row { display: grid; grid-template-columns: 70px 1fr 46px; gap: 8px; align-items: center; }
.msp-name { font-weight: 650; text-decoration: none; }
.msp-chips { display: flex; flex-wrap: wrap; gap: 3px; }
.msp-pct { text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); }
.ms-chip { border: 1px solid var(--c); background: color-mix(in srgb, var(--c) 25%, var(--surface)); color: var(--ink); font-size: 11px; font-weight: 650; padding: 2px 6px; border-radius: 4px; cursor: pointer; }
.ms-chip.late { outline: 2px solid var(--late); outline-offset: 1px; }

/* ---------- Kanban ---------- */
.kanban { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 10px; align-items: flex-start; }
.kb-col { flex: 0 0 250px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); display: flex; flex-direction: column; max-height: calc(100vh - 230px); }
.kb-col.over { outline: 2px dashed var(--primary); }
.kb-col header { display: flex; justify-content: space-between; padding: 8px 10px; font-weight: 620; border-top: 3px solid var(--c, var(--primary)); border-radius: var(--radius) var(--radius) 0 0; }
.kb-cards { padding: 6px; display: flex; flex-direction: column; gap: 6px; overflow-y: auto; min-height: 60px; }
.kb-card { background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--c); border-radius: 6px; padding: 8px; cursor: grab; box-shadow: var(--shadow); }
.kb-card.late { border-color: var(--late); border-left-color: var(--late); }
.kb-card.dragging { opacity: .5; }
.kb-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 3px; }
.kb-title { display: block; color: var(--ink); text-decoration: none; font-weight: 600; margin-bottom: 4px; }
.kb-title:hover { color: var(--primary); }
.kb-meta { margin-top: 3px; }
.pdca-board .kb-col { flex: 1 0 250px; }
.pdca-col header { border-top-width: 4px; }
.pdca-P header { border-top-color: #2a78d6; } .pdca-D header { border-top-color: #eb6834; } .pdca-C header { border-top-color: #1baf7a; } .pdca-A header { border-top-color: #4a3aa7; }
.pdca-help { margin: 0; padding: 0 10px 4px; }
.pdca-move { display: flex; justify-content: space-between; margin-top: 6px; }
.add-card { margin: 4px 6px 8px; }

/* ---------- Calendar & Gantt ---------- */
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border-left: 1px solid var(--border); border-top: 1px solid var(--border); }
.cal-wd { font-size: 11.5px; font-weight: 600; color: var(--muted); padding: 5px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); text-transform: capitalize; background: var(--surface-2); }
.cal-cell { min-height: 96px; padding: 3px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.cal-cell.out { background: var(--surface-2); opacity: .6; }
.cal-cell.today { box-shadow: inset 0 0 0 2px var(--primary); }
.cal-d { font-size: 11.5px; font-weight: 650; color: var(--ink-2); }
.cal-ms, .cal-act, .cal-more { border: 0; text-align: left; font-size: 11px; padding: 1px 4px; border-radius: 3px; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; width: 100%; }
.cal-ms { background: var(--c); color: #fff; font-weight: 700; }
.cal-act { background: color-mix(in srgb, var(--c) 16%, var(--surface)); border-left: 3px solid var(--c); color: var(--ink); }
.cal-act.late { box-shadow: inset 0 0 0 1px var(--late); }
.cal-act.done { text-decoration: line-through; opacity: .6; }
.cal-more { background: transparent; color: var(--primary); }
.gantt { position: relative; }
.g-axis { position: relative; height: 20px; margin-left: 34%; border-bottom: 1px solid var(--border-strong); }
.g-axis span { position: absolute; font-size: 10.5px; color: var(--muted); transform: translateX(-2px); white-space: nowrap; border-left: 1px solid var(--border-strong); padding-left: 3px; }
.g-row { display: grid; grid-template-columns: 34% 1fr; align-items: center; min-height: 26px; border-bottom: 1px solid var(--border); }
.g-label { border: 0; background: transparent; text-align: left; font-size: 12px; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 3px 6px 3px 0; color: var(--ink); }
.g-label:hover { color: var(--primary); }
.g-track { position: relative; height: 26px; }
.g-bar { position: absolute; top: 8px; height: 10px; border-radius: 3px; background: color-mix(in srgb, var(--c) 55%, transparent); }
.g-bar.late { background: repeating-linear-gradient(45deg, color-mix(in srgb, var(--late) 55%, transparent) 0 4px, transparent 4px 7px); }
.g-diamond { position: absolute; top: 7px; width: 12px; height: 12px; background: var(--c); transform: translateX(-6px) rotate(45deg); border: 2px solid var(--surface); }
.g-today { position: absolute; top: 0; bottom: 0; width: 0; border-left: 2px dashed var(--late); opacity: .7; }

/* ---------- Drawer ---------- */
.drawer { position: fixed; inset: 0; background: rgba(11, 11, 11, .3); z-index: 60; display: flex; justify-content: flex-end; }
.drawer[hidden] { display: none; }
.drawer-box { width: min(760px, 100%); height: 100%; background: var(--surface); display: flex; flex-direction: column; box-shadow: -6px 0 24px rgba(0,0,0,.18); }
.drawer-head { padding: 14px 18px 0; border-bottom: 1px solid var(--border); position: relative; }
.drawer-head .icon-btn { position: absolute; right: 10px; top: 10px; }
.drawer-head h2 { font-size: 18px; margin: 6px 40px 10px 0; }
.drawer-id { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; padding-right: 40px; }
.status-row { margin-top: 6px; }
.drawer-head .tabs { margin-top: 10px; border-bottom: 0; }
.drawer-body { padding: 16px 18px 40px; overflow-y: auto; flex: 1; }
.desc { white-space: pre-wrap; margin-top: 0; }
.grid-dl { display: grid; grid-template-columns: 160px 1fr; gap: 6px 14px; margin: 0; }
.grid-dl dt { color: var(--muted); font-size: 12.5px; font-weight: 600; }
.grid-dl dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.proj-info .grid-dl { grid-template-columns: 150px 1fr 150px 1fr; }
.proj-progress { display: flex; gap: 24px; flex-wrap: wrap; margin-top: 12px; font-size: 12.5px; color: var(--ink-2); }
.proj-progress .meter { width: 160px; }
.progress-line { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.progress-line .meter { width: 180px; }
.progress-line input[type=range] { flex: 1; min-width: 140px; }
.timeline { list-style: none; margin: 0; padding: 0 0 0 4px; }
.tl-item { display: flex; gap: 10px; position: relative; padding-bottom: 12px; }
.tl-item::before { content: ""; position: absolute; left: 4px; top: 14px; bottom: 0; width: 1px; background: var(--border-strong); }
.tl-item:last-child::before { display: none; }
.tl-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--border-strong); margin-top: 5px; flex: none; }
.tl-transfer .tl-dot { background: #eb6834; } .tl-decision .tl-dot, .tl-approval .tl-dot, .tl-gate .tl-dot { background: #4a3aa7; }
.tl-closed .tl-dot { background: var(--good); } .tl-reopened .tl-dot { background: var(--late); } .tl-created .tl-dot { background: var(--primary); }
.tl-body { min-width: 0; flex: 1; }
.tl-text { color: var(--ink-2); margin-top: 2px; overflow-wrap: anywhere; }
.tl-transfer .tl-body { background: var(--surface-2); border-radius: 6px; padding: 6px 10px; }
.transfer-dl { display: grid; grid-template-columns: 130px 1fr; gap: 3px 10px; margin: 6px 0 0; font-size: 12.5px; }
.transfer-dl dt { color: var(--muted); } .transfer-dl dd { margin: 0; }
.changes { margin: 4px 0 0; padding-left: 18px; }
.changes del { color: var(--muted); } .changes ins { text-decoration: none; font-weight: 600; }
.comments, .evidence, .decisions, .notif-list { list-style: none; padding: 0; margin: 12px 0 0; }
.comments li, .evidence li, .decisions li { border: 1px solid var(--border); border-radius: 6px; padding: 8px 10px; margin-bottom: 8px; }
.comments li.sys { background: var(--surface-2); }
.comments p, .decisions p { margin: 4px 0 0; white-space: pre-wrap; }
.decisions li { border-left: 3px solid var(--border-strong); }
.decisions .dec-rejected, .decisions .dec-failed { border-left-color: var(--late); }
.decisions .dec-accepted, .decisions .dec-passed { border-left-color: var(--good); }
.decisions .dec-conditional, .decisions .dec-passed_cond, .decisions .dec-on_hold { border-left-color: #fab219; }
.notif-list li { padding: 6px 0; border-bottom: 1px solid var(--border); }
.notif-list a { color: var(--ink); text-decoration: none; }
.inline-form { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.inline-form textarea { width: 100%; padding: 8px; border: 1px solid var(--border-strong); border-radius: 6px; background: var(--surface); }
.inline-form .btn { align-self: flex-start; }
.checklist-status { list-style: none; padding: 0; margin: 8px 0 14px; }
.checklist-status li { padding: 5px 0; display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.ck { width: 20px; height: 20px; flex: none; display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; font-weight: 700; font-size: 12px; color: #fff; background: var(--border-strong); }
.checklist-status .ok .ck { background: var(--good); } .checklist-status .ko .ck { background: var(--late); }
.crit { list-style: none; padding: 0; margin: 0; }
.crit li { padding: 3px 0; }

/* ---------- Modal ---------- */
.modal { position: fixed; inset: 0; z-index: 80; background: rgba(11, 11, 11, .4); display: flex; align-items: flex-start; justify-content: center; padding: 5vh 16px; overflow-y: auto; }
.modal[hidden] { display: none; }
.modal-box { background: var(--surface); border-radius: 10px; width: min(560px, 100%); box-shadow: 0 12px 40px rgba(0,0,0,.25); }
.modal-box.wide { width: min(980px, 100%); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--border); gap: 10px; }
.modal-head h2 { font-size: 16px; }
.modal-body { padding: 16px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 10px 10px; }
body.modal-open, body.drawer-open { overflow: hidden; }

/* ---------- toasts & tooltip ---------- */
.toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 100; max-width: min(420px, calc(100vw - 32px)); }
.toast { background: #13233a; color: #fff; padding: 10px 14px; border-radius: 8px; box-shadow: 0 6px 20px rgba(0,0,0,.25); border-left: 4px solid #3987e5; transition: opacity .3s, transform .3s; }
.toast.ok { border-left-color: var(--good); }
.toast.error { border-left-color: #ff6b6b; background: #4a1414; }
.toast.out { opacity: 0; transform: translateY(8px); }
.tip { position: fixed; z-index: 120; pointer-events: none; background: #13233a; color: #fff; padding: 5px 9px; border-radius: 5px; font-size: 12px; max-width: 320px; box-shadow: 0 4px 12px rgba(0,0,0,.25); }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .chart-card.span2 { grid-column: auto; }
  .proj-info .grid-dl { grid-template-columns: 140px 1fr; }
}
@media (max-width: 900px) {
  .view { padding: 16px 16px 60px; }
  .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .two-col { grid-template-columns: 1fr; }
  .me-box span { display: none; }
  .chart-grid { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .topbar { flex-wrap: wrap; padding: 8px 10px; }
  .search-box { order: 5; flex-basis: 100%; max-width: none; }
  .me-box { margin-left: auto; }
  .me-box select { max-width: 150px; }
  .form-grid { grid-template-columns: 1fr; }
  .fld.half { grid-column: auto; }
  .grid-dl, .proj-info .grid-dl { grid-template-columns: 1fr; gap: 2px; }
  .grid-dl dd { margin-bottom: 6px; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  h1 { font-size: 19px; }
  .modal { padding: 0; }
  .modal-box, .modal-box.wide { border-radius: 0; min-height: 100%; }
  .kb-col { flex-basis: 82vw; }
  .cal-cell { min-height: 64px; }
  .cal-act { font-size: 0; height: 6px; padding: 0; }
  .cal-ms { font-size: 10px; }
  .g-row, .g-axis { grid-template-columns: 40% 1fr; }
  .g-axis { margin-left: 40%; }
  .search-inline input { min-width: 0; flex: 1; }
  .search-inline { flex: 1 1 100%; }
  .transfer-dl { grid-template-columns: 1fr; }
}
@media print {
  .topbar, .btn, .toasts { display: none !important; }
  .view { overflow: visible; }
  .app { height: auto; }
}


/* ---------- API layer: login / company picker overlay ---------- */
.api-ov { position: fixed; inset: 0; z-index: 200; background: var(--bg); display: flex; align-items: center; justify-content: center; padding: 16px; }
.api-card { width: min(360px, 100%); display: flex; flex-direction: column; gap: 12px; margin: 0; }
.api-card form { display: flex; flex-direction: column; gap: 12px; }
.api-title { margin: 0; text-align: center; }
.api-actions { justify-content: flex-end; }

/* == UI-A: actions page & topbar == */
.search-box { min-width: 180px; max-width: 640px; }
details.menu { position: relative; display: inline-block; }
details.menu > summary { list-style: none; cursor: pointer; user-select: none; }
details.menu > summary::-webkit-details-marker { display: none; }
.menu-pop { position: absolute; top: 100%; left: 0; margin-top: 4px; min-width: 200px; padding: 4px; display: flex; flex-direction: column; gap: 2px; background: var(--surface); border: 1px solid var(--border-strong); border-radius: 8px; box-shadow: var(--shadow); z-index: 60; }
details.menu.right > .menu-pop { left: auto; right: 0; }
.menu-pop .btn { width: 100%; justify-content: flex-start; text-align: left; }
.menu-row { display: flex; align-items: center; border-radius: 6px; }
.menu-row:hover { background: var(--surface-2); }
.menu-row.on { background: var(--primary); }
.menu-row.on button { color: #fff; }
.menu-row > button:first-child { flex: 1; border: 0; background: transparent; padding: 6px 8px; text-align: left; cursor: pointer; font-size: 13px; color: var(--ink); }
.menu-empty { margin: 6px 8px; }
.actions-tbl th.stk, .actions-tbl td.stk { position: sticky; z-index: 1; background: var(--surface); }
.actions-tbl th.stk1, .actions-tbl td.stk1 { left: 0; width: 84px; min-width: 84px; max-width: 84px; white-space: normal; overflow-wrap: anywhere; }
.actions-tbl th.stk2, .actions-tbl td.stk2 { left: 84px; min-width: 200px; box-shadow: 1px 0 0 var(--border); }
.actions-tbl tr.clickable:hover td.stk { background: var(--surface-2); }
@media (max-width: 900px) { .actions-tbl .hide-md { display: none; } }

/* == UI-B: login, save status, accounts == */
/* Login */
.api-brand { display: flex; flex-direction: column; align-items: center; gap: 6px; margin-bottom: 4px; text-align: center; }
.api-logo { width: 48px; height: 48px; }
.api-title { font-size: 22px; letter-spacing: .2px; }
.api-sub { margin: 0; color: var(--muted); font-size: 13.5px; }
.api-card .form-error { margin: 0; }
.api-submit { justify-content: center; padding: 9px 12px; }
.api-link { align-self: center; border: 0; background: transparent; color: var(--primary); cursor: pointer; font-size: 12.5px; padding: 2px 4px; }
.api-link:hover { text-decoration: underline; }
.api-help { margin: 0; color: var(--ink-2); font-size: 12.5px; text-align: center; background: var(--surface-2); border-radius: 6px; padding: 8px 10px; }
/* Save status (topbar) */
.save-status { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); white-space: nowrap; }
.save-status:empty { display: none; }
.save-status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.save-status.s-ok::before { background: var(--good); }
.save-status.s-busy::before, .save-status.s-warn::before { background: var(--warn); }
.save-status.s-err { color: var(--danger); }
.save-status.s-err::before { background: var(--danger); }
@media (max-width: 600px) { .save-status:not(.s-err) { display: none; } }
/* Account page */
.acc-kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; margin: 0 0 8px; }
.acc-kv dd { margin: 0; }
.acc-h { margin: 18px 0 8px; font-size: 14px; }
.acc-form { display: flex; flex-direction: column; gap: 10px; max-width: 420px; }
.acc-form.acc-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); max-width: 760px; gap: 10px 14px; }
.acc-form .full { grid-column: 1 / -1; }
.acc-form .form-error, .acc-ok { margin: 0; }
.acc-ok { color: var(--good); font-weight: 550; }
.acc-pw { display: flex; gap: 6px; }
.acc-pw input { flex: 1; min-width: 0; font-family: var(--mono); }
.acc-note { border: 1px solid var(--border-strong); background: var(--surface-2); border-radius: 6px; padding: 8px 10px; margin-bottom: 10px; overflow-wrap: anywhere; }
.acc-note code { font-family: var(--mono); font-weight: 600; user-select: all; }
.acc-acts { white-space: nowrap; }
.acc-people { margin: 10px 0 0; font-size: 12.5px; }
@media (max-width: 600px) { .acc-form.acc-grid { grid-template-columns: 1fr; } }

/* == UI-C: theme, mobile, onboarding == */
:root[data-theme="dark"] .chip-x:hover { background: rgba(255,255,255,.15); }
.wel-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; margin-top: 12px; }
.wel-step { border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; display: flex; flex-direction: column; gap: 6px; align-items: flex-start; background: var(--surface-2); }
.wel-step p { margin: 0 0 6px; flex: 1; }
.wel-n { width: 24px; height: 24px; border-radius: 50%; background: var(--primary); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 12px; }
@media (max-width: 900px) {
  .topbar { flex-wrap: wrap; gap: 6px; }
  .topbar .icon-btn, .topbar .btn { flex: none; }
}
@media (max-width: 600px) {
  html, body, .app, .main-col { max-width: 100vw; overflow-x: hidden; }
  .topbar { gap: 4px; }
  .search-box { order: 9; }
  .me-box { margin-left: 0; min-width: 0; flex: 1 1 0; }
  .me-box select { max-width: 100%; width: 100%; }
  .save-status:not(.s-err) { font-size: 0; }
  #logoutBtn, .lang-btn { padding: 6px 8px; min-width: 0; }
  .view { padding: 12px 10px 60px; }
  .card { padding: 12px; }
  .card, .table-wrap, .chart-card { max-width: 100%; }
  .page-head { flex-direction: column; align-items: stretch; }
  .btn-row { flex-wrap: wrap; }
  .modal-box, .modal-box.wide { width: 100%; max-width: none; }
  .drawer-box { width: 100%; }
}

/* == UI-E: presentation & search == */
body.present .app-settings, body.present .app-account, body.present .app-console, body.present #saveStatus { display: none; }
body.present { font-size: 110%; }
.search-results a.sr-on { background: var(--surface-2); outline: 1px solid currentColor; }

/* == UI-D: console == */
.co-badge { display: inline-flex; align-items: center; gap: 6px; max-width: 220px; padding: 3px 10px; border: 1px solid var(--border-strong); border-radius: 999px; background: var(--surface-2); color: var(--ink); font: inherit; font-size: 12.5px; font-weight: 600; white-space: nowrap; }
button.co-badge { cursor: pointer; }
.co-badge .co-name { overflow: hidden; text-overflow: ellipsis; }
.co-badge em { font-style: normal; font-size: 10.5px; font-weight: 700; padding: 0 6px; border-radius: 8px; background: #f59e0b; color: #1a1a1a; }
.co-badge.demo { border-color: #f59e0b; background: rgba(245, 158, 11, .15); }
.badge.co-demo { background: #f59e0b; border-color: #f59e0b; color: #1a1a1a; }
.badge.co-demo::before { display: none; }
.co-list { display: flex; flex-direction: column; gap: 6px; }
.co-list .btn { justify-content: flex-start; text-align: left; }
.co-acts { min-width: 260px; }
.co-acts .btn { margin-bottom: 4px; }
.demo-lock .file-btn, .demo-lock [data-act^="export"] { display: none; }
/* settings > data: hide the emptied Export/Import sections (heading, row, help) */
.demo-lock h3:has(+ .btn-row [data-act="exportJSON"]), .demo-lock .btn-row:has([data-act="exportJSON"]),
.demo-lock h3:has(+ .btn-row [data-change="importJSON"]), .demo-lock .btn-row:has([data-change="importJSON"]),
.demo-lock .btn-row:has([data-change="importJSON"]) + p { display: none; }
@media (max-width: 600px) {
  #presentBtn { display: none; }
  .co-badge { max-width: none; flex: 0 1 auto; min-width: 0; gap: 4px; padding: 3px 8px; }
  .co-badge .co-name { max-width: 90px; }
  .co-badge.demo .co-name { max-width: 60px; }
  .search-box { min-width: 0; }
}

/* == UI-F: owner management mode == */
.mgmt .search-box, .mgmt .me-box, .mgmt #bellBtn, .mgmt #presentBtn { display: none; }
.co-banner { flex: none; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; padding: 7px 16px; font-size: 13px; background: var(--primary-soft); color: var(--ink); border-bottom: 1px solid var(--primary); }
.co-banner.demo { background: rgba(245, 158, 11, .22); border-bottom-color: #f59e0b; }
.co-banner.blocked { background: rgba(208, 59, 59, .16); border-bottom-color: var(--late); }
.co-banner .btn { margin-left: auto; }
body.present .co-banner { display: none; }
.badge.tag-warn { --c: #d97706; }
.badge.tag-late { --c: var(--late); }
.badge.tag-idle { --c: var(--muted); }
.badge.tag-ok { --c: var(--good); }
.co-tabs { margin-bottom: 12px; }
.co-filters { margin-top: 4px; }
.co-q { min-width: 220px; padding: 6px 10px; border: 1px solid var(--border-strong); border-radius: 6px; background: var(--surface); }
.co-filters select { padding: 6px 8px; border: 1px solid var(--border-strong); border-radius: 6px; background: var(--surface); max-width: 280px; }
.co-inv { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
@media (max-width: 600px) { .co-inv { grid-template-columns: 1fr; } .co-banner .btn { margin-left: 0; } }
