/* ═══════════════════════════════════════════════════════════════
   Hospital CMS — Professional Theme
   Light: crisp white/slate · Dark: deep navy
═══════════════════════════════════════════════════════════════ */

/* ── Design tokens ─────────────────────────────────────────── */
:root {
  /* Brand - Sky blue workspace */
  --primary:       #2f80ed;
  --primary-hover: #1769d1;
  --primary-light: #e3f2ff;
  --primary-text:  #ffffff;

  /* Backgrounds */
  --bg:        #edf7ff;
  --surface:   #ffffff;
  --surface-2: #f5fbff;
  --surface-3: #dceefa;

  /* Text */
  --ink:       #102a43;
  --muted:     #607d98;
  --subtle:    #829ab1;

  /* Borders */
  --line:      #cfe3f2;

  /* Semantic */
  --brand:      var(--primary);
  --brand-dark: var(--primary-hover);
  --danger:     #dc2626;
  --ok:         #16a34a;
  --warn:       #d97706;
  --info:       #0284c7;
  --accent:     #f2994a;
  --hover:      #56ccf2;

  /* Sidebar */
  --sidebar-bg:               #dff2ff;
  --sidebar-text:             #123b5d;
  --sidebar-nav-text:         #285b7d;
  --sidebar-nav-hover-bg:     rgba(47,128,237,0.08);
  --sidebar-nav-active-text:  #1769d1;
  --sidebar-nav-active-bg:    rgba(47,128,237,0.12);
  --sidebar-user-pill-text:   #285b7d;
  --sidebar-brand-bg:         #2f80ed;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(15,23,42,0.08), 0 1px 2px rgba(15,23,42,0.04);
  --shadow:    0 4px 16px rgba(15,23,42,0.10), 0 1px 4px rgba(15,23,42,0.06);
  --shadow-lg: 0 12px 40px rgba(15,23,42,0.14);

  /* Radius */
  --r-sm: 6px;
  --r:    10px;
  --r-lg: 14px;
}

/* ── Dark mode tokens ───────────────────────────────────────── */
body.dark-mode {
  --bg:        #0f172a;
  --surface:   #1e293b;
  --surface-2: #162032;
  --surface-3: #2d3f55;
  --ink:       #f1f5f9;
  --muted:     #94a3b8;
  --subtle:    #64748b;
  --line:      #334155;

  --primary:       #10b981;
  --primary-hover: #059669;
  --primary-light: #064e3b;
  --hover:         #34d399;   /* Lighter green for dark mode */

  --sidebar-bg:           #020817;
  --sidebar-nav-hover-bg: rgba(255,255,255,0.06);
  --sidebar-nav-active-bg:rgba(16,185,129,0.20);
  --sidebar-nav-active-text: #6ee7b7;

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
  --shadow:    0 4px 16px rgba(0,0,0,0.35);
  --shadow-lg: 0 12px 40px rgba(0,0,0,0.5);
}

.print-estimate-page {
  max-width: 1100px;
  margin: 0 auto;
  background: var(--surface);
  color: var(--ink);
  padding: 24px;
}

.print-estimate-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 24px;
}

.print-estimate-heading {
  text-align: center;
  margin-bottom: 24px;
}

.print-estimate-heading h1 {
  margin: 0;
}

.print-estimate-heading p {
  margin: 6px 0 0;
  color: var(--muted);
}

.print-estimate-meta,
.print-estimate-items,
.print-estimate-totals {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 24px;
}

.print-estimate-meta th,
.print-estimate-meta td,
.print-estimate-items th,
.print-estimate-items td,
.print-estimate-totals th,
.print-estimate-totals td {
  border: 1px solid var(--line);
  padding: 10px;
  text-align: left;
  vertical-align: top;
}

.print-estimate-meta th,
.print-estimate-items th,
.print-estimate-totals th {
  background: var(--surface-2);
  font-weight: 700;
}

.print-estimate-items th {
  white-space: nowrap;
}

.print-estimate-items .description {
  text-align: justify;
}

.print-estimate-items .number,
.print-estimate-totals td {
  text-align: right;
}

.print-estimate-items .empty-cell {
  text-align: center;
  color: var(--muted);
}

.print-estimate-totals {
  max-width: 440px;
  margin-left: auto;
}

.print-estimate-totals .grand-total th,
.print-estimate-totals .grand-total td {
  font-size: 1.1em;
  font-weight: 800;
}

.print-estimate-notes {
  border-top: 1px solid var(--line);
  padding-top: 14px;
  margin-top: 20px;
}

.print-estimate-notes h2 {
  font-size: 1rem;
  margin: 0 0 6px;
}

.print-estimate-signatures {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 48px;
  margin-top: 80px;
  text-align: center;
}

.print-estimate-signatures div {
  border-top: 1px solid var(--ink);
  padding-top: 8px;
}

.rate-analysis-search-panel {
  background: var(--surface-2);
  border: 1px solid var(--line);
}

.rate-analysis-search-controls {
  width: 100%;
  margin-bottom: 0;
}

.rate-analysis-search-controls label {
  font-weight: 700;
}

.rate-analysis-search-controls input,
.rate-analysis-search-controls select {
  min-height: 42px;
}

.rate-analysis-search-btn {
  min-height: 42px;
  padding: 0 22px;
  border: 1px solid var(--primary);
  border-radius: var(--r-sm);
  color: #fff;
  background: var(--primary);
  font-weight: 700;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: background 0.15s, box-shadow 0.15s, transform 0.15s;
}

.rate-analysis-search-btn:hover {
  background: var(--primary-hover);
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}

.rate-analysis-search-btn:focus-visible {
  outline: 3px solid rgba(47, 128, 237, 0.3);
  outline-offset: 2px;
}

@media (max-width: 720px) {
  .rate-analysis-search-controls {
    flex-wrap: wrap;
  }

  .rate-analysis-search-controls > div {
    flex: 1 1 100% !important;
  }

  .rate-analysis-search-btn {
    width: 100%;
  }
}

/* Comprehensive Rate Analysis Page Styles */
.comprehensive-rate-analysis {
  padding: 20px;
  max-width: 1400px;
  margin: 0 auto;
}

.comprehensive-rate-analysis .topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.comprehensive-rate-analysis .topbar-title h1 {
  margin: 0;
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--ink);
}

.comprehensive-rate-analysis .topbar-title p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.comprehensive-rate-analysis .toolbar {
  display: flex;
  gap: 12px;
}

.comprehensive-rate-analysis .work-info-section {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 20px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
}

.comprehensive-rate-analysis .work-info-section h3 {
  margin: 0 0 16px;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--ink);
}

.comprehensive-rate-analysis .info-table {
  width: 100%;
  border-collapse: collapse;
}

.comprehensive-rate-analysis .info-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
}

.comprehensive-rate-analysis .info-table td:first-child {
  font-weight: 600;
  color: var(--muted);
  width: 200px;
}

.comprehensive-rate-analysis .info-table tr:last-child td {
  border-bottom: none;
}

.comprehensive-rate-analysis .no-data,
.comprehensive-rate-analysis .no-analysis {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 40px;
  text-align: center;
  color: var(--muted);
}

.comprehensive-rate-analysis .analysis-results {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

.comprehensive-rate-analysis .sub-analysis-section,
.comprehensive-rate-analysis .main-analysis-section {
  margin-bottom: 32px;
}

.comprehensive-rate-analysis .sub-analysis-section h3,
.comprehensive-rate-analysis .main-analysis-section h3 {
  margin: 0 0 16px;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--ink);
  padding-bottom: 8px;
  border-bottom: 2px solid var(--primary);
}

.comprehensive-rate-analysis .data-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 16px;
}

.comprehensive-rate-analysis .data-table th,
.comprehensive-rate-analysis .data-table td {
  border: 1px solid var(--line);
  padding: 10px 12px;
  text-align: left;
  vertical-align: top;
}

.comprehensive-rate-analysis .data-table th {
  background: var(--surface-2);
  font-weight: 600;
  color: var(--ink);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.comprehensive-rate-analysis .data-table .sub-analysis-header {
  background: var(--primary-light);
  font-weight: 600;
}

.comprehensive-rate-analysis .data-table .sub-analysis-header td {
  padding: 12px;
  font-weight: 600;
  color: var(--primary-hover);
}

.comprehensive-rate-analysis .data-table .sub-analysis-info td {
  background: var(--surface-2);
  font-weight: 500;
}

.comprehensive-rate-analysis .data-table .sub-analysis-total {
  background: #d1fae5;
  font-weight: 600;
}

.comprehensive-rate-analysis .data-table .item-header {
  background: var(--surface-2);
  font-weight: 600;
}

.comprehensive-rate-analysis .data-table .item-header td {
  font-weight: 600;
  color: var(--ink);
}

.comprehensive-rate-analysis .data-table .cost-row {
  background: var(--surface-3);
}

.comprehensive-rate-analysis .data-table .total-row {
  background: #dbeafe;
  font-weight: 600;
}

.comprehensive-rate-analysis .data-table .final-rate-row {
  background: #fef3c7;
  font-weight: 700;
}

.comprehensive-rate-analysis .data-table .spacer td {
  border: none;
  padding: 8px;
}

.comprehensive-rate-analysis .data-table td[style*="text-align: right"] {
  text-align: right;
}

.comprehensive-rate-analysis .error {
  background: #fee2e2;
  border: 1px solid #fecaca;
  border-radius: var(--r);
  padding: 20px;
  color: #991b1b;
}

@media print {
  @page { size: landscape; margin: 12mm; }

  body { background: #fff; }
  .top-nav,
  .page-header,
  .noprint { display: none !important; }
  .main-content { margin: 0; padding: 0; }
  .print-estimate-page { max-width: none; padding: 0; }
  .print-estimate-meta th,
  .print-estimate-items th,
  .print-estimate-totals th { background: #f3f4f6 !important; color: #111827 !important; }
  
  /* Comprehensive Rate Analysis Print Styles */
  .comprehensive-rate-analysis { padding: 0; }
  .comprehensive-rate-analysis .topbar,
  .comprehensive-rate-analysis .toolbar { display: none !important; }
  .comprehensive-rate-analysis .work-info-section,
  .comprehensive-rate-analysis .analysis-results { 
    border: none; 
    box-shadow: none; 
    padding: 0;
  }
  .comprehensive-rate-analysis .data-table th,
  .comprehensive-rate-analysis .data-table .sub-analysis-header,
  .comprehensive-rate-analysis .data-table .sub-analysis-info,
  .comprehensive-rate-analysis .data-table .sub-analysis-total,
  .comprehensive-rate-analysis .data-table .item-header,
  .comprehensive-rate-analysis .data-table .cost-row,
  .comprehensive-rate-analysis .data-table .total-row,
  .comprehensive-rate-analysis .data-table .final-rate-row {
    background: #f3f4f6 !important;
    color: #111827 !important;
  }
}

@media (max-width: 720px) {
  .print-estimate-page { padding: 12px; }
  .print-estimate-meta,
  .print-estimate-items { display: block; overflow-x: auto; }
  .print-estimate-signatures { gap: 12px; margin-top: 48px; }
}

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

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: 'DM Sans', system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  letter-spacing: 0;
  transition: background 0.2s, color 0.2s;
}

button, input, select, textarea { font: inherit; }
button { border: 0; cursor: pointer; }
a { color: var(--primary); text-decoration: none; }

/* ── Login ──────────────────────────────────────────────────── */
.login-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(380px, 0.9fr);
}

.login-hero {
  position: relative;
  min-height: 100vh;
  padding: 48px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  color: #fff;
  background:
    linear-gradient(160deg, rgba(10,20,60,0.72) 0%, rgba(30,64,175,0.38) 60%, rgba(0,0,0,0.18) 100%),
    url("https://images.unsplash.com/photo-1519494026892-80bbd2d6fd0d?auto=format&fit=crop&w=1600&q=90") center / cover;
}

.login-hero h1 {
  margin: 0;
  max-width: 700px;
  font-size: clamp(2.2rem, 4.5vw, 4.8rem);
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: -0.03em;
}

.login-hero p {
  max-width: 560px;
  margin: 16px 0 0;
  font-size: 1.05rem;
  line-height: 1.7;
  color: rgba(255,255,255,0.80);
}

.hero-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0,1fr));
  gap: 12px;
  max-width: 640px;
  margin-top: 32px;
}

