/* ============================================================================
   STOICHEM INTERIO — VUDFIT ENTERPRISE CRM DESIGN SYSTEM
   Stoichem Interio Pvt. Ltd. (Godhra, Gujarat)
   Crafted to mirror the luxury aesthetic of stoicheminterio.com
   Typography: Outfit (Sans-Serif) & Playfair Display (Luxury Serif)
   Color Palette: Deep Forest Obsidian, Imperial Green & Sovereign Champagne Gold
============================================================================ */

:root {
  /* Brand Forest Palette (stoicheminterio.com) */
  --forest-950: #05160E;
  --forest-900: #0B2316;
  --forest-850: #0C2E1D;
  --forest-800: #0E3E26;
  --forest-700: #165735;
  --forest-600: #1B6935;
  --forest-500: #237A40;
  --forest-200: #C2DEC9;
  --forest-100: #E6F3EC;
  --forest-50:  #F2F8F5;

  /* Sovereign Champagne Gold Accents */
  --gold-500: #C5A059;
  --gold-600: #AA8022;
  --gold-700: #9A7B38;
  --gold-800: #785E22;
  --gold-200: #EADBBA;
  --gold-100: #F5EEDB;
  --gold-50:  #FBF7EE;
  --gold-subtle: rgba(197, 160, 89, 0.12);
  --gold-border: rgba(197, 160, 89, 0.32);
  --gold-gradient: linear-gradient(135deg, #D4AF37 0%, #C5A059 50%, #AA8022 100%);
  --forest-gradient: linear-gradient(135deg, #05160E 0%, #0B2316 40%, #165735 100%);

  /* Neutrals & Slate Hierarchy */
  --slate-900: #0B2316;
  --slate-800: #1A2E22;
  --slate-700: #33443B;
  --slate-600: #4B5B53;
  --slate-500: #6B7B73;
  --slate-400: #94A39B;
  --slate-300: #CBD5CF;
  --slate-200: #E2E8E4;
  --slate-100: #F1F5F3;
  --slate-50:  #F8FAF9;

  /* Surfaces & Backgrounds */
  --bg-page: #FBF9F6;
  --surface-card: #FFFFFF;
  --surface-subtle: #F6F4EF;
  --border-subtle: rgba(11, 35, 22, 0.09);
  --border-strong: rgba(11, 35, 22, 0.18);

  /* Semantic Alerts */
  --danger: #DC2626;
  --danger-light: #FEF2F2;
  --danger-border: #FCA5A5;
  --warning: #D97706;
  --warning-light: #FFFBEB;
  --warning-border: #FCD34D;
  --success: #16A34A;
  --success-light: #F0FDF4;
  --info: #2563EB;
  --info-light: #EFF6FF;

  /* Backward Compatibility Aliases */
  --brand-green: var(--forest-700);
  --forest-green: var(--forest-700);
  --green: var(--forest-700);
  --brand-forest-deep: var(--forest-950);
  --brand-forest: var(--forest-900);
  --brand-green-light: var(--forest-50);
  --gold: var(--gold-500);
  --gold-primary: var(--gold-500);
  --gold-deep: var(--gold-600);
  --gold-light: var(--gold-50);
  --text-muted: var(--slate-500);
  --border: var(--border-subtle);
  --radius: var(--radius-md);
  --font: var(--font-sans);

  /* Dimensions & Ergonomics */
  --radius-xs: 4px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;

  /* Shadows with Gold Glow Highlights */
  --shadow-sm: 0 1px 3px rgba(5, 22, 14, 0.05), 0 1px 2px rgba(197, 160, 89, 0.04);
  --shadow-md: 0 4px 12px -2px rgba(5, 22, 14, 0.07), 0 2px 4px -1px rgba(197, 160, 89, 0.06);
  --shadow-lg: 0 10px 25px -4px rgba(5, 22, 14, 0.09), 0 4px 8px -2px rgba(197, 160, 89, 0.08);
  --shadow-xl: 0 20px 35px -6px rgba(5, 22, 14, 0.12), 0 8px 16px -4px rgba(197, 160, 89, 0.1);
  --shadow-glow: 0 0 24px rgba(197, 160, 89, 0.35);

  /* Typography */
  --font-sans: 'Outfit', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-serif: 'Playfair Display', Georgia, serif;
  --transition: all 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

/* ============================================================================
   BASE RESET & GLOBAL STYLES
============================================================================ */
* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  font-family: var(--font-sans);
  background-color: var(--bg-page);
  background-image: radial-gradient(rgba(197, 160, 89, 0.14) 1px, transparent 1px);
  background-size: 24px 24px;
  color: var(--slate-900);
  line-height: 1.55;
  font-size: 14.5px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Luxury Text Selection */
::selection {
  background: var(--gold-500);
  color: var(--forest-950);
}
::-moz-selection {
  background: var(--gold-500);
  color: var(--forest-950);
}

/* Custom Scrollbars */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--slate-100); }
::-webkit-scrollbar-thumb { background: var(--slate-300); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--gold-500); }

