/* Original dashboard styles, unchanged. Additions for the server-backed version are at the end. */
:root {
  color-scheme: light;
  --surface-1:      #f8f2e2;
  --surface-2:      #fffdf6;
  --page-plane:     #f3ecda;
  --text-primary:   #122a43;
  --text-secondary: #3c5876;
  --text-muted:     #7c8fa3;
  --gridline:       #e2d7ba;
  --baseline-axis:  #c7b98c;
  --border:         rgba(18,42,67,0.14);
  --status-good:     #0ca30c;
  --status-warning:  #fab219;
  --status-serious:  #ec835a;
  --status-critical: #d03b3b;
  --success-text:    #006300;
  --series-1: #1d5c96;
  --cat-1: #2a78d6;
  --cat-2: #eb6834;
  --cat-3: #1baf7a;
  --cat-4: #eda100;
  --cat-5: #e87ba4;
  --cat-6: #008300;
  --cat-7: #4a3aa7;
  --cat-8: #e34948;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --surface-1:      #12385f;
    --surface-2:      #1b4f8c;
    --page-plane:     #081a30;
    --text-primary:   #f6f1e2;
    --text-secondary: #eaf1fa;
    --text-muted:     #b7cbe4;
    --gridline:       #2c5586;
    --baseline-axis:  #3a6193;
    --border:         rgba(246,241,226,0.22);
    --status-good:     #0ca30c;
    --status-warning:  #fab219;
    --status-serious:  #ec835a;
    --status-critical: #e66767;
    --success-text:    #0ca30c;
    --series-1: #5aa3ef;
    --cat-1: #3987e5;
    --cat-2: #d95926;
    --cat-3: #199e70;
    --cat-4: #c98500;
    --cat-5: #d55181;
    --cat-6: #008300;
    --cat-7: #9085e9;
    --cat-8: #e66767;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --surface-1:      #12385f;
  --surface-2:      #1b4f8c;
  --page-plane:     #081a30;
  --text-primary:   #f6f1e2;
  --text-secondary: #eaf1fa;
  --text-muted:     #b7cbe4;
  --gridline:       #2c5586;
  --baseline-axis:  #3a6193;
  --border:         rgba(246,241,226,0.22);
  --status-good:     #0ca30c;
  --status-warning:  #fab219;
  --status-serious:  #ec835a;
  --status-critical: #e66767;
  --success-text:    #0ca30c;
  --series-1: #5aa3ef;
  --cat-1: #3987e5;
  --cat-2: #d95926;
  --cat-3: #199e70;
  --cat-4: #c98500;
  --cat-5: #d55181;
  --cat-6: #008300;
  --cat-7: #9085e9;
  --cat-8: #e66767;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  background: var(--page-plane);
  color: var(--text-primary);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}
body { padding: 0 16px 48px; }
.wrap { max-width: 1100px; margin: 0 auto; }

/* theme toggle */
.theme-toggle {
  position: fixed; top: 14px; right: 16px; z-index: 50;
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 999px; padding: 4px 8px; cursor: pointer;
  box-shadow: 0 1px 6px rgba(0,0,0,0.10);
  font-family: inherit;
}
.theme-toggle .icon { font-size: 0.72rem; color: var(--text-muted); line-height: 1; }
.theme-toggle .track {
  position: relative; width: 40px; height: 22px; border-radius: 999px;
  background: var(--gridline); transition: background .2s ease;
}
.theme-toggle.on .track { background: var(--series-1); }
.theme-toggle .thumb {
  position: absolute; top: 2px; left: 2px; width: 18px; height: 18px;
  border-radius: 50%; background: var(--surface-2);
  box-shadow: 0 1px 2px rgba(0,0,0,0.3); transition: left .2s ease;
}
.theme-toggle.on .thumb { left: 20px; }

