/*
 * Manna Reports — custom design system
 * Overrides Bootstrap 5 variables + defines report-specific components.
 * No build step required: loaded via collectstatic.
 */

/* ------------------------------------------------------------------ */
/* 1. Design tokens                                                     */
/* ------------------------------------------------------------------ */

:root {
  --color-bg: #fafaf7;
  --color-surface: #ffffff;
  --color-primary: #1b4d3e;
  --color-primary-hover: #14392e;
  --color-accent: #4a7c59;
  --color-success: #10b981;
  --color-warning: #f59e0b;
  --color-danger: #ef4444;
  --color-info: #6366f1;
  --color-text-primary: #1f2937;
  --color-text-secondary: #6b7280;
  --color-border: #e5e7eb;
  --color-hover-row: #f3f4f6;

  /* Bootstrap 5 overrides */
  --bs-body-bg: var(--color-bg);
  --bs-body-color: var(--color-text-primary);
  --bs-border-color: var(--color-border);
  --bs-primary-rgb: 27, 77, 62;
  --bs-border-radius-xl: 12px;
  --bs-card-border-radius: 12px;
  --bs-card-border-color: var(--color-border);
  --bs-card-cap-bg: transparent;
}

/* Dark mode overrides */
[data-bs-theme="dark"] {
  --color-bg: #111827;
  --color-surface: #1f2937;
  --color-text-primary: #f9fafb;
  --color-text-secondary: #9ca3af;
  --color-border: #374151;
  --color-hover-row: #374151;
  --bs-body-bg: var(--color-bg);
  --bs-body-color: var(--color-text-primary);
  --bs-border-color: var(--color-border);
}

/* ------------------------------------------------------------------ */
/* 2. Base                                                              */
/* ------------------------------------------------------------------ */

body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background-color: var(--color-bg);
  color: var(--color-text-primary);
  font-size: 14px;
  line-height: 1.6;
}

/* ------------------------------------------------------------------ */
/* 3. Reports nav / header                                             */
/* ------------------------------------------------------------------ */

.reports-header {
  padding: 24px 0 16px;
  border-bottom: 1px solid var(--color-border);
  margin-bottom: 24px;
}

.reports-header h1 {
  font-size: 28px;
  font-weight: 700;
  color: var(--color-text-primary);
  margin: 0 0 4px;
}

.reports-header .subtitle {
  font-size: 13px;
  color: var(--color-text-secondary);
  margin: 0;
}

/* ------------------------------------------------------------------ */
/* 3.1 Top navigation bar (global, all pages)                          */
/* ------------------------------------------------------------------ */

.top-nav {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  /* Desktop: fixed bar. Mobile: grows when drawer opens. */
  min-height: 52px;
  position: sticky;
  top: 0;
  z-index: 1030;
}

.top-nav-bar {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: space-between;
  height: 52px;
  width: 100%;
  gap: 8px;
}

/* Desktop row — identical to pre-#268 layout */
.top-nav-desktop {
  display: none;
  align-items: center;
  flex: 1 1 auto;
  min-width: 0;
  height: 100%;
}

