/* pyTam Planner - one stylesheet, light + dark via [data-theme]. */
:root {
  --bg: #f5f6f8; --surface: #ffffff; --surface-2: #f9fafb; --surface-3: #eef1f5;
  --border: #e2e6eb; --border-strong: #cfd5dd;
  --text: #1d2330; --muted: #667085; --faint: #98a2b3;
  --primary: #2563eb; --primary-soft: #e8efff; --primary-text: #ffffff;
  --ok: #16a34a; --ok-soft: #e7f6ec; --warn: #d97706; --warn-soft: #fff4e0;
  --bad: #dc2626; --bad-soft: #fde8e8; --info: #0e7490; --info-soft: #e2f4f8;
  --purple: #7c3aed; --purple-soft: #f1eaff;
  --upcoming: #64748b; --upcoming-soft: #eef2f6;
  --weekend: rgba(100, 116, 139, 0.07); --holiday: rgba(220, 38, 38, 0.08);
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, .18);
  --radius: 8px; --radius-sm: 6px;
  --font: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --sidebar: 216px; --topbar: 56px;
  color-scheme: light;
}
[data-theme="dark"] {
  --bg: #0e1116; --surface: #161a21; --surface-2: #1b2029; --surface-3: #232935;
  --border: #2a313d; --border-strong: #3a4250;
  --text: #e5e9f0; --muted: #9aa4b5; --faint: #6b7587;
  --primary: #4d8bff; --primary-soft: #1c2a45; --primary-text: #ffffff;
  --ok: #34c56b; --ok-soft: #15291d; --warn: #f0a23b; --warn-soft: #2e2414;
  --bad: #f05252; --bad-soft: #321a1c; --info: #38b2cf; --info-soft: #14272d;
  --purple: #a78bfa; --purple-soft: #261d3d;
  --upcoming: #8a96a8; --upcoming-soft: #222833;
  --weekend: rgba(148, 163, 184, 0.06); --holiday: rgba(240, 82, 82, 0.10);
  --shadow: 0 1px 2px rgba(0, 0, 0, .4); --shadow-lg: 0 12px 32px rgba(0, 0, 0, .5);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 14px/1.45 var(--font); color: var(--text); background: var(--bg);
  -webkit-font-smoothing: antialiased; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; }
h1 { font-size: 20px; } h2 { font-size: 16px; } h3 { font-size: 14px; }
.muted { color: var(--muted); } .faint { color: var(--faint); } .small { font-size: 12px; }
.nowrap { white-space: nowrap; } .grow { flex: 1 1 auto; min-width: 0; }
.row { display: flex; align-items: center; gap: 8px; }
.col { display: flex; flex-direction: column; gap: 8px; }
.wrap { flex-wrap: wrap; } .between { justify-content: space-between; }
.hidden { display: none !important; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
svg.icon { width: 18px; height: 18px; flex: 0 0 auto; stroke: currentColor; fill: none;
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------------------------------------------------------------- shell */
.app { display: grid; grid-template-columns: var(--sidebar) 1fr; grid-template-rows: var(--topbar) 1fr;
  height: 100vh; }
.sidebar { grid-row: 1 / 3; background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 12px 10px; gap: 2px; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 16px; }
.brand-logo { width: 32px; height: 32px; border-radius: 8px; background: var(--primary);
  color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 15px; }
.brand-name { font-weight: 700; font-size: 15px; line-height: 1.1; }
.brand-sub { font-size: 11px; color: var(--muted); }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--radius-sm);
  color: var(--text); font-weight: 500; cursor: pointer; border: 0; background: none; font: inherit;
  text-align: left; width: 100%; }
.nav-item:hover { background: var(--surface-3); text-decoration: none; }
.nav-item.active { background: var(--primary-soft); color: var(--primary); }
.nav-item .badge { margin-left: auto; }
.nav-sep { height: 1px; background: var(--border); margin: 10px 4px; }
.sidebar-foot { margin-top: auto; padding: 8px; font-size: 11px; color: var(--faint); }
.topbar { display: flex; align-items: center; gap: 12px; padding: 0 20px; background: var(--surface);
  border-bottom: 1px solid var(--border); min-width: 0; }
.topbar .page-title { font-size: 17px; font-weight: 600; white-space: nowrap; }
.main { overflow: auto; padding: 20px 24px 40px; min-width: 0; }
.main.flush { padding: 0; overflow: hidden; display: flex; flex-direction: column; }
.page-root { display: contents; }
.topbar .menu-btn { display: none; }

/* ------------------------------------------------------------- controls */
button, .btn { font: inherit; cursor: pointer; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 34px; padding: 0 12px;
  border-radius: var(--radius-sm); border: 1px solid var(--border-strong); background: var(--surface);
  color: var(--text); font-weight: 500; white-space: nowrap; text-decoration: none; }
