/* =============================================
   PROJECTIQ — DESIGN SYSTEM CSS
   ============================================= */

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

input,
select,
textarea,
button {
  font-family: inherit;
}

:root {
  --sidebar-bg: #0B1527;
  --sidebar-text: #8B9AB8;
  --sidebar-active-bg: #3B5BDB;
  --sidebar-hover-bg: rgba(255, 255, 255, 0.06);
  --sidebar-width: 210px;

  --main-bg: #F4F5F8;
  --card-bg: #FFFFFF;
  --border: #E5E7EB;
  --border-light: #F3F4F6;

  --primary: #3B5BDB;
  --primary-hover: #3251c9;
  --primary-light: #EEF2FF;

  --green: #16A34A;
  --green-bg: #DCFCE7;
  --green-light: #F0FDF4;
  --green-text: #15803D;

  --yellow: #D97706;
  --yellow-bg: #FEF3C7;
  --yellow-text: #92400E;

  --red: #DC2626;
  --red-bg: #FEE2E2;
  --red-text: #B91C1C;

  --orange: #EA580C;
  --orange-bg: #FFEDD5;
  --orange-text: #C2410C;

  --purple: #7C3AED;
  --purple-bg: #EDE9FE;
  --purple-text: #6D28D9;

  --blue-light: #DBEAFE;
  --blue-text: #1D4ED8;

  --gray-bg: #F3F4F6;
  --gray-text: #6B7280;

  --text-primary: #111827;
  --text-secondary: #6B7280;
  --text-muted: #9CA3AF;
  --text-white: #FFFFFF;

  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 1px 3px rgba(0, 0, 0, 0.08), 0 2px 8px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.10);

  --radius-sm: 5px;
  --radius-md: 8px;
  --radius-lg: 12px;
}

html,
body {
  height: 100%;
  font-family: var(--font);
  font-size: 13px;
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

#app {
  height: 100%;
}

/* =============================================
   LOGIN PAGE
   ============================================= */

.login-page {
  display: flex;
  height: 100vh;
  background: linear-gradient(135deg, #E6EEF8 0%, #F5F7FF 40%, #FFFFFF 75%, #E6EEF8 100%);
  position: relative;
  overflow: hidden;
  font-family: var(--font);
}

.login-left {
  width: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  z-index: 2;
  text-align: center;
}

.login-left-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.logo-gear {
  width: 130px;
  height: 130px;
  margin-bottom: 36px;
  filter: drop-shadow(0 8px 16px rgba(59, 130, 246, 0.2));
}

.login-brand-title {
  font-size: 56px;
  font-weight: 900;
  letter-spacing: 2px;
  color: #0F172A;
  margin-bottom: 16px;
}

.login-brand-subtitle {
  font-size: 15px;
  font-weight: 500;
  color: #475569;
  letter-spacing: 0.5px;
  margin-bottom: 48px;
}

.login-brand-footer {
  font-size: 11px;
  font-weight: 600;
  color: #64748B;
  letter-spacing: 1px;
}

.login-right {
  width: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px;
  z-index: 2;
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: #FFFFFF;
  border-radius: 32px;
  padding: 48px;
  box-shadow: 0 25px 50px -12px rgba(15, 23, 42, 0.08), 0 0 1px rgba(0, 0, 0, 0.1);
  display: flex;
  flex-direction: column;
}

.login-card h2 {
  font-size: 28px;
  font-weight: 800;
  color: #0F172A;
  margin-bottom: 8px;
  letter-spacing: -0.5px;
}

.login-card .login-subtitle {
  color: #94A3B8;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.8px;
  margin-bottom: 32px;
  text-transform: uppercase;
}

.login-form-group {
  margin-bottom: 24px;
}

.login-form-group-label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.login-form-group label {
  font-size: 11px;
  font-weight: 700;
  color: #94A3B8;
  letter-spacing: 0.8px;
}

.login-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
  background: #EEF2F6;
  border-radius: 14px;
  height: 48px;
  padding: 0 16px;
  transition: background 0.15s, box-shadow 0.15s;
}

.login-input-wrap:focus-within {
  background: #EAF0F6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.login-input-wrap svg {
  color: #94A3B8;
  flex-shrink: 0;
}

.login-input-wrap .login-form-control {
  flex: 1;
  height: 100%;
  background: transparent;
  border: none;
  outline: none;
  font-family: var(--font);
  font-size: 14px;
  font-weight: 600;
  color: #0F172A;
  padding: 0 12px;
}

.login-input-wrap .login-form-control::placeholder {
  color: #94A3B8;
  font-weight: 500;
}

.login-password-toggle {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #94A3B8;
  transition: color 0.15s;
}

.login-password-toggle:hover {
  color: #3B82F6;
}

.login-forgot-link {
  font-size: 11px;
  font-weight: 700;
  color: #2563EB;
  text-decoration: none;
  letter-spacing: 0.5px;
}

.login-forgot-link:hover {
  text-decoration: underline;
}

.btn-login {
  width: 100%;
  height: 50px;
  background: #2563EB;
  color: #ffffff;
  border: none;
  border-radius: 14px;
  font-family: var(--font);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 10px 15px -3px rgba(37, 99, 235, 0.3);
  transition: background 0.15s, transform 0.1s, box-shadow 0.15s;
}

.btn-login:hover {
  background: #1D4ED8;
  box-shadow: 0 12px 20px -3px rgba(29, 78, 216, 0.4);
}

.btn-login:active {
  transform: translateY(1px);
}

.btn-login svg {
  flex-shrink: 0;
}

.demo-box {
  margin-top: 24px;
  background: #F8FAFC;
  border: 1px solid #E2E8F0;
  border-radius: 14px;
  padding: 14px;
  text-align: center;
}

.demo-box .demo-title {
  font-size: 11px;
  font-weight: 700;
  color: #64748B;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
  text-transform: uppercase;
}

.demo-box .demo-info {
  font-size: 11px;
  color: #64748B;
  line-height: 1.8;
  font-weight: 500;
}

.demo-box .demo-info span {
  color: #2563EB;
  font-weight: 700;
}

/* =============================================
   APP LAYOUT
   ============================================= */

.app-layout {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* =============================================
   SIDEBAR
   ============================================= */

.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow: visible;
  position: relative;
  transition: width 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar.is-collapsed {
  width: 64px;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 20px 16px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  flex-shrink: 0;
  position: relative;
}

.sidebar-collapse-btn {
  position: absolute;
  top: 14px;
  right: -13px;
  z-index: 100;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--sidebar-bg);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: var(--sidebar-text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
  transition: color 0.15s, background 0.15s, border-color 0.15s, transform 0.15s;
}

.sidebar-collapse-btn:hover {
  color: #ffffff;
  background: var(--primary);
  border-color: var(--primary);
  transform: scale(1.1);
}

.sidebar.is-collapsed .sidebar-logo {
  padding: 16px 8px;
  justify-content: center;
}

.sidebar.is-collapsed .sidebar-logo-text,
.sidebar.is-collapsed .sidebar-collapse-btn,
.sidebar.is-collapsed .nav-text,
.sidebar.is-collapsed .sidebar-group-arrow,
.sidebar.is-collapsed .sidebar-submenu-items,
.sidebar.is-collapsed .user-info,
.sidebar.is-collapsed .sidebar-logout {
  display: none !important;
}

.sidebar.is-collapsed .nav-item,
.sidebar.is-collapsed .sidebar-settings {
  justify-content: center;
  padding: 10px 0;
  margin: 2px 6px;
}

.sidebar.is-collapsed .sidebar-user {
  justify-content: center;
  padding: 8px 0;
}

.sidebar-logo-icon {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sidebar-logo-text .brand {
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  display: block;
  line-height: 1.2;
}

.sidebar-logo-text .sub {
  color: rgba(255, 255, 255, 0.38);
  font-size: 8.5px;
  font-weight: 500;
  letter-spacing: 1.2px;
  text-transform: uppercase;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 0;
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-nav::-webkit-scrollbar {
  display: none;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 14px;
  margin: 1px 8px;
  border-radius: var(--radius-md);
  color: var(--sidebar-text);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
  text-decoration: none;
}

.nav-item:hover {
  background: var(--sidebar-hover-bg);
  color: rgba(255, 255, 255, 0.8);
}

.nav-item.active {
  background: var(--sidebar-active-bg);
  color: #fff;
}

.nav-item svg {
  flex-shrink: 0;
  opacity: 0.75;
}

.nav-item.active svg {
  opacity: 1;
}

/* ── Premium Dark Left Sidebar Submenus ── */
.sidebar-nav-group {
  margin: 2px 0;
}

.nav-group-header {
  display: flex !important;
  justify-content: space-between !important;
  align-items: center !important;
  user-select: none;
}

.sidebar-group-arrow {
  font-size: 9px;
  color: rgba(255, 255, 255, 0.45);
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  line-height: 1;
  padding: 4px;
}

.sidebar-nav-group:not(.is-open) .sidebar-submenu-items {
  display: none !important;
}

.sidebar-nav-group:not(.is-open) .sidebar-group-arrow {
  transform: rotate(-90deg);
}

.sidebar-submenu-items {
  padding: 4px 0 4px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  border-left: 1.5px solid rgba(255, 255, 255, 0.1);
  margin-left: 20px;
  margin-top: 2px;
  margin-bottom: 6px;
}

.sidebar-sub-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border-radius: var(--radius-md, 8px);
  color: rgba(255, 255, 255, 0.7);
  font-size: 12px;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.sidebar-sub-item:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
  transform: translateX(2px);
}

.sidebar-sub-item.active {
  background: var(--primary, #2563EB);
  color: #ffffff;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.35);
}

.sidebar-bottom {
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  padding: 12px 8px;
  flex-shrink: 0;
}

.sidebar-settings {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 14px;
  border-radius: var(--radius-md);
  color: var(--sidebar-text);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  margin-bottom: 4px;
}

.sidebar-settings:hover {
  background: var(--sidebar-hover-bg);
  color: rgba(255, 255, 255, 0.8);
}

.sidebar-settings.active {
  background: var(--sidebar-active-bg);
  color: #fff;
}

.sidebar-settings svg {
  flex-shrink: 0;
  opacity: 0.75;
}

.sidebar-settings.active svg {
  opacity: 1;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border-radius: var(--radius-md);
  cursor: pointer;
}

.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

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

.user-info .user-name {
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}

.user-info .user-role {
  color: rgba(255, 255, 255, 0.38);
  font-size: 9.5px;
  font-weight: 500;
  letter-spacing: 0.8px;
  text-transform: uppercase;
}

.sidebar-logout {
  color: var(--sidebar-text);
  cursor: pointer;
  flex-shrink: 0;
  opacity: 0.6;
  transition: opacity 0.15s;
}

.sidebar-logout:hover {
  opacity: 1;
}

/* =============================================
   MAIN AREA
   ============================================= */

.main-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--main-bg);
}

.top-bar {
  height: 44px;
  background: #fff;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  flex-shrink: 0;
}

.top-bar-title {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--text-muted);
}

.top-bar-right {
  display: flex;
  align-items: center;
  gap: 14px;
}

.fy-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
}

.fy-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
}

.top-bar-user {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

/* ── Health Document Button ── */
.health-doc-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--card-bg);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s ease;
}

.health-doc-btn:hover {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  transform: scale(1.1);
}

/* ── Health Document Modal ── */
.health-doc-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  animation: fadeIn 0.25s ease;
}

.health-doc-modal {
  background: var(--card-bg, #fff);
  border-radius: 14px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
  width: 800px;
  max-width: 95vw;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: popupScale 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.health-doc-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--border-light, #f8fafc);
  flex-shrink: 0;
}

.health-doc-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  padding: 4px;
  display: flex;
  transition: color 0.15s;
}

.health-doc-close:hover {
  color: var(--danger, #ef4444);
}

.health-doc-body {
  padding: 24px;
  overflow-y: auto;
  flex-grow: 1;
}

.health-doc-body::-webkit-scrollbar {
  width: 5px;
}

.health-doc-body::-webkit-scrollbar-track {
  background: transparent;
}

.health-doc-body::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

/* Sections */
.health-section {
  margin-bottom: 24px;
}

.health-section-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border-light, #e2e8f0);
}

/* Mini cards row */
.health-cards-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.health-mini-card {
  background: var(--gray-bg, #f8fafc);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  text-align: center;
}

.health-mini-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.health-mini-value {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
}

/* Module Status Table */
.health-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.health-table th {
  text-align: left;
  padding: 8px 12px;
  background: var(--gray-bg, #f8fafc);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 2px solid var(--border);
}

.health-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-light, #f1f5f9);
  color: var(--text-secondary);
}

.health-table tr:hover td {
  background: var(--blue-light, #eff6ff);
}

.health-status-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
}

.health-status-badge.active {
  background: #DCFCE7;
  color: #16A34A;
}

/* Role cards */
.health-role-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px;
}

.health-role-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.health-role-list {
  margin: 0;
  padding-left: 18px;
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.8;
}

/* Workflow strip */
.health-workflow {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
  padding: 14px;
  background: var(--gray-bg, #f8fafc);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.health-workflow-step {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-primary);
}

.health-wf-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
}

.health-workflow-arrow {
  color: var(--text-muted);
  font-size: 16px;
  font-weight: 300;
}

/* Business Rules Grid */
.health-rules-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.health-rule-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card-bg);
}

.health-rule-item strong {
  font-size: 13px;
  color: var(--text-primary);
}

.health-rule-item div>div {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
  line-height: 1.4;
}

.health-rule-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* Responsive */
@media (max-width: 768px) {
  .health-cards-row {
    grid-template-columns: repeat(2, 1fr);
  }

  .health-cards-row[style*="repeat(3"] {
    grid-template-columns: 1fr !important;
  }

  .health-rules-grid {
    grid-template-columns: 1fr;
  }

  .health-workflow {
    gap: 2px;
  }

  .health-workflow-step {
    padding: 4px 8px;
    font-size: 11px;
  }

  .health-doc-modal {
    max-height: 92vh;
  }
}

.page-content {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

.page-content::-webkit-scrollbar {
  width: 5px;
}

.page-content::-webkit-scrollbar-track {
  background: transparent;
}

.page-content::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

/* =============================================
   PAGE HEADER
   ============================================= */

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 20px;
}

.page-header-left h1 {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 3px;
}

.page-header-left .subtitle {
  font-size: 13px;
  color: var(--text-secondary);
}