.hero-stat {
  padding: 16px 18px;
  border: 1px solid rgba(255,255,255,0.18);
  background: rgba(255,255,255,0.09);
  backdrop-filter: blur(10px);
  border-radius: var(--r);
}

.hero-stat strong { display: block; font-size: 1.6rem; font-weight: 800; }
.hero-stat span   { color: rgba(255,255,255,0.72); font-size: 0.84rem; }

.login-panel {
  min-height: 100vh;
  padding: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
}

.login-card { width: min(100%, 420px); }

.brand-row, .top-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 1rem;
}

.brand-mark {
  width: 38px; height: 38px;
  display: grid; place-items: center;
  border-radius: var(--r-sm);
  background: var(--primary);
  color: #fff;
  font-weight: 800;
  font-size: 0.85rem;
  letter-spacing: 0;
}

.login-card h2 { margin: 28px 0 6px; font-size: 1.75rem; font-weight: 800; letter-spacing: -0.03em; }
.login-card > p { margin: 0 0 24px; color: var(--muted); font-size: 0.92rem; line-height: 1.6; }

/* ── iCloud-style Login ─────────────────────────────────────── */
.login-shell-icloud {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  background: linear-gradient(135deg, #059669 0%, #10b981 100%);
  overflow: hidden;
}

.login-background-icloud {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.bg-circle-icloud {
  position: absolute;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  animation: float 20s infinite ease-in-out;
}

.bg-circle-1 {
  width: 300px;
  height: 300px;
  top: 10%;
  left: 10%;
  animation-delay: 0s;
}

.bg-circle-2 {
  width: 200px;
  height: 200px;
  top: 60%;
  right: 15%;
  animation-delay: -5s;
}

.bg-circle-3 {
  width: 150px;
  height: 150px;
  bottom: 20%;
  left: 30%;
  animation-delay: -10s;
}

@keyframes float {
  0%, 100% {
    transform: translateY(0) rotate(0deg);
  }
  50% {
    transform: translateY(-20px) rotate(180deg);
  }
}

.login-container-icloud {
  position: relative;
  z-index: 10;
  width: 100%;
  max-width: 400px;
  padding: 48px 40px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(20px);
  border-radius: 24px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  text-align: center;
}

.login-logo-icloud {
  margin-bottom: 32px;
}

.logo-circle-icloud {
  width: 80px;
  height: 80px;
  margin: 0 auto;
  background: linear-gradient(135deg, #059669 0%, #10b981 100%);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 10px 30px rgba(5, 150, 105, 0.3);
}

.logo-text-icloud {
  color: white;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: 2px;
}

.login-title-icloud {
  margin: 0 0 8px;
  font-size: 1.75rem;
  font-weight: 600;
  color: #1a1a1a;
  letter-spacing: -0.5px;
}

.login-subtitle-icloud {
  margin: 0 0 40px;
  font-size: 0.95rem;
  color: #666;
  font-weight: 400;
}

.login-form-icloud {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.form-group-icloud {
  position: relative;
}

.form-group-icloud input {
  width: 100%;
  padding: 16px 16px 16px 48px;
  font-size: 1rem;
  border: 2px solid #e5e5e5;
  border-radius: 12px;
  background: #fafafa;
  transition: all 0.3s ease;
  outline: none;
}

.form-group-icloud input:focus {
  border-color: #059669;
  background: white;
  box-shadow: 0 0 0 4px rgba(5, 150, 105, 0.1);
}

.form-group-icloud input::placeholder {
  color: transparent;
}

.form-label-icloud {
  position: absolute;
  left: 48px;
  top: 50%;
  transform: translateY(-50%);
  color: #999;
  font-size: 1rem;
  pointer-events: none;
  transition: all 0.3s ease;
}

.form-group-icloud input:focus + .form-label-icloud,
.form-group-icloud input:not(:placeholder-shown) + .form-label-icloud {
  top: 0;
  left: 16px;
  transform: translateY(-50%);
  font-size: 0.75rem;
  color: #059669;
  background: white;
  padding: 0 8px;
  border-radius: 4px;
}

.login-button-icloud {
  position: relative;
  width: 100%;
  padding: 16px 24px;
  background: linear-gradient(135deg, #059669 0%, #10b981 100%);
  color: white;
  border: none;
  border-radius: 12px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 4px 15px rgba(5, 150, 105, 0.4);
}

.login-button-icloud:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(102, 126, 234, 0.5);
}

.login-button-icloud:active {
  transform: translateY(0);
}

.button-text-icloud {
  flex: 1;
}

.button-arrow-icloud {
  font-size: 1.2rem;
  transition: transform 0.3s ease;
}

.login-button-icloud:hover .button-arrow-icloud {
  transform: translateX(4px);
}

.login-links-icloud {
  display: flex;
  justify-content: space-between;
  margin-top: 24px;
  gap: 16px;
}

.link-button-icloud {
  background: none;
  border: none;
  color: #059669;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: color 0.2s ease;
  padding: 0;
}

.link-button-icloud:hover {
  color: #047857;
  text-decoration: underline;
}

.login-footer-icloud {
  margin-top: 32px;
  padding-top: 24px;
  border-top: 1px solid #e5e5e5;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}

.footer-link-icloud {
  color: #666;
  text-decoration: none;
  font-size: 0.85rem;
  transition: color 0.2s ease;
  display: flex;
  align-items: center;
  gap: 4px;
}

.footer-link-icloud:hover {
  color: #059669;
}

.footer-divider-icloud {
  color: #ccc;
  font-size: 0.85rem;
}

.mobile-icon-icloud {
  font-size: 1rem;
}

/* Dark mode for iCloud login */
body.dark-mode .login-shell-icloud {
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
}

body.dark-mode .login-container-icloud {
  background: rgba(30, 30, 40, 0.95);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

body.dark-mode .login-title-icloud {
  color: #ffffff;
}

body.dark-mode .login-subtitle-icloud {
  color: #a0a0a0;
}

body.dark-mode .form-group-icloud input {
  background: #252535;
  border-color: #3a3a4a;
  color: #ffffff;
}

body.dark-mode .form-group-icloud input:focus {
  background: #1a1a2e;
  border-color: #10b981;
}

body.dark-mode .form-label-icloud {
  color: #888;
}

body.dark-mode .form-group-icloud input:focus + .form-label-icloud,
body.dark-mode .form-group-icloud input:not(:placeholder-shown) + .form-label-icloud {
  color: #10b981;
  background: #1a1a2e;
}

body.dark-mode .login-footer-icloud {
  border-top-color: #3a3a4a;
}

body.dark-mode .footer-link-icloud {
  color: #888;
}

body.dark-mode .footer-link-icloud:hover {
  color: #10b981;
}

body.dark-mode .footer-divider-icloud {
  color: #555;
}

body.dark-mode .link-button-icloud {
  color: #10b981;
}

body.dark-mode .link-button-icloud:hover {
  color: #34d399;
}

/* Responsive design for iCloud login */
@media (max-width: 768px) {
  .login-container-icloud {
    max-width: 90%;
    padding: 32px 24px;
  }
  
  .login-title-icloud {
    font-size: 1.5rem;
  }
  
  .logo-circle-icloud {
    width: 64px;
    height: 64px;
  }
  
  .logo-text-icloud {
    font-size: 1.25rem;
  }
  
  .bg-circle-icloud {
    opacity: 0.5;
  }
}

@media (max-width: 480px) {
  .login-container-icloud {
    padding: 24px 20px;
    border-radius: 16px;
  }
  
  .login-links-icloud {
    flex-direction: column;
    gap: 12px;
  }
  
  .login-footer-icloud {
    flex-direction: column;
    gap: 8px;
  }
  
  .footer-divider-icloud {
    display: none;
  }
}

/* ── Login Shell (iCloud style) ───────────────────────────────── */
.login-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #059669 0%, #10b981 100%);
  padding: 20px;
}

.login-container {
  width: 100%;
  max-width: 400px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(20px);
  border-radius: 20px;
  padding: 48px 40px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  text-align: center;
}

.login-logo {
  display: flex;
  justify-content: center;
  margin-bottom: 24px;
}

.login-title {
  font-size: 1.75rem;
  font-weight: 600;
  color: #1d1d1f;
  margin: 0 0 8px 0;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-top: 32px;
}

.form-group {
  position: relative;
}

.form-group input {
  width: 100%;
  padding: 16px 12px;
  border: 1px solid #d2d2d7;
  border-radius: 12px;
  font-size: 1rem;
  background: #ffffff;
  color: #1d1d1f;
  outline: none;
  transition: all 0.2s ease;
}

.form-group input:focus {
  border-color: #059669;
  box-shadow: 0 0 0 4px rgba(5, 150, 105, 0.1);
}

.form-label {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: #86868b;
  font-size: 1rem;
  pointer-events: none;
  transition: all 0.2s ease;
  background: transparent;
  padding: 0 4px;
}

.form-group input:focus + .form-label,
.form-group input:not(:placeholder-shown) + .form-label {
  top: 0;
  font-size: 0.75rem;
  color: #059669;
  background: #ffffff;
}

.login-button {
  width: 100%;
  padding: 16px;
  background: #059669;
  color: #ffffff;
  border: none;
  border-radius: 12px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-top: 8px;
}

.login-button:hover {
  background: #047857;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(5, 150, 105, 0.4);
}

.login-button:active {
  transform: translateY(0);
}

.login-links {
  display: flex;
  justify-content: space-between;
  margin-top: 24px;
  gap: 16px;
}

.link-button {
  background: none;
  border: none;
  color: #059669;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: color 0.2s ease;
  padding: 0;
}

.link-button:hover {
  color: #047857;
  text-decoration: underline;
}

/* Dark mode for login */
body.dark-mode .login-shell {
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
}

body.dark-mode .login-container {
  background: rgba(30, 30, 40, 0.95);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

body.dark-mode .login-title {
  color: #ffffff;
}

body.dark-mode .form-group input {
  background: #252535;
  border-color: #3a3a4a;
  color: #ffffff;
}

body.dark-mode .form-group input:focus {
  background: #1a1a2e;
  border-color: #10b981;
}

body.dark-mode .form-label {
  color: #888;
}

body.dark-mode .form-group input:focus + .form-label,
body.dark-mode .form-group input:not(:placeholder-shown) + .form-label {
  color: #10b981;
  background: #1a1a2e;
}

body.dark-mode .link-button {
  color: #10b981;
}

body.dark-mode .link-button:hover {
  color: #34d399;
}

/* Responsive for login */
@media (max-width: 768px) {
  .login-container {
    max-width: 90%;
    padding: 32px 24px;
  }

  .login-title {
    font-size: 1.5rem;
  }
}

@media (max-width: 480px) {
  .login-container {
    padding: 24px 20px;
    border-radius: 16px;
  }

  .login-links {
    flex-direction: column;
    gap: 12px;
  }
}

/* ── Form box (single line add/edit/delete) ─────────────────── */
.form-box {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
  position: relative;
  z-index: 10;
}

.form-box-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
}

.form-box-header h3 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--ink);
}

.close-btn {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 1.5rem;
  font-weight: 300;
  cursor: pointer;
  border-radius: 4px;
  transition: all 0.2s ease;
}

.close-btn:hover {
  background: var(--surface-3);
  color: var(--ink);
}

.form-box-content {
  padding: 16px;
}

.form-row {
  display: flex;
  gap: 12px;
  align-items: center;
}

.form-row input,
.form-row select {
  flex: 1;
  min-width: 150px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--ink);
  font-size: 0.9rem;
}

.form-row input:focus,
.form-row select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(30,64,175,0.1);
}

/* ── Form fields ────────────────────────────────────────────── */
.field { margin-bottom: 14px; }

.field label {
  display: block;
  margin-bottom: 6px;
  color: var(--ink);
  font-weight: 600;
  font-size: 0.85rem;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--ink);
  padding: 10px 12px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

/* Date input styling */
input[type="date"] {
  font-family: inherit;
  cursor: pointer;
}

input[type="date"]::-webkit-calendar-picker-indicator {
  cursor: pointer;
  opacity: 0.6;
  transition: opacity 0.15s;
}

input[type="date"]::-webkit-calendar-picker-indicator:hover {
  opacity: 1;
}

.field textarea    { min-height: 100px; resize: vertical; }

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(30,64,175,0.12);
}

