:root {
  --bg: #f5f6f8; --panel: #ffffff; --ink: #16202c; --muted: #637083; --line: #dfe3e8;
  --brand: #0b5394; --brand-ink: #ffffff; --accent: #b3261e;
  --ok: #1e7b3a; --ok-bg: #e7f4ea; --warn: #9a5b00; --warn-bg: #fdf1dc;
  --bad: #b3261e; --bad-bg: #fbe7e5; --info: #0b5394; --info-bg: #e5eef8;
  --crit: #c62828; --bar: #6b8fb8; --bar-done: #74b98a;
  --shadow: 0 1px 2px rgba(0,0,0,.06), 0 4px 16px rgba(0,0,0,.05);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f141a; --panel: #171e27; --ink: #e6ebf1; --muted: #93a0b0; --line: #2a3441;
    --brand: #4f8fd1; --brand-ink: #0b1119; --ok: #7fd49a; --ok-bg: #173022; --warn: #f0b35a; --warn-bg: #33270f;
    --bad: #ff8a80; --bad-bg: #3a1a18; --info: #8ab8ea; --info-bg: #15283d; --crit: #ff6b6b; --bar: #4c6f97; --bar-done: #3f8a58;
  }
}
:root[data-theme="dark"] {
  --bg: #0f141a; --panel: #171e27; --ink: #e6ebf1; --muted: #93a0b0; --line: #2a3441;
  --brand: #4f8fd1; --brand-ink: #0b1119; --ok: #7fd49a; --ok-bg: #173022; --warn: #f0b35a; --warn-bg: #33270f;
  --bad: #ff8a80; --bad-bg: #3a1a18; --info: #8ab8ea; --info-bg: #15283d; --crit: #ff6b6b; --bar: #4c6f97; --bar-done: #3f8a58;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
a { color: var(--brand); text-decoration: none; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 16px; margin: 0; }
h3 { font-size: 14px; margin: 0 0 6px; }

.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { background: var(--panel); padding: 32px; border-radius: 14px; box-shadow: var(--shadow); max-width: 420px; text-align: center; }
/* Logo — same treatment as cau-reports: explicit caps so the 1800px PNG never
   renders at intrinsic size, and a white chip in the header so it reads in dark mode. */
.logo { display: block; }
.login-card .logo { width: 240px; height: auto; max-width: 80%; margin: 0 auto 10px; }
.brand { display: flex; align-items: center; gap: 8px; }
.brand .logo { height: 30px; width: auto; max-height: 30px; background: #fff; border-radius: 6px; padding: 2px 8px; }
@media (max-width: 640px) { .brand .logo { height: 26px; } }
:root[data-theme="dark"] .login-card .logo { filter: brightness(1.55); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .login-card .logo { filter: brightness(1.55); } }

.top { display: flex; align-items: center; gap: 18px; padding: 10px 16px; background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; flex-wrap: wrap; }
.brand { font-weight: 800; font-size: 16px; color: var(--ink); }
#nav { display: flex; gap: 4px; flex-wrap: wrap; }
#nav a { padding: 6px 10px; border-radius: 8px; color: var(--muted); font-weight: 600; }
#nav a.on { background: var(--info-bg); color: var(--info); }
.me { margin-left: auto; display: flex; gap: 8px; align-items: center; }
main { max-width: 1280px; margin: 0 auto; padding: 16px; }
.foot { text-align: center; padding: 16px; font-size: 11px; }

.btn { border: 1px solid var(--line); background: var(--panel); color: var(--ink); border-radius: 8px; padding: 7px 12px; font-weight: 600; cursor: pointer; font: inherit; font-weight: 600; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.danger { color: var(--bad); border-color: var(--bad); }
.btn.ghost { background: transparent; }
.btn.sm { padding: 4px 8px; font-size: 12px; }
.btn.lg { padding: 10px 18px; font-size: 15px; }
.btn:disabled { opacity: .5; cursor: default; }
.icon-btn { background: none; border: 0; color: var(--muted); font-size: 16px; cursor: pointer; }

.page-head { display: flex; align-items: flex-end; gap: 12px; margin: 4px 0 14px; flex-wrap: wrap; }
.page-head .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); margin-bottom: 14px; }
.card .hd { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.card .bd { padding: 12px 14px; }
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.cols { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }

.tblwrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 11px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); font-weight: 700; white-space: nowrap; }
tr.row { cursor: pointer; }
tr.row:hover td { background: var(--bg); }
tr.done td { color: var(--muted); }
td.num { color: var(--muted); font-variant-numeric: tabular-nums; width: 36px; }
td.sub { padding-left: 28px; }
.nowrap { white-space: nowrap; }
.mono { font-variant-numeric: tabular-nums; }