.btn:hover { background: var(--surface-3); text-decoration: none; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-text); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.danger { color: var(--bad); }
.btn.danger.solid { background: var(--bad); color: #fff; border-color: var(--bad); }
.btn.ok { background: var(--ok); color: #fff; border-color: var(--ok); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-3); }
.btn.sm { height: 28px; padding: 0 9px; font-size: 13px; }
.btn.icon-only { width: 34px; padding: 0; }
.btn.sm.icon-only { width: 28px; }
.btn.active { background: var(--primary-soft); color: var(--primary); border-color: var(--primary); }
input, select, textarea { font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm); padding: 6px 9px; min-width: 0; }
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--primary); }
input[type="range"] { padding: 0; accent-color: var(--primary); }
textarea { resize: vertical; min-height: 70px; }
select { height: 34px; padding: 0 8px; }
input:not([type="checkbox"]):not([type="range"]) { height: 34px; }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field > label, .label { font-size: 12px; color: var(--muted); font-weight: 500; }
.field .hint { font-size: 12px; color: var(--muted); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.seg { display: inline-flex; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); overflow: hidden; }
.seg button { border: 0; background: var(--surface); padding: 0 11px; height: 32px; color: var(--text);
  border-right: 1px solid var(--border); font-weight: 500; }
.seg button:last-child { border-right: 0; }
.seg button.on { background: var(--primary); color: #fff; }
.seg button:hover:not(.on) { background: var(--surface-3); }
.switch { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; user-select: none; font-size: 13px; }

/* ---------------------------------------------------------------- cards */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; gap: 8px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.card-head h2 { font-size: 15px; }
.card-body { padding: 14px 16px; }
.card-body.tight { padding: 4px 0; }
.page-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head h1 { margin-right: auto; }
.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 10px 16px;
  background: var(--surface); border-bottom: 1px solid var(--border); }
.toolbar .sep { width: 1px; height: 22px; background: var(--border); margin: 0 2px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { padding: 14px 16px; }
.kpi .kpi-label { font-size: 12px; color: var(--muted); font-weight: 500; }
.kpi .kpi-value { font-size: 26px; font-weight: 650; line-height: 1.2; margin-top: 2px; }
.kpi .kpi-note { font-size: 12px; color: var(--muted); }
.kpi.bad .kpi-value { color: var(--bad); } .kpi.ok .kpi-value { color: var(--ok); }
.kpi.warn .kpi-value { color: var(--warn); }
.layout-2 { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.stack { display: flex; flex-direction: column; gap: 16px; }

/* ---------------------------------------------------------- chips, avatars */
.chip { display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 8px; border-radius: 11px;
  font-size: 12px; font-weight: 500; background: var(--surface-3); color: var(--muted); white-space: nowrap; }
.chip.ok, .chip.done { background: var(--ok-soft); color: var(--ok); }
.chip.warn, .chip.behind, .chip.at_risk, .chip.pending, .chip.review { background: var(--warn-soft); color: var(--warn); }
.chip.bad, .chip.late, .chip.rejected, .chip.over { background: var(--bad-soft); color: var(--bad); }
.chip.info, .chip.doing, .chip.on_track { background: var(--primary-soft); color: var(--primary); }
.chip.blocked { background: var(--purple-soft); color: var(--purple); }
.chip.upcoming, .chip.todo, .chip.cancelled, .chip.unscheduled, .chip.empty { background: var(--upcoming-soft); color: var(--upcoming); }
.chip.approved, .chip.free { background: var(--ok-soft); color: var(--ok); }
.chip.busy { background: var(--warn-soft); color: var(--warn); }
.badge { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--bad); color: #fff;
  font-size: 11px; font-weight: 700; display: inline-grid; place-items: center; }
.avatar { width: 24px; height: 24px; border-radius: 50%; color: #fff; font-size: 11px; font-weight: 700;
  display: inline-grid; place-items: center; flex: 0 0 auto; text-transform: uppercase; }
.avatar.lg { width: 34px; height: 34px; font-size: 13px; }
.avatar.none { background: var(--surface-3); color: var(--faint); border: 1px dashed var(--border-strong); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: 0 0 auto; }
.progress { height: 6px; background: var(--surface-3); border-radius: 3px; overflow: hidden; position: relative; min-width: 40px; }
.progress > span { position: absolute; left: 0; top: 0; bottom: 0; background: var(--primary); border-radius: 3px; }
.progress > i { position: absolute; top: -2px; bottom: -2px; width: 2px; background: var(--text); opacity: .55; }
.progress.lg { height: 10px; border-radius: 5px; }

/* ---------------------------------------------------------------- lists */
.list { display: flex; flex-direction: column; }
.list-item { display: flex; align-items: center; gap: 10px; padding: 9px 16px; border-bottom: 1px solid var(--border);
  cursor: pointer; min-width: 0; }
.list-item:last-child { border-bottom: 0; }
.list-item:hover { background: var(--surface-2); }
.list-group { padding: 10px 16px 4px; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase;
  letter-spacing: .03em; }
.empty-state { padding: 28px 16px; text-align: center; color: var(--muted); }
.empty-state .icon { width: 30px; height: 30px; color: var(--faint); margin-bottom: 6px; }
.alert-item { display: flex; gap: 10px; padding: 10px 16px; border-bottom: 1px solid var(--border); cursor: pointer; align-items: flex-start; }
.alert-item:last-child { border-bottom: 0; }
.alert-item:hover { background: var(--surface-2); }
.alert-item .icon { margin-top: 1px; }
.alert-item.danger .icon { color: var(--bad); } .alert-item.warning .icon { color: var(--warn); }
.alert-item.info .icon { color: var(--info); }
table.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); padding: 8px 12px;
  border-bottom: 1px solid var(--border); background: var(--surface-2); white-space: nowrap; position: sticky; top: 0; z-index: 1; }
