:root {
  --bg-main: #f8fafc;
  --bg-card: #ffffff;
  --text-main: #0f172a;
  --text-muted: #64748b;

  /* System fonts paint immediately and avoid delaying LCP on slow links. */
  --font-head: ui-rounded, 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  --font-body: 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;

  --primary: #4f46e5;
  --primary-gradient: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
  --accent: #d97706;
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;

  --shadow-flat: 0 10px 30px -5px rgba(0, 0, 0, 0.05), 0 4px 6px -2px rgba(0, 0, 0, 0.02);
  --shadow-flat-sm: 0 4px 12px -2px rgba(0, 0, 0, 0.04);
  --shadow-pressed: inset 0 2px 4px 0 rgba(0, 0, 0, 0.05);
  --shadow-hover: 0 20px 30px -10px rgba(79, 70, 229, 0.15), 0 10px 15px -5px rgba(0, 0, 0, 0.04);
  --border-subtle: 1px solid rgba(226, 232, 240, 0.8);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}



/* Idle & Stalled Delay Alert Badges */
.badge-idle {
  background: rgba(245, 158, 11, 0.15);
  color: #d97706;
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.badge-stalled {
  background: rgba(239, 68, 68, 0.15);
  color: #dc2626;
  border: 1px solid rgba(239, 68, 68, 0.3);
  animation: pulseAlert 2s infinite;
}

@keyframes pulseAlert {
  0% { opacity: 1; }
  50% { opacity: 0.65; }
  100% { opacity: 1; }
}

/* Invalid input state */
.input-error {
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.2) !important;
  border-color: var(--danger) !important;
  color: var(--danger);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ── History Log Modal Table ────────── */
.history-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 0.5rem;
  font-size: 0.85rem;
  font-family: var(--font-body);
}

.history-table th {
  text-align: left;
  padding: 0.75rem 0.9rem;
  color: var(--text-muted);
  font-family: var(--font-head);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: #f1f5f9;
}

.history-table td {
  padding: 0.75rem 0.9rem;
  border-bottom: 1px solid #f1f5f9;
  color: var(--text-main);
}

.history-table tr:hover td {
  background: rgba(79, 70, 229, 0.04);
}

.badge-qty {
  background: rgba(245, 158, 11, 0.15);
  color: #b45309;
  border: 1px solid rgba(245, 158, 11, 0.3);
}

/* ── Reset ───────────────────────────── */
html, body {
  width: 100%;
  max-width: 100%;
}

body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--bg-main);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6, .proj-card-title, .modal-title {
  font-family: var(--font-head);
  letter-spacing: -0.02em;
}

/* ── Header ──────────────────────────── */
.header {
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(14px);
  border-bottom: var(--border-subtle);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.03);
  padding: 0.65rem 1.6rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.85rem;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  flex-shrink: 0;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text-main);
  margin: 0;
  white-space: nowrap;
}

.header-logo {
  height: 30px;
  width: 30px;
  object-fit: contain;
}

.nav-tabs {
  display: flex;
  gap: 0.45rem;
  margin: 0;
  align-items: center;
}

.nav-tab {
  padding: 0.42rem 0.95rem;
  border-radius: 10px;
  font-size: 0.82rem;
  font-weight: 700;
  font-family: var(--font-head);
  color: var(--text-muted);
  background: #f1f5f9;
  border: 1px solid transparent;
  transition: all 0.2s ease;
  white-space: nowrap;
  cursor: pointer;
}

.nav-tab:hover {
  background: #e2e8f0;
  color: var(--text-main);
}

.nav-tab.active {
  color: #ffffff;
  background: var(--primary-gradient);
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.28);
}

.header-right,
.project-bar {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  justify-content: flex-end;
  flex-shrink: 0;
}

.header-action-btn {
  font-size: 0.78rem;
  padding: 0.42rem 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}

.notification-bell {
  position: relative;
  min-width: 38px;
  min-height: 34px;
  padding: 0.35rem 0.6rem;
  font-size: 0.95rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.user-profile-widget {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  background: var(--bg-main);
  box-shadow: var(--shadow-pressed);
  padding: 0.3rem 0.65rem;
  border-radius: 10px;
  white-space: nowrap;
}

.user-profile-name {
  font-weight: 700;
  font-size: 0.82rem;
  color: var(--text-main);
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.btn-user-profile {
  font-size: 0.72rem;
  padding: 0.25rem 0.45rem;
  border-radius: 6px;
  white-space: nowrap;
}

.notification-count {
  position: absolute;
  top: -7px;
  right: -7px;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #dc2626;
  color: #fff;
  border: 2px solid #fff;
  font-size: 0.68rem;
  line-height: 1;
  font-weight: 800;
  box-shadow: 0 3px 8px rgba(220, 38, 38, 0.3);
}

.notification-modal {
  width: min(680px, 94vw);
  max-height: min(760px, 90vh);
  text-align: left;
  display: flex;
  flex-direction: column;
}

.notification-modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.notification-summary {
  color: var(--text-muted);
  font-size: 0.82rem;
  margin-top: 0.25rem;
}

.notifications-list {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  min-height: 110px;
  max-height: 56vh;
  overflow-y: auto;
  padding: 0.15rem 0.25rem 0.15rem 0.1rem;
}

.notification-item {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  gap: 0.75rem;
  align-items: start;
  padding: 0.85rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
}

.notification-item.unread {
  border-color: rgba(79, 70, 229, 0.35);
  background: rgba(79, 70, 229, 0.055);
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.08);
}

.notification-icon {
  width: 42px;
  height: 42px;
  border-radius: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-main);
  font-size: 1.15rem;
}

.notification-title-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.25rem;
}

.notification-title-row strong { color: var(--text-main); }
.notification-message { color: var(--text-muted); font-size: 0.82rem; line-height: 1.45; }
.notification-meta { color: var(--text-muted); font-size: 0.72rem; margin-top: 0.4rem; }
.notification-unread-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--primary); }
.notification-open-btn { white-space: nowrap; align-self: center; }
.header-proj-select {
  max-width: 210px;
  min-width: 130px;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.82rem;
  padding: 0.38rem 0.6rem;
  font-weight: 600;
}

.header-proj-lbl {
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
}

.user-role-badge {
  background: var(--primary);
  color: #fff;
  font-size: 0.72rem;
  padding: 0.2rem 0.45rem;
}

/* Responsive adjustments for laptop, tablet, and mobile screens */
@media (max-width: 1380px) {
  .header {
    flex-wrap: wrap;
    padding: 0.55rem 1.2rem;
    gap: 0.5rem 0.8rem;
  }
  .header-left {
    justify-content: space-between;
    width: 100%;
  }
  .header-right,
  .project-bar {
    width: 100%;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 0.45rem;
  }
}

@media (max-width: 768px) {
  .header-left {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.45rem;
  }
  .nav-tabs {
    width: 100%;
    overflow-x: auto;
    padding-bottom: 0.2rem;
  }
  .header-right,
  .project-bar {
    justify-content: flex-start;
  }
}

/* ── Dashboard Portfolio View ────────── */
.hidden { display: none !important; }

/* Executive viewers may read reports but cannot open operational audit history. */
body[data-user-role="viewer"] .view-history-btn { display: none !important; }

.dashboard-banner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.8rem;
  background: var(--bg-main);
  box-shadow: var(--shadow-flat);
  padding: 1.5rem 2rem;
  border-radius: 18px;
}
.dashboard-banner h2 { font-size: 1.3rem; font-weight: 800; margin-bottom: 0.3rem; }

.projects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 1.5rem;
}

.project-summary-card {
  background: var(--bg-main);
  box-shadow: var(--shadow-flat);
  border-radius: 20px;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: transform 0.2s, box-shadow 0.2s;
}
.project-summary-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-hover);
}

.proj-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  border-bottom: 1px solid rgba(163,177,198,0.3);
  padding-bottom: 0.8rem;
}
.proj-card-title { font-size: 1.1rem; font-weight: 800; color: var(--text-main); }

.proj-card-stats {
  display: flex;
  gap: 1rem;
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.proj-stage-bars {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  background: var(--bg-main);
  box-shadow: var(--shadow-pressed);
  padding: 0.9rem;
  border-radius: 12px;
  margin-bottom: 1.2rem;
}

/* ── Inputs & Selects ────────────────── */
select, input, button, textarea {
  box-sizing: border-box !important;
}

select, input[type="text"], input[type="password"], input[type="number"], input[type="date"] {
  background: var(--bg-main);
  box-shadow: var(--shadow-pressed);
  border: none;
  color: var(--text-main);
  padding: 0.55rem 0.9rem;
  border-radius: 10px;
  font-size: 0.88rem;
  outline: none;
  transition: box-shadow 0.2s;
  width: 100%;
  box-sizing: border-box !important;
}
select:focus, input:focus {
  box-shadow: inset 3px 3px 6px rgba(163,177,198,0.7),
              inset -3px -3px 6px rgba(255,255,255,0.8),
              0 0 0 2px var(--primary);
}
input[type="number"] { width: 68px; text-align: center; padding: 0.45rem 0.4rem; }
input[type="date"]   { padding: 0.45rem 0.7rem; }

.act-unit-target {
  min-width: 75px !important;
  text-align: center;
}
.act-weight-pct {
  min-width: 60px !important;
  text-align: center;
}

.password-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  width: 100% !important;
  box-sizing: border-box !important;
}
.password-input-wrapper input {
  width: 100% !important;
  flex: 1 1 100% !important;
  padding-right: 2.5rem !important;
  box-sizing: border-box !important;
}
.password-toggle-btn {
  position: absolute;
  right: 0.65rem;
  top: 50%;
  transform: translateY(-50%);
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  margin: 0;
  appearance: none;
  -webkit-appearance: none;
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  padding: 0 !important;
  line-height: 1;
  color: var(--text-muted);
  cursor: pointer;
  opacity: 0.7;
  transition: color 0.2s, opacity 0.2s;
  user-select: none;
}
.password-toggle-icon {
  width: 1.05rem;
  height: 1.05rem;
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
}
.password-toggle-icon[hidden] { display: none !important; }
.password-toggle-hide { display: none; }
.password-toggle-btn.is-revealed .password-toggle-show { display: none; }
.password-toggle-btn.is-revealed .password-toggle-hide { display: block; }
.password-toggle-btn:hover:not(:disabled),
.password-toggle-btn:active:not(:disabled) {
  color: var(--primary);
  background: transparent !important;
  transform: translateY(-50%) !important;
  box-shadow: none !important;
  opacity: 1;
}

.password-toggle-btn:focus-visible {
  transform: translateY(-50%) !important;
  border-radius: 50%;
  outline-offset: 0;
}

/* Password managers expect a username context in password-change forms. */
.credential-username-context {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

/* ── Buttons ─────────────────────────── */
button {
  cursor: pointer;
  background: var(--bg-main);
  box-shadow: var(--shadow-flat-sm);
  border: none;
  color: var(--primary);
  font-weight: 600;
  font-size: 0.88rem;
  padding: 0.55rem 1.1rem;
  border-radius: 10px;
  transition: box-shadow 0.2s, transform 0.15s;
}

button:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: var(--shadow-hover);
}

button:active:not(:disabled) {
  transform: translateY(0);
  box-shadow: var(--shadow-pressed);
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(79, 70, 229, 0.35);
  outline-offset: 2px;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
  box-shadow: none;
  transform: none;
}