/* ============================================================================
   EXECUTIVE HEADER
============================================================================ */
header {
  background: var(--forest-gradient);
  color: #FFFFFF;
  padding: 12px 28px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 4px 24px rgba(5, 22, 14, 0.35);
  border-bottom: 1px solid var(--gold-border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  text-decoration: none;
  color: #FFFFFF;
}

.brand-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: var(--gold-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  color: var(--forest-950);
  font-size: 18px;
  letter-spacing: -0.5px;
  box-shadow: 0 2px 10px rgba(197, 160, 89, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.3);
}

.brand-title {
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 1.28rem;
  letter-spacing: 0.8px;
  color: #FFFFFF;
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-title .brand-highlight {
  color: var(--gold-500);
  font-style: italic;
  font-family: var(--font-serif);
}

.brand-badge {
  font-family: var(--font-sans);
  background: var(--gold-gradient);
  color: var(--forest-950);
  font-size: 0.65rem;
  padding: 3px 8px;
  border-radius: 20px;
  font-weight: 800;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  box-shadow: 0 1px 4px rgba(197, 160, 89, 0.4);
}

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

.user-profile-badge {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255, 255, 255, 0.08);
  padding: 4px 14px 4px 6px;
  border-radius: 30px;
  border: 1px solid rgba(197, 160, 89, 0.25);
  backdrop-filter: blur(6px);
}

.user-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--gold-gradient);
  color: var(--forest-950);
  font-weight: 800;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(197, 160, 89, 0.35);
}

.user-info {
  font-size: 0.85rem;
  line-height: 1.2;
}

.user-info strong {
  display: block;
  font-weight: 700;
  color: #FFFFFF;
}

.user-role-tag {
  font-size: 0.68rem;
  color: var(--gold-500);
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
}

.notif-bell-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(197, 160, 89, 0.25);
  color: #FFFFFF;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: var(--transition);
}

.notif-bell-btn:hover {
  background: rgba(197, 160, 89, 0.2);
  border-color: var(--gold-500);
  transform: translateY(-1px);
}

.notif-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  background: var(--danger);
  color: #FFFFFF;
  font-size: 0.68rem;
  font-weight: 800;
  padding: 1px 6px;
  border-radius: 10px;
  border: 2px solid var(--forest-950);
  animation: pulseBadge 2s infinite;
}

@keyframes pulseBadge {
  0% { transform: scale(1); }
  50% { transform: scale(1.1); }
  100% { transform: scale(1); }
}

/* ============================================================================
   SIDEBAR & MAIN LAYOUT
============================================================================ */
.layout {
  display: flex;
  min-height: calc(100vh - 61px);
}

aside.sidebar {
  width: 260px;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  box-shadow: 2px 0 12px rgba(5, 22, 14, 0.03);
  flex-shrink: 0;
}