.table td { padding: 8px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tr.click:hover td { background: var(--surface-2); cursor: pointer; }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; overflow-y: hidden; }
.tab { padding: 9px 14px; border: 0; background: none; color: var(--muted); font-weight: 500; border-bottom: 2px solid transparent;
  white-space: nowrap; display: inline-flex; gap: 6px; align-items: center; }
.tab.on { color: var(--primary); border-bottom-color: var(--primary); }
.tab:hover:not(.on) { color: var(--text); }
.callout { padding: 10px 12px; border-radius: var(--radius-sm); background: var(--info-soft); color: var(--text);
  font-size: 13px; display: flex; gap: 8px; align-items: flex-start; }
.callout.warn { background: var(--warn-soft); } .callout.bad { background: var(--bad-soft); }
.callout.ok { background: var(--ok-soft); }
.invite-link { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); background: var(--surface-2); }
.invite-link code { word-break: break-all; font-size: 13px; user-select: all; }
.callout .icon { margin-top: 1px; }

/* --------------------------------------------------------- modal, drawer */
.overlay { position: fixed; inset: 0; background: rgba(15, 20, 30, .45); z-index: 50; display: grid;
  place-items: center; padding: 20px; animation: fade .12s ease-out; }
.modal { background: var(--surface); border-radius: 12px; box-shadow: var(--shadow-lg); width: min(560px, 100%);
  max-height: calc(100vh - 40px); display: flex; flex-direction: column; }
.modal.wide { width: min(820px, 100%); }
.modal-head { display: flex; align-items: center; gap: 8px; padding: 16px 20px 10px; }
.modal-head h2 { font-size: 17px; margin-right: auto; }
.modal-body { padding: 6px 20px 16px; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; }
.modal-foot { display: flex; gap: 8px; justify-content: flex-end; padding: 12px 20px; border-top: 1px solid var(--border); }
.drawer-wrap { position: fixed; inset: 0; z-index: 40; pointer-events: none; }
.drawer-wrap .scrim { position: absolute; inset: 0; background: rgba(15, 20, 30, .25); pointer-events: auto; animation: fade .12s; }
.drawer { position: absolute; top: 0; right: 0; bottom: 0; width: min(520px, 100vw); background: var(--surface);
  box-shadow: var(--shadow-lg); display: flex; flex-direction: column; pointer-events: auto; animation: slide .16s ease-out; }
.drawer-head { padding: 14px 18px 10px; border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 8px; }
.drawer-body { overflow-y: auto; padding: 14px 18px 24px; display: flex; flex-direction: column; gap: 14px; }
.title-input { font-size: 18px; font-weight: 600; border: 1px solid transparent; padding: 4px 6px; margin-left: -7px;
  width: calc(100% + 7px); background: transparent; height: auto !important; }
.title-input:hover { border-color: var(--border); }
.saved-note { font-size: 12px; color: var(--ok); transition: opacity .4s; }
.smart { border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; display: flex;
  flex-direction: column; gap: 6px; background: var(--surface-2); font-size: 13px; }
.smart .row { align-items: flex-start; }
.comment { display: flex; gap: 10px; }
.comment .bubble { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 8px 10px; flex: 1; white-space: pre-wrap; word-break: break-word; }
.history-item { font-size: 12px; color: var(--muted); padding: 4px 0; border-bottom: 1px dashed var(--border); }
.toast-host { position: fixed; right: 20px; bottom: 20px; z-index: 80; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--text); color: var(--bg); padding: 10px 14px; border-radius: var(--radius); box-shadow: var(--shadow-lg);
  max-width: 380px; font-size: 13px; animation: rise .15s ease-out; display: flex; gap: 8px; align-items: flex-start; }
.toast.bad { background: var(--bad); color: #fff; } .toast.ok { background: var(--ok); color: #fff; }
.popover { position: fixed; z-index: 60; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); min-width: 220px; max-width: 360px; max-height: 360px; overflow-y: auto; padding: 6px 0; }
.popover .list-item { padding: 7px 12px; }
.tip { position: fixed; z-index: 70; pointer-events: none; background: var(--text); color: var(--bg); font-size: 12px;
  padding: 6px 9px; border-radius: 6px; max-width: 320px; box-shadow: var(--shadow-lg); white-space: pre-line; }
@keyframes fade { from { opacity: 0; } }
@keyframes slide { from { transform: translateX(30px); opacity: 0; } }
@keyframes rise { from { transform: translateY(8px); opacity: 0; } }