.top-nav-mobile-tools {
  display: none;
  flex: 0 0 auto;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.top-nav-toggler {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  border: 1px solid var(--color-border);
  background: none;
  color: var(--color-text-secondary);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.top-nav-toggler:hover {
  border-color: var(--color-accent);
  color: var(--color-primary);
  background: var(--color-hover-row);
}

.top-nav-action-btn {
  border: 1px solid var(--color-border) !important;
  color: var(--color-text-secondary) !important;
  font-size: 13px !important;
  white-space: nowrap;
}

.top-nav-drawer {
  display: none;
  border-top: 1px solid var(--color-border);
  background: var(--color-surface);
}

.top-nav-drawer.is-open {
  display: block;
}

.top-nav-drawer-inner {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 0 14px;
}

.top-nav-drawer-inner .top-nav-link {
  width: 100%;
  padding: 12px 14px;
  font-size: 15px;
  border-radius: 10px;
}

.top-nav-drawer-inner .top-nav-action-btn {
  width: 100%;
  display: flex !important;
  justify-content: flex-start;
  align-items: center;
  text-align: left;
  padding: 10px 14px !important;
  font-size: 15px !important;
}

.top-nav-drawer-inner form {
  width: 100%;
  margin: 0;
}

/* ≥992px: restore classic desktop navbar; hide hamburger entirely */
@media (min-width: 992px) {
  .top-nav {
    height: 52px;
    display: flex;
    align-items: center;
  }

  .top-nav-bar {
    justify-content: flex-start;
  }

  .top-nav-desktop {
    display: flex !important;
  }

  .top-nav-mobile-tools,
  .top-nav-drawer {
    display: none !important;
  }
}

/* <992px: logo left + tools right on one row; links in drawer */
@media (max-width: 991.98px) {
  .top-nav {
    height: auto;
    overflow: visible;
    padding-top: env(safe-area-inset-top, 0px);
  }

  .top-nav-bar {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    align-items: center;
    justify-content: space-between;
    height: 52px;
    max-height: 52px;
    flex-shrink: 0;
  }

  .top-nav-drawer.is-open {
    display: block !important;
  }

  .top-nav-desktop {
    display: none !important;
  }

  .top-nav-brand,
  .top-nav-brand--logo {
    flex: 0 1 auto;
    min-width: 0;
    max-width: calc(100% - 100px);
  }

  .top-nav-logo {
    height: 26px;
    width: auto;
    max-width: 100%;
    object-fit: contain;
  }

  .top-nav-mobile-tools {
    display: flex !important;
    flex: 0 0 auto;
    margin-left: auto;
  }

  .top-nav-mobile-tools .dark-mode-toggle {
    width: 40px;
    height: 40px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .main-content {
    padding-left: 12px !important;
    padding-right: 12px !important;
    padding-top: 1rem !important;
  }

  .report-footer {
    padding-left: 12px;
    padding-right: 12px;
    font-size: 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
  }

  .report-footer .ms-3 {
    margin-left: 0 !important;
  }
}

.top-nav-brand {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  background: var(--color-primary);
  color: #fff;
  border-radius: 9px;
  font-size: 14px;
  text-decoration: none;
  flex-shrink: 0;
  transition: background 0.15s;
}

.top-nav-brand:hover {
  background: var(--color-primary-hover);
  color: #fff;
  text-decoration: none;
}

/* Logo variant — wider, no colored square background */
.top-nav-brand--logo {
  width: auto;
  height: auto;
  background: transparent;
  border-radius: 0;
  padding: 2px 0;
}

.top-nav-brand--logo:hover {
  background: transparent;
  opacity: 0.82;
}

.top-nav-logo {
  height: 28px;
  width: auto;
  display: block;
  /* White bg PNG blends seamlessly on white navbar */
  mix-blend-mode: multiply;
}

/* Dark mode: make logo white so it reads on dark navbar */
[data-bs-theme="dark"] .top-nav-logo {
  mix-blend-mode: normal;
  filter: brightness(0) invert(1);
  opacity: 0.88;
}

.top-nav-sep {
  color: var(--color-border);
  font-size: 20px;
  font-weight: 300;
  margin: 0 10px;
  user-select: none;
}

.top-nav-links {
  display: flex;
  align-items: center;
  gap: 2px;
}

.top-nav-link {
  display: inline-flex;
  align-items: center;
  padding: 5px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text-secondary);
  text-decoration: none;
  transition: background 0.12s, color 0.12s;
  white-space: nowrap;
}

.top-nav-link:hover {
  background: var(--color-hover-row);
  color: var(--color-text-primary);
  text-decoration: none;
}

.top-nav-link--active {
  background: rgba(27, 77, 62, 0.09);
  color: var(--color-primary);
  font-weight: 600;
}

[data-bs-theme="dark"] .top-nav-link--active {
  background: rgba(74, 124, 89, 0.18);
  color: #6ee7b7;
}

/* ------------------------------------------------------------------ */
/* 4. Tab navigation                                                    */
/* ------------------------------------------------------------------ */

.reports-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
}

.reports-tab {
  display: inline-flex;
  align-items: center;
  padding: 8px 20px;
  border-radius: 9999px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text-secondary);
  text-decoration: none;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.reports-tab:hover {
  border-color: var(--color-accent);
  color: var(--color-primary);
}

.reports-tab.active {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: #ffffff;
}

/* ------------------------------------------------------------------ */
/* 5. Report cards                                                      */
/* ------------------------------------------------------------------ */

.report-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  padding: 20px 24px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  transition: box-shadow 0.15s;
}