body.dark-mode .field input,
body.dark-mode .field select,
body.dark-mode .field textarea {
  background: var(--surface-2);
  border-color: var(--line);
  color: var(--ink);
}

/* Role tabs */
.role-tabs {
  display: grid;
  grid-template-columns: repeat(4,minmax(0,1fr));
  gap: 4px; padding: 4px;
  margin-bottom: 18px;
  background: var(--surface-3);
  border-radius: var(--r-sm);
}

.role-tabs button {
  min-height: 38px;
  color: var(--muted);
  background: transparent;
  border-radius: 5px;
  font-weight: 600;
  font-size: 0.85rem;
  transition: background 0.15s, color 0.15s;
}

.role-tabs button.active {
  color: var(--ink);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

/* CI Management sub-tabs */
.ci-sub-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px;
  padding: 4px;
  margin-bottom: 18px;
  background: var(--surface-3);
  border-radius: var(--r-sm);
}

.ci-sub-tabs .sub-tab-btn {
  min-height: 38px;
  color: var(--muted);
  background: transparent;
  border-radius: 5px;
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.ci-sub-tabs .sub-tab-btn.active {
  color: var(--ink);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

/* ── Buttons ────────────────────────────────────────────────── */
.primary-btn, .ghost-btn, .danger-btn, .tiny-btn {
  min-height: 40px;
  border-radius: var(--r-sm);
  padding: 0 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  font-weight: 700;
  font-size: 0.88rem;
  transition: background 0.15s, opacity 0.15s, box-shadow 0.15s;
  white-space: nowrap;
}

.primary-btn { color: #fff; background: var(--primary); box-shadow: var(--shadow-sm); }
.primary-btn:hover { background: var(--primary-hover); box-shadow: var(--shadow); }
.primary-btn:disabled,
.ghost-btn:disabled,
.tiny-btn:disabled {
  cursor: wait;
  opacity: 0.72;
  box-shadow: none;
}
.btn-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,0.45);
  border-top-color: #fff;
  border-radius: 50%;
  animation: btn-spin 0.75s linear infinite;
}
@keyframes btn-spin {
  to { transform: rotate(360deg); }
}

.ghost-btn { color: var(--ink); background: var(--surface-2); border: 1px solid var(--line); }
.ghost-btn:hover { background: var(--surface-3); }

.danger-btn { color: #fff; background: var(--danger); }
.danger-btn:hover { opacity: 0.88; }

.tiny-btn {
  min-height: 30px; padding: 0 10px;
  font-size: 0.78rem; font-weight: 600;
  color: var(--primary);
  background: var(--primary-light);
  border-radius: var(--r-sm);
}
.tiny-btn:hover { background: #dbeafe; }
body.dark-mode .tiny-btn { background: var(--primary-light); color: #93c5fd; }
body.dark-mode .tiny-btn:hover { background: #1e3a5f; }

/* ── App shell & top navigation ─────────────────────────────── */
.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

/* macOS-inspired Navigation */
.top-nav {
  position: sticky;
  top: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 8px 24px;
  background: rgba(255, 255, 255, 0.7);
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  box-shadow: 0 1px 0 0 rgba(0, 0, 0, 0.05);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 0;
}

.brand-logo {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #059669 0%, #10b981 100%);
  color: white;
  font-weight: 700;
  font-size: 0.9rem;
  border-radius: 7px;
  box-shadow: 0 2px 8px rgba(5, 150, 105, 0.25);
}

.brand-text {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.02em;
}

.nav-menu {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
  justify-content: flex-start;
  margin-left: 24px;
}

/* macOS-style Navigation Items */
.nav-item {
  padding: 6px 12px;
  border: none;
  background: transparent;
  color: rgba(0, 0, 0, 0.6);
  font-size: 0.8125rem;
  font-weight: 500;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  white-space: nowrap;
}

.nav-item:hover {
  color: rgba(0, 0, 0, 0.85);
  background: rgba(0, 0, 0, 0.05);
}

.nav-item.active {
  color: #059669;
  background: rgba(5, 150, 105, 0.1);
  font-weight: 600;
}

/* Override nav-item styles for dropdown toggles */
.nav-item.dropdown-toggle {
  background: transparent;
  border: none;
  padding: 6px 12px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.nav-item.dropdown-toggle:hover {
  background: rgba(0, 0, 0, 0.05);
  color: rgba(0, 0, 0, 0.85);
}

.nav-item.dropdown-toggle.active {
  background: rgba(5, 150, 105, 0.1);
  color: #059669;
  font-weight: 600;
}

.nav-item.dropdown-toggle .dropdown-arrow {
  font-size: 0.65rem;
  opacity: 0.5;
  transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.nav-item.dropdown-toggle:hover .dropdown-arrow {
  opacity: 0.7;
}

/* Navigation dropdown styles */
.nav-dropdown {
  position: relative;
  display: inline-block;
}

.nav-dropdown .dropdown-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
}

.dropdown-arrow {
  font-size: 0.7rem;
  transition: transform 0.2s ease;
}

.nav-dropdown.open .dropdown-arrow {
  transform: rotate(180deg);
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  min-width: 220px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(5,150,105,0.15), 0 0 0 1px rgba(5,150,105,0.05);
  padding: 8px;
  display: none;
  flex-direction: column;
  gap: 2px;
  z-index: 1000;
  animation: dropdownFadeIn 0.2s ease;
}

.nav-dropdown.open .dropdown-menu {
  display: flex;
}

.dropdown-item {
  width: 100%;
  padding: 12px 18px;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 600;
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  white-space: nowrap;
  position: relative;
  overflow: hidden;
}

.dropdown-item::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%) scaleX(0);
  width: 4px;
  height: 60%;
  background: linear-gradient(180deg, #059669 0%, #10b981 100%);
  border-radius: 0 3px 3px 0;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.dropdown-item:hover {
  color: var(--primary);
  background: linear-gradient(135deg, rgba(5,150,105,0.08) 0%, rgba(16,185,129,0.12) 100%);
  transform: translateX(4px);
  padding-left: 22px;
}

.dropdown-item:hover::before {
  transform: translateY(-50%) scaleX(1);
}

.dropdown-item.active {
  color: var(--primary);
  background: linear-gradient(135deg, rgba(5,150,105,0.15) 0%, rgba(16,185,129,0.2) 100%);
  font-weight: 700;
  padding-left: 22px;
}

.dropdown-item.active::before {
  transform: translateY(-50%) scaleX(1);
}

@keyframes dropdownFadeIn {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Dark mode dropdown styles */
body.dark-mode .dropdown-menu {
  background: var(--surface);
  border-color: var(--line);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}

body.dark-mode .dropdown-item {
  color: var(--muted);
}

body.dark-mode .dropdown-item:hover {
  color: var(--ink);
  background: var(--surface-2);
}

.nav-actions {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 16px;
}

.theme-toggle {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: var(--surface-2);
  border-radius: 10px;
  cursor: pointer;
  font-size: 1.2rem;
  transition: all 0.2s ease;
}

.theme-toggle:hover {
  background: var(--surface-3);
  transform: scale(1.05);
}

.user-profile {
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border-radius: 10px;
  background: transparent;
  transition: background 0.2s ease;
  padding: 0;
}

.user-profile .user-name-display {
  padding: 8px 16px;
  background: linear-gradient(135deg, rgba(5,150,105,0.1) 0%, rgba(16,185,129,0.15) 100%);
  border-radius: 10px;
  border: 1px solid rgba(5,150,105,0.2);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 8px;
}

.user-profile .user-name-display .dropdown-arrow {
  font-size: 0.65rem;
  transition: transform 0.2s ease;
  opacity: 0.7;
}

.user-profile:hover .user-name-display {
  background: linear-gradient(135deg, rgba(5,150,105,0.15) 0%, rgba(16,185,129,0.2) 100%);
  border-color: rgba(5,150,105,0.3);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(5,150,105,0.2);
}

.user-profile-dropdown.show .user-name-display .dropdown-arrow {
  transform: rotate(180deg);
}

.user-profile-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  display: none;
  flex-direction: column;
  min-width: 220px;
  gap: 4px;
  padding: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
  z-index: 1000;
}

.user-profile-dropdown.show {
  display: flex;
}

.user-profile-dropdown .dropdown-item {
  width: 100%;
  padding: 12px 16px;
  border: none;
  background: transparent;
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 500;
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-profile-dropdown .dropdown-item:hover {
  background: var(--surface-2);
  color: var(--primary);
}

.user-profile-dropdown .dropdown-item span:first-child {
  font-size: 1.1rem;
}

.user-profile-dropdown .logout-item:hover {
  background: rgba(220, 38, 38, 0.1);
  color: var(--danger);
}

.profile-header {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 4px;
  background: var(--surface-2);
  border-radius: 8px;
}

.profile-header .profile-name {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--ink);
}

.profile-header .profile-role {
  font-size: 0.8rem;
  color: var(--muted);
  text-transform: capitalize;
}

.user-avatar {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #059669 0%, #10b981 100%);
  color: white;
  font-weight: 600;
  font-size: 0.9rem;
  border-radius: 50%;
}

.user-name-display {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: linear-gradient(135deg, rgba(5,150,105,0.1) 0%, rgba(16,185,129,0.15) 100%);
  border-radius: 10px;
  border: 1px solid rgba(5,150,105,0.2);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
}

.user-name-display:hover {
  background: linear-gradient(135deg, rgba(5,150,105,0.15) 0%, rgba(16,185,129,0.2) 100%);
  border-color: rgba(5,150,105,0.3);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(5,150,105,0.2);
}

.user-name-display .user-icon {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #059669 0%, #10b981 100%);
  color: white;
  font-weight: 700;
  font-size: 0.85rem;
  border-radius: 50%;
  flex-shrink: 0;
}

.user-name-display .user-info {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
  min-width: 0;
}

.user-name-display .user-info strong {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-name-display .user-info span {
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: capitalize;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

body.dark-mode .user-name-display {
  background: rgba(16,185,129,0.15);
  border-color: rgba(16,185,129,0.3);
}

body.dark-mode .user-name-display:hover {
  background: rgba(16,185,129,0.25);
  border-color: rgba(16,185,129,0.4);
}

body.dark-mode .user-name-display .user-info strong {
  color: #10b981;
}

.logout-btn {
  padding: 8px 16px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 500;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.logout-btn:hover {
  color: var(--danger);
  border-color: var(--danger);
  background: rgba(220, 38, 38, 0.05);
}

/* Dark mode for top nav */
body.dark-mode .top-nav {
  background: rgba(30, 30, 40, 0.95);
  border-bottom-color: var(--line);
}

body.dark-mode .brand-text {
  color: var(--ink);
}

body.dark-mode .nav-item {
  color: var(--muted);
}

body.dark-mode .nav-item:hover {
  color: #10b981;
  background: rgba(16,185,129,0.1);
}

body.dark-mode .nav-item.active {
  color: #10b981;
  background: rgba(16,185,129,0.2);
}

body.dark-mode .theme-toggle {
  background: rgba(255, 255, 255, 0.05);
}

body.dark-mode .theme-toggle:hover {
  background: rgba(255, 255, 255, 0.1);
}

body.dark-mode .logout-btn {
  color: var(--muted);
  border-color: var(--line);
}

body.dark-mode .logout-btn:hover {
  color: var(--danger);
  border-color: var(--danger);
  background: rgba(220, 38, 38, 0.1);
}

/* Responsive for top nav */
@media (max-width: 1024px) {
  .nav-menu {
    gap: 4px;
    margin-left: 16px;
  }

  .nav-item {
    padding: 10px 16px;
    font-size: 0.85rem;
  }
  
  .dropdown-item {
    padding: 10px 16px;
    font-size: 0.85rem;
  }
}

@media (max-width: 768px) {
  .top-nav {
    padding: 12px 20px;
    gap: 16px;
  }

  .brand-text {
    display: none;
  }

  .nav-menu {
    gap: 2px;
    margin-left: 8px;
  }

  .nav-item {
    padding: 8px 12px;
    font-size: 0.8rem;
  }
  
  .dropdown-item {
    padding: 8px 12px;
    font-size: 0.8rem;
  }

  .logout-btn {
    padding: 6px 12px;
    font-size: 0.8rem;
  }
}

@media (max-width: 480px) {
  .top-nav {
    padding: 10px 16px;
    gap: 12px;
  }

  .nav-item {
    padding: 6px 10px;
    font-size: 0.75rem;
  }
  
  .dropdown-item {
    padding: 6px 10px;
    font-size: 0.75rem;
  }

  .theme-toggle {
    width: 36px;
    height: 36px;
    font-size: 1rem;
  }

  .user-avatar {
    width: 32px;
    height: 32px;
    font-size: 0.8rem;
  }
}

.nav-dropdown {
  position: relative;
  display: inline-block;
}

.nav-dropdown:hover .dropdown-menu,
.nav-dropdown.show .dropdown-menu {
  display: block !important;
  visibility: visible !important;
  opacity: 1 !important;
}

.nav-dropdown:hover .nav-item.dropdown-toggle .dropdown-arrow,
.nav-dropdown.show .nav-item.dropdown-toggle .dropdown-arrow {
  transform: rotate(180deg);
}

/* macOS-style Dropdown Menu */
.dropdown-menu {
  position: absolute !important;
  top: calc(100% + 4px) !important;
  left: 0 !important;
  background: rgba(255, 255, 255, 0.85) !important;
  backdrop-filter: saturate(180%) blur(20px) !important;
  -webkit-backdrop-filter: saturate(180%) blur(20px) !important;
  min-width: 200px !important;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12), 
              0 1px 2px rgba(0, 0, 0, 0.08),
              inset 0 1px 0 rgba(255, 255, 255, 0.5) !important;
  border-radius: 10px !important;
  z-index: 10000 !important;
  padding: 4px !important;
  border: 1px solid rgba(0, 0, 0, 0.08) !important;
  display: none !important;
  pointer-events: auto !important;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px) scale(0.95);
  transition: opacity 0.2s cubic-bezier(0.4, 0, 0.2, 1),
              visibility 0.2s cubic-bezier(0.4, 0, 0.2, 1),
              transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.dropdown-menu.show {
  display: block !important;
  visibility: visible !important;
  opacity: 1 !important;
  transform: translateY(0) scale(1);
}

/* macOS-style Dropdown Items */
.dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 6px 10px;
  text-align: left;
  border: none;
  background: transparent;
  color: rgba(0, 0, 0, 0.75);
  font-size: 0.8125rem;
  font-weight: 400;
  cursor: pointer;
  border-radius: 6px;
  transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  white-space: nowrap;
}

.dropdown-item:hover {
  background: rgba(5, 150, 105, 0.12);
  color: #059669;
}

.dropdown-item.active {
  background: rgba(5, 150, 105, 0.15);
  color: #059669;
  font-weight: 500;
}

.dropdown-arrow {
  transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}
  border: none;
  background: none;
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--ink);
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
  border-radius: 6px;
  margin: 2px 8px;
}

.dropdown-item::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, var(--hover) 0%, #2563eb 100%);
  opacity: 0;
  transition: opacity 0.2s ease;
  z-index: -1;
  border-radius: 6px;
}

.dropdown-item:hover {
  color: #fff;
  transform: translateX(4px);
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.2);
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.dropdown-item:hover::before {
  opacity: 1;
}

.dropdown-item svg {
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.dropdown-item:hover svg {
  transform: scale(1.1);
}

.dropdown-item:active {
  transform: translateX(2px);
}

.user-dropdown {
  position: relative;
  display: inline-block;
}

.user-dropdown:hover .user-dropdown-menu {
  display: block !important;
  visibility: visible !important;
  opacity: 1 !important;
}

.user-dropdown-menu {
  position: absolute !important;
  right: 0 !important;
  top: 100% !important;
  background: var(--surface) !important;
  min-width: 180px !important;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15) !important;
  border-radius: 8px !important;
  z-index: 1000 !important;
  padding: 8px 0 !important;
  margin-top: 4px !important;
  border: 1px solid var(--line) !important;
  display: none !important;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px);
  transition: opacity 0.3s ease, visibility 0.3s ease, transform 0.3s ease;
}

.user-dropdown-menu.show {
  display: block !important;
  visibility: visible !important;
  opacity: 1 !important;
  transform: translateY(0);
}

.user-dropdown-menu .dropdown-item {
  margin: 2px 8px;
  border-radius: 6px;
}

.user-dropdown-menu .dropdown-item:hover {
  background: linear-gradient(135deg, var(--hover) 0%, #2563eb 100%);
  color: #fff;
  transform: translateX(4px);
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.user-dropdown-menu .dropdown-item:hover::before {
  opacity: 1;
}

.user-dropdown-menu .dropdown-item::before {
  background: linear-gradient(135deg, var(--hover) 0%, #2563eb 100%);
}

/* Download app link styling */
.dropdown-item[href*="Hospital_CMS_V2.apk"],
a[href*="Hospital_CMS_V2.apk"] {
  font-weight: 600;
  color: var(--primary) !important;
}

.dropdown-item[href*="Hospital_CMS_V2.apk"]:hover,
a[href*="Hospital_CMS_V2.apk"]:hover {
  color: #fff !important;
}

.header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  min-width: 0;
}

.user-pill {
  display: flex;
  gap: 10px;
  align-items: center;
  min-width: 0;
  padding-right: 6px;
  position: relative;
}

.user-pill::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, var(--hover) 0%, #2563eb 100%);
  opacity: 0;
  transition: opacity 0.25s ease;
  z-index: -1;
  border-radius: var(--r);
  pointer-events: none;
}

.user-pill:hover::before {
  opacity: 1;
}

.user-pill:hover {
  color: #fff;
  border-color: var(--hover);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3), 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.user-pill:hover strong,
.user-pill:hover span {
  color: #fff;
}

.user-pill:active {
  transform: translateY(0);
  box-shadow: 0 2px 4px rgba(59, 130, 246, 0.2);
}

.avatar {
  width: 28px; height: 28px; flex: 0 0 28px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--warn);
  color: #fff;
  font-weight: 700;
  font-size: 0.7rem;
  overflow: hidden;
}

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

.user-pill strong {
  display: block;
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.85rem;
  color: var(--ink);
  transition: color 0.25s ease;
}
.user-pill span {
  display: block;
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.75rem;
  color: var(--muted);
  transition: color 0.25s ease;
}

.icon-action {
  width: 40px;
  min-width: 40px;
  min-height: 40px;
  padding: 0;
}

/* ── Main content ───────────────────────────────────────────── */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.app-footer {
  padding: 14px 24px 18px;
  color: var(--muted);
  background: var(--surface);
  border-top: 1px solid var(--line);
  text-align: center;
  font-size: 0.78rem;
  line-height: 1.6;
}

.app-footer strong {
  color: var(--ink);
  font-weight: 700;
}

.page-header {
  padding: 32px 32px 24px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.page-header h1 {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.page-header p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.content-area {
  padding: 32px;
  flex: 1;
}

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

.topbar-title {
  min-width: 240px;
}

.topbar-title h1 {
  font-size: 1rem;
  margin: 0;
  font-weight: 600;
}

.topbar-title p {
  font-size: 0.85rem;
  margin: 4px 0 0;
  color: var(--muted);
}

.register-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.complaint-register-head {
  align-items: stretch;
}

.register-controls {
  flex: 1 1 680px;
  max-width: 960px;
  display: grid;
  gap: 10px;
  justify-items: end;
}

.register-filters,
.register-actions {
  justify-content: flex-end;
}

.register-search {
  min-width: 180px;
  max-width: 240px;
  flex: 1 1 200px;
}

.date-search {
  min-width: 140px;
  max-width: 160px;
  flex: 0 0 150px;
}

#clearDateFilters {
  min-width: 32px;
  max-width: 32px;
  padding: 0 8px;
  flex: 0 0 32px;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ── Hospital Summary Page ───────────────────────────────────── */
.summary-table {
  width: 100%;
  border-collapse: collapse;
}

.summary-table thead {
  background: var(--surface-2);
}

.summary-table th {
  padding: 12px 16px;
  text-align: left;
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--ink);
  border-bottom: 2px solid var(--line);
}

.summary-table tbody tr {
  border-bottom: 1px solid var(--line);
  transition: background 0.2s ease;
}

.summary-table tbody tr:hover {
  background: var(--surface-2);
}

.summary-table tbody tr.clickable-row {
  cursor: pointer;
}

.summary-table tbody tr.clickable-row:hover {
  background: var(--surface-3);
}

.summary-table td {
  padding: 12px 16px;
  font-size: 0.9rem;
  color: var(--ink);
}

.summary-table .metric-value {
  font-weight: 700;
  text-align: center;
}

.summary-table .metric-value.total {
  color: var(--primary);
}

.summary-table .metric-value.open {
  color: var(--warn);
}

.summary-table .metric-value.closed {
  color: var(--ok);
}

.summary-table .metric-value.assigned {
  color: var(--info);
}

.summary-table .metric-value.high {
  color: var(--danger);
}

.summary-table .metric-value.resolution {
  color: var(--accent);
}

.summary-table .clickable-cell {
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
}

.summary-table .clickable-cell:hover {
  transform: scale(1.1);
  text-decoration: underline;
}

.summary-table .clickable-cell::after {
  content: '→';
  position: absolute;
  top: 50%;
  right: 4px;
  transform: translateY(-50%);
  opacity: 0;
  transition: opacity 0.2s ease;
  font-size: 0.7rem;
  color: var(--primary);
}

.summary-table .clickable-cell:hover::after {
  opacity: 1;
}

.summary-table .summary-view-btn {
  padding: 6px 12px;
  font-size: 0.8rem;
}

.summary-table .tiny-btn {
  white-space: nowrap;
}

/* ── Clickable Elements ───────────────────────────────────────── */
.clickable-metric {
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
}

.clickable-metric:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
  border-color: var(--primary);
}

.clickable-metric::after {
  content: '→';
  position: absolute;
  top: 50%;
  right: 12px;
  transform: translateY(-50%);
  opacity: 0;
  transition: opacity 0.2s ease;
  font-size: 0.8rem;
  color: var(--primary);
}

.clickable-metric:hover::after {
  opacity: 1;
}

.clickable-category {
  cursor: pointer;
  transition: all 0.2s ease;
}

.clickable-category:hover {
  transform: scale(1.05);
  box-shadow: var(--shadow);
}

.clickable-item {
  cursor: pointer;
  transition: all 0.2s ease;
}

.clickable-item:hover {
  background: var(--surface-2);
  transform: translateX(4px);
}

.clickable-item:hover::after {
  content: '→';
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  opacity: 0;
  transition: opacity 0.2s ease;
  font-size: 0.8rem;
  color: var(--primary);
}

.clickable-item:hover::after {
  opacity: 1;
}

.summary-metric.clickable-metric {
  cursor: pointer;
  transition: all 0.2s ease;
}

.summary-metric.clickable-metric:hover {
  background: var(--surface-3);
  transform: scale(1.05);
}

@media (max-width: 768px) {
  .summary-table {
    font-size: 0.8rem;
  }
  
  .summary-table th,
  .summary-table td {
    padding: 8px 12px;
  }
  
  .summary-table .summary-view-btn {
    padding: 4px 8px;
    font-size: 0.75rem;
  }
}

.compact-search {
  min-width: 118px;
  max-width: 150px;
}

.building-search {
  min-width: 150px;
  max-width: 190px;
}

.register-actions .primary-btn,
.register-actions .ghost-btn,
.register-filters .primary-btn {
  white-space: nowrap;
}

.user-panel-controls {
  display: grid;
  gap: 10px;
  justify-items: end;
}

.user-panel-primary,
.user-panel-tabs {
  justify-content: flex-end;
}

.user-panel-tabs .ghost-btn {
  white-space: nowrap;
}

.search {
  min-width: 240px;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 0 12px;
  background: var(--surface);
  color: var(--ink);
  outline: none;
  font-size: 0.88rem;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.search:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(30,64,175,0.10); }
body.dark-mode .search { background: var(--surface-2); border-color: var(--line); color: var(--ink); }

/* ── Metrics ────────────────────────────────────────────────── */
.metrics {
  display: grid;
  grid-template-columns: repeat(4,minmax(0,1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.metric {
  padding: 20px;
  border-radius: var(--r);
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.15s;
}
.metric:hover { box-shadow: var(--shadow); }

.metric span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.metric strong {
  display: block;
  margin-top: 6px;
  font-size: 2.2rem;
  font-weight: 800;
  color: var(--primary);
  letter-spacing: -0.04em;
  line-height: 1;
}

/* ── Cards / Panels ─────────────────────────────────────────── */
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.panel-head {
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.panel-head h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  color: var(--ink);
}

/* grid helpers */
.grid-2 {
  display: grid;
  grid-template-columns: minmax(0,1.35fr) minmax(300px,0.65fr);
  gap: 16px;
}

/* ── Tables ─────────────────────────────────────────────────── */
.table-wrap { overflow: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
  font-size: 0.875rem;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
}

th {
  padding: 10px 14px;
  background: var(--surface-2);
  border-bottom: 2px solid var(--line);
  border-right: 1px solid var(--line);
  text-align: left;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
}

th:last-child { border-right: none; }

table th {
  font-weight: 700 !important;
}

td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--line);
  border-right: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  color: var(--ink);
}

td:last-child { border-right: none; }

tbody tr { transition: background 0.1s; }
tbody tr:hover td { background: var(--primary-light); }
body.dark-mode tbody tr:hover td { background: rgba(59,130,246,0.07); }
tbody tr:last-child td { border-bottom: none; }

td strong { display: block; font-weight: 600; }
td small  { color: var(--muted); font-size: 0.78rem; }

/* ── Badges ─────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.badge.open       { color: #92400e; background: #fef3c7; }
.badge.assigned   { color: #1e40af; background: #dbeafe; }
.badge.progress   { color: #9a3412; background: #ffedd5; }
.badge.resolved   { color: #065f46; background: #d1fae5; }
.badge.closed     { color: #475569; background: #e2e8f0; }
.badge.priority-major    { color: #991b1b; background: #fee2e2; }
.badge.priority-periodic { color: #92400e; background: #fef3c7; }
.badge.priority-minor    { color: #166534; background: #dcfce7; }

body.dark-mode .badge.open       { color: #fcd34d; background: rgba(252,211,77,0.12); }
body.dark-mode .badge.assigned   { color: #93c5fd; background: rgba(147,197,253,0.12); }
body.dark-mode .badge.progress   { color: #fdba74; background: rgba(253,186,116,0.12); }
body.dark-mode .badge.resolved   { color: #6ee7b7; background: rgba(110,231,183,0.12); }
body.dark-mode .badge.closed     { color: #94a3b8; background: rgba(148,163,184,0.10); }
body.dark-mode .badge.priority-major    { color: #fca5a5; background: rgba(252,165,165,0.12); }
body.dark-mode .badge.priority-periodic { color: #fcd34d; background: rgba(252,211,77,0.12); }
body.dark-mode .badge.priority-minor    { color: #86efac; background: rgba(134,239,172,0.12); }

/* Form grid */
.form-grid {
  display: grid;
  grid-template-columns: repeat(3,minmax(0,1fr));
  gap: 14px;
  padding: 18px;
}
.form-grid .full { grid-column: 1 / -1; }

/* 4-column form grid */
.form-grid-4 {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  padding: 16px;
}

.form-grid-4 .form-group {
  display: flex;
  flex-direction: column;
}

.form-grid-4 .form-group label {
  font-size: 0.85rem;
  font-weight: 500;
  color: #374151;
  margin-bottom: 4px;
}

.form-grid-4 .form-group input,
.form-grid-4 .form-group select,
.form-grid-4 .form-group textarea {
  padding: 8px 10px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 0.9rem;
  transition: border-color 0.2s;
}

.form-grid-4 .form-group input:focus,
.form-grid-4 .form-group select:focus,
.form-grid-4 .form-group textarea:focus {
  outline: none;
  border-color: #4f46e5;
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.form-grid-4 .form-group textarea {
  resize: vertical;
  min-height: 60px;
}

/* 4-column info grid */
.info-grid-4 {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  padding: 20px;
}

.info-grid-4 .info-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.info-grid-4 .info-item label {
  font-size: 0.8rem;
  font-weight: 600;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.025em;
}

.info-grid-4 .info-item span {
  font-size: 0.95rem;
  color: #111827;
  font-weight: 500;
}

@media (max-width: 1024px) {
  .form-grid-4 {
    grid-template-columns: repeat(2, 1fr);
  }
  .info-grid-4 {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 640px) {
  .form-grid-4 {
    grid-template-columns: 1fr;
  }
  .info-grid-4 {
    grid-template-columns: 1fr;
  }
}

/* ── Category strip ─────────────────────────────────────────── */
.category-strip {
  display: grid;
  grid-template-columns: repeat(3,minmax(0,1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.category {
  padding: 16px 20px;
  border-radius: var(--r);
  color: #fff;
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}
.category.civil        { background: linear-gradient(135deg,#92400e,#b45309); }
.category.electrical   { background: linear-gradient(135deg,#1e40af,#2563eb); }
.category.horticulture { background: linear-gradient(135deg,#14532d,#16a34a); }
.category span { font-size: 0.82rem; opacity: 0.88; display: block; }
.category strong { display: block; font-size: 1.8rem; font-weight: 800; margin-top: 6px; letter-spacing: -0.04em; }

/* ── Person cards ───────────────────────────────────────────── */
.cards {
  display: grid;
  grid-template-columns: repeat(3,minmax(0,1fr));
  gap: 14px;
}

.person-card {
  padding: 18px;
  border-radius: var(--r);
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.15s;
}
.person-card:hover { box-shadow: var(--shadow); }
.person-head { display: flex; gap: 12px; align-items: center; margin-bottom: 12px; }
.person-card h3 { margin: 0; font-size: 0.95rem; font-weight: 700; }
.person-card p  { margin: 5px 0; color: var(--muted); font-size: 0.85rem; }

/* ── List items ─────────────────────────────────────────────── */
.list { display: grid; gap: 0; padding: 0; }
.list-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
  transition: background 0.1s;
}
.list-item:last-child { border-bottom: none; }
.list-item:hover { background: var(--surface-2); }
.list-item strong { display: block; margin-bottom: 3px; font-weight: 600; font-size: 0.9rem; }
.list-item span, .list-item small { color: var(--muted); font-size: 0.82rem; line-height: 1.5; }

/* ── Work detail cards ──────────────────────────────────────── */
.work-detail-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 12px; }
.work-detail-card {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface-2);
}
.work-detail-card h3 { margin: 0 0 4px; font-size: 0.92rem; font-weight: 700; }
.work-detail-card p, .work-detail-card small, .work-detail-card li { color: var(--muted); font-size: 0.84rem; }
.work-detail-card ul { margin: 8px 0 0 16px; padding: 0; }

/* ── Action stack / feedback ────────────────────────────────── */
.action-stack, .feedback-box {
  display: grid;
  gap: 6px;
  min-width: 160px;
}

.action-stack select,
.feedback-box select,
.feedback-box textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 7px 10px;
  background: var(--surface);
  color: var(--ink);
  font-size: 0.82rem;
  outline: none;
}
.action-stack select:focus,
.feedback-box select:focus,
.feedback-box textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(30,64,175,0.10);
}
body.dark-mode .action-stack select,
body.dark-mode .feedback-box select,
body.dark-mode .feedback-box textarea {
  background: var(--surface-2);
  border-color: var(--line);
  color: var(--ink);
}
.feedback-box textarea { min-height: 58px; resize: vertical; }

/* ── Image thumb ────────────────────────────────────────────── */
.image-thumb {
  width: 58px; height: 48px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  overflow: hidden;
  background: var(--surface-2);
  transition: opacity 0.15s;
}
.image-thumb:hover { opacity: 0.85; }
.image-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* ── Demo box ───────────────────────────────────────────────── */
.demo-box {
  margin-top: 16px;
  padding: 14px 16px;
  border-radius: var(--r-sm);
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.65;
}

/* ── PDF export group ───────────────────────────────────────── */
.pdf-export-group { display: flex; gap: 6px; align-items: center; }

/* ── Empty state ────────────────────────────────────────────── */
.empty {
  padding: 32px 24px;
  color: var(--muted);
  text-align: center;
  font-size: 0.9rem;
}

/* ── Basic Data View ───────────────────────────────────────── */
.basic-data-view {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.basic-data-view .topbar {
  align-items: center;
  justify-content: space-between;
}

.link-btn {
  color: var(--primary);
  text-decoration: none;
  font-weight: 500;
  transition: color 0.2s ease;
}

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

.form-container {
  margin-top: 20px;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding: 18px;
  border-top: 1px solid var(--line);
}

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 1050px) {
  .login-shell, .grid-2 { grid-template-columns: 1fr; }
  .login-hero { min-height: 50vh; }
  .login-panel { min-height: auto; }

  .app-header {
    padding: 12px 18px;
    flex-wrap: nowrap;
  }
  .header-main { align-items: flex-start; }
  .nav {
    flex: 1;
    min-width: 0;
    flex-wrap: nowrap;
  }
  .header-actions { 
    min-width: 0;
    flex-shrink: 0;
  }
  .user-pill strong,
  .user-pill span { max-width: 220px; }

  .metrics, .cards { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .main { padding: 16px 18px; }
  .register-controls {
    max-width: none;
    justify-items: stretch;
  }
  .register-filters,
  .register-actions {
    justify-content: flex-start;
  }
  .user-panel-controls {
    justify-items: stretch;
  }
  .user-panel-primary,
  .user-panel-tabs {
    justify-content: flex-start;
  }
}

@media (max-width: 900px) {
  .mobile-menu-trigger {
    cursor: pointer;
  }
  
  .mobile-menu-trigger:hover {
    background: var(--surface-2);
  }
  
  .mobile-hidden {
    display: none !important;
  }
  
  .nav-items-container {
    display: none !important;
  }
  
  .nav-items-container.show {
    display: flex !important;
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    background: var(--surface);
    flex-direction: column;
    flex-wrap: wrap;
    padding: 8px;
    gap: 4px;
    border: 1px solid var(--line);
    border-radius: var(--r);
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
    z-index: 99;
    min-width: 200px;
    animation: slideDown 0.3s cubic-bezier(0.4, 0, 0.2, 1) forwards;
  }
  
  .mobile-menu-trigger.active .brand-text {
    color: var(--primary);
  }
  
  @keyframes slideDown {
    from {
      opacity: 0;
      transform: translateY(-8px);
    }
    to {
      opacity: 1;
      transform: translateY(0);
    }
  }
  
  .nav-items-container button,
  .nav-items-container .nav-dropdown {
    width: 100%;
    justify-content: flex-start;
    padding: 10px 12px;
    margin: 2px 0;
    border-radius: 6px;
  }
  
  .nav-items-container .dropdown-menu {
    position: static !important;
    box-shadow: none !important;
    border: none !important;
    padding: 4px 0 4px 16px !important;
    margin: 0 !important;
    display: none !important;
    opacity: 0 !important;
    visibility: hidden !important;
    background: transparent !important;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    max-height: 0 !important;
    overflow: hidden !important;
  }
  
  .nav-items-container.show .nav-dropdown.show .dropdown-menu {
    display: block !important;
    opacity: 1 !important;
    visibility: visible !important;
    max-height: 500px !important;
    animation: fadeIn 0.25s cubic-bezier(0.4, 0, 0.2, 1) forwards;
  }
  
  @keyframes fadeIn {
    from {
      opacity: 0;
      transform: translateY(-4px);
      max-height: 0;
    }
    to {
      opacity: 1;
      transform: translateY(0);
      max-height: 500px;
    }
  }
  
  .nav-items-container .nav-dropdown:hover .dropdown-menu {
    display: none !important;
  }
  
  .nav-items-container .nav-dropdown:hover .nav-dropdown-toggle .dropdown-arrow {
    transform: rotate(0deg);
  }
  
  .nav-items-container .nav-dropdown.show .nav-dropdown-toggle .dropdown-arrow {
    transform: rotate(180deg);
  }
  
  .nav-items-container .dropdown-arrow {
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  }
  
  .nav-items-container .dropdown-item {
    padding: 8px 12px;
    margin: 2px 0;
  }
  
  .mobile-user-menu {
    display: none !important;
  }
  
  .nav-items-container.show .mobile-user-menu {
    display: block !important;
  }
  
  .mobile-user-toggle {
    display: none !important;
  }
  
  .nav-items-container.show .mobile-user-toggle {
    display: flex !important;
  }
  
  .mobile-user-options {
    display: none !important;
  }
  
  .mobile-user-toggle.show + .mobile-user-options {
    display: block !important;
    animation: fadeIn 0.25s cubic-bezier(0.4, 0, 0.2, 1) forwards;
  }
  
  .mobile-user-toggle.show .user-arrow {
    transform: rotate(180deg);
  }
  
  .user-arrow {
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  }
  
  .mobile-only {
    display: none !important;
  }
  
  .nav-items-container.show .mobile-user-options .mobile-only {
    display: flex !important;
  }
  
  .nav-items-container.show .mobile-only.button {
    display: flex !important;
  }
}

@media (max-width: 720px) {
  .login-hero, .login-panel, .main { padding: 16px; }
  .app-header {
    gap: 10px;
    padding: 10px 12px;
  }
  .header-main { gap: 10px; }
  .top-brand span { display: none; }
  .header-actions { gap: 6px; }
  
  .nav {
    gap: 4px;
    margin: 0 -12px;
    padding: 8px 12px 2px;
    overflow-x: auto;
    flex-wrap: nowrap;
    scrollbar-width: thin;
  }
  .user-pill { display: none; }
  .hero-stats, .metrics, .cards, .category-strip, .form-grid { grid-template-columns: 1fr; }
  .topbar { align-items: stretch; flex-direction: column; }
  .toolbar, .search { width: 100%; }
  .register-controls { width: 100%; }
  .user-panel-controls { width: 100%; }
  .date-search { width: 100%; max-width: none; min-width: auto; flex: 1 1 auto; }
  #clearDateFilters { display: none; }
  .register-actions .primary-btn,
  .register-actions .ghost-btn,
  .register-filters .primary-btn,
  .user-panel-primary .primary-btn,
  .user-panel-primary .ghost-btn,
  .user-panel-tabs .ghost-btn,
  .compact-search,
  .building-search,
  .register-search {
    width: 100%;
  }
  .role-tabs { grid-template-columns: 1fr 1fr; }
}

/* ── Staff popup ────────────────────────────────────────────── */
.staff-link {
  background: none;
  border: none;
  padding: 0;
  color: var(--primary);
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
  white-space: nowrap;
  transition: color 0.15s;
}
.staff-link:hover { color: var(--primary-hover); }
.staff-link small { font-size: 0.68rem; opacity: 0.65; }

.staff-popup-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.50);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.staff-popup {
  background: var(--surface);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  width: min(100%,380px);
  padding: 28px;
  position: relative;
  animation: popup-in 0.18s cubic-bezier(0.34,1.56,0.64,1);
}

@keyframes popup-in {
  from { opacity: 0; transform: scale(0.92) translateY(12px); }
  to   { opacity: 1; transform: scale(1)   translateY(0); }
}

.staff-popup-close {
  position: absolute;
  top: 14px; right: 14px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 50%;
  width: 28px; height: 28px;
  font-size: 0.78rem;
  cursor: pointer;
  color: var(--muted);
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s, color 0.15s;
}
.staff-popup-close:hover { background: var(--danger); color: #fff; border-color: var(--danger); }

.staff-popup-head { display: flex; align-items: center; gap: 14px; margin-bottom: 20px; }

.staff-popup-photo {
  width: 72px;
  height: 88px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  border-radius: var(--r-sm);
  overflow: hidden;
  background: var(--primary);
  color: #fff;
  font-weight: 800;
  font-size: 1.1rem;
}
.staff-popup-photo img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  border-radius: 0;
}

.staff-popup-body { display: grid; }

.staff-popup-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  font-size: 0.875rem;
  gap: 12px;
}
.staff-popup-row:last-child { border-bottom: none; }
.staff-popup-row span  { color: var(--muted); flex-shrink: 0; font-size: 0.82rem; }
.staff-popup-row strong { text-align: right; word-break: break-word; font-weight: 600; }

/* ── Pagination ─────────────────────────────────────────────── */
[data-page] {
  min-width: 80px;
}
[data-page]:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}


/* ── Pagination Styles ─────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 20px;
  margin-top: 20px;
  background: var(--surface);
  border-radius: var(--r);
  box-shadow: var(--shadow-sm);
}

.pagination-btn {
  min-height: 38px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface-2);
  color: var(--ink);
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.15s ease;
}

.pagination-btn:hover:not(:disabled) {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  box-shadow: var(--shadow-sm);
}

.pagination-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  background: var(--surface-2);
}

.pagination-info {
  padding: 0 12px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--ink);
}

.pagination-select {
  min-height: 38px;
  padding: 0 32px 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface-2);
  color: var(--ink);
  font-weight: 500;
  font-size: 0.85rem;
  cursor: pointer;
  outline: none;
  transition: all 0.15s ease;
}

.pagination-select:hover {
  border-color: var(--primary);
}

.pagination-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(30,64,175,0.12);
}

/* Dark mode pagination */
body.dark-mode .pagination {
  background: var(--surface);
  border-color: var(--line);
}

body.dark-mode .pagination-btn {
  background: var(--surface-2);
  border-color: var(--line);
  color: var(--ink);
}

body.dark-mode .pagination-btn:hover:not(:disabled) {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

body.dark-mode .pagination-select {
  background: var(--surface-2);
  border-color: var(--line);
  color: var(--ink);
}

/* Responsive pagination */
@media (max-width: 768px) {
  .pagination {
    flex-wrap: wrap;
    gap: 8px;
    padding: 16px;
  }

  .pagination-btn {
    min-height: 34px;
    padding: 0 12px;
    font-size: 0.8rem;
  }

  .pagination-info {
    width: 100%;
    text-align: center;
    order: -1;
    margin-bottom: 8px;
  }

  .pagination-select {
    width: 100%;
  }
}


/* ── DSR Form Positioning ─────────────────────────────────────── */
#dsrFormContainer {
  margin-bottom: 24px;
  animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

#dsrFormContainer .panel {
  border: 2px solid var(--primary);
  box-shadow: var(--shadow-lg);
}

#dsrFormContainer .panel-head {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-hover) 100%);
  color: #fff;
  padding: 16px 20px;
  border-radius: var(--r) var(--r) 0 0;
}

#dsrFormContainer .panel-head h2 {
  margin: 0;
  color: #fff;
}

#dsrFormContainer .panel-head .ghost-btn {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.3);
  color: #fff;
}

#dsrFormContainer .panel-head .ghost-btn:hover {
  background: rgba(255, 255, 255, 0.25);
  border-color: rgba(255, 255, 255, 0.5);
}

/* Dark mode DSR form */
body.dark-mode #dsrFormContainer .panel {
  border-color: var(--primary);
}

body.dark-mode #dsrFormContainer .panel-head {
  background: linear-gradient(135deg, var(--primary) 0%, #2563eb 100%);
}


/* ── Compact Form Layout (Two Rows) ─────────────────────────── */
.form-section-compact {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.form-row {
  display: flex;
  gap: 12px;
  align-items: end;
  flex-wrap: nowrap;
}

.form-row .field {
  margin-bottom: 0;
  flex: 1;
  min-width: 0;
}

.form-row .field[style*="flex: 2"] {
  flex: 2;
}

.form-actions-inline {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  flex-shrink: 0;
}

.form-actions-inline label {
  visibility: hidden;
  height: 0;
  margin: 0;
}

.btn-full {
  width: 100%;
  min-height: 40px;
  white-space: nowrap;
}

/* Responsive compact form */
@media (max-width: 1400px) {
  .form-row {
    flex-wrap: wrap;
  }
}


/* ── Generate Market Rate Page ─────────────────────────────────── */
.generate-market-rate {
  max-width: 1200px;
  margin: 0 auto;
}

.loading-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px;
  background: var(--surface-2);
  border-radius: var(--r);
  margin-bottom: 24px;
}

.loader {
  width: 60px;
  height: 60px;
  border: 6px solid var(--surface-3);
  border-top: 6px solid var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 20px;
}

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

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

.loading-text p {
  margin: 8px 0;
  color: var(--muted);
}

.progress-text {
  font-weight: 600;
  color: var(--primary);
  font-size: 1.1em;
}

.status-text {
  font-style: italic;
  font-size: 0.9em;
}

.status-section {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  padding: 20px;
}

.status-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: var(--surface-2);
  border-radius: var(--r-sm);
  border-left: 4px solid var(--primary);
}

.status-label {
  font-weight: 500;
  color: var(--muted);
}

.status-value {
  font-weight: 600;
  color: var(--ink);
}

.info-section {
  padding: 20px;
}

.info-section h3 {
  margin-top: 0;
  margin-bottom: 12px;
  color: var(--primary);
  font-size: 1.1em;
}

.info-section ul {
  margin: 0 0 16px 0;
  padding-left: 20px;
}

.info-section li {
  margin-bottom: 8px;
  color: var(--muted);
}

/* Dark mode loading container */
body.dark-mode .loading-container {
  background: var(--surface-3);
}

body.dark-mode .status-item {
  background: var(--surface-3);
  border-left-color: var(--primary);
}

body.dark-mode .info-section h3 {
  color: var(--primary);
}

body.dark-mode .info-section li {
  color: var(--muted);
}


/* ── Edit Market Rate Page ─────────────────────────────────── */
.edit-market-rate {
  max-width: 1400px;
  margin: 0 auto;
}

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.modal-content {
  background: var(--surface);
  border-radius: var(--r);
  box-shadow: var(--shadow-lg);
  max-width: 600px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
  animation: slideUp 0.3s ease-out;
}

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

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-hover) 100%);
  color: #fff;
  border-radius: var(--r) var(--r) 0 0;
}

