/* ============================================
   DaCucina ERP — Design System
   Luxury kitchen brand: warm cream + copper (LIGHT BY DEFAULT)
   Dark mode via body.dark
   ============================================ */

:root {
  /* ========== LIGHT THEME (default) ========== */

  /* Backgrounds — warm cream/ivory */
  --bg-primary: #f8f5f0;      /* warm cream — main page bg */
  --bg-secondary: #ffffff;     /* white — cards, sidebar */
  --bg-tertiary: #f1ece4;      /* light beige — inputs, hover */
  --bg-elevated: #ebe5dc;      /* darker cream — popups */
  --bg-hover: #e5ddd1;          /* hover state */

  /* Copper / gold accents (DaCucina brand — same in both themes) */
  --accent-primary: #b88857;
  --accent-hover: #a07444;
  --accent-light: rgba(184, 136, 87, 0.10);
  --accent-glow: rgba(184, 136, 87, 0.20);

  /* Walnut */
  --walnut: #8b6346;
  --walnut-light: rgba(139, 99, 70, 0.10);

  /* Text — dark on light bg */
  --text-primary: #2a1f15;     /* warm charcoal */
  --text-secondary: #5c4a3a;
  --text-tertiary: #8c7a68;
  --text-muted: #b8a99a;

  /* Borders — subtle warm */
  --border-subtle: rgba(42, 31, 21, 0.06);
  --border-default: rgba(42, 31, 21, 0.12);
  --border-strong: rgba(42, 31, 21, 0.22);
  --border-accent: rgba(184, 136, 87, 0.40);

  /* Status colors (a tad darker so they're readable on cream) */
  --success: #16a34a;
  --success-bg: rgba(22, 163, 74, 0.10);
  --warning: #ca8a04;
  --warning-bg: rgba(202, 138, 4, 0.10);
  --danger: #dc2626;
  --danger-bg: rgba(220, 38, 38, 0.10);
  --info: #2563eb;
  --info-bg: rgba(37, 99, 235, 0.10);

  /* Status palette for leads/files */
  --status-new: #2563eb;
  --status-progress: #b88857;
  --status-pending: #ca8a04;
  --status-complete: #16a34a;
  --status-stuck: #dc2626;

  /* Layout */
  --sidebar-width: 260px;
  --topbar-height: 64px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;

  /* Transitions */
  --t-fast: 0.15s ease;
  --t-base: 0.25s ease;
  --t-slow: 0.4s cubic-bezier(0.4, 0, 0.2, 1);

  /* Fonts */
  /* Hebrew-first font stack — fallback covers Mac/Windows/Linux/Android Hebrew rendering even when Google Fonts fail */
  --font-sans: 'Heebo', 'Assistant', 'Segoe UI', 'Arial Hebrew', 'Tahoma', -apple-system, BlinkMacSystemFont, system-ui, 'Noto Sans Hebrew', sans-serif;
  --font-display: 'Heebo', 'Assistant', 'Segoe UI', 'Arial Hebrew', 'Tahoma', sans-serif;

  /* Shadow (heavier on light theme to give depth) */
  --shadow-sm: 0 1px 3px rgba(42, 31, 21, 0.08);
  --shadow-md: 0 4px 12px rgba(42, 31, 21, 0.10);
  --shadow-lg: 0 12px 32px rgba(42, 31, 21, 0.14);
}

/* ========== DARK THEME (toggleable) ========== */
body.dark {
  --bg-primary: #0f1115;
  --bg-secondary: #161922;
  --bg-tertiary: #1c2030;
  --bg-elevated: #232838;
  --bg-hover: #2a3045;

  --accent-primary: #c89d6b;
  --accent-hover: #d9b083;
  --accent-light: rgba(200, 157, 107, 0.12);
  --accent-glow: rgba(200, 157, 107, 0.25);

  --walnut: #8b6346;
  --walnut-light: rgba(139, 99, 70, 0.15);

  --text-primary: #f5f1ea;
  --text-secondary: #b8b3a8;
  --text-tertiary: #8a8578;
  --text-muted: #5d5a52;

  --border-subtle: rgba(245, 241, 234, 0.06);
  --border-default: rgba(245, 241, 234, 0.10);
  --border-strong: rgba(245, 241, 234, 0.18);
  --border-accent: rgba(200, 157, 107, 0.35);

  --success: #4ade80;
  --success-bg: rgba(74, 222, 128, 0.10);
  --warning: #fbbf24;
  --warning-bg: rgba(251, 191, 36, 0.10);
  --danger: #f87171;
  --danger-bg: rgba(248, 113, 113, 0.10);
  --info: #60a5fa;
  --info-bg: rgba(96, 165, 250, 0.10);

  --status-new: #60a5fa;
  --status-progress: #c89d6b;
  --status-pending: #fbbf24;
  --status-complete: #4ade80;
  --status-stuck: #f87171;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.30);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.40);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.50);
}

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

html, body {
  height: 100%;
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.6;
  overflow: hidden;
  direction: rtl;
}

html.public-signature-mode,
body.public-signature-mode {
  height: auto;
  min-height: 100%;
  overflow-x: hidden;
  overflow-y: auto !important;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
}

body.public-signature-mode {
  background: #f8f5f0;
  padding-bottom: 0;
}

.public-sign-page {
  min-height: 100vh;
  min-height: 100dvh;
  overflow: visible;
  padding-bottom: calc(2rem + env(safe-area-inset-bottom));
}

.public-sign-shell {
  width: 100%;
}

.public-sign-actions {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 1rem;
}

.public-sign-submit {
  min-height: 48px;
}

.signature-canvas-wrap,
.signature-canvas {
  max-width: 100%;
}

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

button { cursor: pointer; border: none; background: none; }
a { color: inherit; text-decoration: none; cursor: pointer; }

/* Custom scrollbar */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent-primary); }

/* ============================================
   LOGIN SCREEN
   ============================================ */
.login-screen {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--bg-primary);
  z-index: 1000;
  overflow: hidden;
}
.login-screen.active { display: flex; align-items: center; justify-content: center; }

.login-bg-decoration {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(135deg, rgba(20, 16, 12, 0.45) 0%, rgba(40, 30, 22, 0.55) 100%),
    url('img/kitchen-hero.jpg');
  background-size: cover;
  background-position: center center;
  background-repeat: no-repeat;
  pointer-events: none;
}
.login-bg-decoration::after {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 20% 30%, rgba(200, 157, 107, 0.18) 0%, transparent 60%),
    radial-gradient(circle at 80% 80%, rgba(139, 99, 70, 0.15) 0%, transparent 50%);
  pointer-events: none;
}

.login-container {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 480px;
  padding: 2rem;
}

.login-card {
  background: rgba(28, 22, 16, 0.92);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border: 1px solid rgba(200, 157, 107, 0.35);
  border-radius: var(--radius-xl);
  padding: 2.5rem;
  box-shadow:
    0 25px 60px rgba(0, 0, 0, 0.5),
    0 0 0 1px rgba(200, 157, 107, 0.1) inset;
}

.login-brand {
  text-align: center;
  margin-bottom: 2rem;
  padding-bottom: 2rem;
  border-bottom: 1px solid var(--border-subtle);
}

.brand-logo {
  width: 72px;
  height: 72px;
  margin: 0 auto 1rem;
  background: linear-gradient(135deg, var(--accent-primary) 0%, var(--walnut) 100%);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 24px var(--accent-glow);
}

.brand-mark {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 700;
  color: var(--bg-primary);
  letter-spacing: -0.5px;
}

.brand-name {
  font-size: 32px;
  font-weight: 300;
  color: var(--text-primary);
  letter-spacing: 1px;
  margin-bottom: 0.25rem;
}

.brand-tagline {
  font-size: 11px;
  color: var(--accent-primary);
  letter-spacing: 3px;
  text-transform: uppercase;
  font-weight: 500;
}

.brand-divider {
  width: 40px;
  height: 1px;
  background: var(--accent-primary);
  margin: 1rem auto;
  opacity: 0.5;
}

.brand-system {
  font-size: 13px;
  color: var(--text-secondary);
  letter-spacing: 0.5px;
}

.login-form { display: flex; flex-direction: column; gap: 1rem; }

.field-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 0.4rem;
  display: block;
  letter-spacing: 0.3px;
}

.text-input, .select-input, .textarea-input {
  width: 100%;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem;
  color: var(--text-primary);
  font-size: 14px;
  transition: all var(--t-fast);
  outline: none;
}

.text-input:hover, .select-input:hover, .textarea-input:hover {
  border-color: var(--border-strong);
}
.text-input:focus, .select-input:focus, .textarea-input:focus {
  border-color: var(--accent-primary);
  background: var(--bg-elevated);
  box-shadow: 0 0 0 3px var(--accent-light);
}

.textarea-input { resize: vertical; min-height: 80px; font-family: inherit; }

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
.form-field { display: flex; flex-direction: column; }