.report-card:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

/* ------------------------------------------------------------------ */
/* 6. KPI cards                                                         */
/* ------------------------------------------------------------------ */

.kpi-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  padding: 20px 20px 16px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  position: relative;
  overflow: hidden;
  /* Flex column + fixed-height footer keeps all cards the same size
     regardless of whether they have a sub-label, trend, or sparkline —
     same pattern as .dashboard-kpi-card. */
  height: 100%;
  min-height: 172px;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
}

.kpi-card-body {
  flex: 1 1 auto;
  min-height: 0;
}

.kpi-card-footer {
  flex: 0 0 auto;
  margin-top: auto;
  min-height: 44px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}

.kpi-sub-text {
  font-size: 12px;
  color: var(--color-text-secondary);
  margin-bottom: 4px;
}

/* 4px top health indicator */
.kpi-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--color-border);
  border-radius: 12px 12px 0 0;
}

.kpi-card.kpi-success::before { background: var(--color-success); }
.kpi-card.kpi-warning::before { background: var(--color-warning); }
.kpi-card.kpi-danger::before  { background: var(--color-danger); }
.kpi-card.kpi-neutral::before { background: var(--color-border); }

.kpi-value {
  font-size: 36px;
  font-weight: 700;
  color: var(--color-text-primary);
  line-height: 1.1;
  margin-bottom: 4px;
}

.kpi-label {
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--color-text-secondary);
  margin-bottom: 8px;
}

.kpi-trend {
  font-size: 12px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 2px;
}

.kpi-trend.up   { color: var(--color-success); }
.kpi-trend.down { color: var(--color-danger); }
.kpi-trend.flat { color: var(--color-text-secondary); }
.kpi-trend.new  {
  color: var(--color-info);
  background: rgba(99, 102, 241, 0.08);
  padding: 2px 8px;
  border-radius: 9999px;
  font-size: 11px;
}

.kpi-trend-sub {
  font-size: 11px;
  font-weight: 400;
  opacity: 0.7;
  margin-left: 3px;
}

.kpi-sparkline {
  margin-top: 8px;
  opacity: 0.7;
}

/* ------------------------------------------------------------------ */
/* 7. Period cards (index page)                                         */
/* ------------------------------------------------------------------ */

.period-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  padding: 18px 22px;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  display: block;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.period-card:hover {
  border-color: var(--color-accent);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  color: inherit;
}

.period-card .period-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--color-text-primary);
  margin-bottom: 2px;
}

.period-card .period-author {
  font-size: 12px;
  color: var(--color-text-secondary);
  margin-bottom: 12px;
}

.period-card .period-badge {
  font-size: 11px;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 9999px;
  padding: 2px 10px;
  color: var(--color-text-secondary);
}

.period-metrics {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
}

.period-metric-item .metric-val {
  font-size: 20px;
  font-weight: 700;
  color: var(--color-text-primary);
  line-height: 1.2;
}

.period-metric-item .metric-lbl {
  font-size: 11px;
  color: var(--color-text-secondary);
}

.period-card-footer {
  display: flex;
  justify-content: flex-end;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--color-border);
}

.period-card-open-hint {
  font-size: 12px;
  color: var(--color-text-secondary);
  opacity: 0;
  transition: opacity 0.15s;
}

.period-card:hover .period-card-open-hint {
  opacity: 1;
  color: var(--color-primary);
}

/* ------------------------------------------------------------------ */
/* 8. Stage badges                                                      */
/* ------------------------------------------------------------------ */

.stage-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 9999px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}

