/* ============================================================
   DoorPulse Design System — 2026 Modern SaaS
   ============================================================ */

/* --- DESIGN TOKENS --- */
:root {
  /* Brand */
  --brand: #E85D26;
  --brand-dark: #C94A1A;
  --brand-light: #FF7A45;
  --brand-subtle: rgba(232, 93, 38, 0.10);
  --brand-glow: rgba(232, 93, 38, 0.25);

  /* Surfaces */
  --bg-root: #09090B;
  --bg-primary: #0C0C0E;
  --bg-secondary: #141418;
  --bg-tertiary: #1C1C22;
  --bg-elevated: #222228;
  --bg-hover: rgba(255, 255, 255, 0.04);
  --bg-active: rgba(255, 255, 255, 0.06);

  /* Borders */
  --border-default: rgba(255, 255, 255, 0.06);
  --border-subtle: rgba(255, 255, 255, 0.04);
  --border-strong: rgba(255, 255, 255, 0.10);
  --border-brand: rgba(232, 93, 38, 0.3);

  /* Text */
  --text-primary: #FAFAFA;
  --text-secondary: #A1A1AA;
  --text-tertiary: #71717A;
  --text-muted: #52525B;
  --text-inverse: #09090B;

  /* Semantic */
  --green: #22C55E;
  --green-bg: rgba(34, 197, 94, 0.10);
  --green-border: rgba(34, 197, 94, 0.25);
  --blue: #3B82F6;
  --blue-bg: rgba(59, 130, 246, 0.10);
  --blue-border: rgba(59, 130, 246, 0.25);
  --yellow: #EAB308;
  --yellow-bg: rgba(234, 179, 8, 0.10);
  --yellow-border: rgba(234, 179, 8, 0.25);
  --red: #EF4444;
  --red-bg: rgba(239, 68, 68, 0.10);
  --red-border: rgba(239, 68, 68, 0.25);
  --purple: #A855F7;
  --purple-bg: rgba(168, 85, 247, 0.10);
  --teal: #14B8A6;
  --teal-bg: rgba(20, 184, 166, 0.10);

  /* Typography */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-display: 'Space Grotesk', var(--font-sans);
  --font-mono: 'JetBrains Mono', 'SF Mono', 'Fira Code', monospace;

  --text-xs: 0.75rem;    /* 12px */
  --text-sm: 0.8125rem;  /* 13px */
  --text-base: 0.875rem; /* 14px */
  --text-md: 0.9375rem;  /* 15px */
  --text-lg: 1.0625rem;  /* 17px */
  --text-xl: 1.25rem;    /* 20px */
  --text-2xl: 1.5rem;    /* 24px */
  --text-3xl: 1.875rem;  /* 30px */

  /* Spacing */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;
  --space-16: 64px;

  /* Radii */
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-2xl: 20px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.25);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.35);
  --shadow-xl: 0 16px 48px rgba(0, 0, 0, 0.4);
  --shadow-brand: 0 4px 16px rgba(232, 93, 38, 0.2);

  /* Layout */
  --sidebar-w: 260px;
  --sidebar-collapsed: 72px;
  --header-h: 56px;

  /* Transitions */
  --transition-fast: 0.12s ease;
  --transition-base: 0.2s ease;
  --transition-slow: 0.3s ease;
}

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

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  font-family: var(--font-sans);
  background: var(--bg-root);
  color: var(--text-secondary);
  line-height: 1.5;
  overflow-x: hidden;
  min-height: 100vh;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  color: var(--text-primary);
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.01em;
}

a { text-decoration: none; color: inherit; }
img { max-width: 100%; }
button { cursor: pointer; }

/* --- LAYOUT --- */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* --- SIDEBAR --- */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-primary);
  border-right: 1px solid var(--border-default);
  position: fixed;
  top: 0; left: 0; bottom: 0;
  display: flex;
  flex-direction: column;
  z-index: 50;
  transition: transform var(--transition-slow);
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar::-webkit-scrollbar { width: 0; }

.sidebar-logo {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-5) var(--space-5) var(--space-5);
  text-decoration: none;
  flex-shrink: 0;
}

.sidebar-logo .icon {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-dark) 100%);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
  box-shadow: var(--shadow-brand);
}

.sidebar-section {
  padding: var(--space-2) var(--space-3);
}

.sidebar-section-label {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: var(--space-3) var(--space-3) var(--space-2);
}

.sidebar-nav {
  padding: var(--space-1) var(--space-3);
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  color: var(--text-tertiary);
  font-size: var(--text-sm);
  font-weight: 450;
  transition: all var(--transition-fast);
  margin-bottom: 2px;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-family: inherit;
  position: relative;
}

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