/* ---------------------------------------------------------------- login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px;
  background: radial-gradient(1200px 600px at 10% -10%, var(--primary-soft), transparent), var(--bg); }
.login-card { width: min(400px, 100%); padding: 28px; display: flex; flex-direction: column; gap: 14px; }
.login-card .brand { padding: 0 0 6px; }

/* ---------------------------------------------------------------- gantt */
/* toolbar: view | show toggles | person ... actions */
.plan-toolbar { gap: 10px; }
.tb-group { display: flex; align-items: center; gap: 6px; }
.tb-group + .tb-group { padding-left: 10px; border-left: 1px solid var(--border); }
.tb-group > svg.icon { width: 16px; height: 16px; color: var(--muted); }
.tb-label { font-size: 12px; color: var(--muted); font-weight: 600; margin-right: 2px; }
.plan-toolbar select { height: 28px; font-size: 13px; padding: 0 6px; max-width: 170px; }
.btn.pill { border-radius: 14px; }
.btn.pill svg { width: 15px; height: 15px; }
.btn.pill.active svg { stroke-width: 2.8; }
.btn.warn-btn { border-color: var(--warn); color: var(--warn); background: var(--warn-soft); }
.btn .badge { min-width: 18px; height: 18px; font-size: 10.5px; padding: 0 5px; }
.menu { display: flex; flex-direction: column; }
.menu-item { display: flex; align-items: center; gap: 10px; padding: 8px 14px; border: 0; background: none; width: 100%;
  color: var(--text); font: inherit; font-size: 13.5px; text-align: left; cursor: pointer; text-decoration: none; }
.menu-item:hover { background: var(--surface-3); text-decoration: none; }
.menu-item svg { width: 16px; height: 16px; color: var(--muted); }

/* summary cards */
.plan-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 12px; padding: 12px 16px;
  background: var(--bg); border-bottom: 1px solid var(--border); }
.pk-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 10px 14px; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.pk-label { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); font-weight: 600; }
.pk-label svg { width: 15px; height: 15px; }
.pk-main { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-height: 28px; }
.pk-big { font-size: 22px; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.pk-sub { font-size: 12px; color: var(--muted); }
.pk-note { font-size: 12px; font-weight: 600; color: var(--muted); }
.pk-note.ok { color: var(--ok); } .pk-note.warn { color: var(--warn); } .pk-note.bad { color: var(--bad); }
.stack-bar { display: flex; gap: 2px; height: 8px; border-radius: 4px; overflow: hidden; background: var(--surface-3); }
.stack-bar span { display: block; min-width: 4px; }
.st-done { background: var(--ok); } .st-review { background: var(--warn); }
.st-doing { background: var(--primary); } .st-todo { background: var(--upcoming); opacity: .55; }
.pk-legend { display: flex; flex-wrap: wrap; gap: 2px 10px; font-size: 11.5px; color: var(--muted); }
.pk-legend i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 4px; }
.pk-stats { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 4px; }
.pk-stat { display: flex; flex-direction: column; align-items: flex-start; padding: 3px 4px; border-radius: 6px; border: 0;
  background: none; font: inherit; color: var(--text); text-align: left; min-width: 0; cursor: default; }
.pk-stat b { font-size: 19px; line-height: 1.15; font-variant-numeric: tabular-nums; }
.pk-stat span { font-size: 11px; line-height: 1.15; color: var(--muted); max-width: 100%; word-break: keep-all; }
.pk-stat.zero b { color: var(--faint); font-weight: 600; }
.pk-stat.bad b { color: var(--bad); } .pk-stat.warn b { color: var(--warn); }
.pk-stat.purple b { color: var(--purple); } .pk-stat.info b { color: var(--primary); }
button.pk-stat.bad { background: var(--bad-soft); cursor: pointer; }
button.pk-stat.bad:hover { filter: brightness(.97); }

/* chart */
.gantt { flex: 1; position: relative; overflow: auto; background: var(--surface); }
.g-inner { position: relative; }
.g-head { position: sticky; top: 0; z-index: 6; display: flex; background: var(--surface); border-bottom: 1px solid var(--border-strong); }
.g-head-left { position: sticky; left: 0; z-index: 7; background: var(--surface); border-right: 1px solid var(--border);
  display: grid; gap: 6px; align-items: end; padding: 0 10px 8px 12px; font-size: 11.5px; color: var(--muted); font-weight: 600;
  text-transform: uppercase; letter-spacing: .3px; }
.g-scale { position: relative; }
.g-scale .m { position: absolute; top: 0; height: 22px; line-height: 22px; font-size: 12px; font-weight: 700;
  padding-left: 8px; border-left: 1px solid var(--border); white-space: nowrap; overflow: hidden; color: var(--text); }
.g-scale .d { position: absolute; top: 22px; height: 30px; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 1px; line-height: 1.05; border-left: 1px solid var(--border); overflow: hidden; }
.g-scale .d b { font-size: 11.5px; font-weight: 600; color: var(--text); }
.g-scale .d span { font-size: 9.5px; color: var(--faint); }
.g-scale .d.off b { color: var(--faint); font-weight: 500; }
.g-scale .d.hol b, .g-scale .d.hol span { color: var(--bad); }
.g-scale .d.today b { background: var(--primary); color: #fff; border-radius: 9px; padding: 1px 5px; }
.g-scale .d.today span { color: var(--primary); font-weight: 700; }
.g-scale .d.wk { display: block; line-height: 30px; text-align: center; font-size: 11px; color: var(--muted); }
.g-scale .d.now { background: var(--primary-soft); color: var(--primary); font-weight: 700; }
.g-bg { position: absolute; z-index: 0; pointer-events: none; }
.g-bg .off { position: absolute; top: 0; bottom: 0; background: var(--weekend); }
.g-bg .hol { position: absolute; top: 0; bottom: 0; background: var(--holiday); }
.g-bg .today { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--primary); opacity: .75; }
.g-bg .today::before { content: ""; position: absolute; top: -1px; left: -3px; width: 8px; height: 8px; border-radius: 50%;
  background: var(--primary); }