.page-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* =============================================
   BREADCRUMB
   ============================================= */

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 12px;
  font-size: 13px;
}

.breadcrumb-back {
  display: flex;
  align-items: center;
  gap: 5px;
  color: var(--text-secondary);
  cursor: pointer;
  font-weight: 500;
  transition: color 0.15s;
}

.breadcrumb-back:hover {
  color: var(--primary);
}

.breadcrumb-sep {
  color: var(--text-muted);
}

.breadcrumb-current {
  color: var(--text-primary);
  font-weight: 500;
}

/* =============================================
   BUTTONS
   ============================================= */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 14px;
  border-radius: var(--radius-md);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  outline: none;
  transition: background 0.15s, opacity 0.15s, transform 0.1s;
  white-space: nowrap;
}

.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-secondary {
  background: var(--gray-bg);
  color: var(--text-primary);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--border-light);
}

.btn-outline {
  background: transparent;
  color: var(--primary);
  border: 1px solid var(--primary);
}

.btn-outline:hover {
  background: var(--primary-light);
}

.btn-success {
  background: var(--green);
  color: #fff;
}

.btn-success:hover {
  background: #15803D;
}

.btn-danger {
  background: var(--red);
  color: #fff;
}

.btn-danger:hover {
  background: #B91C1C;
}

.btn-warning {
  background: var(--yellow);
  color: #fff;
}

.btn-sm {
  height: 30px;
  padding: 0 11px;
  font-size: 12px;
}

/* =============================================
   BADGES / STATUS PILLS
   ============================================= */

.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
}

.badge-active {
  background: var(--green-bg);
  color: var(--green-text);
}

.badge-completed {
  background: var(--blue-light);
  color: var(--blue-text);
}

.badge-on-hold {
  background: var(--yellow-bg);
  color: var(--yellow-text);
}

.badge-planning {
  background: var(--gray-bg);
  color: var(--gray-text);
}

.badge-pending {
  background: var(--orange-bg);
  color: var(--orange-text);
}

.badge-approved {
  background: var(--green-bg);
  color: var(--green-text);
}

.badge-baselined {
  background: var(--blue-light);
  color: var(--blue-text);
}

.badge-draft {
  background: var(--gray-bg);
  color: var(--gray-text);
}

.badge-closed {
  background: var(--purple-bg);
  color: var(--purple-text);
}

.badge-rejected {
  background: var(--red-bg);
  color: var(--red-text);
}

.badge-positive {
  background: var(--green-bg);
  color: var(--green-text);
}

.badge-negative {
  background: var(--red-bg);
  color: var(--red-text);
}

.badge-inactive {
  background: var(--gray-bg);
  color: var(--text-muted);
}

.badge-danger {
  background: #FEE2E2;
  color: #DC2626;
}

.badge-count {
  background: var(--green-bg);
  color: var(--green-text);
  min-width: 24px;
  text-align: center;
  padding: 3px 7px;
}

/* =============================================
   CARDS
   ============================================= */

.card {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  position: relative;
}

.card:focus-within {
  z-index: 10;
}

.card-body {
  padding: 20px;
}

.kpi-grid {
  display: grid;
  gap: 14px;
}

.kpi-grid-3 {
  grid-template-columns: repeat(3, 1fr);
}

.kpi-grid-4 {
  grid-template-columns: repeat(4, 1fr);
}

.kpi-grid-6 {
  grid-template-columns: repeat(3, 1fr);
}

.kpi-grid-2 {
  grid-template-columns: repeat(2, 1fr);
}

.kpi-card {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: relative;
  overflow: hidden;
}

.kpi-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.9px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 2px;
}

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

.kpi-value-sm {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
}

.kpi-sub {
  font-size: 11.5px;
  color: var(--text-muted);
  margin-top: 2px;
}

.kpi-icon {
  position: absolute;
  top: 16px;
  right: 18px;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
}

.kpi-icon-blue {
  background: var(--primary-light);
  color: var(--primary);
}

.kpi-icon-green {
  background: var(--green-bg);
  color: var(--green);
}

.kpi-icon-orange {
  background: var(--orange-bg);
  color: var(--orange);
}

.kpi-icon-red {
  background: var(--red-bg);
  color: var(--red);
}

.kpi-icon-purple {
  background: var(--purple-bg);
  color: var(--purple);
}

.kpi-icon-yellow {
  background: var(--yellow-bg);
  color: var(--yellow);
}

/* Project detail top KPI row */
.project-kpi-row {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.project-kpi-pill {
  flex: 1;
  min-width: 0;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 14px;
}

.project-kpi-pill .pill-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.7px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 3px;
}

.project-kpi-pill .pill-value {
  font-size: 17px;
  font-weight: 700;
  color: var(--text-primary);
}

.project-kpi-pill .pill-sub {
  font-size: 10px;
  color: var(--text-muted);
}

.project-kpi-pill.pill-green {
  background: var(--green-light);
  border-color: #BBF7D0;
}

.project-kpi-pill.pill-green .pill-value {
  color: var(--green-text);
}

.project-kpi-pill.pill-red {
  background: #FFF5F5;
  border-color: #FECACA;
}

.project-kpi-pill.pill-red .pill-value {
  color: var(--red-text);
}

/* =============================================
   TABS
   ============================================= */

.tabs-bar {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
  background: var(--card-bg);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: 0 4px;
}

.tab-btn {
  padding: 12px 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  border: none;
  background: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  font-family: var(--font);
  transition: color 0.15s;
  white-space: nowrap;
}

.tab-btn:hover {
  color: var(--text-primary);
}

.tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: 600;
}

/* Sub tabs (Materials / Labour / Expenses) */
.sub-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 18px;
}

.sub-tab-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--radius-md);
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--card-bg);
  font-family: var(--font);
  transition: all 0.15s;
}

.sub-tab-btn.active {
  background: var(--primary-light);
  color: var(--primary);
  border-color: var(--primary);
  font-weight: 600;
}

.sub-tab-btn:hover:not(.active) {
  background: var(--gray-bg);
}

/* =============================================
   TABLES
   ============================================= */

.table-wrap {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: visible;
  box-shadow: var(--shadow-md);
}

.table-wrap table {
  width: 100%;
  border-collapse: collapse;
}

.table-wrap thead {
  background: #F9FAFB;
}

.table-wrap th {
  padding: 11px 16px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.7px;
  text-transform: uppercase;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.table-wrap td {
  padding: 13px 16px;
  font-size: 13px;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
}

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

.table-wrap tbody tr:hover {
  background: #FAFBFC;
}

.table-wrap td.text-right {
  text-align: right;
}

.table-wrap th.text-right {
  text-align: right;
}

.cell-primary {
  font-weight: 600;
  color: var(--text-primary);
}

.cell-code {
  font-size: 11.5px;
  color: var(--primary);
  font-weight: 500;
  font-family: 'JetBrains Mono', monospace;
  min-width: 78px;
}

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

.cell-muted {
  color: var(--text-muted);
  font-style: italic;
}

/* =============================================
   SEARCH / FILTER BAR
   ============================================= */

.search-filter-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.search-input-wrap {
  position: relative;
}

.search-input-wrap svg {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

.search-input {
  width: 380px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-family: var(--font);
  font-size: 13px;
  color: var(--text-primary);
  background: var(--card-bg);
  padding: 0 12px 0 34px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.search-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59, 91, 219, 0.1);
}

.search-input::placeholder {
  color: var(--text-muted);
}

.filter-tabs {
  display: flex;
  gap: 4px;
}

.filter-tab {
  padding: 6px 13px;
  border-radius: var(--radius-md);
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  border: none;
  background: transparent;
  font-family: var(--font);
  transition: background 0.15s, color 0.15s;
}

.filter-tab:hover {
  background: var(--gray-bg);
}

.filter-tab.active {
  background: var(--card-bg);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  font-weight: 600;
}

/* =============================================
   PROGRESS BAR
   ============================================= */

.progress-track {
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 3px;
  background: var(--primary);
  transition: width 0.6s ease;
}

.progress-fill.green {
  background: var(--green);
}

.progress-fill.yellow {
  background: var(--yellow);
}

.progress-fill.red {
  background: var(--red);
}

.progress-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 5px;
  font-size: 11.5px;
  color: var(--text-muted);
}

/* =============================================
   AVATAR
   ============================================= */

.avatar-circle {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.avatar-lg {
  width: 52px;
  height: 52px;
  font-size: 20px;
}

/* =============================================
   GRID LAYOUTS
   ============================================= */

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.grid-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 16px;
}

.grid-2-1 {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 16px;
}

.grid-1-2 {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 16px;
}

/* =============================================
   CHARTS
   ============================================= */

.chart-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 20px;
}

.chart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.chart-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.chart-legend {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 10px;
}

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

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

/* =============================================
   CUSTOMERS PAGE
   ============================================= */

.customer-cell {
  display: flex;
  align-items: center;
  gap: 12px;
}

.customer-info .name {
  font-weight: 600;
  font-size: 13px;
}

.customer-info .gstin {
  font-size: 11px;
  color: var(--primary);
  font-family: monospace;
  margin-top: 2px;
}

/* =============================================
   CUSTOMER DETAIL PAGE
   ============================================= */

.customer-detail-layout {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 20px;
  align-items: start;
}

.customer-profile-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 24px;
}

.customer-profile-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 20px;
}

.customer-profile-header .name {
  font-size: 17px;
  font-weight: 700;
}

.customer-profile-header .cid {
  font-size: 11.5px;
  color: var(--text-muted);
}

.profile-field {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 14px;
  color: var(--text-secondary);
}

.profile-field svg {
  flex-shrink: 0;
  margin-top: 1px;
}

.profile-field .field-value {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.contact-section-title {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 14px;
  margin-top: 6px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.contact-card {
  margin-bottom: 16px;
}

.contact-card .contact-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
}

.contact-card .contact-role {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.contact-card .contact-detail {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 3px;
}

.profile-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.profile-stat {
  text-align: center;
}

.profile-stat .stat-num {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
}

.profile-stat .stat-num.blue {
  color: var(--primary);
}

.profile-stat .stat-label {
  font-size: 11px;
  color: var(--text-muted);
}

/* Project History */
.project-history-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 20px;
}

.project-history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.project-history-header h3 {
  font-size: 16px;
  font-weight: 700;
}

.history-item {
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin-bottom: 10px;
}

.history-item-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 8px;
}

.history-code {
  font-size: 11px;
  color: var(--primary);
  font-weight: 500;
  font-family: monospace;
}

.history-name {
  font-size: 13px;
  font-weight: 600;
}

.history-dates {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

.history-financials {
  text-align: right;
}

.history-value {
  font-size: 14px;
  font-weight: 700;
}

.history-profit {
  font-size: 12px;
  font-weight: 600;
  color: var(--green);
}

/* =============================================
   PROJECTS LIST
   ============================================= */

.project-cell {
  min-width: 200px;
}

.project-cell .proj-code {
  font-size: 11px;
  color: var(--primary);
  font-family: monospace;
  font-weight: 500;
}

.project-cell .proj-name {
  font-size: 13px;
  font-weight: 600;
  margin-top: 1px;
}

.customer-with-contacts .cust-name {
  font-size: 13px;
  font-weight: 500;
}

.customer-with-contacts .cust-contact {
  font-size: 11.5px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.customer-with-contacts .cust-contact span {
  color: var(--text-muted);
}

/* =============================================
   PROJECT DETAIL
   ============================================= */

.project-detail-header {
  margin-bottom: 16px;
}

.project-detail-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.project-detail-title {
  display: flex;
  align-items: center;
  gap: 12px;
}

.project-detail-title h1 {
  font-size: 22px;
  font-weight: 700;
}

.project-meta {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 12.5px;
  color: var(--text-secondary);
  margin-top: 6px;
}

.project-meta-item {
  display: flex;
  align-items: center;
  gap: 5px;
}

/* Tabs for project workspace */
.project-tabs-bar {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  display: flex;
  padding: 0 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0;
}

.project-tab-content {
  background: var(--main-bg);
  margin-top: 0;
}

/* =============================================
   OVERVIEW TAB
   ============================================= */

.overview-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

.overview-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 18px 20px;
}

.overview-card h4 {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.9px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 12px;
}

/* Customer card inside overview */
.ov-customer-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.ov-customer-header .cust-name {
  font-size: 15px;
  font-weight: 700;
}

.ov-contact {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 10px;
}

.ov-contact-info .name {
  font-size: 13px;
  font-weight: 600;
}

.ov-contact-info .email {
  font-size: 11.5px;
  color: var(--text-secondary);
  margin-top: 1px;
}

.ov-contact-info .phone {
  font-size: 11.5px;
  color: var(--text-secondary);
}

/* Contract Value Summary */
.contract-line {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 7px 0;
  font-size: 13px;
  border-bottom: 1px solid var(--border-light);
}

.contract-line:last-child {
  border-bottom: none;
}

.contract-line.total {
  font-weight: 700;
  font-size: 14px;
  border-top: 1px solid var(--border);
  padding-top: 10px;
}

.contract-amount-blue {
  color: var(--primary);
  font-weight: 700;
}

.contract-amount-green {
  color: var(--green);
  font-weight: 600;
}

.contract-amount-red {
  color: var(--red);
  font-weight: 600;
}

.contract-amount-orange {
  color: var(--orange);
  font-weight: 600;
}

/* Profit Snapshot */
.profit-value-big {
  font-size: 26px;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 4px;
}

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

/* Budget Summary */
.budget-full {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 18px 20px;
  margin-bottom: 16px;
}

.budget-row {
  margin-bottom: 14px;
}

.budget-row-label {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  margin-bottom: 6px;
}

.budget-row-label .label {
  font-weight: 500;
  color: var(--text-secondary);
}

.budget-row-label .percent {
  font-weight: 600;
  color: var(--text-primary);
}

/* Recent Activity */
.activity-list {}

.activity-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid var(--border-light);
  font-size: 13px;
}

.activity-item:last-child {
  border-bottom: none;
}

.activity-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
  flex-shrink: 0;
  margin-top: 5px;
}

.activity-dot.gray {
  background: var(--border);
}

.activity-dot.blue {
  background: var(--primary);
}

.activity-dot.orange {
  background: var(--orange);
}

.activity-text {
  flex: 1;
  color: var(--text-primary);
  line-height: 1.4;
}

.activity-time {
  font-size: 11.5px;
  color: var(--text-muted);
  white-space: nowrap;
}

/* =============================================
   ESTIMATE TAB
   ============================================= */