.nav-item.active {
  background: var(--brand-subtle);
  color: var(--brand);
  font-weight: 550;
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: -12px;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 20px;
  background: var(--brand);
  border-radius: 0 var(--radius-full) var(--radius-full) 0;
}

.nav-item .nav-icon {
  font-size: 1.125rem;
  width: 24px;
  text-align: center;
  flex-shrink: 0;
  line-height: 1;
}

.nav-item .badge {
  margin-left: auto;
  background: var(--brand);
  color: white;
  font-size: 0.65rem;
  padding: 2px 7px;
  border-radius: var(--radius-full);
  font-weight: 600;
  line-height: 1.4;
}

.sidebar-footer {
  padding: var(--space-4) var(--space-4);
  border-top: 1px solid var(--border-default);
  flex-shrink: 0;
}

.sidebar-footer-card {
  background: var(--bg-tertiary);
  border-radius: var(--radius-lg);
  padding: var(--space-3) var(--space-4);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  cursor: default;
}

.sidebar-footer-avatar {
  width: 32px; height: 32px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-dark) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-xs);
  font-weight: 700;
  color: white;
  flex-shrink: 0;
}

.sidebar-footer-info {
  overflow: hidden;
}

.sidebar-footer-name {
  font-size: var(--text-sm);
  font-weight: 550;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-footer-role {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

/* --- MAIN CONTENT --- */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-height: 100vh;
  background: var(--bg-root);
}

/* --- PAGE HEADER --- */
.page-header {
  padding: var(--space-5) var(--space-8);
  border-bottom: 1px solid var(--border-default);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-4);
  background: var(--bg-primary);
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(12px);
}

.page-header h1 {
  font-size: var(--text-xl);
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.page-header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.breadcrumbs {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-bottom: var(--space-1);
}

.breadcrumbs a {
  color: var(--text-tertiary);
  transition: color var(--transition-fast);
}

.breadcrumbs a:hover { color: var(--brand); }
.breadcrumbs .sep { opacity: 0.4; }

.page-body {
  padding: var(--space-6) var(--space-8);
}

/* --- BUTTONS --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: 550;
  cursor: pointer;
  transition: all var(--transition-fast);
  border: none;
  font-family: inherit;
  white-space: nowrap;
  line-height: 1.5;
}

.btn-primary {
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-dark) 100%);
  color: white;
  box-shadow: var(--shadow-brand);
}
.btn-primary:hover {
  background: linear-gradient(135deg, var(--brand-light) 0%, var(--brand) 100%);
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(232, 93, 38, 0.3);
}
.btn-primary:active { transform: translateY(0); }

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

.btn-ghost {
  background: transparent;
  color: var(--text-tertiary);
  border: 1px solid var(--border-default);
}
.btn-ghost:hover {
  background: var(--bg-hover);
  border-color: var(--border-strong);
  color: var(--text-secondary);
}

.btn-danger {
  background: var(--red-bg);
  color: var(--red);
  border: 1px solid var(--red-border);
}
.btn-danger:hover {
  background: var(--red);
  color: white;
  border-color: var(--red);
}

.btn-success {
  background: var(--green-bg);
  color: var(--green);
  border: 1px solid var(--green-border);
}

.btn-sm {
  padding: var(--space-1) var(--space-3);
  font-size: var(--text-xs);
  border-radius: var(--radius-sm);
}

.btn-lg {
  padding: var(--space-3) var(--space-6);
  font-size: var(--text-base);
  border-radius: var(--radius-lg);
}

.btn-icon {
  padding: var(--space-2);
  width: 34px;
  height: 34px;
}

/* --- STAT CARDS --- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-8);
}

.stat-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xl);
  padding: var(--space-5);
  transition: all var(--transition-base);
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: var(--stat-accent, var(--border-default));
  opacity: 0.6;
}

.stat-card:hover {
  border-color: var(--border-strong);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.stat-card .stat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-3);
}

.stat-card .stat-icon {
  width: 36px; height: 36px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
}

.stat-card .label {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.stat-card .value {
  font-size: var(--text-2xl);
  font-weight: 700;
  color: var(--text-primary);
  font-family: var(--font-display);
  line-height: 1.2;
}

.stat-card .sub {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  margin-top: var(--space-1);
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

.stat-card .trend-up { color: var(--green); }
.stat-card .trend-down { color: var(--red); }

/* --- CARDS (Generic) --- */
.card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xl);
  transition: all var(--transition-base);
}

.card:hover {
  border-color: var(--border-strong);
}

.card-padded {
  padding: var(--space-5);
}

/* --- TABLE --- */
.table-wrap {
  background: var(--bg-secondary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xl);
  overflow: hidden;
}

.table-toolbar {
  padding: var(--space-4) var(--space-5);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
  border-bottom: 1px solid var(--border-default);
}