.btn-primary {
  background: var(--primary-gradient);
  color: #fff;
  box-shadow: 0 6px 14px rgba(79, 70, 229, 0.25);
}

.btn-primary:hover:not(:disabled) {
  color: #fff;
}

.btn-secondary {
  background: #fff;
  color: var(--primary);
  border: 1px solid rgba(99, 102, 241, 0.18);
}

.btn-danger {
  background: #fef2f2;
  color: #dc2626;
  border: 1px solid rgba(220, 38, 38, 0.2);
}

.btn-sm {
  min-width: 2rem;
  padding: 0.35rem 0.55rem;
  font-size: 0.78rem;
}
/* ── BOQ Table Spreadsheet Layout ──────── */
.boq-table {
  font-family: var(--font-body);
  font-size: 0.85rem;
  width: 100%;
}
.boq-table th {
  font-family: var(--font-head);
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 0.6rem 0.4rem;
  background: #f1f5f9;
  border-bottom: 2px solid #e2e8f0;
  text-align: left;
  white-space: nowrap;
}
.boq-table td {
  padding: 0.5rem 0.35rem;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
}
.boq-table tr:hover td {
  background: rgba(79, 70, 229, 0.03);
}
.boq-table tr.status-cancelled td {
  opacity: 0.6;
  background: #fef2f2;
}
.boq-act-cell {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 0.5rem 0.6rem;
  min-width: 165px;
}

/* Quick Stepper & Batch Action Buttons */
.btn-chip {
  background: var(--bg-main);
  box-shadow: var(--shadow-flat-sm);
  border: 1px solid rgba(163,177,198,0.3);
  color: var(--text-main);
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.2rem 0.45rem;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
  line-height: 1;
}
.btn-chip:hover {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  box-shadow: var(--shadow-hover);
}
.btn-chip:active {
  box-shadow: var(--shadow-pressed);
  transform: scale(0.95);
}
.btn-chip-fill {
  background: rgba(16,185,129,0.12);
  color: var(--success);
  border-color: rgba(16,185,129,0.3);
}
.btn-chip-fill:hover {
  background: var(--success);
  color: #fff;
}
.quick-batch-bar {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
  background: rgba(226,232,240,0.5);
  padding: 0.5rem 0.8rem;
  border-radius: 10px;
  margin-bottom: 1rem;
}
input[type="number"]:focus, input[type="text"]:focus {
  background: #ffffff !important;
  border-color: var(--primary) !important;
  box-shadow: 0 0 0 3px rgba(59,130,246,0.2) !important;
  outline: none;
}

/* ── Main Layout ─────────────────────── */
.main-container {
  flex: 1;
  max-width: 1600px;
  margin: 0 auto;
  width: 98%;
  padding: 1.5rem 1rem;
}

/* ── Stats ───────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1.2rem;
  margin-bottom: 2rem;
}
.stats-grid.grid-5 {
  grid-template-columns: repeat(5, 1fr);
}
.stats-grid.grid-6 {
  grid-template-columns: repeat(6, 1fr);
}
.stats-grid.grid-7 {
  grid-template-columns: repeat(7, 1fr);
}
.stats-grid.grid-8 {
  grid-template-columns: repeat(8, 1fr);
}
.stats-grid.grid-9 {
  grid-template-columns: repeat(9, 1fr);
}
.stats-grid.grid-10 {
  grid-template-columns: repeat(10, 1fr);
}
@media (max-width: 1600px) {
  .stats-grid.grid-10 { grid-template-columns: repeat(5, 1fr); }
}
@media (max-width: 1400px) {
  .stats-grid.grid-7, .stats-grid.grid-8, .stats-grid.grid-9, .stats-grid.grid-10 { grid-template-columns: repeat(4, 1fr); }
}
@media (max-width: 1000px) {
  .stats-grid.grid-5, .stats-grid.grid-6, .stats-grid.grid-7, .stats-grid.grid-8, .stats-grid.grid-9, .stats-grid.grid-10 { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 800px) {
  .stats-grid, .stats-grid.grid-5, .stats-grid.grid-6, .stats-grid.grid-7, .stats-grid.grid-8, .stats-grid.grid-9, .stats-grid.grid-10 { grid-template-columns: repeat(2, 1fr); }
}

/* ── Commercial Valuation Summary Bar ── */
.commercial-valuation-bar {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}
@media (max-width: 960px) {
  .commercial-valuation-bar {
    grid-template-columns: 1fr;
  }
}
.val-summary-card {
  background: var(--bg-card);
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  padding: 1rem 1.15rem;
  box-shadow: var(--shadow-flat-sm);
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}
.val-summary-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-flat);
  border-color: #cbd5e1;
}
.val-summary-card.active-val-card {
  border-color: #6366f1;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.05), rgba(79, 70, 229, 0.02));
  box-shadow: 0 4px 16px rgba(99, 102, 241, 0.14);
}
.val-summary-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(226, 232, 240, 0.8);
  padding-bottom: 0.45rem;
}
.val-summary-title {
  font-family: var(--font-head);
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-main);
}
.val-summary-body {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.val-summary-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
}
.val-summary-lbl {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
}
.val-summary-num {
  font-size: 0.95rem;
  font-weight: 800;
  white-space: nowrap;
}
.val-summary-num.val-blue {
  color: #2563eb;
}
.val-summary-num.val-purple {
  color: #7c3aed;
}
.val-summary-num.val-amber {
  color: #d97706;
}
.val-summary-num.val-green {
  color: #059669;
}
.val-summary-num.val-teal {
  color: #0d9488;
}
.val-summary-meta {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-top: 0.2rem;
}
.val-progress-track {
  flex: 1;
  height: 6px;
  background: #e2e8f0;
  border-radius: 999px;
  overflow: hidden;
}
.val-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #6366f1, #10b981);
  border-radius: 999px;
  transition: width 0.3s ease;
}
.val-progress-text {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
  white-space: nowrap;
}

.stat-card {
  background: var(--bg-main);
  box-shadow: var(--shadow-flat);
  padding: 1.3rem 1.5rem;
  border-radius: 16px;
}
.stat-card .label {
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin-bottom: 0.4rem;
}
.stat-card .val { font-size: 2rem; font-weight: 800; line-height: 1; }

/* ── Toolbar ─────────────────────────── */
.toolbar {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  margin-bottom: 1.5rem;
  gap: 0.75rem;
}

.toolbar-left {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.toolbar-right {
  justify-content: flex-start;
}

.activity-chips {
  min-width: 0;
  max-width: 100%;
  flex-wrap: wrap !important;
  overflow: visible;
  padding: 0.15rem 0;
}

.activity-chips > * {
  flex: 0 0 auto;
}

/* Dashboard Status Filter Tabs */
.dashboard-filter-tabs {
  display: flex;
  gap: 0.5rem;
  margin: 0 0 0.85rem;
  flex-wrap: wrap;
  align-items: center;
}

.dash-tab {
  padding: 0.5rem 1rem;
  border-radius: 10px;
  font-size: 0.85rem;
  font-weight: 700;
  font-family: var(--font-head);
  color: var(--text-muted);
  background: var(--bg-card);
  border: 1px solid #e2e8f0;
  box-shadow: var(--shadow-flat-sm);
  transition: all 0.2s ease;
  white-space: nowrap;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}

.dash-tab:hover {
  background: #f1f5f9;
  color: var(--text-main);
  border-color: #cbd5e1;
}

.dash-tab.active {
  color: #ffffff;
  background: var(--primary-gradient);
  border-color: transparent;
  box-shadow: 0 4px 14px rgba(79, 70, 229, 0.28);
}

.dash-tab .tab-badge {
  font-size: 0.72rem;
  font-weight: 800;
  padding: 0.15rem 0.45rem;
  border-radius: 20px;
  background: rgba(0, 0, 0, 0.08);
  color: inherit;
  line-height: 1;
}

.dash-tab.active .tab-badge {
  background: rgba(255, 255, 255, 0.25);
  color: #ffffff;
}

.search-filter-group {
  display: flex;
  gap: 0.75rem;
}

.search-input {
  padding: 0.6rem 1rem;
  border: none;
  border-radius: 8px;
  font-size: 0.9rem;
  min-width: 250px;
  background: var(--bg-main);
  box-shadow: var(--shadow-pressed);
  transition: box-shadow 0.2s;
}

.search-input:focus {
  outline: none;
  box-shadow: inset 3px 3px 6px rgba(163,177,198,0.7),
              inset -3px -3px 6px rgba(255,255,255,0.8),
              0 0 0 2px var(--primary);
}

.filter-select {
  padding: 0.6rem 1rem;
  border: none;
  border-radius: 8px;
  font-size: 0.9rem;
  background: var(--bg-main);
  box-shadow: var(--shadow-pressed);
  cursor: pointer;
}

.report-date-control {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}

.report-date-control label {
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 700;
  white-space: nowrap;
}

.report-date-control .filter-select {
  min-width: 9.75rem;
  padding: 0.55rem 0.65rem;
}

.toolbar h2 { font-size: 1.15rem; font-weight: 700; }

/* ── Item List ───────────────────────── */
.items-list { display: flex; flex-direction: column; gap: 1.2rem; }

.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 3rem;
  box-shadow: var(--shadow-pressed);
  border-radius: 16px;
}

/* ── Item Card ───────────────────────── */
.item-card {
  background: var(--bg-main);
  box-shadow: var(--shadow-flat);
  border-radius: 16px;
  padding: 1.2rem 1.5rem;
  transition: box-shadow 0.25s, padding 0.2s;
}
.item-card.cancelled { opacity: 0.65; }
.item-card.collapsed {
  padding: 0.75rem 1.2rem;
}
.item-card.collapsed .item-body {
  display: none;
}

.item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.8rem;
  flex-wrap: nowrap;
  overflow-x: auto;
}
.item-card:not(.collapsed) .item-header {
  padding-bottom: 0.8rem;
  margin-bottom: 0.8rem;
  border-bottom: 1px solid rgba(163,177,198,0.35);
}

.item-header-left {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: nowrap;
  flex-shrink: 0;
}

.toggle-expand-btn {
  padding: 0.3rem 0.55rem;
  font-size: 0.76rem;
  border-radius: 8px;
  background: var(--bg-main);
  box-shadow: var(--shadow-flat-sm);
  color: var(--primary);
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-weight: 700;
  white-space: nowrap;
}
.toggle-expand-btn:hover {
  box-shadow: var(--shadow-hover);
}

/* ── BOQ Spreadsheet Data Table ─────────────── */
.boq-table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--bg-card);
  box-shadow: var(--shadow-flat);
  border-radius: 18px;
  padding: 1rem;
  margin-top: 1rem;
  width: 100%;
  max-width: 100%;
}

.boq-table {
  width: 100%;
  min-width: 980px;
  border-collapse: separate;
  border-spacing: 0;
}

.boq-table th {
  background: #f1f5f9;
  color: var(--text-muted);
  font-family: var(--font-head);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  padding: 0.55rem 0.5rem;
  white-space: nowrap;
  border-bottom: 2px solid #e2e8f0;
}

.boq-table td {
  padding: 0.5rem 0.45rem;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
}

.boq-table th:last-child,
.boq-table td:last-child {
  min-width: 200px;
  max-width: 215px;
  white-space: normal;
  text-align: center;
  position: sticky;
  right: 0;
  background: var(--bg-card);
  z-index: 2;
  box-shadow: -4px 0 8px rgba(0, 0, 0, 0.06);
  border-left: 1px solid rgba(226, 232, 240, 0.85);
}