.modal-header h2 {
  margin: 0;
  color: #fff;
  font-size: 1.2em;
}

.modal-header .close-btn {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: #fff;
  font-size: 1.5em;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.modal-header .close-btn:hover {
  background: rgba(255, 255, 255, 0.3);
}

.modal-content .estimate-form {
  padding: 20px;
}

.edit-market-rate-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 16px;
}

.edit-market-rate-modal {
  max-width: 460px;
  width: min(92%, 460px);
}

.edit-market-rate-modal .modal-header {
  padding: 12px 16px;
}

.edit-market-rate-modal .modal-header h2 {
  font-size: 1rem;
}

.edit-market-rate-modal .estimate-form {
  padding: 14px 16px 16px;
}

.edit-market-rate-modal .edit-market-rate-form {
  gap: 9px 12px;
}

.edit-market-rate-modal .field {
  margin-bottom: 0;
}

.edit-market-rate-modal .field label {
  font-size: 0.82rem;
  margin-bottom: 4px;
}

.edit-market-rate-modal input,
.edit-market-rate-modal textarea {
  min-height: 34px;
  padding: 7px 9px;
  font-size: 0.88rem;
}

.edit-market-rate-modal textarea {
  min-height: 52px;
}

.edit-market-rate-full-field,
.edit-market-rate-form-actions {
  grid-column: 1 / -1;
}