.search-input {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: var(--space-2) var(--space-3);
  padding-left: 36px;
  color: var(--text-primary);
  font-size: var(--text-sm);
  outline: none;
  min-width: 260px;
  font-family: inherit;
  transition: all var(--transition-fast);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2371717A' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'%3E%3C/circle%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'%3E%3C/line%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 12px center;
}

.search-input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-subtle);
}

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

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

thead {
  background: var(--bg-tertiary);
}

th {
  text-align: left;
  padding: var(--space-3) var(--space-5);
  font-size: var(--text-xs);
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border-default);
}

td {
  padding: var(--space-3) var(--space-5);
  font-size: var(--text-sm);
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-secondary);
}

tr {
  cursor: pointer;
  transition: background var(--transition-fast);
}

tr:hover td {
  background: var(--bg-hover);
}

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

/* --- STATUS PILLS --- */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: 550;
  white-space: nowrap;
}

.pill::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.pill-scheduled { background: var(--blue-bg); color: var(--blue); }
.pill-scheduled::before { background: var(--blue); }

.pill-in_progress { background: var(--yellow-bg); color: var(--yellow); }
.pill-in_progress::before { background: var(--yellow); }

.pill-completed { background: var(--green-bg); color: var(--green); }
.pill-completed::before { background: var(--green); }

.pill-cancelled { background: var(--red-bg); color: var(--red); }
.pill-cancelled::before { background: var(--red); }

.pill-emergency { background: var(--red-bg); color: var(--red); }
.pill-emergency::before { background: var(--red); }

.pill-normal { background: var(--blue-bg); color: var(--blue); }
.pill-normal::before { background: var(--blue); }

.pill-high { background: var(--yellow-bg); color: var(--yellow); }
.pill-high::before { background: var(--yellow); }

.pill-urgent { background: var(--red-bg); color: var(--red); }
.pill-urgent::before { background: var(--red); }

.pill-residential { background: var(--green-bg); color: var(--green); }
.pill-residential::before { background: var(--green); }

.pill-commercial { background: var(--purple-bg); color: var(--purple); }
.pill-commercial::before { background: var(--purple); }

/* --- TECH DOT --- */
.tech-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 8px;
  flex-shrink: 0;
  box-shadow: 0 0 0 2px var(--bg-secondary);
}

/* --- DISPATCH BOARD --- */
.dispatch-controls {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}

.dispatch-controls .week-label {
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--text-primary);
  min-width: 200px;
  text-align: center;
  font-family: var(--font-display);
}

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

.dispatch-header-row {
  display: grid;
  grid-template-columns: 160px repeat(7, 1fr);
  border-bottom: 1px solid var(--border-default);
  background: var(--bg-tertiary);
}

.dispatch-header-cell {
  padding: var(--space-3) var(--space-2);
  text-align: center;
  font-size: var(--text-xs);
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.dispatch-header-cell .day-num {
  display: block;
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--text-tertiary);
  font-family: var(--font-display);
  margin-top: 2px;
}

.dispatch-header-cell.today {
  color: var(--brand);
  background: var(--brand-subtle);
  border-bottom: 2px solid var(--brand);
}

.dispatch-header-cell.today .day-num {
  color: var(--brand);
}

.dispatch-tech-row {
  display: grid;
  grid-template-columns: 160px repeat(7, 1fr);
  border-bottom: 1px solid var(--border-subtle);
  min-height: 90px;
  transition: background var(--transition-fast);
}

.dispatch-tech-row:last-child { border-bottom: none; }
.dispatch-tech-row:hover { background: var(--bg-hover); }

.dispatch-tech-name {
  padding: var(--space-3) var(--space-4);
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  font-size: var(--text-sm);
  color: var(--text-secondary);
  font-weight: 550;
  border-right: 1px solid var(--border-subtle);
  background: var(--bg-tertiary);
}

.dispatch-day-cell {
  padding: var(--space-2);
  border-right: 1px solid var(--border-subtle);
  min-height: 90px;
  position: relative;
  transition: background var(--transition-fast);
  cursor: pointer;
}

.dispatch-day-cell:hover {
  background: var(--bg-hover);
}

.dispatch-day-cell.today {
  background: rgba(232, 93, 38, 0.03);
}

.dispatch-day-cell:last-child { border-right: none; }

.dispatch-job {
  padding: var(--space-2) var(--space-2) var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-1);
  font-size: 0.6875rem;
  cursor: pointer;
  transition: all var(--transition-fast);
  border-left: 3px solid;
  line-height: 1.35;
  position: relative;
}

.dispatch-job:hover {
  transform: translateX(2px) translateY(-1px);
  box-shadow: var(--shadow-md);
  z-index: 2;
}