/* role bar */
.role-cluster {
  position: fixed; top: 14px; left: 16px; z-index: 50;
  display: none; align-items: center; gap: 10px;
}
.role-bar {
  display: inline-flex; align-items: center; gap: 10px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 999px; padding: 6px 8px 6px 14px;
  box-shadow: 0 1px 6px rgba(0,0,0,0.10);
  font-size: 0.78rem; color: var(--text-secondary);
}
.role-bar .role-name { font-weight: 700; color: var(--text-primary); }
.role-bar .role-logout {
  border: none; background: var(--surface-1); color: var(--text-secondary);
  font-size: 0.74rem; padding: 5px 10px; border-radius: 999px; cursor: pointer; font-family: inherit;
}
.role-bar .role-logout:hover { color: var(--text-primary); }

.edit-toggle {
  display: none; align-items: center; gap: 6px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 999px; padding: 6px 14px;
  font-size: 0.78rem; font-weight: 600; color: var(--text-secondary);
  cursor: pointer; font-family: inherit;
  box-shadow: 0 1px 6px rgba(0,0,0,0.10);
}
.edit-toggle .pencil { font-size: 0.85rem; line-height: 1; }
.edit-toggle:hover { color: var(--text-primary); }
.edit-toggle.on { background: var(--series-1); border-color: var(--series-1); color: #fff; }

/* login overlay */
.login-overlay {
  position: fixed; inset: 0; background: var(--page-plane);
  display: flex; align-items: center; justify-content: center; z-index: 100; padding: 16px;
}
.login-card {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 16px;
  padding: 28px 26px; width: 100%; max-width: 340px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.18);
  display: flex; flex-direction: column; gap: 14px;
}
.login-icon { font-size: 1.8rem; text-align: center; }
.login-card h2 { margin: 0; font-size: 1.05rem; text-align: center; color: var(--text-primary); }
.login-mock-note { font-size: 0.72rem; color: var(--text-muted); text-align: center; margin: 0; line-height: 1.4; }
.login-field { display: flex; flex-direction: column; gap: 4px; font-size: 0.8rem; color: var(--text-secondary); }
.login-field select, .login-field input {
  font-family: inherit; font-size: 0.88rem; padding: 8px 10px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface-1); color: var(--text-primary);
}
.login-submit {
  margin-top: 4px; padding: 10px; border: none; border-radius: 8px;
  background: var(--series-1); color: #fff; font-weight: 700; font-size: 0.88rem; cursor: pointer;
}
.login-submit:hover { opacity: 0.9; }
a.login-submit { display: block; text-align: center; text-decoration: none; }
.login-error { color: var(--status-critical); font-size: 0.78rem; text-align: center; margin: 0; font-weight: 600; }

/* user management (admin) */
.users-overlay { z-index: 110; background: color-mix(in srgb, var(--page-plane) 88%, transparent); }
.users-card { max-width: 900px; max-height: 90vh; overflow: auto; }
.users-hint { margin: 0; font-size: 0.78rem; color: var(--text-muted); text-align: center; line-height: 1.4; }
.users-table select {
  font-family: inherit; font-size: 0.8rem; padding: 4px 6px; border-radius: 6px;
  border: 1px solid var(--border); background: var(--surface-1); color: var(--text-primary);
}
.users-table input[type="checkbox"] { cursor: pointer; }
.users-table select:disabled, .users-table input:disabled { opacity: 0.55; cursor: not-allowed; }