.edit-market-rate-form-actions {
  display: flex;
  justify-content: flex-end;
  padding-top: 4px;
}

.modal-content textarea {
  resize: vertical;
  min-height: 60px;
}

.edit-market-rate-form input[readonly],
.edit-market-rate-form textarea[readonly] {
  background: var(--surface-2);
  color: var(--muted);
  cursor: not-allowed;
}

/* Dark mode modal */
body.dark-mode .modal-content {
  background: var(--surface);
  border: 1px solid var(--line);
}

body.dark-mode .modal-header {
  background: linear-gradient(135deg, var(--primary) 0%, #2563eb 100%);
}

@media (max-width: 768px) {
  .edit-market-rate-form {
    grid-template-columns: 1fr;
  }

  .form-row {
    flex-wrap: wrap;
  }
  
  .form-actions-inline {
    margin-top: 8px;
  }
}

/* Dark mode compact form */
body.dark-mode .form-section-compact {
  background: var(--surface);
}

/* ── Prepare Estimate Layout ─────────────────────────────────── */
.prep-estimate-layout {
  display: grid;
  grid-template-columns: 25% 75%;
  gap: 1.5rem;
  margin-top: 1.5rem;
}

.prep-estimate-sidebar {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.prep-estimate-main {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.prep-estimate-table-panel {
  min-height: 600px;
}

/* Responsive adjustments for prep-estimate */
@media (max-width: 1280px) {
  .prep-estimate-layout {
    grid-template-columns: 30% 70%;
  }
}

@media (max-width: 1050px) {
  .prep-estimate-layout {
    grid-template-columns: 1fr;
  }
  
  .prep-estimate-table-panel {
    min-height: 400px;
  }
}

/* ── Compact Prepare Estimate Page ─────────────────────────────── */
.prep-estimate-view .topbar {
  padding: 0.75rem 1.5rem;
  margin-bottom: 1rem;
}

.prep-estimate-view .topbar-title h1 {
  font-size: 1rem;
  margin-bottom: 0.25rem;
}

.prep-estimate-view .topbar-title p {
  font-size: 0.813rem;
  margin: 0;
}

.prep-estimate-view .panel {
  padding: 1rem;
}

.prep-estimate-view .panel-head {
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
}

.prep-estimate-view .panel-head h2 {
  font-size: 1rem;
  margin: 0;
}

.prep-estimate-view .form-section-compact {
  gap: 0.75rem;
}

.prep-estimate-view .field {
  margin-bottom: 0.5rem;
}

.prep-estimate-view .field label {
  font-size: 0.813rem;
  margin-bottom: 0.25rem;
  font-weight: 500;
}

.prep-estimate-view .field input,
.prep-estimate-view .field select {
  padding: 0.5rem;
  font-size: 0.875rem;
}

.prep-estimate-view .checkbox-field {
  font-size: 0.875rem;
  margin: 0.5rem 0;
}

.prep-estimate-view .form-actions {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
}

.prep-estimate-view .primary-btn,
.prep-estimate-view .secondary-btn,
.prep-estimate-view .ghost-btn {
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
}

.prep-estimate-help p {
  font-size: 0.813rem;
  line-height: 1.4;
  margin-bottom: 0.75rem;
}

.prep-estimate-help .metric {
  padding: 0.5rem;
  margin-bottom: 0.5rem;
}

.prep-estimate-help .metric span {
  font-size: 0.75rem;
}

.prep-estimate-help .metric strong {
  font-size: 1.25rem;
}

.prep-estimate-view .data-table {
  font-size: 0.875rem;
}

.prep-estimate-view .data-table th,
.prep-estimate-view .data-table td {
  padding: 0.5rem 0.75rem;
}

.prep-estimate-view .data-table th {
  font-size: 0.813rem;
}

.prep-estimate-view .action-btn {
  padding: 0.25rem 0.625rem;
  font-size: 0.75rem;
  margin: 0 0.125rem;
}

.prep-estimate-view .status-badge {
  padding: 0.125rem 0.5rem;
  font-size: 0.75rem;
}

.prep-estimate-layout {
  gap: 1rem;
  margin-top: 1rem;
}

.prep-estimate-sidebar {
  gap: 1rem;
}

.prep-estimate-main {
  gap: 1rem;
}

.prep-estimate-table-panel {
  min-height: 500px;
}

/* Reduce table container padding */
.prep-estimate-view .table-container {
  padding: 0;
}

/* Modal Overlay and Dialog Styles */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
}

.modal-dialog {
  background: white;
  border-radius: 8px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  width: 90%;
  max-width: 500px;
  max-height: 90vh;
  overflow: auto;
}

.modal-header {
  padding: 1.5rem;
  border-bottom: 1px solid #e5e7eb;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h3 {
  margin: 0;
  font-size: 1.25rem;
  color: #1f2937;
}

.modal-body {
  padding: 1.5rem;
}

.modal-body p {
  margin: 0.5rem 0;
  color: #4b5563;
}

.modal-body .field {
  margin-top: 1rem;
}

.modal-body label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
  color: #374151;
}

.modal-body .form-control {
  width: 100%;
  padding: 0.5rem;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  font-size: 1rem;
}

.modal-body textarea.form-control {
  resize: vertical;
  font-family: inherit;
}

.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid #e5e7eb;
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
}