.boq-table thead th:last-child {
  background: #f1f5f9;
  z-index: 4;
}

.boq-table tbody tr:nth-child(even) td:last-child {
  background: #f8fafc;
}

.boq-table tbody tr:nth-child(odd) td:last-child {
  background: #ffffff;
}

.boq-table tbody tr:hover td:last-child {
  background: #eef2ff;
}

.boq-table tbody tr.status-cancelled td:last-child {
  background: #fef2f2;
}

.boq-table tbody tr.row-updated-highlight td:last-child {
  background: #f0fdfa;
}

/* Operational views have fewer columns than the planning spreadsheet. Give
   procurement, production, delivery, and installation the same compact
   behavior, while keeping the table's scroll contained in its own wrapper. */
.boq-table.stage-operational-table,
.boq-table.stage-installation-table {
  min-width: 720px;
  table-layout: auto;
}

.boq-table.stage-operational-table th,
.boq-table.stage-operational-table td,
.boq-table.stage-installation-table th,
.boq-table.stage-installation-table td {
  padding: 0.55rem 0.5rem;
  white-space: normal;
}

.boq-table.stage-operational-table th:last-child,
.boq-table.stage-operational-table td:last-child,
.boq-table.stage-installation-table th:last-child,
.boq-table.stage-installation-table td:last-child {
  min-width: 180px;
  max-width: 215px;
  white-space: normal;
  position: sticky;
  right: 0;
  background: var(--bg-card);
  z-index: 2;
  box-shadow: -4px 0 8px rgba(0, 0, 0, 0.06);
  border-left: 1px solid rgba(226, 232, 240, 0.85);
}

.boq-table.stage-operational-table thead th:last-child,
.boq-table.stage-installation-table thead th:last-child {
  background: #f1f5f9;
  z-index: 4;
}

.boq-table .stage-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.25rem 0.35rem;
}

.boq-table .stage-actions button {
  padding: 0.32rem 0.55rem;
  font-size: 0.78rem;
  white-space: nowrap;
  border-radius: 6px;
}

.boq-table input[type="text"],
.boq-table input[type="number"] {
  padding: 0.35rem 0.5rem;
  font-size: 0.82rem;
  border-radius: 6px;
}

.boq-table .operational-description-cell {
  min-width: 160px;
  max-width: 280px;
  color: var(--text-main);
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.boq-table tr:hover td {
  background: rgba(79, 70, 229, 0.03);
}

.boq-table tr.status-cancelled td {
  opacity: 0.55;
  text-decoration: line-through;
}

.boq-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
}

.boq-table tbody tr:nth-child(even) td {
  background: rgba(241, 245, 249, 0.45);
}

@keyframes rowUpdatedHighlight {
  0% {
    background-color: rgba(15, 118, 110, 0.32) !important;
  }
  30% {
    background-color: rgba(15, 118, 110, 0.22) !important;
  }
  70% {
    background-color: rgba(15, 118, 110, 0.10) !important;
  }
  100% {
    background-color: inherit;
  }
}

.boq-table tr.row-updated-highlight td {
  animation: rowUpdatedHighlight 2s ease-out;
}

.quick-stage-tabs {
  display: flex;
  gap: 0.3rem;
  align-items: center;
}
.quick-stage-btn {
  font-size: 0.75rem;
  padding: 0.3rem 0.6rem;
  border-radius: 8px;
  box-shadow: var(--shadow-flat-sm);
  background: var(--bg-main);
  color: var(--text-muted);
  font-weight: 600;
  white-space: nowrap;
}
.quick-stage-btn.active {
  box-shadow: var(--shadow-pressed);
  color: var(--primary);
  font-weight: 800;
}

.preset-filter-tab {
  font-size: 0.78rem;
  padding: 0.35rem 0.75rem;
  border-radius: 8px;
  background: var(--bg-main);
  box-shadow: var(--shadow-flat-sm);
  color: var(--text-muted);
  font-weight: 600;
}
.preset-filter-tab.active {
  box-shadow: var(--shadow-pressed);
  color: var(--primary);
  font-weight: 800;
}

.item-title-group { display: flex; gap: 0.45rem; align-items: center; flex-wrap: nowrap; }
.item-tag-label   { font-weight: 800; font-size: 1rem; white-space: nowrap; }
.item-actions     { display: flex; gap: 0.4rem; align-items: center; flex-shrink: 0; flex-wrap: nowrap; }

/* Badges */
.badge {
  padding: 0.25rem 0.7rem;
  border-radius: 8px;
  font-size: 0.72rem;
  font-weight: 700;
  box-shadow: var(--shadow-flat-sm);
  white-space: nowrap;
}
.badge-tag              { color: var(--primary); }
.badge-type             { color: #805ad5; }
.badge-status-active    { color: var(--success); }
.badge-status-cancelled { color: var(--danger); }

/* ── Progress Bar ──────────────────────/* ── Multi-stage Progress Summary ────── */
.stage-progress-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.2rem;
  margin: 1rem 0;
  background: var(--bg-main);
  box-shadow: var(--shadow-pressed);
  padding: 1rem;
  border-radius: 14px;
}

.stage-prog-item { display: flex; flex-direction: column; gap: 0.4rem; }
.stage-prog-head {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
}
.stage-prog-head strong { color: var(--text-main); }

.bar-prod { background: linear-gradient(90deg, #f59e0b, #fbbf24); }
.bar-del  { background: linear-gradient(90deg, #06b6d4, #38bdf8); }
.bar-inst { background: linear-gradient(90deg, var(--primary), var(--accent)); }

.act-chip {
  font-size: 0.65rem;
  background: rgba(77, 124, 255, 0.15);
  color: var(--primary);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  margin-left: 0.3rem;
}

.progress-container { margin: 0.8rem 0 0; }
.progress-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
}
.progress-pct { display: flex; align-items: center; gap: 0.4rem; font-size: 0.9rem; color: var(--text-main); }
.progress-pct strong { font-size: 1.1rem; color: var(--primary); }

.manual-badge {
  font-size: 0.62rem;
  background: rgba(77,124,255,0.12);
  color: var(--primary);
  padding: 0.1rem 0.4rem;
  border-radius: 5px;
}
.calc-badge { font-size: 0.72rem; color: var(--text-muted); }

.progress-bar-outer {
  height: 12px;
  background: var(--bg-main);
  box-shadow: var(--shadow-pressed);
  border-radius: 8px;
  overflow: hidden;
  padding: 2px;
}
.progress-bar-inner {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  border-radius: 6px;
  transition: width 0.4s ease;
}

/* ── Stage Tabs ──────────────────────── */
.stage-tabs {
  display: flex;
  gap: 0.4rem;
  margin-top: 1.2rem;
  flex-wrap: wrap;
}
.stage-tab {
  padding: 0.4rem 0.9rem;
  border-radius: 9px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  box-shadow: var(--shadow-flat-sm);
  background: var(--bg-main);
  transition: all 0.2s;
}
.stage-tab.active {
  color: var(--primary);
  box-shadow: var(--shadow-pressed);
}

.stage-mode-tab {
  padding: 0.6rem 0.9rem;
  border-radius: 10px;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-muted);
  box-shadow: var(--shadow-flat-sm);
  background: var(--bg-main);
  transition: all 0.2s ease;
  border: none;
  cursor: pointer;
}
.stage-mode-tab:hover {
  color: var(--primary);
  box-shadow: var(--shadow-hover);
}
.stage-mode-tab.active {
  color: #ffffff !important;
  background: var(--primary) !important;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.35) !important;
}

/* ── Stage Panel ─────────────────────── */
.stage-panel { display: none; padding-top: 1rem; }
.stage-panel.active { display: block; }

.stage-note {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.77rem;
  color: var(--text-muted);
  background: var(--bg-main);
  box-shadow: var(--shadow-pressed);
  border-radius: 8px;
  padding: 0.45rem 0.8rem;
  margin-bottom: 1rem;
}

.panel-footer {
  display: flex;
  justify-content: flex-end;
  margin-top: 1rem;
}

/* ── Activities Grid ─────────────────── */
.act-grid {
  display: grid;
  gap: 0.8rem;
  background: var(--bg-main);
  box-shadow: var(--shadow-pressed);
  padding: 1rem;
  border-radius: 14px;
}

/* modal container uses same class */
#modalActivitiesContainer {
  display: grid;
  gap: 0.8rem;
  background: var(--bg-main);
  box-shadow: var(--shadow-pressed);
  padding: 1rem;
  border-radius: 14px;
  margin-bottom: 0.5rem;
}

.act-box {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  min-width: 0;
}
.act-box > label {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Delivery activity cards can be narrow when an item has many activities.
   Keep the quick-fill buttons on their own grid row so “Remaining” never
   spills outside the card. */
.delivery-today-header,
.activity-today-header {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 0.35rem;
}

.delivery-today-label,
.activity-today-label {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--accent);
}

.delivery-step-controls,
.activity-step-controls {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.2rem;
  width: 100%;
}

.delivery-step-controls .btn-chip,
.activity-step-controls .btn-chip {
  width: 100%;
  min-width: 0;
  white-space: nowrap;
}

.act-qty-row {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}
.qty-label {
  font-size: 0.68rem;
  color: var(--text-muted);
  min-width: 46px;
}
.qty-of {
  font-size: 0.72rem;
  color: var(--text-muted);
  white-space: nowrap;
}

/* ── Date Row inside panels ──────────── */
.dates-row {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
  align-items: flex-end;
}
.date-field { display: flex; flex-direction: column; gap: 0.3rem; }
.date-field > label { font-size: 0.75rem; color: var(--text-muted); font-weight: 600; }

/* ── Modal ───────────────────────────── */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  inset: 0;
  background: rgba(224,229,236,0.75);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  overflow-y: auto;
  padding: 1rem;
}
#userManagementModal, #editUserModal, #presetsModal, #restoreItemsModal, #importResultModal {
  z-index: 1100;
}
.modal-overlay.hidden { display: none !important; }

/* ── Loading Overlay & Spinner ───────── */
#loadingOverlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  inset: 0;
  background: rgba(224, 229, 236, 0.4);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid var(--bg-main);
  border-top: 4px solid var(--primary);
  border-radius: 50%;
  box-shadow: var(--shadow-flat-sm);
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

body.loading {
  overflow: hidden;
}