aside.sidebar nav {
  padding: 18px 12px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.nav-section-title {
  font-size: 0.7rem;
  font-weight: 800;
  color: var(--slate-400);
  text-transform: uppercase;
  letter-spacing: 1.2px;
  padding: 14px 14px 6px 14px;
}

aside.sidebar nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  color: var(--slate-700);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9rem;
  border-radius: var(--radius-md);
  transition: var(--transition);
  position: relative;
}

aside.sidebar nav a svg {
  flex-shrink: 0;
  stroke: var(--slate-400);
  transition: var(--transition);
}

aside.sidebar nav a:hover {
  background: var(--forest-50);
  color: var(--forest-700);
  transform: translateX(2px);
}

aside.sidebar nav a:hover svg {
  stroke: var(--forest-700);
}

aside.sidebar nav a.active {
  background: var(--forest-100);
  color: var(--forest-800);
  font-weight: 700;
  box-shadow: 0 1px 4px rgba(11, 35, 22, 0.05);
}

aside.sidebar nav a.active svg {
  stroke: var(--forest-800);
}

aside.sidebar nav a.active::before {
  content: '';
  position: absolute;
  left: -12px;
  top: 6px;
  bottom: 6px;
  width: 4px;
  border-radius: 0 4px 4px 0;
  background: var(--gold-gradient);
}

main.content {
  flex: 1;
  padding: 28px 36px;
  max-width: 1440px;
  margin: 0 auto;
  width: 100%;
}

/* ============================================================================
   CARDS & LUXURY PANELS
============================================================================ */
.card {
  background: var(--surface-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}

.card:hover {
  box-shadow: var(--shadow-md);
  border-color: rgba(197, 160, 89, 0.22);
}

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

.card-header::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0;
  width: 48px;
  height: 2px;
  background: var(--gold-gradient);
}

.card-title {
  font-family: var(--font-serif);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--forest-900);
  letter-spacing: -0.2px;
}

.card-subtitle {
  font-family: var(--font-sans);
  font-size: 0.82rem;
  color: var(--slate-500);
  margin-top: 4px;
}

/* Quick KPI Stat Tiles */
.stat-tile {
  background: var(--surface-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}

.stat-tile:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: rgba(197, 160, 89, 0.3);
}

.stat-tile::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--forest-700);
}

.stat-tile.gold::after { background: var(--gold-gradient); }
.stat-tile.warning::after { background: var(--warning); }
.stat-tile.danger::after { background: var(--danger); }
.stat-tile.info::after { background: var(--info); }

.stat-label {
  font-size: 0.74rem;
  font-weight: 800;
  color: var(--slate-500);
  text-transform: uppercase;
  letter-spacing: 0.9px;
}

.stat-value {
  font-family: var(--font-sans);
  font-size: 1.95rem;
  font-weight: 800;
  color: var(--forest-900);
  margin-top: 6px;
  line-height: 1.15;
  letter-spacing: -0.5px;
}

.stat-meta {
  font-size: 0.8rem;
  color: var(--slate-500);
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ============================================================================
   TABLES & DATA GRIDS
============================================================================ */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: #FFFFFF;
  box-shadow: var(--shadow-sm);
}

table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.9rem;
}

thead {
  background-color: var(--forest-50);
  border-bottom: 1px solid var(--border-subtle);
}

th {
  padding: 13px 16px;
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--forest-800);
  white-space: nowrap;
}

td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--slate-100);
  vertical-align: middle;
  color: var(--slate-700);
}

tbody tr:last-child td {
  border-bottom: none;
}

tbody tr {
  transition: background-color 0.15s ease;
}

tbody tr:hover {
  background-color: rgba(197, 160, 89, 0.04);
}

/* Filter Bar & Chips */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 18px;
}

.filter-chip {
  padding: 7px 16px;
  border-radius: 20px;
  font-size: 0.82rem;
  font-weight: 600;
  border: 1px solid var(--border-subtle);
  background: #FFFFFF;
  color: var(--slate-700);
  cursor: pointer;
  transition: var(--transition);
}

