/* CSWMP PMS — app shell styles. Reuses the login page's ocean identity.
 * Every color is a CSS variable so the whole UI themes from :root (light) and
 * html[data-theme="dark"]. Light values below are pixel-identical to before.
 * "Series" hexes used by charts / workload bars stay literal per DASHBOARD_SPEC. */
:root {
  --page: #f4f8fc;
  --surface: #fff;
  --surface-2: #fbfdff;
  --surface-3: #eef3f8;
  --line: #d7e2ee;
  --line-strong: #c3d2e0;

  --ink: #1a2733;
  --muted: #5c6b7a;
  --label: #33424f;
  --disabled: #9aa7b4;

  --blue: #185FA5;          /* solid brand fill (buttons, active nav/chip) */
  --blue-dark: #0C447C;     /* headings */
  --blue-hover: #134e89;
  --btn-press: #0C447C;
  --brand-text: #185FA5;    /* links + text on blue tint + hover accents */
  --accent: #378ADD;
  --accent-light: #85B7EB;
  --on-fill: #fff;          /* text on a solid brand/accent/danger fill */
  --wash: #E6F1FB;          /* hover bg + accent tint */
  --wash-strong: #dcecfb;
  --blue-bg: #e4eefb;       /* blue badge tint */
  --focus-ring: rgba(24, 95, 165, 0.15);

  --ok: #1f9d55;  --ok-bg: #e5f6ec;  --ok-strong: #146c3a;  --ok-border: #bfe6cd;
  --amber: #b8860b;  --amber-bg: #fdf3dd;  --amber-border: #ecd9a3;
  --red: #b3261e;  --red-bg: #fdeaea;  --red-hover: #8f1e17;  --red-border: #f0b4b4;
  --danger-solid: #b3261e;  /* solid red fill (nav badge, danger button) */
  --gray: #6b7885;  --gray-bg: #eef2f6;
  --archived-bg: #eceff2;  --archived-text: #93a0ac;
  --info-border: #bcd8f2;

  --radius: 8px;
  --shadow: 0 1px 3px rgba(12, 68, 124, 0.08), 0 1px 2px rgba(12, 68, 124, 0.06);
}

html[data-theme="dark"] {
  --page: #0C141D;
  --surface: #141E2A;
  --surface-2: #172230;
  --surface-3: #0e1822;
  --line: #24303E;
  --line-strong: #2E3B4B;

  --ink: #E8EEF5;
  --muted: #A6B4C4;
  --label: #E8EEF5;
  --disabled: #5b6a7b;

  --blue: #4E97E0;
  --blue-dark: #E8EEF5;
  --blue-hover: #5aa0e6;
  --btn-press: #3577b8;
  --brand-text: #7FB6EC;
  --accent: #4E97E0;
  --accent-light: #3a6d99;
  --on-fill: #fff;
  --wash: #12293F;
  --wash-strong: #163449;
  --blue-bg: #12293F;
  --focus-ring: rgba(78, 151, 224, 0.30);

  --ok: #6FBF8A;  --ok-bg: #15301F;  --ok-strong: #6FBF8A;  --ok-border: #1e3d29;
  --amber: #E4B65C;  --amber-bg: #37290F;  --amber-border: #49370f;
  --red: #F08A84;  --red-bg: #3A1D1C;  --red-hover: #c0655f;  --red-border: #4d2624;
  --danger-solid: #C0453C;
  --gray: #7C8B9C;  --gray-bg: #1C2836;
  --archived-bg: #263341;  --archived-text: #8a98a8;
  --info-border: #1c3a52;

  --shadow: 0 1px 3px rgba(0, 0, 0, 0.45), 0 1px 2px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: 'Public Sans', 'Segoe UI', Helvetica, Arial, sans-serif;
  background: var(--page);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.5;
}
a { color: var(--brand-text); text-decoration: none; }
a:hover { color: var(--blue-dark); text-decoration: underline; }

/* ---- shell ---- */
.app-shell { display: flex; flex-direction: column; min-height: 100vh; }

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap; row-gap: 6px;
  min-height: 56px; padding: 6px 20px; box-sizing: border-box;
  background: var(--surface); border-bottom: 1px solid var(--line);
}
.topbar .brand { display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--blue-dark); letter-spacing: 0.02em; text-decoration: none; }
.topbar a.brand:hover { color: var(--brand-text); text-decoration: none; }
.topbar .brand .logo {
  width: 30px; height: 30px; border-radius: 8px; background: var(--blue);
  display: flex; align-items: center; justify-content: center; flex: 0 0 auto;
}
.topbar .spacer { flex: 1; }
.topbar .user-box { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.2; }
.topbar .user-box .name { font-weight: 600; font-size: 13px; max-width: 200px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .user-box .role { font-size: 11.5px; color: var(--muted); text-transform: capitalize; }

.pills { display: flex; gap: 6px; }
.cswmp-pill {
  min-width: 38px; height: 26px; padding: 0 9px; border-radius: 999px;
  font: 600 12px/1 inherit; letter-spacing: 0.04em; cursor: pointer;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--muted);
}
.cswmp-pill.active,
html[data-lang="uz"] .cswmp-pill[data-lang="uz"],
html[data-lang="ru"] .cswmp-pill[data-lang="ru"],
html[data-lang="en"] .cswmp-pill[data-lang="en"],
html[data-lang="zh"] .cswmp-pill[data-lang="zh"] { border-color: var(--blue); background: var(--blue); color: var(--on-fill); }
/* ZH chosen on a page without a ZH pill: the chrome is English, so EN shows active (own rule: :has) */
html[data-lang="zh"]:not(:has(.cswmp-pill[data-lang="zh"])) .cswmp-pill[data-lang="en"] { border-color: var(--blue); background: var(--blue); color: var(--on-fill); }
/* theme icons from html[data-theme] (theme.js keeps them in step afterwards) */
.theme-toggle .icon-sun { display: none; }
html[data-theme="dark"] .theme-toggle .icon-sun { display: inline; }
html[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
/* translatable labels stay invisible until the dictionary has been applied */
html[data-i18n-pending] [data-i18n], html[data-i18n-pending] [data-tr] { visibility: hidden; }

/* theme toggle button */
.theme-toggle { display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border: 1px solid var(--line-strong); border-radius: 8px;
  background: var(--surface); color: var(--muted); cursor: pointer; flex: 0 0 auto; }
.theme-toggle:hover { background: var(--wash); color: var(--brand-text); }

.layout { display: flex; flex: 1; align-items: stretch; }
.sidebar {
  width: 220px; flex: 0 0 220px; background: var(--surface);
  border-right: 1px solid var(--line); padding: 16px 12px;
  display: flex; flex-direction: column;
}
.sidebar .nav-item.nav-bottom { margin-top: auto; }
.sidebar .nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: var(--radius); color: var(--ink);
  font-weight: 500; margin-bottom: 4px;
}
.sidebar .nav-item:hover { background: var(--wash); text-decoration: none; }
.sidebar .nav-item.active { background: var(--blue); color: var(--on-fill); }
.sidebar .nav-item.active .nav-icon { color: var(--on-fill); }
.sidebar .nav-item .nav-icon { color: var(--accent); display: flex; }
.sidebar .nav-item.disabled { color: var(--disabled); cursor: not-allowed; }
.sidebar .nav-item.disabled:hover { background: transparent; }
.sidebar .soon {
  margin-left: auto; font-size: 10px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.05em; color: var(--muted); background: var(--gray-bg);
  padding: 2px 6px; border-radius: 999px;
}
.sidebar .nav-badge {
  margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px;
  border-radius: 999px; background: var(--danger-solid); color: var(--on-fill);
  font-size: 11px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center;
}

.content { flex: 1; padding: 24px 28px; min-width: 0; }
.page-head { display: flex; align-items: center; gap: 12px; margin: 0 0 18px; }
.page-head h1 { margin: 0; font-size: 22px; font-weight: 700; color: var(--blue-dark); }
.page-head .spacer { flex: 1; }

/* ---- cards ---- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 18px 20px; }
.stat-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 22px; }
.stat-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.stat-card .num { font-size: 28px; font-weight: 700; color: var(--blue-dark); line-height: 1.1; }
.stat-card .num.alert { color: var(--red); }
.stat-card .label { font-size: 12.5px; color: var(--muted); margin-top: 4px; }

/* ---- tables ---- */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
table.data { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.data th, table.data td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.data th { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.03em; background: var(--surface-2); }
table.data tr:last-child td { border-bottom: none; }
table.data tbody tr:hover { background: var(--wash); }

/* ---- badges ---- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge.status-draft { background: var(--gray-bg); color: var(--gray); }
.badge.status-under_review { background: var(--amber-bg); color: var(--amber); }
.badge.status-approved { background: var(--ok-bg); color: var(--ok); }
.badge.status-archived { background: var(--archived-bg); color: var(--archived-text); }
.badge.prio-high { background: var(--red-bg); color: var(--red); }
.badge.prio-medium { background: var(--amber-bg); color: var(--amber); }
.badge.prio-low { background: var(--gray-bg); color: var(--gray); }

/* ---- deadline chips ---- */
.deadline { display: inline-flex; align-items: center; gap: 5px; font-weight: 600; }
.deadline.ok { color: var(--ok); }
.deadline.soon { color: var(--amber); }
.deadline.overdue { color: var(--red); }

/* ---- buttons ---- */
.btn {
  display: inline-flex; align-items: center; gap: 7px; height: 38px; padding: 0 16px;
  border: none; border-radius: var(--radius); background: var(--blue); color: var(--on-fill);
  font: 600 14px/1 inherit; cursor: pointer; text-decoration: none;
}
.btn:hover { background: var(--blue-hover); color: var(--on-fill); text-decoration: none; }
.btn:active { background: var(--btn-press); }
.btn.outline { background: var(--surface); color: var(--blue); border: 1px solid var(--line-strong); }
.btn.outline:hover { background: var(--wash); color: var(--blue-dark); }
.btn.small { height: 32px; padding: 0 12px; font-size: 13px; }
.btn.danger { background: var(--danger-solid); }
.btn.danger:hover { background: var(--red-hover); }
.btn.ghost { background: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--gray-bg); color: var(--ink); }

.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; border: none; background: transparent; border-radius: 6px; color: var(--muted); cursor: pointer; }
.icon-btn:hover { background: var(--wash); color: var(--brand-text); }

/* ---- forms ---- */
label.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: var(--label); }
.input, select.input, textarea.input {
  height: 40px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: 6px;
  font: 400 14px/1 inherit; color: var(--ink); background: var(--surface); outline: none; width: 100%;
}
textarea.input { height: auto; padding: 10px 12px; resize: vertical; }
.input:focus, select.input:focus, textarea.input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px var(--focus-ring); }

/* ---- filters bar ---- */
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 16px; }
.filters .input { height: 36px; width: auto; min-width: 140px; }
.filters .search { min-width: 220px; }

/* ---- empty states ---- */
.empty { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty .icon { color: var(--accent-light); margin-bottom: 12px; }
.empty h3 { margin: 0 0 6px; color: var(--ink); font-size: 16px; }
.empty p { margin: 0; font-size: 13.5px; }

/* ---- toasts / messages ---- */
.toasts { position: fixed; top: 68px; right: 20px; z-index: 60; display: flex; flex-direction: column; gap: 10px; max-width: 360px; }
.toast { padding: 12px 16px; border-radius: var(--radius); box-shadow: var(--shadow); font-size: 13.5px; border: 1px solid; background: var(--surface); }
.toast.success { border-color: var(--ok-border); background: var(--ok-bg); color: var(--ok-strong); }
.toast.error, .toast.danger { border-color: var(--red-border); background: var(--red-bg); color: var(--red); }
.toast.warning { border-color: var(--amber-border); background: var(--amber-bg); color: var(--amber); }
.toast.info { border-color: var(--info-border); background: var(--wash); color: var(--blue-dark); }

/* ---- breadcrumbs ---- */
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); margin-bottom: 14px; }
.crumbs a { color: var(--muted); }
.crumbs a:hover { color: var(--brand-text); }
.crumbs .sep { color: var(--line-strong); }
.crumbs .current { color: var(--ink); font-weight: 600; }

/* ---- error pages ---- */
.errpage { max-width: 460px; margin: 80px auto; text-align: center; }
.errpage .code { font-size: 56px; font-weight: 800; color: var(--accent-light); }
.errpage h1 { color: var(--blue-dark); margin: 6px 0 10px; }

@media (max-width: 780px) {
  .sidebar { width: 64px; flex-basis: 64px; }
  .sidebar .nav-item span.label, .sidebar .soon { display: none; }
  .content { padding: 18px 14px; }
}

/* ---- documents: tree + layout ---- */
.doc-layout { display: grid; grid-template-columns: 250px 1fr; gap: 18px; align-items: start; }
.folder-tree { padding: 12px; max-height: 72vh; overflow: auto; }
.tree, .tree ul { list-style: none; margin: 0; padding: 0; }
.tree li { margin: 1px 0; }
.tree details > ul { padding-left: 14px; }
.tree summary { list-style: none; cursor: pointer; }
.tree summary::-webkit-details-marker { display: none; }
.tree-row { display: flex; align-items: center; gap: 6px; padding: 6px 8px; border-radius: 6px; }
.tree-row:hover { background: var(--wash); }
.tree-row.active { background: var(--blue); }
.tree-row.active .tree-link, .tree-row.active .tree-count { color: var(--on-fill); }
.tree-row.active .tree-count { background: rgba(255,255,255,0.22); }
.tree-link { flex: 1; color: var(--ink); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tree-link:hover { text-decoration: none; color: var(--brand-text); }
.tree-count { font-size: 11px; color: var(--muted); background: var(--gray-bg); border-radius: 999px; padding: 1px 7px; }
.pager { display: flex; align-items: center; gap: 12px; justify-content: center; margin-top: 14px; }
.pager-info { font-size: 13px; color: var(--muted); }

/* ---- document detail ---- */
.detail-grid { display: grid; grid-template-columns: 1fr 320px; gap: 18px; align-items: start; }
.detail-main { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.detail-side { display: flex; flex-direction: column; gap: 14px; }
.card-title { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); font-weight: 600; color: var(--blue-dark); }
.preview-card { padding: 0; overflow: hidden; }
.preview-card embed, .preview-card img { display: block; width: 100%; height: 520px; border: 0; background: var(--surface-3); }
.preview-card img { object-fit: contain; }
.preview-note { color: var(--muted); font-size: 13.5px; }
.meta dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 8px 14px; font-size: 13px; }
.meta dt { color: var(--muted); }
.meta dd { margin: 0; color: var(--ink); }
.actions form { margin: 0 0 12px; display: flex; flex-direction: column; gap: 8px; }
.actions form:last-child { margin-bottom: 0; }
.actions .row { display: flex; gap: 8px; }