.modal {
  background: var(--bg-main);
  box-shadow: var(--shadow-hover);
  border-radius: 20px;
  padding: 2rem 2.2rem;
  width: 100%;
  max-width: 640px;
  max-height: 90vh;
  overflow-y: auto;
}
.modal-title  { font-size: 1.2rem; font-weight: 800; margin-bottom: 1.4rem; }
.form-group   { display: flex; flex-direction: column; gap: 0.35rem; margin-bottom: 1rem; }
.form-group > label { font-size: 0.8rem; color: var(--text-muted); font-weight: 600; }
.form-group > input,
.form-group > select { width: 100%; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.modal-actions { display: flex; justify-content: flex-end; gap: 1rem; margin-top: 1.5rem; }

/* Participant links: compact rows and an independently scrolling list. */
#momParticipantsModal .mom-participants-dialog {
  max-width: 640px;
  padding: 1.4rem;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  gap: 1rem;
}
#momParticipantsModal header h3 { margin: 0 0 0.5rem; }
#momParticipantsModal header p { margin: 0; font-size: 0.85rem; color: var(--text-muted); line-height: 1.5; }
#momParticipantChoices { min-height: 0; overflow-y: auto; padding-right: 0.4rem; }
#momParticipantsModal .mom-participant-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 240px);
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0;
  border-bottom: 1px solid var(--border-color, #e2e8f0);
}
#momParticipantsModal .mom-participant-row[hidden] { display: none; }
#momParticipantsModal .mom-participant-label { display: flex; gap: 0.65rem; align-items: center; margin: 0; min-width: 0; }
#momParticipantsModal .mom-participant-identity { min-width: 0; }
#momParticipantsModal .mom-participant-identity strong { display: block; font-size: 0.88rem; overflow-wrap: anywhere; }
#momParticipantsModal .mom-participant-identity small { display: block; margin-top: 0.15rem; font-size: 0.76rem; color: var(--text-muted); }
#momParticipantsModal .mom-participant-account { width: 100%; min-width: 0; margin: 0; font-size: 0.8rem; }
#momParticipantsModal .modal-actions { flex-shrink: 0; margin: 0; padding-top: 0.5rem; gap: 0.6rem; }
@media (max-width: 560px) {
  #momParticipantsModal .mom-participants-dialog { padding: 1rem; }
  #momParticipantsModal .mom-participant-row { grid-template-columns: minmax(0, 1fr); gap: 0.4rem; }
}

/* Add-item form: keep all BOQ details compact and readable without leaving a
   sparse grid. */
.item-modal-intro {
  color: var(--text-muted);
  font-size: 0.84rem;
  margin: -0.65rem 0 1.1rem;
}
.item-form-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.15rem 0.9rem;
}
.item-form-grid .form-group { min-width: 0; }
.item-field-boq { grid-column: span 2; }
.item-field-half { grid-column: span 2; }
.item-field-full { grid-column: 1 / -1; }
.item-type-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.4rem 0.65rem;
  margin: 0;
  padding: 0.75rem;
  border: 1px solid rgba(226, 232, 240, 0.9);
  border-radius: 12px;
  background: var(--bg-main);
}
.item-type-options legend {
  padding: 0 0.2rem;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 600;
}
.item-type-options label {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--text-main);
  font-size: 0.79rem;
  font-weight: 600;
  cursor: pointer;
}
.item-type-options input[type="checkbox"] {
  width: auto;
  min-width: 1rem;
  height: 1rem;
  margin: 0;
  accent-color: var(--primary);
}
.item-optional-details {
  margin-top: 0.2rem;
  padding: 0.75rem 0.9rem;
  border-radius: 12px;
  background: var(--bg-main);
  box-shadow: var(--shadow-pressed);
}
.item-optional-details summary {
  cursor: pointer;
  color: var(--primary);
  font-size: 0.82rem;
  font-weight: 700;
}
.item-optional-grid { margin-top: 0.85rem; }

.section-label {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: 1rem 0 0.5rem;
}

/* ── Responsive Mobile Styles ─────────────────────────── */
@media (max-width: 1000px) {
  .header {
    flex-direction: column;
    padding: 1rem;
    gap: 1rem;
    align-items: stretch;
  }
  .header h1 {
    text-align: center;
  }
  .nav-tabs {
    justify-content: center;
    margin: 0;
  }
  .project-bar {
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.8rem;
  }
  #userProfileWidget {
    margin-left: 0;
    justify-content: center;
    width: 100%;
  }
  .dashboard-banner {
    flex-direction: column;
    text-align: center;
    gap: 1rem;
  }
}

@media (max-width: 768px) {
  html, body {
    width: 100% !important;
    max-width: 100% !important;
  }

  .main-container {
    padding: 0.75rem !important;
    width: 100% !important;
    max-width: 100% !important;
  }

  .header {
    padding: 0.75rem 0.8rem !important;
    width: 100% !important;
    box-sizing: border-box !important;
  }

  .header h1 {
    font-size: 1.15rem !important;
    justify-content: center !important;
  }

  .nav-tabs {
    width: 100% !important;
    justify-content: center !important;
    gap: 0.4rem !important;
  }

  .nav-tab {
    flex: 1;
    text-align: center;
    padding: 0.55rem 0.4rem !important;
    font-size: 0.78rem !important;
  }

  .project-bar {
    width: 100% !important;
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 0.6rem !important;
  }

  #headerProjectSelectGroup {
    width: 100% !important;
    flex-direction: column !important;
    align-items: stretch !important;
  }

  #projectSelect {
    width: 100% !important;
    min-width: 0 !important;
  }

  #userProfileWidget {
    width: 100% !important;
    flex-wrap: wrap !important;
    justify-content: center !important;
    margin-left: 0 !important;
    padding: 0.4rem !important;
  }

  .notification-bell {
    align-self: center;
  }

  .notification-modal-header {
    flex-direction: column;
  }

  .notification-item {
    grid-template-columns: 36px minmax(0, 1fr);
  }

  .notification-icon {
    width: 36px;
    height: 36px;
  }

  .notification-open-btn {
    grid-column: 1 / -1;
    width: 100%;
  }

  .stats-grid, .stats-grid.grid-5, .stats-grid.grid-6 {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 0.65rem !important;
  }

  .stat-card {
    padding: 0.85rem 0.9rem !important;
  }

  .stat-card .val {
    font-size: 1.35rem !important;
  }

  .boq-table-wrapper {
    width: 100% !important;
    max-width: 100% !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
    padding: 0.5rem !important;
    display: block !important;
    border-radius: 12px !important;
  }

  .boq-table.stage-operational-table,
  .boq-table.stage-installation-table {
    min-width: 640px;
  }

  .toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .toolbar-left {
    flex-direction: column;
    align-items: stretch;
    width: 100%;
  }

  .search-filter-group {
    flex-direction: column;
    align-items: stretch;
    width: 100%;
  }

  .search-input {
    min-width: unset;
    width: 100%;
  }

  .toolbar-right {
    flex-direction: column;
    align-items: stretch;
    width: 100%;
  }

  .toolbar-right button {
    width: 100%;
  }

  .stage-mode-bar {
    flex-direction: column !important;
    align-items: stretch !important;
  }

  .stage-mode-tab {
    width: 100% !important;
  }

  #activityBreakdownBar {
    flex-direction: column !important;
    align-items: stretch !important;
  }

  #activityChipsContainer {
    width: 100% !important;
  }

  .act-chip {
    font-size: 0.72rem !important;
    padding: 0.2rem 0.4rem !important;
  }

  .dates-row {
    flex-direction: column;
    align-items: stretch;
  }

  .date-field {
    width: 100%;
  }

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

  .form-row, .preset-form-row {
    grid-template-columns: 1fr;
    gap: 0.5rem;
  }

  .item-form-grid {
    grid-template-columns: 1fr 1fr;
    gap: 0.15rem 0.65rem;
  }
  .item-field-boq, .item-field-half, .item-field-full { grid-column: 1 / -1; }
  .item-type-options { grid-template-columns: 1fr; }

  .modal {
    padding: 1.2rem 0.9rem;
    max-height: 95vh;
    width: 95% !important;
  }

  .quick-batch-bar {
    flex-direction: column;
    align-items: stretch;
  }
}