.btn-primary {
  background: linear-gradient(135deg, var(--accent-primary) 0%, #a07444 100%);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-md);
  padding: 0.85rem 1.5rem;
  font-weight: 600;
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: all var(--t-base);
  letter-spacing: 0.3px;
  cursor: pointer;
}
.btn-primary:hover {
  background: linear-gradient(135deg, var(--accent-hover) 0%, #c89d6b 100%);
  box-shadow: 0 4px 20px var(--accent-glow);
  transform: translateY(-1px);
}
.btn-primary:active { transform: translateY(0); }
.btn-block { width: 100%; margin-top: 0.5rem; }

.btn-secondary {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: 0.65rem 1.25rem;
  font-weight: 500;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  transition: all var(--t-fast);
}
.btn-secondary:hover {
  background: var(--bg-hover);
  border-color: var(--border-strong);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  padding: 0.5rem 0.9rem;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  transition: all var(--t-fast);
}
.btn-ghost:hover { background: var(--bg-elevated); color: var(--text-primary); }

.btn-danger {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid rgba(248, 113, 113, 0.25);
  border-radius: var(--radius-md);
  padding: 0.5rem 1rem;
  font-size: 13px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}
.btn-danger:hover { background: rgba(248, 113, 113, 0.2); }

.login-footer {
  text-align: center;
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border-subtle);
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.5px;
}
.version-sep { margin: 0 0.5rem; opacity: 0.5; }
.env-tag { color: var(--accent-primary); }

/* ============================================
   APP SHELL
   ============================================ */
.app-shell {
  display: none;
  height: 100vh;
  overflow: hidden;
}
.app-shell.active { display: flex; }

/* ============================================
   SIDEBAR
   ============================================ */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-secondary);
  border-left: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.sidebar-brand {
  padding: 1.25rem 1.25rem;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand-logo-small {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, var(--accent-primary) 0%, var(--walnut) 100%);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--bg-primary);
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -0.5px;
}

.brand-text { display: flex; flex-direction: column; }
.brand-name-small {
  font-size: 16px;
  font-weight: 500;
  color: var(--text-primary);
  letter-spacing: 0.5px;
}
.brand-sub {
  font-size: 10px;
  color: var(--accent-primary);
  letter-spacing: 1.5px;
  text-transform: uppercase;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.nav-section { display: flex; flex-direction: column; gap: 0.15rem; }
.nav-section-title {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  padding: 0 0.75rem 0.4rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0.75rem;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 13.5px;
  font-weight: 400;
  transition: all var(--t-fast);
  position: relative;
}
.nav-item i { font-size: 18px; flex-shrink: 0; opacity: 0.85; }
.nav-item span { flex: 1; }

.nav-item:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.nav-item.active {
  background: var(--accent-light);
  color: var(--accent-primary);
  font-weight: 500;
}
.nav-item.active::before {
  content: '';
  position: absolute;
  right: -0.75rem;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 60%;
  background: var(--accent-primary);
  border-radius: 2px;
}
.nav-item.active i { opacity: 1; }

.nav-badge {
  background: var(--bg-elevated);
  color: var(--text-tertiary);
  font-size: 10px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 10px;
  min-width: 20px;
  text-align: center;
}
.nav-item.active .nav-badge {
  background: var(--accent-primary);
  color: var(--bg-primary);
}

.sidebar-footer {
  padding: 0.75rem;
  border-top: 1px solid var(--border-subtle);
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.5rem 0.6rem;
  border-radius: var(--radius-md);
  background: var(--bg-tertiary);
  transition: all var(--t-fast);
}
.user-chip:hover { background: var(--bg-elevated); }

.user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-primary), var(--walnut));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--bg-primary);
  flex-shrink: 0;
}

.user-info { flex: 1; min-width: 0; }
.user-name {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-role {
  display: block;
  font-size: 10.5px;
  color: var(--accent-primary);
  letter-spacing: 0.3px;
}

.logout-btn {
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-tertiary);
  transition: all var(--t-fast);
}
.logout-btn:hover { background: var(--bg-hover); color: var(--danger); }
.logout-btn i { font-size: 16px; }

/* ============================================
   MAIN CONTENT
   ============================================ */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.topbar {
  height: var(--topbar-height);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-subtle);
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.topbar-left { display: flex; align-items: baseline; gap: 0.75rem; }
.page-title {
  font-size: 18px;
  font-weight: 500;
  color: var(--text-primary);
  letter-spacing: 0.3px;
}
.breadcrumb {
  font-size: 12px;
  color: var(--text-tertiary);
  padding-right: 0.75rem;
  border-right: 1px solid var(--border-default);
}

.topbar-right { display: flex; align-items: center; gap: 0.6rem; }

.search-box {
  position: relative;
  width: 320px;
}
.search-box i {
  position: absolute;
  right: 0.85rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-tertiary);
  font-size: 16px;
}
.search-box input {
  width: 100%;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: 0.55rem 2.4rem 0.55rem 1rem;
  color: var(--text-primary);
  font-size: 13px;
  outline: none;
  transition: all var(--t-fast);
}
.search-box input:focus {
  border-color: var(--accent-primary);
  background: var(--bg-elevated);
}

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  background: var(--bg-tertiary);
  border: 1px solid var(--border-default);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  position: relative;
  transition: all var(--t-fast);
}
.icon-btn:hover { background: var(--bg-elevated); color: var(--accent-primary); }
.icon-btn i { font-size: 18px; }
.notification-dot {
  position: absolute;
  top: 8px;
  left: 8px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent-primary);
  box-shadow: 0 0 0 2px var(--bg-secondary);
}

/* ============================================
   VIEW CONTAINER
   ============================================ */
.view-container {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
}

.view {
  display: none;
  animation: fadeInUp 0.3s ease;
}
.view.active { display: block; }

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

/* ============================================
   DASHBOARD
   ============================================ */
.dashboard-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.dashboard-greeting {
  font-size: 22px;
  font-weight: 400;
  color: var(--text-primary);
  margin-bottom: 0.25rem;
}
.dashboard-greeting .accent { color: var(--accent-primary); font-weight: 500; }
.dashboard-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
}

.dashboard-actions { display: flex; gap: 0.5rem; }

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.kpi-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  transition: all var(--t-base);
  position: relative;
  overflow: hidden;
}
.kpi-card:hover {
  border-color: var(--border-accent);
  transform: translateY(-2px);
}

.kpi-card::before {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 3px;
  height: 100%;
  background: var(--accent-primary);
  opacity: 0;
  transition: opacity var(--t-base);
}
.kpi-card:hover::before { opacity: 1; }

.kpi-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.kpi-icon {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  background: var(--accent-light);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-primary);
}
.kpi-icon i { font-size: 18px; }

.kpi-trend {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  gap: 3px;
}
.kpi-trend.up { background: var(--success-bg); color: var(--success); }
.kpi-trend.down { background: var(--danger-bg); color: var(--danger); }
.kpi-trend.neutral { background: var(--bg-tertiary); color: var(--text-tertiary); }

.kpi-value {
  font-size: 28px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.5px;
  line-height: 1.1;
  margin-bottom: 0.2rem;
}

.kpi-label {
  font-size: 12px;
  color: var(--text-secondary);
  letter-spacing: 0.3px;
}

/* Dashboard grid 2-col */
.dashboard-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}
@media (max-width: 1200px) { .dashboard-grid { grid-template-columns: 1fr; } }

