:root {
  --bg: #f4f6fa;
  --panel: #ffffff;
  --ink: #1e2633;
  --muted: #6b7688;
  --line: #e3e8f0;
  --brand: #3b5bdb;
  --brand-ink: #ffffff;
  --in_progress: #3b82f6;
  --overdue: #ef4444;
  --hold: #f59e0b;
  --done: #22c55e;
  --done_late: #9333ea;
  --shadow: 0 8px 30px rgba(20, 30, 60, .12);
  --radius: 10px;
}
* { box-sizing: border-box; }
/* The `hidden` attribute must always win, even over class rules that set `display`
   (.modal, .view, .drawer). Without this, hidden pop-ups stay visible and can't be closed. */
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
html { overflow: hidden; }        /* app shell: only inner regions scroll, never the window */
body {
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg); color: var(--ink); font-size: 14px;
  display: flex; flex-direction: column; height: 100vh; overflow: hidden;
}
/* App shell: fill the viewport so each view scrolls internally (keeps topbar + toolbars pinned). */
#appRoot { flex: 1; display: flex; flex-direction: column; min-height: 0; }
h1, h2, h3 { margin: 0; }
button { font-family: inherit; cursor: pointer; }

/* ---------- topbar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 14px 22px; background: var(--panel);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 40; flex-shrink: 0;
}
.brand { display: flex; align-items: center; gap: 12px; }
.logo {
  width: 40px; height: 40px; display: grid; place-items: center;
  background: var(--brand); color: #fff; border-radius: 10px; font-size: 20px;
}
.topbar h1 { font-size: 17px; }
.subtitle { margin: 2px 0 0; color: var(--muted); font-size: 12px; }
.tabs { display: flex; gap: 4px; background: var(--bg); padding: 4px; border-radius: 10px; }
.tab {
  border: 0; background: transparent; padding: 8px 16px; border-radius: 8px;
  color: var(--muted); font-weight: 600; font-size: 13px;
}
.tab.active { background: var(--panel); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.08); }

/* ---------- views / toolbar ---------- */
.view { flex: 1; padding: 18px 22px; display: flex; flex-direction: column; min-height: 0; }
.toolbar { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; flex-wrap: wrap; flex-shrink: 0; }
.spacer { flex: 1; }
.legend { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; }
.dot { width: 11px; height: 11px; border-radius: 3px; display: inline-block; margin-left: 6px; }
.dot.s-in_progress { background: var(--in_progress); }
.dot.s-overdue { background: var(--overdue); }
.dot.s-hold { background: var(--hold); }
.dot.s-done { background: var(--done); }
.search, input[type="week"], input[type="date"], input[type="text"], textarea, input[type="search"] {
  font: inherit; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--panel); color: var(--ink);
}
.search { width: 220px; }
.toggle {
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
  font-size: 12px; color: var(--muted); user-select: none; white-space: nowrap;
}
.toggle input { margin: 0; cursor: pointer; }
.gantt-hidden-note {
  position: sticky; left: 0; padding: 8px 12px; margin-top: 2px;
  font-size: 12px; color: var(--muted); background: var(--panel);
}
.gantt-hidden-note a { color: var(--in_progress); font-weight: 600; }