/* ── Unified Print & PDF Export Styles ─────────────────── */
@media print {
  @page {
    size: auto;
    margin: 10mm 8mm 12mm 8mm;
  }

  html,
  body {
    background: #fff !important;
    color: #0f172a !important;
    margin: 0 !important;
    padding: 0 !important;
    font-size: 9pt !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  /* Universal print hides for non-printable page elements */
  .no-print,
  .header,
  #toastContainer,
  #offlineBanner,
  #authLoadingScreen,
  #paginationWrap,
  .pagination-bar,
  .modal-overlay.hidden {
    display: none !important;
  }

  /* Hide main application UI when printing any open modal report */
  body.printing-exec-report .main-container,
  body.printing-audit-report .main-container,
  body.printing-invoice .main-container,
  body:has(#executiveReportModal:not(.hidden)) .main-container,
  body:has(#auditReportModal:not(.hidden)) .main-container,
  body:has(#invoiceDetailModal:not(.hidden)) .main-container {
    display: none !important;
  }

  /* ── When printing Executive Report Modal ── */
  body.printing-exec-report .modal-overlay:not(#executiveReportModal),
  body:has(#executiveReportModal:not(.hidden)) .modal-overlay:not(#executiveReportModal) {
    display: none !important;
  }

  body.printing-exec-report #executiveReportModal,
  body:has(#executiveReportModal:not(.hidden)) #executiveReportModal {
    position: static !important;
    display: block !important;
    width: 100% !important;
    height: auto !important;
    min-height: 100% !important;
    max-height: none !important;
    overflow: visible !important;
    background: #fff !important;
    box-shadow: none !important;
    padding: 0 !important;
    margin: 0 !important;
  }

  body.printing-exec-report .modal.executive-report-modal,
  body:has(#executiveReportModal:not(.hidden)) .modal.executive-report-modal {
    position: static !important;
    display: block !important;
    box-shadow: none !important;
    border: none !important;
    max-width: 100% !important;
    width: 100% !important;
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
    padding: 0 !important;
    margin: 0 !important;
    background: #fff !important;
    border-radius: 0 !important;
  }

  body.printing-exec-report #execReportContent,
  body.printing-exec-report .exec-report-container,
  body:has(#executiveReportModal:not(.hidden)) #execReportContent,
  body:has(#executiveReportModal:not(.hidden)) .exec-report-container {
    overflow: visible !important;
    height: auto !important;
    max-height: none !important;
  }

  /* Executive report tables */
  .report-table {
    width: 100% !important;
    border-collapse: collapse !important;
  }

  .report-table thead {
    display: table-header-group !important;
  }

  .report-table tr {
    page-break-inside: avoid !important;
    break-inside: avoid !important;
  }

  /* ── When printing System Audit & User Access Modal ── */
  body.printing-audit-report .modal-overlay:not(#auditReportModal),
  body:has(#auditReportModal:not(.hidden)) .modal-overlay:not(#auditReportModal) {
    display: none !important;
  }

  body.printing-audit-report #auditReportModal,
  body:has(#auditReportModal:not(.hidden)) #auditReportModal {
    position: static !important;
    display: block !important;
    width: 100% !important;
    height: auto !important;
    min-height: 100% !important;
    max-height: none !important;
    overflow: visible !important;
    background: #fff !important;
    box-shadow: none !important;
    padding: 0 !important;
    margin: 0 !important;
  }

  body.printing-audit-report .modal.audit-modal,
  body:has(#auditReportModal:not(.hidden)) .modal.audit-modal {
    position: static !important;
    display: block !important;
    box-shadow: none !important;
    border: none !important;
    max-width: 100% !important;
    width: 100% !important;
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
    padding: 0 !important;
    margin: 0 !important;
    background: #fff !important;
    border-radius: 0 !important;
  }

  /* Hide interactive toolbar controls inside audit modal */
  .modal-actions,
  .audit-filter-bar,
  #auditPaginationContainer,
  .audit-tabs,
  #closeAuditReportModalBtn,
  #closeAuditBottomBtn,
  #downloadAuditCsvBtn,
  #downloadUserSummaryCsvBtn,
  #printAuditReportBtn {
    display: none !important;
  }

  /* Audit KPI stats cards in print */
  #auditStatsContainer {
    display: grid !important;
    grid-template-columns: repeat(5, 1fr) !important;
    gap: 0.5rem !important;
    margin-bottom: 0.85rem !important;
    page-break-inside: avoid !important;
    break-inside: avoid !important;
  }

  #auditStatsContainer .stat-card {
    background: #f8fafc !important;
    border: 1px solid #cbd5e1 !important;
    border-radius: 6px !important;
    box-shadow: none !important;
    padding: 0.45rem 0.65rem !important;
    page-break-inside: avoid !important;
    break-inside: avoid !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  #auditStatsContainer .stat-card .label {
    font-size: 0.68rem !important;
    color: #475569 !important;
    font-weight: 700 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.02em !important;
    margin-bottom: 0.2rem !important;
  }

  #auditStatsContainer .stat-card .val {
    font-size: 1.15rem !important;
    font-weight: 800 !important;
    line-height: 1.15 !important;
  }

  /* Unconstrain panel & table containers for multi-page flow */
  .audit-panel {
    display: block !important;
    height: auto !important;
    max-height: none !important;
    min-height: 0 !important;
    overflow: visible !important;
    flex: none !important;
  }

  .audit-panel.hidden {
    display: none !important;
  }

  #auditLogTableContainer,
  #auditUserSummaryContainer {
    display: block !important;
    width: 100% !important;
    height: auto !important;
    max-height: none !important;
    min-height: 0 !important;
    overflow: visible !important;
    border: 1px solid #cbd5e1 !important;
    border-radius: 4px !important;
    background: #fff !important;
    margin-bottom: 1rem !important;
  }

  /* Audit & User Access tables print layout */
  .audit-table {
    width: 100% !important;
    border-collapse: collapse !important;
    table-layout: auto !important;
  }

  .audit-table thead {
    display: table-header-group !important;
  }

  .audit-table tr {
    page-break-inside: avoid !important;
    break-inside: avoid !important;
  }

  .audit-table th {
    background: #f1f5f9 !important;
    color: #0f172a !important;
    font-weight: 700 !important;
    font-size: 7pt !important;
    text-transform: uppercase !important;
    letter-spacing: 0.03em !important;
    border: 1px solid #cbd5e1 !important;
    padding: 3.5pt 5pt !important;
    white-space: nowrap !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  .audit-table td {
    font-size: 7.2pt !important;
    padding: 3.5pt 5pt !important;
    border: 1px solid #e2e8f0 !important;
    color: #1e293b !important;
    vertical-align: middle !important;
    word-break: break-word !important;
  }

  .audit-table .badge {
    font-size: 6.8pt !important;
    padding: 1pt 3.5pt !important;
    border: 1px solid #cbd5e1 !important;
    border-radius: 3px !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  .audit-table code {
    font-size: 6.8pt !important;
    padding: 1pt 3pt !important;
    background: #f1f5f9 !important;
    border: 1px solid #e2e8f0 !important;
    border-radius: 3px !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  /* Print metadata badge */
  .audit-print-meta {
    display: block !important;
    font-size: 7.5pt !important;
    color: #334155 !important;
    background: #f8fafc !important;
    border: 1px solid #cbd5e1 !important;
    border-radius: 4px !important;
    padding: 5pt 8pt !important;
    margin-bottom: 8pt !important;
    page-break-inside: avoid !important;
    break-inside: avoid !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  /* ── When printing Invoice / Payment Certificate Modal ── */
  body.printing-invoice .modal-overlay:not(#invoiceDetailModal),
  body:has(#invoiceDetailModal:not(.hidden)) .modal-overlay:not(#invoiceDetailModal) {
    display: none !important;
  }

  body.printing-invoice #invoiceDetailModal,
  body:has(#invoiceDetailModal:not(.hidden)) #invoiceDetailModal {
    position: static !important;
    display: block !important;
    width: 100% !important;
    height: auto !important;
    min-height: 100% !important;
    max-height: none !important;
    overflow: visible !important;
    background: #fff !important;
    box-shadow: none !important;
    padding: 0 !important;
    margin: 0 !important;
  }

  body.printing-invoice .modal.invoice-spreadsheet-modal,
  body:has(#invoiceDetailModal:not(.hidden)) .modal.invoice-spreadsheet-modal {
    position: static !important;
    display: block !important;
    box-shadow: none !important;
    border: none !important;
    max-width: 100% !important;
    width: 100% !important;
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
    padding: 0 !important;
    margin: 0 !important;
    background: #fff !important;
    border-radius: 0 !important;
  }

  body.printing-invoice .invoice-modal-header button,
  body.printing-invoice .invoice-modal-header select,
  body.printing-invoice .invoice-modal-header label,
  body:has(#invoiceDetailModal:not(.hidden)) .invoice-modal-header button,
  body:has(#invoiceDetailModal:not(.hidden)) .invoice-modal-header select,
  body:has(#invoiceDetailModal:not(.hidden)) .invoice-modal-header label {
    display: none !important;
  }

  body.printing-invoice .invoice-table-container,
  body:has(#invoiceDetailModal:not(.hidden)) .invoice-table-container {
    overflow: visible !important;
    max-height: none !important;
    border: none !important;
  }

  body.printing-invoice .invoice-sheet-table,
  body:has(#invoiceDetailModal:not(.hidden)) .invoice-sheet-table {
    width: 100% !important;
    table-layout: auto !important;
    font-size: 6.8pt !important;
    border-collapse: collapse !important;
  }

  body.printing-invoice .invoice-sheet-table th,
  body.printing-invoice .invoice-sheet-table td,
  body:has(#invoiceDetailModal:not(.hidden)) .invoice-sheet-table th,
  body:has(#invoiceDetailModal:not(.hidden)) .invoice-sheet-table td {
    padding: 2pt 3pt !important;
    border: 1px solid #94a3b8 !important;
  }

  body.printing-invoice .invoice-sheet-table tr,
  body:has(#invoiceDetailModal:not(.hidden)) .invoice-sheet-table tr {
    page-break-inside: avoid !important;
    break-inside: avoid !important;
  }

  body.printing-invoice input.sheet-input,
  body:has(#invoiceDetailModal:not(.hidden)) input.sheet-input {
    border: none !important;
    background: transparent !important;
    box-shadow: none !important;
    font-size: 6.8pt !important;
    padding: 0 !important;
  }
}

/* ── Unauthenticated Full-Screen Login Mode ─────────── */
body.auth-pending header,
body.auth-pending .main-container {
  display: none !important;
}

#authLoadingScreen {
  display: none;
  min-height: 100vh;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: var(--bg-main);
  color: var(--text-main);
}

body.auth-pending #authLoadingScreen {
  display: flex;
}

#authLoadingScreen > div {
  display: grid;
  justify-items: center;
  gap: 0.55rem;
  text-align: center;
}

#authLoadingScreen img {
  width: 42px;
  height: 42px;
  object-fit: contain;
}

#authLoadingScreen strong {
  font-family: var(--font-head);
  font-size: 1.2rem;
}

#authLoadingScreen span {
  color: var(--text-muted);
  font-size: 0.88rem;
}

body.unauthenticated {
  background: #0f172a !important;
}

body.unauthenticated header,
body.unauthenticated .main-container {
  display: none !important;
}

body.unauthenticated #loginModal,
#loginModal:not(.hidden) {
  display: flex !important;
}

#loginModal {
  background: rgba(15, 23, 42, 0.95) !important;
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  z-index: 10000;
}

#loginModal .modal {
  background: #ffffff !important;
  color: #0f172a !important;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3) !important;
  border: 1px solid rgba(255, 255, 255, 0.15) !important;
}

/* ── Executive Visual Analytics Dashboard Styles ──────── */
.analytics-container {
  transition: all 0.3s ease-in-out;
}

.analytics-card {
  background: var(--bg-card);
  border-radius: 16px;
  padding: 1rem 1.2rem;
  box-shadow: var(--shadow-flat);
  border: 1px solid rgba(226, 232, 240, 0.8);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.analytics-card .chart-header {
  margin-bottom: 0.6rem;
  display: flex;
  flex-direction: column;
}

.analytics-card .chart-header h4 {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-main);
  margin: 0;
}

.analytics-card .chart-header .chart-subtitle {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* ── Dedicated Executive Analytics Workspace Styles ── */
#analyticsView {
  animation: fadeInAnalyticsView 0.22s ease-in-out;
}

@keyframes fadeInAnalyticsView {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.analytics-top-bar {
  border: 1px solid rgba(226, 232, 240, 0.9);
  transition: box-shadow 0.2s ease;
}

.analytics-matrix-section {
  transition: all 0.2s ease-in-out;
}

#analyticsProjectMatrixTable tbody tr:hover {
  background-color: rgba(79, 70, 229, 0.04);
}

@media print {
  #analyticsView .analytics-top-bar button,
  #analyticsView .analytics-filter-tabs,
  #analyticsView .search-input,
  #analyticsView .filter-select {
    display: none !important;
  }
}

/* Installation work can cover more than one activity in a single site entry. */
.installation-activity-card {
  transition: border-color 0.16s ease, background-color 0.16s ease, box-shadow 0.16s ease;
}

.installation-activity-card.selected {
  border-color: var(--primary) !important;
  background: rgba(79, 70, 229, 0.06) !important;
  box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.09);
}

/* One BOQ item may be released under several Work Orders. */
#workOrderReleaseForm {
  display: grid;
  grid-template-columns: minmax(140px, 1.5fr) minmax(90px, 0.8fr) minmax(160px, 2fr) auto;
  gap: 0.6rem;
  align-items: end;
  padding: 0.8rem;
  border-radius: 10px;
  background: var(--bg-main);
  box-shadow: var(--shadow-pressed);
}

.work-order-release-row {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding: 0.65rem;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  background: #fff;
}

@media (max-width: 768px) {
  #workOrderReleaseForm {
    grid-template-columns: 1fr 1fr;
  }
  #workOrderReleaseForm .form-group:nth-child(3) {
    grid-column: 1 / -1;
  }
  #workOrderReleaseForm button {
    grid-column: 1 / -1;
    width: 100%;
  }
}

@media (max-width: 520px) {
  #workOrderReleaseForm {
    grid-template-columns: 1fr;
  }
}

/* ── System Audit & User Access Center Styles ── */
.audit-modal {
  max-width: 1120px;
  width: 96vw;
  max-height: 92vh;
}

.badge-audit-access {
  background: #dbeafe;
  color: #1e40af;
  border: 1px solid #bfdbfe;
}
.badge-audit-projects {
  background: #ede9fe;
  color: #6b21a8;
  border: 1px solid #ddd6fe;
}
.badge-audit-boq {
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fde68a;
}
.badge-audit-progress {
  background: #d1fae5;
  color: #065f46;
  border: 1px solid #a7f3d0;
}
.badge-audit-installation {
  background: #e0e7ff;
  color: #3730a3;
  border: 1px solid #c7d2fe;
}
.badge-audit-users {
  background: #ccfbf1;
  color: #115e59;
  border: 1px solid #99f6e4;
}
.badge-audit-settings {
  background: #f1f5f9;
  color: #334155;
  border: 1px solid #cbd5e1;
}

.audit-tabs button.active {
  background: #fff;
  border-bottom: 2px solid var(--primary);
  color: var(--primary);
  font-weight: 700;
}

.audit-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}

.audit-table th {
  position: sticky;
  top: 0;
  background: #f8fafc;
  z-index: 2;
  padding: 0.6rem 0.5rem;
  border-bottom: 2px solid #e2e8f0;
  text-align: left;
  font-weight: 700;
  color: var(--text-muted);
  white-space: nowrap;
}

.audit-table td {
  padding: 0.5rem;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
}