.dispatch-job .job-time {
  font-weight: 700;
  color: var(--text-primary);
  font-size: 0.6875rem;
}

.dispatch-job .job-type {
  color: var(--text-tertiary);
  font-size: 0.625rem;
}

.dispatch-job .job-customer {
  color: var(--text-secondary);
  font-size: 0.625rem;
  margin-top: 1px;
}

/* --- MODAL --- */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.70);
  backdrop-filter: blur(8px);
  z-index: 200;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: var(--space-12) var(--space-6);
  overflow-y: auto;
  animation: fadeIn 0.2s ease;
}

.modal-overlay.hidden { display: none; }

.modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-2xl);
  width: 100%;
  max-width: 640px;
  box-shadow: var(--shadow-xl);
  animation: slideUp 0.25s ease;
}

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

.modal-header h2 {
  font-size: var(--text-lg);
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.25rem;
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
}

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

.modal-body {
  padding: var(--space-6);
}

.modal-footer {
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--border-default);
  display: flex;
  justify-content: flex-end;
  gap: var(--space-3);
  background: var(--bg-tertiary);
  border-radius: 0 0 var(--radius-2xl) var(--radius-2xl);
}

/* --- FORMS --- */
.form-group {
  margin-bottom: var(--space-4);
}

.form-label {
  display: block;
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  margin-bottom: var(--space-2);
  font-weight: 550;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.form-input, .form-select, .form-textarea {
  width: 100%;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: var(--space-2) var(--space-3);
  color: var(--text-primary);
  font-size: var(--text-sm);
  outline: none;
  font-family: inherit;
  transition: all var(--transition-fast);
  line-height: 1.5;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-subtle);
}

.form-input::placeholder, .form-textarea::placeholder {
  color: var(--text-muted);
}

.form-select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2371717A' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

.form-select option {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.form-textarea {
  resize: vertical;
  min-height: 80px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-3);
}

.form-hint {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: var(--space-1);
}

/* Visual service type selector */
.service-type-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}

.service-type-card {
  background: var(--bg-tertiary);
  border: 2px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: var(--space-3);
  text-align: center;
  cursor: pointer;
  transition: all var(--transition-fast);
  font-size: var(--text-xs);
  color: var(--text-secondary);
  font-weight: 500;
}

.service-type-card:hover {
  border-color: var(--border-strong);
  background: var(--bg-elevated);
}

.service-type-card.selected {
  border-color: var(--brand);
  background: var(--brand-subtle);
  color: var(--brand);
}

.service-type-card .st-icon {
  font-size: 1.5rem;
  margin-bottom: var(--space-2);
  display: block;
}

/* --- CUSTOMER DETAIL --- */
.detail-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: var(--space-8);
  flex-wrap: wrap;
  gap: var(--space-4);
}

.detail-name {
  font-size: var(--text-2xl);
  margin-bottom: var(--space-2);
}

.detail-meta {
  display: flex;
  gap: var(--space-5);
  flex-wrap: wrap;
}

.detail-meta-item {
  font-size: var(--text-sm);
  color: var(--text-tertiary);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.detail-section {
  margin-bottom: var(--space-8);
}

.detail-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-4);
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--border-default);
}

.detail-section-header h3 {
  font-size: var(--text-base);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

/* --- INFO CARDS --- */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--space-4);
}

.info-card {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  transition: all var(--transition-base);
}

.info-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-sm);
}

.info-card .card-title {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--space-3);
}

.info-card .card-row {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-bottom: var(--space-1);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.info-card .card-row span {
  color: var(--text-secondary);
}

.info-card .card-actions {
  margin-top: var(--space-4);
  padding-top: var(--space-3);
  border-top: 1px solid var(--border-default);
  display: flex;
  gap: var(--space-2);
}

/* --- CUSTOMER CARD (List View) --- */
.customer-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: var(--space-4);
}

.customer-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xl);
  padding: var(--space-5);
  cursor: pointer;
  transition: all var(--transition-base);
  display: flex;
  gap: var(--space-4);
}

.customer-card:hover {
  border-color: var(--border-strong);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.customer-avatar {
  width: 44px; height: 44px;
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-base);
  font-weight: 700;
  color: white;
  flex-shrink: 0;
  font-family: var(--font-display);
}

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

.customer-card-name {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--space-1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.customer-card-detail {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-bottom: 2px;
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

.customer-card-footer {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-top: var(--space-3);
}

/* --- TECHNICIAN CARDS --- */
.tech-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xl);
  padding: var(--space-5);
  transition: all var(--transition-base);
  position: relative;
  overflow: hidden;
}

.tech-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--tech-color, var(--brand));
}

.tech-card:hover {
  border-color: var(--border-strong);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.tech-card-header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.tech-card-avatar {
  width: 40px; height: 40px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-sm);
  font-weight: 700;
  color: white;
  flex-shrink: 0;
  font-family: var(--font-display);
}