.pill { display: inline-block; padding: 1px 8px; border-radius: 99px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.s-not-started { background: var(--bg); color: var(--muted); border: 1px solid var(--line); }
.s-in-progress { background: var(--info-bg); color: var(--info); }
.s-blocked { background: var(--bad-bg); color: var(--bad); }
.s-done { background: var(--ok-bg); color: var(--ok); }
.d-overdue { color: var(--bad); font-weight: 700; }
.d-soon { color: var(--warn); font-weight: 600; }
.flag { font-size: 11px; font-weight: 700; padding: 0 5px; border-radius: 4px; margin-left: 4px; white-space: nowrap; }
.f-crit { color: var(--crit); border: 1px solid var(--crit); }
.f-late, .f-wait { color: var(--warn); border: 1px solid var(--warn); }
.f-cycle { color: #fff; background: var(--bad); }
.f-ms { color: var(--brand); border: 1px solid var(--brand); }
.dep { font-size: 12px; color: var(--muted); }
.dep .q { color: var(--warn); font-weight: 700; }

.pcard { padding: 14px; cursor: pointer; }
.pcard h3 { font-size: 15px; }
.bar { height: 6px; background: var(--bg); border-radius: 4px; overflow: hidden; margin: 8px 0; }
.bar > span { display: block; height: 100%; background: var(--ok); }
.kv { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.kv b { color: var(--ink); }

.tabs { display: flex; gap: 4px; margin-bottom: 10px; }
.tabs a { padding: 6px 12px; border-radius: 8px; font-weight: 600; color: var(--muted); border: 1px solid transparent; }
.tabs a.on { border-color: var(--line); background: var(--panel); color: var(--ink); }

/* Timeline */
.tl { position: relative; overflow-x: auto; }
.tl-inner { position: relative; min-width: 900px; }
.tl-head { display: flex; position: sticky; top: 0; background: var(--panel); border-bottom: 1px solid var(--line); z-index: 2; }
.tl-month { flex: none; font-size: 11px; font-weight: 700; color: var(--muted); padding: 6px 4px; border-left: 1px solid var(--line); text-transform: uppercase; }
.tl-row { position: relative; height: 30px; border-bottom: 1px dashed var(--line); }
.tl-label { position: absolute; left: 6px; top: 6px; font-size: 12px; white-space: nowrap; z-index: 1; pointer-events: none; }
.tl-grid { position: absolute; top: 0; bottom: 0; border-left: 1px solid var(--line); }
.tl-bar { position: absolute; top: 7px; height: 16px; border-radius: 4px; background: var(--bar); opacity: .85; cursor: pointer; }
.tl-bar.crit { background: var(--crit); }
.tl-bar.done { background: var(--bar-done); }
.tl-bar.blocked { background: repeating-linear-gradient(45deg, var(--bad), var(--bad) 4px, var(--bad-bg) 4px, var(--bad-bg) 8px); }
.tl-ms { position: absolute; top: 8px; width: 14px; height: 14px; transform: rotate(45deg); background: var(--brand); cursor: pointer; }
.tl-ms.crit { background: var(--crit); }
.tl-ms.done { background: var(--bar-done); }
.tl-today { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--accent); z-index: 3; }
/* Dependency connectors (timeline + schedule) and the dependency chart */
.tl-edges { position: absolute; left: 0; top: 0; pointer-events: none; z-index: 1; overflow: visible; }
.tl-edges path, .net svg path { pointer-events: stroke; }
.edge { fill: none; stroke-width: 1.5; }
.e-norm { stroke: var(--muted); } .e-norm-head { fill: var(--muted); }
.e-crit { stroke: var(--crit); } .e-crit-head { fill: var(--crit); }
.e-late { stroke: var(--warn); stroke-width: 2; } .e-late-head { fill: var(--warn); }
.e-done { stroke: var(--bar-done); opacity: .7; } .e-done-head { fill: var(--bar-done); }
.e-prop { stroke-dasharray: 5 4; }
.tl-bar, .tl-ms { z-index: 2; }
.tl-plan { position: absolute; top: 4px; height: 22px; width: 2px; background: var(--muted); opacity: .6; }
.net { overflow: auto; padding: 0 0 12px; }
.net-inner { position: relative; }
.net svg { position: absolute; left: 0; top: 0; overflow: visible; }
.node { position: absolute; box-sizing: border-box; background: var(--panel); border: 1px solid var(--line); border-left: 4px solid var(--muted);
  border-radius: 8px; padding: 6px 8px; cursor: pointer; box-shadow: var(--shadow); overflow: hidden; }
.node:hover { border-color: var(--brand); }
.node.ns-in-progress { border-left-color: var(--info); }
.node.ns-blocked { border-left-color: var(--bad); }
.node.ns-done { border-left-color: var(--ok); opacity: .75; }
.node.crit { box-shadow: 0 0 0 2px var(--crit) inset, var(--shadow); }
.node.od .n-m { color: var(--bad); font-weight: 600; }
.n-t { font-size: 12px; font-weight: 700; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.n-m { font-size: 11px; color: var(--muted); margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.legend {display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin: 8px 0; }
.sw { display: inline-block; width: 12px; height: 10px; border-radius: 2px; vertical-align: middle; margin-right: 4px; }

/* Forms / modal */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: grid; place-items: start center; padding: 40px 16px; overflow-y: auto; z-index: 20; }
.modal-card { background: var(--panel); border-radius: 14px; width: 100%; max-width: 760px; box-shadow: var(--shadow); }
.modal-card .hd { padding: 14px 18px; border-bottom: 1px solid var(--line); display: flex; gap: 10px; align-items: center; }
.modal-card .bd { padding: 14px 18px; }
.modal-card .ft { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; gap: 8px; flex-wrap: wrap; }
.modal-card .ft .right { margin-left: auto; display: flex; gap: 8px; }
.form { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px 14px; }
.fld { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--muted); font-weight: 600; }
.fld.wide { grid-column: 1 / -1; }
.fld.check { flex-direction: row; align-items: center; gap: 6px; }
input, select, textarea { font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 7px 9px; font-weight: 400; }
textarea { min-height: 64px; resize: vertical; }
.deplist { max-height: 180px; overflow-y: auto; border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; background: var(--bg); }
.deplist label { display: flex; gap: 6px; align-items: center; font-weight: 400; color: var(--ink); padding: 2px 0; }
.updates { margin-top: 14px; }
.upd { border-left: 3px solid var(--line); padding: 4px 10px; margin: 6px 0; }
.upd .meta { font-size: 11px; color: var(--muted); }
.banner { padding: 8px 12px; border-radius: 8px; margin-bottom: 10px; font-size: 13px; }
.banner.warn { background: var(--warn-bg); color: var(--warn); }
.banner.bad { background: var(--bad-bg); color: var(--bad); }
.banner.info { background: var(--info-bg); color: var(--info); }
.empty { padding: 18px; text-align: center; color: var(--muted); }

@media (max-width: 640px) {
  main { padding: 12px; }
  .hide-sm { display: none; }
  .modal { padding: 12px; }
}