.audit-table tr:hover td {
  background: #f8fafc;
}


/* ── Project Assigned Installation Lead Badges & Controls ── */
.badge-installer {
  background: rgba(14, 165, 233, 0.14);
  color: #0284c7;
  font-weight: 700;
  border: 1px solid rgba(14, 165, 233, 0.25);
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}
.badge-installer-unassigned {
  background: rgba(245, 158, 11, 0.12);
  color: #b45309;
  font-weight: 700;
  border: 1px dashed rgba(245, 158, 11, 0.35);
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}
.project-lead-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  background: rgba(241, 245, 249, 0.65);
  border: 1px solid rgba(203, 213, 225, 0.5);
  padding: 0.45rem 0.75rem;
  border-radius: 8px;
  margin-bottom: 0.85rem;
  font-size: 0.8rem;
}
.project-lead-info {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.btn-assign-lead {
  font-size: 0.75rem;
  padding: 0.25rem 0.55rem;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
  font-weight: 600;
}

/* ── Client Progress Invoicing & Spreadsheet Styles ─────── */
.invoice-spreadsheet-modal {
  background: #f8fafc;
  border-radius: 12px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

.invoice-commercial-card {
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.invoice-table-container {
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.06);
}

.invoice-sheet-table {
  width: max-content;
  min-width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.78rem;
}

.invoice-sheet-table thead tr.header-group-row th {
  position: sticky;
  top: 0;
  z-index: 10;
  font-size: 0.73rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 0.35rem 0.5rem;
  border-top: 1px solid #cbd5e1;
  border-bottom: 1px solid #94a3b8;
  border-right: 1px solid #cbd5e1;
  text-align: center;
}

.invoice-sheet-table thead tr.header-cols-row th {
  position: sticky;
  top: 28px;
  z-index: 10;
  font-size: 0.7rem;
  font-weight: 700;
  background: #f1f5f9;
  color: #334155;
  padding: 0.35rem 0.4rem;
  border-bottom: 2px solid #64748b;
  border-right: 1px solid #cbd5e1;
  text-align: center;
  white-space: nowrap;
}

.invoice-sheet-table .grp-base { background: #e2e8f0; color: #1e293b; }
.invoice-sheet-table .grp-frame-del { background: #dbeafe; color: #1e40af; border-left: 2px solid #3b82f6; }
.invoice-sheet-table .grp-glass-del { background: #e0f2fe; color: #0369a1; border-left: 2px solid #0284c7; }
.invoice-sheet-table .grp-frame-inst { background: #dcfce7; color: #15803d; border-left: 2px solid #10b981; }
.invoice-sheet-table .grp-glass-inst { background: #ccfbf1; color: #0f766e; border-left: 2px solid #14b8a6; }
.invoice-sheet-table .grp-silicone { background: #fef3c7; color: #b45309; border-left: 2px solid #f59e0b; }
.invoice-sheet-table .grp-summary { background: #f3e8ff; color: #6b21a8; border-left: 2px solid #a855f7; }

.invoice-sheet-table td {
  padding: 0.25rem 0.4rem;
  border-bottom: 1px solid #e2e8f0;
  border-right: 1px solid #e2e8f0;
  vertical-align: middle;
  background: #fff;
  white-space: nowrap;
}

.invoice-sheet-table tr:hover td {
  background: #f8fafc;
}

.invoice-sheet-table .sticky-col-sl {
  position: sticky;
  left: 0;
  z-index: 5;
  background: #fff;
  text-align: center;
  font-weight: 600;
  border-right: 1px solid #cbd5e1;
}

.invoice-sheet-table .sticky-col-item {
  position: sticky;
  left: 45px;
  z-index: 5;
  background: #fff;
  font-weight: 600;
  border-right: 2px solid #cbd5e1;
}

.invoice-sheet-table tr:hover .sticky-col-sl,
.invoice-sheet-table tr:hover .sticky-col-item {
  background: #f1f5f9;
}

.invoice-sheet-table input.sheet-input {
  width: 100%;
  border: 1px solid transparent;
  background: transparent;
  padding: 0.2rem 0.35rem;
  font-size: 0.78rem;
  font-family: inherit;
  font-weight: 600;
  border-radius: 4px;
  text-align: right;
  transition: all 0.15s ease;
}

.invoice-sheet-table input.sheet-input:hover {
  background: #f8fafc;
  border-color: #cbd5e1;
}

.invoice-sheet-table input.sheet-input:focus {
  background: #fff;
  border-color: #3b82f6;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.25);
  outline: none;
}

.invoice-sheet-table input.sheet-input-text {
  text-align: left;
}

.invoice-sheet-table td.calc-cell {
  background: #f8fafc;
  text-align: right;
  font-weight: 600;
  color: #334155;
}

.invoice-sheet-table td.claim-total-cell {
  background: rgba(243, 232, 255, 0.5);
  text-align: right;
  font-weight: 800;
  color: #6b21a8;
}

.invoice-sheet-table tr.subtotal-row td {
  background: #f1f5f9 !important;
  font-weight: 800;
  border-top: 2px solid #94a3b8;
  border-bottom: 2px solid #94a3b8;
  color: #0f172a;
  text-align: right;
}

.invoice-sheet-table tr.section-divider-row td {
  background: #e2e8f0 !important;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #1e293b;
  padding: 0.5rem 0.75rem;
  border-top: 2px solid #64748b;
  border-bottom: 1px solid #94a3b8;
}

.invoice-sheet-table tr.grand-total-row td {
  background: #eff6ff !important;
  font-weight: 900;
  font-size: 0.85rem;
  border-top: 2px solid #2563eb;
  border-bottom: 3px double #1d4ed8;
  color: #1e3a8a;
  text-align: right;
  padding: 0.45rem 0.5rem;
}

.invoice-sheet-table .milestone-del-cell {
  border-left: 2px solid rgba(59, 130, 246, 0.25);
}
.invoice-sheet-table .milestone-inst-cell {
  border-left: 2px solid rgba(16, 185, 129, 0.25);
}
.invoice-sheet-table .milestone-silicone-cell {
  border-left: 2px solid rgba(245, 158, 11, 0.25);
}
.invoice-sheet-table .milestone-summary-cell {
  border-left: 2px solid rgba(168, 85, 247, 0.35);
}

.btn-remove-row {
  background: none;
  border: none;
  color: #ef4444;
  cursor: pointer;
  padding: 0.15rem 0.35rem;
  font-size: 0.85rem;
  border-radius: 4px;
}
.btn-remove-row:hover {
  background: #fee2e2;
}

/* ── Classic Page-by-Page Pagination Bar ──────── */
.pagination-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  width: 100%;
  padding: 0.75rem 1.25rem;
  background: var(--bg-card);
  border-radius: 10px;
  border: var(--border-subtle);
  box-shadow: var(--shadow-flat-sm);
  margin-top: 0.75rem;
}

.pagination-info {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
}

.pagination-controls {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
  justify-content: center;
}

.pagination-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.1rem;
  height: 2.1rem;
  padding: 0 0.6rem;
  font-size: 0.82rem;
  font-weight: 600;
  font-family: var(--font-body);
  color: var(--text-main);
  background: var(--bg-card);
  border: 1px solid rgba(203, 213, 225, 0.9);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease-in-out;
  user-select: none;
}

.pagination-btn:hover:not(:disabled) {
  background: #f1f5f9;
  border-color: #94a3b8;
  color: var(--primary);
}

.pagination-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  background: #f8fafc;
  border-color: rgba(226, 232, 240, 0.8);
}

.pagination-btn.active {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
  font-weight: 700;
  box-shadow: 0 2px 4px rgba(79, 70, 229, 0.25);
}

.pagination-ellipsis {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.5rem;
  height: 2.1rem;
  font-size: 0.9rem;
  color: var(--text-muted);
  user-select: none;
}

.pagination-size-wrapper {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
  white-space: nowrap;
}

.pagination-size-select {
  padding: 0.35rem 0.65rem;
  font-size: 0.82rem;
  font-weight: 600;
  font-family: var(--font-body);
  color: var(--text-main);
  background: var(--bg-card);
  border: 1px solid rgba(203, 213, 225, 0.9);
  border-radius: 6px;
  cursor: pointer;
  outline: none;
  transition: border-color 0.15s ease;
}

.pagination-size-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.15);
}

@media (max-width: 768px) {
  .pagination-bar {
    justify-content: center;
    text-align: center;
  }
  .pagination-info,
  .pagination-size-wrapper {
    width: 100%;
    justify-content: center;
  }
}

/* Executive Requirement & Directive Styles */
.badge-req-required {
  background: #dcfce7 !important;
  color: #15803d !important;
  border: 1px solid #86efac !important;
}

.badge-req-not-required {
  background: #ffe4e6 !important;
  color: #be123c !important;
  border: 1px solid #fca5a5 !important;
}

.badge-req-on-hold {
  background: #fef3c7 !important;
  color: #b45309 !important;
  border: 1px solid #fcd34d !important;
}

.badge-req-under-review {
  background: #f1f5f9 !important;
  color: #475569 !important;
  border: 1px solid #cbd5e1 !important;
}

.card-directive-preview:hover {
  background: linear-gradient(135deg, rgba(67, 56, 202, 0.08), rgba(99, 102, 241, 0.12)) !important;
  transform: translateY(-1px);
  transition: all 0.2s ease;
}

.decision-radio-card:hover {
  filter: brightness(0.97);
}

.decision-radio-card:has(input:checked) {
  box-shadow: 0 0 0 2px #4338ca;
}

.comment-bubble {
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.comment-bubble:hover {
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
}

.mention-pill {
  display: inline-block;
  padding: 0.1rem 0.42rem;
  border-radius: 6px;
  font-weight: 700;
  font-size: 0.8rem;
  line-height: 1.3;
  margin: 0 0.12rem;
  vertical-align: baseline;
}

.mention-dept {
  background: #e0e7ff;
  color: #3730a3;
  border: 1px solid #c7d2fe;
}

.mention-user {
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fde68a;
}

.btn-mention-chip {
  border: 1px solid #c7d2fe;
  background: #eef2ff;
  color: #4338ca;
  padding: 0.15rem 0.45rem;
  border-radius: 6px;
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.btn-mention-chip:hover {
  background: #e0e7ff;
  border-color: #818cf8;
  transform: translateY(-1px);
}

/* ── Team Directive Reply & Status Chips ──────────────── */
.btn-response-chip {
  border-radius: 6px;
  font-size: 0.74rem;
  font-weight: 700;
  cursor: pointer;
  padding: 0.25rem 0.6rem;
  transition: all 0.15s ease;
  user-select: none;
  border: 1px solid #cbd5e1;
  background: #f8fafc;
  color: var(--text-main);
}

.btn-response-chip:hover {
  transform: translateY(-1px);
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.btn-response-chip.selected {
  outline: 2px solid var(--primary);
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.25);
  font-weight: 800;
}

.btn-response-chip[data-status="done"].selected {
  background: #dcfce7 !important;
  border-color: #16a34a !important;
  color: #15803d !important;
}

.btn-response-chip[data-status="in_progress"].selected {
  background: #dbeafe !important;
  border-color: #2563eb !important;
  color: #1d4ed8 !important;
}

.btn-response-chip[data-status="reason"].selected {
  background: #fef3c7 !important;
  border-color: #d97706 !important;
  color: #b45309 !important;
}

.btn-response-chip[data-status="update"].selected {
  background: #f3e8ff !important;
  border-color: #9333ea !important;
  color: #7e22ce !important;
}

.comment-bubble.team-reply {
  background: #f8fafc;
  border-left: 3px solid #6366f1;
}

.comment-bubble.executive-directive {
  background: #ffffff;
  border-left: 3px solid #4338ca;
}

/* ── Live App Update Notification Banner ── */
.app-update-banner {
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
  color: #f8fafc;
  border-bottom: 1px solid rgba(59, 130, 246, 0.4);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
  position: sticky;
  top: 0;
  z-index: 1000;
  animation: slideDownUpdateBanner 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideDownUpdateBanner {
  from {
    transform: translateY(-100%);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.app-update-banner-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0.45rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.85rem;
  font-size: 0.85rem;
  flex-wrap: wrap;
}

.app-update-icon {
  font-size: 1.1rem;
  display: inline-flex;
  align-items: center;
}

.app-update-text {
  color: #e2e8f0;
}

.app-update-text strong {
  color: #60a5fa;
}

.app-update-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-app-update-reload {
  background: #2563eb;
  color: #ffffff;
  border: none;
  border-radius: 6px;
  padding: 0.32rem 0.85rem;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.4);
}

.btn-app-update-reload:hover {
  background: #1d4ed8;
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(37, 99, 235, 0.5);
}

.btn-app-update-dismiss {
  background: transparent;
  color: #94a3b8;
  border: none;
  font-size: 1rem;
  cursor: pointer;
  padding: 0.2rem 0.4rem;
  border-radius: 4px;
  line-height: 1;
  transition: color 0.15s ease;
}

.btn-app-update-dismiss:hover {
  color: #ffffff;
}

@media print {
  .app-update-banner {
    display: none !important;
  }
}

/* ── Work Order Discipline Badges & Valuation Chips ── */
.badge-al {
  background: #eff6ff !important;
  color: #1d4ed8 !important;
  border: 1px solid #bfdbfe !important;
  font-weight: 700;
}

.badge-gl {
  background: #ecfdf5 !important;
  color: #047857 !important;
  border: 1px solid #a7f3d0 !important;
  font-weight: 700;
}

.badge-gen {
  background: #f8fafc !important;
  color: #475569 !important;
  border: 1px solid #cbd5e1 !important;
  font-weight: 600;
}

.val-discipline-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  padding: 0.15rem 0.45rem;
  border-radius: 6px;
  font-size: 0.76rem;
  font-weight: 700;
}

.val-discipline-chip.al-chip {
  background: #eff6ff;
  color: #1d4ed8;
  border: 1px solid #bfdbfe;
}

.val-discipline-chip.gl-chip {
  background: #ecfdf5;
  color: #047857;
  border: 1px solid #a7f3d0;
}

.stat-subsplit {
  display: flex;
  gap: 0.35rem;
  justify-content: center;
  align-items: center;
}

/* ── Minutes of Meeting (MOM) Interactive Workspace ── */

.mom-top-bar {
  background: var(--bg-card);
  border-radius: 12px;
  box-shadow: var(--shadow-flat);
  border: 1px solid #e2e8f0;
}

.mom-select-main {
  border-radius: 8px;
  border: 1px solid #cbd5e1;
  background: #ffffff;
  color: var(--text-main);
  padding: 0.45rem 0.85rem;
}

.mom-meta-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 700;
  padding: 0.3rem 0.65rem;
}

.mom-attendees-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.mom-attendee-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.35rem 0.75rem;
  border-radius: 20px;
  font-size: 0.82rem;
  font-weight: 600;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  color: var(--text-main);
  transition: all 0.15s ease;
  user-select: none;
}

.mom-attendee-pill.clickable {
  cursor: pointer;
}

.mom-attendee-pill.clickable:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

.mom-attendee-indicator {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  font-size: 0.72rem;
  font-weight: 800;
}

.mom-attendee-p .mom-attendee-indicator {
  background: #10b981;
  color: #ffffff;
}

.mom-attendee-a .mom-attendee-indicator {
  background: #ef4444;
  color: #ffffff;
}

.mom-attendee-p {
  background: #f0fdf4;
  border-color: #bbf7d0;
}

.mom-attendee-a {
  background: #fef2f2;
  border-color: #fecaca;
  opacity: 0.85;
}

.mom-region-tab {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  padding: 0.5rem 1rem;
  border-radius: 9px;
  cursor: pointer;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}

.mom-region-tab:hover {
  background: #f1f5f9;
  color: var(--text-main);
}

.mom-region-tab.active {
  background: var(--primary-gradient);
  border-color: var(--primary);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.25);
}

.mom-region-tab.active .tab-badge {
  background: rgba(255, 255, 255, 0.25);
  color: #ffffff;
}

.mom-category-heading {
  margin: 1.75rem 0 0.85rem;
  padding: 1rem 1.25rem;
  border-left: 5px solid var(--primary);
  border-radius: 10px;
  background: var(--bg-main);
  color: var(--primary);
  box-shadow: var(--shadow-flat);
  font-size: clamp(1.15rem, 2vw, 1.5rem);
  font-weight: 800;
  letter-spacing: 0.035em;
  text-transform: uppercase;
  line-height: 1.3;
  grid-column: 1 / -1;
  break-after: avoid;
}

.mom-category-heading:first-child { margin-top: 0; }

.mom-project-card {
  background: var(--bg-card);
  border-radius: 12px;
  box-shadow: var(--shadow-flat);
  border: 1px solid #e2e8f0;
  overflow: hidden;
  transition: box-shadow 0.2s ease;
}

.mom-project-card:hover {
  box-shadow: var(--shadow-hover);
}

.mom-project-header {
  padding: 0.85rem 1.25rem;
  background: linear-gradient(135deg, rgba(248, 250, 252, 0.9), rgba(241, 245, 249, 0.7));
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.mom-project-title-group {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.mom-job-badge {
  background: #1e293b;
  color: #f8fafc;
  padding: 0.25rem 0.6rem;
  border-radius: 6px;
  font-family: monospace;
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.mom-project-name {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--text-main);
}

.mom-meta-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.76rem;
  font-weight: 600;
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  color: #334155;
}

.mom-meta-chip.finish {
  background: #faf5ff;
  border-color: #e9d5ff;
  color: #7e22ce;
}

.mom-meta-chip.pm {
  background: #eff6ff;
  border-color: #bfdbfe;
  color: #1d4ed8;
}

.mom-meta-chip.eng {
  background: #f0fdf4;
  border-color: #bbf7d0;
  color: #15803d;
}

.mom-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
}

.mom-table th {
  text-align: left;
  padding: 0.65rem 0.9rem;
  background: #f8fafc;
  color: var(--text-muted);
  font-family: var(--font-head);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid #e2e8f0;
}

.mom-table td {
  padding: 0.75rem 0.9rem;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: top;
  color: var(--text-main);
}

.mom-table tr:last-child td {
  border-bottom: none;
}

.mom-table tr:hover td {
  background: rgba(79, 70, 229, 0.02);
}

/* Status Badges */
.mom-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.2rem 0.6rem;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 700;
  white-space: nowrap;
}

.mom-status-open {
  background: #f1f5f9;
  color: #475569;
  border: 1px solid #cbd5e1;
}

.mom-status-in_progress {
  background: #eff6ff;
  color: #1d4ed8;
  border: 1px solid #bfdbfe;
}

.mom-status-completed {
  background: #ecfdf5;
  color: #047857;
  border: 1px solid #a7f3d0;
}

.mom-status-on_hold {
  background: #fffbeb;
  color: #b45309;
  border: 1px solid #fde68a;
}

.mom-deadline-overdue {
  background: #fef2f2;
  color: #dc2626;
  border: 1px solid #fecaca;
  font-weight: 800;
}

.mom-deadline-duesoon {
  background: #fff7ed;
  color: #c2410c;
  border: 1px solid #fed7aa;
  font-weight: 700;
}

.mom-deadline-ok {
  background: #f8fafc;
  color: #475569;
  border: 1px solid #e2e8f0;
}

/* Audit history timeline */
.mom-audit-timeline-item {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: 0.5rem 0.75rem;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  font-size: 0.8rem;
}

.mom-audit-timeline-item .header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.74rem;
  color: var(--text-muted);
}

.mom-audit-action-chip {
  font-weight: 700;
  padding: 0.12rem 0.4rem;
  border-radius: 4px;
  font-size: 0.7rem;
}

.action-status_changed {
  background: #eff6ff;
  color: #1d4ed8;
}

.action-date_revised {
  background: #fef3c7;
  color: #b45309;
}

.action-remark_added {
  background: #f3e8ff;
  color: #7e22ce;
}

/* General Directives Card */
.mom-directive-card {
  padding: 0.75rem 1rem;
  background: #ffffff;
  border: 1px solid #fed7aa;
  border-radius: 8px;
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  transition: transform 0.15s ease;
}

.mom-directive-card:hover {
  transform: translateX(4px);
  background: #fffbeb;
}

.mom-directive-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #d97706;
  color: #ffffff;
  font-size: 0.78rem;
  font-weight: 800;
}