.g-bg .ms { position: absolute; top: 0; bottom: 0; width: 0; border-left: 2px dashed var(--purple); opacity: .45; }
.g-links { position: absolute; z-index: 3; pointer-events: none; overflow: visible; }
.g-links path { fill: none; stroke: var(--faint); stroke-width: 1.4; opacity: .8; }
.g-links path.bad { stroke: var(--bad); stroke-dasharray: 4 3; opacity: 1; }
.g-links path.hi { stroke: var(--primary); stroke-width: 2.2; opacity: 1; }

/* rows */
.g-row { display: flex; position: relative; border-bottom: 1px solid var(--border); }
.g-row:hover > .g-left, .g-row.sel > .g-left { background: var(--surface-2); }
.g-row:hover > .g-time { background: rgba(37, 99, 235, .035); }
.g-left { position: sticky; left: 0; z-index: 4; background: var(--surface); border-right: 1px solid var(--border);
  display: flex; align-items: center; gap: 6px; padding: 0 8px 0 12px; min-width: 0; cursor: pointer; }
.g-left .g-name { flex: 1; min-width: 0; display: flex; align-items: center; gap: 7px; overflow: hidden; }
.g-left .g-name .t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.g-left .g-name > svg.icon { width: 16px; height: 16px; color: var(--c, var(--muted)); }
.g-left .code { font-size: 10.5px; color: var(--faint); font-variant-numeric: tabular-nums; flex: 0 0 auto; }
.g-left .count { font-size: 11px; color: var(--muted); background: var(--surface-3); border-radius: 9px; padding: 0 7px;
  line-height: 18px; flex: 0 0 auto; font-weight: 600; }
.g-left .g-dates { font-size: 11px; color: var(--muted); width: 82px; text-align: right; flex: 0 0 auto; font-variant-numeric: tabular-nums; }
.g-left .g-pct { width: 64px; flex: 0 0 auto; display: flex; align-items: center; justify-content: flex-end; gap: 6px; font-size: 11px; }
.g-pct .mini { width: 26px; height: 4px; border-radius: 2px; background: var(--surface-3); overflow: hidden; flex: 0 0 auto; }
.g-pct .mini i { display: block; height: 100%; background: var(--primary); border-radius: 2px; }
.g-pct.full .mini i { background: var(--ok); }
.g-pct.late .mini i { background: var(--bad); } .g-pct.late .n { color: var(--bad); font-weight: 700; }
.g-pct .n { min-width: 30px; text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.g-left .tw, .g-left .tw-space { width: 18px; height: 18px; flex: 0 0 auto; }
.g-left .tw { display: grid; place-items: center; color: var(--muted); border: 0; background: none; padding: 0; border-radius: 4px; }
.g-left .tw:hover { background: var(--surface-3); }
.g-left .tw svg { width: 14px; height: 14px; transition: transform .12s; }
.g-left .tw.closed svg { transform: rotate(-90deg); }
.g-left .add-btn { width: 22px; height: 22px; display: grid; place-items: center; border: 0; border-radius: 6px; padding: 0;
  background: none; color: var(--primary); opacity: .35; flex: 0 0 auto; }
.g-left .add-btn svg { width: 15px; height: 15px; }
.g-row:hover .add-btn { opacity: 1; } .g-left .add-btn:hover { background: var(--primary-soft); }
.sdot { width: 8px; height: 8px; border-radius: 50%; background: var(--c); flex: 0 0 auto; }
.g-row.phase { background: color-mix(in srgb, var(--surface-3) 55%, transparent); }
.g-row.phase > .g-left { background: var(--surface-2); font-weight: 700; box-shadow: inset 4px 0 0 var(--c); padding-left: 10px; }
.g-row.phase > .g-left .t { color: color-mix(in srgb, var(--c) 35%, var(--text)); }
.g-row.phase:hover > .g-left { background: var(--surface-3); }
.g-row.package > .g-left { font-weight: 600; padding-left: 28px; }
.g-row.task > .g-left { padding-left: 46px; font-size: 13.5px; }
.g-row.task.child > .g-left { padding-left: 64px; }
.g-row.task .avatar { width: 22px; height: 22px; font-size: 10px; }
.g-time { position: relative; flex: 0 0 auto; }

/* colour per state: bars, phase rows, dots, legend */
:is(.bar, .sumbar, .sdot, .lg-bar, .g-row.phase) { --c: var(--upcoming); }
:is(.bar, .sumbar, .sdot, .lg-bar, .g-row.phase):is(.on_track, .doing) { --c: var(--primary); }
:is(.bar, .sumbar, .sdot, .lg-bar, .g-row.phase):is(.behind, .at_risk) { --c: var(--warn); }
:is(.bar, .sumbar, .sdot, .lg-bar, .g-row.phase).late { --c: var(--bad); }
:is(.bar, .sumbar, .sdot, .lg-bar, .g-row.phase).blocked { --c: var(--purple); }
:is(.bar, .sumbar, .sdot, .lg-bar, .g-row.phase).done { --c: var(--ok); }

/* bars: tinted track, solid part = % done */
.bar { position: absolute; top: 7px; height: 22px; border-radius: 6px; cursor: grab; z-index: 2; user-select: none;
  touch-action: none; display: flex; align-items: center;
  background: color-mix(in srgb, var(--c) 20%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--c) 65%, var(--surface));
  box-shadow: 0 1px 2px rgba(16, 24, 40, .08); transition: box-shadow .12s; }