.filter-chip:hover {
  background: var(--forest-50);
  color: var(--forest-800);
  border-color: var(--forest-200);
}

.filter-chip.active {
  background: var(--forest-700);
  color: #FFFFFF;
  border-color: var(--forest-700);
  box-shadow: 0 2px 6px rgba(22, 87, 53, 0.3);
}

/* Search Input with Icon */
.search-input-wrapper {
  position: relative;
  flex: 1;
  min-width: 240px;
}

.search-input-wrapper svg {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  stroke: var(--slate-400);
  pointer-events: none;
}

.search-input-wrapper input {
  padding-left: 40px;
}

/* ============================================================================
   PROGRESS BARS & GAUGES
============================================================================ */
.progress-bar-container {
  height: 8px;
  background-color: var(--slate-100);
  border-radius: 10px;
  overflow: hidden;
  width: 100%;
}

.progress-bar-fill {
  height: 100%;
  background: var(--forest-gradient);
  border-radius: 10px;
  transition: width 0.4s ease-in-out;
}

.progress-bar-fill.gold {
  background: var(--gold-gradient);
}

/* ============================================================================
   BADGES & STATUS PILLS
============================================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: inline-block;
}

.badge-pending {
  background-color: var(--slate-100);
  color: var(--slate-700);
  border: 1px solid var(--slate-200);
}

.badge-inprogress {
  background-color: #EFF6FF;
  color: #1D4ED8;
  border: 1px solid #BFDBFE;
}

.badge-completed {
  background-color: var(--forest-50);
  color: var(--forest-700);
  border: 1px solid var(--forest-200);
}

.badge-delayed {
  background-color: var(--warning-light);
  color: #B45309;
  border: 1px solid var(--warning-border);
}

.badge-urgent {
  background-color: var(--danger-light);
  color: var(--danger);
  border: 1px solid var(--danger-border);
  font-weight: 800;
  animation: pulseUrgent 1.8s infinite;
}

@keyframes pulseUrgent {
  0% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.4); }
  70% { box-shadow: 0 0 0 6px rgba(220, 38, 38, 0); }
  100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0); }
}

.badge-overdue {
  background-color: #450A0A;
  color: #FCA5A5;
  border: 1px solid var(--danger);
  font-weight: 800;
}

.badge-gold {
  background-color: var(--gold-50);
  color: var(--gold-700);
  border: 1px solid var(--gold-border);
  font-weight: 700;
}

.badge-primary {
  background-color: #EFF6FF;
  color: #1D4ED8;
  border: 1px solid #BFDBFE;
  font-weight: 700;
}

/* ============================================================================
   BUTTONS & ACTIONS
============================================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: var(--transition);
  text-decoration: none;
  line-height: 1;
}

.btn:active {
  transform: scale(0.98);
}

.btn-forest, .btn-primary {
  background: var(--forest-gradient);
  color: #FFFFFF;
  box-shadow: 0 2px 6px rgba(11, 35, 22, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.btn-forest:hover, .btn-primary:hover {
  background: linear-gradient(135deg, #0B2316 0%, #165735 100%);
  box-shadow: 0 4px 12px rgba(11, 35, 22, 0.35);
  transform: translateY(-1px);
}

.btn-gold {
  background: var(--gold-gradient);
  color: var(--forest-950);
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(197, 160, 89, 0.35);
}

.btn-gold:hover {
  background: linear-gradient(135deg, #DFBD47 0%, #B88E28 100%);
  box-shadow: 0 4px 14px rgba(197, 160, 89, 0.45);
  transform: translateY(-1px);
}

.btn-outline {
  background: #FFFFFF;
  border-color: var(--border-subtle);
  color: var(--slate-700);
}

.btn-outline:hover {
  background: var(--forest-50);
  border-color: var(--forest-200);
  color: var(--forest-800);
}

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

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

.btn-whatsapp {
  background: #25D366;
  color: #FFFFFF;
  font-weight: 700;
  box-shadow: 0 2px 6px rgba(37, 211, 102, 0.3);
}

.btn-whatsapp:hover {
  background: #1EBE5D;
  box-shadow: 0 4px 12px rgba(37, 211, 102, 0.4);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.8rem;
  border-radius: var(--radius-sm);
}

/* Action button bar inside table row */
.action-group {
  display: inline-flex;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border-subtle);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.action-group .btn {
  border-radius: 0;
  border: none;
  border-right: 1px solid var(--border-subtle);
}