.estimate-layout {
  display: flex;
  gap: 16px;
  align-items: flex-start;
}

.cost-tree-panel {
  width: 200px;
  flex-shrink: 0;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  transition: width 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.cost-tree-panel.is-collapsed {
  width: 48px;
}

.estimate-content {
  flex: 1;
  min-width: 0;
}

.cost-tree-header {
  padding: 12px 14px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.9px;
  text-transform: uppercase;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.cost-tree-header-title {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cost-tree-toggle-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  transition: color 0.15s, background 0.15s;
}

.cost-tree-toggle-btn:hover {
  color: var(--text-primary);
  background: var(--border-light);
}

.cost-tree-panel.is-collapsed .cost-tree-header {
  padding: 12px 0;
  justify-content: center;
}

.cost-tree-panel.is-collapsed .cost-tree-header-title {
  display: none !important;
}

.cost-tree-panel.is-collapsed .estimate-version-tab {
  padding: 10px 0 !important;
  justify-content: center !important;
  border-left: none !important;
}

.cost-tree-panel.is-collapsed .estimate-version-tab .version-full-label,
.cost-tree-panel.is-collapsed .estimate-version-tab .version-badge {
  display: none !important;
}

.cost-tree-panel.is-collapsed .estimate-version-tab .version-pill {
  display: inline-block !important;
}

.estimate-version-tab .version-pill {
  display: none;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 12px;
  background: var(--border-light);
  color: var(--text-secondary);
}

.estimate-version-tab.active-est-version .version-pill {
  background: var(--primary);
  color: #ffffff;
}

.tree-item {
  padding: 8px 12px;
  font-size: 12.5px;
  cursor: pointer;
  transition: background 0.1s;
  display: flex;
  align-items: center;
  gap: 6px;
}

.tree-item:hover {
  background: var(--gray-bg);
}

.tree-item.active {
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 600;
}

.tree-item-l0 {
  font-weight: 700;
  color: var(--text-primary);
  padding-left: 12px;
  border-bottom: 1px solid var(--border-light);
}

.tree-item-l1 {
  padding-left: 24px;
  color: var(--text-secondary);
  font-size: 12px;
}

.tree-item-l2 {
  padding-left: 38px;
  color: var(--text-muted);
  font-size: 11.5px;
}

.tree-chevron {
  color: var(--text-muted);
  flex-shrink: 0;
}

.estimate-content {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.estimate-content-header {
  padding: 14px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border);
}

.estimate-content-header h3 {
  font-size: 16px;
  font-weight: 700;
}

.estimate-table {
  flex: 1;
  overflow: auto;
}

.estimate-table table {
  width: 100%;
  border-collapse: collapse;
}

.estimate-table th {
  position: sticky;
  top: 0;
  z-index: 10;
  padding: 8px 6px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--text-muted);
  background: #F9FAFB;
  border-bottom: 1px solid var(--border);
  text-align: right;
  white-space: nowrap;
}

.estimate-table th:first-child {
  text-align: left;
  padding-left: 10px;
}

.estimate-table td {
  padding: 6px 6px;
  font-size: 12.5px;
  border-bottom: 1px solid var(--border-light);
  text-align: right;
  vertical-align: middle;
}

.estimate-table td:first-child {
  text-align: left;
  padding-left: 10px;
}

.estimate-table tr:hover td {
  background: #FAFBFC;
}

.selling-value {
  color: var(--primary);
  font-weight: 600;
}

.estimate-footer {
  padding: 12px 20px;
  background: #F9FAFB;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 0;
}

.estimate-footer-item {
  flex: 1;
  text-align: center;
  padding: 0 10px;
  border-right: 1px solid var(--border);
}

.estimate-footer-item:last-child {
  border-right: none;
}

.estimate-footer-item .footer-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 3px;
}

.estimate-footer-item .footer-value {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
}

.estimate-footer-item .footer-value.green {
  color: var(--green);
}

.estimate-footer-item .footer-value.blue {
  color: var(--primary);
}

/* =============================================
   QUOTATION TAB
   ============================================= */

.quotation-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 18px;
}

.quotation-header h2 {
  font-size: 20px;
  font-weight: 700;
}

.quotation-header .sub {
  font-size: 13px;
  color: var(--text-secondary);
}

.workflow-stepper {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 20px 24px;
  margin-bottom: 20px;
}

.workflow-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 14px;
}

.stepper {
  display: flex;
  align-items: center;
  gap: 0;
}

.step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  position: relative;
  flex: 1;
}

.step-circle {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  z-index: 1;
}

.step.completed .step-circle {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.step.active .step-circle {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.step-label {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
}

.step.active .step-label {
  color: var(--primary);
  font-weight: 600;
}

.step.completed .step-label {
  color: var(--primary);
}

.step-connector {
  height: 2px;
  flex: 1;
  background: var(--border);
  margin-bottom: 24px;
}

.step-connector.done {
  background: var(--primary);
}

.quotation-versions-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.version-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 18px;
}

.version-card-new {
  background: var(--card-bg);
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  min-height: 140px;
  color: var(--primary);
  font-size: 13px;
  font-weight: 600;
  transition: background 0.15s;
}

.version-card-new:hover {
  background: var(--primary-light);
}

.version-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 6px;
}

.version-number {
  font-size: 16px;
  font-weight: 800;
}

.version-date {
  font-size: 11.5px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.version-value {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 6px;
}

.version-notes {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 14px;
  line-height: 1.5;
}

.version-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.btn-ver {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--gray-bg);
  color: var(--text-secondary);
  font-family: var(--font);
  transition: background 0.15s;
}

.btn-ver:hover {
  background: var(--border);
}

.btn-ver-primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.btn-ver-primary:hover {
  background: var(--primary-hover);
}

/* =============================================
   ACTUAL COSTS TAB
   ============================================= */

.cost-summary-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-bottom: 18px;
}

.cost-summary-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 16px 18px;
}

.cost-summary-card .cs-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.7px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.cost-summary-card .cs-value {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
}

.cost-summary-card .cs-value.over {
  color: var(--red);
}

.cost-summary-card .cs-value.under {
  color: var(--green);
}

.cost-summary-card .cs-value.variance-pos {
  color: var(--red);
}

.variance-pos-text {
  color: var(--red);
  font-weight: 600;
}

.variance-neg-text {
  color: var(--green);
  font-weight: 600;
}

.variance-arrow {
  margin-right: 2px;
}

/* =============================================
   CHANGE ORDERS TAB
   ============================================= */

.co-timeline-item {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-sm);
}

.co-item-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 6px;
}

.co-item-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.co-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.co-icon-pos {
  background: var(--green-bg);
  color: var(--green);
}

.co-icon-neg {
  background: var(--red-bg);
  color: var(--red);
}

.co-number {
  font-size: 14px;
  font-weight: 700;
}

.co-date {
  font-size: 11.5px;
  color: var(--text-muted);
}

.co-desc {
  font-size: 13px;
  color: var(--text-secondary);
  margin: 6px 0;
  padding-left: 42px;
}

.co-impact {
  text-align: right;
}

.co-impact-value {
  font-size: 15px;
  font-weight: 700;
}

.co-impact-value.pos {
  color: var(--green);
}

.co-impact-value.neg {
  color: var(--red);
}

.co-impact-label {
  font-size: 11px;
  color: var(--text-muted);
}

.co-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border-light);
}

/* =============================================
   PAYMENTS TAB
   ============================================= */

.payment-collection-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 18px 20px;
  margin-bottom: 18px;
}

.payment-collection-card h4 {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 10px;
}

.collection-progress-wrap {
  margin-bottom: 6px;
}

.collection-progress-fill {
  height: 8px;
  background: var(--green);
  border-radius: 4px;
}

.collection-percent {
  text-align: right;
  font-size: 12px;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 5px;
}

.payment-row-total {
  font-weight: 700;
  background: #F9FAFB;
}

/* =============================================
   FINANCIALS TAB
   ============================================= */

.financials-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-bottom: 20px;
}

.fin-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 16px 18px;
}

.fin-card .fin-label {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.fin-card .fin-value {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
}

.fin-card .fin-value.blue {
  color: var(--primary);
}

.fin-card .fin-value.green {
  color: var(--green);
}

.fin-card .fin-value.red {
  color: var(--red);
}

.fin-card .fin-sub {
  font-size: 11.5px;
  color: var(--text-muted);
  margin-top: 3px;
}

/* =============================================
   REPORTS PAGE
   ============================================= */

.reports-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.report-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 20px;
}

.report-card-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
}

.report-card h3 {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 6px;
}

.report-card p {
  font-size: 12.5px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 16px;
}

.report-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.btn-export {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 11px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--gray-bg);
  color: var(--text-secondary);
  font-family: var(--font);
  transition: background 0.15s;
}

.btn-export:hover {
  background: var(--border);
}

/* =============================================
   MASTERS PAGE
   ============================================= */

.masters-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 20px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 6px;
  display: inline-flex;
}

.master-tab {
  padding: 7px 18px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  background: transparent;
  font-family: var(--font);
  color: var(--text-secondary);
  transition: all 0.15s;
}

.master-tab.active {
  background: var(--card-bg);
  color: var(--text-primary);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
}

.action-icons {
  display: flex;
  gap: 8px;
  align-items: center;
}

.icon-btn {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  cursor: pointer;
  background: transparent;
  border: none;
  transition: background 0.15s;
}

.icon-btn:hover {
  background: var(--gray-bg);
}

.icon-btn-edit {
  color: var(--primary);
}

.icon-btn-delete {
  color: var(--red);
}

/* =============================================
   DASHBOARD - SPECIFIC WIDGETS
   ============================================= */

/* Period filter */
.period-filter {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 6px 12px;
  font-size: 12.5px;
  color: var(--text-secondary);
}

.period-filter input[type="date"] {
  border: none;
  font-family: var(--font);
  font-size: 12px;
  color: var(--text-primary);
  outline: none;
  background: transparent;
}

/* Pending Approvals */
.approval-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-light);
}

.approval-item:last-child {
  border-bottom: none;
}

.approval-left .approval-title {
  font-size: 13px;
  font-weight: 600;
}

.approval-left .approval-sub {
  font-size: 11.5px;
  color: var(--text-muted);
}

.approval-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.approval-amount {
  font-size: 13px;
  font-weight: 700;
}

.review-link {
  font-size: 12px;
  color: var(--primary);
  font-weight: 600;
  cursor: pointer;
}

/* Supervisor My Projects */
.my-project-item {
  padding: 14px 0;
  border-bottom: 1px solid var(--border-light);
}

.my-project-item:last-child {
  border-bottom: none;
}

.my-project-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.my-project-name {
  font-size: 13.5px;
  font-weight: 600;
}

.my-project-client {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.my-project-budget {
  font-size: 11.5px;
  color: var(--text-muted);
  margin-top: 5px;
  text-align: right;
}

/* Quick Actions (Staff) */
.quick-action-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  cursor: pointer;
  border: 1px solid var(--border);
  margin-bottom: 8px;
  transition: background 0.15s;
  font-size: 13px;
  font-weight: 600;
  background: var(--card-bg);
}

.qa-blue {
  color: var(--primary);
  border-left: 3px solid var(--primary);
}

.qa-orange {
  color: var(--orange);
  border-left: 3px solid var(--orange);
}

.qa-purple {
  color: var(--purple);
  border-left: 3px solid var(--purple);
}

.qa-green {
  color: var(--green);
  border-left: 3px solid var(--green);
}

.quick-action-item:hover {
  background: var(--gray-bg);
}

/* =============================================
   MODAL
   ============================================= */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(2px);
}

.modal {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 500px;
  max-width: 95vw;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h3 {
  font-size: 17px;
  font-weight: 700;
}

.modal-close {
  cursor: pointer;
  color: var(--text-muted);
  background: none;
  border: none;
  padding: 4px;
  border-radius: 4px;
  transition: color 0.15s;
}

.modal-close:hover {
  color: var(--text-primary);
}

.modal-body {
  padding: 20px 24px;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.form-group-modal {
  margin-bottom: 16px;
}

.form-group-modal label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 5px;
}

.form-control-modal {
  width: 100%;
  height: 38px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-family: var(--font);
  font-size: 13px;
  padding: 0 12px;
  color: var(--text-primary);
  background: #fff;
  outline: none;
  transition: border-color 0.15s;
}

.form-control-modal:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59, 91, 219, 0.1);
}

select.form-control-modal {
  cursor: pointer;
}

/* =============================================
   UTILITY
   ============================================= */

.hidden {
  display: none !important;
}

.text-right {
  text-align: right;
}

.text-center {
  text-align: center;
}

.mt-4 {
  margin-top: 16px;
}

.mt-8 {
  margin-top: 32px;
}

.mb-4 {
  margin-bottom: 16px;
}

.gap-12 {
  gap: 12px;
}

.flex {
  display: flex;
}

.flex-center {
  display: flex;
  align-items: center;
}

.justify-between {
  justify-content: space-between;
}

.font-bold {
  font-weight: 700;
}

.text-green {
  color: var(--green);
}

.text-red {
  color: var(--red);
}

.text-primary-color {
  color: var(--primary);
}

.text-muted {
  color: var(--text-muted);
}

.text-sm {
  font-size: 12px;
}

/* Notice badge */
.count-badge {
  background: var(--primary);
  color: #fff;
  border-radius: 20px;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 7px;
  min-width: 20px;
  text-align: center;
}

/* Dashboard header + period row */
.dashboard-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 18px;
}

/* =============================================
   TABLE TOOLBAR (Search + Filters)
   ============================================= */

.table-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  gap: 12px;
  flex-wrap: wrap;
}

.toolbar-filters {
  display: flex;
  align-items: center;
  gap: 8px;
}

.filter-select {
  height: 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-family: var(--font);
  font-size: 13px;
  color: var(--text-primary);
  background: var(--card-bg);
  padding: 0 28px 0 10px;
  outline: none;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236B7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
}

.filter-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59, 91, 219, 0.1);
}

/* =============================================
   ROW ACTIONS (Three-dot Menu)
   ============================================= */

.btn-icon-sm {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  background: transparent;
  cursor: pointer;
  color: var(--text-muted);
  transition: all 0.15s;
}

.btn-icon-sm:hover {
  background: var(--gray-bg);
  border-color: var(--border);
  color: var(--text-primary);
}

.row-actions-wrap {
  position: relative;
  display: inline-flex;
}

.row-actions-menu {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  z-index: 100;
  min-width: 190px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  padding: 6px 0;
  animation: menuFadeIn 0.15s ease;
}

