:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --text: #1f2933;
  --muted: #667483;
  --line: #dfe4ea;
  --accent: #1f5eff;
  --accent-soft: #eef3ff;
  --danger: #b42318;
  --danger-soft: #fff0ee;
  --success: #267542;
  --success-soft: #edf8f0;
  --warning: #956800;
  --warning-soft: #fff5df;
  --shadow: 0 2px 10px rgba(20, 30, 45, .06);
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.45 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
button, input, textarea, select { font: inherit; }
button { border: 0; border-radius: 7px; padding: 9px 13px; cursor: pointer; background: #edf1f5; color: var(--text); }
button:hover:not(:disabled) { filter: brightness(.98); }
button:disabled, input:disabled, textarea:disabled, select:disabled { cursor: not-allowed; opacity: .66; }
button.primary { background: var(--accent); color: #fff; font-weight: 650; }
button.danger { background: var(--danger-soft); color: var(--danger); font-weight: 650; }
button.ghost { background: #fff; border: 1px solid var(--line); }
button.small-btn { padding: 6px 9px; font-size: 12px; }
button.full { width: 100%; }
.hidden { display: none !important; }
.muted, .hint { color: var(--muted); }
.hint { font-size: 12px; }
.eyebrow { color: var(--accent); font-size: 11px; font-weight: 800; letter-spacing: .09em; }
label { display: block; margin: 11px 0 5px; font-weight: 650; color: #34404c; }

.topbar { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 16px 28px; background: #17212b; color: #fff; }
.brand-title { font-size: 18px; font-weight: 720; margin-top: 3px; }
.top-actions { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.top-actions .ghost { background: transparent; color: #fff; border-color: #465463; }
.status-pill, .user-badge { padding: 6px 9px; border-radius: 18px; background: rgba(255,255,255,.09); font-size: 12px; }
.status-pill { color: #9fe0ae; }

.projectbar { display: flex; justify-content: space-between; align-items: end; gap: 18px; padding: 14px 28px; background: #fff; border-bottom: 1px solid var(--line); }
.project-picker { min-width: min(680px, 58vw); max-width: 820px; }
.project-picker .label { display: block; color: var(--muted); font-size: 11px; font-weight: 800; margin-bottom: 5px; text-transform: uppercase; letter-spacing: .06em; }
#projectSelect { min-height: 44px; font-size: 15px; font-weight: 750; border-color: #aeb9c5; box-shadow: 0 2px 7px rgba(20,30,45,.05); }
.project-picker-details { display: grid; grid-template-columns: auto minmax(0,1fr); gap: 8px 12px; align-items: baseline; margin-top: 6px; padding: 0 2px; }
.project-picker-details strong { color: var(--accent); font-size: 12px; }
.project-picker-details span { color: #52606d; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.project-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.nav { display: flex; gap: 4px; overflow: auto; padding: 0 28px; background: #fff; border-bottom: 1px solid var(--line); }
.nav button { background: transparent; border-radius: 0; border-bottom: 3px solid transparent; padding: 14px 11px; color: #52606d; white-space: nowrap; }
.nav button.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 700; }
.nav .admin-only { display: none; }
.nav .admin-only:not(.hidden) { display: block; }

.container { max-width: 1500px; margin: 0 auto; padding: 24px; }
.tab { display: none; }
.tab.active { display: block; }
.tab.admin-only.active:not(.hidden) { display: block; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; margin-bottom: 18px; }
.view-head { position: relative; background: linear-gradient(90deg, #fff, #f8fafc); border: 1px solid var(--line); border-radius: 11px; padding: 16px 18px 15px 22px; box-shadow: 0 3px 12px rgba(20,30,45,.045); overflow: hidden; }
.view-head::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 5px; background: var(--accent); }
.page-head h2 { margin: 0 0 7px; font-size: 28px; line-height: 1.15; letter-spacing: -.02em; }
.project-context { display: flex; flex-wrap: wrap; gap: 8px 20px; color: var(--muted); font-size: 13px; }
.project-context strong { color: var(--text); }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); padding: 18px; margin-bottom: 16px; }
.section-title { display: flex; justify-content: space-between; align-items: center; gap: 15px; margin-bottom: 12px; }
.section-title h2, .section-title h3 { margin: 0; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 22px; }
.form-grid.three { grid-template-columns: 1fr 1fr 1fr; }
.form-grid.four { grid-template-columns: repeat(4, 1fr); }
input, textarea, select { width: 100%; border: 1px solid #cfd6de; background: #fff; border-radius: 7px; padding: 9px 10px; outline: none; color: var(--text); }
input:focus, textarea:focus, select:focus { border-color: #86a7ff; box-shadow: 0 0 0 3px rgba(31,94,255,.08); }
textarea { min-height: 78px; resize: vertical; }

.logo-editor { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.logo-preview-wrap { min-height: 58px; display: flex; align-items: center; margin: 6px 0 10px; }
.logo-preview { max-width: 210px; max-height: 78px; object-fit: contain; border: 1px solid var(--line); border-radius: 6px; padding: 6px; background: #fff; }
.logo-editor input[type=file] { margin: 5px 0 8px; }

.savebar { position: sticky; bottom: 12px; background: rgba(255,255,255,.98); border: 1px solid var(--line); box-shadow: 0 5px 20px rgba(20,30,45,.12); border-radius: 10px; padding: 11px 14px; display: flex; justify-content: space-between; align-items: center; gap: 15px; z-index: 5; }
.savebar > div { display: flex; align-items: center; gap: 10px; }
.save-state { padding: 6px 10px; border-radius: 20px; background: var(--success-soft); color: var(--success); font-size: 12px; font-weight: 650; }
.save-state.dirty { background: var(--warning-soft); color: var(--warning); }
.save-state.saving { background: var(--accent-soft); color: #3158a7; }
.save-state.error-state { background: var(--danger-soft); color: var(--danger); }

.setup-grid { display: grid; grid-template-columns: 300px minmax(0,1fr); gap: 16px; }
.position-list { min-height: 400px; }
.position-item { width: 100%; display: grid; grid-template-columns: minmax(0,1fr) auto; align-items: stretch; background: #f7f9fb; border: 1px solid transparent; border-radius: 8px; margin-bottom: 7px; overflow: hidden; }
.position-item.selected { background: var(--accent-soft); border-color: #a9c0ff; color: #1848b8; }
.position-select { min-width: 0; display: flex; align-items: center; gap: 9px; text-align: left; background: transparent; padding: 9px 8px 9px 10px; }
.position-order { flex: 0 0 25px; height: 25px; display: grid; place-items: center; border-radius: 50%; background: #e5eaf0; color: #52606d; font-size: 11px; font-weight: 800; }
.position-item.selected .position-order { background: #fff; color: #1848b8; }
.position-label { min-width: 0; display: flex; flex-direction: column; }
.position-label strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.position-label small { margin-top: 2px; color: var(--muted); font-size: 10px; font-weight: 650; }
.position-reorder { display: grid; grid-template-columns: 28px 28px; gap: 3px; align-content: center; padding: 5px 6px 5px 2px; }
.position-reorder button { padding: 4px 0; min-width: 28px; border: 1px solid #d3dae2; background: #fff; font-weight: 900; line-height: 1; }
.assignment { border: 1px solid var(--line); border-radius: 8px; padding: 13px; margin: 10px 0; background: #fbfcfd; }
.assignment-top { display: flex; align-items: center; gap: 12px; }
.assignment-top strong { flex: 1; }
.assignment .percent { font-weight: 700; }
.check { display: flex; align-items: center; gap: 7px; font-weight: 500 !important; margin: 0; }
.check input, .active-toggle input { width: auto; }
.assignment-head { margin-top: 18px; padding-top: 12px; border-top: 1px solid var(--line); display: flex; justify-content: space-between; gap: 14px; }
.milestone-row { display: grid; grid-template-columns: 120px 1fr; gap: 12px; align-items: center; margin-top: 9px; }
.stage-row { display: grid; grid-template-columns: 35px 1fr auto; gap: 10px; align-items: center; border: 1px solid var(--line); padding: 10px; border-radius: 8px; margin: 7px 0; }
.stage-row > div:nth-child(2) { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.order { font-weight: 700; color: var(--muted); text-align: center; }

.table-scroll { overflow: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { border-bottom: 1px solid var(--line); padding: 10px; text-align: left; vertical-align: top; }
.matrix th, .matrix td { white-space: nowrap; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 16px; }
.kpi span { display: block; color: var(--muted); font-size: 12px; }
.kpi strong { display: block; font-size: 20px; margin-top: 5px; overflow-wrap: anywhere; }
.bar { height: 8px; background: #e9edf2; border-radius: 20px; overflow: hidden; flex: 1; }
.bar i { display: block; height: 100%; background: var(--accent); border-radius: 20px; }
.timeline-row, .metric { display: flex; align-items: center; gap: 10px; margin: 13px 0; }
.timeline-row > span, .metric > span { width: 150px; }
.timeline-row b, .metric b { width: 48px; text-align: right; }
.tag { display: inline-block; padding: 4px 7px; background: #f0f3f6; border-radius: 12px; font-size: 12px; white-space: nowrap; }
.alert { padding: 11px 14px; border: 1px solid #f2c7c2; background: #fff5f3; color: #8a261d; border-radius: 8px; margin-bottom: 12px; }
.alert ul { margin: 7px 0 0 18px; padding: 0; }
.success-box { padding: 11px 14px; border: 1px solid #c7e4cf; background: var(--success-soft); color: var(--success); border-radius: 8px; margin-bottom: 12px; }

.delivery-controls { display: grid; grid-template-columns: minmax(260px,1fr) minmax(180px,240px) auto; align-items: end; gap: 16px; }
.delivery-actions { display: flex; align-items: end; }
.workflow-step { display: grid; grid-template-columns: 42px 1fr; gap: 14px; padding: 15px 0; border-bottom: 1px solid var(--line); }
.workflow-step:last-child { border-bottom: 0; }
.workflow-index { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: #edf1f5; font-weight: 800; color: #52606d; }
.workflow-main { min-width: 0; }
.workflow-top { display: flex; justify-content: space-between; gap: 12px; align-items: center; margin-bottom: 9px; }
.workflow-meta { display: flex; gap: 10px 18px; flex-wrap: wrap; margin-top: 8px; color: var(--muted); font-size: 12px; }
.workflow-description { margin-top: 8px; color: #465463; }
.workflow-warning { margin-top: 8px; color: var(--danger); font-size: 12px; font-weight: 650; }
.unified-report .workflow-warning { color: #6d5200; background: var(--warning-soft); border-left: 3px solid #d7aa34; padding: 7px 9px; border-radius: 5px; }
.workflow-step.overdue .workflow-index { background: var(--danger-soft); color: var(--danger); }
.workflow-step.completed .workflow-index { background: var(--success-soft); color: var(--success); }
.workflow-step.in-progress .workflow-index { background: var(--accent-soft); color: #1848b8; }
.workflow-step.not-relevant { opacity: .62; }

.report-page { background: #fff; min-height: 800px; padding: 38px; box-shadow: var(--shadow); border: 1px solid var(--line); }
.report-head { display: flex; justify-content: space-between; gap: 24px; border-bottom: 2px solid var(--text); padding-bottom: 20px; }
.report-head h1 { font-size: 30px; margin: 4px 0; }
.report-logo { max-width: 190px; max-height: 70px; object-fit: contain; margin-bottom: 15px; }
.report-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin: 24px 0; }
.report-summary div { padding: 16px; background: #f6f8fa; }
.report-summary span { display: block; color: var(--muted); }
.report-summary strong { font-size: 21px; overflow-wrap: anywhere; }

.admin-grid { display: grid; grid-template-columns: 1.25fr .75fr; gap: 16px; }
.role-help { display: grid; grid-template-columns: repeat(4,1fr); gap: 8px; margin: 0 0 15px; }
.role-help div { padding: 10px; background: #f7f9fb; border: 1px solid var(--line); border-radius: 8px; }
.role-help strong, .role-help span { display: block; }
.role-help span { font-size: 11px; color: var(--muted); margin-top: 3px; }
.user-row, .member-row, .snapshot { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); gap: 12px; }
.user-main { display: flex; flex-direction: column; flex: 1; }
.user-main span, .member-row small { font-size: 12px; color: var(--muted); }
.active-toggle { display: flex; align-items: center; gap: 6px; margin: 0; font-weight: 500; }
.member-actions { display: flex; align-items: center; gap: 8px; min-width: 260px; }
.permission-current { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.permission-current span { color: var(--muted); }
.permission-current strong { flex: 1; }
.backup-actions { display: flex; justify-content: space-between; gap: 16px; align-items: center; flex-wrap: wrap; }
.backup-import { display: flex; gap: 8px; align-items: center; flex: 1; justify-content: flex-end; }
.backup-import input { max-width: 420px; }
.warning-box { margin-top: 14px; padding: 12px; border-radius: 8px; background: var(--warning-soft); border: 1px solid #ecd99b; color: #6d5200; }
.status-message, .success-msg { color: var(--success); font-size: 12px; margin-top: 10px; min-height: 18px; }

.actions { display: flex; gap: 8px; margin-top: 15px; }
.actions.end { justify-content: flex-end; }
.align-end { display: flex; align-items: end; }
.empty { padding: 24px; text-align: center; color: var(--muted); border: 1px dashed var(--line); border-radius: 8px; }
.overlay, .modal { position: fixed; inset: 0; background: rgba(18,26,35,.48); display: flex; align-items: center; justify-content: center; z-index: 50; }
.login-card, .modal-card { background: #fff; border-radius: 12px; padding: 28px; width: min(500px, calc(100% - 30px)); box-shadow: 0 15px 50px rgba(0,0,0,.2); }
.login-card h1, .modal-card h2 { margin: 5px 0 8px; }
.modal-card { max-height: 90vh; overflow: auto; }
.wide-modal { width: min(900px, calc(100% - 30px)); }
.confirm-card { width: min(480px, calc(100% - 30px)); }
.icon { background: transparent; font-size: 24px; padding: 0; }
.error { color: var(--danger); min-height: 20px; margin: 8px 0; }
footer { text-align: center; padding: 25px; color: var(--muted); font-size: 12px; }

.toast-box { position: fixed; right: 18px; bottom: 18px; z-index: 90; display: grid; gap: 8px; width: min(390px, calc(100% - 36px)); }
.toast { background: #17212b; color: #fff; padding: 12px 14px; border-radius: 8px; box-shadow: 0 8px 30px rgba(0,0,0,.2); }
.toast.error { background: #8a261d; margin: 0; min-height: 0; }

@media (max-width: 1000px) {
  .admin-grid, .grid2, .form-grid, .form-grid.three, .form-grid.four { grid-template-columns: 1fr; }
  .role-help { grid-template-columns: 1fr 1fr; }
  .delivery-controls { grid-template-columns: 1fr; }
  .setup-grid { grid-template-columns: 1fr; }
  .stage-row { grid-template-columns: 30px 1fr; }
  .stage-row button { grid-column: 2; }
  .savebar { position: static; }
  .topbar { padding: 15px; align-items: flex-start; flex-direction: column; }
  .projectbar { padding: 12px 15px; flex-direction: column; align-items: stretch; }
  .project-picker { min-width: 0; max-width: none; }
  .project-picker-details { grid-template-columns: 1fr; gap: 2px; }
  .nav { padding: 0 15px; }
  .container { padding: 15px; }
  .report-page { padding: 20px; }
  .user-row { flex-wrap: wrap; }
  .member-actions { min-width: 0; width: 100%; }
  .workflow-meta { gap: 8px 14px; }
  .milestone-row { grid-template-columns: 1fr; }
}

@media print {
  @page { margin: 12mm; }
  body { background: #fff; }
  body:not(.print-delivery) .topbar,
  body:not(.print-delivery) .projectbar,
  body:not(.print-delivery) .nav,
  body:not(.print-delivery) footer,
  body:not(.print-delivery) .no-print,
  body:not(.print-delivery) .savebar { display: none !important; }
  body:not(.print-delivery) .container { padding: 0; max-width: none; }
  body:not(.print-delivery) .tab { display: none !important; }
  body:not(.print-delivery) #reportTab { display: block !important; }
  body:not(.print-delivery) .report-page { border: 0; box-shadow: none; padding: 0; }
  .print-sheet { padding: 0; color: #111; }
  .print-workflow { display: grid; grid-template-columns: 40px 1fr; gap: 14px; padding: 11px 0; border-bottom: 1px solid #ddd; break-inside: avoid; }
  .print-workflow > div:nth-child(2) { display: grid; gap: 6px; }
  .print-workflow-title { display: flex; justify-content: space-between; gap: 12px; }
  .print-workflow .bar { width: 100%; }
  .print-warning { color: #6d5200; font-weight: 700; }
}

.setup-body { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: linear-gradient(145deg, #eef2f7, #f8fafc); }
.setup-card { width: min(880px, 100%); background: #fff; border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 18px 55px rgba(20,30,45,.12); padding: 30px; }
.setup-card h1 { margin: 5px 0 8px; }
.setup-check { margin-top: 30px; }

/* ===== V12 usability and reporting enhancements ===== */
.topbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
}
.topbar-brand { min-width: 0; }
.topbar-center { justify-self: center; }
.top-actions { justify-self: end; }
.admin-launch {
  background: rgba(255,255,255,.11);
  color: #fff;
  border: 1px solid rgba(255,255,255,.22);
  border-radius: 22px;
  padding: 9px 18px;
  font-weight: 750;
  letter-spacing: .01em;
}
.admin-launch:hover:not(:disabled), .admin-launch.active {
  background: #fff;
  color: #17212b;
}

.dashboard-visuals {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.donut-card, .visual-status-card {
  min-height: 176px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 16px;
}
.donut-card {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
}
.donut {
  --value: 0;
  width: 126px;
  height: 126px;
  flex: 0 0 126px;
  padding: 13px;
  border-radius: 50%;
  background: conic-gradient(var(--accent) calc(var(--value) * 1%), #e7ecf2 0);
  display: grid;
  place-items: center;
}
.donut-hole {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: #fff;
  display: grid;
  place-items: center;
  align-content: center;
  text-align: center;
  padding: 8px;
  box-shadow: inset 0 0 0 1px #eef1f4;
}
.donut-hole strong { font-size: 25px; line-height: 1; }
.donut-hole span { color: var(--muted); font-size: 11px; margin-top: 5px; }
.donut-detail { color: var(--muted); max-width: 170px; }
.visual-status-card { display: flex; flex-direction: column; justify-content: center; }
.visual-label { color: var(--muted); font-size: 12px; }
.visual-status-card > strong { font-size: 28px; margin: 6px 0 15px; }
.status-chip-row { display: flex; gap: 7px; flex-wrap: wrap; }
.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border-radius: 20px;
  padding: 5px 9px;
  font-size: 11px;
  font-weight: 700;
  background: #f0f3f6;
  color: #52606d;
}
.status-chip.completed { background: var(--success-soft); color: var(--success); }
.status-chip.in-progress { background: var(--accent-soft); color: #1848b8; }
.status-chip.planned { background: #f0f3f6; color: #52606d; }
.status-chip.overdue { background: var(--danger-soft); color: var(--danger); }
.status-chip.not-relevant { background: #f5f5f5; color: #7b8794; }
.table-progress { display: flex; align-items: center; gap: 8px; min-width: 135px; }
.table-progress .bar { min-width: 75px; }
.table-progress b { font-size: 11px; min-width: 34px; text-align: right; }
.tag-ok { background: var(--success-soft); color: var(--success); }
.tag-risk { background: var(--danger-soft); color: var(--danger); }

.stage-flow-panel { overflow: hidden; }
.stage-flow { display: flex; align-items: center; gap: 4px; overflow-x: auto; padding: 8px 2px 4px; }
.stage-flow-item { display: flex; align-items: center; flex: 1 0 auto; }
.stage-flow-node {
  min-width: 130px;
  border: 1px solid var(--line);
  background: #f8fafc;
  border-radius: 10px;
  padding: 11px 12px;
}
.stage-flow-node strong, .stage-flow-node span { display: block; }
.stage-flow-node span { color: var(--accent); font-weight: 800; margin-top: 4px; }
.stage-flow-arrow { color: #9aa6b2; font-size: 20px; padding: 0 8px; }

.company-logo-editor { margin-top: 16px; }
.company-logo-preview-wrap { min-height: 90px; justify-content: center; background: #f8fafc; border: 1px dashed var(--line); border-radius: 8px; }
.company-logo-preview-wrap .logo-preview { max-width: 230px; max-height: 88px; border: 0; background: transparent; }

.report-toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 190px minmax(220px, 1fr) auto;
  gap: 14px;
  align-items: end;
  position: sticky;
  top: 10px;
  z-index: 4;
}
.report-toolbar label { margin-top: 0; }
.report-toolbar-info { align-self: center; padding-top: 18px; }
.report-a4 {
  width: min(100%, 210mm);
  min-height: 297mm;
  margin: 0 auto 20px;
  padding: 12mm;
  border-radius: 3px;
}
.unified-report { color: #1f2933; }
.report-head-modern { align-items: flex-start; border-bottom: 3px solid #17212b; }
.report-title-block { min-width: 0; }
.report-title-block h1 { margin-bottom: 2px; font-size: 28px; }
.report-title-block > p { margin: 0 0 10px; color: var(--muted); font-size: 15px; }
.report-meta-line { display: flex; flex-wrap: wrap; gap: 8px 20px; color: var(--muted); font-size: 11px; }
.report-meta-line strong { color: var(--text); margin-left: 4px; }
.report-brand-block { min-width: 150px; max-width: 210px; text-align: right; display: flex; flex-direction: column; align-items: flex-end; gap: 6px; font-size: 11px; color: var(--muted); }
.company-report-logo { margin: 0; max-width: 180px; max-height: 64px; object-fit: contain; }
.report-logo-placeholder { width: 150px; height: 52px; border: 1px dashed var(--line); display: grid; place-items: center; color: #a0aab4; font-size: 10px; }
.report-section { padding: 22px 0 4px; }
.report-section-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 17px; }
.report-section-head > div:first-child { display: flex; align-items: center; gap: 11px; }
.report-section-head h2 { margin: 1px 0 0; font-size: 20px; }
.report-section-number { width: 34px; height: 34px; border-radius: 8px; background: #17212b; color: #fff; display: grid; place-items: center; font-weight: 800; }
.report-date-box { text-align: right; background: #f5f7fa; border-radius: 8px; padding: 8px 10px; min-width: 120px; }
.report-date-box span, .report-date-box strong { display: block; }
.report-date-box span { color: var(--muted); font-size: 10px; }
.report-date-box strong { margin-top: 2px; }
.report-hero-grid { display: grid; grid-template-columns: 230px 1fr; gap: 16px; align-items: stretch; }
.report-hero-grid .donut-card, .delivery-dashboard .donut-card { min-height: 155px; box-shadow: none; background: #f8fafc; }
.report-hero-grid .donut { width: 112px; height: 112px; flex-basis: 112px; }
.report-facts, .delivery-facts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.report-facts > div, .delivery-facts > div { border: 1px solid var(--line); border-radius: 8px; padding: 10px 11px; min-width: 0; }
.report-facts span, .delivery-facts span { display: block; font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.report-facts strong, .delivery-facts strong { display: block; margin-top: 3px; overflow-wrap: anywhere; }
.report-facts small { display: block; color: var(--muted); margin-top: 2px; overflow-wrap: anywhere; }
.report-copy-grid { display: grid; grid-template-columns: 1.15fr .85fr; gap: 18px; margin: 18px 0; }
.report-copy-grid > div { background: #f8fafc; border-left: 3px solid #d6dce3; padding: 10px 12px; }
.report-copy-grid h3 { margin: 0 0 5px; font-size: 13px; }
.report-copy-grid p { margin: 0; color: #465463; white-space: pre-wrap; }
.report-subtitle { margin: 18px 0 8px; font-size: 14px; }
.report-table-wrap { border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.report-table { font-size: 11px; }
.report-table th { background: #f4f6f8; font-size: 10px; text-transform: uppercase; letter-spacing: .03em; color: #52606d; }
.report-table th, .report-table td { padding: 8px; }
.report-section-divider { height: 1px; background: #cdd4dc; margin: 20px 0 0; position: relative; }
.report-section-divider::after { content: ''; position: absolute; left: 0; top: -2px; width: 80px; height: 5px; background: var(--accent); }
.delivery-dashboard { display: grid; grid-template-columns: 190px 190px 1fr; gap: 12px; align-items: stretch; }
.delivery-dashboard .donut-card { display: grid; gap: 3px; justify-items: center; text-align: center; }
.delivery-dashboard .donut { width: 92px; height: 92px; flex-basis: 92px; padding: 10px; }
.delivery-dashboard .donut-hole strong { font-size: 20px; }
.delivery-dashboard .donut-detail { font-size: 10px; }
.health-risk { color: var(--danger); }
.health-ok { color: var(--success); }
.report-status-chips { margin: 12px 0; }
.report-warning, .report-ok { padding: 9px 11px; border-radius: 8px; margin: 10px 0 13px; font-size: 11px; }
.report-warning { background: var(--warning-soft); color: #6d5200; border: 1px solid #ecd99b; }
.report-warning ul { margin: 5px 0 0 17px; padding: 0; }
.report-ok { background: var(--success-soft); color: var(--success); border: 1px solid #c7e4cf; }
.report-workflow { display: grid; gap: 0; }
.report-workflow-step { display: grid; grid-template-columns: 38px 1fr; gap: 10px; min-width: 0; }
.report-workflow-rail { display: flex; flex-direction: column; align-items: center; }
.report-workflow-rail .workflow-index { flex: 0 0 32px; width: 32px; height: 32px; }
.workflow-connector { width: 2px; background: #d9e0e7; flex: 1; min-height: 16px; }
.report-workflow-card { border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px; margin-bottom: 7px; background: #fff; min-width: 0; }
.report-workflow-step.completed .report-workflow-card { border-left: 3px solid var(--success); }
.report-workflow-step.in-progress .report-workflow-card { border-left: 3px solid var(--accent); }
.report-workflow-step.overdue .report-workflow-card { border-left: 3px solid var(--danger); }
.report-workflow-step.not-relevant .report-workflow-card { opacity: .62; }
.status-tag.completed { background: var(--success-soft); color: var(--success); }
.status-tag.in-progress { background: var(--accent-soft); color: #1848b8; }
.status-tag.overdue { background: var(--danger-soft); color: var(--danger); }
.status-tag.planned { background: #f0f3f6; color: #52606d; }

@media (max-width: 1000px) {
  .topbar { grid-template-columns: 1fr auto; }
  .topbar-center { grid-column: 1 / -1; grid-row: 2; width: 100%; }
  .admin-launch { width: 100%; }
  .dashboard-visuals { grid-template-columns: 1fr; }
  .report-toolbar { grid-template-columns: 1fr 1fr; position: static; }
  .report-toolbar-info { padding-top: 0; }
  .report-toolbar .delivery-actions { justify-content: stretch; }
  .report-toolbar .delivery-actions button { width: 100%; }
  .report-hero-grid, .delivery-dashboard, .report-copy-grid { grid-template-columns: 1fr; }
  .report-a4 { width: 100%; min-height: 0; padding: 20px; }
  .report-facts, .delivery-facts { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 640px) {
  .report-toolbar, .report-facts, .delivery-facts { grid-template-columns: 1fr; }
  .report-head-modern, .report-section-head { flex-direction: column; }
  .report-brand-block { align-items: flex-start; text-align: left; }
  .report-date-box { text-align: left; }
  .donut-card { justify-content: flex-start; }
}

@media print {
  @page { size: A4 portrait; margin: 8mm; }
  html, body { background: #fff !important; }
  .unified-report { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .topbar, .projectbar, .nav, footer, .no-print, .savebar, .toast-box, .modal, .overlay { display: none !important; }
  .container { max-width: none !important; padding: 0 !important; margin: 0 !important; }
  .tab { display: none !important; }
  #reportTab { display: block !important; }
  #reportContent.report-a4 { display: block !important; width: auto !important; min-height: 0 !important; margin: 0 !important; padding: 0 !important; border: 0 !important; box-shadow: none !important; }
  .report-head-modern, .report-section-head, .report-hero-grid, .delivery-dashboard, .report-copy-grid, .report-workflow-step, .report-facts > div, .delivery-facts > div, .donut-card { break-inside: avoid; page-break-inside: avoid; }
  .report-section-divider { break-after: avoid; }
  .report-workflow-card { box-shadow: none; }
  .report-table-wrap { overflow: visible; }
  .report-table { font-size: 9.5px; }
  .report-table th, .report-table td { padding: 5px 6px; }
  .report-section { padding-top: 15px; }
  .report-copy-grid { margin: 12px 0; }
  .report-workflow-card { padding: 7px 9px; margin-bottom: 5px; }
  .workflow-meta { font-size: 9.5px; gap: 5px 10px; }
  .workflow-description, .workflow-warning { font-size: 9.5px; }
  .donut-card, .visual-status-card { box-shadow: none; }
}

/* V14 portfolio, administration and snapshot UX */
.portfolio-grid { display:grid; grid-template-columns:repeat(auto-fit,minmax(280px,1fr)); gap:12px; }
.portfolio-card { border:1px solid var(--line); background:#fff; border-radius:12px; padding:14px; text-align:left; cursor:pointer; color:inherit; box-shadow:0 2px 8px rgba(15,23,42,.04); }
.portfolio-card:hover { border-color:#9fb6d8; transform:translateY(-1px); }
.portfolio-card.completed-project { background:#f7faf8; opacity:.9; }
.portfolio-card-head { display:flex; justify-content:space-between; gap:10px; align-items:flex-start; }
.portfolio-card-head strong,.portfolio-card-head small,.portfolio-number { display:block; }
.portfolio-card-head strong { font-size:15px; margin:3px 0; }
.portfolio-card-head small { color:var(--muted); }
.portfolio-number { font-size:10px; font-weight:800; color:var(--accent); letter-spacing:.05em; text-transform:uppercase; }
.portfolio-progress { display:grid; grid-template-columns:1fr auto; gap:10px; align-items:center; margin:14px 0 10px; }
.portfolio-meta { display:grid; grid-template-columns:1fr 1fr; gap:6px 12px; font-size:11px; color:var(--muted); }
.portfolio-meta b { color:var(--text); }
.attention-item { width:100%; display:grid; grid-template-columns:auto 1fr auto; gap:10px; align-items:center; border:0; border-bottom:1px solid var(--line); background:transparent; padding:10px 4px; text-align:left; cursor:pointer; color:inherit; }
.attention-item:hover { background:#f8fafc; }
.attention-item strong,.attention-item small { display:block; }
.attention-item small { color:var(--muted); margin-top:2px; }
.attention-date { font-size:10px; font-weight:800; color:var(--accent); min-width:72px; }
.warning-dot { width:24px; height:24px; border-radius:50%; display:grid; place-items:center; font-weight:900; background:var(--danger-soft); color:var(--danger); }
.warning-medium .warning-dot { background:#fff4d6; color:#8a6410; }
.warning-low .warning-dot { background:#edf2f7; color:#52606d; }
.project-completed-check { margin-top:16px; padding:10px 12px; border:1px solid var(--line); border-radius:8px; background:#f8fafc; }
.admin-subnav { display:flex; flex-wrap:wrap; gap:8px; margin-bottom:14px; }
.admin-subnav button { border:1px solid var(--line); background:#fff; border-radius:8px; padding:9px 13px; cursor:pointer; font-weight:700; }
.admin-subnav button.active { background:#17212b; color:#fff; border-color:#17212b; }
.admin-section { margin-bottom:16px; }
.audit-action { font-size:10px; font-weight:800; background:#eef3f8; padding:4px 6px; border-radius:5px; white-space:nowrap; }
.snapshot { display:flex; justify-content:space-between; gap:12px; align-items:center; }
.snapshot > div:first-child strong,.snapshot > div:first-child span { display:block; }
.snapshot-actions { display:flex; gap:6px; }
.modal-wide { width:min(920px,calc(100vw - 30px)); max-height:85vh; overflow:auto; }
.snapshot-compare-summary { display:grid; grid-template-columns:repeat(3,1fr); gap:10px; margin:8px 0 16px; }
.snapshot-compare-summary > div { border:1px solid var(--line); border-radius:8px; padding:10px; }
.snapshot-compare-summary span,.snapshot-compare-summary strong { display:block; }
.snapshot-compare-summary span { font-size:10px; color:var(--muted); text-transform:uppercase; }
.snapshot-compare-summary strong { font-size:22px; margin-top:3px; }
.compare-list { padding:10px; background:#f8fafc; border-radius:8px; margin-bottom:14px; }
.report-page-break { border-top:1px solid #d6dde5; margin-top:18px; }

@media (max-width:700px) {
  .portfolio-meta,.snapshot-compare-summary { grid-template-columns:1fr; }
  .attention-item { grid-template-columns:auto 1fr; }
  .attention-item .status-chip { grid-column:2; justify-self:start; }
  .snapshot { align-items:flex-start; flex-direction:column; }
}

@media print {
  .report-page-break { break-before: page; page-break-before: always; border-top:0 !important; margin-top:0 !important; }
  .report-page-break:first-of-type { break-before:auto; page-break-before:auto; }
  .report-section { orphans:3; widows:3; }
  .report-section-head { break-after:avoid-page; page-break-after:avoid; }
  .report-table thead { display:table-header-group; }
  .report-workflow-step { break-inside:avoid-page; page-break-inside:avoid; }
}

.section-actions { display:flex; gap:8px; align-items:center; flex-wrap:wrap; }

/* V17 modular navigation and Customer Master Data */
.module-nav { gap: 22px; align-items: stretch; }
.nav-group { display: flex; align-items: stretch; gap: 3px; position: relative; padding-left: 82px; }
.nav-group + .nav-group { border-left: 1px solid var(--line); padding-left: 122px; }
.nav-group-label { position: absolute; left: 4px; top: 50%; transform: translateY(-50%); color: #7a8794; font-size: 10px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; white-space: nowrap; pointer-events: none; }
.nav-group + .nav-group .nav-group-label { left: 14px; }
.customer-page-head { align-items: center; }
.customer-module-grid { display: grid; grid-template-columns: minmax(300px, 380px) minmax(0, 1fr); gap: 16px; align-items: start; }
.customer-directory { position: sticky; top: 12px; max-height: calc(100vh - 170px); overflow: hidden; display: flex; flex-direction: column; }
.customer-search-wrap { padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.customer-search-wrap label { margin-top: 0; }
.customer-list { overflow: auto; padding-top: 10px; min-height: 180px; }
.customer-list-item { width: 100%; display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; text-align: left; background: #fff; border: 1px solid transparent; padding: 11px 10px; margin-bottom: 6px; }
.customer-list-item:hover { background: #f7f9fb; }
.customer-list-item.active { background: var(--accent-soft); border-color: #a9c0ff; }
.customer-list-item > div { min-width: 0; display: grid; gap: 2px; }
.customer-list-item strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.customer-list-item small { color: var(--muted); }
.customer-number { color: var(--accent); font-size: 10px; font-weight: 800; letter-spacing: .04em; }
.customer-status { flex: 0 0 auto; padding: 3px 7px; border-radius: 999px; background: var(--success-soft); color: var(--success); font-size: 10px; font-weight: 800; text-transform: uppercase; }
.customer-status.prospect { background: var(--accent-soft); color: #3158a7; }
.customer-status.inactive { background: #eef1f4; color: #687581; }
.empty-list, .empty-state { padding: 34px 18px; text-align: center; color: var(--muted); }
.empty-state { min-height: 320px; display: grid; place-content: center; gap: 5px; }
.empty-state strong { color: var(--text); font-size: 18px; }
.customer-editor-panel { min-width: 0; }
.customer-form-grid textarea { min-height: 104px; }
.customer-project-links { margin: 18px 0; padding: 14px; border: 1px solid var(--line); border-radius: 9px; background: #fafbfd; }
.customer-project-links h3 { margin: 0 0 10px; }
.customer-project-chip-row { display: flex; flex-wrap: wrap; gap: 7px; }
.customer-project-chip { display: flex; align-items: center; gap: 7px; border: 1px solid var(--line); background: #fff; }
.customer-project-chip strong { color: var(--accent); }
.customer-contact-head { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line); }
.customer-contact-table th:last-child, .customer-contact-table td:last-child { width: 150px; }
.table-actions { display: flex; gap: 5px; flex-wrap: wrap; }
.customer-savebar { margin-top: 16px; }
.customer-reference-card { margin: 7px 0 5px; padding: 10px 11px; border: 1px solid var(--line); border-radius: 8px; background: #f8fafc; min-height: 58px; }
.customer-reference-card.compact { min-height: 48px; }
.customer-reference-card div { display: grid; gap: 2px; }
.customer-reference-card strong { font-size: 12px; }
.customer-reference-card span, .customer-reference-card small { color: var(--muted); font-size: 11px; }
.compact-grid { gap: 12px; }

@media (max-width: 1100px) {
  .customer-module-grid { grid-template-columns: 1fr; }
  .customer-directory { position: static; max-height: none; }
  .customer-list { max-height: 320px; }
  .module-nav { gap: 8px; }
  .nav-group, .nav-group + .nav-group { padding-left: 0; border-left: 0; }
  .nav-group-label { display: none; }
}

@media (max-width: 700px) {
  .module-nav { display: block; padding-top: 5px; padding-bottom: 5px; }
  .nav-group { overflow-x: auto; }
  .customer-page-head { align-items: stretch; flex-direction: column; }
  .customer-contact-table { min-width: 780px; }
}