.action-group .btn:last-child {
  border-right: none;
}

/* ============================================================================
   FORMS & INPUTS
============================================================================ */
.form-group {
  margin-bottom: 18px;
}

label {
  display: block;
  font-size: 0.76rem;
  font-weight: 800;
  color: var(--forest-800);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

input, select, textarea {
  width: 100%;
  padding: 11px 15px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  font-size: 0.94rem;
  outline: none;
  background-color: #FFFFFF;
  color: var(--slate-900);
  transition: var(--transition);
}

input:focus, select:focus, textarea:focus {
  border-color: var(--gold-500);
  box-shadow: 0 0 0 3px rgba(197, 160, 89, 0.2);
}

input::placeholder, textarea::placeholder {
  color: var(--slate-400);
}

/* ============================================================================
   MODALS & OVERLAYS (24px BORDER-RADIUS MATCHING STOICHEMINTERIO.COM)
============================================================================ */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(5, 22, 14, 0.68);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
  animation: fadeInOverlay 0.2s ease-out;
}

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

.modal {
  background: #FFFFFF;
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 30px;
  position: relative;
  border: 1px solid rgba(197, 160, 89, 0.25);
  animation: zoomInModal 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes zoomInModal {
  from { opacity: 0; transform: scale(0.96) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal.modal-lg { max-width: 820px; }
.modal.modal-xl { max-width: 1100px; }

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 22px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border-subtle);
  position: relative;
}

.modal-header::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0;
  width: 50px;
  height: 2px;
  background: var(--gold-gradient);
}

.modal-title {
  font-family: var(--font-serif);
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--forest-900);
  letter-spacing: -0.3px;
}

.close-btn {
  background: var(--forest-50);
  border: 1px solid var(--border-subtle);
  width: 34px;
  height: 34px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--slate-600);
  font-size: 1.15rem;
  transition: var(--transition);
}

.close-btn:hover {
  background: var(--gold-500);
  color: var(--forest-950);
  transform: rotate(90deg);
}

/* ============================================================================
   DIGITAL SIGNATURE CANVAS
============================================================================ */
.signature-box {
  border: 2px dashed rgba(197, 160, 89, 0.45);
  border-radius: var(--radius-md);
  background: var(--bg-page);
  position: relative;
  overflow: hidden;
  margin: 12px 0 16px 0;
}

.signature-canvas {
  width: 100%;
  height: 180px;
  display: block;
  cursor: crosshair;
  touch-action: none;
}

.signature-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 8px;
}

/* ============================================================================
   FLOATING TOAST NOTIFICATIONS
============================================================================ */
#toastContainer {
  position: fixed;
  top: 24px;
  right: 24px;
  z-index: 99999;
  display: flex;
  flex-direction: column;
  gap: 12px;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xl);
  border-left: 5px solid var(--forest-700);
  padding: 16px 20px;
  min-width: 320px;
  max-width: 440px;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  animation: toastSlideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  transition: opacity 0.3s ease, transform 0.3s ease;
  border-top: 1px solid var(--border-subtle);
  border-right: 1px solid var(--border-subtle);
  border-bottom: 1px solid var(--border-subtle);
}

.toast.toast-error {
  border-left-color: var(--danger);
}

.toast.toast-warning {
  border-left-color: var(--warning);
}