.row-actions-menu.open {
  display: block;
}

@keyframes menuFadeIn {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.row-action-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 14px;
  border: none;
  background: transparent;
  font-family: var(--font);
  font-size: 13px;
  color: var(--text-primary);
  cursor: pointer;
  text-align: left;
  transition: background 0.1s;
}

.row-action-item:hover {
  background: var(--gray-bg);
}

.row-action-item svg {
  flex-shrink: 0;
}

.row-action-danger {
  color: var(--red);
}

.row-action-danger:hover {
  background: var(--red-bg);
}

.row-action-divider {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}

.actions-cell {
  text-align: center;
}

/* =============================================
   CUSTOMER DETAIL PAGE — HEADER CARD
   ============================================= */

.cd-header-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 20px 24px;
  margin-bottom: 4px;
}

.cd-header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.cd-header-info {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.cd-header-name {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
}

.cd-header-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12.5px;
  color: var(--text-muted);
}

.cd-header-id {
  font-weight: 500;
  color: var(--text-secondary);
}

.cd-header-gstin {
  display: flex;
  align-items: center;
  gap: 4px;
}

.cd-header-actions {
  display: flex;
  gap: 8px;
}

/* =============================================
   CUSTOMER DETAIL PAGE — CONTENT GRID
   ============================================= */

.cd-content-grid {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 16px;
}

.cd-left-col,
.cd-right-col {
  display: flex;
  flex-direction: column;
}

/* Card section header */
.card-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
}

.card-section-header h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-section-content {
  padding: 20px;
}

/* Info grid (key-value rows) */
.info-grid {
  display: flex;
  flex-direction: column;
}

.info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-light);
}

.info-row:last-child {
  border-bottom: none;
}

.info-label {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
}

.info-value {
  font-size: 13px;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 5px;
}

/* Contact card v2 */
.contact-card-v2 {
  display: flex;
  flex-direction: column;
  padding: 12px;
  background: var(--gray-bg);
  border-radius: var(--radius-md);
  margin-bottom: 8px;
  gap: 10px;
  min-width: 0;
}

.contact-card-v2:last-child {
  margin-bottom: 0;
}

.contact-card-v2-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  width: 100%;
}

.contact-card-v2-left>div:not(.contact-avatar) {
  min-width: 0;
  flex: 1;
}

.contact-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  flex-shrink: 0;
}

.contact-card-v2-right {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: flex-start;
  min-width: 0;
  flex-shrink: 1;
  width: 100%;
  padding-left: 46px;
  /* align details with name (avatar width 36px + gap 10px) */
  box-sizing: border-box;
}

.contact-card-v2 .contact-detail {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: var(--text-secondary);
  max-width: 100%;
  min-width: 0;
}

.contact-card-v2 .contact-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* =============================================
   TIMELINE
   ============================================= */

.timeline {
  display: flex;
  flex-direction: column;
  gap: 0;
  position: relative;
  padding-left: 24px;
}

.timeline::before {
  content: '';
  position: absolute;
  left: 7px;
  top: 6px;
  bottom: 6px;
  width: 2px;
  background: var(--border);
}

.timeline-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 0;
  position: relative;
}

.timeline-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: var(--card-bg);
  position: absolute;
  left: -24px;
  top: 12px;
  z-index: 1;
}

.timeline-dot.green {
  border-color: var(--green);
  background: var(--green-bg);
}

.timeline-dot.blue {
  border-color: var(--primary);
  background: var(--primary-light);
}

.timeline-dot.purple {
  border-color: var(--purple);
  background: var(--purple-bg);
}

.timeline-dot.red {
  border-color: var(--red);
  background: var(--red-bg);
}

.timeline-content {
  flex: 1;
}

.timeline-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
}

.timeline-date {
  font-size: 11.5px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* =============================================
   ADD CUSTOMER FORM
   ============================================= */

.add-customer-form-layout {
  max-width: 820px;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.form-group-full {
  grid-column: 1 / -1;
}

.form-group label .required {
  color: var(--red);
}

.form-actions-bar {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 0;
}

.btn-outline {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  border-radius: var(--radius-md);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  border: 1px solid var(--border);
  background: var(--card-bg);
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.15s;
}

.btn-outline:hover {
  background: var(--gray-bg);
  border-color: var(--text-muted);
}

.btn-sm {
  padding: 5px 12px;
  font-size: 12px;
}

/* Contact form blocks */
.contact-form-block {
  padding: 16px 0;
  border-bottom: 1px solid var(--border-light);
}

.contact-form-block:last-child {
  border-bottom: none;
}

.contact-form-block:first-child {
  padding-top: 0;
}

.contact-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.contact-block-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.btn-remove-contact,
.btn-remove-branch {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border: 1px solid var(--red-bg);
  border-radius: var(--radius-md);
  background: var(--red-bg);
  color: var(--red);
  font-family: var(--font);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-remove-contact:hover,
.btn-remove-branch:hover {
  background: var(--red);
  color: #fff;
  border-color: var(--red);
}

/* Customer name hover effect in table */
.customer-name-link .name {
  transition: color 0.15s;
}

.customer-name-link:hover .name {
  color: var(--primary);
  text-decoration: underline;
}

/* =============================================
   FORM CONTROLS (Add/Edit Customer)
   ============================================= */

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 4px;
}

.form-group label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 0.2px;
}

.form-control {
  width: 100%;
  height: 42px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  font-family: var(--font);
  font-size: 13.5px;
  padding: 0 14px;
  color: var(--text-primary);
  background: var(--card-bg);
  outline: none;
}

select.form-control {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236B7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
  cursor: pointer;
}

.form-control:hover {
  border-color: #CBD5E1;
}

.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59, 91, 219, 0.12);
  background: #FAFBFF;
}

.form-control::placeholder {
  color: var(--text-muted);
  font-weight: 400;
}

/* Input with icon wrapper */
.input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.input-wrap svg {
  position: absolute;
  left: 12px;
  color: var(--text-muted);
  pointer-events: none;
  z-index: 1;
  flex-shrink: 0;
}

.input-wrap .form-control {
  padding-left: 38px;
}

/* Improved card section headers for forms */
.add-customer-form-layout .card {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  overflow: visible;
  transition: box-shadow 0.2s;
}

.add-customer-form-layout .card-section-header {
  border-top-left-radius: var(--radius-lg);
  border-top-right-radius: var(--radius-lg);
}

.add-customer-form-layout .card:hover {
  box-shadow: var(--shadow-lg);
}

.add-customer-form-layout .card-section-header {
  background: #FAFBFC;
}

.add-customer-form-layout .card-section-header h3 {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -0.1px;
}

.add-customer-form-layout .card-body {
  padding: 24px;
}

.add-customer-form-layout .form-grid {
  gap: 20px;
}

/* Contact form block refinements */
.contact-form-block {
  padding: 20px 0;
  border-bottom: 1px solid var(--border-light);
}

.contact-form-block:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.contact-form-block:first-child {
  padding-top: 0;
}

.contact-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.contact-block-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
}

/* Form actions bar */
.form-actions-bar {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding: 20px 0;
}

.form-actions-bar .btn {
  height: 42px;
  padding: 0 24px;
  font-size: 14px;
  border-radius: var(--radius-md);
}

/* Responsive fixes */
@media (max-width: 1100px) {
  .overview-grid {
    grid-template-columns: 1fr 1fr;
  }

  .kpi-grid-3,
  .kpi-grid-6 {
    grid-template-columns: repeat(2, 1fr);
  }

  .quotation-versions-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .reports-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .cd-content-grid {
    grid-template-columns: 1fr;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }
}

/* =============================================
/* =============================================
   BOQ BUILDER — ESTIMATE TAB
   ============================================= */

/* Empty State */
.boq-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  text-align: center;
}

.boq-empty-icon {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  background: var(--blue-light, #EFF6FF);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
  color: var(--primary);
}

.boq-empty-icon svg {
  width: 28px;
  height: 28px;
}

.boq-empty-state h3 {
  margin-bottom: 4px;
  font-size: 18px;
  color: var(--text-primary);
}

/* Section Header Row — Level 0 (top) */
.boq-section-header-row td {
  background: #EDF2F7 !important;
  padding: 12px 14px !important;
  border-bottom: none !important;
  border-left: 4px solid var(--primary) !important;
}

.boq-section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-primary);
}

.boq-section-icon {
  color: var(--primary);
  display: flex;
  align-items: center;
}

.boq-section-icon svg {
  width: 16px;
  height: 16px;
}

/* Inline Inputs */
.boq-inline-input {
  width: 100%;
  border: 1px solid transparent;
  background: transparent;
  padding: 6px 8px;
  font-size: 13px;
  font-family: inherit;
  color: var(--text-primary);
  border-radius: 4px;
  transition: all 0.15s ease;
  box-sizing: border-box;
}

/* Remove default number spinner arrows to prevent text clipping */
.boq-inline-input::-webkit-outer-spin-button,
.boq-inline-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.boq-inline-input[type=number] {
  -moz-appearance: textfield;
  appearance: textfield;
}

.boq-inline-input:hover {
  border-color: var(--border);
  background: #FAFBFC;
}

.boq-inline-input:focus {
  outline: none;
  border-color: var(--primary);
  background: white;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.15);
}

.boq-field-desc {
  min-width: 140px;
}

.boq-field-num {
  text-align: right !important;
  width: 100%;
  padding-right: 6px !important;
  padding-left: 4px !important;
}

.boq-field-unit {
  text-align: center;
  width: 100%;
}

.boq-field-pct {
  text-align: right !important;
  width: 100%;
  padding-right: 6px !important;
  padding-left: 4px !important;
}

.boq-field-val {
  text-align: right !important;
  width: 100%;
  padding-right: 6px !important;
  padding-left: 4px !important;
}

/* Hide number input spinners in estimate table */
.estimate-table input::-webkit-outer-spin-button,
.estimate-table input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.estimate-table input[type="number"] {
  -moz-appearance: textfield;
}

/* Calculated Cells */
.boq-calc-cell {
  font-weight: 600;
  text-align: right;
  font-size: 13px;
  padding-right: 14px !important;
  color: var(--text-primary);
  white-space: nowrap;
}

.boq-calc-cell.boq-selling {
  color: var(--primary);
}

/* Item Rows — Direct (under header) */
.boq-item-row td {
  border-left: 4px solid #CBD5E1 !important;
  padding-left: 24px;
}

.boq-item-row td:first-child {
  padding-left: 24px !important;
}

.boq-item-row:hover td {
  background: #F7FAFC;
}

/* Item Rows — Depth 1 (under sub-header) */
.boq-item-row.boq-depth-1 td {
  border-left: 4px solid #A5B4FC !important;
  background: #FAFBFF;
}

.boq-item-row.boq-depth-1 td:first-child {
  padding-left: 48px !important;
}

.boq-item-row.boq-depth-1:hover td {
  background: #F0F4FF;
}

/* Subtotal Row */
.boq-subtotal-row td {
  background: #EDF2F7 !important;
  border-top: 1px solid #CBD5E1 !important;
  border-bottom: 2px solid #CBD5E1 !important;
  border-left: 4px solid var(--primary) !important;
  padding: 10px 14px !important;
}

.boq-subtotal-label {
  text-align: right !important;
  font-weight: 700;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  color: var(--text-secondary, #475569);
}

.boq-subtotal-value {
  font-weight: 700;
  text-align: right !important;
  font-size: 13px;
  color: var(--text-primary);
}

.boq-subtotal-value.boq-selling {
  color: var(--primary);
}

/* Add Item Row */
.boq-add-item-row td {
  padding: 6px 14px 6px 24px !important;
  border-bottom: 1px solid #F1F5F9 !important;
  border-left: 4px solid #CBD5E1 !important;
}

.boq-add-item-row.boq-depth-1 td {
  border-left: 4px solid #A5B4FC !important;
  padding-left: 48px !important;
  background: #FAFBFF;
}

.boq-add-item-btn {
  background: none;
  border: 1px dashed #CBD5E1;
  color: var(--text-muted);
  font-size: 12px;
  padding: 5px 12px;
  border-radius: 4px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.15s ease;
}

.boq-add-item-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--blue-light, #EFF6FF);
}

.boq-add-item-btn svg {
  width: 14px;
  height: 14px;
}

/* Delete Button */
.boq-actions-cell {
  text-align: center;
}

.boq-delete-btn {
  background: none;
  border: none;
  color: #CBD5E1;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
}

.boq-delete-btn:hover {
  color: #EF4444;
  background: #FEF2F2;
}

.boq-delete-btn svg {
  width: 14px;
  height: 14px;
}

/* Add Section Form */
.boq-add-section-form {
  padding: 12px 20px;
  background: #F8FAFC;
  border-bottom: 1px solid var(--border);
}

.boq-section-form-inner {
  display: flex;
  align-items: center;
  gap: 10px;
}

.boq-section-form-inner .form-control {
  flex: 1;
  height: 36px;
  font-size: 13px;
}

/* BOQ Table overrides */
.boq-table table {
  border-collapse: collapse;
  width: 100%;
}

.boq-table thead th {
  position: sticky;
  top: 0;
  z-index: 10;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  padding: 10px 14px;
  text-align: left;
  background: #F8FAFC;
  border-bottom: 2px solid #E2E8F0;
  white-space: nowrap;
}

.boq-table tbody td {
  padding: 4px 6px;
  border-bottom: 1px solid #F1F5F9;
  vertical-align: middle;
}

/* Sub-header rows — Level 1 */
.boq-subheader-row td {
  background: #EEF2FF !important;
  padding: 9px 14px 9px 32px !important;
  border-bottom: none !important;
  border-left: 4px solid #818CF8 !important;
}

.boq-subheader-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: #4F46E5;
}

.boq-subheader-icon {
  color: #818CF8;
  display: flex;
  align-items: center;
}

.boq-subheader-icon svg {
  width: 14px;
  height: 14px;
}

/* Sub-header inline form row */
.boq-subheader-form-row td {
  background: #EEF2FF !important;
  padding: 8px 14px !important;
  border-bottom: 1px solid #E2E8F0 !important;
  border-left: 4px solid #818CF8 !important;
}

/* Add Sub-Header button (inline in section header) */
.boq-add-subheader-btn {
  margin-left: auto;
  background: none;
  border: 1px dashed #94A3B8;
  color: #64748B;
  font-size: 11px;
  padding: 3px 10px;
  border-radius: 4px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  transition: all 0.15s ease;
  font-weight: 500;
}