.panel {
  background: var(--bg-secondary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.panel-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.panel-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.panel-title i {
  color: var(--accent-primary);
  font-size: 18px;
}

.panel-action {
  font-size: 12px;
  color: var(--accent-primary);
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: all var(--t-fast);
}
.panel-action:hover { background: var(--accent-light); }

.panel-body { padding: 1rem 1.25rem; }
.panel-body.no-padding { padding: 0; }

/* Pipeline visualization */
.pipeline {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.pipeline-stage {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0.85rem;
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  transition: all var(--t-fast);
}
.pipeline-stage:hover {
  background: var(--bg-elevated);
  border-color: var(--border-default);
}
.pipeline-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.pipeline-name { flex: 1; font-size: 13px; color: var(--text-primary); }
.pipeline-count {
  font-size: 16px;
  font-weight: 600;
  color: var(--accent-primary);
}
.pipeline-bar {
  width: 80px;
  height: 4px;
  background: var(--bg-primary);
  border-radius: 2px;
  overflow: hidden;
}
.pipeline-bar-fill {
  height: 100%;
  background: var(--accent-primary);
  border-radius: 2px;
}

/* ============================================
   TABLES
   ============================================ */
.table-wrapper {
  overflow-x: auto;
  background: var(--bg-secondary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table thead {
  background: var(--bg-tertiary);
}
.data-table th {
  text-align: right;
  padding: 0.85rem 1rem;
  font-weight: 500;
  font-size: 11.5px;
  color: var(--text-tertiary);
  letter-spacing: 0.5px;
  text-transform: uppercase;
  border-bottom: 1px solid var(--border-subtle);
  white-space: nowrap;
}

.data-table td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-primary);
  vertical-align: middle;
}

.data-table tbody tr {
  transition: background var(--t-fast);
  cursor: pointer;
}
.data-table tbody tr:hover { background: var(--bg-tertiary); }
.data-table tbody tr:last-child td { border-bottom: none; }

.cell-id {
  font-family: 'Courier New', monospace;
  font-size: 12px;
  color: var(--accent-primary);
  font-weight: 600;
}

.cell-name { font-weight: 500; }
.cell-name .sub {
  display: block;
  font-size: 11.5px;
  color: var(--text-tertiary);
  font-weight: 400;
  margin-top: 2px;
}

/* ============================================
   BADGES & STATUS PILLS
   ============================================ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: 0.2px;
  white-space: nowrap;
}
.badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.badge-new      { background: rgba(96, 165, 250, 0.12); color: #60a5fa; }
.badge-progress { background: var(--accent-light); color: var(--accent-primary); }
.badge-pending  { background: var(--warning-bg); color: var(--warning); }
.badge-complete { background: var(--success-bg); color: var(--success); }
.badge-stuck    { background: var(--danger-bg); color: var(--danger); }
.badge-info     { background: var(--info-bg); color: var(--info); }
.badge-neutral  { background: var(--bg-elevated); color: var(--text-secondary); }
.badge-walnut   { background: var(--walnut-light); color: #b48666; }

/* ============================================
   TOOLBAR (above tables)
   ============================================ */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.toolbar-left, .toolbar-right { display: flex; align-items: center; gap: 0.5rem; }

.filter-chip {
  padding: 0.45rem 0.85rem;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  font-size: 12.5px;
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  transition: all var(--t-fast);
}
.filter-chip:hover { border-color: var(--border-strong); color: var(--text-primary); }
.filter-chip.active {
  background: var(--accent-light);
  border-color: var(--border-accent);
  color: var(--accent-primary);
}
.filter-chip .chip-count {
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 10.5px;
  padding: 1px 6px;
  border-radius: 8px;
  font-weight: 600;
}

/* Premium appointment filter tabs */
.dc-appt-filter-shell {
  direction: rtl;
  display: flex;
  justify-content: flex-start;
  align-items: center;
  width: 100%;
  margin: 0;
  padding: 14px;
  border: 1px solid rgba(167, 132, 82, 0.18);
  border-radius: 22px;
  background:
    radial-gradient(circle at 85% 0%, rgba(180, 134, 70, 0.08), transparent 32%),
    linear-gradient(180deg, rgba(255,255,255,0.88), rgba(248,245,239,0.74));
  box-shadow: 0 12px 34px rgba(58, 43, 24, 0.06);
}

.dc-appt-filter-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.dc-appt-filter-tab {
  appearance: none;
  border: 1px solid rgba(120, 95, 63, 0.16);
  background: rgba(255, 255, 255, 0.76);
  color: #4b3a2a;
  min-height: 46px;
  padding: 8px 14px 8px 10px;
  border-radius: 15px;
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-weight: 700;
  transition:
    transform 160ms ease,
    box-shadow 160ms ease,
    border-color 160ms ease,
    background 160ms ease,
    color 160ms ease;
  box-shadow: 0 5px 16px rgba(58, 43, 24, 0.045);
}

.dc-appt-filter-tab:hover {
  transform: translateY(-1px);
  border-color: rgba(170, 127, 67, 0.38);
  background: rgba(255, 252, 246, 0.96);
  box-shadow: 0 10px 24px rgba(58, 43, 24, 0.08);
}

.dc-appt-filter-tab.is-active {
  color: #8a5c20;
  border-color: rgba(176, 126, 57, 0.62);
  background: linear-gradient(180deg, #fffaf2 0%, #f4eadb 100%);
  box-shadow:
    0 12px 28px rgba(150, 102, 38, 0.15),
    inset 0 1px 0 rgba(255,255,255,0.9);
}

.dc-appt-filter-icon {
  width: 28px;
  height: 28px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #a8793e;
  background: rgba(170, 127, 67, 0.10);
  flex: 0 0 auto;
}

.dc-appt-filter-tab.is-active .dc-appt-filter-icon {
  color: #8a5c20;
  background: rgba(170, 127, 67, 0.16);
}

.dc-appt-filter-count {
  min-width: 34px;
  height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  color: #2f241a;
  background: rgba(255,255,255,0.86);
  box-shadow: inset 0 0 0 1px rgba(120,95,63,0.08);
}

.dc-appt-filter-label {
  white-space: nowrap;
  font-size: 14px;
}

@media (max-width: 900px) {
  .dc-appt-filter-shell {
    padding: 10px;
    border-radius: 18px;
  }

  .dc-appt-filter-tabs {
    width: 100%;
  }

  .dc-appt-filter-tab {
    flex: 1 1 calc(50% - 8px);
    justify-content: center;
  }
}

/* ============================================
   ACTION BUTTONS IN TABLES
   ============================================ */
.row-actions {
  display: flex;
  gap: 4px;
}
.row-action-btn {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--t-fast);
}
.row-action-btn:hover {
  background: var(--bg-elevated);
  color: var(--accent-primary);
}
.row-action-btn.danger:hover { color: var(--danger); }
.row-action-btn i { font-size: 15px; }

/* ============================================
   MODAL
   ============================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(42, 31, 21, 0.35);
  backdrop-filter: blur(4px);
  z-index: 2000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  overflow-y: auto;
}
body.dark .modal-overlay {
  background: rgba(0, 0, 0, 0.6);
}
.modal-overlay.active {
  display: flex;
  animation: fadeIn 0.2s ease;
}

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

.modal-container {
  background: transparent;
  border: none;
  max-width: 100%;
  width: 100%;
  max-height: 100%;
  overflow: visible;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-container > .modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xl);
  max-width: 900px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: scaleIn 0.25s var(--t-slow);
}

@keyframes scaleIn {
  from { transform: scale(0.95); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  background: var(--bg-secondary);
  z-index: 10;
}

.modal-title {
  font-size: 17px;
  font-weight: 500;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.modal-title i { color: var(--accent-primary); font-size: 22px; }

.modal-close {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--t-fast);
}
.modal-close:hover { background: var(--danger-bg); color: var(--danger); }
.modal-close i { font-size: 16px; }

.modal-body { padding: 1.5rem; }

.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  position: sticky;
  bottom: 0;
  background: var(--bg-secondary);
}

/* ============================================
   FORM LAYOUTS
   ============================================ */
.form-section {
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  margin-bottom: 1rem;
}
.form-section-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--accent-primary);
  margin-bottom: 1rem;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  letter-spacing: 0.3px;
}
.form-section-title i { font-size: 16px; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
}
.form-grid-3 { grid-template-columns: repeat(3, 1fr); }
.form-grid-4 { grid-template-columns: repeat(4, 1fr); }
.form-field-full { grid-column: 1 / -1; }

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

.required { color: var(--accent-primary); margin-right: 2px; }

.field-hint {
  font-size: 11px;
  color: var(--text-tertiary);
  margin-top: 0.3rem;
}

/* Conditional field reveal */
.conditional-field {
  max-height: 0;
  overflow: hidden;
  transition: max-height var(--t-slow);
}
.conditional-field.show { max-height: 500px; }

/* ============================================
   TOAST NOTIFICATIONS
   ============================================ */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  left: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  z-index: 3000;
  pointer-events: none;
}

.toast {
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: 0.75rem 1.1rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-width: 280px;
  max-width: 400px;
  box-shadow: var(--shadow-lg);
  animation: slideInLeft 0.3s ease;
  pointer-events: all;
}

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