.tech-card-name {
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--text-primary);
}

.tech-card-status {
  margin-left: auto;
}

.tech-card-detail {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-bottom: var(--space-1);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.tech-card-specialties {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
  margin-top: var(--space-3);
}

.specialty-tag {
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 0.6875rem;
  color: var(--text-tertiary);
  font-weight: 500;
}

.tech-card-actions {
  display: flex;
  gap: var(--space-2);
  margin-top: var(--space-4);
  padding-top: var(--space-3);
  border-top: 1px solid var(--border-default);
}

/* --- DASHBOARD --- */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-6);
  margin-top: var(--space-6);
}

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

.dashboard-card-header {
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border-default);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.dashboard-card-header h3 {
  font-size: var(--text-sm);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.dashboard-card-body {
  padding: var(--space-4) var(--space-5);
}

.dashboard-card-body.no-pad {
  padding: 0;
}

/* Quick schedule list */
.schedule-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-5);
  border-bottom: 1px solid var(--border-subtle);
  transition: background var(--transition-fast);
  cursor: pointer;
}

.schedule-item:last-child { border-bottom: none; }
.schedule-item:hover { background: var(--bg-hover); }

.schedule-time {
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--text-primary);
  min-width: 50px;
  font-family: var(--font-display);
}

.schedule-info {
  flex: 1;
}

.schedule-title {
  font-size: var(--text-sm);
  color: var(--text-primary);
  font-weight: 500;
}

.schedule-subtitle {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

/* Quick action cards */
.quick-actions {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-3);
}

.quick-action-btn {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  cursor: pointer;
  transition: all var(--transition-base);
  text-align: center;
  font-family: inherit;
  color: var(--text-secondary);
}

.quick-action-btn:hover {
  border-color: var(--brand);
  background: var(--brand-subtle);
  color: var(--brand);
  transform: translateY(-1px);
}

.quick-action-btn .qa-icon {
  font-size: 1.5rem;
  margin-bottom: var(--space-2);
  display: block;
}

.quick-action-btn .qa-label {
  font-size: var(--text-xs);
  font-weight: 550;
}

/* --- EMPTY STATE --- */
.empty-state {
  text-align: center;
  padding: var(--space-16) var(--space-6);
  color: var(--text-tertiary);
}

.empty-state .icon {
  font-size: 3rem;
  margin-bottom: var(--space-4);
  opacity: 0.4;
}

.empty-state h3 {
  color: var(--text-secondary);
  margin-bottom: var(--space-2);
  font-size: var(--text-lg);
}

.empty-state p {
  font-size: var(--text-sm);
  margin-bottom: var(--space-5);
  max-width: 360px;
  margin-left: auto;
  margin-right: auto;
}

/* --- TOAST --- */
.toast-container {
  position: fixed;
  top: var(--space-6);
  right: var(--space-6);
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.toast {
  background: var(--bg-secondary);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  padding: var(--space-3) var(--space-5);
  font-size: var(--text-sm);
  color: var(--text-primary);
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  animation: toastIn 0.35s ease;
  min-width: 280px;
}

.toast.success { border-left: 3px solid var(--green); }
.toast.success .toast-icon { color: var(--green); }
.toast.error { border-left: 3px solid var(--red); }
.toast.error .toast-icon { color: var(--red); }

.toast-icon {
  font-size: 1.1rem;
  flex-shrink: 0;
}

@keyframes toastIn {
  from { transform: translateX(120%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* --- MOBILE --- */
.mobile-header {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0;
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border-default);
  padding: var(--space-3) var(--space-5);
  z-index: 60;
  align-items: center;
  justify-content: space-between;
  height: var(--header-h);
  backdrop-filter: blur(12px);
}

.hamburger {
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 1.4rem;
  cursor: pointer;
  padding: var(--space-1);
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  transition: background var(--transition-fast);
}

.hamburger:hover { background: var(--bg-hover); }

.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 45;
  backdrop-filter: blur(4px);
}

@media (max-width: 768px) {
  .mobile-header { display: flex; }

  .sidebar {
    transform: translateX(-100%);
    z-index: 55;
    width: 280px;
  }

  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay.open { display: block; }

  .main-content {
    margin-left: 0;
    padding-top: var(--header-h);
  }

  .page-header {
    padding: var(--space-4) var(--space-5);
    position: relative;
    top: auto;
  }

  .page-body {
    padding: var(--space-4) var(--space-5);
  }

  .dispatch-header-row, .dispatch-tech-row {
    grid-template-columns: 100px repeat(7, 1fr);
  }

  .dispatch-tech-name {
    padding: var(--space-2);
    font-size: var(--text-xs);
  }

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

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

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

  .customer-card-grid { grid-template-columns: 1fr; }

  .service-type-grid { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); }

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

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

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

  .detail-header { flex-direction: column; }
}

@media (max-width: 480px) {
  .stat-grid { grid-template-columns: 1fr; }
  .card-grid { grid-template-columns: 1fr; }
  .quick-actions { grid-template-columns: 1fr; }
}

/* --- LOADING --- */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-16);
  flex-direction: column;
  gap: var(--space-3);
}