.modal-footer button {
  padding: 0.5rem 1rem;
  border-radius: 4px;
  font-size: 0.875rem;
  cursor: pointer;
}


/* ============================================================
   COST ABSTRACT STYLES
   ============================================================ */
.cost-abstract-view {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px;
}

.cost-abstract-sheet {
  background: white;
  padding: 32px;
}

.cost-abstract-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  margin-top: 20px;
}

.cost-abstract-table th,
.cost-abstract-table td {
  padding: 8px 12px;
  border: 1px solid #d1d5db;
  text-align: left;
}

.cost-abstract-table thead th {
  background-color: #f3f4f6;
  font-weight: 600;
}

.cost-abstract-table tbody tr:hover {
  background-color: #f9fafb;
}

@media print {
  .cost-abstract-view {
    padding: 0;
    max-width: 100%;
  }
  
  .cost-abstract-sheet {
    box-shadow: none;
    border: none;
    padding: 20px;
  }
  
  .cost-abstract-table {
    font-size: 11px;
  }
  
  .cost-abstract-table th,
  .cost-abstract-table td {
    padding: 6px 8px;
  }
}


/* ============================================================
   PROJECT DETAILS STYLES
   ============================================================ */
.office-stamp-view {
  max-width: 1180px;
  margin: 0 auto;
  padding: 16px;
}