.bar:hover { box-shadow: 0 0 0 3px color-mix(in srgb, var(--c) 28%, transparent); }
.bar .fill { position: absolute; left: -1px; top: -1px; bottom: -1px; border-radius: 6px; background: var(--c); pointer-events: none; }
.bar .out { position: absolute; left: calc(100% + 7px); display: flex; align-items: center; gap: 5px; font-size: 11.5px;
  color: var(--muted); white-space: nowrap; pointer-events: none; }
.bar .out .avatar { width: 18px; height: 18px; font-size: 8.5px; }
.bar .out .late-tag { color: var(--bad); font-weight: 700; }
.bar .h { position: absolute; top: 0; bottom: 0; width: 8px; cursor: ew-resize; }
.bar .h.l { left: -2px; } .bar .h.r { right: -2px; }
.bar.critical { box-shadow: 0 0 0 2px var(--bad); }
.bar.dim { opacity: .25; }
.bar.dragging { opacity: .9; cursor: grabbing; box-shadow: var(--shadow-lg); }
.sumbar { position: absolute; top: 11px; height: 14px; border-radius: 7px; z-index: 2; overflow: hidden;
  background: color-mix(in srgb, var(--c) 18%, var(--surface)); border: 1px solid color-mix(in srgb, var(--c) 50%, var(--surface)); }
.sumbar .fill { position: absolute; left: 0; top: 0; bottom: 0; background: var(--c); }
.pkgbar { position: absolute; top: 14px; height: 8px; border-radius: 4px; z-index: 2; overflow: hidden;
  background: color-mix(in srgb, var(--faint) 30%, var(--surface)); }
.pkgbar .fill { position: absolute; left: 0; top: 0; bottom: 0; background: var(--primary); border-radius: 4px; }
.pkgbar.full .fill { background: var(--ok); }
.diamond { position: absolute; top: 10px; width: 16px; height: 16px; transform: rotate(45deg); background: var(--purple);
  z-index: 3; border-radius: 3px; margin-left: -8px; box-shadow: 0 0 0 2px var(--surface); }
.diamond.late { background: var(--bad); } .diamond.at_risk { background: var(--warn); } .diamond.done { background: var(--ok); }
.baseline { position: absolute; top: 31px; height: 3px; background: var(--faint); border-radius: 2px; z-index: 1; opacity: .85; }
.g-row.task.flash > .g-left { background: var(--primary-soft); }

/* legend under the chart */
.g-legend { display: flex; align-items: center; gap: 8px 16px; flex-wrap: wrap; padding: 7px 16px; font-size: 12px;
  color: var(--muted); background: var(--surface); border-top: 1px solid var(--border); }