.boq-add-subheader-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--blue-light, #EFF6FF);
}

.boq-add-subheader-btn svg {
  width: 12px;
  height: 12px;
}

/* Footer green */
.estimate-footer .footer-value.green {
  color: #059669;
}

/* ═══════════════════════════════════════════════════════════════════════
   QUOTATION TAB STYLES
   ═══════════════════════════════════════════════════════════════════════ */

.quotation-container {
  padding: 0;
}

/* Header bar */
.quotation-header-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  background: white;
  border-bottom: 1px solid var(--border);
}

.quotation-header-bar h3 {
  font-size: 18px;
}

/* Status badges */
.quotation-status-badge {
  padding: 6px 16px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.quotation-status-draft {
  background: #F1F5F9;
  color: #475569;
}

.quotation-status-quoted {
  background: #E0F2FE;
  color: #0369A1;
}

.quotation-status-closed {
  background: #DBEAFE;
  color: #1D4ED8;
}

.quotation-status-approved {
  background: #D1FAE5;
  color: #065F46;
}

.quotation-status-baselined {
  background: #EDE9FE;
  color: #5B21B6;
}

.quotation-status-rejected {
  background: #FFEDD5;
  color: #C2410C;
}

.quotation-status-lost {
  background: #FEE2E2;
  color: #991B1B;
}

/* Summary cards grid */
.quotation-summary-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  padding: 20px 24px;
  background: #F8FAFC;
  border-bottom: 1px solid var(--border);
}

.quotation-summary-card {
  background: white;
  border-radius: 10px;
  padding: 16px 20px;
  border: 1px solid #E2E8F0;
}

.summary-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.summary-value {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
}

.summary-value.blue {
  color: var(--primary);
}

.summary-value.green {
  color: #059669;
}

.summary-value.red {
  color: #DC2626;
}

/* Items section */
.quotation-items-section {
  padding: 20px 24px;
}

.quotation-items-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.quotation-items-header h4 {
  margin: 0;
  font-size: 15px;
}

/* Items table */
.quotation-items-table {
  width: 100%;
  border-collapse: collapse;
  border: 1px solid #E2E8F0;
  border-radius: 8px;
  overflow: hidden;
}

.quotation-items-table thead th {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  padding: 10px 14px;
  background: #F8FAFC;
  border-bottom: 2px solid #E2E8F0;
}

.quotation-items-table tbody td {
  padding: 10px 14px;
  border-bottom: 1px solid #F1F5F9;
  font-size: 13px;
  vertical-align: middle;
}

.quotation-items-table tfoot td {
  padding: 12px 14px;
  background: #F8FAFC;
  border-top: 2px solid #E2E8F0;
}

.quotation-section-row td {
  background: #F1F5F9 !important;
  padding: 8px 14px !important;
  border-left: 4px solid var(--primary) !important;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--text-secondary, #475569);
}

/* Action bar */
.quotation-actions-bar {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  padding: 16px 24px;
  background: #F8FAFC;
  border-top: 1px solid var(--border);
}

/* Danger outline button */
.btn-danger-outline {
  border-color: #FCA5A5 !important;
  color: #DC2626 !important;
}

.btn-danger-outline:hover {
  background: #FEF2F2 !important;
  border-color: #EF4444 !important;
}

/* Lost banner */
.quotation-lost-banner {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 24px;
  background: #FEF2F2;
  border-bottom: 1px solid #FECACA;
}

.lost-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #DC2626;
  color: white;
  padding: 4px 12px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.5px;
  white-space: nowrap;
}

.lost-badge svg {
  width: 14px;
  height: 14px;
}

.lost-details {
  font-size: 13px;
  color: #7F1D1D;
}

/* Locked banner */
.quotation-locked-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 24px;
  background: #EDE9FE;
  border-bottom: 1px solid #DDD6FE;
  color: #5B21B6;
  font-size: 13px;
}

.quotation-locked-banner svg {
  width: 16px;
  height: 16px;
}

/* ═══════════════════════════════════════════════════════════════════════
/* ═══════════════════════════════════════════════════════════════════════
   QUOTATION VERSION HISTORY
   ═══════════════════════════════════════════════════════════════════════ */

.version-history-bar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 24px;
  background: #F8FAFC;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}

.version-history-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  white-space: nowrap;
}

.version-history-label svg {
  width: 14px;
  height: 14px;
}

.version-history-items {
  display: flex;
  gap: 8px;
}

.version-history-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid #E2E8F0;
  background: white;
  cursor: default;
  transition: all 0.15s ease;
}

.version-history-item.active {
  border-color: var(--primary);
  background: #EFF6FF;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.15);
}

.version-number {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
}

.version-meta {
  display: flex;
  align-items: center;
  gap: 8px;
}

.version-qtn {
  font-size: 12px;
  color: var(--text-muted);
}

/* ═══════════════════════════════════════════════════════════════════════
   QUOTATION MODALS (Lost Reason / Baseline Confirm)
   ═══════════════════════════════════════════════════════════════════════ */

/* Overlay */
.quotation-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.quotation-modal-overlay.active {
  opacity: 1;
}

/* Modal card */
.quotation-modal {
  background: white;
  border-radius: 16px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  width: 480px;
  max-width: 90vw;
  overflow: hidden;
  transform: translateY(20px) scale(0.97);
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.quotation-modal-overlay.active .quotation-modal {
  transform: translateY(0) scale(1);
}

/* Modal header */
.quotation-modal-header {
  padding: 24px 24px 16px;
  text-align: center;
}

.quotation-modal-header h3 {
  margin: 10px 0 4px;
  font-size: 18px;
  font-weight: 700;
}

.quotation-modal-header p {
  margin: 0;
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.4;
}

/* Modal header icon */
.quotation-modal-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto;
}

.quotation-modal-icon svg {
  width: 24px;
  height: 24px;
}

/* Lost header */
.quotation-modal-header.lost .quotation-modal-icon {
  background: #FEE2E2;
  color: #DC2626;
}

.quotation-modal-header.lost h3 {
  color: #991B1B;
}

/* Baseline header */
.quotation-modal-header.baseline .quotation-modal-icon {
  background: #EDE9FE;
  color: #7C3AED;
}

.quotation-modal-header.baseline h3 {
  color: #5B21B6;
}

/* Modal body */
.quotation-modal-body {
  padding: 0 24px 20px;
}

/* Form fields */
.modal-field {
  margin-bottom: 16px;
}

.modal-field:last-child {
  margin-bottom: 0;
}

.modal-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary, #475569);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.modal-label .required {
  color: #DC2626;
}

.modal-select {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid #E2E8F0;
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text-primary);
  background: white;
  appearance: none;
  background-image: url("data:image/svg+xml,%3csvg width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' xmlns='http://www.w3.org/2000/svg'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 12px center;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.modal-select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.modal-textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid #E2E8F0;
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text-primary);
  resize: vertical;
  min-height: 80px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.modal-textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

/* Baseline warning box */
.baseline-warning {
  background: #FFFBEB;
  border: 1px solid #FDE68A;
  border-radius: 10px;
  padding: 16px 18px;
  font-size: 13px;
  color: #92400E;
  line-height: 1.5;
}

.baseline-warning strong {
  display: block;
  margin-bottom: 8px;
  font-size: 14px;
}

.baseline-warning ul {
  margin: 0;
  padding-left: 18px;
}

.baseline-warning li {
  margin-bottom: 4px;
}

.baseline-warning li:last-child {
  margin-bottom: 0;
}

/* Modal footer */
.quotation-modal-footer {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  padding: 16px 24px;
  background: #F8FAFC;
  border-top: 1px solid #E2E8F0;
}

/* Danger button */
.btn-danger {
  background: #DC2626 !important;
  color: white !important;
  border: none !important;
}

.btn-danger:hover {
  background: #B91C1C !important;
}

.btn-danger:disabled {
  background: #FCA5A5 !important;
  cursor: not-allowed;
}

.btn-danger svg {
  width: 14px;
  height: 14px;
}



/* ═══════════════════════════════════════════════════════════════════════════
   ACTUAL COSTS TAB
   ═══════════════════════════════════════════════════════════════════════════ */

/* KPI Cards Grid */
.actual-cost-kpis {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.ac-kpi-card {
  background: var(--card-bg);
  padding: 20px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  transition: box-shadow 0.2s;
}

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

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

.ac-kpi-value {
  font-size: 26px;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1.2;
}

.ac-kpi-value.green {
  color: #16A34A;
}

.ac-kpi-value.red {
  color: #DC2626;
}

.ac-kpi-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 6px;
}

.ac-kpi-breakdown {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 8px;
  font-size: 11px;
  color: var(--text-secondary);
  font-weight: 500;
}

/* Utilization Bar */
.utilization-bar-wrap {
  width: 100%;
  height: 8px;
  background: var(--border);
  border-radius: 4px;
  margin-top: 10px;
  overflow: hidden;
}

.utilization-bar {
  height: 100%;
  border-radius: 4px;
  transition: width 0.6s ease;
}

.utilization-bar.under {
  background: linear-gradient(90deg, #22C55E, #16A34A);
}

.utilization-bar.warn {
  background: linear-gradient(90deg, #F59E0B, #D97706);
}

.utilization-bar.over {
  background: linear-gradient(90deg, #EF4444, #DC2626);
}

/* Toolbar — tabs + add button */
.ac-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  gap: 12px;
  flex-wrap: wrap;
}

.ac-tabs {
  display: flex;
  gap: 4px;
  background: var(--bg-secondary);
  padding: 4px;
  border-radius: var(--radius-md);
}

.filter-tab {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border: none;
  background: none;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.filter-tab:hover {
  background: var(--card-bg);
  color: var(--text-primary);
}

.filter-tab.active {
  background: var(--card-bg);
  color: var(--primary);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.filter-tab svg {
  width: 14px;
  height: 14px;
}

.tab-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  background: var(--border);
  font-size: 11px;
  font-weight: 700;
  color: var(--text-secondary);
}

.filter-tab.active .tab-count {
  background: var(--primary);
  color: white;
}

/* Add Entry Dropdown */
.ac-add-dropdown {
  position: relative;
}

.ac-dropdown-menu {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 100;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  min-width: 200px;
  overflow: hidden;
}

.ac-dropdown-menu.show {
  display: block;
}

.ac-dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 12px 16px;
  border: none;
  background: none;
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
  text-align: left;
}

.ac-dropdown-item:hover {
  background: var(--bg-secondary);
}

.ac-dropdown-item svg {
  width: 16px;
  height: 16px;
  color: var(--text-muted);
}

/* Modal Form Grids */
.modal-form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 14px;
  margin-bottom: 14px;
}

.modal-form-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 4px;
}

.modal-form-field label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.modal-form-field input,
.modal-form-field select,
.modal-form-field textarea {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.modal-form-field select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236B7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 30px;
  cursor: pointer;
}

.modal-form-field input:focus,
.modal-form-field select:focus,
.modal-form-field textarea:focus {
  border-color: var(--primary);
  outline: none;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

/* Delete icon button */
.btn-icon-sm {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: none;
  background: none;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s;
}

.btn-icon-sm:hover {
  background: #FEE2E2;
  color: #DC2626;
}

.btn-icon-sm svg {
  width: 14px;
  height: 14px;
}

/* Responsive KPIs */
@media (max-width: 900px) {
  .actual-cost-kpis {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 600px) {
  .modal-form-grid {
    grid-template-columns: 1fr !important;
  }

  .modal-form-field {
    grid-column: span 1 !important;
  }
}

@media (max-width: 500px) {
  .actual-cost-kpis {
    grid-template-columns: 1fr;
  }

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

/* Native details/summary dropdown */
details.ac-add-dropdown>summary {
  list-style: none;
}

details.ac-add-dropdown>summary::-webkit-details-marker {
  display: none;
}

details.ac-add-dropdown>summary::marker {
  display: none;
  content: '';
}

details.ac-add-dropdown .ac-dropdown-item:hover {
  background: #f3f4f6;
}

/* Actual cost accordion summaries — make them look clickable */
.ac-form-accordion>summary {
  padding: 14px 20px !important;
  cursor: pointer !important;
  font-weight: 600 !important;
  font-size: 13px !important;
  color: var(--primary, #2563eb) !important;
  list-style: none !important;
  display: flex !important;
  align-items: center !important;
  gap: 8px !important;
  user-select: none !important;
  background: rgba(59, 130, 246, 0.1) !important;
  border: 1px dashed var(--primary, #2563eb) !important;
  border-radius: 8px !important;
  transition: all 0.15s !important;
  margin: -1px;
}

.ac-form-accordion>summary:hover {
  background: rgba(59, 130, 246, 0.15) !important;
}

.ac-form-accordion[open]>summary {
  border-bottom-left-radius: 0 !important;
  border-bottom-right-radius: 0 !important;
}

.ac-form-accordion>summary::-webkit-details-marker {
  display: none;
}

.ac-form-accordion>summary::marker {
  display: none;
  content: '';
}

.ac-form-accordion>summary .ac-expand-hint {
  margin-left: auto;
  font-weight: 500;
  font-size: 11px;
  color: var(--primary, #2563eb);
  background: rgba(59, 130, 246, 0.15);
  padding: 2px 10px;
  border-radius: 12px;
}

.ac-form-accordion[open]>summary .ac-expand-hint {
  display: none;
}

/* =============================================
   ALLOCATION TAB FEATURE STYLES
   ============================================= */

.alloc-wrapper {
  display: flex;
  flex-direction: column;
  gap: 24px;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(4px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.alloc-section {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 24px;
}

.alloc-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}

.alloc-section-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.alloc-section-title svg {
  color: var(--primary);
}

.alloc-section-sub {
  font-size: 12.5px;
  color: var(--text-secondary);
  margin: 4px 0 0 0;
}

/* Empty State styling */
.alloc-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 48px 24px;
  background: #F9FAFB;
  border: 1px dashed var(--border);
  border-radius: var(--radius-md);
  color: var(--text-muted);
}

.alloc-empty-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--border-light);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
}

.alloc-empty-icon svg {
  width: 24px;
  height: 24px;
}

.alloc-empty-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.alloc-empty-sub {
  font-size: 13px;
  color: var(--text-secondary);
}

/* Allocation Tables */
.alloc-table-wrap {
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.alloc-table {
  width: 100%;
  border-collapse: collapse;
}

.alloc-table th {
  background: #F9FAFB;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.alloc-table td {
  padding: 14px 16px;
  font-size: 13.5px;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
}

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

.alloc-table tbody tr:hover {
  background: #FAFBFC;
}

/* User cell with Avatar */
.alloc-user-cell {
  display: flex;
  align-items: center;
  gap: 12px;
}

.alloc-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
}

.alloc-user-name {
  font-weight: 600;
  color: var(--text-primary);
}

.alloc-user-role {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 1px;
}

.alloc-email {
  color: var(--text-secondary);
}

.alloc-date {
  color: var(--text-secondary);
}

/* Badges and Counts */
.alloc-count-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  background: var(--primary-light);
  color: var(--primary);
}

.alloc-headcount {
  font-weight: 600;
  font-size: 13.5px;
  color: var(--text-primary);
  min-width: 24px;
  text-align: center;
}

/* Status Pill in Allocation Panel */
.alloc-status-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 13.5px;
  margin-top: 8px;
}

.alloc-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

/* Danger Button specifically styled for Allocation */
.btn-alloc-danger {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  color: var(--red);
  background: transparent;
  border: 1px solid rgba(239, 68, 68, 0.2);
  cursor: pointer;
  transition: all 0.15s;
}

.btn-alloc-danger:hover {
  background: var(--red-bg);
  border-color: var(--red);
  color: var(--red-text);
}

/* Counter adjustment buttons (+ / -) */
.alloc-count-btn {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--card-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  color: var(--text-secondary);
  transition: all 0.15s;
}

.alloc-count-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-light);
}