.toast.toast-info {
  border-left-color: var(--info);
}

.toast-icon {
  font-size: 1.2rem;
  flex-shrink: 0;
  line-height: 1;
  margin-top: 2px;
}

.toast-content {
  flex: 1;
}

.toast-title {
  font-weight: 700;
  font-size: 0.92rem;
  color: var(--forest-900);
  margin-bottom: 3px;
}

.toast-message {
  font-size: 0.84rem;
  color: var(--slate-600);
  line-height: 1.45;
}

@keyframes toastSlideIn {
  from { opacity: 0; transform: translateX(40px); }
  to { opacity: 1; transform: translateX(0); }
}

/* ============================================================================
   FINDINGS CARDS & QUALITY OPTIMIZATION
============================================================================ */
.finding-card {
  border: 1px solid var(--border-subtle);
  border-left: 4px solid var(--forest-700);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  margin-bottom: 10px;
  background: #FFFFFF;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: var(--transition);
}

.finding-card:hover {
  transform: translateX(3px);
  box-shadow: var(--shadow-sm);
}

.finding-card.High {
  border-left-color: var(--danger);
  background: #FEF2F2;
}

.finding-card.Medium {
  border-left-color: var(--warning);
  background: #FFFBEB;
}

/* ============================================================================
   1-PAGE PRINTABLE WORKSHOP JOB CARD (@media print)
============================================================================ */
@page {
  size: A4 portrait;
  margin: 8mm 8mm 8mm 8mm;
}

@media print {
  body {
    background: #FFFFFF !important;
    background-image: none !important;
    color: #000000 !important;
    font-size: 9.5pt !important;
  }
  header, aside.sidebar, .btn, .header-actions, .modal-overlay, #logoutBtn, .notif-bell-btn, #toastContainer, .mobile-nav-bar {
    display: none !important;
  }
  .layout { display: block !important; margin: 0 !important; padding: 0 !important; }
  main.content { padding: 0 !important; max-width: 100% !important; }
  .card { border: none !important; box-shadow: none !important; padding: 0 !important; }

  .job-card-print {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    padding: 0 !important;
    margin: 0 !important;
    page-break-inside: avoid;
  }
  .job-card-header {
    border-bottom: 2px solid #000 !important;
    padding-bottom: 8px !important;
    margin-bottom: 12px !important;
    display: flex !important;
    justify-content: space-between !important;
  }
  table.print-table {
    width: 100% !important;
    border-collapse: collapse !important;
    margin: 8px 0 !important;
  }
  table.print-table th, table.print-table td {
    border: 1px solid #000 !important;
    padding: 4px 6px !important;
    font-size: 8.5pt !important;
  }
  .print-grid {
    display: grid !important;
    grid-template-columns: repeat(4, 1fr) !important;
    gap: 8px !important;
    margin-top: 14px !important;
  }
  .print-sign-box {
    border: 1px solid #000 !important;
    padding: 6px !important;
    min-height: 70px !important;
    font-size: 8pt !important;
  }
}

/* ============================================================================
   DARK FOREST OBSIDIAN THEME (stoicheminterio.com official Dark Palette)
============================================================================ */
[data-theme="dark"] {
  --bg-page: #05160E;
  --surface-card: #0B2316;
  --surface-subtle: #081B11;
  --slate-900: #F1F5F3;
  --slate-800: #E2E8E4;
  --slate-700: #CBD5CF;
  --slate-600: #94A39B;
  --slate-500: #7A8D83;
  --slate-400: #5C6E64;
  --slate-300: #33443B;
  --slate-200: #1A2E22;
  --slate-100: #0C2819;
  --slate-50:  #081E13;
  --border-subtle: rgba(197, 160, 89, 0.22);
  --border-strong: rgba(197, 160, 89, 0.45);
  --forest-50: #0C2E1D;
  --forest-100: #103D27;
  --forest-200: #1B6935;
}