.lg-item { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.lg-bar { width: 24px; height: 11px; border-radius: 4px; position: relative; overflow: hidden;
  background: color-mix(in srgb, var(--c) 20%, var(--surface)); border: 1px solid color-mix(in srgb, var(--c) 65%, var(--surface)); }
.lg-bar::after { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 55%; background: var(--c); }
.lg-bar.upcoming::after { width: 0; } .lg-bar.done::after { width: 100%; }
.lg-bar.lg-critical { box-shadow: 0 0 0 2px var(--bad); }
.lg-diamond { width: 10px; height: 10px; transform: rotate(45deg); background: var(--purple); border-radius: 2px; margin: 0 2px; }
.lg-today { width: 2px; height: 14px; background: var(--primary); position: relative; }
.lg-today::before { content: ""; position: absolute; top: -2px; left: -3px; width: 8px; height: 8px; border-radius: 50%; background: var(--primary); }
.lg-off { width: 16px; height: 12px; border-radius: 3px; background: var(--holiday); border: 1px solid var(--border); }
.lg-dep { width: 22px; height: 0; border-top: 1.5px solid var(--faint); position: relative; }
.lg-dep::after { content: ""; position: absolute; right: -1px; top: -4.5px; border: 4px solid transparent; border-left: 6px solid var(--faint); border-right: 0; }
.lg-baseline { width: 22px; height: 3px; border-radius: 2px; background: var(--faint); }
.lg-sep { width: 1px; height: 16px; background: var(--border); }
.lg-hint { display: inline-flex; align-items: center; gap: 5px; color: var(--faint); }
.lg-hint svg { width: 14px; height: 14px; }

.plan-toolbar .chev { width: 14px; height: 14px; margin-left: -2px; }
@media (max-width: 1400px) {
  .plan-toolbar { gap: 8px; }
  .tb-group + .tb-group { padding-left: 8px; }
  .tb-label, .plan-toolbar .wide-only, .tb-group > svg.icon, .plan-toolbar .chev { display: none; }
  .plan-toolbar select { max-width: 130px; }
}
@media (max-width: 760px) {
  .plan-toolbar { gap: 6px; padding: 8px 10px; }
  .plan-toolbar .lbl-text, .plan-toolbar .grow { display: none; }
  .plan-toolbar .btn.pill { padding: 0 8px; }
  .plan-toolbar select { max-width: 118px; }
  .tb-group + .tb-group { padding-left: 0; border-left: 0; }
  .plan-kpis { display: flex; overflow-x: auto; padding: 10px 12px; }
  .pk-card { flex: 0 0 250px; }
  .g-left { padding: 0 6px 0 8px; gap: 5px; }
  .g-left .g-dates, .g-left .code, .g-left .menu-tw, .g-left .tw-space, .g-pct .mini, .g-row.phase .chip { display: none; }
  .g-left .g-pct { width: 38px; }
  .g-row.package > .g-left { padding-left: 14px; }
  .g-row.task > .g-left { padding-left: 22px; font-size: 13px; }
  .g-row.task.child > .g-left { padding-left: 32px; }
  .g-left .add-btn { opacity: 1; }
  .g-legend { flex-wrap: nowrap; overflow-x: auto; padding: 6px 10px; }
  .lg-hint { display: none; }
}

/* --------------------------------------------------------------- kanban */
.board { flex: 1; display: grid; grid-template-columns: repeat(4, minmax(250px, 1fr)); gap: 14px; padding: 16px; overflow: auto; align-items: start; }
.lane { background: var(--surface-3); border-radius: 10px; display: flex; flex-direction: column; max-height: 100%; min-height: 120px; }
.lane-head { display: flex; align-items: center; gap: 8px; padding: 10px 12px; font-weight: 600; }
.lane-head .count { color: var(--muted); font-weight: 500; font-size: 12px; }
.lane-body { padding: 0 8px 10px; display: flex; flex-direction: column; gap: 8px; overflow-y: auto; min-height: 60px; }
.lane.over { outline: 2px dashed var(--primary); outline-offset: -4px; }
.kcard { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 9px 10px; cursor: pointer;
  box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 6px; }
.kcard:hover { border-color: var(--border-strong); }
.kcard.dragging { opacity: .4; }
.kcard .k-title { font-weight: 500; line-height: 1.35; word-break: break-word; }
.kcard .k-meta { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.kcard .k-due { display: inline-flex; align-items: center; gap: 3px; }
.kcard .k-due .icon { width: 14px; height: 14px; }
.kcard .k-due.late { color: var(--bad); font-weight: 600; }
.kcard.late { border-left: 3px solid var(--bad); } .kcard.behind { border-left: 3px solid var(--warn); }
.kcard.blocked { border-left: 3px solid var(--purple); }

/* ------------------------------------------------------------ workload */
.load-grid { display: grid; gap: 0; overflow: auto; }
.load-table { border-collapse: separate; border-spacing: 0; width: 100%; }
.load-table th, .load-table td { border-bottom: 1px solid var(--border); padding: 6px; }
.load-table th { font-size: 12px; color: var(--muted); font-weight: 600; text-align: center; background: var(--surface-2);
  position: sticky; top: 0; z-index: 1; white-space: nowrap; }
.load-table td.person { position: sticky; left: 0; background: var(--surface); z-index: 1; min-width: 190px; }
.load-table tr.drop td { background: var(--primary-soft); }
.lcell { border-radius: 6px; padding: 6px 8px; min-width: 96px; cursor: pointer; border: 1px solid transparent; display: flex; flex-direction: column; gap: 4px; }
.lcell:hover { border-color: var(--border-strong); }
.lcell .lh { font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; }
.lcell .lnote { font-size: 11px; color: var(--muted); display: flex; gap: 6px; }
.lcell.free { background: var(--ok-soft); } .lcell.busy { background: var(--warn-soft); }
.lcell.over { background: var(--bad-soft); } .lcell.off { background: var(--surface-3); }
.lcell .progress > span { background: var(--ok); }
.lcell .lnote span { background: var(--surface); border-radius: 4px; padding: 0 4px; }
.legend .sw.free { background: var(--ok-soft); border: 1px solid var(--ok); }
.legend .sw.busy { background: var(--warn-soft); border: 1px solid var(--warn); }
.legend .sw.over { background: var(--bad-soft); border: 1px solid var(--bad); }
.lcell.busy .progress > span { background: var(--warn); } .lcell.over .progress > span { background: var(--bad); }
.uncard { padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); cursor: grab;
  display: flex; flex-direction: column; gap: 4px; }
.uncard:hover { border-color: var(--border-strong); }
.suggest-chip { cursor: pointer; border: 1px solid var(--border); background: var(--surface); }
.suggest-chip:hover { border-color: var(--primary); color: var(--primary); }

/* --------------------------------------------------------------- leave */
.bal-cards { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.cal-grid { overflow: auto; }
.cal-table { border-collapse: separate; border-spacing: 0; font-size: 12px; }
.cal-table th, .cal-table td { border-bottom: 1px solid var(--border); border-right: 1px solid var(--border); text-align: center; padding: 0; height: 30px; min-width: 28px; }
.cal-table th { background: var(--surface-2); color: var(--muted); font-weight: 600; position: sticky; top: 0; z-index: 1; }
.cal-table td.who, .cal-table th.who { position: sticky; left: 0; background: var(--surface); text-align: left; padding: 0 10px; min-width: 160px; z-index: 2; }
.cal-table .off { background: var(--weekend); } .cal-table .hol { background: var(--holiday); }
.cal-table th.today { background: var(--primary); color: #fff; }
.cal-table .lv { position: relative; }
.cal-table .lv::after { content: ""; position: absolute; inset: 5px 2px; border-radius: 4px; background: var(--info); }
.cal-table .lv.pending::after { background: repeating-linear-gradient(45deg, var(--warn), var(--warn) 3px, transparent 3px, transparent 6px); border: 1px solid var(--warn); }
.cal-table .lv.am::after { right: 50%; } .cal-table .lv.pm::after { left: 50%; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); align-items: center; }
.legend .sw { width: 14px; height: 10px; border-radius: 3px; display: inline-block; margin-right: 4px; vertical-align: -1px; }

/* -------------------------------------------------------------- report */
.report { max-width: 1100px; margin: 0 auto; display: flex; flex-direction: column; gap: 16px; }
.report-head { display: flex; gap: 16px; align-items: flex-start; flex-wrap: wrap; }
.big-progress { display: flex; flex-direction: column; gap: 6px; min-width: 260px; flex: 1; }

/* ---------------------------------------------------------------- notes */
.notes-layout { display: grid; grid-template-columns: minmax(280px, 360px) minmax(0, 1fr); gap: 16px; align-items: start; }
.note-side { position: sticky; top: 0; }
.note-list { display: flex; flex-direction: column; gap: 8px; max-height: calc(100vh - 290px); overflow-y: auto; padding: 2px; }
.note-card { background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--border-strong); border-radius: 8px;
  padding: 9px 11px; cursor: pointer; display: flex; flex-direction: column; gap: 4px; box-shadow: var(--shadow); }
.note-card:hover { border-color: var(--border-strong); }
.note-card.sel { outline: 2px solid var(--primary); outline-offset: -1px; }
.note-card .icon.pin { width: 14px; height: 14px; color: var(--warn); }
.note-card .icon.vis { width: 14px; height: 14px; color: var(--faint); }
.note-snip { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.note-card.c-yellow, .note-paper.c-yellow { border-left-color: #eab308; }
.note-card.c-green, .note-paper.c-green { border-left-color: #16a34a; }
.note-card.c-blue, .note-paper.c-blue { border-left-color: #2563eb; }
.note-card.c-pink, .note-paper.c-pink { border-left-color: #db2777; }
.note-card.c-purple, .note-paper.c-purple { border-left-color: #7c3aed; }
.note-card.c-gray, .note-paper.c-gray { border-left-color: #64748b; }
.color-dot { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--surface); padding: 0; cursor: pointer;
  box-shadow: 0 0 0 1px var(--border-strong); }
.color-dot.c-yellow { background: #eab308; } .color-dot.c-green { background: #16a34a; }
.color-dot.c-blue { background: #2563eb; } .color-dot.c-pink { background: #db2777; }
.color-dot.c-purple { background: #7c3aed; } .color-dot.c-gray { background: #64748b; }
.color-dot.c-none { background: repeating-linear-gradient(45deg, var(--surface), var(--surface) 3px, var(--surface-3) 3px, var(--surface-3) 6px); }
.color-dot.on { box-shadow: 0 0 0 2px var(--primary); }
.note-paper { border-left: 6px solid var(--border-strong); min-height: calc(100vh - 200px); display: flex; flex-direction: column; }
.note-head { padding: 14px 18px 10px; border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 10px; }
.note-head .field select, .note-head .field input { min-width: 150px; }
.note-body { padding: 14px 20px 22px; flex: 1; display: flex; flex-direction: column; }
.note-read { gap: 2px; font-size: 14.5px; line-height: 1.55; }
.note-text { flex: 1; min-height: 420px; font: 14.5px/1.6 var(--font); resize: vertical; }
.nl-blank { height: 10px; }
.nl-head { font-weight: 650; margin-top: 6px; }
.nl-bullet { padding-left: 6px; }
.nl-text { white-space: pre-wrap; word-break: break-word; }
.nl-check { display: flex; align-items: flex-start; gap: 9px; padding: 3px 6px; border-radius: 6px; cursor: pointer; }
.nl-check:hover { background: var(--surface-2); }
.nl-check input { margin-top: 3px; flex: 0 0 auto; }
.nl-check.done span { text-decoration: line-through; color: var(--muted); }
.nl-check .nl-task { visibility: hidden; height: 24px; }
.nl-check:hover .nl-task { visibility: visible; }

/* --------------------------------------------------------------- mobile */
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 45; top: 0; bottom: 0; left: 0; width: 240px; transform: translateX(-100%); transition: transform .18s; box-shadow: var(--shadow-lg); }
  .app.nav-open .sidebar { transform: none; }
  .topbar .menu-btn { display: inline-flex; }
  .main { padding: 14px; }
  .layout-2, .grid3, .notes-layout { grid-template-columns: minmax(0, 1fr) !important; }
  .note-list { max-height: 40vh; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .bal-cards { grid-template-columns: 1fr 1fr; }
  .topbar { padding: 0 10px; }
  .topbar .hide-sm { display: none; }
  .board { grid-template-columns: repeat(4, 84vw); }
}

/* ---------------------------------------------------------------- print */
@media print {
  .sidebar, .topbar, .no-print, .toast-host { display: none !important; }
  .app { display: block; height: auto; }
  .main { overflow: visible; padding: 0; }
  body { background: #fff; color: #000; }
  .card { box-shadow: none; break-inside: avoid; }
}