.generate-market-rate-warning {
  margin: 0 0 16px;
  padding: 12px 16px;
  color: #b91c1c;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-left: 4px solid #dc2626;
}

.office-stamp-panel {
  background: var(--surface);
  margin-bottom: 16px;
}

.office-stamp-table th:first-child,
.office-stamp-table td:first-child {
  width: 30%;
}

.office-stamp-form-panel {
  max-width: 760px;
}

.office-stamp-form {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  padding: 16px;
}

.office-stamp-form .form-actions {
  grid-column: 1 / -1;
  padding: 0;
}

@media (max-width: 700px) {
  .office-stamp-form {
    grid-template-columns: 1fr;
  }
}


/* ============================================================
   PROJECT DETAILS STYLES
   ============================================================ */
.project-details-view {
  max-width: 1180px;
  margin: 0 auto;
  padding: 16px;
}

.project-details-content {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.project-details-content .panel {
  background: var(--surface);
}

.project-details-view .form-grid-4 {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px 12px;
  padding: 16px;
  margin-bottom: 0;
}

.project-details-view .form-grid-4 .field {
  margin-bottom: 4px;
}

.project-details-wide-field {
  grid-column: span 2;
}

.project-details-view .form-actions {
  padding: 0 16px 16px;
}

@media (max-width: 768px) {
  .project-details-view .form-grid-4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .project-details-wide-field {
    grid-column: span 2;
  }
}

@media (max-width: 480px) {
  .project-details-view .form-grid-4 {
    grid-template-columns: 1fr;
  }

  .project-details-wide-field {
    grid-column: span 1;
  }
}

/* Keep the pointer path continuous from each trigger into its menu. */
.nav-dropdown .dropdown-menu {
  top: 100% !important;
  transform: none !important;
  transform-origin: top center;
  transition: opacity 0.16s ease, visibility 0.16s ease;
}

.nav-dropdown:hover .dropdown-menu,
.nav-dropdown.open .dropdown-menu,
.nav-dropdown.show .dropdown-menu {
  opacity: 1;
  visibility: visible;
}

.nav-dropdown .dropdown-toggle {
  position: relative;
  z-index: 1;
}

@media print {
  .project-details-view {
    padding: 0;
    max-width: 100%;
  }
  
  .project-details-content .panel {
    box-shadow: none;
    border: 1px solid #d1d5db;
    page-break-inside: avoid;
    margin-bottom: 16px;
  }
  
  .panel-head button {
    display: none;
  }
  
  .data-table {
    font-size: 10px;
  }
  
  .data-table th,
  .data-table td {
    padding: 4px 6px;
  }
}


/* ═══════════════════════════════════════════════════════════════
   DSR Code Selection Modal
═══════════════════════════════════════════════════════════════ */

.dsr-modal {
  display: none;
  position: fixed;
  z-index: 10000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.dsr-modal-content {
  background-color: var(--surface);
  border-radius: 8px;
  width: 75%;
  max-width: 1200px;
  min-width: 500px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  animation: slideUp 0.3s ease-out;
}

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

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

.dsr-modal-header h2 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--ink);
}