[data-theme="dark"] body {
  background-color: var(--bg-page);
  background-image: radial-gradient(rgba(197, 160, 89, 0.16) 1px, transparent 1px);
  color: var(--slate-900);
}

[data-theme="dark"] aside.sidebar {
  background: rgba(11, 35, 22, 0.94);
  border-right-color: var(--border-subtle);
}

[data-theme="dark"] aside.sidebar nav a {
  color: var(--slate-700);
}

[data-theme="dark"] aside.sidebar nav a:hover {
  background: rgba(197, 160, 89, 0.12);
  color: var(--gold-500);
}

[data-theme="dark"] aside.sidebar nav a:hover svg {
  stroke: var(--gold-500);
}

[data-theme="dark"] aside.sidebar nav a.active {
  background: rgba(197, 160, 89, 0.2);
  color: #FFFFFF;
}

[data-theme="dark"] .card {
  background: var(--surface-card);
  border-color: var(--border-subtle);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.45);
}

[data-theme="dark"] .card-title {
  color: #FFFFFF;
}

[data-theme="dark"] .stat-tile {
  background: var(--surface-card);
  border-color: var(--border-subtle);
}

[data-theme="dark"] .stat-value {
  color: #FFFFFF;
}

[data-theme="dark"] .table-responsive, [data-theme="dark"] table {
  background: var(--surface-card);
  border-color: var(--border-subtle);
}

[data-theme="dark"] thead {
  background-color: var(--forest-50);
}

[data-theme="dark"] td {
  border-bottom-color: rgba(197, 160, 89, 0.12);
  color: var(--slate-700);
}

[data-theme="dark"] tbody tr:hover {
  background-color: rgba(197, 160, 89, 0.08);
}

[data-theme="dark"] .modal {
  background: #0B2316;
  border-color: rgba(197, 160, 89, 0.35);
  color: #F1F5F3;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.7);
}

[data-theme="dark"] .modal-title {
  color: #FFFFFF;
}

[data-theme="dark"] input, [data-theme="dark"] select, [data-theme="dark"] textarea {
  background-color: #05160E;
  color: #F1F5F3;
  border-color: var(--border-subtle);
}

[data-theme="dark"] .btn-outline {
  background: #0B2316;
  color: var(--slate-700);
  border-color: var(--border-subtle);
}

[data-theme="dark"] .btn-outline:hover {
  background: #165735;
  color: #FFFFFF;
}

[data-theme="dark"] .filter-chip {
  background: #0B2316;
  color: var(--slate-700);
  border-color: var(--border-subtle);
}

[data-theme="dark"] .signature-box {
  background: #05160E;
}

[data-theme="dark"] .toast {
  background: rgba(11, 35, 22, 0.96);
  border-color: var(--border-subtle);
}

[data-theme="dark"] .toast-title {
  color: #FFFFFF;
}

/* ============================================================================
   VISUAL 4-PHASE PROGRESSION BAR
============================================================================ */
.phase-progression-bar {
  display: flex;
  width: 100%;
  gap: 3px;
  margin-top: 5px;
  border-radius: 6px;
  background: rgba(197, 160, 89, 0.12);
  padding: 2px;
}

.phase-step {
  flex: 1;
  height: 6px;
  border-radius: 4px;
  background: var(--slate-200);
  transition: var(--transition);
  position: relative;
}