.alloc-count-btn:active {
  transform: scale(0.95);
}

/* =============================================
   PRINT OPTIMIZATIONS
   ============================================= */
.print-only {
  display: none !important;
}

@media print {
  body {
    background: #fff !important;
    color: #000 !important;
    font-size: 12pt !important;
  }

  /* Hide sidebar and all interactive elements */
  .sidebar,
  .top-nav,
  .print-hide,
  .app-header,
  .btn,
  button,
  select,
  input,
  .breadcrumb,
  .breadcrumb-back,
  .page-header-actions,
  .project-detail-header,
  .project-kpi-row,
  .project-tabs-bar,
  .reports-sidebar-tabs {
    display: none !important;
  }

  html,
  body,
  .app-layout,
  .main-content {
    height: auto !important;
    min-height: auto !important;
    overflow: visible !important;
    position: static !important;
  }

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

  .print-only {
    display: block !important;
  }

  .table-wrap {
    border: none !important;
    box-shadow: none !important;
    background: transparent !important;
    padding: 0 !important;
    margin: 0 !important;
    width: 100% !important;
  }

  table {
    border-collapse: collapse !important;
    width: 100% !important;
  }

  th,
  td {
    border: 1px solid #cbd5e1 !important;
    padding: 6pt 8pt !important;
    font-size: 10pt !important;
    color: #000 !important;
    background: transparent !important;
    text-align: left !important;
  }

  th {
    font-weight: bold !important;
    background-color: #f1f5f9 !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  .badge {
    border: 1px solid #94a3b8 !important;
    background: transparent !important;
    color: #000 !important;
    padding: 2pt 4pt !important;
    font-size: 8pt !important;
    border-radius: 4px !important;
  }

  .text-green {
    color: #16a34a !important;
    font-weight: bold !important;
  }

  .text-red {
    color: #dc2626 !important;
    font-weight: bold !important;
  }

  .font-mono {
    font-family: monospace !important;
  }

  .reports-sidebar-tabs {
    display: none !important;
  }
}

/* Reports layout styles */
.reports-layout {
  display: flex;
  gap: 24px;
  align-items: flex-start;
  width: 100%;
}

.reports-sidebar-tabs {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 240px;
  flex-shrink: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
}

.reports-tab-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border: none;
  background: transparent;
  border-radius: 8px;
  text-align: left;
  cursor: pointer;
  font-weight: 500;
  color: var(--text-secondary);
  transition: all 0.2s ease;
  width: 100%;
}

.reports-tab-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.reports-tab-btn.active {
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 600;
}

.reports-tab-btn .tab-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
}

.reports-content-pane {
  flex: 1;
  min-width: 0;
}

/* Premium A4 Document Report Preview */
.report-sheet-doc {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg, 12px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.04);
  padding: 40px;
  margin: 0 auto 30px auto;
  max-width: 1000px;
  color: #1e293b;
  font-family: 'Inter', sans-serif;
  position: relative;
  overflow: hidden;
}

.report-sheet-doc.report-sheet-landscape {
  max-width: 1120px;
}

.report-doc-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 24px;
}

.report-doc-brand {
  display: flex;
  flex-direction: column;
}

.report-doc-brand .brand-logo {
  font-size: 22px;
  font-weight: 800;
  color: var(--primary, #3b5bdb);
  letter-spacing: -0.5px;
}

.report-doc-brand .brand-sub {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-secondary, #64748b);
  letter-spacing: 1px;
  margin-top: 2px;
}

.report-doc-meta {
  text-align: right;
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.6;
}

.report-doc-divider {
  height: 2px;
  background: var(--border);
  margin-bottom: 24px;
  border-bottom: 1px solid var(--border-light);
}

.report-doc-title {
  font-size: 24px;
  font-weight: 800;
  color: #0f172a;
  margin: 0 0 8px 0;
  letter-spacing: -0.5px;
  text-transform: uppercase;
}

.report-doc-subtitle {
  font-size: 13.5px;
  color: var(--text-secondary);
  margin-bottom: 30px;
  line-height: 1.5;
}

/* Cross-Project Dashboard Stats styling */
.report-dashboard-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.report-kpi-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s, box-shadow 0.2s;
}

.report-kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

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

.report-kpi-card-value {
  font-size: 22px;
  font-weight: 800;
  color: var(--text-primary);
}

.report-kpi-card-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 6px;
}

/* Report Table Styling inside the document */
.report-sheet-doc table {
  width: 100% !important;
  border-collapse: collapse !important;
  margin-top: 10px;
}

.report-sheet-doc th {
  background: #f8fafc !important;
  border-bottom: 2px solid #cbd5e1 !important;
  color: #334155 !important;
  font-size: 11.5px !important;
  font-weight: 700 !important;
  text-transform: uppercase !important;
  letter-spacing: 0.5px !important;
  padding: 8px 10px !important;
  text-align: left !important;
}

.report-sheet-doc td {
  padding: 8px 10px !important;
  border-bottom: 1px solid #f1f5f9 !important;
  color: #334155 !important;
  font-size: 13px !important;
  vertical-align: middle !important;
}

.report-sheet-doc tr:last-child td {
  border-bottom: none !important;
}

.report-sheet-doc tr.report-totals-row td {
  background: #f8fafc !important;
  font-weight: 700 !important;
  border-top: 2px solid #cbd5e1 !important;
  border-bottom: 2px solid #cbd5e1 !important;
  color: #0f172a !important;
}

/* Print optimizations for clean A4 print sheets */
@media print {
  body {
    background: #ffffff !important;
  }

  .sidebar,
  .top-nav,
  .print-hide,
  .app-header,
  .breadcrumb,
  .breadcrumb-back,
  .page-header,
  .project-tabs-bar,
  .project-kpi-row,
  .project-detail-header,
  .project-kpis-summary,
  .reports-sidebar-tabs,
  .reports-content-pane .page-header,
  .table-wrap.print-hide {
    display: none !important;
  }

  html,
  body,
  .app-layout,
  .main-content {
    height: auto !important;
    min-height: auto !important;
    overflow: visible !important;
    position: static !important;
  }

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

  @page {
    size: A4 portrait;
    margin: 10mm;
  }

  .report-sheet-doc {
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    margin: 0 !important;
    max-width: none !important;
    width: 100% !important;
    overflow: visible !important;
  }

  .report-sheet-doc table {
    page-break-inside: auto !important;
  }

  .report-sheet-doc tr {
    page-break-inside: avoid !important;
    page-break-after: auto !important;
  }

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

  /* Force table colors in prints */
  .report-sheet-doc th {
    background-color: #f8fafc !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  .report-sheet-doc tr.report-totals-row td {
    background-color: #f8fafc !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  /* Tighten spacing for all documents in print mode to prevent page overflows */
  .custom-corporate-letterhead {
    margin-bottom: 12px !important;
    padding-bottom: 8px !important;
  }

  .custom-corporate-letterhead img {
    height: 70px !important;
    /* Scale logo down to 70px in print to reclaim vertical space */
  }

  .custom-corporate-letterhead div div span {
    font-size: 20px !important;
    /* Scale brand text size in print */
  }

  .report-doc-title {
    font-size: 18px !important;
    margin-top: 8px !important;
    margin-bottom: 4px !important;
  }

  .report-doc-subtitle {
    font-size: 10px !important;
    margin-bottom: 10px !important;
  }

  .report-sheet-doc table {
    margin-top: 8px !important;
  }

  .report-sheet-doc th {
    padding: 5px 6px !important;
    font-size: 10px !important;
  }

  .report-sheet-doc td {
    padding: 5px 6px !important;
    font-size: 11px !important;
  }
}

/* =============================================
   PORTFOLIO CHARTS & HIGH RISK WIDGET
   ============================================= */

.dashboard-charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(450px, 1fr));
  gap: 20px;
  margin-bottom: 24px;
}

.dashboard-chart-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 20px;
  display: flex;
  flex-direction: column;
}

.dashboard-chart-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.dashboard-chart-card-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.high-risk-widget {
  background: #FFFBEB;
  /* Premium soft amber alert background */
  border: 1px solid #FCD34D;
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
}

.high-risk-widget-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  color: #B45309;
  font-weight: 700;
  font-size: 15px;
}

.high-risk-widget-header svg {
  width: 20px;
  height: 20px;
  color: #D97706;
}

.high-risk-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}

.high-risk-card {
  background: white;
  border: 1px solid #FDE68A;
  border-radius: var(--radius);
  padding: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: all 0.2s ease;
}

.high-risk-card:hover {
  border-color: #F59E0B;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

.high-risk-card-left {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.high-risk-project-name {
  font-weight: 600;
  font-size: 13px;
  color: var(--text-primary);
}

.high-risk-reasons {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}

.risk-reason-tag {
  font-size: 10px;
  font-weight: 600;
  color: #DC2626;
  background: #FEF2F2;
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid #FEE2E2;
}

.high-risk-action-btn {
  background: #FEF3C7;
  border: 1px solid #FCD34D;
  color: #B45309;
  padding: 6px 10px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.high-risk-action-btn:hover {
  background: #FBBF24;
  color: white;
  border-color: #FBBF24;
}

/* Branch chips */
.branch-chip {
  display: inline-block;
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 10px;
  background: #EFF6FF;
  color: #2563EB;
  border: 1px solid #BFDBFE;
  white-space: nowrap;
}

/* Autocomplete Dropdown styling */
.autocomplete-wrapper {
  position: relative;
  display: inline-block;
}

.autocomplete-input {
  cursor: pointer;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  transition: all 0.2s ease;
}

.autocomplete-input:hover {
  border-color: #CBD5E1;
}

.autocomplete-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59, 91, 219, 0.12);
  background: var(--card-bg);
}

.autocomplete-suggestions {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  max-height: 200px;
  overflow-y: auto;
  z-index: 1000;
  display: none;
  box-shadow: var(--shadow-lg);
  margin-top: 4px;
}

.autocomplete-suggestion-item {
  padding: 8px 12px;
  cursor: pointer;
  font-size: 12.5px;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border-light);
  transition: background 0.15s, color 0.15s;
  text-align: left;
}

.autocomplete-suggestion-item:last-child {
  border-bottom: none;
}

.autocomplete-suggestion-item:hover {
  background: var(--primary-light);
  color: var(--primary);
}

/* Hide native datalist dropdown arrow indicator */
input[list]::-webkit-calendar-picker-indicator {
  display: none !important;
}

/* =============================================
   MOBILE RESPONSIVENESS AND GRID STACKING
   ============================================= */

/* Toggle Button & Overlay base styles */
.sidebar-toggle-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  cursor: pointer;
  color: #334155;
  padding: 6px;
  margin-right: 8px;
  border-radius: var(--radius-sm);
  transition: background 0.15s, color 0.15s;
}

.sidebar-toggle-btn:hover {
  background: var(--border-light);
  color: var(--primary);
}

@media (min-width: 992px) {

  /* Hide 3-lined menu icon on desktop when sidebar is expanded (not collapsed) */
  .sidebar:not(.is-collapsed)~.main-area .sidebar-toggle-btn {
    display: none !important;
  }

  /* Show 3-lined menu icon on desktop when sidebar is collapsed */
  .sidebar.is-collapsed~.main-area .sidebar-toggle-btn {
    display: inline-flex !important;
  }
}

.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(15, 23, 42, 0.4);
  backdrop-filter: blur(2px);
  z-index: 9998;
  animation: fadeInOverlay 0.25s ease;
}