.dsr-modal-search {
  padding: 16px 24px;
  border-bottom: 1px solid var(--line);
  background-color: var(--surface-2);
}

.dsr-modal-body {
  overflow-y: auto;
  padding: 0;
  max-height: calc(80vh - 160px);
}

.dsr-table {
  width: 100%;
  border-collapse: collapse;
  background-color: var(--surface);
}

.dsr-table thead {
  position: sticky;
  top: 0;
  background-color: var(--surface-2);
  z-index: 10;
}

.dsr-table thead th {
  padding: 12px 16px;
  text-align: left;
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--ink);
  border-bottom: 2px solid var(--line);
  white-space: nowrap;
}

.dsr-table tbody tr {
  cursor: pointer;
  transition: background-color 0.15s ease;
  border-bottom: 1px solid var(--line);
}

.dsr-table tbody tr:hover {
  background-color: var(--primary-light);
}

.dsr-table tbody tr:active {
  background-color: #a7f3d0;
}

.dsr-table tbody td {
  padding: 12px 16px;
  font-size: 0.875rem;
  color: var(--ink);
}

.dsr-table tbody td:first-child {
  font-weight: 500;
  color: var(--primary);
}

/* Dark mode adjustments */
.dark-mode .dsr-modal-content {
  background-color: #1e293b;
}

.dark-mode .dsr-modal-header {
  border-bottom-color: #334155;
}

.dark-mode .dsr-modal-search {
  background-color: #0f172a;
  border-bottom-color: #334155;
}

.dark-mode .dsr-modal-search input {
  background-color: #1e293b;
  color: #e2e8f0;
  border-color: #475569;
}

.dark-mode .dsr-modal-search input::placeholder {
  color: #64748b;
}

.dark-mode .dsr-table {
  background-color: #1e293b;
}

.dark-mode .dsr-table thead {
  background-color: #0f172a;
}

.dark-mode .dsr-table thead th {
  color: #e2e8f0;
  border-bottom-color: #334155;
}

.dark-mode .dsr-table tbody tr {
  border-bottom-color: #334155;
}

.dark-mode .dsr-table tbody tr:hover {
  background-color: rgba(5, 150, 105, 0.15);
}

.dark-mode .dsr-table tbody tr:active {
  background-color: rgba(5, 150, 105, 0.25);
}

.dark-mode .dsr-table tbody td {
  color: #e2e8f0;
}

/* Responsive design */
@media (max-width: 1024px) {
  .dsr-modal-content {
    width: 85%;
  }
}

@media (max-width: 768px) {
  .dsr-modal-content {
    width: 95%;
    min-width: auto;
  }
  
  .dsr-table thead th,
  .dsr-table tbody td {
    padding: 8px 12px;
    font-size: 0.8125rem;
  }
}

/* ── Estimate Pro light-blue visual refresh ─────────────────── */
body:not(.dark-mode) {
  background:
    linear-gradient(rgba(255,255,255,0.52) 1px, transparent 1px),
    linear-gradient(90deg, rgba(47,128,237,0.045) 1px, transparent 1px),
    var(--bg);
  background-size: 32px 32px;
}

h1, h2, h3, h4, .brand-text, .login-title {
  font-family: 'Space Grotesk', 'DM Sans', sans-serif;
  letter-spacing: 0;
}

.top-nav {
  padding: 12px 28px;
  background: rgba(255,255,255,0.88);
  border-bottom-color: rgba(47,128,237,0.16);
  box-shadow: 0 8px 24px rgba(24,78,119,0.07);
}

.brand-logo {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(145deg, #56ccf2, #2f80ed);
  box-shadow: 0 7px 16px rgba(47,128,237,0.25);
}

.brand-text { font-weight: 700; color: #123b5d; }

.nav-item {
  color: #52738e;
  border-radius: 9px;
  font-weight: 600;
}

.nav-item:hover {
  color: #1769d1;
  background: #eaf6ff;
}

.nav-item.active,
.nav-item.dropdown-toggle.active {
  color: #1769d1;
  background: #dff2ff;
}

.dropdown-menu,
.user-profile-dropdown {
  border-color: #c7e2f4;
  box-shadow: 0 18px 42px rgba(28,91,136,0.16);
}

.dropdown-item:hover,
.dropdown-item.active {
  color: #1769d1;
  background: #eaf6ff;
}

.user-profile .user-name-display {
  background: #eaf6ff;
  border-color: #c7e2f4;
  color: #285b7d;
}

.user-profile:hover .user-name-display {
  background: #dff2ff;
  border-color: #9fd1ef;
  box-shadow: 0 6px 16px rgba(47,128,237,0.14);
}

.main-content { background: transparent; }
.page-header { padding-top: 32px; }
.page-header h1 { color: #123b5d; }
.page-header p { color: #607d98; }

.panel,
.form-box,
.table-container,
.estimate-form,
.admin-view {
  border-color: #cfe3f2;
  box-shadow: 0 8px 24px rgba(28,91,136,0.07);
}

.panel-head,
.form-box-header,
th { background: #f5fbff; }

.primary-btn,
.login-button {
  background: linear-gradient(135deg, #2f80ed, #1769d1);
  box-shadow: 0 7px 16px rgba(47,128,237,0.22);
}

.primary-btn:hover,
.login-button:hover { background: linear-gradient(135deg, #1769d1, #1558b0); }

.ghost-btn { background: #f5fbff; border-color: #cfe3f2; }
.ghost-btn:hover { background: #e3f2ff; }

.field input:focus,
.field select:focus,
.field textarea:focus,
.form-row input:focus,
.form-row select:focus,
.form-group input:focus {
  border-color: #56a8ed;
  box-shadow: 0 0 0 4px rgba(47,128,237,0.13);
}

.metric strong { color: #2f80ed; }

.login-shell {
  background:
    linear-gradient(135deg, rgba(18,59,93,0.72), rgba(47,128,237,0.45)),
    url("https://images.unsplash.com/photo-1497366811353-6870744d04b2?auto=format&fit=crop&w=1800&q=88") center / cover;
}

.login-container {
  border: 1px solid rgba(255,255,255,0.7);
  box-shadow: 0 24px 70px rgba(18,59,93,0.25);
}

.login-title { color: #123b5d; }

@keyframes surface-rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.content-area > * { animation: surface-rise 0.35s ease both; }

@media (max-width: 720px) {
  .top-nav { padding: 10px 16px; }
  .page-header { padding-top: 20px; }
}

/* Keep every navigation control aligned to one consistent size. */
.nav-item,
.nav-item.dropdown-toggle,
.dropdown-menu .dropdown-item {
  min-height: 40px;
  height: 40px;
  padding-top: 0;
  padding-bottom: 0;
  display: inline-flex;
  align-items: center;
  line-height: 1;
}

.nav-item,
.nav-item.dropdown-toggle {
  min-width: 132px;
  justify-content: center;
}

.dropdown-menu .dropdown-item {
  width: 100%;
  justify-content: flex-start;
}

@media (max-width: 768px) {
  .nav-item,
  .nav-item.dropdown-toggle,
  .dropdown-menu .dropdown-item {
    min-height: 38px;
    height: 38px;
  }

  .nav-item,
  .nav-item.dropdown-toggle {
    min-width: 116px;
  }
}