.spinner {
  width: 32px; height: 32px;
  border: 3px solid var(--border-default);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.loading-text {
  font-size: var(--text-sm);
  color: var(--text-muted);
}

/* --- BACK LINK --- */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--text-muted);
  font-size: var(--text-sm);
  cursor: pointer;
  margin-bottom: var(--space-4);
  transition: color var(--transition-fast);
  background: none;
  border: none;
  font-family: inherit;
  font-weight: 500;
}

.back-link:hover { color: var(--brand); }

/* ============================================================
   PRICE BOOK STYLES
   ============================================================ */

/* Search & Filter Bar */
.pb-toolbar {
  display: flex; align-items: center; gap: 12px; margin-bottom: 24px; flex-wrap: wrap;
}
.pb-search {
  flex: 1; min-width: 280px; background: var(--dark-2); border: 1px solid rgba(139,148,158,0.15);
  border-radius: 10px; padding: 12px 16px 12px 42px; color: var(--gray-2);
  font-size: 0.95rem; outline: none; font-family: inherit; transition: border-color 0.15s;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%238B949E' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: 14px center;
}
.pb-search:focus { border-color: var(--brand); }
.pb-search::placeholder { color: var(--gray-1); }

.pb-filter-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 10px 16px; border-radius: 10px; font-size: 0.85rem;
  font-weight: 500; cursor: pointer; transition: all 0.15s;
  border: 1px solid rgba(139,148,158,0.2); background: var(--dark-2); color: var(--gray-2);
  font-family: inherit;
}
.pb-filter-btn:hover { border-color: var(--brand); color: var(--brand); }
.pb-filter-btn.active { background: var(--brand-light); border-color: var(--brand); color: var(--brand); }

/* Category Pills */
.pb-categories {
  display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 20px;
  -webkit-overflow-scrolling: touch; scrollbar-width: none;
}
.pb-categories::-webkit-scrollbar { display: none; }

.pb-cat-pill {
  display: flex; align-items: center; gap: 6px; padding: 8px 16px;
  border-radius: 20px; font-size: 0.8rem; font-weight: 500;
  white-space: nowrap; cursor: pointer; transition: all 0.15s;
  border: 1px solid rgba(139,148,158,0.15); background: var(--dark-2); color: var(--gray-1);
  font-family: inherit;
}
.pb-cat-pill:hover { border-color: var(--brand); color: var(--brand); }
.pb-cat-pill.active {
  background: var(--brand); border-color: var(--brand); color: white;
}
.pb-cat-pill .cat-count {
  background: rgba(255,255,255,0.2); padding: 1px 6px; border-radius: 10px;
  font-size: 0.7rem;
}
.pb-cat-pill.active .cat-count { background: rgba(255,255,255,0.3); }

/* Product Card Grid */
.pb-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.pb-card {
  background: var(--dark-2); border: 1px solid rgba(139,148,158,0.08);
  border-radius: 14px; overflow: hidden; cursor: pointer;
  transition: all 0.2s; position: relative;
}
.pb-card:hover {
  border-color: rgba(232, 93, 38, 0.3);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}

.pb-card-img {
  width: 100%; aspect-ratio: 1; object-fit: cover;
  background: var(--dark-3); display: block;
}

.pb-card-body { padding: 14px 16px; }

.pb-card-cat {
  font-size: 0.7rem; color: var(--gray-1); text-transform: uppercase;
  letter-spacing: 0.5px; margin-bottom: 4px; display: flex; align-items: center; gap: 4px;
}

.pb-card-name {
  font-family: 'Space Grotesk', sans-serif; font-size: 0.95rem;
  color: var(--white); font-weight: 600; margin-bottom: 4px;
  line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2;
  -webkit-box-orient: vertical; overflow: hidden;
}

.pb-card-desc {
  font-size: 0.78rem; color: var(--gray-1); margin-bottom: 10px;
  line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2;
  -webkit-box-orient: vertical; overflow: hidden;
}

.pb-card-price-row {
  display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap;
}

.pb-card-price {
  font-family: 'Space Grotesk', sans-serif; font-size: 1.15rem;
  color: var(--brand); font-weight: 700;
}
.pb-card-cost {
  font-size: 0.75rem; color: var(--gray-1);
}
.pb-card-sku {
  font-size: 0.7rem; color: var(--gray-1); margin-left: auto;
  font-family: monospace;
}