@keyframes fadeInOverlay {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@media (max-width: 991px) {

  /* Layout reset */
  .app-layout {
    position: relative;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
  }

  /* Login page responsiveness */
  .login-page {
    flex-direction: column;
    overflow-y: auto;
  }

  .login-left {
    display: none;
    /* Hide brand sidebar on mobile login */
  }

  .login-right {
    width: 100% !important;
    padding: 24px !important;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .login-card {
    padding: 28px 24px !important;
    border-radius: 20px !important;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.04) !important;
    border: 1px solid var(--border);
  }

  .login-mobile-logo {
    display: flex !important;
  }

  /* Hamburger toggle button */
  .sidebar-toggle-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-primary);
    padding: 8px;
    margin-right: 8px;
    border-radius: var(--radius-sm);
    transition: background 0.15s;
  }

  .sidebar-toggle-btn:hover {
    background: var(--border-light);
  }

  /* Slide-in sidebar overlay container */
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100dvh;
    z-index: 9999;
    width: 240px;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 0 24px rgba(15, 23, 42, 0.15);
  }

  .sidebar.show-sidebar {
    transform: translateX(0);
  }

  .sidebar-overlay.show-overlay {
    display: block;
  }

  /* Main area margins & padding defaults */
  .top-bar {
    padding: 0 16px;
  }

  .top-bar-title {
    font-size: 9.5px;
    letter-spacing: 0.5px;
  }

  .fy-badge {
    display: none;
    /* Hide non-critical badges to save horizontal space */
  }

  .page-content {
    padding: 16px;
  }

  /* Page Header Stackings */
  .page-header {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 12px !important;
  }

  .page-header-actions {
    width: 100% !important;
    display: flex !important;
    gap: 8px !important;
  }

  .page-header-actions .btn,
  .page-header-actions button {
    flex: 1 !important;
    width: 100% !important;
    justify-content: center !important;
  }

  /* Search & Filter Bar Stacking */
  .search-filter-bar {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 12px !important;
    padding: 12px !important;
  }

  .search-input-wrap,
  .search-input {
    width: 100% !important;
  }

  .filter-tabs {
    overflow-x: auto !important;
    white-space: nowrap !important;
    -webkit-overflow-scrolling: touch !important;
    width: 100% !important;
    scrollbar-width: none !important;
    padding-bottom: 4px !important;
  }

  .filter-tabs::-webkit-scrollbar {
    display: none !important;
  }

  .filter-tab {
    flex-shrink: 0 !important;
  }

  /* Grid Stackings */
  .grid-2,
  .grid-3,
  .grid-2-1,
  .grid-1-2,
  .overview-grid,
  .double-column,
  .actual-cost-kpis,
  .cd-content-grid,
  .customer-detail-layout {
    grid-template-columns: 1fr !important;
    gap: 16px !important;
  }

  /* Project detail title & actions spacing */
  .project-detail-title-row {
    flex-direction: row;
    align-items: center;
    gap: 8px;
  }

  .project-detail-title {
    flex-direction: row !important;
    align-items: center !important;
    flex-wrap: wrap;
    gap: 8px;
  }

  .project-detail-title h1 {
    font-size: 17px !important;
    flex: 1;
    min-width: 0;
  }

  .project-status-badge {
    font-size: 11px !important;
    padding: 3px 10px !important;
  }

  .btn-icon-edit {
    width: 32px !important;
    height: 32px !important;
  }

  /* Mobile meta: stack customer & dates, hide project code */
  .project-meta {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 4px !important;
  }

  .project-meta-code {
    display: none !important;
  }

  /* Horizontal Scrolling for Workspaces Tabs */
  .project-tabs-bar {
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
    width: 100%;
    scrollbar-width: none;
    /* Firefox */
  }

  .project-tabs-bar::-webkit-scrollbar {
    display: none;
    /* Chrome/Safari */
  }

  .project-tabs-bar .tab-btn {
    flex-shrink: 0;
    display: inline-flex;
    padding: 12px 16px;
  }

  /* Reports Tab Layout Stacking & Horizontal Scrolling */
  .reports-layout {
    flex-direction: column !important;
    align-items: stretch !important;
  }

  .reports-sidebar-tabs {
    width: 100% !important;
    flex-direction: row !important;
    overflow-x: auto !important;
    white-space: nowrap !important;
    -webkit-overflow-scrolling: touch !important;
    scrollbar-width: none !important;
    padding: 8px !important;
  }

  .reports-sidebar-tabs::-webkit-scrollbar {
    display: none !important;
  }

  .reports-tab-btn {
    flex-shrink: 0 !important;
    width: auto !important;
  }

  .report-sheet-doc {
    padding: 16px !important;
  }

  /* Responsive Tables Wrapper */
  .table-wrap,
  .alloc-table-wrap,
  table {
    display: block;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Target and override inline grid column layouts to stack on mobile */
  div[style*="grid-template-columns"] {
    grid-template-columns: 1fr !important;
  }

  /* Target and override inline search width sizes to scale to full width on mobile toolbar */
  .table-toolbar .search-input,
  input[style*="width: 280px"],
  input[style*="width:280px"] {
    width: 100% !important;
  }

  /* Stacking and wrapping for table search + select filters toolbar */
  .table-toolbar {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 12px !important;
    padding: 12px !important;
  }

  .table-toolbar .search-input-wrap {
    width: 100% !important;
  }

  .toolbar-filters {
    flex-wrap: wrap !important;
    width: 100% !important;
    gap: 8px !important;
  }

  .toolbar-filters .filter-select {
    flex: 1 1 calc(50% - 4px) !important;
    width: 100% !important;
  }

  /* Summary KPI Cards stacking overrides */
  .kpi-grid-2,
  .kpi-grid-3,
  .kpi-grid-4,
  .kpi-grid-6 {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }

  /* Centered stacking for customer profile header view */
  .customer-profile-header {
    flex-direction: column !important;
    align-items: center !important;
    text-align: center !important;
    gap: 12px !important;
  }

  /* Horizontal scrolling slider for Masters configuration tabs */
  .masters-tabs {
    display: flex !important;
    width: 100% !important;
    overflow-x: auto !important;
    white-space: nowrap !important;
    -webkit-overflow-scrolling: touch !important;
    scrollbar-width: none !important;
    padding: 6px !important;
    border-radius: var(--radius-md) !important;
  }

  .masters-tabs::-webkit-scrollbar {
    display: none !important;
  }

  .master-tab {
    flex-shrink: 0 !important;
    padding: 8px 14px !important;
  }

  /* Stacking for Masters sub-headers */
  .estimate-content-header {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 12px !important;
  }

  .estimate-content-header div {
    width: 100% !important;
    text-align: left !important;
  }

  .estimate-content-header button {
    width: auto !important;
    align-self: flex-start !important;
  }

  /* Responsive styling for Contact Information cards on mobile */
  .contact-card-v2 {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 10px !important;
  }

  .contact-card-v2-right {
    align-items: flex-start !important;
    padding-left: 46px !important;
    /* aligns perfectly under the contact name line */
  }

  /* Responsive Modal overlays wrapper */
  #assignSupervisorModal>div.card,
  #assignStaffModal>div.card,
  #addCustomerModal>div.card,
  #addProjectModal>div.card,
  #editProjectModal>div.card,
  #addBranchModal>div.card,
  #addEstimateModal>div.card,
  #addQuotationModal>div.card,
  #addChangeOrderModal>div.card,
  #addPaymentModal>div.card,
  #addMaterialCostModal>div.card,
  #addLabourCostModal>div.card,
  #addOpExpenseModal>div.card,
  #addPersonModal>div.card,
  #addUserModal>div.card {
    width: 90% !important;
    max-width: 420px !important;
    margin: 16px !important;
  }

  /* --- Mobile-Only Card System --- */
  .desktop-only-table {
    display: none !important;
  }

  .dashboard-charts-grid {
    grid-template-columns: 1fr !important;
    gap: 16px !important;
  }

  .mobile-only-cards {
    display: block !important;
  }

  .pt-mobile-card {
    background: var(--bg-card, #ffffff);
    border: 1px solid var(--border-light, #e2e8f0);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    display: flex;
    flex-direction: column;
    transition: box-shadow 0.2s ease, border-color 0.2s ease;
  }

  .pt-mobile-card:active {
    background-color: var(--bg-hover, #f8fafc);
  }

  .pt-card-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    user-select: none;
  }

  .pt-card-title-col {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
    padding-right: 12px;
  }

  .pt-card-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary, #0f172a);
    margin: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .pt-card-subtitle {
    font-size: 12px;
    color: var(--text-secondary, #64748b);
    margin-top: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .pt-card-toggle-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--border-light, #f1f5f9);
    color: var(--text-secondary, #64748b);
    transition: transform 0.2s ease, background-color 0.2s ease;
  }

  .pt-mobile-card.is-expanded .pt-card-toggle-icon {
    transform: rotate(180deg);
    background-color: var(--primary-light, #e0f2fe);
    color: var(--primary, #0284c7);
  }

  .pt-card-body-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 16px;
    margin-top: 8px;
    font-size: 13px;
  }

  .pt-summary-item {
    display: flex;
    flex-direction: column;
  }

  .pt-summary-label {
    font-size: 10px;
    text-transform: uppercase;
    color: var(--text-muted, #94a3b8);
    letter-spacing: 0.5px;
  }

  .pt-summary-value {
    font-weight: 500;
    color: var(--text-primary, #0f172a);
  }

  /* Collapsible Details Panel */
  .pt-card-details {
    display: none;
    border-top: 1px dashed var(--border-light, #e2e8f0);
    margin-top: 12px;
    padding-top: 12px;
    font-size: 13px;
  }

  .pt-mobile-card.is-expanded .pt-card-details {
    display: block !important;
  }

  .pt-details-grid {
    display: flex;
    flex-direction: column;
    gap: 8px;
  }

  .pt-detail-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
  }

  .pt-detail-label {
    color: var(--text-secondary, #64748b);
  }

  .pt-detail-value {
    font-weight: 500;
    color: var(--text-primary, #0f172a);
    text-align: right;
  }

  .pt-card-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 12px;
    border-top: 1px solid var(--border-light, #e2e8f0);
    padding-top: 12px;
  }

  /* ── Customer Detail Header Card — stack on mobile ── */
  .cd-header-card {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 12px !important;
    padding: 16px !important;
    position: relative !important;
  }

  .cd-header-left {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 10px !important;
  }

  .cd-header-actions {
    position: absolute !important;
    top: 16px;
    right: 16px;
  }

  .cd-header-meta {
    flex-wrap: wrap !important;
    gap: 6px !important;
  }

  .cd-header-actions .btn {
    width: 100% !important;
    justify-content: center !important;
  }

  /* ── Customer Detail Projects table — hide desktop table, use card layout ── */
  .cd-right-col .table-wrap {
    overflow-x: hidden !important;
  }

  .cd-right-col .table-wrap table {
    display: none !important;
  }

  .cd-right-col .mobile-project-cards {
    display: block !important;
  }

  /* ── Project Detail KPI pills — 2-col grid on mobile ── */
  .project-kpi-row {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 8px !important;
  }

  .project-kpi-pill {
    min-width: 0 !important;
    padding: 8px 10px !important;
  }

  .project-kpi-pill .pill-value {
    font-size: 14px !important;
  }

  .project-kpi-pill .pill-label {
    font-size: 9px !important;
  }

  /* ── Project Detail Header — prevent overflow ── */
  .project-detail-header {
    word-break: break-word !important;
  }

  .project-detail-header h1 {
    font-size: 18px !important;
    word-break: break-word !important;
  }

  .project-meta {
    flex-wrap: wrap !important;
    gap: 6px 12px !important;
  }

  /* ── Estimate Tab Layout — stack version history on top, estimate below ── */
  .estimate-layout {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }

  .cost-tree-panel {
    order: -1 !important;
  }

  .cost-tree-header {
    padding: 10px 14px !important;
  }

  .tree-content {
    display: flex !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    scrollbar-width: none !important;
    padding-bottom: 0 !important;
  }

  .tree-content::-webkit-scrollbar {
    display: none !important;
  }

  .tree-content>div {
    flex-shrink: 0 !important;
    border-bottom: none !important;
    border-right: 1px solid var(--border) !important;
    padding: 8px 14px !important;
    font-size: 12px !important;
    white-space: nowrap !important;
  }

  .tree-content>div:last-child {
    border-right: none !important;
  }

  /* ── Estimate Footer — stack on mobile ── */
  .estimate-footer {
    flex-direction: column !important;
    gap: 8px !important;
    padding: 12px 16px !important;
  }

  .estimate-footer-item {
    text-align: left !important;
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    padding: 6px 0 !important;
    border-right: none !important;
    border-bottom: 1px solid var(--border-light) !important;
  }

  .estimate-footer-item:last-child {
    border-bottom: none !important;
  }

  .estimate-footer-item .footer-label {
    margin-bottom: 0 !important;
  }

  /* ── Estimate Content Header — stacking for add section button ── */
  .estimate-content-header h3 {
    font-size: 14px !important;
  }

  /* ── BOQ Section Mobile Subtotal — stack on narrow screens ── */
  .boq-mobile-subtotal {
    flex-direction: column !important;
    gap: 4px !important;
  }

  /* ── Financials Grid — 2 columns on mobile ── */
  .financials-grid {
    grid-template-columns: 1fr 1fr !important;
    gap: 10px !important;
    margin-bottom: 16px !important;
  }

  .fin-card {
    padding: 12px 14px !important;
    min-width: 0 !important;
    overflow: hidden !important;
  }

  .fin-card .fin-value {
    font-size: 16px !important;
    word-break: break-word !important;
  }

  .fin-card .fin-label {
    font-size: 9.5px !important;
  }

  .fin-card .fin-sub {
    font-size: 10px !important;
    word-break: break-word !important;
  }

  /* ── Quotation Header Bar mobile layout ── */
  .quotation-header-bar {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 12px !important;
    padding: 16px !important;
  }

  .qh-title-group {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    width: 100% !important;
  }

  .mobile-status-badge {
    display: block !important;
  }

  .desktop-status-badge {
    display: none !important;
  }

  .qh-actions-group {
    width: 100% !important;
    display: flex !important;
    gap: 10px !important;
  }

  .qh-actions-group .btn {
    flex: 1 !important;
    justify-content: center !important;
    font-size: 11.5px !important;
    padding: 6px 8px !important;
  }

  /* ── Actual Costs Tabs horizontal scroll ── */
  .ac-toolbar {
    flex-direction: column !important;
    align-items: stretch !important;
    width: 100% !important;
    overflow: visible !important;
  }

  .ac-tabs {
    flex-wrap: wrap !important;
    white-space: normal !important;
    width: 100% !important;
    overflow: visible !important;
    display: flex !important;
    gap: 8px !important;
  }

  .ac-tabs .filter-tab {
    flex-shrink: 0 !important;
    display: inline-flex !important;
  }
}

.mobile-only-cards {
  display: none;
}

/* ── Quotation Header status badge helpers (Desktop default) ── */
.mobile-status-badge {
  display: none !important;
}

.desktop-status-badge {
  display: block !important;
}

.qh-title-group {
  display: block;
}

.qh-actions-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* ── Application Custom Select Dropdown ── */
.custom-select-wrapper {
  position: relative;
  width: 100%;
}

.custom-select-trigger {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: white;
  text-align: left;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  font-size: 14px;
  color: var(--text-primary);
  font-family: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.custom-select-trigger:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
  outline: none;
}

.custom-select-options {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  width: 100%;
  background: white;
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  z-index: 1000;
  overflow: hidden;
}

.custom-select-option {
  padding: 10px 12px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text-primary);
  transition: background 0.15s, color 0.15s;
}

.custom-select-option:hover {
  background: var(--bg-secondary, #F8FAFC);
}

.custom-select-option.selected {
  background: var(--primary-light, #EFF6FF) !important;
  color: var(--primary, #3B82F6) !important;
  font-weight: 500;
}

/* Autocomplete Dropdown Styles */
.autocomplete-wrapper {
  position: relative;
  width: 100%;
}

.autocomplete-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  width: 100%;
  max-height: 200px;
  overflow-y: auto;
  background: white;
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  z-index: 1010;
}

.autocomplete-option {
  padding: 8px 12px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
  transition: background 0.15s;
}

.autocomplete-option:hover {
  background: var(--bg-secondary, #F8FAFC);
}

.autocomplete-option.selected {
  background: var(--primary-light, #EFF6FF);
  color: var(--primary, #3B82F6);
  font-weight: 500;
}

.autocomplete-option input[type="checkbox"] {
  cursor: pointer;
  margin: 0;
  width: 14px;
  height: 14px;
}

/* Collapsible blocks and responsive tab dropdowns */
.branch-form-block.collapsed .form-grid,
.contact-form-block.collapsed .form-grid {
  display: none !important;
}

.toggle-arrow {
  display: inline-block;
  margin-right: 8px;
  font-size: 10px;
  color: var(--text-muted);
  transition: transform 0.2s ease;
}

.collapsed .toggle-arrow {
  transform: rotate(-90deg);
}

.tabs-more-dropdown {
  position: absolute;
  z-index: 10000;
  background: var(--card-bg, #ffffff);
  border: 1px solid var(--border);
  border-radius: var(--radius-md, 6px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  min-width: 160px;
  padding: 4px 0;
  max-height: 250px;
  overflow-y: auto;
}

.tabs-more-dropdown-item {
  padding: 8px 16px;
  font-size: 13.5px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

/* Custom Actual Costs Floating Filter Popover styles */
.ac-filter-popover {
  border-radius: 8px;
  border: 1px solid var(--border);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.12);
  background: #ffffff;
  color: var(--text-primary);
  font-weight: normal;
  text-transform: none;
}

.ac-filter-popover input,
.ac-filter-popover select {
  margin-top: 4px;
  margin-bottom: 8px;
}

.ac-filter-popover button {
  font-size: 11px;
  padding: 4px 10px;
}

/* Sticky total actual cost bar */
.sticky-total-bar {
  background: var(--bg-card, #ffffff);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 20px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
  transition: all 0.2s ease;
}

/* View Mode tabs styling */
.view-mode-tabs .filter-tab {
  background: var(--bg-card, #ffffff);
  color: var(--text-secondary);
  border: none;
  font-weight: 500;
  transition: all 0.15s;
}

.view-mode-tabs .filter-tab.active {
  background: var(--primary, #3B82F6);
  color: #ffffff;
}

/* =============================================
   APPLICATION DROPDOWNS
   ============================================= */

.app-custom-select {
  position: relative;
  width: 100%;
}

.app-select-trigger {
  padding: 8px 12px;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  transition: all 0.2s;
  height: 100%;
  min-height: 36px;
}

.app-select-trigger:hover {
  border-color: #cbd5e1;
}

.app-select-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  width: 100%;
  min-width: 130px;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  z-index: 99999;
  max-height: 260px;
  display: none;
  flex-direction: column;
  overflow: hidden;
}

.app-select-search-container {
  padding: 6px;
  background: #ffffff;
  border-bottom: 1px solid var(--border-light, #e2e8f0);
  flex-shrink: 0;
}

.app-select-search-input {
  width: 100%;
  padding: 5px 8px;
  font-size: 12px;
  border: 1px solid var(--border, #cbd5e1);
  border-radius: 4px;
  outline: none;
  box-sizing: border-box;
  background: #f8fafc;
  color: var(--text-primary, #0f172a);
}

.app-select-search-input:focus {
  border-color: var(--primary, #3b82f6);
  background: #ffffff;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.15);
}

.app-select-options-wrapper {
  overflow-y: auto;
  max-height: 200px;
  flex: 1;
}

.app-select-no-results {
  padding: 10px 12px;
  font-size: 12px;
  color: var(--text-muted, #64748b);
  text-align: center;
  font-style: italic;
}

.app-select-trigger:focus {
  outline: 2px solid var(--primary, #3b82f6);
  outline-offset: 1px;
  border-color: var(--primary, #3b82f6);
}

.app-select-option {
  padding: 8px 12px;
  font-size: 13px;
  color: var(--text-primary);
  cursor: pointer;
  transition: background 0.15s;
}

.app-select-option:hover,
.app-select-option.focused {
  background: var(--primary-light, #eef2ff);
  color: var(--primary, #3b82f6);
}

.app-select-option.selected {
  background: #eef2ff;
  color: var(--primary);
  font-weight: 500;
}

.autocomplete-option.active,
.autocomplete-suggestion-item.active {
  background: var(--primary-light, #eef2ff) !important;
  color: var(--primary, #3b82f6) !important;
}

/* Custom Autocomplete Dropdown */
.custom-autocomplete-dropdown {
  background: var(--bg-card, #ffffff);
  border: 1px solid var(--border, #e2e8f0);
  border-radius: var(--radius-md, 8px);
  box-shadow: var(--shadow-lg, 0 10px 15px -3px rgba(0, 0, 0, 0.1));
}

.autocomplete-item {
  color: var(--text-main, #0f172a);
}

.dark-theme .custom-autocomplete-dropdown {
  background: #1e293b;
  border-color: #334155;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
}

.dark-theme .autocomplete-item {
  color: #f8fafc;
}

/* Project Actions Dropdown (3-dot menu) */
.project-actions-dropdown {
  position: relative;
  display: inline-block;
  margin-left: 8px;
}

.project-actions-dropdown summary {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md, 8px);
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-secondary);
  cursor: pointer;
  list-style: none;
  transition: all 0.15s ease;
  user-select: none;
}

.project-actions-dropdown summary::-webkit-details-marker {
  display: none;
}

.project-actions-dropdown summary::marker {
  display: none;
  content: '';
}

.project-actions-dropdown summary:hover {
  background: var(--primary-light, #EFF6FF);
  border-color: var(--primary);
  color: var(--primary);
}

.project-actions-dropdown .dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 1000;
  background: var(--bg-card, white);
  border: 1px solid var(--border);
  border-radius: var(--radius-md, 8px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  min-width: 170px;
  padding: 4px 0;
}

.project-actions-dropdown .dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 16px;
  border: none;
  background: none;
  color: var(--text-primary);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
  text-align: left;
}

.project-actions-dropdown .dropdown-item:hover {
  background: var(--primary-light, #EFF6FF);
  color: var(--primary);
}

.project-actions-dropdown .dropdown-item.text-danger {
  color: var(--red, #EF4444);
}

.project-actions-dropdown .dropdown-item.text-danger:hover {
  background: #FEF2F2;
  color: var(--red, #EF4444);
}

/* =============================================
   KEYBOARD ACCESSIBILITY & FOCUS STYLES
   ============================================= */

/* Universal Focus-Visible System for Keyboard Users */
:focus-visible {
  outline: 2px solid var(--primary, #3B5BDB) !important;
  outline-offset: 2px !important;
  box-shadow: 0 0 0 3px rgba(59, 91, 219, 0.25) !important;
}

/* Interactive Navigation & Tabs Keyboard Focus */
.nav-item:focus-visible,
.tab-btn:focus-visible,
.pt-tab-btn:focus-visible,
.master-tab:focus-visible,
.reports-tab-btn:focus-visible,
.version-history-item:focus-visible,
.estimate-version-tab:focus-visible,
.filter-chip:focus-visible,
.filter-pill:focus-visible,
.status-filter-btn:focus-visible,
.time-filter-btn:focus-visible,
.date-preset-btn:focus-visible,
.sidebar-settings:focus-visible,
.sidebar-user:focus-visible,
.sidebar-logout:focus-visible,
.sidebar-toggle-btn:focus-visible,
.health-doc-btn:focus-visible,
.pt-card-header-row:focus-visible,
.pt-card-body-summary:focus-visible,
.clickable-row:focus-visible,
.app-select-trigger:focus-visible,
.custom-select-trigger:focus-visible,
.btn:focus-visible,
.modal-close:focus-visible,
.close-modal:focus-visible,
.close-btn:focus-visible,
.boq-delete-btn:focus-visible,
.boq-add-subheader-btn:focus-visible,
.boq-add-item-btn:focus-visible,
.delete-remark-btn:focus-visible,
[data-quotation-action]:focus-visible,
[data-delete-item]:focus-visible,
[data-add-item-header]:focus-visible,
[data-parent-header-id]:focus-visible {
  outline: 2px solid var(--primary, #3B5BDB) !important;
  outline-offset: 2px !important;
  box-shadow: 0 0 0 3px rgba(59, 91, 219, 0.3) !important;
}

/* Inputs, Textareas, Selects Keyboard Focus */
.form-control:focus-visible,
.form-control-modal:focus-visible,
.boq-inline-input:focus-visible,
.search-input:focus-visible,
.modal-select:focus-visible,
.modal-textarea:focus-visible,
.filter-select:focus-visible {
  outline: 2px solid var(--primary, #3B5BDB) !important;
  outline-offset: 1px !important;
  box-shadow: 0 0 0 3px rgba(59, 91, 219, 0.2) !important;
}

/* Grid & Table Row Active Keyboard Focus */
.boq-item-row:focus-within {
  background-color: rgba(59, 91, 219, 0.04) !important;
}

.table tbody tr:focus-within,
.data-table tbody tr:focus-within {
  background-color: rgba(59, 91, 219, 0.03);
}

/* Skip to Content Link for Screen Readers & Keyboard Navigation */
.skip-to-content {
  position: absolute;
  top: -40px;
  left: 10px;
  background: var(--primary, #3B5BDB);
  color: white;
  padding: 8px 16px;
  z-index: 10000;
  border-radius: 4px;
  font-weight: 600;
  text-decoration: none;
  transition: top 0.2s ease;
}

.skip-to-content:focus {
  top: 10px;
}

/* Inserted Custom Table Styling */
.inserted-custom-table-wrapper {
  background: var(--card-bg, #ffffff);
  border: 1px solid var(--border-light, #cbd5e1);
  border-radius: var(--radius-lg, 8px);
  overflow-x: auto;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  margin-top: 12px;
}

.inserted-custom-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  margin: 0;
}

.inserted-custom-table th {
  background: var(--bg-light, #f8fafc);
  padding: 10px 12px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary, #475569);
  border-bottom: 2px solid var(--border-light, #cbd5e1);
  border-right: 1px solid var(--border-light, #e2e8f0);
  text-align: left;
}

.inserted-custom-table th:last-child {
  border-right: none;
  text-align: center;
}

.inserted-custom-table td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--border-light, #e2e8f0);
  border-right: 1px solid var(--border-light, #e2e8f0);
  vertical-align: middle;
  background: var(--card-bg, #ffffff);
}

.inserted-custom-table td:last-child {
  border-right: none;
}

.inserted-custom-table tr:hover td {
  background: var(--bg-light, #f8fafc);
}

.inserted-table-cell {
  width: 100%;
  padding: 7px 10px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary, #0f172a);
  background: var(--card-bg, #ffffff);
  border: 1px solid var(--border-light, #cbd5e1);
  border-radius: 5px;
  outline: none;
  transition: all 0.15s ease-in-out;
  box-sizing: border-box;
}

.inserted-table-cell:focus {
  border-color: var(--primary, #2563eb) !important;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15) !important;
  background: #ffffff !important;
}

.inserted-table-cell::placeholder {
  color: var(--text-muted, #94a3b8);
  font-size: 12px;
  font-weight: 400;
}

/* Unified Delete Icon Button Style (Estimate, Quotation & Settings) */
.boq-delete-btn {
  background: transparent !important;
  border: none !important;
  color: var(--text-muted, #94a3b8) !important;
  width: 28px !important;
  height: 28px !important;
  border-radius: 6px !important;
  cursor: pointer !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  transition: all 0.2s ease-in-out !important;
  padding: 0 !important;
}

.boq-delete-btn:hover {
  background: #FEE2E2 !important;
  color: #DC2626 !important;
  box-shadow: 0 0 10px rgba(220, 38, 38, 0.45) !important;
  transform: scale(1.08) !important;
}

.boq-delete-btn svg {
  width: 15px !important;
  height: 15px !important;
  stroke-width: 2px !important;
}

/* Estimate Grid Excel Import/Export & Preview Modal */
.estimate-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.excel-preview-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.excel-preview-stat-card {
  background: #F8FAFC;
  border: 1px solid var(--border-light, #E2E8F0);
  border-radius: 8px;
  padding: 10px 14px;
  text-align: center;
}

.excel-preview-stat-card .stat-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-muted, #64748B);
  margin-bottom: 4px;
}

.excel-preview-stat-card .stat-val {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary, #0F172A);
}

.excel-preview-mode-selector {
  background: #F1F5F9;
  border: 1px solid #CBD5E1;
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.excel-preview-mode-selector label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}

.excel-preview-table-wrapper {
  flex: 1;
  min-height: 250px;
  max-height: 60vh;
  overflow: auto;
  border: 1px solid var(--border-light, #E2E8F0);
  border-radius: 8px;
  margin-bottom: 16px;
}

.excel-preview-table {
  width: 100%;
  min-width: 950px;
  border-collapse: collapse;
  font-size: 12px;
  table-layout: auto;
}

.excel-preview-table th {
  position: sticky;
  top: 0;
  background: #F8FAFC;
  padding: 10px 12px;
  text-align: left;
  font-weight: 600;
  color: var(--text-muted, #475569);
  border-bottom: 1px solid #E2E8F0;
  z-index: 2;
  white-space: nowrap;
}

.excel-preview-table td {
  padding: 8px 12px;
  border-bottom: 1px solid #F1F5F9;
  vertical-align: top;
  line-height: 1.45;
}

.excel-preview-table .col-index {
  width: 40px;
  text-align: center;
  white-space: nowrap;
}

.excel-preview-table .col-header-section {
  min-width: 180px;
  max-width: 320px;
  word-break: break-word;
  overflow-wrap: anywhere;
  white-space: normal;
}

.excel-preview-table .col-description {
  min-width: 250px;
  max-width: 550px;
  word-break: break-word;
  overflow-wrap: anywhere;
  white-space: normal;
}

.excel-preview-table .col-nowrap {
  white-space: nowrap;
}

.excel-badge-valid {
  background: #DEF7EC;
  color: #03543F;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 10.5px;
  font-weight: 600;
}

.excel-badge-warning {
  background: #FEF08A;
  color: #713F12;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 10.5px;
  font-weight: 600;
}

.excel-badge-error {
  background: #FDE8E8;
  color: #9B1C1C;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 10.5px;
  font-weight: 600;
}