.toast i { font-size: 18px; flex-shrink: 0; }
.toast.success i { color: var(--success); }
.toast.info i    { color: var(--info, #2563eb); }
.toast.warning i { color: var(--warning); }
.toast.error i   { color: var(--danger); }

/* Colored accent border — type immediately obvious (Stage 16) */
.toast.success { border-right: 4px solid var(--success); }
.toast.error   { border-right: 4px solid var(--danger); }
.toast.warning { border-right: 4px solid var(--warning); }
.toast.info    { border-right: 4px solid var(--info, #2563eb); }

.toast-msg { flex: 1; font-size: 13px; }
.toast-title { font-weight: 500; display: block; }
.toast-text { font-size: 12px; color: var(--text-secondary); display: block; }

/* ============================================
   ALERT ROWS — dc-alert-* utility classes (Stage 16)
   Usage: <div class="dc-alert-error">…</div>
   Solid, opaque backgrounds — no transparency issues
   ============================================ */
.dc-alert-row {
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
  padding: 0.7rem 1rem;
  border-radius: 8px;
  margin-bottom: 0.45rem;
  font-size: 13px;
  line-height: 1.55;
  font-weight: 450;
}
.dc-alert-row i { flex-shrink: 0; margin-top: 2px; font-size: 15px; }

/* Error — solid red-tinted card */
.dc-alert-error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-right: 3px solid var(--danger);
  color: #7f1d1d;
}
.dc-alert-error i { color: var(--danger); }

/* Warning — solid amber-tinted card */
.dc-alert-warning {
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-right: 3px solid var(--warning);
  color: #78350f;
}
.dc-alert-warning i { color: var(--warning); }

/* Info — solid blue-tinted card */
.dc-alert-info {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-right: 3px solid var(--info, #2563eb);
  color: #1e3a5f;
}
.dc-alert-info i { color: var(--info, #2563eb); }

/* Success — solid green-tinted card */
.dc-alert-success {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-right: 3px solid var(--success);
  color: #14532d;
}
.dc-alert-success i { color: var(--success); }

/* Dark-mode overrides */
body.dark .dc-alert-error   { background: rgba(248,113,113,.13); border-color: rgba(248,113,113,.3); border-right-color: var(--danger); color: #fca5a5; }
body.dark .dc-alert-warning { background: rgba(251,191,36,.12);  border-color: rgba(251,191,36,.3);  border-right-color: var(--warning); color: #fde68a; }
body.dark .dc-alert-info    { background: rgba(96,165,250,.12);  border-color: rgba(96,165,250,.3);  border-right-color: var(--info,#60a5fa); color: #93c5fd; }
body.dark .dc-alert-success { background: rgba(74,222,128,.12);  border-color: rgba(74,222,128,.3);  border-right-color: var(--success); color: #86efac; }

/* cw-info-banner / cw-warning-banner — reusable across workspaces (Stage 16) */
.cw-info-banner    { display:flex; align-items:center; gap:.5rem; font-size:12.5px; border-radius:8px; padding:.6rem .9rem; margin-bottom:.75rem; background:#eff6ff; border:1px solid #bfdbfe; color:#1d4ed8; }
.cw-warning-banner { display:flex; align-items:center; gap:.5rem; font-size:12.5px; border-radius:8px; padding:.6rem .9rem; margin-bottom:.75rem; background:#fffbeb; border:1px solid #fde68a; color:#92400e; }
.cw-all-good       { display:flex; align-items:center; gap:.5rem; font-size:12.5px; border-radius:8px; padding:.6rem .9rem; margin-bottom:1rem;   background:#f0fdf4; border:1px solid #bbf7d0; color:#15803d; }
body.dark .cw-info-banner    { background:rgba(96,165,250,.12);  border-color:rgba(96,165,250,.3);  color:#93c5fd; }
body.dark .cw-warning-banner { background:rgba(251,191,36,.12);  border-color:rgba(251,191,36,.3);  color:#fde68a; }
body.dark .cw-all-good       { background:rgba(74,222,128,.12);  border-color:rgba(74,222,128,.3);  color:#86efac; }

/* ============================================
   EMPTY STATES
   ============================================ */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-tertiary);
}
.empty-state i {
  font-size: 48px;
  color: var(--text-muted);
  margin-bottom: 1rem;
  display: block;
}
.empty-state-title {
  font-size: 15px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 0.4rem;
}
.empty-state-text {
  font-size: 13px;
  margin-bottom: 1.25rem;
}

/* ============================================
   TABS
   ============================================ */
.tabs {
  display: flex;
  gap: 0.25rem;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 1.25rem;
  padding: 0 0.25rem;
  overflow-x: auto;
}
.tab {
  padding: 0.75rem 1.1rem;
  font-size: 13px;
  color: var(--text-secondary);
  border-bottom: 2px solid transparent;
  transition: all var(--t-fast);
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}
.tab i { font-size: 15px; }
.tab:hover { color: var(--text-primary); }
.tab.active {
  color: var(--accent-primary);
  border-bottom-color: var(--accent-primary);
  font-weight: 500;
}

/* ============================================
   STEPPER (workflow visualization)
   ============================================ */
.stepper {
  display: flex;
  align-items: flex-start;
  padding: 1.25rem 0;
  margin-bottom: 1.25rem;
  overflow-x: auto;
  gap: 0;
}

.step {
  flex: 1;
  min-width: 110px;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  text-align: center;
}

.step-circle {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--bg-tertiary);
  border: 2px solid var(--border-default);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-tertiary);
  font-weight: 600;
  font-size: 13px;
  position: relative;
  z-index: 2;
  transition: all var(--t-base);
}
.step-circle i { font-size: 16px; }

.step.done .step-circle {
  background: var(--success-bg);
  border-color: var(--success);
  color: var(--success);
}
.step.active .step-circle {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
  color: var(--bg-primary);
  box-shadow: 0 0 0 4px var(--accent-glow);
}

.step-label {
  font-size: 11.5px;
  color: var(--text-tertiary);
  margin-top: 0.5rem;
  font-weight: 500;
}
.step.done .step-label, .step.active .step-label { color: var(--text-primary); }

.step-connector {
  position: absolute;
  top: 18px;
  right: 50%;
  width: 100%;
  height: 2px;
  background: var(--border-default);
  z-index: 1;
}
.step:first-child .step-connector { display: none; }
.step.done .step-connector, .step.active .step-connector { background: var(--accent-primary); }

/* ============================================
   PERMISSION MATRIX
   ============================================ */
.permission-matrix {
  overflow-x: auto;
  background: var(--bg-secondary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
}

.perm-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}
.perm-table th, .perm-table td {
  padding: 0.6rem 0.7rem;
  border-bottom: 1px solid var(--border-subtle);
  border-left: 1px solid var(--border-subtle);
  text-align: center;
}
.perm-table th:first-child, .perm-table td:first-child {
  text-align: right;
  font-weight: 500;
  background: var(--bg-tertiary);
  position: sticky;
  right: 0;
  z-index: 1;
}
.perm-table thead th {
  background: var(--bg-tertiary);
  color: var(--text-tertiary);
  font-weight: 500;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  white-space: nowrap;
}

.perm-checkbox {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  border: 1.5px solid var(--border-strong);
  background: var(--bg-tertiary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--t-fast);
}
.perm-checkbox.checked {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
}
.perm-checkbox.checked::after {
  content: '✓';
  color: var(--bg-primary);
  font-size: 12px;
  font-weight: 700;
}

/* ============================================
   UTILITY CLASSES
   ============================================ */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 0.25rem; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.gap-4 { gap: 1rem; }
.mt-1 { margin-top: 0.5rem; } .mt-2 { margin-top: 1rem; } .mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; } .mb-2 { margin-bottom: 1rem; } .mb-3 { margin-bottom: 1.5rem; }
.text-secondary { color: var(--text-secondary); }
.text-tertiary { color: var(--text-tertiary); }
.text-accent { color: var(--accent-primary); }
.text-sm { font-size: 12px; }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.w-full { width: 100%; }

/* Hide admin-only nav items by default - shown via JS */
.admin-only.hidden { display: none; }

/* Detail page sidebars */
.detail-layout {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 1.25rem;
}
@media (max-width: 1100px) { .detail-layout { grid-template-columns: 1fr; } }

.detail-main { min-width: 0; }
.detail-aside {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.info-block {
  background: var(--bg-secondary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: 1rem 1.1rem;
}
.info-block-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 0.75rem;
}
.info-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 0.4rem 0;
  font-size: 12.5px;
  border-bottom: 1px solid var(--border-subtle);
}
.info-row:last-child { border-bottom: none; }
.info-label { color: var(--text-tertiary); }
.info-value { color: var(--text-primary); font-weight: 500; text-align: left; }

/* Activity feed */
.activity-feed { display: flex; flex-direction: column; gap: 0.75rem; }
.activity-item {
  display: flex;
  gap: 0.75rem;
  padding: 0.65rem;
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  border-right: 2px solid var(--accent-primary);
}
.activity-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: var(--accent-light);
  color: var(--accent-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.activity-icon i { font-size: 14px; }
.activity-body { flex: 1; }
.activity-text { font-size: 12.5px; color: var(--text-primary); margin-bottom: 0.2rem; }
.activity-meta { font-size: 11px; color: var(--text-tertiary); }
.activity-meta strong { color: var(--accent-primary); font-weight: 500; }

/* ============================================
   CASE WORKSPACE - matches real system layout
   ============================================ */
.case-workbench {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.case-workbench-header {
  background: var(--bg-secondary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
}

.case-workbench-headline {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.case-workbench-title h1 {
  font-size: 28px;
  font-weight: 500;
  color: var(--text-primary);
  letter-spacing: -0.5px;
  margin-bottom: 0.4rem;
}

.case-workbench-title-meta {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.case-workbench-title-meta strong {
  font-size: 14px;
  color: var(--text-secondary);
  font-weight: 500;
}

.case-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 12px;
  font-size: 12.5px;
  font-weight: 600;
}

.case-workbench-meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.75rem;
}

.case-meta-card {
  background: var(--bg-tertiary);
  padding: 0.85rem 1rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
}

.case-meta-card span {
  display: block;
  font-size: 10.5px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 600;
  margin-bottom: 0.3rem;
}

.case-meta-card strong {
  display: block;
  font-size: 14px;
  color: var(--text-primary);
  font-weight: 500;
}

/* Stepper - large workflow viz */
.case-stepper-large {
  display: flex;
  align-items: flex-start;
  gap: 0;
  padding: 1.25rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  overflow-x: auto;
}

/* Tabs - case detail */
.case-tabs {
  display: flex;
  gap: 0.25rem;
  border-bottom: 1px solid var(--border-default);
  margin-bottom: 1.25rem;
  overflow-x: auto;
}

.case-tab-button {
  padding: 0.8rem 1.2rem;
  font-size: 13.5px;
  color: var(--text-secondary);
  border-bottom: 2px solid transparent;
  transition: all var(--t-fast);
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: transparent;
}

.case-tab-button i { font-size: 16px; }
.case-tab-button:hover { color: var(--text-primary); background: var(--bg-tertiary); }

.case-tab-button.is-active {
  color: var(--accent-primary);
  border-bottom-color: var(--accent-primary);
  font-weight: 500;
}

.case-tab-panel { display: none; }
.case-tab-panel.is-active { display: block; }

/* Spec Workspace - sidebar + form + actions */
.case-spec-workspace {
  display: grid;
  grid-template-columns: 240px 1fr 260px;
  gap: 1rem;
  align-items: flex-start;
}

@media (max-width: 1100px) {
  .case-spec-workspace { grid-template-columns: 1fr; }
}

.case-spec-sidebar, .case-spec-actions {
  background: var(--bg-secondary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: 1rem;
  position: sticky;
  top: 1rem;
}

.case-spec-form-shell {
  background: var(--bg-secondary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
}

.case-spec-form-shell.is-locked {
  border-color: var(--danger);
  background: rgba(248, 113, 113, 0.03);
}

.case-panel-head {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-subtle);
}

.case-panel-title {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.case-panel-icon {
  width: 36px;
  height: 36px;
  background: var(--accent-light);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-primary);
  font-size: 18px;
}

.case-panel-title h3 {
  font-size: 14px;
  font-weight: 500;
  margin: 0;
  color: var(--text-primary);
}

.case-panel-title p {
  font-size: 11.5px;
  color: var(--text-tertiary);
  margin: 2px 0 0;
}

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

.case-spec-step-list {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.case-spec-step-button {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 0.75rem;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer;
  transition: all var(--t-fast);
  text-align: right;
}

.case-spec-step-button:hover { background: var(--bg-tertiary); color: var(--text-primary); }

.case-spec-step-button.is-active {
  background: var(--accent-light);
  color: var(--accent-primary);
  border-color: var(--border-accent);
  font-weight: 500;
}

.case-spec-step-button span:first-child {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--bg-elevated);
  color: var(--text-tertiary);
  font-size: 11px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.case-spec-step-button.is-active span:first-child {
  background: var(--accent-primary);
  color: var(--bg-primary);
}

.case-spec-step-button strong { font-weight: 500; flex: 1; font-size: 12.5px; }

.case-spec-readonly-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.5rem;
  margin-bottom: 1rem;
  padding: 0.85rem;
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
}

.case-spec-readonly-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.case-spec-readonly-item span {
  font-size: 10.5px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.case-spec-readonly-item strong {
  font-size: 12.5px;
  color: var(--text-primary);
  font-weight: 500;
}

.case-spec-lock-card {
  padding: 0.85rem 1rem;
  border-radius: var(--radius-md);
  margin-bottom: 1rem;
  border: 1px solid var(--border-default);
}

.case-spec-lock-card.is-locked {
  background: var(--danger-bg);
  border-color: rgba(248, 113, 113, 0.3);
  color: var(--danger);
}

.case-spec-lock-card.is-open {
  background: var(--success-bg);
  border-color: rgba(74, 222, 128, 0.3);
}

.case-spec-lock-card strong {
  display: block;
  margin-bottom: 0.3rem;
  font-weight: 500;
}

.case-spec-lock-card span {
  font-size: 12.5px;
  opacity: 0.8;
}

.case-spec-delivery-card {
  background: var(--bg-tertiary);
  padding: 0.85rem 1rem;
  border-radius: var(--radius-md);
  margin-bottom: 1rem;
}

.case-spec-field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.case-spec-field > span {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 12.5px;
  color: var(--text-secondary);
  font-weight: 500;
}

.case-spec-field em {
  color: var(--accent-primary);
  font-size: 10.5px;
  background: var(--accent-light);
  padding: 1px 6px;
  border-radius: 4px;
  font-style: normal;
  font-weight: 600;
}

.case-spec-field input,
.case-spec-field select,
.case-spec-field textarea {
  width: 100%;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  padding: 0.55rem 0.8rem;
  color: var(--text-primary);
  font-size: 13px;
  outline: none;
  transition: all var(--t-fast);
}

.case-spec-field input:hover, .case-spec-field select:hover, .case-spec-field textarea:hover {
  border-color: var(--border-strong);
}

.case-spec-field input:focus, .case-spec-field select:focus, .case-spec-field textarea:focus {
  border-color: var(--accent-primary);
  background: var(--bg-elevated);
}

.case-spec-field input:disabled, .case-spec-field select:disabled, .case-spec-field textarea:disabled,
.case-spec-field input[readonly], .case-spec-field textarea[readonly] {
  background: var(--bg-primary);
  color: var(--text-tertiary);
  cursor: not-allowed;
  border-color: var(--border-subtle);
}

.case-spec-help {
  font-size: 11px;
  color: var(--text-tertiary);
  margin-top: 2px;
}

.case-spec-step-panel { display: none; }
.case-spec-step-panel.is-active { display: block; animation: fadeInUp 0.25s ease; }

.case-spec-section-block { margin-bottom: 1.5rem; }

.case-spec-section-head {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-subtle);
}

.case-spec-section-head h3 {
  font-size: 16px;
  font-weight: 500;
  color: var(--text-primary);
  margin: 0;
}

.case-spec-subsection {
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  padding: 1rem;
  margin-bottom: 0.75rem;
}

.case-spec-subsection h4 {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent-primary);
  margin: 0 0 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.case-spec-fields-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
}

@media (max-width: 700px) {
  .case-spec-fields-grid { grid-template-columns: 1fr; }
}

.case-spec-actions-stack {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.case-spec-progress-card {
  background: var(--bg-tertiary);
  padding: 0.85rem;
  border-radius: var(--radius-md);
  margin-top: 1rem;
}

.case-spec-progress-card > span {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 0.3rem;
}

.case-spec-progress-card strong {
  display: block;
  font-size: 13.5px;
  color: var(--text-primary);
  margin-bottom: 0.6rem;
}

.case-spec-progress-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.case-spec-progress-bar {
  flex: 1;
  height: 6px;
  background: var(--bg-primary);
  border-radius: 3px;
  overflow: hidden;
}

.case-spec-progress-bar span {
  display: block;
  height: 100%;
  background: var(--accent-primary);
  border-radius: 3px;
  transition: width var(--t-slow);
}

.case-spec-progress-card b {
  font-size: 13px;
  color: var(--accent-primary);
  font-weight: 600;
}

.case-spec-missing-card {
  background: var(--warning-bg);
  border: 1px solid rgba(251, 191, 36, 0.3);
  border-radius: var(--radius-md);
  padding: 0.75rem 0.85rem;
  margin-top: 0.75rem;
}

.case-spec-missing-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.4rem;
}

.case-spec-missing-head strong {
  font-size: 12.5px;
  color: var(--warning);
}

.case-spec-missing-head span {
  background: var(--warning);
  color: var(--bg-primary);
  font-size: 10.5px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 9px;
}

.case-spec-missing-list {
  font-size: 11.5px;
  color: var(--text-secondary);
  line-height: 1.6;
  max-height: 200px;
  overflow-y: auto;
}

/* Source files upload */
.case-spec-upload-card {
  background: var(--bg-tertiary);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-md);
  padding: 1.25rem;
}

.case-spec-upload-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.case-spec-upload-head strong {
  display: block;
  font-size: 13.5px;
  color: var(--text-primary);
  margin-bottom: 0.3rem;
}

.case-spec-upload-head small {
  font-size: 11.5px;
  color: var(--text-tertiary);
}

.soft-chip {
  background: var(--bg-elevated);
  color: var(--text-secondary);
  font-size: 11.5px;
  padding: 3px 10px;
  border-radius: 10px;
  font-weight: 500;
}

.case-spec-upload-controls {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.case-spec-upload-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.case-spec-upload-item {
  background: var(--bg-elevated);
  padding: 0.6rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 12px;
  text-decoration: none;
  color: var(--text-primary);
  display: block;
}

.case-spec-upload-item strong {
  display: block;
  font-weight: 500;
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.case-spec-upload-item small {
  color: var(--text-tertiary);
  font-size: 10.5px;
}

/* Status pills - case-specific */
.status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 11px;
  border-radius: 12px;
  font-size: 11.5px;
  font-weight: 600;
}

/* Compensation - Salary Dashboard */
.salary-dashboard-page { padding: 0; }
.salary-shell { display: flex; flex-direction: column; gap: 1.25rem; }

.salary-header-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 1rem;
}

.salary-eyebrow {
  font-size: 11px;
  color: var(--accent-primary);
  letter-spacing: 2px;
  text-transform: uppercase;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.salary-title {
  font-size: 24px;
  font-weight: 500;
  color: var(--text-primary);
  margin: 0 0 0.4rem;
}

.salary-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  max-width: 600px;
}

.salary-actions { display: flex; gap: 0.5rem; }

.salary-btn {
  padding: 0.6rem 1.2rem;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  transition: all var(--t-fast);
}

.salary-btn:hover { background: var(--bg-elevated); border-color: var(--border-strong); }

.salary-btn-primary {
  background: linear-gradient(135deg, var(--accent-primary), #b88857);
  color: var(--bg-primary);
  border-color: var(--accent-primary);
}

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

.salary-filters-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: 1rem 1.25rem;
  display: flex;
  align-items: flex-end;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.salary-filter {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  min-width: 130px;
}

.salary-filter span {
  font-size: 10.5px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}

.salary-filter select, .salary-filter input {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.75rem;
  color: var(--text-primary);
  font-size: 13px;
}

.salary-hero {
  background: linear-gradient(135deg, var(--bg-secondary) 0%, var(--bg-tertiary) 100%);
  border: 1px solid var(--border-default);
  border-right: 3px solid var(--accent-primary);
  border-radius: var(--radius-lg);
  padding: 2rem;
}

.salary-hero-title {
  font-size: 13px;
  color: var(--text-secondary);
  letter-spacing: 0.5px;
  margin-bottom: 0.5rem;
}

.salary-hero-amount {
  font-size: 48px;
  font-weight: 600;
  color: var(--accent-primary);
  letter-spacing: -1px;
  margin-bottom: 1rem;
}

.salary-hero-breakdown {
  display: flex;
  gap: 2rem;
  flex-wrap: wrap;
}

.salary-hero-mini { display: flex; flex-direction: column; gap: 2px; }
.salary-hero-mini span { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }
.salary-hero-mini strong { font-size: 18px; color: var(--text-primary); font-weight: 500; }

.salary-formula-note {
  margin-top: 1rem;
  padding: 0.6rem 0.85rem;
  background: var(--bg-primary);
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--text-tertiary);
}

.salary-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0.75rem;
}

.salary-kpi-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: 1rem 1.1rem;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.5rem;
}

.salary-kpi-card.salary-kpi-warning {
  border-right: 3px solid var(--warning);
}

.salary-kpi-label {
  font-size: 11.5px;
  color: var(--text-secondary);
  margin-bottom: 0.4rem;
}

.salary-kpi-value {
  font-size: 22px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.5px;
  line-height: 1;
  margin-bottom: 0.4rem;
}

.salary-kpi-note {
  font-size: 10.5px;
  color: var(--text-tertiary);
}

.salary-kpi-icon {
  font-size: 18px;
  color: var(--accent-primary);
  opacity: 0.6;
  font-weight: 600;
}

.salary-tabs {
  display: flex;
  gap: 0.25rem;
  border-bottom: 1px solid var(--border-default);
  overflow-x: auto;
}

.salary-tab {
  padding: 0.7rem 1.1rem;
  font-size: 13px;
  color: var(--text-secondary);
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
  transition: all var(--t-fast);
}

.salary-tab:hover { color: var(--text-primary); }
.salary-tab.active { color: var(--accent-primary); border-bottom-color: var(--accent-primary); font-weight: 500; }

.salary-panel {
  background: var(--bg-secondary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
}

.salary-panel-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  margin: 0 0 1rem;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--border-subtle);
}

.salary-breakdown-row {
  display: flex;
  justify-content: space-between;
  padding: 0.45rem 0;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 13px;
}

.salary-breakdown-row span { color: var(--text-secondary); }
.salary-breakdown-row strong { color: var(--text-primary); font-weight: 500; }

.salary-breakdown-total {
  display: flex;
  justify-content: space-between;
  padding: 0.75rem 0 0.25rem;
  margin-top: 0.5rem;
  border-top: 2px solid var(--accent-primary);
  font-size: 16px;
}

.salary-breakdown-total span { color: var(--text-primary); font-weight: 600; }
.salary-breakdown-total strong { color: var(--accent-primary); font-weight: 600; font-size: 20px; }

.salary-lower-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

@media (max-width: 1100px) { .salary-lower-grid { grid-template-columns: 1fr; } }

.salary-table-wrap { overflow-x: auto; }
.salary-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.salary-table th { text-align: right; padding: 0.6rem 0.5rem; font-weight: 500; color: var(--text-tertiary); font-size: 11px; text-transform: uppercase; border-bottom: 1px solid var(--border-subtle); }
.salary-table td { padding: 0.55rem 0.5rem; border-bottom: 1px solid var(--border-subtle); }

.salary-status {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 10px;
  font-size: 10.5px;
  font-weight: 600;
  margin-left: 4px;
}

.salary-status-paid { background: var(--success-bg); color: var(--success); }
.salary-status-unpaid { background: var(--danger-bg); color: var(--danger); }
.salary-status-synced { background: var(--info-bg); color: var(--info); }
.salary-status-pending_admin_approval { background: var(--warning-bg); color: var(--warning); }
.salary-status-approved { background: var(--success-bg); color: var(--success); }
.salary-status-locked { background: var(--bg-elevated); color: var(--text-tertiary); }
.salary-status-cancelled { background: var(--bg-elevated); color: var(--text-muted); }

.salary-alert-row {
  background: var(--warning-bg);
  border: 1px solid rgba(251, 191, 36, 0.3);
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  color: var(--warning);
}

/* Comp admin tabs */
.comp-admin-tabs {
  display: flex;
  gap: 0.25rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: 0.4rem;
  margin-bottom: 1rem;
  overflow-x: auto;
}

.comp-admin-tab {
  padding: 0.6rem 1rem;
  font-size: 12.5px;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  text-decoration: none;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  transition: all var(--t-fast);
  cursor: pointer;
}

.comp-admin-tab i { font-size: 14px; }
.comp-admin-tab:hover { background: var(--bg-tertiary); color: var(--text-primary); }
.comp-admin-tab.is-active {
  background: var(--accent-light);
  color: var(--accent-primary);
  font-weight: 500;
}

.comp-admin-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
}

.comp-admin-card h3 {
  font-size: 15px;
  font-weight: 500;
  margin: 0 0 1rem;
  color: var(--text-primary);
}

.form-grid label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.form-grid label > span {
  font-size: 11.5px;
  color: var(--text-secondary);
  font-weight: 500;
}

.form-grid label input,
.form-grid label select,
.form-grid label textarea {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  padding: 0.55rem 0.75rem;
  color: var(--text-primary);
  font-size: 13px;
  outline: none;
  transition: all var(--t-fast);
}

.form-grid label input:focus,
.form-grid label select:focus {
  border-color: var(--accent-primary);
  background: var(--bg-elevated);
}

/* Bigger buttons */
.button {
  padding: 0.6rem 1.15rem;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
  border: 1px solid transparent;
  text-decoration: none;
  transition: all var(--t-fast);
}

.button.primary {
  background: var(--accent-primary);
  color: var(--bg-primary);
  border-color: var(--accent-primary);
}
.button.primary:hover { background: var(--accent-hover); }

.button.secondary {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border-color: var(--border-default);
}
.button.secondary:hover { background: var(--bg-elevated); }

.button.tertiary {
  background: transparent;
  color: var(--text-secondary);
}
.button.tertiary:hover { background: var(--bg-tertiary); color: var(--text-primary); }

.button.success {
  background: #4ade80;
  color: #0a3d1f;
  border-color: #4ade80;
}
.button.success:hover { background: #6ee7a3; }

.button.warning {
  background: var(--warning);
  color: var(--bg-primary);
}

.button.danger {
  background: var(--danger);
  color: var(--bg-primary);
}

.button.small { padding: 0.4rem 0.8rem; font-size: 12px; }
.button:disabled { opacity: 0.5; cursor: not-allowed; }


/* ============================================
   ADDITIONAL UTILITY CLASSES (used in views_calendar.js)
   ============================================ */

/* btn-icon - small round icon button */
.btn-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 16px;
  transition: all var(--t-fast);
  margin: 0 2px;
}

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

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

/* Generic btn class - works alongside .btn-primary/.btn-secondary */
.btn {
  padding: 0.55rem 1.1rem;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
  border: 1px solid transparent;
  text-decoration: none;
  transition: all var(--t-fast);
  font-family: inherit;
}

.btn.btn-primary {
  background: linear-gradient(135deg, var(--accent-primary), #a07444);
  color: #ffffff;
  border-color: var(--accent-primary);
}
.btn.btn-primary:hover {
  background: linear-gradient(135deg, var(--accent-hover), var(--accent-primary));
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.btn.btn-secondary {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border-color: var(--border-default);
}
.btn.btn-secondary:hover {
  background: var(--bg-elevated);
  border-color: var(--border-strong);
}

.btn.btn-tertiary {
  background: transparent;
  color: var(--text-secondary);
}
.btn.btn-tertiary:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.btn.btn-danger {
  background: var(--danger);
  color: #ffffff;
  border-color: var(--danger);
}
.btn.btn-danger:hover { opacity: 0.9; }

.btn.btn-success {
  background: var(--success);
  color: #ffffff;
  border-color: var(--success);
}
.btn.btn-success:hover { opacity: 0.9; }

/* Page header for non-card pages */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 1rem;
  position: relative;
  padding-right: 0.25rem;
}
.page-header::before {
  content: '';
  position: absolute;
  top: 0;
  right: -1rem;
  bottom: -0.4rem;
  width: 4px;
  border-radius: 2px;
  background: linear-gradient(180deg, #c89d6b 0%, #8b6346 50%, rgba(200, 157, 107, 0.2) 100%);
  opacity: 0.8;
}

/* Subtle warm kitchen accent in the corner of page-headers */
.page-header::after {
  content: '';
  position: absolute;
  top: -10px;
  right: -1.5rem;
  width: 180px;
  height: 60px;
  background-image: linear-gradient(90deg, transparent 0%, rgba(200, 157, 107, 0.05) 50%, transparent 100%);
  pointer-events: none;
  z-index: -1;
}

.page-header .page-title {
  font-size: 24px;
  font-weight: 500;
  color: var(--text-primary);
  letter-spacing: -0.5px;
  margin: 0 0 0.3rem;
}

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

.page-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}

/* Avatar mini */
.avatar-mini {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent-primary);
  color: var(--bg-primary);
  font-size: 11px;
  font-weight: 600;
  flex-shrink: 0;
}

.user-mini {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 13px;
}

/* Modal overlay fix */
.modal-overlay.active {
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border-default);
  border-radius: 12px;
  width: 100%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  margin: 1rem;
}

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

.modal-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 500;
  color: var(--text-primary);
}

.modal-body {
  padding: 1.25rem;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border-default);
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* Table-wrap (used in users view) */
.table-wrap {
  overflow-x: auto;
  width: 100%;
}

/* Status pill (used in tables) */
.status {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 11px;
  font-size: 11.5px;
  font-weight: 600;
}


/* ===========================================
   MOBILE RESPONSIVE — Make the entire app
   feel like a native mobile app on phones
   =========================================== */

@media (max-width: 900px) {
  /* === Hide desktop sidebar by default on mobile === */
  .sidebar {
    position: fixed;
    right: -280px;
    top: 0;
    width: 270px;
    height: 100vh;
    z-index: 1000;
    transition: right 0.3s ease;
    box-shadow: -4px 0 12px rgba(0,0,0,0.15);
    background: var(--bg-secondary);
  }
  .sidebar.mobile-open {
    right: 0;
  }
  /* Backdrop when sidebar open */
  body.sidebar-open::before {
    content: '';
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 999;
  }

  /* Main content takes full width */
  .main-content {
    margin-right: 0 !important;
    width: 100%;
  }

  /* Mobile menu button (hamburger) */
  .mobile-menu-btn {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-default);
    border-radius: 8px;
    color: var(--text-primary);
    cursor: pointer;
    font-size: 18px;
  }
  /* Hidden on desktop */
  .mobile-menu-btn { display: none; }

  /* Topbar tweaks */
  .topbar {
    padding: 0.7rem 0.85rem !important;
    flex-wrap: wrap;
    gap: 0.5rem;
  }
  .topbar-left { gap: 0.5rem; }
  .topbar-right { gap: 0.4rem; }
  .page-title { font-size: 16px !important; }
  .breadcrumb { display: none; }
  .topbar-search { display: none !important; }

  /* Main content padding */
  .main-content > .view-container,
  .main-content > main {
    padding: 0.75rem !important;
  }

  /* === Page header: stack title + actions === */
  .page-header {
    flex-direction: column;
    align-items: flex-start !important;
    gap: 0.6rem;
  }
  .page-header .page-title { font-size: 19px; }
  .page-header .page-subtitle { font-size: 12px; }
  .page-actions {
    width: 100%;
    flex-wrap: wrap;
    gap: 0.4rem;
  }
  .page-actions .btn {
    flex: 1;
    min-width: 100px;
    font-size: 12px;
    padding: 0.5rem 0.6rem;
  }

  /* === Cards adapt === */
  .card { padding: 0.85rem !important; }
  .card-header { padding: 0.65rem 0.85rem; }

  /* === KPI grid: 2 columns on mobile === */
  .kpi-row,
  .kpi-grid,
  [class*="kpi-grid"] {
    grid-template-columns: 1fr 1fr !important;
    gap: 0.5rem !important;
  }
  .kpi-card { padding: 0.75rem 0.85rem !important; }
  .kpi-value { font-size: 22px !important; }
  .kpi-label { font-size: 10px !important; }

  /* === Dashboard grid: stack everything === */
  .dashboard-grid,
  div[style*="grid-template-columns: 1fr 1fr"],
  div[style*="grid-template-columns: 2fr 1fr"],
  div[style*="grid-template-columns: 1fr 2fr"],
  div[style*="grid-template-columns: repeat(3, 1fr)"],
  div[style*="grid-template-columns: repeat(4, 1fr)"] {
    grid-template-columns: 1fr !important;
  }

  /* === Tables: scroll horizontally === */
  .data-table-wrapper,
  .table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .data-table {
    min-width: 600px;
    font-size: 12px;
  }
  .data-table th,
  .data-table td {
    padding: 6px 8px;
  }

  /* === Filter chips: scroll horizontally === */
  .toolbar {
    flex-wrap: wrap;
    gap: 0.4rem;
    padding: 0.5rem 0.85rem !important;
  }
  .toolbar-left {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    display: flex;
    flex-wrap: nowrap;
    gap: 0.4rem;
    max-width: 100%;
    padding-bottom: 0.3rem;
    scrollbar-width: thin;
  }
  .filter-chip {
    white-space: nowrap;
    flex-shrink: 0;
    font-size: 12px;
    padding: 5px 10px;
  }

  /* === Buttons: bigger touch targets === */
  .btn, .button, button.btn-primary, button.btn-secondary {
    min-height: 38px;
    font-size: 13px;
    padding: 0.5rem 0.85rem;
  }
  .btn-sm, .button.small, .btn.btn-sm {
    min-height: 30px;
    font-size: 11.5px;
    padding: 0.35rem 0.6rem;
  }
  .btn-icon {
    width: 34px !important;
    height: 34px !important;
  }

  /* === Modals: full screen on mobile === */
  .modal {
    max-width: 95vw !important;
    max-height: 95vh !important;
    width: 95vw;
    margin: 2.5vh auto;
  }
  .modal-header {
    padding: 0.85rem 1rem;
  }
  .modal-header h3 {
    font-size: 15px;
  }
  .modal-body {
    padding: 0.85rem;
  }
  .modal-footer {
    padding: 0.6rem 0.85rem;
    flex-wrap: wrap;
    gap: 0.4rem;
  }
  .modal-footer .btn { flex: 1; }

  /* === Form fields: full width === */
  .form-grid,
  div[style*="grid-template-columns: 1fr 1fr; gap"] {
    grid-template-columns: 1fr !important;
  }
  .text-input, .select-input, input[type="text"], input[type="tel"], input[type="email"],
  input[type="date"], input[type="number"], select, textarea {
    font-size: 15px !important; /* iOS won't zoom if >=16px ; 15 is close enough */
    padding: 0.55rem 0.75rem !important;
  }

  /* === Lead/customer cards: stack info === */
  .lead-card,
  .customer-row,
  .opportunity-card {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.4rem;
  }

  /* === Login screen === */
  .login-screen {
    padding: 1rem;
  }
  .login-card {
    width: 95vw !important;
    max-width: 400px;
    padding: 1.5rem !important;
  }

  /* === Calendar views: scroll === */
  .case-spec-tabs,
  .calendar-day-grid {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* === Spec form: single column === */
  .case-spec-fields-grid {
    grid-template-columns: 1fr !important;
  }
  .case-spec-actions {
    margin-top: 1rem;
  }
  .case-spec-actions-stack {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.4rem;
  }
  .case-spec-actions-stack .button { font-size: 12px; padding: 0.55rem 0.6rem; }

  /* === Tabs in lead detail === */
  .tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap;
  }
  .tab {
    white-space: nowrap;
    flex-shrink: 0;
    font-size: 12.5px;
  }

  /* === Toasts adapt === */
  .toast-container {
    right: 1rem !important;
    left: 1rem !important;
    bottom: 1rem !important;
    top: auto !important;
    max-width: none !important;
  }
  .toast {
    width: 100%;
  }

  /* === Calendar day view rows shrink === */
  .calendar-day-grid {
    font-size: 11px !important;
  }
}

/* Very small phones */
@media (max-width: 480px) {
  .kpi-row,
  .kpi-grid {
    grid-template-columns: 1fr !important;
  }
  .page-title { font-size: 17px !important; }
  .card { padding: 0.7rem !important; }
  .modal { width: 100vw !important; max-width: 100vw !important; max-height: 100vh !important; margin: 0; border-radius: 0; }
}

@media (max-width: 768px) {
  body.public-signature-mode {
    min-height: 100dvh;
    overflow-y: auto !important;
    touch-action: pan-y;
  }

  .public-sign-page {
    min-height: 100vh;
    min-height: 100dvh;
    height: auto;
    overflow: visible;
    padding: 12px !important;
    padding-bottom: calc(112px + env(safe-area-inset-bottom)) !important;
  }

  .public-sign-shell,
  .public-sign-card {
    width: 100%;
    max-width: 100%;
  }

  .public-sign-card {
    border-radius: 12px !important;
    padding: 1rem !important;
    margin-bottom: 0.75rem !important;
  }

  .public-signature-card {
    padding-bottom: 0 !important;
  }

  .signature-canvas-wrap {
    touch-action: none;
  }

  .signature-canvas {
    width: 100% !important;
    max-width: 100% !important;
    height: 220px !important;
  }

  .public-sign-actions {
    position: sticky;
    bottom: 0;
    z-index: 20;
    margin: 1rem -1rem 0;
    padding: 0.75rem;
    padding-bottom: calc(0.75rem + env(safe-area-inset-bottom));
    background: rgba(255, 255, 255, 0.97);
    border-top: 1px solid rgba(42, 31, 21, 0.08);
    border-radius: 0 0 12px 12px;
    box-shadow: 0 -6px 18px rgba(42, 31, 21, 0.08);
    backdrop-filter: blur(8px);
  }

  .public-sign-actions button {
    width: 100% !important;
    min-height: 48px;
  }
}

/* Show mobile menu btn only on mobile */
@media (max-width: 900px) {
  .mobile-menu-btn-wrap { display: inline-flex !important; }
}
@media (min-width: 901px) {
  .mobile-menu-btn-wrap { display: none; }
}

/* Safe area for iPhones with notch */
@supports (padding: max(0px)) {
  body { padding-bottom: env(safe-area-inset-bottom); }
}

/* ============================================
   LUXURY KITCHEN HERO STRIP (dashboard, etc.)
   ============================================ */
.dashboard-hero-strip {
  position: relative;
  width: 100%;
  height: 140px;
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 1.5rem;
  background-image: url('img/kitchen-hero.jpg');
  background-size: cover;
  background-position: center 35%;
  box-shadow:
    0 4px 12px rgba(0, 0, 0, 0.18),
    0 0 0 1px rgba(200, 157, 107, 0.18) inset;
}

.dashboard-hero-overlay {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg,
      rgba(20, 16, 12, 0.78) 0%,
      rgba(40, 30, 22, 0.55) 50%,
      rgba(20, 16, 12, 0.25) 100%);
}

.dashboard-hero-content {
  position: absolute;
  top: 50%;
  right: 1.5rem;
  transform: translateY(-50%);
  color: #f8efe4;
  z-index: 1;
}
.dashboard-hero-title {
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.5px;
  margin-bottom: 0.25rem;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}
.dashboard-hero-sub {
  font-size: 13px;
  color: rgba(248, 239, 228, 0.85);
  letter-spacing: 0.3px;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

@media (max-width: 768px) {
  .dashboard-hero-strip { height: 100px; }
  .dashboard-hero-title { font-size: 22px; }
  .dashboard-hero-sub { font-size: 11px; }
}

/* ============================================
   MOBILE PORTRAIT — Header / Hamburger fix
   Root cause: viewport-fit=cover combined with
   apple-mobile-web-app-status-bar-style:black-translucent
   causes the page to render under the iPhone notch /
   Dynamic Island. The topbar starts at y=0 and the
   status bar (~47px) covers the hamburger button,
   making it visually present but physically untappable.
   Fix 1 (portrait): push topbar below safe-area-inset-top.
   Fix 2 (all mobile): hide .search-box (previous rule used
          wrong class .topbar-search — element is .search-box).
   Fix 3 (all mobile): 44×44 min tap target for hamburger.
   Fix 4 (all mobile): topbar z-index above backdrop (999).
   Desktop: zero impact — all rules are inside mobile @media.
   ============================================ */

/* Portrait-only: compensate for iPhone notch / Dynamic Island */
@media (max-width: 900px) and (orientation: portrait) {
  .topbar {
    padding-top: max(0.7rem, env(safe-area-inset-top, 0px)) !important;
    height: auto !important;
    min-height: var(--topbar-height);
    box-sizing: border-box;
  }
  .topbar-left {
    align-items: center !important;
  }
}

/* All mobile — additional fixes */
@media (max-width: 900px) {
  /* Fix: previous rule used .topbar-search but the element class is .search-box */
  .topbar .search-box {
    display: none !important;
  }
  /* iOS HIG: minimum 44×44px tap target for the hamburger button */
  .mobile-menu-btn-wrap {
    min-width: 44px !important;
    min-height: 44px !important;
  }
  /* Keep topbar above the sidebar backdrop (z-index: 999) so hamburger stays tappable */
  .topbar {
    position: relative;
    z-index: 1001;
  }
}

/* ============================================
   MOBILE PORTRAIT — Fixed hamburger + bottom safe area
   Round 2 fix: topbar padding-top alone was insufficient
   because env(safe-area-inset-top) may return 0 in some
   browsers, leaving the button inside the status-bar zone.
   Solution: detach the button from topbar flow entirely and
   position it with position:fixed at an explicit offset that
   is guaranteed to land below the status bar on all devices.
   min value 52px covers all Android status bars + old iPhones.
   env(safe-area-inset-top)+12px covers notch/Dynamic Island.
   ============================================ */

/* Portrait only: fixed hamburger below safe area */
@media (max-width: 900px) and (orientation: portrait) {
  #mobile-menu-btn {
    position: fixed !important;
    /* Fallback for browsers without max() */
    top: 52px;
    /* Safe: whichever is larger — 52px floor or safe-area + 12px */
    top: max(52px, calc(env(safe-area-inset-top, 0px) + 12px)) !important;
    right: calc(env(safe-area-inset-right, 0px) + 12px) !important;
    width: 48px !important;
    height: 48px !important;
    z-index: 99999 !important;
    pointer-events: auto !important;
    touch-action: manipulation !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    background: var(--bg-secondary) !important;
    border: 1px solid var(--border-default) !important;
    border-radius: 10px !important;
    color: var(--text-primary) !important;
    font-size: 20px !important;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15) !important;
    cursor: pointer !important;
    -webkit-tap-highlight-color: transparent !important;
    overflow: visible !important;
  }
}

/* All mobile: bottom content padding
   Accounts for: floating bug-reporter button (54px + 18px gap = 72px)
   + browser bottom chrome + iPhone home-indicator safe area */
@media (max-width: 900px) {
  .view-container {
    padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 96px) !important;
  }
}

/* ============================================================================
 * Global Server-Save Blocking Overlay (server_save_overlay.js)
 * ==========================================================================*/
.sso-overlay {
  position: fixed;
  inset: 0;
  z-index: 100000; /* above modals (which sit lower) */
  display: none;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.18s ease;
}
.sso-overlay.sso-visible { opacity: 1; }
.sso-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(20, 14, 8, 0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.sso-card {
  position: relative;
  background: var(--bg-secondary);
  color: var(--text-primary);
  border-radius: var(--radius-xl, 20px);
  box-shadow: var(--shadow-lg, 0 12px 32px rgba(0,0,0,0.4));
  padding: 2rem 2.25rem;
  max-width: 380px;
  width: calc(100% - 3rem);
  text-align: center;
  transform: translateY(8px) scale(0.98);
  transition: transform 0.18s ease;
  outline: none;
}
.sso-overlay.sso-visible .sso-card { transform: translateY(0) scale(1); }
.sso-title {
  margin: 1.1rem 0 0.5rem;
  font-size: 1.12rem;
  font-weight: 700;
  line-height: 1.4;
}
.sso-detail {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.55;
  color: var(--text-secondary, #6b5d4f);
}
/* Icon slots — only the active mode's icon is shown */
.sso-icon { display: none; width: 64px; height: 64px; margin: 0 auto; }
.sso-mode-saving .sso-icon-saving { display: flex; align-items: center; justify-content: center; }
.sso-mode-ok .sso-icon-ok { display: block; }
.sso-mode-err .sso-icon-err { display: block; }
/* Spinner */
.sso-spinner {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 4px solid var(--bg-elevated, #ebe5dc);
  border-top-color: var(--primary, #b88857);
  animation: sso-spin 0.8s linear infinite;
}
@keyframes sso-spin { to { transform: rotate(360deg); } }
/* Success check */
.sso-icon-ok svg, .sso-icon-err svg { width: 64px; height: 64px; }
.sso-icon-ok circle { fill: none; stroke: var(--success, #16a34a); stroke-width: 3; opacity: 0.25; }
.sso-icon-ok path {
  fill: none; stroke: var(--success, #16a34a); stroke-width: 4;
  stroke-linecap: round; stroke-linejoin: round;
  stroke-dasharray: 48; stroke-dashoffset: 48;
  animation: sso-draw 0.45s ease forwards;
}
.sso-icon-err circle { fill: none; stroke: var(--danger, #dc2626); stroke-width: 3; opacity: 0.25; }
.sso-icon-err path {
  fill: none; stroke: var(--danger, #dc2626); stroke-width: 4;
  stroke-linecap: round; stroke-linejoin: round;
  stroke-dasharray: 24; stroke-dashoffset: 24;
  animation: sso-draw 0.4s ease forwards;
}
@keyframes sso-draw { to { stroke-dashoffset: 0; } }
@media (prefers-reduced-motion: reduce) {
  .sso-spinner { animation-duration: 1.4s; }
  .sso-icon-ok path, .sso-icon-err path { animation: none; stroke-dashoffset: 0; }
  .sso-overlay, .sso-card { transition: none; }
}