.pb-card-footer {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px; border-top: 1px solid rgba(139,148,158,0.06);
}

.pb-card-stock {
  font-size: 0.72rem; display: flex; align-items: center; gap: 4px;
}
.pb-card-stock.in-stock { color: var(--green); }
.pb-card-stock.low-stock { color: var(--yellow); }
.pb-card-stock.out-of-stock { color: var(--red); }

.pb-card-badge {
  position: absolute; top: 12px; right: 12px;
  background: var(--brand); color: white; font-size: 0.65rem;
  font-weight: 700; padding: 3px 8px; border-radius: 6px;
  text-transform: uppercase; letter-spacing: 0.5px;
}

.pb-card-warranty {
  font-size: 0.7rem; color: var(--gray-1);
}

/* Quick-Add Button */
.pb-quick-add {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: 8px;
  background: var(--brand-light); color: var(--brand);
  border: none; cursor: pointer; font-size: 1rem; transition: all 0.15s;
}
.pb-quick-add:hover { background: var(--brand); color: white; }

/* Item Detail View */
.pb-detail {
  display: grid; grid-template-columns: 1fr 1fr; gap: 32px;
}
.pb-detail-img {
  width: 100%; border-radius: 14px; background: var(--dark-3);
  aspect-ratio: 1; object-fit: cover;
}
.pb-detail-info { display: flex; flex-direction: column; gap: 16px; }

.pb-price-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px;
}
.pb-price-box {
  background: var(--dark-3); border-radius: 10px; padding: 12px;
  border: 1px solid rgba(139,148,158,0.06);
}
.pb-price-box .label { font-size: 0.72rem; color: var(--gray-1); margin-bottom: 4px; }
.pb-price-box .price {
  font-family: 'Space Grotesk', sans-serif; font-size: 1.1rem;
  font-weight: 700; color: var(--white);
}
.pb-price-box .price.brand { color: var(--brand); }

.pb-meta-row {
  display: flex; gap: 12px; flex-wrap: wrap;
}
.pb-meta-tag {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 10px; border-radius: 6px; font-size: 0.75rem; font-weight: 500;
  background: var(--dark-3); color: var(--gray-2);
  border: 1px solid rgba(139,148,158,0.08);
}

/* Result Count / Empty */
.pb-results-info {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px; flex-wrap: wrap; gap: 8px;
}
.pb-results-count { font-size: 0.85rem; color: var(--gray-1); }

/* Section header */
.pb-section-title {
  font-family: 'Space Grotesk', sans-serif; font-size: 1rem;
  color: var(--white); font-weight: 600; margin-bottom: 16px;
  display: flex; align-items: center; gap: 8px;
}

/* Comparison table */
.pb-compare-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px;
}

@media (max-width: 768px) {
  .pb-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
  .pb-card-body { padding: 10px 12px; }
  .pb-card-name { font-size: 0.85rem; }
  .pb-card-price { font-size: 1rem; }
  .pb-detail { grid-template-columns: 1fr; }
  .pb-toolbar { gap: 8px; }
  .pb-search { min-width: unset; }
  .pb-price-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ============================================================
   MODAL TABS
   ============================================================ */
.modal-tabs {
  display: flex; gap: 4px; padding: 0 24px;
  border-bottom: 1px solid rgba(139,148,158,0.08);
  margin-bottom: 0;
}
.modal-tab {
  background: none; border: none; font-family: inherit;
  font-size: 0.85rem; font-weight: 500; color: var(--gray-1);
  padding: 12px 16px; cursor: pointer; transition: all 0.15s;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
  display: inline-flex; align-items: center; gap: 8px;
}
.modal-tab:hover { color: var(--gray-2); }
.modal-tab.active { color: var(--brand); border-bottom-color: var(--brand); }
.tab-badge {
  background: var(--brand); color: white;
  font-size: 0.7rem; padding: 1px 7px; border-radius: 10px; font-weight: 600;
}

/* ============================================================
   MEDIA PANEL (inside job modal)
   ============================================================ */
.media-panel { padding: 4px 0; }

.media-capture-bar {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 0; flex-wrap: wrap;
}
.camera-btn {
  display: inline-flex; align-items: center; gap: 8px;
  cursor: pointer;
}
.camera-btn svg, .camera-btn span { pointer-events: none; }

/* Media empty state */
.media-empty {
  border: 2px dashed rgba(139,148,158,0.15); border-radius: 10px;
  padding: 40px 20px; text-align: center; color: var(--gray-1);
}

/* Media thumbnail grid */
.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 10px;
  margin-top: 8px;
}