.btn {
  border: 1px solid var(--line); background: var(--panel); color: var(--ink);
  padding: 8px 14px; border-radius: 8px; font-weight: 600; font-size: 13px;
}
.btn:hover { border-color: #c7d0e0; }
.btn.primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.btn.primary:hover { background: #324bc0; }
.btn.danger { color: var(--overdue); border-color: #f3c0c0; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.small { padding: 5px 10px; font-size: 12px; }

.empty { color: var(--muted); text-align: center; padding: 60px 20px; }

/* ---------- gantt ---------- */
.gantt-wrap {
  flex: 1; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: auto; min-height: 0;
}
.gantt { position: relative; --left-w: 320px; --lbl-cols: 16px 1fr 76px 40px; }
.g-header, .g-row { display: grid; grid-template-columns: var(--left-w) 1fr; }
.g-header {
  position: sticky; top: 0; z-index: 10; background: var(--panel);
  border-bottom: 2px solid var(--line);
}
.g-corner {
  position: sticky; left: 0; z-index: 12; background: var(--panel);
  border-right: 2px solid var(--line); padding: 6px 10px; font-weight: 700; font-size: 10px;
  text-transform: uppercase; letter-spacing: .03em;
  color: var(--muted); display: grid; grid-template-columns: var(--lbl-cols); align-items: center; gap: 6px;
}
.g-corner span:last-child { text-align: center; }
.g-timeline-head { position: relative; height: 44px; background: var(--panel); }
.g-month {
  position: absolute; top: 4px; font-size: 11px; font-weight: 700; color: var(--ink);
  border-left: 1px solid #cdd5e2; padding-left: 5px; height: 100%;
}
.g-week-tick { position: absolute; bottom: 4px; font-size: 9px; color: var(--muted); transform: translateX(2px); }

.g-row { border-bottom: 1px solid var(--line); background: var(--panel); }
.g-row:hover { background: #fafbfe; }
.g-label {
  position: sticky; left: 0; z-index: 4; background: inherit;
  border-right: 2px solid var(--line); padding: 3px 10px;
  display: grid; grid-template-columns: var(--lbl-cols); align-items: center; gap: 6px;
}
.g-row:hover .g-label { background: #fafbfe; }
.drag-handle { cursor: grab; color: #b3bccd; font-size: 13px; user-select: none; line-height: 1; }
.drag-handle:active { cursor: grabbing; }
.lbl-name { font-weight: 600; font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; }
.lbl-status { display: flex; justify-content: flex-start; cursor: pointer; }
.lbl-upd { text-align: center; font-size: 12px; font-weight: 600; color: var(--muted); cursor: pointer; }

/* category groups + drag/drop */
.cat-group { border-bottom: 2px solid var(--line); }
.g-cat-row { display: grid; grid-template-columns: var(--left-w) 1fr; background: #e9edf7; border-top: 1px solid var(--line); }
.cat-head {
  position: sticky; left: 0; z-index: 6; background: #e9edf7;
  border-right: 2px solid var(--line);
  height: 28px; padding: 0 12px; display: flex; align-items: center; gap: 8px;
}
.g-cat-row { cursor: pointer; }
.g-cat-row[draggable="true"] .cat-head:hover { background: #e0e6f5; }
.cat-group.dragging { opacity: .5; }
.cat-group.cat-dnd-before { box-shadow: inset 0 3px 0 0 var(--brand); }
.cat-group.cat-dnd-after { box-shadow: inset 0 -3px 0 0 var(--brand); }
.cat-head .cat-caret { color: var(--muted); font-size: 10px; width: 12px; display: inline-block; }
.cat-head .cat-name { font-weight: 700; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cat-head .cat-count {
  margin-left: auto; background: #fff; color: var(--muted); border: 1px solid var(--line);
  border-radius: 20px; padding: 0 8px; font-size: 11px; font-weight: 700;
}
.cat-icon-btn {
  border: 1px solid var(--line); background: #fff; color: var(--brand);
  width: 22px; height: 22px; border-radius: 6px; font-size: 14px; line-height: 1;
  display: grid; place-items: center; padding: 0; font-weight: 700; flex-shrink: 0;
}
.cat-icon-btn[data-cat-add] { font-size: 16px; }
.cat-icon-btn:hover { background: var(--brand); color: #fff; border-color: var(--brand); }
.cat-band { position: relative; height: 100%; min-height: 26px; background: #e9edf7; }
.g-row.dragging { opacity: .4; }
.g-row.dnd-before { box-shadow: inset 0 3px 0 0 var(--brand); }
.g-row.dnd-after { box-shadow: inset 0 -3px 0 0 var(--brand); }
.cat-group.dnd-into { outline: 2px dashed var(--brand); outline-offset: -2px; border-radius: 4px; }
.g-track { position: relative; height: 28px; }
.g-row .g-track { background: var(--panel); }        /* full-width row background (subjects only, not the category band) */
.g-row:hover .g-track { background: #fafbfe; }
.g-grid-line { position: absolute; top: 0; bottom: 0; width: 1px; }
.g-grid-line.month { background: #cdd5e2; }         /* aligns with the header month line */
.g-grid-line.week { background: var(--line); opacity: .45; }
.g-today { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--overdue); opacity: .55; z-index: 3; }

.bar {
  position: absolute; top: 6px; height: 16px; border-radius: 5px; cursor: pointer;
  display: flex; align-items: center; overflow: hidden; box-shadow: 0 1px 2px rgba(0,0,0,.15);
}
.bar.s-in_progress { background: var(--in_progress); }
.bar.s-overdue { background: var(--overdue); }
.bar.s-hold { background: var(--hold); }
.bar.s-done { background: var(--done); }
.bar .bar-name { color: #fff; font-size: 10px; font-weight: 600; padding: 0 8px; white-space: nowrap; pointer-events: none; }
/* "Original plan" ghost — where the subject was scheduled before it was re-planned on restart. */
.bar-ghost {
  position: absolute; top: 8px; height: 12px; border-radius: 4px; z-index: 1;
  border: 1px dashed var(--muted); background: repeating-linear-gradient(45deg, rgba(120,130,150,.12) 0 4px, transparent 4px 8px);
  pointer-events: auto;
}
.date-lock-hint { background: #fdf0e3; color: #b45309; border: 1px solid #f4d8b0; border-radius: 8px; padding: 8px 10px; font-size: 12px; margin: 4px 0 12px; }
.bar.draggable-dates { cursor: grab; touch-action: none; }
.bar.date-dragging { cursor: grabbing; box-shadow: 0 2px 8px rgba(0,0,0,.3); z-index: 6; }
.bar-resize { position: absolute; top: 0; bottom: 0; width: 8px; z-index: 2; cursor: ew-resize; }
.bar-resize.left { left: 0; } .bar-resize.right { right: 0; }
.bar.draggable-dates:hover .bar-resize { background: rgba(255,255,255,.35); }
.drag-tip {
  position: fixed; z-index: 200; background: #1e2633; color: #fff; font-size: 12px; font-weight: 600;
  padding: 5px 9px; border-radius: 6px; pointer-events: none; box-shadow: var(--shadow); white-space: nowrap;
}
.hold-overlay {
  position: absolute; top: 6px; height: 16px; border-radius: 4px; z-index: 2; pointer-events: none;
  background-image: repeating-linear-gradient(45deg, rgba(0,0,0,.30) 0 5px, rgba(0,0,0,0) 5px 10px);
  border: 1px dashed rgba(0,0,0,.35);
}
.marker-target {
  position: absolute; top: 3px; width: 0; height: 22px; z-index: 3;
  border-left: 2px dashed rgba(30,38,51,.55);
}
.marker-done {
  position: absolute; top: 8px; width: 12px; height: 12px; margin-left: -6px; z-index: 4;
  background: #145c2e; border: 2px solid #fff; border-radius: 50%;
  box-shadow: 0 1px 2px rgba(0,0,0,.4);
}
/* Late completion: a distinct red diamond on the actual done day. */
.marker-done.late { background: var(--overdue); border-radius: 2px; transform: rotate(45deg); }
/* Dotted connector from the target to a late done day (shows the slip without extending the bar). */
.slip-line {
  position: absolute; top: 13px; height: 0; z-index: 3; pointer-events: none;
  border-top: 2px dotted var(--overdue);
}
.badge {
  display: inline-block; padding: 1px 8px; border-radius: 20px; font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .03em; color: #fff;
}
.badge.s-in_progress { background: var(--in_progress); }
.badge.s-overdue { background: var(--overdue); }
.badge.s-hold { background: var(--hold); }
.badge.s-done { background: var(--done); }
.cat-chip {
  display: inline-block; padding: 1px 8px; border-radius: 20px; font-size: 10px; font-weight: 700;
  background: #eef2ff; color: var(--brand); border: 1px solid #d7deff; white-space: nowrap;
}

/* ---------- drawer ---------- */
.drawer { position: fixed; inset: 0; z-index: 40; }
.drawer-backdrop { position: absolute; inset: 0; background: rgba(15,20,35,.4); }
.drawer-panel {
  position: absolute; right: 0; top: 0; bottom: 0; width: min(560px, 96vw);
  background: var(--panel); box-shadow: var(--shadow); overflow-y: auto; padding: 22px;
}
.drawer h2 { font-size: 18px; }
.drawer .close-x { float: right; border: 0; background: transparent; font-size: 22px; color: var(--muted); }
.detail-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin: 14px 0; }
.detail-grid .cell { background: var(--bg); border-radius: 8px; padding: 8px 10px; }
.detail-grid .cell label { font-size: 10px; text-transform: uppercase; color: var(--muted); letter-spacing: .04em; }
.detail-grid .cell .val { font-weight: 600; margin-top: 2px; }
.action-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 18px; }
.hold-hist { margin: 10px 0; }
.hold-hist .h-item { font-size: 12px; color: var(--muted); padding: 4px 0; border-bottom: 1px dashed var(--line); }

.section-title { font-size: 13px; font-weight: 700; margin: 18px 0 8px; display: flex; justify-content: space-between; align-items: center; }
.update-form { background: var(--bg); border-radius: 10px; padding: 12px; margin-bottom: 14px; }
.update-form textarea { width: 100%; resize: vertical; }
.update-form .row { display: flex; gap: 8px; align-items: center; margin-top: 8px; flex-wrap: wrap; }
.filelist { font-size: 12px; color: var(--muted); }

.update {
  border: 1px solid var(--line); border-radius: 10px; padding: 12px; margin-bottom: 10px; background: var(--panel);
}
.update .u-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; }
.update .u-date { font-weight: 700; font-size: 12px; }
.update .u-week { color: var(--muted); font-size: 11px; }
.update .u-body { line-height: 1.5; }
.log-item { display: flex; gap: 9px; padding: 7px 2px; border-bottom: 1px solid var(--line); }
.log-item:last-child { border-bottom: 0; }
.log-icon { flex: 0 0 18px; text-align: center; font-size: 12px; line-height: 1.4; }
.log-body { min-width: 0; }
.log-detail { font-size: 13px; line-height: 1.4; }
.log-meta { color: var(--muted); font-size: 11px; margin-top: 1px; }
.update .u-week a { color: var(--muted); }
.update.editing { border-color: var(--in_progress); }
.update .u-edit-text { width: 100%; resize: vertical; }
.update.editing .row { display: flex; gap: 8px; align-items: center; margin-top: 8px; flex-wrap: wrap; }
.attachments { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.attachments a { text-decoration: none; }
.attachments img { max-height: 90px; border-radius: 6px; border: 1px solid var(--line); display: block; }
.file-chip {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--brand);
  background: #eef2ff; padding: 5px 10px; border-radius: 8px;
}

/* ---------- modal ---------- */
.modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(15,20,35,.45); }
.modal-card { position: relative; background: var(--panel); border-radius: 14px; padding: 22px; width: min(520px, 94vw); box-shadow: var(--shadow); }
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; font-weight: 600; font-size: 12px; color: var(--muted); }
.field input, .field textarea { font-weight: 400; color: var(--ink); }
.field small { font-weight: 400; color: var(--muted); }
.field.inline { flex-direction: row; align-items: center; gap: 8px; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }

/* ---------- MoM ---------- */
/* Minutes week picker: a button with the week's dates that opens a month calendar of weeks. */
.week-pick { position: relative; display: inline-flex; }
.week-btn { font-weight: 600; color: var(--ink); }
.week-btn::after { content: '▾'; margin-left: 8px; font-size: 10px; color: var(--muted); }
.week-panel {
  position: absolute; top: calc(100% + 4px); left: 0; z-index: 50; width: 290px; padding: 10px;
  background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 8px 24px rgba(15, 23, 42, .12);
  font-weight: 400; color: var(--ink);
}
.wk-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; font-size: 13px; }
.wk-nav { border: 0; background: none; font-size: 18px; line-height: 1; padding: 2px 10px; border-radius: 6px; cursor: pointer; color: var(--ink); }
.wk-nav:hover:not(:disabled) { background: var(--bg, #f1f3f7); }
.wk-nav:disabled { opacity: .3; cursor: default; }
.wk-row { display: grid; grid-template-columns: 30px repeat(7, 1fr); width: 100%; border: 0; background: none; padding: 5px 0;
  border-radius: 6px; font: inherit; font-size: 12px; text-align: center; color: var(--ink); cursor: pointer; }
.wk-row .wk-no { color: var(--muted); font-size: 11px; }
.wk-row .out { color: var(--muted); opacity: .6; }
button.wk-row:hover:not(:disabled) { background: #eef2ff; }
.wk-row.now { box-shadow: inset 0 0 0 1px var(--brand); }
.wk-row.sel { background: var(--brand); color: #fff; }
.wk-row.sel .wk-no, .wk-row.sel .out { color: #fff; }
button.wk-row.sel:hover { background: var(--brand); }
.wk-row:disabled { opacity: .35; cursor: default; }
.wk-days { cursor: default; font-weight: 600; color: var(--muted); }
.mom-output {
  flex: 1; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 30px 40px; overflow: auto; min-height: 0;
}
.mom-doc { max-width: 820px; margin: 0 auto; }
.mom-doc h1 { font-size: 22px; margin-bottom: 4px; }
.mom-doc .mom-sub { color: var(--muted); font-size: 13px; margin-bottom: 20px; }
.mom-subject { border-top: 2px solid var(--line); padding-top: 16px; margin-top: 18px; }
.mom-subject h3 { font-size: 16px; display: flex; align-items: center; gap: 10px; }
.mom-dates { font-size: 12px; color: var(--muted); margin: 4px 0 10px; }
.mom-events { margin: 6px 0 10px; padding-left: 18px; }
.mom-events li { font-size: 13px; margin: 2px 0; }
.mom-upd { margin: 10px 0; padding-left: 14px; border-left: 3px solid var(--line); }
.mom-upd .d { font-weight: 700; font-size: 12px; }
.mom-upd .b { white-space: pre-wrap; line-height: 1.5; margin: 3px 0; }
.mom-att { font-size: 12px; color: var(--muted); }
.mom-att img { max-height: 130px; border-radius: 6px; border: 1px solid var(--line); margin: 6px 8px 0 0; }

.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  background: #1e2633; color: #fff; padding: 10px 18px; border-radius: 10px; z-index: 60;
  box-shadow: var(--shadow); font-size: 13px;
}

@media print {
  @page { size: A4 landscape; margin: 12mm; }

  /* The app is a fixed-height shell where only .mom-output scrolls. For print, unclip the whole
     chain so every row flows across pages instead of only the one visible screenful. */
  html, body, #appRoot, .view, .mom-output {
    height: auto !important; max-height: none !important; min-height: 0 !important;
    overflow: visible !important;
  }
  html, body { background: #fff !important; }
  body, #appRoot, .mom-output { display: block !important; }  /* NOT .view — keep [hidden] working */
  .mom-output { border: 0 !important; padding: 0 !important; margin: 0 !important; }
  .mom-doc, .mom-doc-wide { max-width: 100% !important; margin: 0 !important; }

  /* Hide app chrome and interactive-only bits. */
  .topbar, .tabs, .toolbar, .drawer, .modal, .toast,
  .mom-upd-btn, .mom-table .btn, .mom-output .edit-only { display: none !important; }

  /* Make backgrounds/badge colors actually render on paper. */
  * { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }
  a { color: inherit !important; text-decoration: none !important; }

  /* Table: compact, wrap inside cells, repeat the header each page, keep rows intact. */
  .mom-table { font-size: 9.5px; width: 100% !important; table-layout: fixed; }
  .mom-table th, .mom-table td { padding: 4px 6px; overflow-wrap: anywhere; word-break: break-word; }
  .mom-table thead { display: table-header-group; }
  .mom-table thead th { white-space: normal !important; }
  .mom-table td.mom-task { min-width: 0 !important; }
  .mom-table tr { break-inside: avoid; page-break-inside: avoid; }
  .mom-cat-row td { position: static !important; }   /* sticky misbehaves in print */
  .mom-table img { max-width: 100% !important; height: auto !important; max-height: 60px; }
  /* Dates cell: allow it to wrap so "26 Jul 2026 → 01 Sep 2026" stays inside the column. */
  .mom-table .mom-dates-cell { white-space: normal !important; font-size: 9px; }
  /* Status badge: force a single line (never split "Progress"); small enough to fit the column. */
  .mom-table .badge { white-space: nowrap !important; font-size: 8px; padding: 1px 5px; letter-spacing: 0; }

  .mom-doc h1 { font-size: 18px; }
  .mom-subject, .mom-note { break-inside: avoid; }
}

/* ============ AUTH SCREEN ============ */
.auth-screen { position: fixed; inset: 0; display: grid; place-items: center; background: var(--bg); z-index: 100; padding: 20px; }
.auth-card { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); padding: 30px; width: min(380px, 94vw); }
.auth-logo { width: 48px; height: 48px; display: grid; place-items: center; background: var(--brand); color: #fff; border-radius: 12px; font-size: 24px; margin: 0 auto 14px; }
.auth-card h1 { font-size: 20px; text-align: center; }
.auth-card .muted { text-align: center; margin: 4px 0 18px; font-size: 13px; }
.auth-card .field { margin-bottom: 14px; }
.auth-card .field input { padding: 10px 12px; }
.btn.block { width: 100%; padding: 11px; justify-content: center; }
.auth-error { background: #fdecec; color: var(--overdue); border: 1px solid #f3c0c0; border-radius: 8px; padding: 8px 10px; font-size: 12px; margin-bottom: 12px; }
.muted { color: var(--muted); }

/* ============ TOPBAR additions ============ */
.top-center { display: flex; align-items: center; gap: 8px; }
.proj-switch { display: flex; align-items: center; gap: 8px; font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.proj-switch select { font: inherit; font-size: 14px; font-weight: 600; color: var(--ink); text-transform: none; letter-spacing: 0; padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); min-width: 160px; }
.user-menu { display: flex; align-items: center; gap: 10px; }
.user-badge { display: flex; align-items: center; gap: 6px; font-weight: 600; font-size: 13px; }
.role-tag { font-size: 9px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; color: #fff; background: var(--muted); border-radius: 20px; padding: 1px 7px; }
.role-tag.admin { background: var(--brand); }
.role-tag.user { background: var(--muted); }
.role-tag:empty { display: none; }

/* account button: Change password and Log out live in its menu */
.account { position: relative; }
.account-btn { display: flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); border-radius: 8px; padding: 5px 10px; font-weight: 600; font-size: 13px; }
.account-btn:hover, .account-btn[aria-expanded="true"] { border-color: #c7d0e0; }
.account-btn svg { width: 16px; height: 16px; color: var(--muted); flex: none; }
.account-btn .caret { color: var(--muted); font-size: 10px; }
.account-menu { position: absolute; right: 0; top: calc(100% + 6px); z-index: 60; min-width: 180px; display: flex; flex-direction: column; padding: 6px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); }
.account-menu button { border: 0; background: none; text-align: left; padding: 8px 10px; border-radius: 6px; font-size: 13px; color: var(--ink); white-space: nowrap; }
.account-menu button:hover, .account-menu button:focus-visible { background: var(--bg); outline: none; }

/* ============ CATEGORIES tab ============ */
.panel-card { flex: 1; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: auto; min-height: 0; }
.cat-add { display: flex; gap: 8px; }
.cat-add input { min-width: 260px; }
.cat-row { display: flex; align-items: center; justify-content: space-between; padding: 12px 18px; border-bottom: 1px solid var(--line); }
.cat-row:last-child { border-bottom: 0; }
.cat-row-name { font-weight: 600; }
.cat-row-actions { display: flex; gap: 6px; }

/* ============ ADMIN ============ */
.admin-tabs { display: flex; gap: 4px; margin-bottom: 14px; flex-shrink: 0; }
.atab { border: 1px solid var(--line); background: var(--panel); padding: 8px 16px; border-radius: 8px; font-weight: 600; font-size: 13px; color: var(--muted); }
.atab.active { background: var(--brand); color: #fff; border-color: var(--brand); }
.atab[hidden] { display: none; }   /* non-admins only get the Categories pane */
.admin-pane { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.tbl { width: 100%; }
.tbl-head, .tbl-row { display: grid; grid-template-columns: 2fr 1fr 1fr auto; gap: 10px; align-items: center; padding: 10px 18px; }
.tbl-head { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 700; border-bottom: 2px solid var(--line); }
.tbl-row { border-bottom: 1px solid var(--line); }
.tbl-row:last-child { border-bottom: 0; }
.tbl-actions { display: flex; gap: 6px; justify-content: flex-end; }
.check-list { display: flex; flex-direction: column; gap: 6px; max-height: 180px; overflow: auto; border: 1px solid var(--line); border-radius: 8px; padding: 10px; font-weight: 400; color: var(--ink); }
.check { display: flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; }
.check input { width: auto; }

/* ============ password preview toggle ============ */
.pw-wrap { position: relative; display: flex; align-items: center; }
.pw-wrap input { flex: 1; padding-right: 58px; width: 100%; }
.pw-toggle {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  border: 0; background: transparent; color: var(--brand); font-weight: 700; font-size: 12px;
  padding: 4px 6px; border-radius: 6px; cursor: pointer;
}
.pw-toggle:hover { background: #eef2ff; }

/* ============ Minutes table ============ */
.mom-doc-wide { max-width: 100%; }
.mom-banner { border-radius: 8px; padding: 10px 14px; font-weight: 600; font-size: 13px; margin: 12px 0 4px; }
.mom-banner.warn { background: #fdf0e3; color: #b45309; border: 1px solid #f4d8b0; }
.mom-banner.ok { background: #eafaf0; color: #15803d; border: 1px solid #bfe8cd; }
.mom-cat { margin-top: 22px; }
.mom-cat h3 { font-size: 14px; margin-bottom: 8px; color: var(--brand); }
.mom-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.mom-table th, .mom-table td { border: 1px solid var(--line); padding: 8px 10px; text-align: left; vertical-align: top; }
.mom-table thead th { background: #f0f3fa; font-size: 11px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); white-space: normal; }
.mom-table td.mom-task { font-weight: 600; min-width: 150px; }
.mom-dates-cell { white-space: normal; }
.mom-target { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.mom-u { margin: 2px 0; line-height: 1.4; }
.mom-u + .mom-u { border-top: 1px dashed var(--line); padding-top: 4px; }
.mom-u-date { font-size: 11px; font-weight: 700; color: var(--muted); }
.mom-events-row { margin-bottom: 4px; display: flex; flex-wrap: wrap; gap: 4px; }
.ev-tag { font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 10px; background: #eef2ff; color: var(--brand); }
.ev-tag.ev-completed { background: #eafaf0; color: #15803d; }
.ev-tag.ev-hold { background: #fdf0e3; color: #b45309; }
tr.mom-missing td { background: #fdf0e3; }
.mom-missing-tag { color: var(--overdue); font-weight: 700; font-size: 12px; }
.mom-table .file-chip { font-size: 11px; padding: 2px 7px; }
.mom-table img { max-height: 70px; border-radius: 5px; border: 1px solid var(--line); margin-top: 4px; }

/* ============ Minutes: single aligned table ============ */
.mom-table { table-layout: fixed; }
.mom-table td { word-wrap: break-word; overflow-wrap: anywhere; }
.mom-cat-row td {
  background: #e9edf7; font-weight: 700; font-size: 12px; color: var(--brand);
  text-transform: uppercase; letter-spacing: .03em; position: sticky; left: 0;
}
.mom-task a { color: var(--ink); text-decoration: none; font-weight: 600; border-bottom: 1px dashed var(--muted); cursor: pointer; }
.mom-task a:hover { color: var(--brand); border-bottom-color: var(--brand); }
.mom-upd-btn { margin-top: 6px; display: inline-block; }
tr.mom-missing:hover td { background: #fbe4c9; }

/* ============ Done (late) status ============ */
.bar.s-done_late { background: var(--done_late); }
.badge.s-done_late { background: var(--done_late); }
.dot.s-done_late { background: var(--done_late); }

/* ============ Dashboard ============ */
.dash { flex: 1; overflow: auto; min-height: 0; }
.dash-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 14px; }
.dash-head h1 { font-size: 20px; }
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; border-top: 3px solid var(--line); }
.kpi-val { font-size: 26px; font-weight: 800; line-height: 1.1; }
.kpi-lbl { font-size: 12px; color: var(--muted); margin-top: 4px; font-weight: 600; }
.kpi-sub { font-size: 11px; color: var(--muted); margin-top: 4px; }
.kpi.k-in_progress { border-top-color: var(--in_progress); }
.kpi.k-overdue { border-top-color: var(--overdue); }
.kpi.k-hold { border-top-color: var(--hold); }
.kpi.k-done { border-top-color: var(--done); }
.kpi.k-done_late { border-top-color: var(--done_late); }
.kpi.k-rate { border-top-color: var(--brand); background: #f6f8ff; }
.kpi.k-rate .kpi-val { color: var(--brand); }

.dash-section { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; margin-top: 16px; }
.dash-section-title { font-size: 13px; font-weight: 700; margin-bottom: 12px; }
.dash-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 900px) { .dash-cols { grid-template-columns: 1fr; } }

.dist { display: flex; height: 22px; border-radius: 6px; overflow: hidden; border: 1px solid var(--line); }
.dist.empty-dist { display: block; text-align: center; color: var(--muted); font-size: 12px; line-height: 22px; }
.dist-seg { height: 100%; }
.dist-seg.s-in_progress { background: var(--in_progress); }
.dist-seg.s-overdue { background: var(--overdue); }
.dist-seg.s-hold { background: var(--hold); }
.dist-seg.s-done { background: var(--done); }
.dist-seg.s-done_late { background: var(--done_late); }
.dist-legend { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 10px; font-size: 12px; color: var(--muted); }
.dist-legend span { display: inline-flex; align-items: center; }

.stat-table td { text-align: center; }
.stat-table td.mom-task { text-align: left; }
.stat-table th:first-child { text-align: left; }
.cell-good { color: #15803d; font-weight: 700; }
.cell-late { color: var(--done_late); font-weight: 700; }
.cell-bad { color: var(--overdue); font-weight: 700; }
.rate-cell { display: flex; align-items: center; gap: 8px; justify-content: center; }
.meter { width: 60px; height: 7px; background: #eceff5; border-radius: 4px; overflow: hidden; }
.meter-fill { height: 100%; background: var(--done); }

/* ============ Notes tab ============ */
.note-group { border-bottom: 1px solid var(--line); }
.note-group:last-child { border-bottom: 0; }
.note-group-head { background: #eef1f8; font-weight: 700; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--brand); padding: 7px 16px; }
.note-card { padding: 12px 16px; border-bottom: 1px solid var(--line); }
.note-card:last-child { border-bottom: 0; }
.note-card.note-closed { opacity: .62; }
.note-head { display: flex; align-items: center; gap: 8px; }
.note-title { font-weight: 600; flex: 1; }
.note-actions { display: flex; gap: 6px; }
.note-detail { margin: 6px 0; line-height: 1.5; }
.note-meta { font-size: 12px; color: var(--muted); }
.note-status-closed { font-size: 10px; font-weight: 700; text-transform: uppercase; color: var(--muted); border: 1px solid var(--line); border-radius: 10px; padding: 1px 7px; }
/* note-type badges */
.badge.note-t-decision { background: #7c3aed; }
.badge.note-t-regulation { background: #b45309; }
.badge.note-t-info { background: #0ea5e9; }
.badge.note-t-followup { background: #db2777; }

/* Admin user table gets extra Name and Title columns */
.tbl-users .tbl-head, .tbl-users .tbl-row { grid-template-columns: 1.3fr 1.3fr 1fr 0.9fr 1.4fr auto; }

/* ============ Minutes: attendees + notes sections ============ */
.mom-attendees { background: #f6f8ff; border: 1px solid #dbe3ff; border-radius: 10px; padding: 12px 16px; margin: 14px 0; }
.mom-att-head { font-weight: 700; font-size: 13px; margin-bottom: 6px; }
.att-row { font-size: 13px; margin: 2px 0; }
.att-title { display: inline-block; min-width: 130px; font-weight: 700; color: var(--muted); }
.mom-notes-section { margin-top: 24px; }
.mom-section-h { font-size: 18px; border-top: 2px solid var(--line); padding-top: 14px; }
.mom-note-cat h4 { font-size: 13px; color: var(--brand); margin: 14px 0 6px; }
.mom-note { border-left: 3px solid var(--line); padding: 4px 0 4px 12px; margin: 8px 0; }
.mom-note-detail { margin: 4px 0; line-height: 1.5; }
.mom-note-meta { font-size: 12px; color: var(--muted); }
/* notes linked to a task sit in their own row right under that task */
.mom-linked-notes td { padding-top: 0; border-top: none; }
.mom-linked-notes .mom-note { margin: 2px 0 6px; }
.mom-note-label { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin-right: 6px; }
.note-tasks { font-size: 12px; color: var(--muted); margin-top: 4px; }
.note-tasks .cat-chip { margin: 0 4px 0 0; }
.access-tag { font-size: 11px; color: var(--muted); }
/* account modal: one project per row, its View/Edit choice beside the name */
.proj-access { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.proj-access select { width: auto; padding: 3px 6px; font-size: 12px; }
.proj-access select:disabled { opacity: .45; }
.access-tag.view { color: var(--overdue); font-weight: 600; }
/* view-only accounts: hide every control that would change data */
body.read-only .edit-only { display: none !important; }


/* ============ note-week toggle ============ */
.note-week { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--muted); font-weight: 600; cursor: pointer; margin-right: 4px; }
.note-week input { width: auto; }

/* ---------- right-click menu (chart rows + category headers) ---------- */
.ctx-menu {
  position: fixed; z-index: 300; min-width: 190px; padding: 5px;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 8px; box-shadow: var(--shadow);
}
.ctx-item {
  display: block; width: 100%; text-align: left; border: 0; background: none;
  padding: 7px 10px; border-radius: 6px; font-size: 13px; color: var(--ink); line-height: 1.3;
}
.ctx-item:hover { background: var(--bg); }
.ctx-item.danger { color: var(--overdue); }
.ctx-item.danger:hover { background: #fdecec; }
.ctx-sep { height: 1px; margin: 5px 4px; background: var(--line); }

/* ============ formatted text (updates, note details, descriptions) ============ */
.rt { overflow-wrap: anywhere; }
.rt ul, .rt ol { margin: 3px 0; padding-left: 20px; }
.rt li { margin: 1px 0; }
.rt p { margin: 0; }
.rt mark { background: #fff1a8; color: inherit; padding: 0 2px; border-radius: 2px; }
.subj-desc { color: var(--muted); margin: 8px 0; line-height: 1.5; }
.rt-editor { border: 1px solid var(--line); border-radius: 8px; background: var(--panel); font-weight: 400; color: var(--ink); }
.rt-editor:focus-within { border-color: var(--in_progress); }
.rt-toolbar { display: flex; flex-wrap: wrap; gap: 2px; padding: 3px; border-bottom: 1px solid var(--line); background: var(--bg); border-radius: 8px 8px 0 0; }
.rt-toolbar button { border: 0; background: none; min-width: 28px; height: 26px; padding: 0 6px; border-radius: 6px; font-size: 12px; color: var(--ink); cursor: pointer; }
.rt-toolbar button:hover { background: #e4e9f4; }
.rt-toolbar mark { background: #fff1a8; padding: 0 3px; }
.rt-area { min-height: 64px; max-height: 280px; overflow: auto; padding: 8px 10px; outline: none; line-height: 1.5; font-size: 13px; }
.rt-area:empty::before { content: attr(data-placeholder); color: var(--muted); pointer-events: none; }
.update-form .rt-editor, .update.editing .rt-editor { margin-bottom: 2px; }

/* ============ Hide done / attendees dialog ============ */
.att-tools { display: flex; gap: 8px; margin-bottom: 8px; }
.att-tools input { flex: 1; }
.guest-list { display: flex; flex-direction: column; gap: 4px; }
.guest-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 13px; font-weight: 400; color: var(--ink); border: 1px solid var(--line); border-radius: 8px; padding: 4px 4px 4px 10px; }
.guest-add { display: grid; grid-template-columns: 1fr 1fr auto; gap: 6px; margin-top: 6px; }
.mom-att-head { display: flex; align-items: center; gap: 10px; }
.mom-att-edit { padding: 2px 8px; font-size: 11px; }
.mom-attendees.empty-att { background: #fafbfd; border-style: dashed; }

/* ============ Dashboard: outstanding by person ============ */
#view-dashboard .admin-tabs { margin-bottom: 4px; }
#outstanding .toolbar { margin: 10px 0 0; }
.out-head { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.out-name { font-size: 15px; font-weight: 700; margin-right: 4px; }
.out-chip { font-size: 11px; font-weight: 700; border-radius: 20px; padding: 2px 9px; border: 1px solid var(--line); background: var(--bg); }
.out-chip.k-overdue { color: var(--overdue); border-color: #f3c0c0; background: #fdecec; }
.out-chip.k-in_progress { color: var(--in_progress); }
.out-chip.k-hold { color: #b45309; }
.out-chip.k-followup { color: #db2777; }
.out-table td:nth-child(n+2) { white-space: nowrap; }
.out-table td.mom-task a { color: var(--ink); text-decoration: none; border-bottom: 1px dashed var(--muted); }
.out-table td.mom-task a:hover { color: var(--brand); border-bottom-color: var(--brand); }
.out-stale { font-size: 10px; font-weight: 700; color: #b45309; background: #fdf0e3; border-radius: 10px; padding: 1px 6px; margin-left: 4px; }

@media print {
  .mom-attendees { break-inside: avoid; }
  .mom-att-edit { display: none !important; }
  .rt mark { background: #fff1a8 !important; }
}

/* ============ BOD flag, upcoming / done items on the dashboard ============ */
.bod-tag {
  display: inline-block; padding: 0 5px; margin-right: 4px; border-radius: 4px; font-size: 9px; font-weight: 800;
  letter-spacing: .04em; color: #fff; background: #0f766e; vertical-align: 1px;
}
.btn.bod-on { background: #0f766e; border-color: #0f766e; color: #fff; }
.bod-field { margin: 0 0 12px; }
.badge.s-upcoming { background: #64748b; }
.out-chip.k-upcoming { color: #64748b; }
.out-chip.k-done { color: var(--done); }
.out-table tr.out-done td { color: var(--muted); }
@media print { .bod-tag { background: none; color: #0f766e; border: 1px solid #0f766e; } }
.out-proj-row td { background: #1e293b; color: #fff; font-weight: 700; font-size: 12.5px; padding: 6px 10px; }
.pic-filter { padding: 5px 8px; border: 1px solid var(--line); border-radius: 8px; font: inherit; font-size: 13px; background: #fff; max-width: 180px; }
/* Status filter: a button that opens a small panel of checkboxes */
.filter-dd { position: relative; }
.filter-dd > summary {
  list-style: none; cursor: pointer; user-select: none; padding: 6px 12px; border: 1px solid var(--line);
  border-radius: 8px; background: #fff; font-size: 13px; font-weight: 600; white-space: nowrap;
}
.filter-dd > summary::-webkit-details-marker { display: none; }
.filter-dd > summary::after { content: ' ▾'; color: var(--muted); }
.filter-dd[open] > summary { border-color: var(--brand); }
.filter-dd .dd-count { color: var(--brand); }
.dd-panel {
  position: absolute; top: calc(100% + 4px); left: 0; z-index: 50; min-width: 170px; display: flex; flex-direction: column;
  gap: 8px; padding: 10px 12px; background: #fff; border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, .12);
}