/* drag-and-drop reordering (admin + edit mode) */
.sortable-block { position: relative; }
.drag-handle {
  display: none; position: absolute; top: 6px; right: 6px; z-index: 5;
  cursor: grab; font-size: 0.85rem; line-height: 1; color: var(--text-muted);
  background: var(--surface-1); border: 1px solid var(--border); border-radius: 6px; padding: 3px 7px;
  user-select: none;
}
.drag-handle:active { cursor: grabbing; }
body.edit-mode .drag-handle { display: inline-flex; }
.sortable-block.dragging { opacity: 0.4; }
#kpi-grid.sortable-block, .decision-row.sortable-block { padding-top: 0; }
body.edit-mode #kpi-grid { padding-top: 30px; }
body.edit-mode .decision-row { padding-top: 26px; }
body.edit-mode .decision-row > .drag-handle { top: -22px; right: 0; }
body.edit-mode details.qa-row .drag-handle { position: static; display: inline-flex; top: auto; right: auto; }
.delete-handle {
  display: none; position: absolute; top: 6px; right: 38px; z-index: 5;
  cursor: pointer; font-size: 0.8rem; line-height: 1; color: var(--status-critical);
  background: var(--surface-1); border: 1px solid var(--border); border-radius: 6px; padding: 3px 7px;
}
.delete-handle:hover { background: var(--status-critical); color: #fff; border-color: var(--status-critical); }
body.edit-mode .delete-handle { display: inline-flex; }
body.edit-mode .decision-row > .delete-handle { top: -22px; right: 34px; }
body.edit-mode details.qa-row .delete-handle { position: static; display: inline-flex; top: auto; right: auto; margin-right: 6px; }

/* formatting toolbar (admin + edit mode) */
.fmt-toolbar {
  display: none; position: fixed; top: 0; left: 0; right: 0; z-index: 60;
  background: var(--surface-2); border-bottom: 1px solid var(--border);
  padding: 6px 16px; gap: 8px; align-items: center; flex-wrap: wrap;
  box-shadow: 0 1px 6px rgba(0,0,0,0.10);
}
body.edit-mode .fmt-toolbar { display: flex; }
body.edit-mode { padding-top: 46px; }
body.edit-mode .role-cluster, body.edit-mode .theme-toggle { top: 52px; }
.fmt-toolbar select, .fmt-toolbar button {
  font-family: inherit; font-size: 0.8rem; padding: 5px 10px; border-radius: 6px;
  border: 1px solid var(--border); background: var(--surface-1); color: var(--text-primary); cursor: pointer;
}
.fmt-toolbar button:hover { background: var(--series-1); color: #fff; }
.fmt-toolbar button#fmt-style-painter.armed { background: var(--series-1); color: #fff; }

/* admin editing */
[contenteditable="true"].ef {
  border-radius: 4px; outline: 1px dashed transparent; cursor: text;
  transition: outline-color .15s ease, background .15s ease;
}
[contenteditable="true"].ef:hover, [contenteditable="true"].ef:focus {
  outline-color: var(--series-1); outline-style: dashed;
  background: color-mix(in srgb, var(--series-1) 12%, transparent);
}

header.page-head {
  padding: 28px 0 16px;
  border-bottom: 1px solid var(--gridline);
  margin-bottom: 20px;
  text-align: center;
}
.overall-badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 12px; border-radius: 999px;
  font-size: 0.82rem; font-weight: 700;
  background: var(--status-critical);
  color: #ffffff;
  margin-bottom: 10px;
}
.overall-badge .dot { background: #ffffff; }
.title-row {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 16px;
  margin-top: 6px;
}
h1 { font-size: 1.7rem; margin: 0; text-align: center; white-space: nowrap; }
.title-icon { color: var(--series-1); line-height: 0; }
.title-icon.left { justify-self: end; }
.title-icon.right { justify-self: start; }
.title-icon svg { display: block; height: 44px; width: auto; }

.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.dot.good { background: var(--status-good); }
.dot.warning { background: var(--status-warning); }
.dot.critical { background: var(--status-critical); }

nav.tabs {
  display: flex; justify-content: space-between; flex-wrap: nowrap; overflow-x: auto;
  margin-bottom: 20px; border-bottom: 1px solid var(--gridline);
}
nav.tabs button {
  appearance: none; border: none; background: none; cursor: pointer;
  padding: 8px 6px; font-size: 0.72rem; font-weight: 500;
  color: var(--text-secondary); white-space: nowrap;
  border-bottom: 2px solid transparent;
  font-family: inherit;
  flex: 0 0 auto;
}
nav.tabs button:hover { color: var(--text-primary); }
nav.tabs button.active {
  color: var(--series-1);
  border-bottom-color: var(--series-1);
}

section.tabpanel { display: none; }
section.tabpanel.active { display: block; animation: fade .15s ease; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

h2.section-title { font-size: 1.1rem; margin: 28px 0 12px; }
h2.section-title:first-child { margin-top: 0; }
p.section-note { color: var(--text-muted); font-size: 0.8rem; margin: -6px 0 14px; }

/* KPI cards */
.kpi-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}
.kpi-card {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 12px; padding: 14px 16px;
  border-left: 4px solid var(--status-critical);
}
.kpi-card.status-warning { border-left-color: var(--status-warning); }
.kpi-card.status-good { border-left-color: var(--status-good); }
.kpi-card .kpi-head { display: flex; justify-content: space-between; align-items: center; }
.kpi-card .kpi-title { font-weight: 600; font-size: 0.92rem; }
.kpi-card .kpi-detail {
  margin-top: 8px; font-size: 0.83rem; color: var(--text-secondary); line-height: 1.5;
}

.focus-list { background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 16px 18px; margin-top: 16px; }
.focus-list ol { margin: 8px 0 0; padding-left: 20px; font-size: 0.88rem; line-height: 1.6; color: var(--text-secondary); }

/* table */
table.data-table { width: 100%; border-collapse: collapse; font-size: 0.83rem; background: var(--surface-2); border-radius: 10px; overflow: hidden; border: 1px solid var(--border); }
table.data-table th, table.data-table td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--gridline); vertical-align: top; }
table.data-table th { color: var(--text-muted); font-weight: 600; font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.02em; background: var(--surface-1); }
table.data-table tr:last-child td { border-bottom: none; }
table.data-table tbody tr:hover { background: var(--surface-1); }