.phase-step.p1.active, .phase-step.p1.done { background: #3b82f6; }
.phase-step.p2.active, .phase-step.p2.done { background: var(--forest-600); }
.phase-step.p3.active, .phase-step.p3.done { background: var(--gold-500); }
.phase-step.p4.active, .phase-step.p4.done { background: #8b5cf6; }

.phase-step.active::after {
  content: '';
  position: absolute;
  top: -2px;
  left: 50%;
  transform: translateX(-50%);
  width: 4px;
  height: 10px;
  border-radius: 2px;
  background: #FFFFFF;
  box-shadow: 0 0 6px var(--gold-500);
}

/* ============================================================================
   SVG ZERO-NPM VISUAL GAUGES & COST BARS
============================================================================ */
.gauge-container {
  position: relative;
  width: 120px;
  height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.gauge-svg {
  transform: rotate(-90deg);
}

.gauge-center-text {
  position: absolute;
  text-align: center;
}

.cost-stack-bar {
  display: flex;
  width: 100%;
  height: 16px;
  border-radius: 8px;
  overflow: hidden;
  margin: 14px 0 10px 0;
  background: var(--slate-100);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1);
}

.cost-segment {
  height: 100%;
  transition: width 0.4s ease;
}

/* ============================================================================
   MOBILE BOTTOM NAVIGATION BAR (< 768px)
============================================================================ */
.mobile-nav-bar {
  display: none;
}

@media (max-width: 768px) {
  .mobile-nav-bar {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: rgba(5, 22, 14, 0.96);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-top: 1px solid var(--gold-border);
    z-index: 999;
    justify-content: space-around;
    align-items: center;
    padding: 0 6px;
  }

  .mobile-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--slate-400);
    text-decoration: none;
    font-size: 0.65rem;
    font-weight: 700;
    gap: 3px;
    flex: 1;
    padding: 6px 0;
    transition: var(--transition);
  }

  .mobile-nav-item.active {
    color: var(--gold-500);
  }

  .mobile-nav-item svg {
    stroke: currentColor;
  }

  body {
    padding-bottom: 74px;
  }

  /* Off-canvas Mobile Sidebar Drawer */
  .layout {
    flex-direction: column;
  }

  aside.sidebar {
    position: fixed;
    top: 60px;
    bottom: 0;
    left: 0;
    width: 280px;
    max-width: 85vw;
    background: var(--forest-950);
    z-index: 1000;
    transform: translateX(-100%);
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.4);
    border-right: 1px solid var(--gold-border);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    display: block;
  }

  body.sidebar-open aside.sidebar {
    transform: translateX(0);
  }

  #sidebarBackdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 999;
  }

  body.sidebar-open #sidebarBackdrop {
    display: block;
  }

  /* Hamburger Toggle in Header */
  .mobile-menu-btn {
    display: flex !important;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    color: #fff;
    cursor: pointer;
    margin-right: 8px;
  }

  header {
    height: 60px;
    padding: 0 10px;
  }

  .header-actions {
    gap: 6px;
  }

  .user-profile-badge {
    padding: 3px 6px;
  }

  .user-profile-badge strong {
    display: none;
  }

  #changeMasterPasswordBtn, #logoutBtn {
    display: none;
  }

  main.content {
    padding: 12px 10px 84px 10px;
    max-width: 100vw;
    overflow-x: hidden;
  }

  /* Cards & Spacing on Mobile */
  .card {
    padding: 14px 12px !important;
    margin-bottom: 14px !important;
    border-radius: 10px !important;
  }

  /* Modals: full touch sheet */
  .modal {
    width: 95vw !important;
    max-width: 95vw !important;
    max-height: 88vh !important;
    padding: 16px !important;
    margin: auto !important;
    border-radius: 12px !important;
  }

  .modal-overlay {
    padding: 10px;
    align-items: center;
    justify-content: center;
  }

  /* Touch-friendly inputs */
  input, select, textarea {
    font-size: 16px !important; /* Prevents auto-zoom on mobile safari/chrome */
    min-height: 40px;
  }

  .btn {
    min-height: 38px;
    touch-action: manipulation;
  }
}

@media (min-width: 769px) {
  .mobile-menu-btn {
    display: none !important;
  }
  #sidebarBackdrop {
    display: none !important;
  }
}

/* Responsive adjustments */
@media (max-width: 900px) and (min-width: 769px) {
  .layout { flex-direction: column; }
  aside.sidebar { width: 100%; border-right: none; border-bottom: 1px solid var(--border-subtle); }
  main.content { padding: 18px; }
}