.stage-won          { background: #d1fae5; color: #065f46; }
.stage-negotiating  { background: #fef3c7; color: #92400e; }
.stage-evaluating   { background: #e0e7ff; color: #3730a3; }
.stage-met          { background: #f3f4f6; color: #374151; }
.stage-new          { background: #dbeafe; color: #1e40af; }
.stage-no-show      { background: #fee2e2; color: #991b1b; }
.stage-lost         { background: #f3f4f6; color: #6b7280; }
.stage-nurture      { background: #f5f3ff; color: #5b21b6; }
.stage-out          { background: #f9fafb; color: #9ca3af; }

[data-bs-theme="dark"] .stage-won          { background: #065f46; color: #a7f3d0; }
[data-bs-theme="dark"] .stage-negotiating  { background: #78350f; color: #fde68a; }
[data-bs-theme="dark"] .stage-evaluating   { background: #312e81; color: #c7d2fe; }
[data-bs-theme="dark"] .stage-met          { background: #374151; color: #e5e7eb; }
[data-bs-theme="dark"] .stage-new          { background: #1e3a8a; color: #bfdbfe; }
[data-bs-theme="dark"] .stage-no-show      { background: #7f1d1d; color: #fecaca; }

/* ------------------------------------------------------------------ */
/* 9. Tables                                                            */
/* ------------------------------------------------------------------ */

.reports-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.reports-table thead tr {
  border-bottom: 2px solid var(--color-border);
}

.reports-table thead th {
  padding: 10px 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--color-text-secondary);
  text-align: left;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}

.reports-table thead th:hover { color: var(--color-primary); }

.reports-table tbody tr {
  border-bottom: 1px solid var(--color-border);
  transition: background 0.1s;
}

.reports-table tbody tr:hover {
  background: var(--color-hover-row);
}

.reports-table td {
  padding: 10px 12px;
  vertical-align: middle;
}

.reports-table td:first-child { font-weight: 500; }

/* Horizontal scroll on mobile */
.table-responsive-reports {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.table-responsive-reports table thead th:first-child,
.table-responsive-reports table td:first-child {
  position: sticky;
  left: 0;
  background: var(--color-surface);
  z-index: 1;
}

/* ------------------------------------------------------------------ */
/* 10. Forecast progress bars                                           */
/* ------------------------------------------------------------------ */

.forecast-row {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
}

.forecast-label {
  font-size: 14px;
  font-weight: 500;
  color: var(--color-text-secondary);
  min-width: 60px;
}

.forecast-bar-wrap {
  flex: 1;
  background: var(--color-border);
  border-radius: 9999px;
  height: 10px;
  overflow: visible;
  position: relative;
}

.forecast-bar-fill {
  height: 10px;
  border-radius: 9999px;
  background: linear-gradient(90deg, var(--color-accent), var(--color-primary));
  position: relative;
  transition: width 0.6s ease;
}

/* Dot at end of fill */
.forecast-bar-fill::after {
  content: "";
  position: absolute;
  right: -6px;
  top: 50%;
  transform: translateY(-50%);
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--color-primary);
  border: 2px solid var(--color-surface);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
}

.forecast-value {
  font-size: 18px;
  font-weight: 700;
  color: var(--color-text-primary);
  min-width: 130px;
}

.forecast-range {
  font-size: 12px;
  color: var(--color-text-secondary);
}

/* ------------------------------------------------------------------ */
/* 11. Section titles                                                   */
/* ------------------------------------------------------------------ */

.section-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--color-text-primary);
  margin: 0 0 16px;
}

.section-footer {
  font-size: 12px;
  color: var(--color-text-secondary);
  margin-top: 8px;
}

/* ------------------------------------------------------------------ */
/* 12. Filter bar                                                       */
/* ------------------------------------------------------------------ */

.filter-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px 16px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 10px;
  margin-bottom: 20px;
}

.filter-bar select,
.filter-bar input[type="date"] {
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 13px;
  background: var(--color-bg);
  color: var(--color-text-primary);
  outline: none;
  cursor: pointer;
}

.filter-bar select:focus,
.filter-bar input[type="date"]:focus {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(74, 124, 89, 0.15);
}

.filter-preset-btn {
  padding: 6px 14px;
  border-radius: 8px;
  border: 1px solid var(--color-border);
  background: var(--color-bg);
  color: var(--color-text-secondary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.filter-preset-btn:hover,
.filter-preset-btn.active {
  border-color: var(--color-primary);
  color: var(--color-primary);
  background: rgba(27, 77, 62, 0.06);
}

/* ------------------------------------------------------------------ */
/* 13. Dark mode toggle button                                          */
/* ------------------------------------------------------------------ */

.dark-mode-toggle {
  background: none;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 6px 10px;
  cursor: pointer;
  color: var(--color-text-secondary);
  font-size: 16px;
  line-height: 1;
  transition: border-color 0.15s, color 0.15s;
}

.dark-mode-toggle:hover {
  border-color: var(--color-accent);
  color: var(--color-primary);
}

/* ------------------------------------------------------------------ */
/* 14. Report footer                                                    */
/* ------------------------------------------------------------------ */

.report-footer {
  margin-top: 32px;
  padding-top: 16px;
  border-top: 1px solid var(--color-border);
  font-size: 12px;
  color: var(--color-text-secondary);
}

/* ------------------------------------------------------------------ */
/* 14.5 Funnel rows (new style — replaces inline styles)               */
/* ------------------------------------------------------------------ */

.funnel-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.funnel-block-name {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  width: 108px;
  flex-shrink: 0;
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text-secondary);
}

.funnel-block-emoji {
  font-size: 14px;
  line-height: 1;
  flex-shrink: 0;
}

.funnel-bar-wrap {
  flex: 1;
  background: var(--color-border);
  border-radius: 9999px;
  height: 8px;
  overflow: hidden;
}

.funnel-bar-fill {
  height: 8px;
  background: var(--color-accent);
  border-radius: 9999px;
  transition: width 0.4s ease;
}

.funnel-bar-fill--inflow     { background: #3b82f6; }
.funnel-bar-fill--engaged    { background: #8b5cf6; }
.funnel-bar-fill--working    { background: #f59e0b; }
.funnel-bar-fill--committing { background: #ec4899; }
.funnel-bar-fill--won        { background: #10b981; }
.funnel-bar-fill--nurture    { background: #6366f1; }
.funnel-bar-fill--out        { background: #ef4444; }

.funnel-count {
  font-size: 13px;
  font-weight: 600;
  min-width: 32px;
  text-align: right;
}

.funnel-pct {
  font-size: 12px;
  color: var(--color-text-secondary);
  min-width: 38px;
  text-align: right;
}

/* ── Funnel legend strip ───────────────────────────────────── */
.funnel-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  padding: 10px 0 4px;
  border-top: 1px solid var(--color-border);
}

.funnel-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--color-text-secondary);
}

.funnel-legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.dot-inflow     { background: #3b82f6; }
.dot-engaged    { background: #8b5cf6; }
.dot-working    { background: #f59e0b; }
.dot-committing { background: #ec4899; }
.dot-won        { background: #10b981; }
.dot-nurture    { background: #6366f1; }
.dot-out        { background: #ef4444; }

.stage-details summary {
  font-size: 12px;
  cursor: pointer;
  color: var(--color-text-secondary);
  user-select: none;
}

.stage-details summary:hover {
  color: var(--color-text-primary);
}

/* ------------------------------------------------------------------ */
/* 14.6 Completed work / итоги секция                                  */
/* ------------------------------------------------------------------ */

.completed-work-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 4px;
}

.work-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 13px;
  color: var(--color-text-primary);
  line-height: 1.4;
}

.work-item-icon {
  font-size: 14px;
  margin-top: 1px;
  flex-shrink: 0;
}

.work-item-icon--success { color: var(--color-success); }
.work-item-icon--info    { color: var(--color-info); }
.work-item-icon--neutral { color: var(--color-text-secondary); }

.work-item-sub {
  display: block;
  font-size: 11px;
  color: var(--color-text-secondary);
  margin-top: 1px;
}

.alert-strip {
  display: flex;
  align-items: center;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 500;
}

.alert-strip--warning {
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fde68a;
}

.alert-strip--neutral {
  background: var(--color-bg);
  color: var(--color-text-secondary);
  border: 1px solid var(--color-border);
}

[data-bs-theme="dark"] .alert-strip--warning {
  background: #78350f;
  color: #fde68a;
  border-color: #92400e;
}

/* ------------------------------------------------------------------ */
/* 14.7 Plan table, bottlenecks, data hygiene (W-55c)                  */
/* ------------------------------------------------------------------ */

.next-action-cell {
  font-size: 12px;
  color: var(--color-text-primary);
  max-width: 180px;
  line-height: 1.35;
}

.plan-table .plan-row--high td:first-child {
  color: var(--color-danger);
}

.plan-table .plan-row--medium td:first-child {
  color: var(--color-text-secondary);
}

.bottleneck-list,
.hygiene-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.bottleneck-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 13px;
}

.bottleneck-severity {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 4px;
}

.bottleneck-severity--high   { background: var(--color-danger); }
.bottleneck-severity--medium { background: var(--color-warning); }
.bottleneck-severity--low    { background: var(--color-success); }

.bottleneck-title {
  font-weight: 600;
  color: var(--color-text-primary);
  line-height: 1.3;
}

.bottleneck-detail {
  font-size: 12px;
  color: var(--color-text-secondary);
  margin-top: 2px;
}

.hygiene-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 13px;
  line-height: 1.4;
}

.hygiene-icon {
  flex-shrink: 0;
  margin-top: 1px;
  font-size: 14px;
}

.hygiene-item--warn .hygiene-icon { color: var(--color-warning); }
.hygiene-item--ok   .hygiene-icon { color: var(--color-success); }
.hygiene-item--info .hygiene-icon { color: var(--color-info); }

/* ------------------------------------------------------------------ */
/* 15. Print styles                                                     */
/* ------------------------------------------------------------------ */

@media print {
  .reports-header,
  .reports-tabs,
  .filter-bar,
  .dark-mode-toggle,
  nav,
  .no-print {
    display: none !important;
  }

  body {
    background: #fff;
    font-size: 12px;
  }

  .kpi-card,
  .report-card,
  .period-card {
    border: 1px solid #ccc;
    box-shadow: none;
    break-inside: avoid;
  }

  .kpi-card::before {
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }
}

/* ------------------------------------------------------------------ */
/* 16. Responsive                                                       */
/* ------------------------------------------------------------------ */

@media (max-width: 768px) {
  .reports-header h1 { font-size: 22px; }
  .kpi-value { font-size: 28px; }
  .forecast-value { font-size: 15px; min-width: 100px; }
  .forecast-label { min-width: 45px; }

  /* KPI cards: 2 per row on tablet-width phones */
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  /* Period metrics wrap tighter */
  .period-metrics { gap: 14px; }

  .period-control {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .period-control-presets {
    width: 100%;
  }

  .period-control-presets .filter-preset {
    flex: 1 1 0;
    text-align: center;
    justify-content: center;
  }

  .period-control-range {
    width: 100%;
  }

  .period-control-range .filter-input {
    flex: 1 1 auto;
    min-width: 0;
  }

  .kpi-color-legend {
    flex-wrap: wrap;
    gap: 8px 12px;
    font-size: 12px;
  }
}

/* ------------------------------------------------------------------ */
/* W-52: CEO Dashboard Home                                            */
/* ------------------------------------------------------------------ */

/* Greeting header block */
.dashboard-greeting {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  padding: 28px 0 20px;
  border-bottom: 1px solid var(--color-border);
  margin-bottom: 28px;
}

.dashboard-greeting-title {
  font-size: 26px;
  font-weight: 700;
  line-height: 1.15;
  margin: 0 0 4px;
  letter-spacing: -0.5px;
}

.dashboard-greeting-sub {
  font-size: 13px;
  color: var(--color-text-secondary);
  margin: 0;
}

/* Period controls */
.period-control {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
  margin-bottom: 16px;
}

.period-control-presets,
.period-control-range {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.period-control-error {
  font-size: 12px;
  color: var(--color-danger);
  width: 100%;
}

/* Headline KPI cards — CSS grid keeps all 8 cards aligned. */
.dashboard-kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}

.dashboard-kpi-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 14px;
  padding: 20px 18px 14px;
  min-height: 172px;
  display: flex;
  flex-direction: column;
  gap: 0;
  position: relative;
  overflow: hidden;
  transition: box-shadow 0.15s, transform 0.12s;
  box-sizing: border-box;
}

.dashboard-kpi-card:hover {
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.07);
  transform: translateY(-1px);
}

/* 4px top health bar — consistent with .kpi-card::before pattern */
.dashboard-kpi-card::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
  background: var(--color-border);
  border-radius: 14px 14px 0 0;
}

.dashboard-kpi-card.kpi-success::before { background: var(--color-success); }
.dashboard-kpi-card.kpi-warning::before { background: var(--color-warning); }
.dashboard-kpi-card.kpi-danger::before  { background: var(--color-danger); }
.dashboard-kpi-card.kpi-neutral::before { background: var(--color-border); }

.dashboard-kpi-body {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 0;
}

.dashboard-kpi-footer {
  flex: 0 0 22px;
  display: flex;
  align-items: flex-end;
  min-height: 22px;
}

.dashboard-kpi-icon {
  font-size: 18px;
  color: var(--color-accent);
  line-height: 1;
  margin-bottom: 4px;
}

.dashboard-kpi-value {
  font-size: 32px;
  font-weight: 700;
  line-height: 1;
  color: var(--color-text-primary);
  letter-spacing: -1px;
}

.dashboard-kpi-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--color-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.dashboard-kpi-sub {
  font-size: 11px;
  color: var(--color-text-secondary);
  opacity: 0.75;
  margin-top: -2px;
  min-height: 16px;
  line-height: 16px;
}

/* ─── KPI color legend ──────────────────────────────────────────────────── */
.kpi-color-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  align-items: center;
  margin-bottom: 14px;
  font-size: 12px;
  color: var(--color-text-secondary);
}

.kpi-legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.kpi-legend-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 3px;
  flex-shrink: 0;
}

.kpi-legend-dot--success { background: var(--color-success); }
.kpi-legend-dot--warning { background: var(--color-warning); }
.kpi-legend-dot--danger  { background: var(--color-danger); }
.kpi-legend-dot--neutral { background: var(--color-border); }

.kpi-legend-item--muted {
  opacity: 0.65;
  font-size: 11px;
}

/* Section label above nav tiles */
.dashboard-section-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-secondary);
  margin-bottom: 14px;
}

/* Navigation tiles */
.dashboard-tile {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px 18px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 14px;
  text-decoration: none;
  color: var(--color-text-primary);
  transition: box-shadow 0.15s, border-color 0.15s, transform 0.12s;
}

.dashboard-tile:hover {
  text-decoration: none;
  color: var(--color-text-primary);
  border-color: var(--color-primary);
  box-shadow: 0 4px 20px rgba(27, 77, 62, 0.10);
  transform: translateY(-2px);
}

.dashboard-tile--primary:hover { border-color: var(--color-primary); }
.dashboard-tile--accent:hover  { border-color: var(--color-accent); }
.dashboard-tile--muted:hover   { border-color: var(--color-text-secondary); }

.dashboard-tile-icon {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  background: rgba(74, 124, 89, 0.10);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: var(--color-primary);
  flex-shrink: 0;
}

.dashboard-tile--muted .dashboard-tile-icon {
  background: var(--color-bg);
  color: var(--color-text-secondary);
}

.dashboard-tile-body {
  flex: 1;
  min-width: 0;
}

.dashboard-tile-title {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.25;
  color: var(--color-text-primary);
}

.dashboard-tile-sub {
  font-size: 12px;
  color: var(--color-text-secondary);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dashboard-tile-arrow {
  font-size: 16px;
  color: var(--color-text-secondary);
  opacity: 0.5;
  flex-shrink: 0;
  transition: opacity 0.15s, transform 0.15s;
}

.dashboard-tile:hover .dashboard-tile-arrow {
  opacity: 1;
  transform: translateX(3px);
}

/* Bottom strip */
.dashboard-footer-strip {
  display: flex;
  align-items: center;
  gap: 20px;
  font-size: 12px;
  color: var(--color-text-secondary);
  padding: 14px 0;
  border-top: 1px solid var(--color-border);
}

.dashboard-footer-strip a {
  color: var(--color-text-secondary);
  text-decoration: none;
}

.dashboard-footer-strip a:hover {
  color: var(--color-primary);
}

@media (max-width: 576px) {
  .dashboard-greeting {
    flex-direction: column;
    align-items: flex-start;
    padding: 16px 0 14px;
    margin-bottom: 16px;
  }

  .dashboard-greeting-title {
    font-size: 22px;
  }

  /* One KPI per row on narrow phones — readable numbers & labels */
  .dashboard-kpi-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .dashboard-kpi-value {
    font-size: 28px;
  }

  .dashboard-kpi-label {
    font-size: 12px;
  }

  .dashboard-tile {
    padding: 14px 14px;
  }

  .kpi-grid {
    grid-template-columns: 1fr !important;
  }
}

@media (min-width: 577px) and (max-width: 991px) {
  .dashboard-kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ------------------------------------------------------------------ */
/* W-51c: Filter bar extended components                               */
/* ------------------------------------------------------------------ */

/* Sticky filter bar so it stays visible while scrolling report data */
.filter-bar {
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

/* Icon buttons inside filter bar (< >, refresh, list) */
.filter-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid var(--color-border);
  background: var(--color-bg);
  color: var(--color-text-secondary);
  font-size: 14px;
  text-decoration: none;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.filter-btn:hover:not([disabled]) {
  border-color: var(--color-accent);
  color: var(--color-primary);
  background: rgba(74, 124, 89, 0.06);
}

.filter-btn[disabled] {
  opacity: 0.35;
  cursor: not-allowed;
}

/* Date input unified with filter bar style */
.filter-input {
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 5px 10px;
  font-size: 13px;
  background: var(--color-bg);
  color: var(--color-text-primary);
  outline: none;
  cursor: pointer;
  height: 32px;
}

.filter-input:focus {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(74, 124, 89, 0.12);
}

.filter-range-label {
  font-size: 12px;
  color: var(--color-text-secondary);
  white-space: nowrap;
}

/* Quick preset period pills */
.filter-preset {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 20px;
  border: 1px solid var(--color-border);
  background: var(--color-bg);
  color: var(--color-text-secondary);
  font-size: 12px;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.filter-preset:hover:not(.active) {
  border-color: rgba(27, 77, 62, 0.35);
  color: var(--color-primary);
  background: rgba(27, 77, 62, 0.04);
  text-decoration: none;
}

.filter-preset.active {
  border-color: var(--color-primary);
  color: var(--color-primary);
  background: rgba(27, 77, 62, 0.07);
  text-decoration: none;
}

/* HTMX loading indicator (spin animation) */
.htmx-indicator {
  display: none;
}

.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.htmx-request .htmx-indicator i,
.htmx-request.htmx-indicator i {
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

/* Period card current-week highlight */
.period-card--current {
  border-left: 3px solid var(--color-primary);
}

[data-bs-theme="dark"] .filter-btn,
[data-bs-theme="dark"] .filter-input,
[data-bs-theme="dark"] .filter-preset {
  background: var(--color-surface);
}

/* ------------------------------------------------------------------ */
/* W-51d: Chart.js containers                                          */
/* ------------------------------------------------------------------ */

/* Generic chart wrapper — set explicit height, let Chart.js fill width */
.chart-container {
  position: relative;
  width: 100%;
}

.chart-container canvas {
  display: block;
  width: 100% !important;
}

/* Sparkline strip inside KPI card */
.sparkline-wrap {
  position: relative;
  height: 36px;
  margin-top: 8px;
  overflow: hidden;
  border-radius: 4px;
}

.sparkline-wrap canvas {
  display: block;
  width: 100% !important;
  height: 36px !important;
}