.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 999px; font-size: 0.76rem; font-weight: 700; white-space: nowrap; }
.badge.critical { background: var(--status-critical); color: #ffffff; }
.badge.warning  { background: var(--status-warning); color: #3a2600; }
.badge.good     { background: var(--status-good); color: #ffffff; }
.badge.neutral  { background: var(--surface-1); color: var(--text-secondary); border: 1px solid var(--border); }

.view-toggle { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; margin-bottom: 12px; }
.view-toggle button { appearance: none; border: none; background: var(--surface-2); color: var(--text-secondary); font-size: 0.78rem; padding: 6px 12px; cursor: pointer; font-family: inherit; }
.view-toggle button.active { background: var(--series-1); color: #fff; }

/* timeline */
.timeline-wrap { background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 18px 20px 10px; }
.timeline-axis { position: relative; height: 20px; margin-left: 230px; border-bottom: 1px solid var(--gridline); font-size: 0.7rem; color: var(--text-muted); }
.timeline-axis span { position: absolute; transform: translateX(-50%); bottom: 4px; }
.timeline-row { display: flex; align-items: center; height: 34px; }
.timeline-label { width: 230px; flex-shrink: 0; font-size: 0.8rem; color: var(--text-secondary); padding-right: 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.timeline-track { position: relative; flex: 1; height: 100%; border-bottom: 1px dashed var(--gridline); }
.tl-bar { position: absolute; top: 50%; height: 6px; transform: translateY(-50%); border-radius: 3px; }
.tl-marker { position: absolute; top: 50%; width: 10px; height: 10px; border-radius: 50%; transform: translate(-50%, -50%); border: 2px solid var(--surface-2); cursor: pointer; }
.tl-marker.baseline { background: var(--text-muted); width: 8px; height: 8px; }
.tl-unknown { position: absolute; top: 50%; transform: translateY(-50%); font-size: 0.72rem; color: var(--text-muted); }
.timeline-legend { display: flex; gap: 16px; flex-wrap: wrap; margin: 14px 0 4px; font-size: 0.76rem; color: var(--text-secondary); }
.timeline-legend .item { display: flex; align-items: center; gap: 6px; }
.legend-swatch { width: 10px; height: 10px; border-radius: 50%; }

/* risk matrix */
.matrix-wrap { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; align-items: start; }
@media (max-width: 760px) { .matrix-wrap { grid-template-columns: 1fr; } }
.matrix { display: grid; grid-template-columns: 22px 70px repeat(2, 1fr); grid-template-rows: 22px 22px repeat(2, 110px); gap: 4px; }
.matrix .x-title { font-size: 0.72rem; color: var(--text-muted); display: flex; align-items: center; justify-content: center; }
.matrix .y-title { font-size: 0.72rem; color: var(--text-muted); display: flex; align-items: center; justify-content: center; writing-mode: vertical-rl; transform: rotate(180deg); }
.matrix .col-tick, .matrix .row-tick { font-size: 0.72rem; color: var(--text-muted); font-weight: 600; display: flex; align-items: center; justify-content: center; text-align: center; }
.matrix-cell { background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 6px; display: flex; flex-wrap: wrap; align-content: flex-start; gap: 5px; }
.risk-chip { border: none; cursor: pointer; font-size: 0.72rem; font-weight: 700; color: #fff; padding: 4px 7px; border-radius: 6px; font-family: inherit; }
.risk-chip.critical { background: var(--status-critical); }
.risk-chip.warning { background: var(--status-warning); color: #4a3300; }
.risk-chip.good { background: var(--status-good); }
.risk-chip.selected { outline: 2px solid var(--series-1); outline-offset: 1px; }

.risk-detail-panel { background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 16px 18px; font-size: 0.85rem; color: var(--text-secondary); line-height: 1.55; min-height: 140px; }
.risk-detail-panel h3 { margin: 0 0 4px; color: var(--text-primary); font-size: 0.98rem; }
.risk-detail-panel .meta-row { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0; }
.risk-detail-panel .placeholder { color: var(--text-muted); }

.filter-row { display: flex; gap: 10px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }
.filter-row select, .filter-row input[type="text"] {
  font-family: inherit; font-size: 0.8rem; padding: 6px 10px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text-primary);
}
.filter-row input[type="text"] { min-width: 150px; }
.filter-row input[type="text"]::placeholder { color: var(--text-muted); }
.filter-row label { font-size: 0.78rem; color: var(--text-muted); }

details.qa-row { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; margin-bottom: 8px; padding: 10px 14px; }
details.qa-row summary { cursor: pointer; font-size: 0.86rem; display: flex; justify-content: space-between; gap: 10px; align-items: center; list-style: none; }
details.qa-row summary::-webkit-details-marker { display: none; }
details.qa-row summary .q-left { display: flex; align-items: center; gap: 8px; min-width: 0; }
details.qa-row summary .q-chevron { flex-shrink: 0; color: var(--text-secondary); font-size: 2.1rem; line-height: 0.6; font-weight: 700; transition: transform .15s ease; }
details.qa-row[open] summary .q-chevron { transform: rotate(180deg); }
details.qa-row summary .q-text { font-weight: 600; }
details.qa-row .q-body { margin-top: 10px; font-size: 0.82rem; color: var(--text-secondary); line-height: 1.55; }
details.qa-row .q-meta { display: flex; gap: 14px; flex-wrap: wrap; font-size: 0.76rem; color: var(--text-muted); margin-top: 8px; }

/* decisions */
.decision-row { display: grid; grid-template-columns: 250px 1fr 1fr; gap: 12px; margin-bottom: 12px; }
@media (max-width: 960px) { .decision-row { grid-template-columns: 1fr; } }
.decision-card { background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; display: flex; flex-direction: column; height: 100%; }
.decision-card.decision-left { justify-content: center; gap: 42px; }
.decision-card.decision-left > * { margin: 0; }
.decision-card .tile-title { font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); margin-bottom: 10px; }
.decision-card .d-id-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.decision-card .d-id { font-size: 0.72rem; font-weight: 700; color: var(--series-1); background: var(--surface-1); padding: 2px 9px; border-radius: 999px; }
.decision-card .d-topic { font-size: 0.95rem; font-weight: 700; line-height: 1.35; }
.decision-card .d-owner { font-size: 0.78rem; color: var(--text-muted); }
.decision-options .opt { display: flex; gap: 8px; margin-bottom: 10px; align-items: flex-start; }
.decision-options .opt:last-child { margin-bottom: 0; }
.decision-options .opt-label { flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px; border-radius: 50%; background: var(--series-1); color: #fff; font-size: 0.72rem; font-weight: 700; }
.decision-options .opt-text { font-size: 0.85rem; color: var(--text-secondary); line-height: 1.5; }
.decision-opts .tile-body { flex: 1; display: flex; flex-direction: column; justify-content: center; gap: 54px; }
.decision-opts .tile-body .opt { margin-bottom: 0; }

.empty-state {
  background: var(--surface-2); border: 1px dashed var(--border); border-radius: 12px;
  padding: 30px 24px; text-align: center; color: var(--text-secondary);
}
.empty-state .icon { font-size: 1.6rem; margin-bottom: 8px; }
.empty-state h3 { margin: 0 0 6px; color: var(--text-primary); font-size: 1rem; }
.empty-state p { font-size: 0.85rem; max-width: 520px; margin: 0 auto 4px; line-height: 1.55; }
.empty-state code { background: var(--surface-1); padding: 1px 6px; border-radius: 4px; font-size: 0.8rem; }

.skeleton-table th { opacity: 0.6; }
.skeleton-table td.sk { color: var(--text-muted); font-style: italic; }

/* live stats (Jira/SM) */
.live-source { font-size: 0.76rem; color: var(--text-muted); margin: -8px 0 16px; }
.caveat-box { background: var(--surface-2); border: 1px dashed var(--border); border-radius: 10px; padding: 12px 14px; font-size: 0.8rem; color: var(--text-secondary); line-height: 1.5; margin-top: 16px; }

/* pie charts */
.pie-row { display: flex; gap: 24px; flex-wrap: wrap; margin-bottom: 18px; }
.pie-chart-block { flex: 1; min-width: 320px; }
.pie-visual { position: relative; aspect-ratio: 460 / 280; }
.pie-visual svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.pie-labels { position: absolute; inset: 0; }
.pie-label {
  position: absolute; font-size: 0.68rem; line-height: 1.25; color: var(--text-secondary);
  max-width: 120px; border-radius: 3px;
}
.pie-label.anchor-start { text-align: left; }
.pie-label.anchor-end { text-align: right; }
.pie-label-handle { display: none; cursor: move; font-size: 0.65rem; color: var(--text-muted); margin-right: 3px; }
body.edit-mode .pie-label-handle { display: inline-block; }
body.edit-mode .pie-label { outline: 1px dashed transparent; border-radius: 3px; }
body.edit-mode .pie-label:hover { outline-color: var(--series-1); }
.pie-count-table { width: 100%; border-collapse: collapse; font-size: 0.82rem; margin-top: 14px; }
.pie-count-table th, .pie-count-table td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--gridline); }
.pie-count-table th { color: var(--text-muted); font-weight: 600; font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.02em; }
.pie-count-table td.pie-count-cell { text-align: right; font-weight: 600; color: var(--text-primary); }
.pie-count-table th.pie-count-cell { text-align: right; }
.pie-count-table tr.pie-total-row td { border-bottom: none; border-top: 2px solid var(--border); font-weight: 700; }
.pie-count-table .pie-swatch { width: 10px; height: 10px; border-radius: 3px; display: inline-block; margin-right: 6px; vertical-align: middle; }
.pie-count-table input[type="checkbox"] { cursor: pointer; }
.pie-selected-sum { font-size: 0.82rem; color: var(--text-secondary); margin: 8px 0 0; }

/* files tab */
.file-row { display: flex; align-items: center; gap: 10px; padding: 9px 12px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; margin-bottom: 6px; }
.file-row .file-icon { flex-shrink: 0; }
.file-row .file-name { flex: 1; cursor: pointer; color: var(--series-1); text-decoration: underline; font-size: 0.88rem; word-break: break-all; }
.file-row .file-name:hover { opacity: 0.8; }
.file-row .file-size { font-size: 0.76rem; color: var(--text-muted); flex-shrink: 0; }
.file-row .file-delete { border: none; background: var(--surface-1); color: var(--status-critical); border-radius: 6px; padding: 3px 7px; cursor: pointer; flex-shrink: 0; }

/* dynamic tab / block creation (admin + edit mode) */
.tab-add-btn { display: none; font-size: 0.9rem; font-weight: 700; padding: 8px 12px; }
body.edit-mode .tab-add-btn { display: inline-flex; align-items: center; justify-content: center; }
.add-block-btn {
  display: none; margin-top: 10px; font-family: inherit; font-size: 0.82rem; font-weight: 600;
  padding: 8px 14px; border-radius: 8px; border: 1px dashed var(--border);
  background: var(--surface-2); color: var(--series-1); cursor: pointer;
}
body.edit-mode .add-block-btn { display: inline-flex; align-items: center; }
.add-block-btn:hover { background: var(--series-1); color: #fff; border-style: solid; }

footer.page-foot { margin-top: 40px; padding-top: 16px; border-top: 1px solid var(--gridline); font-size: 0.75rem; color: var(--text-muted); line-height: 1.6; }
footer.page-foot b { color: var(--text-secondary); }

/* ---------- additions for the server-backed version ---------- */

/* the overall badge follows the status stored in the content */
.overall-badge.status-warning { background: var(--status-warning); color: #3a2600; }
.overall-badge.status-warning .dot { background: #3a2600; }
.overall-badge.status-good { background: var(--status-good); }

/* "refresh now" button in the live data source line (admin only) */
.live-source button {
  margin-left: 8px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text-secondary);
  font-size: 0.72rem; padding: 3px 10px; border-radius: 999px; cursor: pointer; font-family: inherit;
}
.live-source button:hover { color: var(--text-primary); }
.live-source button:disabled { opacity: 0.6; cursor: default; }
.live-source .source-error { color: var(--status-critical); }

/* a block removed with the delete button stays in the page, hidden, so the
   renderers and the stored block order keep working */
.sortable-block.deleted-block { display: none; }

/* a table inserted from the formatting toolbar: its look comes from here, the
   stored text keeps only the size it was dragged to */
.ef .resizable-table-wrap {
  display: inline-block; resize: both; overflow: auto; vertical-align: top;
  border: 1px solid var(--border); min-width: 160px; min-height: 70px; max-width: 100%;
}
.ef table { width: 100%; height: 100%; border-collapse: collapse; }
.ef td, .ef th { border: 1px solid var(--border); padding: 6px; min-width: 40px; text-align: left; }

/* the upload button while files are being sent */
#file-upload-btn:disabled { opacity: 0.6; cursor: default; }

/* save / error feedback */
.toast {
  position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); z-index: 120;
  display: none; background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px;
  padding: 8px 16px; font-size: 0.8rem; color: var(--text-primary);
  box-shadow: 0 2px 10px rgba(0,0,0,0.18);
}
.toast.show { display: block; }
.toast.error { border-color: var(--status-critical); color: var(--status-critical); font-weight: 600; }