/* ── Photo Attachments & Lightbox Styles ── */
.photo-preview-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 0.4rem;
}

.photo-preview-card {
  position: relative;
  width: 84px;
  height: 84px;
  border-radius: 8px;
  overflow: hidden;
  border: 1.5px solid #cbd5e1;
  background: #f1f5f9;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.photo-preview-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.photo-preview-remove {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(220, 38, 38, 0.9);
  color: #ffffff;
  border: none;
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  padding: 0;
  transition: transform 0.15s ease, background 0.15s ease;
}

.photo-preview-remove:hover {
  background: #b91c1c;
  transform: scale(1.1);
}

.photo-chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
  margin-top: 0.25rem;
}

.photo-thumb-btn {
  width: 38px;
  height: 38px;
  border-radius: 6px;
  overflow: hidden;
  border: 1.5px solid #94a3b8;
  padding: 0;
  cursor: pointer;
  background: #f8fafc;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
  flex-shrink: 0;
}

.photo-thumb-btn:hover {
  transform: scale(1.12);
  border-color: #2563eb;
  box-shadow: 0 4px 10px rgba(37, 99, 235, 0.25);
  z-index: 2;
}

.photo-thumb-btn img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.photo-badge-count {
  font-size: 0.72rem;
  font-weight: 700;
  background: #e0f2fe;
  color: #0369a1;
  padding: 0.15rem 0.45rem;
  border-radius: 6px;
  border: 1px solid #bae6fd;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

/* Lightbox Modal */
body:has(#photoLightboxModal:not(.hidden)) {
  overflow: hidden;
}

#photoLightboxModal {
  padding: 12px 10px;
  overflow: hidden;
}

.photo-lightbox-container {
  background: var(--bg-card);
  border-radius: 16px;
  width: min(960px, calc(100vw - 32px));
  height: min(850px, calc(100dvh - 40px));
  max-height: calc(100dvh - 40px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.18);
  border: var(--border-subtle);
  flex-shrink: 0;
}

.photo-lightbox-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.85rem 1.25rem;
  background: var(--bg-card);
  border-bottom: var(--border-subtle);
  color: var(--text-main);
  gap: 1rem;
}

.photo-lightbox-info {
  flex: 1;
  min-width: 0;
}

.photo-lightbox-info strong {
  font-size: 0.95rem;
  color: var(--text-main);
  display: block;
}