/* ---- upload form ---- */
.upload-form { max-width: 640px; display: flex; flex-direction: column; gap: 14px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.dropzone { position: relative; border: 2px dashed var(--line-strong); border-radius: 8px; padding: 26px; text-align: center; color: var(--muted); background: var(--wash); }
.dropzone.drag { border-color: var(--blue); background: var(--wash-strong); }
.dropzone input[type=file] { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.dz-file { display: block; margin-top: 8px; font-weight: 600; color: var(--blue-dark); }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; }

@media (max-width: 900px) {
  .doc-layout { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
  .grid2 { grid-template-columns: 1fr; }
}

/* ---- tasks: task status badges ---- */
.badge.tstatus-new { background: var(--blue-bg); color: var(--blue-dark); border: 1px dashed var(--blue); }
.badge.tstatus-todo { background: var(--gray-bg); color: var(--gray); }
.badge.tstatus-in_progress { background: var(--blue-bg); color: var(--brand-text); }
.badge.tstatus-review { background: var(--amber-bg); color: var(--amber); }
.badge.tstatus-done { background: var(--ok-bg); color: var(--ok); }
.badge.tstatus-closed { background: var(--gray-bg); color: var(--gray); border: 1px solid var(--line-strong); }
.badge.verif-pending { background: var(--amber-bg); color: var(--amber); border: 1px dashed var(--amber); }
.btn[disabled] { opacity: .55; cursor: not-allowed; }

/* ---- Manager decision card ---- */
.decision-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 10px; padding-top: 10px; }
.decision-tile { display: flex; flex-direction: column; gap: 4px; padding: 12px 14px; border: 1px solid var(--line-strong); border-radius: var(--radius); cursor: pointer; background: var(--surface); }
.decision-tile input { position: absolute; opacity: 0; pointer-events: none; }
.decision-tile:hover { background: var(--wash); }
.decision-tile.selected { border-color: var(--blue); background: var(--wash-strong, var(--wash)); box-shadow: 0 0 0 1px var(--blue) inset; }
.decision-tile.disabled { opacity: .5; cursor: not-allowed; }
.decision-tile .dt-title { font-weight: 600; color: var(--ink); }
.decision-tile .dt-sub { font-size: 12px; color: var(--muted); }
.decision-panels { padding-top: 12px; }
.decision-form { display: flex; flex-direction: column; gap: 10px; max-width: 560px; }
.decision-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.decision-strip { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding-top: 10px; }
.decision-strip .ds-text { font-size: 13px; }
.field-error { display: block; margin-top: 4px; font-size: 12.5px; color: var(--danger-solid); }

/* ---- consultant verification queue ---- */
.btn.success { background: var(--ok, #1d9a4f); border-color: var(--ok, #1d9a4f); color: var(--on-fill); }
.btn.success:hover { filter: brightness(1.08); }
.btn.outline-danger { background: transparent; border: 1px solid var(--danger-solid); color: var(--danger-solid); }
.btn.outline-danger:hover { background: var(--wash); }
.vcards { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; padding-top: 10px; }
.vcard { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; background: var(--surface); display: flex; flex-direction: column; gap: 8px; }
.vcard .vc-top { display: flex; align-items: center; gap: 8px; }
.vcard .vc-date { margin-left: auto; font-size: 12px; }
.vcard .vc-title { font-weight: 600; }
.vcard .vc-quote { margin: 0; padding: 8px 12px; border-left: 3px solid var(--line-strong); background: var(--wash); font-size: 13px; border-radius: 0 6px 6px 0; }
.vcard .vc-form { display: flex; flex-direction: column; gap: 8px; }
.vcard .vc-dropzone { padding: 14px; font-size: 12.5px; }
.vcard .vc-hint { font-size: 12px; }
.vcard .vc-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.file-chip { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; margin: 2px 4px 2px 0; border: 1px solid var(--line-strong); border-radius: 999px; font-size: 12px; background: var(--wash); }
.file-chip a { color: var(--danger-solid); text-decoration: none; }

/* ---- correspondence: direction + letter status badges ---- */
.badge.dir-incoming { background: var(--blue-bg); color: var(--brand-text); }
.badge.dir-outgoing { background: var(--gray-bg); color: var(--gray); }
.badge.lstatus-registered { background: var(--gray-bg); color: var(--gray); }
.badge.lstatus-pending_reply { background: var(--amber-bg); color: var(--amber); }
.badge.lstatus-replied { background: var(--blue-bg); color: var(--brand-text); }
.badge.lstatus-closed { background: var(--ok-bg); color: var(--ok); }

/* ---- dashboard (approved spec) ---- */
.dash { display: flex; flex-direction: column; gap: 12px; }
.dash-header { display: flex; align-items: center; justify-content: space-between; }
.dash-title { font-size: 16px; font-weight: 600; margin: 0; }
.period-chips { display: inline-flex; gap: 6px; }
.period-chips .chip { font-size: 11px; padding: 4px 12px; border: 1px solid var(--line);
  background: var(--surface); border-radius: 999px; color: var(--muted); cursor: pointer; }
.period-chips .chip.active { background: var(--wash); color: var(--brand-text); border-color: var(--brand-text); }

.dash-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.dstat { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; background: var(--surface);
  min-width: 0; overflow: hidden; }
.dstat-num { font-size: 22px; font-weight: 600; line-height: 1.1; }
.dstat-num.alert { color: #CC4B45; }  /* danger series hue (DASHBOARD_SPEC) */
.dstat-label { font-size: 11px; color: var(--muted); margin-top: 2px; }

.dash-charts { display: grid; grid-template-columns: 1.35fr 1fr 1.15fr; gap: 12px; }
/* calendar (compact) left, employee activity (wider rows) right */
.dash-bottom { display: grid; grid-template-columns: 1fr 1.4fr; gap: 12px; }

/* Task status summary (admin/manager top row) */
.sum-card { display: grid; grid-template-columns: 1fr auto; gap: 16px;
  align-items: stretch; }
.sum-main { min-width: 0; }
.sum-head { display: flex; align-items: baseline; justify-content: space-between; }
.sum-title { font-size: 13px; font-weight: 500; }
.sum-pct { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.sum-total { font-size: 26px; font-weight: 600; line-height: 1.1;
  margin: 4px 0 10px; }
.sum-bar { display: flex; gap: 2px; height: 9px; border-radius: 999px;
  overflow: hidden; background: var(--page); }
.sum-seg { height: 100%; min-width: 3px; }
.seg-done { background: #3F9C5F; }         /* chart series hues */
.seg-inprog { background: var(--accent); }
.seg-todo { background: var(--line-strong); }
.seg-over { background: var(--red); }
.sum-tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px;
  margin-top: 10px; }
.sum-tile { display: flex; align-items: center; gap: 6px; padding: 7px 9px;
  border: 1px solid var(--line); border-radius: 8px; font-size: 12px;
  color: var(--ink); text-decoration: none; min-width: 0; }
.sum-tile:hover { background: var(--wash); text-decoration: none; }
.sum-tile .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.sum-tile span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sum-tile b { margin-left: auto; font-variant-numeric: tabular-nums; }
.sum-tile.overdue, .sum-tile.overdue b { color: var(--red); }
.sum-docs { border-left: 1px solid var(--line); padding-left: 16px;
  min-width: 120px; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 3px; color: var(--muted); }
.sum-docs-num { font-size: 22px; font-weight: 600; color: var(--ink);
  line-height: 1.1; }
/* min-width:0 lets grid tracks shrink below a canvas's intrinsic size —
   without it Chart.js canvases force the row wider than the viewport. */
.dash-stats > *, .dash-charts > *, .dash-bottom > * { min-width: 0; }
.dcard { border: 1px solid var(--line); border-radius: 10px; padding: 12px; background: var(--surface);
  min-width: 0; overflow: hidden; }
.dcard-title { font-size: 13px; font-weight: 500; margin-bottom: 8px; }

.chart-wrap { position: relative; width: 100%; }
/* standalone height utilities so BOTH .chart-wrap and .donut-wrap get a
   definite height (Chart.js needs it with maintainAspectRatio:false). */
.h240 { height: 240px; }
.h220 { height: 220px; }
.chart-wrap canvas, .donut-wrap canvas { cursor: pointer; }

.chart-legend { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 6px; }
.chart-legend .lg { display: inline-flex; align-items: center; gap: 5px; font-size: 10px; color: var(--muted); }
.dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; flex: 0 0 auto; }

.donut-row { display: flex; align-items: center; gap: 10px; min-width: 0; }
.donut-wrap { position: relative; flex: 1 1 auto; min-width: 0; }  /* ~55%, but shrinkable */
.donut-center { position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; pointer-events: none; }
.donut-total { font-size: 20px; font-weight: 600; line-height: 1; }
.donut-cap { font-size: 10px; color: var(--muted); }
.donut-legend { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column;
  gap: 8px; font-size: 12px; color: var(--muted); flex: 0 0 auto; min-width: 92px; }
/* nowrap so "Medium · 6" never wraps and the legend cannot squeeze the donut */
.donut-legend li { display: flex; align-items: center; gap: 6px; white-space: nowrap; }

.workload { display: flex; flex-direction: column; }

/* Employee activity card (grouped by department, collapsible sections) */
.act-title { display: flex; align-items: baseline; justify-content: space-between; }
.act-legend { font-size: 11px; color: var(--muted); }
.activity { display: flex; flex-direction: column; gap: 4px; max-height: 340px;
  overflow-y: auto; padding-right: 2px; }
.act-dept-head { display: grid; grid-template-columns: 14px 1fr 36px 44px;
  gap: 6px; align-items: center; padding: 6px 8px; border-radius: 8px;
  background: var(--page); border: 1px solid var(--line); cursor: pointer;
  font-size: 12px; font-weight: 600; color: var(--ink); list-style: none; }
.act-dept-head::-webkit-details-marker { display: none; }
.act-dept-head:hover { background: var(--wash); }
.act-chev { color: var(--muted); transition: transform .15s ease; }
details[open] > .act-dept-head .act-chev { transform: rotate(90deg); }
.act-dept-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.act-num { text-align: right; font-variant-numeric: tabular-nums;
  font-size: 12px; color: var(--ink); }
.act-pillcol { display: flex; justify-content: flex-end; min-width: 44px; }
.pill-red { background: var(--red-bg); color: var(--red); border-radius: 999px;
  font-size: 10.5px; font-weight: 700; padding: 1px 8px;
  font-variant-numeric: tabular-nums; }
.pill-muted { background: var(--gray-bg, var(--page)); color: var(--muted);
  border: 1px solid var(--line); border-radius: 999px; font-size: 10.5px;
  font-weight: 600; padding: 1px 8px; }
.act-dash { color: var(--muted); font-size: 11px; }
.act-row { display: grid; grid-template-columns: 28px 1fr 36px 44px; gap: 8px;
  align-items: center; padding: 5px 8px 5px 22px; border-radius: 8px;
  color: var(--ink); text-decoration: none; }
.act-row:hover { background: var(--wash); text-decoration: none; }
.act-avatar { width: 28px; height: 28px; border-radius: 50%;
  background: var(--wash); color: var(--brand-text); display: inline-flex;
  align-items: center; justify-content: center; font-size: 10.5px;
  font-weight: 700; flex: none; }
.act-main { display: flex; flex-direction: column; min-width: 0; }
.act-name { font-size: 12.5px; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; }
.act-seen { display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; color: var(--muted); }
.act-seen.warn { color: var(--amber); font-weight: 600; }
.act-seen.never { font-style: italic; }
.act-warn-ic { flex: none; }
.act-never-section .act-dept-head { background: transparent;
  border-style: dashed; color: var(--muted); }
.act-dept-tag { color: var(--muted); font-size: 11.5px; font-weight: 400; }
.act-row.act-never .act-name, .act-row.act-never .act-num { color: var(--muted); }

/* Deadline calendar card */
.cal-title { display: flex; align-items: center; justify-content: space-between;
  gap: 8px; }
.cal-nav { display: inline-flex; align-items: center; gap: 6px; }
.cal-btn { border: 1px solid var(--line-strong); background: var(--surface);
  color: var(--brand-text); border-radius: 6px; width: 24px; height: 24px;
  line-height: 1; cursor: pointer; font-size: 14px; padding: 0; }
.cal-btn:hover { background: var(--wash); }
.cal-month { font-size: 12.5px; font-weight: 600; min-width: 110px;
  text-align: center; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 3px; margin-top: 8px; }
.cal-wd { font-size: 10px; font-weight: 600; color: var(--muted);
  text-transform: uppercase; text-align: center; padding-bottom: 2px; }
.cal-grid a.cal-day, .cal-grid span.cal-day { display: flex;
  flex-direction: column; align-items: center; aspect-ratio: 1;
  min-width: 0; border-radius: 8px; background: var(--page);
  border: 1px solid var(--line); color: var(--ink); text-decoration: none; }
.cal-num { font-size: 10px; line-height: 1; padding-top: 4px;
  color: inherit; opacity: .75; }
.cal-count { flex: 1; display: flex; align-items: center;
  font-size: 12.5px; font-weight: 700; font-variant-numeric: tabular-nums; }
.cal-grid a.cal-day:hover { background: var(--wash); text-decoration: none; }
.cal-grid span.cal-day.out { background: transparent; border-color: transparent; }
.cal-grid a.cal-day.planned { background: var(--wash);
  border-color: var(--wash-strong); color: var(--blue-dark, var(--accent)); }
.cal-grid a.cal-day.danger { background: var(--red-bg);
  border-color: var(--red-border); color: var(--red); }
.cal-grid a.cal-day.danger:hover { background: var(--red-bg); }
.cal-grid a.cal-day.today { outline: 2px solid var(--accent);
  outline-offset: -1px; }
.cal-legend { display: flex; gap: 14px; margin-top: 8px; font-size: 11px;
  color: var(--muted); }
.cal-key { display: inline-flex; align-items: center; gap: 5px; }
.cal-sq { width: 8px; height: 8px; border-radius: 2px; display: inline-block; }
/* never-activated accounts in executor selects: selectable but muted */
.opt-muted { color: var(--muted); }
.cal-sq.planned { background: var(--accent); }
.cal-sq.danger { background: var(--red); }
.cal-sq.meet { background: var(--ok); }
/* meetings indicator: green, so it never reads as a task count */
.cal-meet { font-size: 9.5px; font-weight: 700; color: var(--ok-strong);
  background: var(--ok-bg); border: 1px solid var(--ok-border);
  border-radius: 6px; padding: 0 4px; line-height: 1.35;
  margin-top: auto; margin-bottom: 3px; }
.cal-grid a.cal-day.meet { background: var(--ok-bg);
  border-color: var(--ok-border); color: var(--ok-strong); }
.cal-grid a.cal-day.meet:hover { background: var(--ok-bg); }
/* the day panel under the grid (tasks due + meetings for a clicked day) */
.cal-day-panel:empty { display: none; }
.cal-day-detail { margin-top: 10px; border-top: 1px solid var(--line);
  padding-top: 8px; font-size: 12.5px; }
.cal-day-head { display: flex; align-items: center;
  justify-content: space-between; gap: 8px; margin-bottom: 2px; }
.cal-day-board { font-size: 11.5px; white-space: nowrap; }
.cal-day-sec { font-size: 10.5px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .04em; color: var(--muted); margin: 6px 0 2px; }
.cal-day-list { list-style: none; margin: 0; padding: 0; }
.cal-day-list li { display: flex; align-items: center; gap: 6px;
  padding: 3px 0; min-width: 0; }
.cal-day-list li .cal-sq { flex: 0 0 auto; }
.cal-day-list a { color: var(--ink); overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; }
.cal-day-list a:hover { color: var(--brand-text); }
.wl-row { display: flex; align-items: center; gap: 8px; padding: 4.5px 0; color: var(--ink); }
.wl-row:hover { text-decoration: none; }
.wl-avatar { width: 18px; height: 18px; border-radius: 50%; background: var(--wash); color: var(--brand-text);
  font-size: 8px; font-weight: 600; display: flex; align-items: center; justify-content: center; flex: 0 0 auto; }
.wl-name { width: 110px; font-size: 12px; color: var(--muted); white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; flex: 0 0 auto; }
.wl-track { flex: 1; height: 10px; background: var(--gray-bg); border-radius: 5px; overflow: hidden; display: flex; }
.wl-seg { height: 10px; }
.wl-over { background: #CC4B45; }   /* overdue series (DASHBOARD_SPEC) */
.wl-rest { background: #378ADD; }   /* accent series (DASHBOARD_SPEC) */
.wl-count { font-size: 12px; width: 24px; text-align: right; flex: 0 0 auto; color: var(--ink); }

.attn { display: flex; flex-direction: column; }
.attn-item { display: flex; align-items: center; gap: 10px; padding: 8px 0;
  border-top: 1px solid var(--line); color: var(--ink); font-size: 12.5px; }
.attn-item:first-child { border-top: 0; }
.attn-item:hover { text-decoration: none; }
.attn-tile { width: 26px; height: 26px; border-radius: 7px; display: flex; align-items: center;
  justify-content: center; flex: 0 0 auto; }
.tile-red { background: var(--red-bg); color: var(--red); }
.tile-amber { background: var(--amber-bg); color: var(--amber); }
.tile-blue { background: var(--wash); color: var(--brand-text); }
.attn-label { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.dash-footer { margin-top: 2px; }
.pager { display: flex; align-items: center; gap: 12px; margin-top: 12px; }

/* ---- executive dashboard: dept table, overdue top-10, adoption ---- */
.dash-exec { display: grid; grid-template-columns: 1.2fr 1fr; gap: 12px; margin-bottom: 12px; }
.dash-exec > * { min-width: 0; }
.exec-table th { cursor: pointer; user-select: none; white-space: nowrap; }
.exec-table th.sorted { color: var(--brand-text); }
.exec-table td { font-variant-numeric: tabular-nums; }
.exec-row { cursor: pointer; }
.exec-row:hover { background: var(--wash); }
.exec-overdue { list-style: none; margin: 0; padding: 0; }
.exec-overdue li { display: flex; align-items: center; gap: 8px; padding: 5.5px 0;
  min-width: 0; border-bottom: 1px solid var(--line); font-size: 12.5px; }
.exec-overdue li:last-child { border-bottom: none; }
.exec-days { flex: 0 0 auto; white-space: nowrap; }
.exec-ref { flex: 0 0 auto; font-variant-numeric: tabular-nums; font-size: 11.5px; }
.exec-title { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; color: var(--ink); font-weight: 600; }
.exec-title:hover { color: var(--brand-text); }
.exec-meta { flex: 0 0 auto; max-width: 40%; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; color: var(--muted); font-size: 11.5px; }
.adopt { display: flex; flex-direction: column; gap: 7px; }
.adopt-row { display: flex; align-items: center; gap: 10px; min-width: 0; }
.adopt-name { flex: 0 0 34%; min-width: 0; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; font-size: 12.5px; font-weight: 600; }
.adopt-bar { flex: 1 1 auto; height: 8px; border-radius: 999px; background: var(--gray-bg); overflow: hidden; }
.adopt-fill { display: block; height: 100%; border-radius: 999px; background: var(--accent); }
.adopt-fill.zero { background: var(--danger-solid); min-width: 6px; }
.adopt-num { flex: 0 0 auto; font-size: 12px; font-variant-numeric: tabular-nums; color: var(--muted); }

@media (max-width: 1100px) {
  .dash-charts, .dash-bottom, .dash-stats { grid-template-columns: 1fr 1fr; }
  .dash-exec { grid-template-columns: 1fr; }
}

/* ---- contracts: status + invoice badges, progress bar ---- */
.badge.cstatus-draft { background: var(--gray-bg); color: var(--gray); }
.badge.cstatus-active { background: var(--ok-bg); color: var(--ok); }
.badge.cstatus-suspended { background: var(--amber-bg); color: var(--amber); }
.badge.cstatus-completed { background: var(--blue-bg); color: var(--brand-text); }
.badge.cstatus-terminated { background: var(--red-bg); color: var(--red); }
.badge.istatus-submitted { background: var(--gray-bg); color: var(--gray); }
.badge.istatus-approved { background: var(--amber-bg); color: var(--amber); }
.badge.istatus-paid { background: var(--ok-bg); color: var(--ok); }
.badge.istatus-rejected { background: var(--red-bg); color: var(--red); }
.progress { display: inline-block; width: 120px; height: 8px; border-radius: 999px;
  background: var(--gray-bg); overflow: hidden; vertical-align: middle; margin-right: 6px; }
.progress .bar { height: 100%; background: var(--blue); border-radius: 999px; }

/* ---- clickable task cards / rows ---- */
.task-card[data-href] { cursor: pointer; }
.clickable-rows tbody tr[data-href] { cursor: pointer; }
.task-card[data-href]:focus-visible,
.clickable-rows tbody tr[data-href]:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.clickable-rows tbody tr[data-href]:hover { background: var(--wash); }

/* ---- documents list redesign (rows) ---- */
.doc-rows { display: flex; flex-direction: column; }
.doc-row { display: flex; align-items: center; gap: 12px; padding: 9px 4px; border-top: 1px solid var(--line); }
.doc-row:first-child { border-top: 0; }
.doc-ic { flex: 0 0 auto; width: 30px; height: 30px; border-radius: 7px; display: inline-flex;
  align-items: center; justify-content: center; font-size: 9px; font-weight: 700; letter-spacing: .3px; }
.doc-ic.ic-pdf { background: var(--red-bg); color: var(--red); }
.doc-ic.ic-xls { background: var(--ok-bg); color: var(--ok); }
.doc-ic.ic-doc { background: var(--blue-bg); color: var(--brand-text); }
.doc-ic.ic-img, .doc-ic.ic-zip, .doc-ic.ic-gen { background: var(--wash); color: var(--accent); }
.doc-main { flex: 1; min-width: 0; }
.doc-titleline { display: flex; align-items: center; gap: 8px; min-width: 0; }
.doc-title { font-size: 13.5px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-sub { font-size: 11px; margin-top: 1px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-date { flex: 0 0 auto; width: 90px; text-align: right; font-size: 12px; color: var(--muted); }
.doc-actions { flex: 0 0 auto; display: flex; gap: 4px; }

/* task-files toggle chip */
.chip-toggle { cursor: pointer; }
.chip-body { display: inline-flex; align-items: center; gap: 5px; padding: 6px 12px; border: 1px solid var(--line-strong);
  border-radius: 999px; font-size: 12px; font-weight: 600; color: var(--muted); background: var(--surface); }
.chip-toggle input:checked + .chip-body { background: var(--wash); color: var(--brand-text); border-color: var(--brand-text); }

/* sidebar: task-attachments folder below a divider */
.tree-divider { border-top: 1px dashed var(--line-strong); margin: 8px 6px; }
.tree-attach { opacity: .8; }
.tree-attach .tree-link { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); }

/* ---- task detail redesign ---- */
.td-head { display: flex; flex-direction: column; gap: 14px; }
.td-titlerow { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.td-title { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; min-width: 0; }
.td-title h1 { font-size: 19px; font-weight: 600; margin: 0; }
.td-ref { font-size: 13px; font-weight: 500; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.ref-col { color: var(--muted); font-size: 12.5px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.td-actions { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; flex-wrap: wrap; justify-content: flex-end; }
.wf-return { display: flex; align-items: center; gap: 6px; margin: 0; }
.wf-return .input { width: 150px; padding: 6px 10px; }
.wf-awaiting { font-size: 13px; font-style: italic; }
/* ---- task assignment panel + timeline / inbox rows ---- */
.assign-form { padding-top: 10px; display: flex; flex-direction: column; gap: 12px; }
.tl-rows { display: flex; flex-direction: column; padding-top: 6px; }
.tl-row { display: flex; align-items: flex-start; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.tl-row:last-child { border-bottom: none; }
.tl-main { flex: 1; min-width: 0; }
.tl-line { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 13px; }
.tl-arrow { color: var(--muted); }
.tl-comment { font-size: 13px; margin-top: 3px; }
.tl-when { font-size: 12px; white-space: nowrap; }
.tl-detail { font-weight: 600; }
.meta-grid { display: flex; flex-wrap: wrap; gap: 22px; }
.meta-item { min-width: 0; }
.meta-k { font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; margin-bottom: 3px; }
.meta-v { font-size: 13px; display: flex; align-items: center; gap: 7px; }
.avatar.sm { width: 22px; height: 22px; font-size: 9px; }
.chip-outline { display: inline-flex; align-items: center; padding: 2px 10px; border: 1px solid var(--line-strong);
  border-radius: 999px; font-size: 12px; color: var(--ink); }
.due-chip { display: inline-flex; align-items: center; gap: 5px; padding: 2px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 600; background: var(--gray-bg); color: var(--muted); }
.due-chip.ok { background: var(--ok-bg); color: var(--ok); }
.due-chip.soon { background: var(--amber-bg); color: var(--amber); }
.due-chip.overdue { background: var(--red-bg); color: var(--red); }
.desc-panel { background: var(--page); border: 1px solid var(--line); border-radius: 10px;
  padding: 12px 14px; font-size: 13px; color: var(--ink); }

/* machine-translated task content (theme-variable colors follow dark mode) */
.tr-auto { display: inline-flex; align-items: center; color: var(--muted);
  margin-left: 4px; vertical-align: middle; cursor: help; }
/* the hidden attribute must beat any display rule — i18n.js toggles it */
[data-tr-show][hidden] { display: none !important; }
.tr-pending { font-size: 12px; font-style: italic; }
.tr-original { margin-top: 8px; font-size: 12.5px; color: var(--muted); }
.tr-original summary { cursor: pointer; font-weight: 600; }
.tr-original-body { background: var(--page); border: 1px dashed var(--line);
  border-radius: 8px; padding: 8px 12px; margin-top: 6px; color: var(--ink); }
.tr-edit { border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; }
.tr-edit summary { cursor: pointer; font-weight: 600; font-size: 13px; color: var(--brand-text); }
.tr-edit-lang { border-top: 1px solid var(--line); margin-top: 10px; padding-top: 10px; }
.tr-edit-head { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.tr-reset-label { display: inline-flex; align-items: center; gap: 5px; margin-left: auto;
  font-size: 12px; color: var(--muted); cursor: pointer; }

.td-attach-head { display: flex; align-items: center; justify-content: space-between; }
.pill-add { border: 1px solid var(--line-strong); background: var(--surface); color: var(--brand-text); font-weight: 600;
  font-size: 12px; padding: 4px 12px; border-radius: 999px; cursor: pointer; }
.pill-add:hover { border-color: var(--accent); background: var(--wash); }
.attach-rows { display: flex; flex-direction: column; }
.attach-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.attach-row:first-child { border-top: 0; }
.attach-row .ar-main { flex: 1; min-width: 0; }
.ar-title { font-size: 13px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ar-meta { font-size: 11.5px; margin-top: 1px; }
.ar-actions { display: flex; align-items: center; gap: 6px; flex: 0 0 auto; }
.ar-actions form { line-height: 0; }
.ext-img { background: var(--wash); color: var(--accent); }

/* ---- task attachments ---- */
.attach-block { margin-top: 4px; }
.attach-toggle { width: 100%; display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px; border: 1.5px dashed var(--line-strong); border-radius: 10px; background: var(--surface-2);
  color: var(--muted); font-size: 13px; font-weight: 600; cursor: pointer; }
.attach-toggle:hover { border-color: var(--accent); color: var(--brand-text); }
.attach-heading { font-size: 13px; font-weight: 600; margin-bottom: 8px; }
.dropzone { border: 1.5px dashed var(--line-strong); border-radius: 10px; padding: 16px;
  text-align: center; color: var(--muted); font-size: 13px; cursor: pointer; background: var(--surface-2); }
.dropzone.drag { border-color: var(--accent); background: var(--wash); color: var(--brand-text); }
.attach-list { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.attach-chip, .attach-existing-chip { display: inline-flex; align-items: center; gap: 8px;
  padding: 5px 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); font-size: 12px; max-width: 320px; }
.attach-existing { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.ac-name, .ae-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ac-size { color: var(--muted); flex: 0 0 auto; }
.ac-remove { border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 13px; padding: 0 2px; }
.ac-remove:hover { color: var(--red); }
.ext-tile { flex: 0 0 auto; width: 30px; height: 22px; border-radius: 5px; display: inline-flex;
  align-items: center; justify-content: center; font-size: 9px; font-weight: 700; letter-spacing: .3px; }
.ext-pdf { background: var(--red-bg); color: var(--red); }
.ext-xls { background: var(--ok-bg); color: var(--ok); }
.ext-doc { background: var(--blue-bg); color: var(--brand-text); }
.ext-gen { background: var(--wash); color: var(--accent); }
.attach-folder { margin-top: 8px; font-size: 12px; }
.attach-folder .input { margin-top: 6px; }
.clip { display: inline-flex; align-items: center; gap: 2px; color: var(--muted); font-size: 12px; font-weight: 600; }
.task-chip { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 999px;
  background: var(--wash); color: var(--brand-text); font-size: 12px; font-weight: 600; }
.row-actions { display: flex; gap: 6px; align-items: center; }
.row-actions form { line-height: 0; }

/* ---- telegram connect ---- */
.tg-steps { margin: 12px 0; padding-left: 18px; line-height: 2; }
.tg-code { display: inline-block; margin-top: 6px; padding: 8px 14px; border-radius: 8px;
  background: var(--gray-bg); font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 16px; font-weight: 700; letter-spacing: 1px; }

.muted { color: var(--muted); }
.deadline.muted { color: var(--muted); font-weight: 400; }

/* ---- list/board toggle ---- */
.view-toggle { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 8px; overflow: hidden; }
.toggle-btn { padding: 8px 14px; font-size: 13px; font-weight: 600; color: var(--muted); background: var(--surface); }
.toggle-btn:hover { background: var(--wash); text-decoration: none; color: var(--brand-text); }
.toggle-btn.active, .toggle-btn.active:hover { background: var(--blue); color: var(--on-fill); }

/* ---- department filter chips ---- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.chip { padding: 5px 12px; border-radius: 999px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--muted); font-size: 12.5px; font-weight: 600; cursor: pointer; }
/* hover on an UNSELECTED chip must never be mistakable for the selected
   state: a neutral background lift + border darkening only — the accent
   fill belongs to .active alone */
.chip:hover { background: var(--gray-bg); border-color: var(--muted); color: var(--ink); text-decoration: none; }
.chip:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.chip.active, .chip.active:hover { background: var(--blue); border-color: var(--blue); color: var(--on-fill); }
button.chip { font-family: inherit; }
/* muted task-count badge inside a department chip */
.chip-count { font-size: 10.5px; font-weight: 700; margin-left: 6px; padding: 0 6px; border-radius: 999px; background: var(--gray-bg); color: var(--muted); font-variant-numeric: tabular-nums; }
.chip.active .chip-count { background: rgba(255, 255, 255, .22); color: var(--on-fill); }
/* ---- admin task deletion ---- */
.btn.danger { background: var(--danger-solid); border-color: var(--danger-solid); color: var(--on-fill); }
.btn.danger:hover { filter: brightness(1.1); }
.icon-btn.icon-danger { color: var(--danger-solid); }
.bulk-bar { display: flex; justify-content: flex-end; margin: 10px 0 0; }
.data th.sel-col, .data td.sel-col { width: 34px; text-align: center; }

/* board filter row: dot separators between filter groups + a reset chip */
.chips#board-filters { margin-top: -8px; }
.chip-sep { color: var(--muted); align-self: center; font-weight: 700; }
/* Clear filters owns a FIXED slot at the right end of the toolbar; it is
   always rendered and merely muted while no filter is active */
.chip.chip-clear { border-style: dashed; color: var(--danger-solid); margin-left: auto; }
.chip.chip-clear:hover { background: var(--gray-bg); color: var(--danger-solid); }
.chip.chip-clear.disabled { pointer-events: none; color: var(--muted); border-color: var(--line); opacity: .55; }
/* board toggle for collapsed zero-count department chips */
#dept-chips .chip-more:hover { background: var(--gray-bg); }
/* all-filtered-out board: one centred message instead of four empty columns */
.board-empty { grid-column: 1 / -1; display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 56px 20px; border: 1px dashed var(--line-strong); border-radius: 10px; background: var(--gray-bg); }
.board-empty-msg { margin: 0; font-size: 14px; color: var(--muted); text-align: center; }
.board-empty-msg strong { color: var(--ink); }

/* ---- kanban board ---- */
.board { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; align-items: start; }
.board-col { background: var(--gray-bg); border-radius: 10px; padding: 10px; }
.board-col-head { display: flex; align-items: center; justify-content: space-between; padding: 4px 6px 10px; font-weight: 700; color: var(--blue-dark); font-size: 13px; }
.col-name { display: inline-flex; align-items: center; gap: 5px; }
.col-lock { display: inline-flex; align-items: center; color: var(--muted); }
.col-count { font-size: 11px; color: var(--muted); background: var(--surface); border-radius: 999px; padding: 1px 8px; }
.board-col-body { display: flex; flex-direction: column; gap: 8px; min-height: 44px; }
.task-card { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; box-shadow: var(--shadow); cursor: grab; }
.task-card:active { cursor: grabbing; }
.task-card:not(.locked)[data-href] { cursor: grab; }
.task-card.locked { cursor: default; }
.task-card.locked:active { cursor: default; }
.tc-top { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; flex-wrap: wrap; }
.dept-tag { font-size: 10.5px; font-weight: 600; color: var(--brand-text); background: var(--wash); border-radius: 4px; padding: 2px 6px; }
/* ---- programme module ("Dastur"): register + package card ---- */
.pg-sub { margin: 2px 0 0; font-size: 13px; }
.pg-pill { display: inline-flex; align-items: center; font-size: 11px; font-weight: 600; padding: 3px 8px; border-radius: 5px; white-space: nowrap; background: var(--gray-bg); color: var(--gray); }
.pg-pill.red { background: var(--red-bg); color: var(--red); }
.pg-pill.amber { background: var(--amber-bg); color: var(--amber); }
.pg-pill.green { background: var(--ok-bg); color: var(--ok); }
.pg-pill.blue { background: var(--blue-bg); color: var(--blue); }
.pg-pill.gray { background: var(--gray-bg); color: var(--gray); }
table.data.pg-register td { white-space: normal; vertical-align: top; }
.pg-register .pg-code { font-weight: 600; }
.pg-register .pg-name { font-size: 12px; }
.pg-register .pg-num { font-variant-numeric: tabular-nums; text-align: right; }
.pg-register .pg-issue { max-width: 340px; color: var(--ink); }
.pg-register .pg-actions { text-align: right; white-space: nowrap; }
.pg-card { display: flex; flex-direction: column; gap: 16px; }
.pg-head-row { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.pg-title { margin: 0; font-size: 22px; font-weight: 700; color: var(--blue-dark); }
.pg-ppline { margin: 6px 0 0; font-size: 13px; }
.pg-keyissue { margin: 6px 0 0; font-size: 13px; }
.pg-section .pg-h2 { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 0 0 12px; font-size: 15px; font-weight: 600; color: var(--blue-dark); }
.pg-h2 .pg-add { margin-left: auto; }
.pg-stage-now { font-weight: 400; font-size: 13px; }
.pg-steps { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 6px; }
.pg-step { display: flex; flex-direction: column; gap: 6px; }
.pg-step-bar { height: 8px; border-radius: 4px; background: var(--gray-bg); }
.pg-step-bar.done { background: var(--ok); }
.pg-step-bar.amber { background: var(--amber); }
.pg-step-bar.red { background: var(--red); }
.pg-step-label { font-size: 12px; color: var(--ink); }
.pg-step.todo .pg-step-label { color: var(--muted); }
.pg-step.cur .pg-step-label { font-weight: 600; }
.pg-grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 16px; }
.pg-row { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.pg-row:last-of-type { border-bottom: none; }
.pg-ms .pg-ms-label { flex: 1; min-width: 0; }
.pg-mono { font-variant-numeric: tabular-nums; font-size: 12px; color: var(--ink); white-space: nowrap; }
.pg-dot { width: 6px; height: 6px; border-radius: 50%; flex: none; background: var(--red); }
.pg-dot.gray { background: var(--gray); }
.pg-issue-text { flex: 1; min-width: 0; }
.pg-row-actions { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.pg-inline-form { margin: 0; display: inline; }
.pg-closed { margin-top: 10px; }
.pg-closed summary { cursor: pointer; font-size: 12.5px; }
.pg-next { margin-top: 12px; font-size: 13px; }
.pg-next .muted { font-size: 12px; }
.pg-task { display: grid; grid-template-columns: 90px minmax(0, 1fr) minmax(120px, auto) minmax(120px, auto); gap: 10px; cursor: pointer; }
.pg-task:hover { background: var(--wash); }
.pg-task a { color: var(--ink); }
.pg-task-meta { font-size: 12.5px; white-space: nowrap; }
.pg-task-due { font-size: 12px; color: var(--muted); white-space: nowrap; text-align: right; }
.pg-task-due.ok { color: var(--ok); }
.pg-task-due.overdue { color: var(--red); font-weight: 600; }
.pg-form { margin-top: 14px; padding-top: 14px; border-top: 1px dashed var(--line-strong); display: flex; flex-direction: column; gap: 12px; }
.pg-row-edit { flex: none; }
@media (max-width: 640px) { .pg-task { grid-template-columns: 1fr; gap: 4px; } .pg-task-due { text-align: left; } .pg-steps .pg-step-label { font-size: 10.5px; } }
.dl-table td { vertical-align: top; }
.dl-table .dl-title { white-space: normal; min-width: 260px; }
.dl-table .dl-date { font-variant-numeric: tabular-nums; }
.dl-table .dl-actions { text-align: right; white-space: nowrap; }
.dl-table .dl-actions form { display: inline; margin: 0; }
.dl-table .dl-actions .btn + .btn, .dl-table .dl-actions form + .btn { margin-left: 6px; }
.dl-note { font-size: 12px; }
/* ---- programme dashboard ---- */
.pd-head { align-items: flex-end; }
.pd-chips { margin-bottom: 0; }
.pd-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
@media (min-width: 1100px) { .pd-tiles { grid-template-columns: repeat(7, minmax(0, 1fr)); } }
.pd-tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.pd-tile-label { font-size: 12px; color: var(--muted); }
.pd-tile-value { font-size: 22px; font-weight: 700; margin: 4px 0; color: var(--blue-dark); line-height: 1.1; font-variant-numeric: tabular-nums; }
.pd-tile-value.red { color: var(--red); } .pd-tile-value.green { color: var(--ok); } .pd-tile-value.amber { color: var(--amber); }
.pd-tile-sub { font-size: 12px; color: var(--muted); }
.pd-gantt-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 12px; }
.pd-gantt-head .pg-h2 { margin: 0; }
.pd-legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 12px; }
.pd-legend > span { display: inline-flex; align-items: center; gap: 6px; }
.pd-legend i { display: inline-block; box-sizing: border-box; }
.pd-legend .lg-plan { width: 9px; height: 9px; background: var(--ink); transform: rotate(45deg); }
.pd-legend .lg-slip { width: 16px; height: 9px; background: var(--red-bg); border: 1px solid var(--red); }
.pd-legend .lg-impl { width: 16px; height: 9px; background: var(--ok-bg); border: 1px solid var(--ok); }
.pd-legend .lg-fc { width: 9px; height: 9px; border: 2px solid var(--amber); border-radius: 50%; }
.pd-gantt-scroll { overflow-x: auto; }
.pd-gantt { min-width: 760px; }
.pd-gantt-row { display: grid; grid-template-columns: 150px minmax(0, 1fr) 150px 84px; gap: 10px; align-items: center; min-height: 46px; padding: 6px 0; border-bottom: 1px solid var(--line); color: var(--ink); font-size: 13px; text-decoration: none; }
a.pd-gantt-row:hover { background: var(--wash); text-decoration: none; }
.pd-gantt-headrow { min-height: 0; padding: 0 0 6px; font-size: 11px; }
.pd-axis { position: relative; height: 14px; }
.pd-tick { position: absolute; top: 0; padding-left: 4px; border-left: 1px solid var(--line-strong); }
.pd-pkg { display: flex; flex-direction: column; }
.pd-pkg .muted { font-size: 11px; }
.pd-bar { position: relative; display: block; height: 22px; background: var(--gray-bg); border-radius: 4px; }
.pd-slip { position: absolute; top: 5px; height: 12px; border-radius: 3px; background: var(--red-bg); border: 1px solid var(--red); box-sizing: border-box; }
.pd-impl { position: absolute; top: 5px; height: 12px; right: 0; border-radius: 3px; background: var(--ok-bg); border: 1px solid var(--ok); box-sizing: border-box; }
.pd-plan { position: absolute; top: 6px; width: 10px; height: 10px; background: var(--ink); transform: rotate(45deg); margin-left: -5px; }
.pd-fc { position: absolute; top: 5px; width: 12px; height: 12px; border: 2px solid var(--amber); border-radius: 50%; box-sizing: border-box; margin-left: -6px; }
.pd-today { position: absolute; top: -4px; bottom: -4px; width: 2px; background: var(--blue); }
.pd-stage { font-size: 12px; }
.pd-right { text-align: right; }
.pd-delay { font-size: 12px; font-weight: 600; color: var(--amber); }
.pd-delay.red { color: var(--red); }
.pd-hint { font-size: 11px; padding-top: 8px; margin: 0; }
.pd-cardsub { margin: -6px 0 12px; }
.pd-dept-row { display: grid; grid-template-columns: 110px 54px minmax(0, 1fr) 54px; gap: 10px; align-items: center; min-height: 34px; color: var(--ink); font-size: 13px; text-decoration: none; }
.pd-dept-row:hover { background: var(--wash); text-decoration: none; }
.pd-dept-bar { display: block; position: relative; height: 8px; background: var(--gray-bg); border-radius: 4px; }
.pd-dept-fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 4px; }
.pd-dept-fill.green { background: var(--ok); } .pd-dept-fill.amber { background: var(--amber); } .pd-dept-fill.red { background: var(--red); }
.pd-avg { font-size: 12px; font-weight: 600; }
.pd-avg.green { color: var(--ok); } .pd-avg.amber { color: var(--amber); } .pd-avg.red { color: var(--red); }
.pd-link { font-size: 12px; }
.pd-att-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.pd-att-row:last-of-type { border-bottom: none; }
.pd-att-title { flex: 1; min-width: 0; }
.pd-att-when { font-size: 12px; white-space: nowrap; }
.pd-att-when.red { color: var(--red); } .pd-att-when.amber { color: var(--amber); }
/* ---- programme disbursement ---- */
.ds-tabs { margin-bottom: 16px; }
.ds-body { margin-top: 0; }
.ds-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; }
.ds-bar { position: relative; height: 6px; background: var(--gray-bg); border-radius: 3px; margin-top: 8px; overflow: hidden; }
.ds-fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 3px; background: var(--blue); }
.ds-fill.blue { background: var(--blue); } .ds-fill.green { background: var(--ok); } .ds-fill.amber { background: var(--amber); } .ds-fill.red { background: var(--red); }
.pd-tile-value.muted { color: var(--muted); }
.ds-manual { font-size: 13px; }
.ds-manual summary { cursor: pointer; color: var(--muted); }
.ds-manual .pg-form { margin-top: 8px; padding-top: 10px; }
.ds-chart { position: relative; height: 300px; min-width: 0; }
.ds-legend i { width: 18px; height: 0; }
.ds-legend .lg-dash-blue { border-top: 2px dashed var(--blue); }
.ds-legend .lg-solid-blue { border-top: 3px solid var(--blue); }
.ds-legend .lg-dash-amber { border-top: 2px dashed var(--amber); }
.ds-legend .lg-solid-amber { border-top: 3px solid var(--amber); }
.ds-note { padding-top: 10px; }
.ds-q { display: grid; grid-template-columns: 90px repeat(4, minmax(0, 1fr)); gap: 6px; font-size: 12.5px; padding: 8px 0; border-bottom: 1px solid var(--line); align-items: center; color: var(--ink); }
.ds-q.head { padding: 0 0 6px; font-size: 11px; }
.ds-q .num { font-variant-numeric: tabular-nums; text-align: right; }
.ds-q .red { color: var(--red); font-weight: 600; } .ds-q .green { color: var(--ok); font-weight: 600; } .ds-q .muted { color: var(--muted); }
.ds-recon { grid-template-columns: 60px repeat(3, minmax(0, 1fr)) minmax(180px, 1.5fr); }
.ds-reason-form { display: flex; gap: 6px; margin: 0; }
.ds-reason-form .input { height: 30px; font-size: 12px; flex: 1; min-width: 0; }
.ds-cat { padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.ds-cat:last-of-type { border-bottom: none; }
.ds-cat-head { display: flex; justify-content: space-between; gap: 10px; }
.ds-stat-table th.num, .ds-stat-table td.num, .ds-plan-table th.num, .ds-plan-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.ds-stat-table tr.muted td { color: var(--muted); }
.ds-plan-table td.err { color: var(--red); white-space: normal; }
.ds-import-forms { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }
.ds-import-form { display: flex; flex-direction: column; gap: 8px; padding: 12px 14px; border: 1px dashed var(--line-strong); border-radius: 8px; }
.ds-h3 { margin: 0; font-size: 13.5px; font-weight: 600; color: var(--blue-dark); }
.ds-cols { font-size: 12px; color: var(--muted); margin: 0; }
.ds-import-actions { margin-top: 12px; }
@media (max-width: 760px) { .ds-q { grid-template-columns: 70px repeat(4, minmax(0, 1fr)); font-size: 11.5px; } .ds-recon { grid-template-columns: 1fr; } .ds-recon.head { display: none; } .ds-recon .num { text-align: left; } }
/* programme package chip (blue pill as in the Dastur mockup): code only, the name sits in title */
.pkg-tag { font-size: 10.5px; font-weight: 600; color: var(--blue); background: var(--blue-bg); border-radius: 4px; padding: 2px 6px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.tc-ref { font-size: 11px; font-weight: 500; color: var(--muted); letter-spacing: 0.03em; margin-bottom: 2px; font-variant-numeric: tabular-nums; }
.tc-title { font-size: 13.5px; font-weight: 600; color: var(--ink); margin-bottom: 8px; line-height: 1.35; }
.tc-title a { color: var(--ink); }
.tc-title a:hover { color: var(--brand-text); }
.tc-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.tc-deadline { font-size: 11.5px; }
.avatar { width: 26px; height: 26px; border-radius: 50%; background: var(--accent); color: var(--on-fill); font-size: 11px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; }
.sortable-ghost { opacity: 0.4; }
.sortable-chosen { box-shadow: 0 4px 14px rgba(12, 68, 124, 0.18); }

@media (max-width: 1000px) { .board { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 600px) { .board { grid-template-columns: 1fr; } }

/* ---- dashboard ---- */
.dash-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.dash-activity { grid-column: 1 / -1; }
.dash-list { display: flex; flex-direction: column; }
.dash-row { display: flex; align-items: center; gap: 10px; padding: 11px 16px; border-bottom: 1px solid var(--line); color: var(--ink); }
.dash-row:last-child { border-bottom: none; }
.dash-row:hover { background: var(--wash); text-decoration: none; }
.dash-row-title { flex: 1; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini-link { margin-left: auto; font-size: 12px; font-weight: 600; }
.act-text { flex: 1; font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.act-text strong { color: var(--ink); font-weight: 600; }
.act-time { font-size: 11.5px; color: var(--muted); white-space: nowrap; }

@media (max-width: 800px) { .dash-grid { grid-template-columns: 1fr; } }

/* --- settings / administration ------------------------------------------ */
.settings-rows { display: flex; flex-direction: column; }
.settings-row {
  display: flex; flex-wrap: wrap; align-items: center; gap: 12px;
  padding: 10px 4px; border-top: 1px solid var(--line);
}
.settings-row:first-child { border-top: 0; }
.settings-row .sr-id { flex: 1 1 220px; min-width: 160px; overflow-wrap: anywhere; }
.sr-name { font-weight: 600; font-size: 14px; }
.sr-id-line { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.sr-login { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; font-size: 12.5px; color: var(--muted); }
.sr-sub { font-size: 12px; }
.sr-confirm, .sr-reset-done { flex-basis: 100%; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 8px 0 2px; }
.sr-confirm p, .sr-reset-done p { margin: 0; }
.sr-reset-done .temp-pw { margin: 0; flex: 0 0 auto; }
.sr-confirm .btn.danger { background: var(--red); border-color: var(--red); color: #fff; }
.sr-org { flex: 0 0 auto; white-space: nowrap; max-width: 150px; overflow: hidden; text-overflow: ellipsis; }
.sr-org-none { opacity: .6; }
.sr-role-block { display: flex; flex-direction: column; gap: 2px; }
.sr-changed { font-size: 11px; white-space: nowrap; }
.sr-rights-line { flex-basis: 100%; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; font-size: 12.5px; }
.sr-right-on { background: var(--blue-bg); color: var(--brand-text); border-color: transparent; }
.sr-right-implied { font-size: 12px; }
.sr-rights, .sr-org-modal { flex-basis: 100%; margin: 0; }
.sr-rights-set { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; margin: 0; padding: 8px 10px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--wash); }
.sr-rights-set legend { padding: 0 4px; font-size: 12px; font-weight: 600; }
.sr-rights-hint { flex-basis: 100%; margin: 0; font-size: 12px; }
.sr-cap { display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; cursor: pointer; }
.sr-cap input { margin: 0; accent-color: var(--blue); }
.sr-cap-implied { opacity: .6; cursor: default; }
.sr-cap-implied em { font-style: normal; font-size: 11px; }
.sr-org-modal { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; padding: 10px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--wash); }
.sr-org-modal .field { margin: 0; min-width: 160px; }
.sr-org-modal strong { flex-basis: 100%; }
.sr-saved { margin-left: 6px; font-size: 12px; color: var(--ok); font-weight: 600; }
.roles-help { margin-bottom: 16px; }
.roles-help summary { cursor: pointer; font-weight: 600; }
.roles-help-list { margin: 10px 0 0; padding-left: 18px; font-size: 13px; line-height: 1.5; }
.roles-help-list li { margin: 4px 0; }
.roles-matrix { margin-top: 10px; font-size: 12.5px; }
.roles-matrix th, .roles-matrix td { text-align: center; padding: 5px 8px; }
.roles-matrix th[scope="row"] { text-align: left; white-space: nowrap; }
.roles-matrix-org { background: var(--wash); }
.roles-matrix .mx-yes { color: var(--ok); font-weight: 700; }
.roles-matrix .mx-no { color: var(--muted); }
.roles-matrix .mx-own, .roles-matrix .mx-read, .roles-matrix .mx-right { font-size: 11.5px; color: var(--muted); }
.pf-delete { position: relative; }
.pf-delete summary { list-style: none; cursor: pointer; display: inline-flex; }
.pf-delete summary::-webkit-details-marker { display: none; }
.pf-delete-confirm { position: absolute; right: 0; top: 100%; z-index: 5; width: 320px; margin: 6px 0 0; padding: 12px; display: flex; flex-direction: column; gap: 10px; font-size: 13px; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.12); }
.pf-delete-confirm .btn.danger { align-self: flex-end; background: var(--red); border-color: var(--red); color: #fff; }
.input.sm { height: 32px; padding: 4px 8px; font-size: 12.5px; width: auto; min-width: 130px; }
.settings-row .tg-dot { width: 9px; height: 9px; }
.settings-row .sr-action { margin: 0; flex: 0 0 auto; }
.dept-rename { display: flex; align-items: center; gap: 6px; margin: 0; }
.temp-pw {
  display: flex; align-items: center; gap: 10px; margin: 14px 0;
  padding: 12px 14px; border: 1px solid var(--line-strong);
  border-radius: 10px; background: var(--wash);
}
.temp-pw code { font-size: 18px; font-weight: 700; letter-spacing: 0.06em; color: var(--ink); }
/* role badges (also used on the create-success screen) */
.badge.role-admin { background: var(--red-bg); color: var(--red); }
.badge.role-manager { background: var(--blue-bg); color: var(--brand-text); }
.badge.role-specialist { background: var(--ok-bg); color: var(--ok); }
.badge.role-viewer { background: var(--gray-bg); color: var(--gray); }
.role-admin.input { border-color: var(--red-border); }
@media (max-width: 720px) {
  .settings-row { flex-wrap: wrap; }
  .settings-row .sr-id { flex-basis: 100%; }
}

/* ---- meetings ---- */
.meet-section { font-size: 13px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); margin: 18px 0 8px; }
.meet-list { padding: 4px 0; }
.meet-row { display: flex; align-items: center; gap: 14px; padding: 10px 16px; text-decoration: none; color: var(--ink); border-bottom: 1px solid var(--line); }
.meet-row:last-child { border-bottom: none; }
.meet-row:hover { background: var(--wash); }
.meet-past .meet-row { opacity: .6; }
.meet-row.meet-cancelled { opacity: .5; }
.meet-row.meet-cancelled .meet-title { text-decoration: line-through; }
.meet-date { display: flex; flex-direction: column; align-items: center; min-width: 52px; padding: 4px 6px; border-radius: 10px; background: var(--gray-bg); }
.meet-day { font-size: 17px; font-weight: 700; line-height: 1.1; }
.meet-month { font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }
.meet-time { font-size: 11px; font-weight: 600; color: var(--brand-text); }
.meet-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.meet-title { font-weight: 600; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meet-meta { font-size: 12px; }
.meet-count { display: inline-flex; align-items: center; gap: 4px; font-size: 12.5px; white-space: nowrap; }
.badge.mstatus-scheduled { background: var(--blue-bg, var(--wash)); color: var(--blue); }
.badge.mstatus-done { background: var(--ok-bg); color: var(--ok); }
.badge.mstatus-cancelled { background: var(--red-bg); color: var(--red); }
.chip.chip-cross { border-style: dashed; cursor: default; }
/* unread notification strip on the meetings list */
.meet-notifications { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.meet-ntf { display: flex; align-items: center; gap: 10px; padding: 9px 14px; border-radius: 10px; border: 1px solid var(--line-strong); background: var(--wash); text-decoration: none; color: var(--ink); font-size: 13px; }
.meet-ntf-kind { font-weight: 700; white-space: nowrap; }
.meet-ntf-cancelled .meet-ntf-kind { color: var(--red); }
.meet-ntf-rescheduled .meet-ntf-kind { color: var(--amber); }
.meet-ntf-invited .meet-ntf-kind { color: var(--brand-text); }
.meet-ntf-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* detail: attendee grid */
/* min(230px, 100%) keeps one card per row on very narrow phones instead of
   the grid overflowing the viewport */
.meet-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(230px, 100%), 1fr)); gap: 8px; margin-top: 10px; }
/* overflow:hidden is the safety net: card content can only truncate, never
   paint over the neighbouring attendee */
.meet-person { display: flex; align-items: center; gap: 8px; padding: 7px 10px; border: 1px solid var(--line); border-radius: 10px; min-width: 0; overflow: hidden; }
.meet-person.meet-declined { opacity: .55; }
.meet-person-name { flex: 1 1 auto; min-width: 0; font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* long (Uzbek) department names truncate inside the pill — full name in
   title; inline-block because text-overflow does not apply to inline-flex */
.meet-person .chip,
.meet-person .badge { display: inline-block; max-width: 140px; min-width: 0; flex-shrink: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meet-person .chip { padding: 2px 9px; font-size: 11px; cursor: default; }
.meet-resp { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; border-radius: 50%; flex-shrink: 0; }
.meet-resp-accepted { background: var(--ok-bg); color: var(--ok); }
.meet-resp-declined { background: var(--red-bg); color: var(--red); }
.meet-resp-pending { background: var(--gray-bg); color: var(--muted); }
.meet-resp-guest { background: var(--gray-bg); color: var(--muted); }
.badge.badge-consultant { background: var(--amber-bg); color: var(--amber); }
.badge.badge-guest { background: var(--gray-bg); color: var(--muted); }
.meet-legend { font-size: 12px; margin: 12px 0 0; }
.meet-task-links { margin: 8px 0 0; padding-left: 18px; font-size: 13px; }
.meet-task-links li { margin: 3px 0; }
/* form: invite chips, person search, guest rows */
.meet-chiprow { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0; }
.chip.chip-toggle.chip-consultants { border-style: dashed; border-color: var(--amber); color: var(--amber); }
.chip.chip-toggle.chip-consultants.active { background: var(--amber); border-color: var(--amber); color: var(--on-fill); }
.chip.chip-toggle.chip-consultants.active .muted, .chip.chip-toggle.active .muted { color: inherit; opacity: .8; }
.meet-search-wrap { position: relative; }
.meet-search-results { position: absolute; z-index: 30; left: 0; right: 0; top: 100%; margin-top: 4px; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 10px; overflow: hidden; box-shadow: 0 8px 24px rgba(0,0,0,.12); }
.meet-search-hit { display: block; width: 100%; text-align: left; padding: 8px 12px; border: none; background: none; color: var(--ink); font-size: 13px; cursor: pointer; }
.meet-search-hit:hover { background: var(--wash); }
.meet-tokens { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.meet-token { cursor: default; display: inline-flex; align-items: center; gap: 6px; }
.meet-token-x { border: none; background: none; color: inherit; cursor: pointer; font-size: 11px; padding: 0; }
.meet-guest-row { display: flex; gap: 8px; margin: 6px 0; align-items: center; }
.meet-guest-row .input { flex: 1; }

/* meetings form polish: match the task form's vertical density */
.upload-form div.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: var(--label); }
.meet-chiprow { margin: 2px 0; gap: 6px; }
.chip-label { display: inline-block; max-width: 28ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom; }
.chip.chip-empty { opacity: .45; }
.chip.chip-more { border-style: dashed; color: var(--muted); font-weight: 500; }
.chip.chip-more:hover { background: var(--wash); }
#chips-helper { font-weight: 500; min-height: 16px; }
.meet-tokens { margin-top: 6px; gap: 5px; }
.meet-guest-row { margin: 4px 0; }

/* meetings: two-level department -> people picker */
#meet-panels { display: flex; flex-direction: column; gap: 8px; margin-top: 6px; }
.meet-panel { border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px 10px; background: var(--page); }
.meet-panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding-bottom: 6px; margin-bottom: 4px; border-bottom: 1px solid var(--line); }
.meet-panel-head strong { font-size: 12.5px; }
.meet-select-all { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 500; color: var(--muted); cursor: pointer; }
.meet-member { display: flex; align-items: center; gap: 8px; padding: 3px 0; font-size: 13px; font-weight: 500; color: var(--ink); cursor: pointer; }
.meet-member input { accent-color: var(--blue); }
.meet-member.meet-inactive > span:first-of-type { opacity: .55; }
.meet-na { font-size: 11px; font-style: italic; }

/* task detail: participants + involved departments */
.task-participants { flex-wrap: wrap; gap: 6px; }
.participant-chip { gap: 6px; padding: 3px 10px 3px 4px; }
.participant-chip .badge { margin-left: 2px; }
.chip-extra-dept { opacity: .75; border-style: dashed; }

/* task form: department multi-select chip box driving the people panels */
.dept-msel { position: relative; display: flex; align-items: center; flex-wrap: wrap; gap: 6px; min-height: 38px; padding: 5px 30px 5px 8px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--surface); cursor: pointer; }
.dept-msel:focus { outline: 2px solid var(--blue); outline-offset: 1px; }
.dept-msel-ph { font-weight: 500; font-size: 13px; }
.dept-msel-caret { position: absolute; right: 10px; color: var(--muted); font-size: 11px; pointer-events: none; }
.dept-msel-chips { display: contents; }
.dept-msel-chip { cursor: default; display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; font-size: 12px; }
.dept-msel-list { position: relative; z-index: 25; margin-top: 4px; max-height: 260px; overflow-y: auto; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--surface); box-shadow: 0 8px 24px rgba(0,0,0,.12); }
.dept-msel-row { display: flex; align-items: center; gap: 8px; padding: 7px 12px; font-size: 13px; font-weight: 500; color: var(--ink); cursor: pointer; }
.dept-msel-row:hover { background: var(--wash); }
.dept-msel-row input { accent-color: var(--blue); }
.dept-msel-row input[disabled] + .chip-label { opacity: .7; }
.dept-msel-consultants { border-top: 1px dashed var(--line-strong); color: var(--amber); }
.picker-hint { font-weight: 500; font-size: 12px; }

/* inline creator-comment editor on the task page */
.cc-edit { vertical-align: middle; margin-left: 4px; }
.cc-actions { display: flex; gap: 8px; margin-top: 8px; }

/* cross-org creation: people are read-only context — departments stay
   usable, every selection control disappears, the hint shows */
.picker-cross-hint { display: none; font-size: 12px; font-weight: 600; }
.picker-readonly .picker-cross-hint { display: block; margin-bottom: 4px; }
.picker-readonly .meet-member input,
.picker-readonly .meet-select-all { display: none; }
.picker-readonly .meet-member { cursor: default; }
.picker-readonly .picker-people-search,
.picker-readonly .picker-selected { display: none; }
/* --- metering points (register of bulk metering points) --- */
.mp-filters { margin-bottom: 16px; }
.mp-filters .search { width: 100%; max-width: 520px; margin-bottom: 12px; }
.mp-filter-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px 12px; align-items: end; }
.mp-filter { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.mp-filter .input { width: 100%; min-width: 0; height: 36px; }
.mp-filter-label { font-size: 11.5px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.03em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mp-filter-toggle { justify-content: flex-end; }
.mp-filter-toggle .chip-body { height: 36px; box-sizing: border-box; }
.mp-toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.mp-toolbar .spacer { flex: 1; }
.mp-count { font-size: 13.5px; font-weight: 600; color: var(--ink); }
.pf-count { display: flex; flex-direction: column; gap: 2px; }
.pf-own-org { font-size: 12px; }
.mp-table th a { color: inherit; display: inline-flex; align-items: center; gap: 4px; }
.mp-table th a:hover { color: var(--brand-text); text-decoration: none; }
.mp-table th.sorted a { color: var(--brand-text); }
.mp-sort-arrow { font-size: 9px; }
.mp-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.mp-table td.mp-name { max-width: 34ch; overflow: hidden; text-overflow: ellipsis; }
.mp-id { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-weight: 600; letter-spacing: 0.01em; }
h1.mp-id { font-size: 20px; margin: 0; }
.badge.mp-check { background: var(--amber-bg); color: var(--amber); }
.badge.mp-poscheck { background: var(--red-bg); color: var(--red); border: 1px dashed var(--red); }
.mp-subtitle { margin: 8px 0 0; font-size: 13.5px; white-space: pre-wrap; }
.mp-detail-grid .card-title { padding-left: 0; padding-right: 0; margin-bottom: 10px; }
.mp-meta dd { white-space: pre-wrap; word-break: break-word; }
.mp-photos { margin: 0; padding-left: 18px; font-size: 13.5px; line-height: 1.9; }
@media (max-width: 900px) { .mp-detail-grid { grid-template-columns: 1fr; } }

/* ---- meter installation protocols (Rev9) ---- */
.pf-search { margin-bottom: 16px; }
.pf-search .search { width: 100%; max-width: 520px; }
.pf-list td.num { text-align: right; font-variant-numeric: tabular-nums; }
.pf-list td.mp-name { max-width: 30ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pf-list td.pf-updated { font-size: 12.5px; white-space: nowrap; }
.pf-tone-ok { color: var(--ok-strong); font-weight: 600; }
.pf-tone-bad { color: var(--red); font-weight: 600; }
.pf-tone-refer { color: var(--amber); font-weight: 600; }
.pf-tone-none { color: var(--muted); }

/* new protocol: typeahead */
.pf-picker { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 16px; align-items: start; }
.pf-map-wrap { order: 2; position: sticky; top: 16px; }
.pf-sites { order: 1; min-width: 0; }
.pf-map { height: 520px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--wash); z-index: 0; }
.pf-map-hint { margin: 6px 0 0; font-size: 12px; }
.pf-site-hit { outline: 2px solid var(--blue); outline-offset: 2px; }
.pf-site-only { opacity: .85; }
.pf-n-protocols { background: var(--blue-bg); color: var(--brand-text); }
.pf-filters-toggle { display: none; margin: 0 0 10px; }
@media (max-width: 720px) {
  .pf-picker { display: flex; flex-direction: column; }
  .pf-map-wrap { order: 1; position: static; width: 100%; }
  .pf-sites { order: 2; }
  .pf-map { height: 40vh; }
}
@media (max-width: 600px) {
  .pf-filters-toggle { display: inline-flex; }
  .pf-filters.pf-collapsed .mp-filter-grid { display: none; }
}
.pf-sites-note { margin: 4px 0 0; font-size: 13.5px; }
.pf-site-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.pf-site { display: flex; align-items: center; gap: 14px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface-2); }
.pf-site-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; font-size: 13.5px; }
.pf-site-facility { color: var(--ink); }
.pf-site-where { font-size: 12.5px; }
.pf-site-open { display: flex; align-items: center; gap: 8px; margin: 0; }
.pf-meter-no { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); }
.pf-meter-no .input { width: 64px; height: 32px; padding: 0 8px; }
@media (max-width: 640px) {
  .pf-site { flex-direction: column; align-items: stretch; }
  .pf-site-open { justify-content: flex-end; }
}

/* the form */
.pf-page-head h1 { font-size: 20px; }
.pf-head { margin-bottom: 16px; }
.pf-readonly { margin: 10px 0 0; font-size: 13px; }
.pf-form { display: flex; flex-direction: column; gap: 22px; padding-bottom: 72px; }
.pf-phase { display: flex; flex-direction: column; gap: 14px; }
.pf-phase-head { padding: 14px 18px; border-radius: var(--radius); border-left: 5px solid var(--blue); background: var(--blue-bg); }
.pf-phase-head h2 { margin: 0 0 4px; font-size: 15px; letter-spacing: 0.02em; color: var(--blue-dark); white-space: pre-wrap; }
.pf-phase-head p { margin: 0; font-size: 13px; color: var(--muted); }
.pf-phase-B .pf-phase-head { border-left-color: #0f766e; background: #e3f3f1; }
html[data-theme="dark"] .pf-phase-B .pf-phase-head { border-left-color: #5eead4; background: #10302d; }
.pf-phase-C .pf-phase-head { border-left-color: var(--ok); background: var(--ok-bg); }
.pf-section .card-title { white-space: pre-wrap; }
.pf-intro { margin: 0; padding: 10px 16px; font-size: 13px; color: var(--muted); border-bottom: 1px solid var(--line); }
.pf-row { padding: 12px 16px; border-bottom: 1px solid var(--line); }
.pf-row:last-child { border-bottom: 0; }
.pf-row-result { background: var(--surface-2); }
.pf-row-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.pf-ref { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-weight: 700; font-size: 12.5px; color: var(--brand-text); background: var(--wash); border-radius: 6px; padding: 1px 7px; }
.pf-label { flex: 1 1 320px; font-size: 13.5px; font-weight: 600; color: var(--label); min-width: 0; }
.pf-row-meta { display: inline-flex; gap: 10px; font-size: 12px; color: var(--muted); white-space: nowrap; }
.pf-unit { font-weight: 600; color: var(--ink); }
.pf-cells { display: grid; gap: 8px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.pf-cells-1 { grid-template-columns: minmax(0, 1fr); }
.pf-cells-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.pf-cell { display: flex; align-items: center; gap: 8px; min-width: 0; }
.pf-cell .input { flex: 1; min-width: 0; height: 36px; }
.pf-cell-n { flex: 0 0 18px; font-size: 11px; font-weight: 700; color: var(--disabled); text-align: center; }
.pf-result, .pf-fixed { flex: 1; min-width: 0; min-height: 36px; padding: 7px 10px; border-radius: 6px; font-size: 13px; line-height: 1.45; white-space: pre-wrap; word-break: break-word; }
.pf-result { background: var(--surface-3); border: 1px solid var(--line); color: var(--ink); }
.pf-result:empty::before { content: "—"; color: var(--disabled); }
.pf-fixed { background: var(--surface-3); border: 1px dashed var(--line-strong); }
.pf-hint { margin-top: 6px; font-size: 12px; color: var(--muted); }
.pf-greyed { opacity: .55; }
.pf-greyed .input { background: var(--surface-3); }
.pf-savebar { order: 99; position: sticky; bottom: 0; z-index: 5; display: flex; align-items: center; gap: 12px; padding: 10px 16px; margin: 0 -4px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 -2px 10px rgba(0,0,0,.08); }
.pf-dirty { font-size: 13px; font-weight: 600; color: var(--amber); }
.pf-saved { font-size: 13px; font-weight: 600; color: var(--ok-strong); }
.pf-saved[hidden] { display: none; }
@media (max-width: 780px) {
  .pf-cells, .pf-cells-2 { grid-template-columns: minmax(0, 1fr); }
  .pf-row { padding: 10px 12px; }
  .pf-row-meta { white-space: normal; }
  .pf-page-head { flex-wrap: wrap; }
}

/* stage 4: source/clause, hold-point banner, phase review, gating notices */
.pf-src { color: var(--muted); }
.pf-src-auto { font-size: 10.5px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; padding: 1px 6px; border-radius: 4px; background: var(--gray-bg); color: var(--gray); }
.pf-clause { color: var(--muted); }
.pf-banner { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; padding: 12px 16px; border-radius: var(--radius); border: 1px solid var(--amber-border); border-left: 5px solid var(--amber); background: var(--amber-bg); color: var(--ink); font-size: 13.5px; }
.pf-banner strong { color: var(--amber); }
.pf-banner-icon { flex: 0 0 auto; align-self: center; color: var(--amber); }
.pf-banner-sub { color: var(--muted); font-size: 12.5px; }
.badge.pf-hold { background: var(--amber-bg); color: var(--amber); border: 1px solid var(--amber-border); }
.badge.pf-dec-ok { background: var(--ok-bg); color: var(--ok); }
.badge.pf-dec-bad { background: var(--red-bg); color: var(--red); }
.badge.pf-dec-none { background: #eef2f6; color: #3a4857; }                 /* 8.3:1 */
html[data-theme="dark"] .badge.pf-dec-none { background: #1C2836; color: #cdd7e1; }  /* 10.2:1 */
.pf-phase-row { display: block; }
.pf-decision { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 12.5px; margin-top: 10px; }
.pf-decision .badge { white-space: nowrap; }
.pf-decision .input { height: 32px; font-size: 13px; }
.pf-decision select.input { width: auto; max-width: 240px; }
.pf-decision input.input { width: 200px; }
.pf-dec-meta { white-space: nowrap; }
.pf-dec-comment { color: var(--ink); font-style: italic; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pf-notice { margin: 0; padding: 10px 16px; font-size: 13px; color: var(--amber); background: var(--amber-bg); border-bottom: 1px solid var(--amber-border); }
.pf-list .pf-phase-badges { display: flex; gap: 4px; flex-wrap: wrap; }
.pf-list .pf-phase-badges .badge { font-size: 11px; padding: 2px 7px; }
.pf-toolbar-actions { display: flex; gap: 8px; flex-wrap: wrap; }
@media (max-width: 780px) {
  .pf-decision input.input { width: 100%; }
}

.mp-protocol-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 8px; }

/* production follow-ups */
.pf-banner[hidden] { display: none; }                      /* the hidden attribute wins over display:flex */
@media (min-width: 781px) {
  .pf-row[data-ref="A8"] .pf-cells-3 { grid-template-columns: minmax(0, 2fr) minmax(0, 1.2fr) minmax(0, 1fr); }
}
@media (min-width: 900px) {
  /* one line at desktop widths: every part may shrink, long parts ellipsise */
  .pf-decision { flex-wrap: nowrap; min-width: 0; }
  .pf-decision .badge { flex: 0 1 auto; min-width: 0; max-width: 190px; overflow: hidden; text-overflow: ellipsis; display: inline-block; line-height: 20px; }
  .pf-decision .pf-dec-meta { flex: 0 1 auto; min-width: 0; max-width: 170px; overflow: hidden; text-overflow: ellipsis; }
  .pf-decision .pf-dec-comment { flex: 0 1 auto; max-width: 140px; }
  .pf-decision select.input { flex: 0 1 auto; min-width: 120px; max-width: 200px; }
  .pf-decision input.input { flex: 1 1 100px; min-width: 90px; max-width: 240px; }
  .pf-decision .btn { flex: 0 0 auto; }
}
html[data-theme="dark"] .pf-table-wrap { scrollbar-width: thin; scrollbar-color: var(--line-strong) var(--surface); }
html[data-theme="dark"] .pf-table-wrap::-webkit-scrollbar { height: 10px; }
html[data-theme="dark"] .pf-table-wrap::-webkit-scrollbar-track { background: var(--surface); }
html[data-theme="dark"] .pf-table-wrap::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 6px; border: 2px solid var(--surface); }

/* sections locked until the phase before them is approved */
.pf-locked .pf-cells .input:disabled { background: var(--surface-3); color: var(--muted); cursor: not-allowed; }
.pf-locked .pf-row { opacity: .85; }

/* --- submit for review: states, the phase bar, the missing-entries list -- */
.badge.pf-dec-submitted { background: var(--blue-bg); color: var(--blue-dark); }
html[data-theme="dark"] .badge.pf-dec-submitted { background: #15283d; color: #9cc8ff; }
.pf-phase-foot { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 16px; margin: 6px 0 4px; border-top: 1px dashed var(--line); font-size: 13px; }
.pf-missing { margin: 8px 0; padding: 10px 16px; border-radius: var(--radius); background: var(--red-bg); color: var(--red); font-size: 13px; }
.pf-missing ul { margin: 6px 0 0; padding-left: 18px; columns: 2; column-gap: 24px; }
.pf-missing a { color: inherit; }
.pf-missing .pf-ref { font-weight: 700; margin-right: 4px; }
.pf-cell { scroll-margin-top: 96px; }
.pf-cell-missing .input { border-color: var(--red); box-shadow: 0 0 0 2px var(--red-bg); }
.pf-reopen { display: inline-block; }
.pf-reopen summary { list-style: none; cursor: pointer; }
.pf-reopen summary::-webkit-details-marker { display: none; }
.pf-reopen-form { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; padding: 10px; border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--surface); min-width: 260px; max-width: 420px; }
.pf-reopen-form .input { width: 100%; }
.pf-chips { display: flex; gap: 8px; flex-wrap: wrap; margin: 0 0 10px; }
.tl-row.tl-unread { background: var(--blue-bg); border-radius: 6px; }
.badge.pf-nt-submitted { background: var(--blue-bg); color: var(--blue-dark); }
.badge.pf-nt-approved, .badge.pf-nt-approved_with_comments { background: var(--ok-bg); color: var(--ok); }
.badge.pf-nt-rejected { background: var(--red-bg); color: var(--red); }
.badge.pf-nt-withdrawn, .badge.pf-nt-reopened { background: var(--amber-bg); color: var(--amber); }
@media (max-width: 700px) { .pf-missing ul { columns: 1; } }

/* --- settings / users: read-only list + side panel ----------------------- */
.su-filters { align-items: center; }
.su-filters .input { min-width: 110px; }
.su-filters .search { min-width: 170px; flex: 1 1 170px; max-width: 260px; }
.sp .sp-check { display: flex; flex-direction: row; align-items: center; gap: 8px; }
.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 10px; overflow: hidden; background: var(--surface); }
.seg-btn { appearance: none; border: 0; border-left: 1px solid var(--line); background: transparent; color: var(--muted); font: inherit; font-size: 13px; height: 36px; padding: 0 12px; cursor: pointer; white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; }
.seg-btn:first-child { border-left: 0; }
.seg-btn.active { background: var(--blue-bg); color: var(--brand-text); font-weight: 600; }
.seg-count { font-size: 11px; padding: 1px 6px; border-radius: 999px; background: var(--wash); color: var(--muted); }
.seg-btn.active .seg-count { background: var(--surface); }
.su-layout { display: flex; gap: 16px; align-items: flex-start; }
.su-list { flex: 1 1 0; min-width: 0; }
.su-panel { flex: 0 0 440px; max-width: 440px; position: sticky; top: 72px; }
.su-panel:empty { display: none; }
.su-group { margin-bottom: 12px; }
.su-group-head { display: flex; align-items: center; gap: 8px; margin: 0 0 6px; font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.su-group-head .dot { width: 9px; height: 9px; }
.su-dot-pmc { background: var(--blue); }
.su-dot-client { background: var(--ok); }
.su-dot-contractor { background: #D98C2B; }
.su-dot-other { background: var(--line-strong); }
.su-group-count { font-weight: 500; }
.su-head { padding: 0 4px 4px; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); flex-direction: row; gap: 12px; }
.sr-list { flex-wrap: nowrap; }
.sr-person { display: flex; align-items: center; gap: 10px; flex: 1 1 240px; min-width: 0; }
.sr-person .sr-id { flex: 1 1 auto; }
.sr-role-col { flex: 0 0 200px; display: flex; align-items: center; gap: 4px; flex-wrap: wrap; font-size: 12.5px; }
.sr-rights-col { flex: 1 1 200px; display: flex; flex-wrap: wrap; gap: 4px 6px; font-size: 12px; }
.sr-rights-col .chip-outline { padding: 1px 8px; font-size: 11.5px; }
.sr-status { flex: 0 0 48px; display: inline-flex; justify-content: center; }
.dot-on { background: var(--ok); }
.dot-off { background: var(--line-strong); }
.sr-inactive .sr-person, .sr-inactive .sr-role-col, .sr-inactive .sr-rights-col { opacity: .55; }
.settings-row.is-editing { background: var(--blue-bg); box-shadow: inset 3px 0 0 var(--blue); border-radius: 6px; }
.sp { background: var(--surface); border: 1px solid var(--line-strong); border-radius: 12px; box-shadow: 0 8px 24px rgba(0,0,0,.08); max-height: calc(100vh - 88px); overflow: auto; }
.sp-head { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--surface); z-index: 2; }
.sp-title { margin: 0; font-size: 16px; flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; outline: none; }
.sp-close { margin-left: auto; font-size: 18px; line-height: 1; padding: 2px 8px; }
.sp-body { padding: 4px 16px 16px; }
.sp-section { margin: 16px 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.sp-section:first-child { margin-top: 10px; }
.sp-hint { display: block; font-size: 12px; margin-top: 4px; }
.sp-static-value { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-height: 32px; }
.sp .field { margin-bottom: 10px; }
.sp .sr-org-modal { margin: 0 0 10px; }
.sp-rights { display: flex; flex-direction: column; gap: 6px; margin: 0; }
.sp-right-card { display: flex; gap: 10px; align-items: flex-start; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; font-size: 13px; }
.sp-right-card input { margin: 3px 0 0; accent-color: var(--blue); flex: 0 0 auto; }
.sp-right-card:has(input:checked) { border-color: var(--blue); background: var(--blue-bg); }
.sp-right-implied { opacity: .7; cursor: default; }
.sp-right-text { display: flex; flex-direction: column; gap: 2px; }
.sp-right-text .muted { font-size: 12px; }
.sp-included { font-style: normal; font-size: 11.5px; color: var(--brand-text); }
.sp-account { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.sp-account .sr-action { margin: 0; margin-left: auto; }
.sp .sr-confirm, .sp .sr-reset-done { flex-direction: column; align-items: flex-start; }
.sp-history { list-style: none; margin: 0; padding: 0; font-size: 12.5px; }
.sp-hist { display: grid; grid-template-columns: 96px 1fr; gap: 2px 10px; padding: 6px 0; border-top: 1px solid var(--line); }
.sp-hist:first-child { border-top: 0; }
.sp-hist-when { font-size: 11.5px; grid-row: span 2; }
.sp-hist-actor { font-weight: 600; }
.sp-hist-what { color: var(--muted); }
.sp-check { display: flex; align-items: center; gap: 8px; }
.sp-check input { margin: 0; }
.sp-errors { position: static; margin: 8px 0; }
@media (max-width: 900px) {
  .su-layout { display: block; }
  .su-panel { position: fixed; inset: 0; max-width: none; z-index: 50; padding: 0; background: rgba(0,0,0,.35); }
  .su-panel:empty { display: none; }
  .sp { height: 100%; max-height: none; border-radius: 0; border: 0; }
  .sr-list { flex-wrap: wrap; }
  .sr-role-col { flex: 1 1 140px; }
  .sr-rights-col { flex: 1 1 100%; order: 5; }
  .su-head { display: none; }
  .seg { flex-wrap: wrap; }
}

/* --- settings / groups tab, the panel's groups + effective permissions --- */
.gr-head, .gr-row { display: grid; grid-template-columns: minmax(180px, 2fr) minmax(160px, 2fr) 70px 90px; gap: 10px; align-items: center; }
.gr-head { font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; padding: 0 4px 6px; }
.gr-row { padding: 10px 4px; border-top: 1px solid var(--line); }
.gr-scope { display: flex; flex-wrap: wrap; gap: 6px; }
.crumbs { margin: 0 0 10px; font-size: 13px; color: var(--muted); }
.gp-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.gp-head .sr-action { margin: 0 0 0 auto; }
.gp-title { margin: 0; font-size: 18px; }
.gp-desc { margin: 8px 0 0; }
.gp-add { margin: 0 0 10px; }
.gp-perms, .sp-perms, .sp-groups { list-style: none; margin: 0; padding: 0; font-size: 13px; }
.gp-perms li, .sp-perms li { padding: 4px 0; border-top: 1px solid var(--line); display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; }
.gp-perms li:first-child, .sp-perms li:first-child { border-top: 0; }
.sp-perm-src { font-size: 11.5px; flex-basis: 100%; }
.sp-groups li { display: flex; align-items: center; gap: 8px; padding: 4px 0; }
.sp-group-kind { font-size: 11px; }
.gh-kind { margin: 12px 0 4px; font-size: 13px; }
.gh-perms code { margin-right: 6px; font-size: 11.5px; }
@media (max-width: 700px) { .gr-head { display: none; } .gr-row { grid-template-columns: 1fr; } }

/* --- protocol register: the shared header in protocols mode ---------- */
.pf-f-date-off { display: none; }
.pf-showing { font-size: 12.5px; margin-left: 10px; }
.pf-count { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pf-count .chip-clear { margin-left: 0; }
.pf-toolbar-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pf-toolbar-actions .chip-clear { margin-left: 0; }
.pf-active-filters { list-style: none; margin: 6px 0 10px; padding: 0; display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 14px; font-size: 13px; }
.pf-table-wrap { max-width: 100%; overflow-x: auto; }

/* --- register maps: list / list + map / map (static/js/map_view.js) --- */
.mv-layout { position: relative; }
.mv-layout[data-view="split"] { display: grid; grid-template-columns: minmax(0, 45%) minmax(0, 55%); gap: 16px; align-items: start; }
.mv-layout[data-view="list"] .mv-map-wrap { display: none; }
.mv-layout[data-view="map"] .mv-list > *:not(.mp-toolbar) { display: none; }   /* the count and the switch stay */
.mv-layout[data-view="split"] .mv-list { min-width: 0; }
.mv-map-wrap { position: sticky; top: 16px; min-width: 0; }
.mv-map-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 0 0 8px; }
.mv-map-bar .mv-follow .chip-body { height: 32px; box-sizing: border-box; }
.mv-pin-count { font-size: 12px; margin-left: auto; font-variant-numeric: tabular-nums; }
.mv-map { height: 70vh; min-height: 360px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--wash); z-index: 0; }
.mv-switch { margin-left: 10px; }
.mv-switch .seg-btn { padding: 4px 10px; font-size: 12px; }
.mv-legend { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; font-size: 12px; display: flex; flex-direction: column; gap: 4px; color: var(--ink); }
.mv-legend-row { display: inline-flex; align-items: center; gap: 6px; }
.mv-legend-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; border: 1px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.15); }
tr.mv-row-hit td { background: var(--blue-bg) !important; }
.mv-layout[data-view="split"] tr[data-pin-id], .mv-layout[data-view="map"] tr[data-pin-id] { cursor: pointer; }
.mv-popup { font-size: 13px; line-height: 1.45; min-width: 200px; }
.mv-popup-title { font-weight: 600; margin-bottom: 2px; }
.mv-popup-facility { margin-bottom: 2px; }
.mv-popup-phases { margin: 6px 0; }
.mv-popup-open { margin-top: 4px; }
.leaflet-container { font-family: inherit; }
@media (max-width: 600px) {
  .mv-view-split { display: none; }
  .mv-layout[data-view="split"] { display: block; }
  .mv-layout[data-view="split"] .mv-list > *:not(.mp-toolbar) { display: none; }
  .mv-map { height: 55vh; min-height: 0; }
  .mv-map-wrap { position: static; }
}

/* --- maps: tiles fallback, fullscreen, the in-map tools ------------------ */
.map-tiles-missing { background: var(--wash); }
.map-tiles-missing .leaflet-tile-pane { display: none; }
/* under the top-right chip, right of the left column: never over the legend or the attribution */
.map-tiles-note { position: absolute; left: 56px; top: 56px; max-width: calc(100% - 64px); z-index: 700; pointer-events: none;
  padding: 4px 10px; border-radius: 999px; border: 1px solid var(--map-ctl-border, var(--line-strong)); background: var(--map-ctl-bg, var(--surface)); color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* the map controls: light tokens by default, the dark set on the dark theme */
:root { --map-ctl-bg: var(--surface); --map-ctl-border: var(--line-strong); --map-ctl-ink: var(--ink); --map-ctl-hover: var(--wash); }
html[data-theme="dark"] { --map-ctl-bg: #132540; --map-ctl-border: #24395a; --map-ctl-ink: #e6edf5; --map-ctl-hover: #1d2d45; }
/* the left column: zoom, fullscreen, near me — 40 x 40 each, 8 px apart; the follow chip alone top-right */
.leaflet-container.mv-map .leaflet-top .leaflet-control, .leaflet-container.pf-map .leaflet-top .leaflet-control { margin-top: 8px; }
.leaflet-container.mv-map .leaflet-left .leaflet-control, .leaflet-container.pf-map .leaflet-left .leaflet-control { margin-left: 8px; }
.leaflet-container.mv-map .leaflet-right .leaflet-control, .leaflet-container.pf-map .leaflet-right .leaflet-control { margin-right: 8px; }
.leaflet-container.mv-map .leaflet-bottom .leaflet-control, .leaflet-container.pf-map .leaflet-bottom .leaflet-control { margin-bottom: 8px; }
.leaflet-container.mv-map .leaflet-bar, .leaflet-container.pf-map .leaflet-bar { border: 1px solid var(--map-ctl-border); border-radius: 8px; overflow: hidden; background: var(--map-ctl-bg); box-shadow: 0 1px 4px rgba(0,0,0,.25); }
.leaflet-container.mv-map .leaflet-bar a, .leaflet-container.pf-map .leaflet-bar a { display: flex; align-items: center; justify-content: center; width: 40px; height: 40px; line-height: 40px; padding: 0;
  background: var(--map-ctl-bg); color: var(--map-ctl-ink); border: 0; border-bottom: 1px solid var(--map-ctl-border); border-radius: 0;
  font: 600 20px/40px inherit; text-decoration: none; }
.leaflet-container.mv-map .leaflet-bar a:last-child, .leaflet-container.pf-map .leaflet-bar a:last-child { border-bottom: 0; }
.leaflet-container.mv-map .leaflet-bar a:hover, .leaflet-container.mv-map .leaflet-bar a:focus-visible, .leaflet-container.pf-map .leaflet-bar a:hover, .leaflet-container.pf-map .leaflet-bar a:focus-visible { background: var(--map-ctl-hover); color: var(--map-ctl-ink); }
.leaflet-container.mv-map .leaflet-bar a.leaflet-disabled, .leaflet-container.pf-map .leaflet-bar a.leaflet-disabled { opacity: .45; background: var(--map-ctl-bg); }
.mv-ctl a svg { display: block; width: 18px; height: 18px; }
.mv-ctl[hidden] { display: none; }
.mv-tools { display: flex; }
.mv-tools .mv-follow .chip-body { height: 40px; box-sizing: border-box; padding: 0 14px; font-size: 13px; border-radius: 8px;
  background: var(--map-ctl-bg); color: var(--map-ctl-ink); border: 1px solid var(--map-ctl-border); box-shadow: 0 1px 4px rgba(0,0,0,.25); }
.mv-tools .mv-follow .chip-body:hover { background: var(--map-ctl-hover); }
.mv-tools .mv-follow input:checked + .chip-body { background: var(--blue); color: var(--on-fill, #fff); border-color: var(--blue); }
/* fullscreen: the legend stays bottom-left, the attribution bottom-right, neither covers the other at 390 px */
.mv-legend { max-width: 46vw; }
.leaflet-container.mv-map .leaflet-control-attribution, .leaflet-container.pf-map .leaflet-control-attribution { max-width: 46vw; font-size: 10px; line-height: 1.3; padding: 2px 6px; border-radius: 6px 0 0 0;
  background: var(--map-ctl-bg); color: var(--muted); }
.leaflet-container.mv-map .leaflet-control-attribution a, .leaflet-container.pf-map .leaflet-control-attribution a { color: var(--brand-text); }
.leaflet-container.mv-map .leaflet-bottom .leaflet-control-attribution { margin: 0; }
html[data-theme="dark"] .mv-legend { background: var(--map-ctl-bg); border-color: var(--map-ctl-border); color: var(--map-ctl-ink); }
.map-fs { position: fixed !important; inset: 0 !important; width: 100vw !important; height: 100vh !important; max-height: none !important;
  border-radius: 0 !important; border: 0 !important; z-index: 3000 !important; margin: 0 !important; }
.map-fs:fullscreen { width: 100% !important; height: 100% !important; }
body.map-fs-open { overflow: hidden; }
/* the CSS fullscreen mode: the sticky top bar and the sidebar must not paint over the map */
body.map-fs-open .topbar, body.map-fs-open .sidebar, body.map-fs-open .guide-home { visibility: hidden; }
.mv-nocoords { margin-left: 8px; font-size: 11.5px; padding: 3px 10px; border-style: dashed; color: var(--amber, #B7791F); }
@media (max-width: 600px) {
  .mv-legend { max-width: 52vw; font-size: 11px; padding: 5px 8px; }
  .mv-map .leaflet-control-attribution, .pf-map .leaflet-control-attribution { max-width: 42vw; }
}

/* --- protocol photos (the mobile app's pictures under an entry) ------- */
.pf-photos { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 2px; }
.pf-photo { display: flex; flex-direction: column; gap: 2px; width: 96px; text-decoration: none; color: var(--muted); font-size: 11px; }
.pf-photo img { width: 96px; height: 72px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); background: var(--wash); }
.pf-photo-cap { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---- in-app guidance (guide app: the "?" drawer, the spotlight tour, teaching empty states, the home-screen banner) ---- */
.help-btn { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px;
  border: 1px solid var(--line-strong); border-radius: 8px; background: var(--surface); color: var(--blue);
  font: 700 16px/1 inherit; cursor: pointer; flex: 0 0 auto; }
.help-btn:hover, .help-btn[aria-expanded="true"] { background: var(--wash); color: var(--blue-dark); }
/* desktop: a side panel next to the page (the page stays usable, "Show me" visible); phone: a bottom sheet with a backdrop */
.guide-backdrop { display: none; position: fixed; inset: 0; z-index: 70; background: rgba(12, 20, 29, 0.35); }
.guide-drawer[hidden], .guide-backdrop[hidden], .guide-home[hidden] { display: none !important; }
.guide-drawer { position: fixed; top: 0; right: 0; bottom: 0; z-index: 71; width: min(420px, 100vw);
  display: flex; flex-direction: column; background: var(--surface); border-left: 1px solid var(--line);
  box-shadow: -12px 0 32px rgba(0,0,0,0.18); }
.guide-head { display: flex; align-items: flex-start; gap: 12px; padding: 18px 20px 12px; border-bottom: 1px solid var(--line); }
.guide-head > div { flex: 1; min-width: 0; }
.guide-kicker { font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; }
.guide-title { margin: 2px 0 0; font-size: 18px; }
.guide-role { font-size: 12.5px; margin-top: 2px; }
.guide-body { flex: 1; overflow: auto; padding: 14px 20px; }
.guide-foot { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 20px; border-top: 1px solid var(--line); }
.guide-steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.guide-step { padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface-2); }
.guide-step-head { display: flex; align-items: center; gap: 10px; }
.guide-step-n { display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; border-radius: 999px;
  background: var(--blue); color: var(--on-fill); font-size: 12.5px; font-weight: 700; flex: 0 0 auto; }
.guide-step-title { font-size: 14px; }
.guide-step-text { margin: 8px 0 10px; font-size: 13.5px; line-height: 1.5; color: var(--ink); }
.guide-show:disabled { opacity: 0.5; cursor: not-allowed; }
.guide-phase { border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 10px; }
.guide-phase-sum { cursor: pointer; padding: 10px 14px; font-weight: 600; list-style: none; }
.guide-phase-sum::-webkit-details-marker { display: none; }
.guide-phase-sum::before { content: "▸"; display: inline-block; width: 16px; color: var(--muted); }
.guide-phase[open] .guide-phase-sum::before { content: "▾"; }
.guide-phase .guide-steps { padding: 0 12px 12px; }
/* "Show me": the pulsing outline on the control */
.guide-hl { outline: 3px solid var(--accent) !important; outline-offset: 4px; border-radius: 6px;
  animation: guide-pulse 1.1s ease-in-out 3; position: relative; z-index: 72; }
@keyframes guide-pulse { 0%, 100% { outline-color: var(--accent); box-shadow: 0 0 0 0 rgba(55,138,221,0.45); }
  50% { outline-color: var(--blue-dark); box-shadow: 0 0 0 10px rgba(55,138,221,0); } }
/* the spotlight tour */
.guide-tour { position: fixed; inset: 0; z-index: 80; }
.guide-spot { position: fixed; border-radius: 8px; box-shadow: 0 0 0 9999px rgba(12, 20, 29, 0.6); pointer-events: none;
  transition: top .2s, left .2s, width .2s, height .2s; }
.guide-spot[hidden] { display: block !important; box-shadow: none; }
.guide-tour:has(.guide-spot[hidden]) { background: rgba(12, 20, 29, 0.6); }
.guide-tour-card { position: fixed; width: min(360px, calc(100vw - 24px)); padding: 16px 18px; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); color: var(--ink); }
.guide-tour-card-sheet { left: 12px !important; right: 12px; width: auto; }
.guide-tour-kicker { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.guide-tour-title { margin: 4px 0 6px; font-size: 16px; }
.guide-tour-text { margin: 0 0 10px; font-size: 13.5px; line-height: 1.5; }
.guide-tour-dots { display: flex; gap: 5px; margin-bottom: 12px; }
.guide-dot { width: 7px; height: 7px; border-radius: 999px; background: var(--line-strong); }
.guide-dot.active { background: var(--blue); }
.guide-tour-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
html.guide-touring { overflow: hidden; }
/* teaching empty states */
.guide-empty-steps { display: inline-block; text-align: left; margin: 10px auto 0; padding-left: 22px; font-size: 13.5px; line-height: 1.6; color: var(--ink); }
.guide-empty-actions { margin-top: 14px; display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.guide-hint { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin: 0 0 12px; padding: 10px 14px;
  border: 1px dashed var(--line-strong); border-radius: var(--radius); background: var(--wash); font-size: 13px; color: var(--ink); }
.guide-note { display: flex; gap: 12px; align-items: flex-start; margin: 0 0 14px; padding: 12px 16px; border-left: 4px solid var(--accent);
  background: var(--wash); border-radius: var(--radius); font-size: 13.5px; }
.guide-note strong { display: block; margin-bottom: 2px; }
/* "How this form works" */
.guide-intro { margin: 0 0 14px; }
.guide-intro-sum { display: flex; align-items: center; gap: 8px; padding: 12px 16px; cursor: pointer; font-weight: 600; list-style: none; color: var(--blue-dark); }
.guide-intro-sum::-webkit-details-marker { display: none; }
.guide-intro-list { margin: 0; padding: 0 18px 14px 36px; font-size: 13.5px; line-height: 1.55; display: flex; flex-direction: column; gap: 6px; }
.guide-intro-reviewer { border-top: 1px dashed var(--line); padding-top: 6px; list-style: none; margin-left: -18px; }
/* the home-screen banner (phones only, static/js/guide.js decides) */
.guide-home { position: fixed; left: 12px; right: 12px; bottom: 12px; z-index: 65; padding: 12px 14px; }
.guide-home-row { display: flex; gap: 12px; align-items: flex-start; }
.guide-home-icon { border-radius: 9px; flex: 0 0 auto; }
.guide-home-copy p { margin: 2px 0 0; font-size: 13px; }
.guide-home-steps { margin-top: 10px; font-size: 13px; }
.guide-home-steps h4 { margin: 8px 0 4px; font-size: 13px; }
.guide-home-steps ol { margin: 0; padding-left: 20px; line-height: 1.5; }
.guide-home-actions { display: flex; gap: 8px; margin-top: 10px; }
/* the /help/ page */
.guide-help-head { align-items: flex-start; }
.guide-help-intro { margin: 4px 0 0; max-width: 720px; }
.guide-help-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 16px; }
.guide-help-role { margin-bottom: 16px; }
.guide-help-page { margin: 18px 0 8px; font-size: 15px; color: var(--blue-dark); }
.guide-help-phase { margin: 10px 0 6px; font-size: 13.5px; color: var(--muted); }
.guide-steps-print .guide-step p { margin: 4px 0 0; font-size: 13.5px; line-height: 1.5; }
@media (max-width: 780px) {
  .guide-drawer { top: auto; left: 0; right: 0; bottom: 0; width: 100vw; max-height: 82vh; border-left: 0; border-top: 1px solid var(--line);
    border-radius: 16px 16px 0 0; box-shadow: 0 -12px 32px rgba(0,0,0,0.22); }
  .guide-head { padding-top: 14px; }
  .guide-head::before { content: ""; position: absolute; top: 6px; left: 50%; width: 40px; height: 4px; margin-left: -20px; border-radius: 999px; background: var(--line-strong); }
  .guide-drawer { position: fixed; }
  .guide-backdrop:not([hidden]) { display: block; }
  html.guide-open { overflow: hidden; }
}
@media print {
  .topbar, .sidebar, .guide-drawer, .guide-backdrop, .guide-home, .guide-print, .guide-help-head .btn, .guide-help-tabs, .toasts { display: none !important; }
  .layout, .content { display: block; padding: 0; }
  .guide-help-role { break-inside: avoid; border: 0; box-shadow: none; padding: 0 0 12px; }
  .guide-step { break-inside: avoid; border: 0; padding: 4px 0; background: transparent; }
  body { background: #fff; color: #000; }
}

/* ---- protocol form, field UX (contractor surveyors on a 390 px phone) ---- */
.pf-cell { flex-direction: column; align-items: stretch; gap: 4px; scroll-margin-top: 140px; }
/* in the column layout the old flex: 1 would collapse the height to the content */
.pf-cell .input, .pf-cell .pf-result, .pf-cell .pf-fixed { flex: 0 0 auto; width: 100%; box-sizing: border-box; }
.pf-cell-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; min-height: 15px; }
.pf-cell-key { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 11px; font-weight: 700; color: var(--muted); letter-spacing: .02em; }
.pf-plain { font-size: 12.5px; color: var(--ink); }
.pf-plain-unit { font-size: 12px; font-weight: 600; color: var(--muted); }
.pf-cell-focus .input { box-shadow: 0 0 0 3px rgba(55,138,221,0.35); }
.pf-section-head { display: flex; align-items: center; gap: 10px; }
.pf-section-title { flex: 1; min-width: 0; }
.pf-progress { font: 600 12px/1 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; padding: 4px 9px; border-radius: 999px; background: var(--amber-bg); color: var(--amber); white-space: nowrap; }
.pf-progress-done { background: var(--ok-bg); color: var(--ok-strong); }
.pf-status { display: flex; align-items: flex-start; gap: 8px; padding: 8px 16px; font-size: 12.5px; line-height: 1.45; border-bottom: 1px solid var(--line); background: var(--surface-2); }
.pf-status-dot { flex: 0 0 auto; width: 10px; height: 10px; border-radius: 999px; margin-top: 4px; background: var(--disabled); }
.pf-status[data-tone="ok"] .pf-status-dot { background: var(--ok); }
.pf-status[data-tone="bad"] .pf-status-dot { background: var(--red); }
.pf-status[data-tone="refer"] .pf-status-dot { background: var(--amber); }
.pf-status[data-tone="ok"] .pf-status-label { color: var(--ok-strong); }
.pf-status[data-tone="bad"] .pf-status-label { color: var(--red); }
.pf-status[data-tone="refer"] .pf-status-label { color: var(--amber); }
.pf-status-rule { color: var(--muted); }
.pf-hp-bar { display: none; }
.pf-photos { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-start; margin-top: 8px; }
.pf-photo-add { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 10px; border: 1px dashed var(--line-strong); border-radius: 8px; cursor: pointer; font-size: 12.5px; color: var(--blue); background: var(--surface); }
.pf-photo-add:hover { background: var(--wash); }
.pf-photo-pending { position: relative; opacity: .9; }
.pf-photo-bar { display: block; height: 4px; margin-top: 4px; border-radius: 2px; background: var(--line); overflow: hidden; }
.pf-photo-bar i { display: block; height: 100%; width: 0; background: var(--blue); transition: width .2s; }
.pf-photo-error .pf-photo-cap { color: var(--red); }
.pf-photo-error .pf-photo-bar i { background: var(--red); width: 100% !important; }
.pf-photo-actions { display: flex; gap: 4px; }
.pf-draft { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 14px; border-left: 4px solid var(--amber); border-radius: var(--radius); background: var(--amber-bg); font-size: 13px; color: var(--ink); }
.pf-draft[hidden] { display: none; }
.pf-dirty-dot { display: none; width: 10px; height: 10px; border-radius: 999px; background: var(--amber); }
.pf-bar-submit { display: none; }
.pf-saving .pf-savebar .btn { opacity: .6; pointer-events: none; }
@media (max-width: 600px) {
  .pf-form { padding-bottom: 112px; }
  .pf-cells { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  .pf-cell { padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
  .pf-cell-result { background: var(--surface-2); }
  .pf-cell-missing { border-color: var(--red-border); background: var(--red-bg); }
  .pf-cell .input, .pf-cell select.input { height: 44px; font-size: 16px; }
  .pf-form .btn, .pf-photo-add, .pf-decision .btn { min-height: 44px; }
  .pf-row { padding: 10px 8px; }
  .pf-label { flex-basis: 100%; }
  .pf-head .meta-grid { grid-template-columns: 1fr; }
  /* sticky section header with the count, under the thin hold-point bar */
  .pf-section .card-title { position: sticky; top: 96px; z-index: 4; background: var(--surface); border-radius: var(--radius) var(--radius) 0 0; }
  .pf-hp-bar { display: flex; align-items: center; gap: 8px; position: sticky; top: 56px; z-index: 6; margin: -8px -14px 12px; padding: 8px 14px; font-size: 12.5px; font-weight: 600; min-height: 40px; }
  .pf-hp-bar-dot { width: 10px; height: 10px; border-radius: 999px; background: currentColor; flex: 0 0 auto; }
  .pf-hp-bar[data-open="0"] { background: var(--ok-bg); color: var(--ok-strong); }
  .pf-hp-bar[data-open="1"] { background: var(--amber-bg); color: var(--amber); }
  #pf-hp-banner { display: none !important; }
  /* the bottom bar: Save and the phase's Submit, with the unsaved dot */
  .pf-savebar { position: fixed; left: 0; right: 0; bottom: 0; margin: 0; border-radius: 0; z-index: 30; padding: 10px 12px; gap: 8px; }
  .pf-savebar .pf-dirty { display: none; }
  .pf-dirty-dot:not([hidden]) { display: inline-block; }
  .pf-bar-submit { display: inline-flex; flex: 1 1 auto; }
  .pf-savebar .btn { flex: 1 1 auto; }
  .pf-phase-foot { display: none; }
  .pf-cell { scroll-margin-top: 150px; }
}