.media-thumb {
  position: relative; border-radius: 8px; overflow: hidden;
  aspect-ratio: 1 / 1; cursor: pointer; background: var(--dark-3);
  transition: transform 0.15s, box-shadow 0.15s;
}
.media-thumb:hover { transform: scale(1.03); box-shadow: 0 4px 16px rgba(0,0,0,0.4); }
.media-thumb img {
  width: 100%; height: 100%; object-fit: cover; display: block;
}

/* Video thumb */
.media-thumb-video {
  position: relative; width: 100%; height: 100%;
}
.media-thumb-video video { width: 100%; height: 100%; object-fit: cover; display: block; }
.media-play-icon {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  background: rgba(0,0,0,0.65); color: white; font-size: 1.2rem;
  width: 36px; height: 36px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  pointer-events: none; padding-left: 3px;
}

/* Tag overlay on thumbnail */
.media-thumb-tag {
  position: absolute; bottom: 0; left: 0; right: 0;
  padding: 3px 7px; font-size: 0.65rem; font-weight: 600;
  text-overflow: ellipsis; overflow: hidden; white-space: nowrap;
  backdrop-filter: blur(2px);
}
.media-thumb-caption {
  position: absolute; top: 4px; right: 4px;
  background: rgba(0,0,0,0.65); color: var(--gray-2);
  font-size: 0.6rem; padding: 2px 6px; border-radius: 4px;
  max-width: 90px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ============================================================
   MEDIA VIEWER (lightbox overlay)
   ============================================================ */
.media-viewer-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.85); backdrop-filter: blur(6px);
  z-index: 500; display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.media-viewer-content {
  background: var(--dark-2); border: 1px solid rgba(139,148,158,0.15);
  border-radius: 16px; padding: 24px; max-width: 700px; width: 100%;
  position: relative; box-shadow: 0 24px 80px rgba(0,0,0,0.6);
  max-height: 90vh; overflow-y: auto;
}
.media-viewer-close {
  position: absolute; top: 12px; right: 14px;
  background: var(--dark-3); border: none; color: var(--gray-1);
  font-size: 1.3rem; width: 32px; height: 32px; border-radius: 6px;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: all 0.15s; z-index: 1;
}
.media-viewer-close:hover { background: var(--red-bg); color: var(--red); }
.media-viewer-meta {
  margin-top: 16px; display: flex; flex-direction: column; gap: 12px;
}
.media-viewer-tag-edit {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.media-viewer-tag-edit label { font-size: 0.8rem; color: var(--gray-1); min-width: 28px; }

/* ============================================================
   TAG FILTER BUTTONS (Media Library)
   ============================================================ */
.media-tag-filters {
  display: flex; flex-wrap: wrap; gap: 8px;
  margin-bottom: 24px;
}
.tag-filter-btn {
  background: var(--dark-3); border: 1px solid rgba(139,148,158,0.15);
  border-radius: 20px; padding: 5px 14px; font-size: 0.8rem;
  color: var(--gray-1); cursor: pointer; transition: all 0.15s;
  font-family: inherit;
}
.tag-filter-btn:hover { border-color: var(--gray-1); color: var(--gray-2); }
.tag-filter-btn.active {
  background: var(--tag-color, var(--brand));
  border-color: var(--tag-color, var(--brand));
  color: white; font-weight: 600;
}

/* ============================================================
   MEDIA LIBRARY PAGE
   ============================================================ */
.media-library-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}
.media-library-item {
  background: var(--dark-2); border: 1px solid rgba(139,148,158,0.08);
  border-radius: 12px; overflow: hidden; cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
}
.media-library-item:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(0,0,0,0.3); }
.media-lib-thumb {
  width: 100%; aspect-ratio: 4 / 3; overflow: hidden;
  position: relative; background: var(--dark-3);
}
.media-lib-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.media-lib-info {
  padding: 10px 12px; display: flex; flex-direction: column; gap: 4px;
}
.media-lib-tag {
  display: inline-block; padding: 2px 8px; border-radius: 5px;
  font-size: 0.72rem; font-weight: 600; align-self: flex-start;
}
.media-lib-customer {
  font-size: 0.82rem; color: var(--gray-2); font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.media-lib-job {
  font-size: 0.75rem; color: var(--gray-1);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.media-lib-date { font-size: 0.72rem; color: var(--gray-1); }

/* ============================================================
   CUSTOMER MEDIA SECTION
   ============================================================ */
.customer-media-section {
  background: var(--dark-2); border: 1px solid rgba(139,148,158,0.08);
  border-radius: 12px; padding: 20px; margin-bottom: 32px;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .media-grid { grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); gap: 8px; }
  .media-library-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
  .media-capture-bar { gap: 8px; }
  .media-viewer-content { padding: 16px; }
}