.photo-lightbox-info span {
  font-size: 0.78rem;
  color: var(--text-muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
  line-height: 1.5;
  margin-top: 0.25rem;
}

.photo-lightbox-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-shrink: 0;
}

.photo-lightbox-actions .btn-secondary {
  background: var(--bg-card);
  color: var(--primary);
  border: 1px solid rgba(99, 102, 241, 0.18);
  font-size: 0.82rem;
  padding: 0.35rem 0.75rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  height: 40px;
  box-sizing: border-box;
  border-radius: 8px;
  white-space: nowrap;
  text-decoration: none;
  line-height: 1;
}

.photo-lightbox-actions .btn-secondary:hover {
  background: #eef2ff;
}

.photo-lightbox-actions #photoLightboxDownloadBtn {
  background: var(--primary-gradient);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.2);
}

.photo-lightbox-body {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-main);
  padding: 1rem;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
  box-sizing: border-box;
}

.photo-lightbox-body img {
  display: block;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 6px;
  box-shadow: none;
}

.photo-lightbox-caption {
  padding: 0.75rem 1.25rem;
  background: var(--bg-card);
  border-top: var(--border-subtle);
  color: var(--text-muted);
  font-size: 0.84rem;
  line-height: 1.4;
  min-height: 20px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (max-width: 640px) {
  .photo-lightbox-container {
    width: calc(100vw - 20px);
    height: calc(100dvh - 24px);
    max-height: calc(100dvh - 24px);
  }

  .photo-lightbox-header {
    flex-wrap: wrap;
    padding: 0.75rem;
    gap: 0.65rem;
  }

  .photo-lightbox-info {
    flex-basis: 100%;
  }

  .photo-lightbox-actions {
    margin-left: auto;
  }

  .photo-lightbox-body {
    padding: 0.75rem;
  }

  .photo-lightbox-caption {
    padding: 0.65rem 0.75rem;
  }
}

/* Schedule Health Status Pills */
.health-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-weight: 700;
  font-size: 0.75rem;
  padding: 0.2rem 0.55rem;
  border-radius: 9999px;
  white-space: nowrap;
}

.health-on-track {
  background: #ecfdf5;
  color: #065f46;
  border: 1px solid #a7f3d0;
}

.health-moderate {
  background: #fffbeb;
  color: #b45309;
  border: 1px solid #fde68a;
}

.health-at-risk {
  background: #fef2f2;
  color: #b91c1c;
  border: 1px solid #fecaca;
  animation: pulseAlert 2.5s infinite;
}

.health-completed {
  background: #eff6ff;
  color: #1e40af;
  border: 1px solid #bfdbfe;
}

/* Print Stylesheet for MOM */
@media print {
  /* Hide application chrome */
  .header,
  .nav-tabs,
  .mom-top-bar,
  .mom-toolbar,
  .dashboard-banner,
  .modal-overlay,
  .app-update-banner,
  #openSettingsBtn,
  #notificationsBtn,
  .btn-primary,
  .btn-secondary,
  .mom-action-cell {
    display: none !important;
  }

  body {
    background: #ffffff !important;
    color: #000000 !important;
    font-size: 10pt;
  }

  .main-container {
    padding: 0 !important;
    margin: 0 !important;
    max-width: 100% !important;
  }

  .mom-print-header {
    display: block !important;
  }

  .mom-header-card,
  .mom-project-card,
  .mom-general-notes-section {
    box-shadow: none !important;
    border: 1px solid #cbd5e1 !important;
    break-inside: avoid;
    margin-bottom: 1.5rem !important;
  }

  .mom-table th {
    background: #e2e8f0 !important;
    color: #000000 !important;
  }

  .mom-table td {
    color: #000000 !important;
  }
}





/* Keep dashboard and project totals readable across screen sizes. */
.stats-grid:is(.project-summary-grid, .dashboard-summary-grid) {
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 1rem;
}
:is(.project-summary-grid, .dashboard-summary-grid) .stat-card { min-width: 0; padding: 1.1rem; }
:is(.project-summary-grid, .dashboard-summary-grid) .stat-card .label { min-height: 2.6em; line-height: 1.35; }
:is(.project-summary-grid, .dashboard-summary-grid) .stat-card .val { line-height: 1.3; white-space: nowrap; font-variant-numeric: tabular-nums; }
:is(.project-summary-grid, .dashboard-summary-grid) .stat-subsplit { line-height: 1.5; }
:is(.project-summary-grid, .dashboard-summary-grid) .stat-subsplit > span { display: inline-block; white-space: nowrap; }
.mom-photo-upload-controls { display: flex; align-items: center; flex-wrap: wrap; gap: 0.75rem; margin: 0.5rem 0; }
.mom-photo-upload-controls button { padding: 0.6rem 1rem; border-radius: 10px; font-weight: 700; }
@media (max-width: 1200px) {
  .stats-grid:is(.project-summary-grid, .dashboard-summary-grid) { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 800px) {
  .stats-grid:is(.project-summary-grid, .dashboard-summary-grid) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  :is(.project-summary-grid, .dashboard-summary-grid) .stat-card { padding: 0.85rem; }
}
@media (max-width: 460px) {
  .stats-grid:is(.project-summary-grid, .dashboard-summary-grid) { grid-template-columns: minmax(0, 1fr) !important; }
}

/* Simple monthly revenue forecast */
/* Revenue performance insights */
.revenue-performance h3 {margin:0 0 18px;font-size:18px;}
.revenue-performance-grid {display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:20px;}
.revenue-performance-grid>div {padding:16px;border-radius:10px;background:#f8fafc;}
.revenue-performance-grid span,.revenue-performance-grid small {display:block;color:#64748b;font-size:12px;line-height:1.5;}
.revenue-performance-grid strong {display:block;font-size:28px;color:#4f46e5;margin:7px 0;font-variant-numeric:tabular-nums;}
.revenue-insights {padding-left:20px;margin:18px 0 0;color:#334155;font-size:14px;line-height:1.65;}.revenue-insights li+li {margin-top:8px;}
.revenue-quarter-details {margin-top:18px;border-top:1px solid #e2e8f0;padding-top:14px;}.revenue-quarter-details summary {cursor:pointer;color:#4f46e5;font-weight:600;}.revenue-quarter-details p {font-size:12px;color:#64748b;}
@media(max-width:650px){.revenue-performance-grid{grid-template-columns:1fr;gap:10px;}.revenue-performance-grid strong{font-size:24px;}}
#analyticsView .revenue-heading { display:flex; justify-content:space-between; align-items:center; gap:20px; flex-wrap:wrap; margin:12px 0 22px; }
.revenue-heading h2 { margin:0 0 6px; font-size:24px; }.revenue-heading p {margin:0;color:#64748b;}
.revenue-controls {display:flex;align-items:center;gap:8px;flex-wrap:wrap;}.revenue-controls select {width:100px;}
#analyticsView [hidden] {display:none!important;}
.revenue-totals {display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:16px;margin-bottom:20px;}
.revenue-totals>div,.revenue-panel {background:#fff;border:1px solid #e2e8f0;border-radius:14px;padding:20px;}
.revenue-totals span {display:block;color:#64748b;font-size:13px;margin-bottom:10px;}.revenue-totals strong {font-size:26px;font-variant-numeric:tabular-nums;}
.revenue-panel {margin-bottom:18px;}.revenue-chart-key {display:flex;gap:22px;justify-content:center;font-size:13px;}.revenue-chart-key span:before {content:'';display:inline-block;width:12px;height:12px;margin-right:7px;border-radius:3px;}.forecast-key:before {background:#6366f1;}.actual-key:before {background:#10b981;}
#revenueForecastChart svg {display:block;width:100%;max-height:280px;margin-top:10px;}
#revenueForecastMessage {font-size:13px;color:#64748b;margin:0 0 16px;}.revenue-table-wrap {overflow:auto;}.revenue-table {width:100%;border-collapse:collapse;font-variant-numeric:tabular-nums;}.revenue-table th,.revenue-table td {padding:11px 16px;border-bottom:1px solid #e2e8f0;text-align:right;white-space:nowrap;}.revenue-table th:first-child {text-align:left;}.revenue-table thead,.revenue-table tfoot {background:#f8fafc;}.revenue-table tfoot {font-weight:700;}.revenue-table input {width:100%;min-width:120px;text-align:right;box-sizing:border-box;}.revenue-negative {color:#b45309;}.revenue-positive {color:#059669;}
.revenue-footer {display:flex;justify-content:space-between;align-items:center;gap:12px;margin-top:18px;color:#64748b;font-size:12px;}.revenue-footer>div {display:flex;gap:8px;}
@media(max-width:650px){.revenue-totals {grid-template-columns:1fr;gap:10px;}.revenue-totals>div {padding:14px;}.revenue-totals strong {font-size:23px;}.revenue-panel {padding:12px;}.revenue-table th,.revenue-table td {padding:10px 8px;}.revenue-footer {align-items:flex-start;flex-direction:column;}}
@media print {body:has(#analyticsView:not(.hidden)) header,body:has(#analyticsView:not(.hidden)) .revenue-controls,body:has(#analyticsView:not(.hidden)) .revenue-footer {display:none!important;} .revenue-panel,.revenue-totals>div {break-inside:avoid;box-shadow:none;}}
.mom-project-documents { padding: 0.8rem 1rem; border-bottom: 1px solid var(--border-color, #e2e8f0); background: #f8fafc; }
.mom-documents-bar, .mom-document-row, .mom-pdf-header, .mom-pdf-actions { display: flex; align-items: center; gap: 0.6rem; }
.mom-documents-bar { justify-content: space-between; font-size: 0.85rem; }
.mom-documents-bar button, .mom-document-row button { font-size: 0.78rem; padding: 0.4rem 0.65rem; }
.mom-document-list { display: grid; gap: 0.45rem; margin-top: 0.5rem; }
.mom-document-row { padding: 0.55rem 0.7rem; border: 1px solid #e2e8f0; border-radius: 10px; background: #fff; }
.mom-document-info { flex: 1; min-width: 0; }
.mom-document-name { display: block; border: 0; background: none; padding: 0 !important; text-align: left; color: #4f46e5; font-weight: 700; overflow-wrap: anywhere; cursor: pointer; }
.mom-document-info small, .mom-document-empty { color: var(--text-muted); font-size: 0.75rem; }
.modal.mom-pdf-preview { width: min(1100px, 96vw); max-width: 1100px; max-height: 92vh; padding: 0; overflow: hidden; }
.mom-pdf-header { padding: 0.9rem 1rem; justify-content: space-between; border-bottom: 1px solid #e2e8f0; background: #fff; }
.mom-pdf-header h3 { margin: 0; font-size: 1rem; min-width: 0; overflow-wrap: anywhere; }
.mom-pdf-actions { flex-shrink: 0; flex-wrap: wrap; }
.mom-pdf-actions a { display: inline-flex; align-items: center; justify-content: center; padding: 0.45rem 0.7rem; border: 1px solid #cbd5e1; border-radius: 8px; background: #fff; color: #4f46e5; font-size: 0.8rem; white-space: nowrap; text-decoration: none; }
.mom-pdf-preview iframe { display: block; border: 0; width: 100%; height: 75vh; background: #f8fafc; }
@media (max-width: 600px) { .mom-pdf-header { align-items: flex-start; flex-direction: column; } .mom-document-row { flex-wrap: wrap; } .mom-document-info { flex-basis: 100%; } .mom-pdf-actions { gap: 0.4rem; } }
@media print { .mom-project-documents { display: none; } }
