:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --border: #e2e8f0;
  --border-light: #f1f5f9;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-tertiary: #64748b;
  --text-muted: #94a3b8;
  /* Brand palette — sampled from the ModWash teardrop logo */
  --brand-indigo: #2a2a8c;
  --brand-blue: #2756c4;
  --brand-purple: #6d28d9;
  --brand-magenta: #d6168f;
  --brand-red: #e23744;
  --brand-orange: #f6a01a;
  --brand-teal: #15b8a6;
  --brand-gradient: linear-gradient(135deg, #2a2a8c 0%, #6d28d9 45%, #d6168f 100%);
  --brand-gradient-bar: linear-gradient(90deg, #2a2a8c 0%, #2756c4 22%, #6d28d9 44%, #d6168f 64%, #e23744 82%, #f6a01a 100%);
  --accent: #2f3aa3;
  --accent-hover: #232b80;
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --danger-border: #fecaca;
  --success: #16a34a;
  --warning: #d97706;
  --info: #2563eb;
  --radius: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06);
  --shadow-lg: 0 20px 25px -5px rgba(0,0,0,0.1), 0 10px 10px -5px rgba(0,0,0,0.04);
  --font: 'Inter', system-ui, -apple-system, sans-serif;
  --mono: 'JetBrains Mono', monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ===========================
   LOGIN SCREEN
   =========================== */
.login-screen {
  min-height: 100vh;
  background: linear-gradient(135deg, #1e2a78 0%, #6d28d9 42%, #d6168f 78%, #e23744 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.login-card {
  background: white;
  border-radius: var(--radius-xl);
  padding: 3rem;
  width: 100%;
  max-width: 440px;
  box-shadow: 0 25px 50px -12px rgba(0,0,0,0.5);
}

.login-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.logo-box {
  width: 48px;
  height: 48px;
  background: #0f172a;
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.logo-box.small {
  width: 32px;
  height: 32px;
  border-radius: var(--radius);
}

.brand-logo {
  height: 88px;
  width: auto;
  display: block;
  flex-shrink: 0;
}

.brand-logo.small {
  height: 46px;
}

.login-header h1 {
  margin: 0;
  font-size: 28px;
  font-weight: 800;
  letter-spacing: 0.02em;
  background: var(--brand-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.login-header p {
  margin: 0;
  font-size: 13px;
  color: var(--text-tertiary);
}

.login-subtitle {
  color: var(--text-tertiary);
  font-size: 14px;
  margin: 1.5rem 0 2rem;
}

.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: #334155;
  margin-bottom: 6px;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #cbd5e1;
  border-radius: var(--radius);
  font-size: 14px;
  outline: none;
  font-family: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
  background: white;
  color: var(--text-primary);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--brand-blue);
  box-shadow: 0 0 0 3px rgba(39,86,196,0.15);
}

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

.password-wrapper {
  position: relative;
}

.password-toggle {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-tertiary);
  padding: 4px;
  display: flex;
  align-items: center;
}

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

.login-error {
  background: var(--danger-bg);
  color: #991b1b;
  padding: 10px 12px;
  border-radius: var(--radius);
  font-size: 13px;
  margin-bottom: 1rem;
  border: 1px solid var(--danger-border);
}

.login-setpw-hint {
  font-size: 13px;
  color: var(--text-secondary);
  background: var(--border-light);
  border-radius: var(--radius);
  padding: 10px 12px;
  margin: 0 0 1rem;
}

.btn-link-subtle {
  display: block;
  width: 100%;
  margin-top: 10px;
  background: none;
  border: none;
  color: var(--text-tertiary);
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
  padding: 4px;
}
.btn-link-subtle:hover { color: var(--text-primary); }

.btn-primary {
  padding: 10px 16px;
  background: var(--brand-gradient);
  background-size: 140% 140%;
  background-position: 0% 50%;
  color: white;
  border: none;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background-position 0.25s ease, box-shadow 0.15s, transform 0.05s;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-primary:hover { background-position: 100% 50%; box-shadow: 0 4px 12px rgba(109,40,217,0.3); }
.btn-primary:active { transform: scale(0.98); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-secondary {
  padding: 10px 16px;
  background: white;
  color: var(--text-secondary);
  border: 1px solid #cbd5e1;
  border-radius: var(--radius);
  font-size: 14px;
  cursor: pointer;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

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

.btn-danger {
  padding: 10px 16px;
  background: white;
  color: var(--danger);
  border: 1px solid var(--danger-border);
  border-radius: var(--radius);
  font-size: 14px;
  cursor: pointer;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

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

.btn-full { width: 100%; justify-content: center; }

.btn-icon {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px;
  cursor: pointer;
  color: var(--text-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

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

.demo-accounts {
  margin-top: 2rem;
  padding: 1rem;
  background: var(--bg);
  border-radius: var(--radius);
  font-size: 12px;
  color: var(--text-tertiary);
}

.demo-title {
  font-weight: 500;
  color: #334155;
  margin-bottom: 8px;
}

.demo-item {
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.role-tag {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 500;
}

.role-admin { background: #fef2f2; color: #991b1b; }
.role-tech { background: #eff6ff; color: #1e40af; }
.role-user { background: #f1f5f9; color: #475569; }

/* ===========================
   APP LAYOUT
   =========================== */
.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.header {
  background: white;
  border-bottom: 1px solid var(--border);
  border-top: 4px solid transparent;
  border-image: var(--brand-gradient-bar) 1;
  padding: 12px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 10;
}

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

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

.brand-name {
  font-size: 17px;
  font-weight: 800;
  letter-spacing: 0.02em;
  background: var(--brand-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.nav {
  display: flex;
  gap: 4px;
}

.nav-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: transparent;
  color: var(--text-tertiary);
  border: none;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
}

.nav-btn:hover { background: var(--border-light); color: var(--text-primary); }
.nav-btn.active { background: rgba(39,86,196,0.10); color: var(--brand-blue); }

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

.user-info { text-align: right; }
.user-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
}

.main {
  padding: 1.5rem 1.75rem;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
}

/* ===========================
   VIEW HEADERS
   =========================== */
.view-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.view-header h2 {
  margin: 0;
  font-size: 22px;
  font-weight: 600;
}

.view-header .subtitle {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--text-tertiary);
}

/* ===========================
   STAT CARDS
   =========================== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 1.5rem;
}

.stat-card {
  padding: 14px 16px;
  border-radius: var(--radius-lg);
}

.stat-card .stat-label {
  font-size: 11px;
  font-weight: 500;
  opacity: 0.7;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.stat-card .stat-value {
  font-size: 26px;
  font-weight: 600;
  margin-top: 2px;
  line-height: 1.2;
}

.stat-card.stat-total { background: #f1f5f9; color: #0f172a; }
.stat-card.stat-open { background: #e0f2fe; color: #0c4a6e; }
.stat-card.stat-progress { background: #fef3c7; color: #854d0e; }
.stat-card.stat-resolved { background: #dcfce7; color: #166534; }

/* ===========================
   DASHBOARD CHARTS
   =========================== */
.charts-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 1.5rem;
}

.chart-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: var(--shadow-sm);
}

.chart-card-head {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-tertiary);
  margin-bottom: 14px;
}

.chart-donut-wrap {
  display: flex;
  align-items: center;
  gap: 16px;
}

.chart-donut { flex-shrink: 0; }
.chart-donut circle { transition: stroke-dasharray 0.4s ease; }
.chart-donut-num { font-size: 26px; font-weight: 700; fill: var(--text-primary); font-family: var(--font); }
.chart-donut-sub { font-size: 10px; fill: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; font-family: var(--font); }

.chart-legend {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  color: var(--text-secondary);
  min-width: 0;
}

.chart-legend-item { display: flex; align-items: center; gap: 7px; white-space: nowrap; }
.chart-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.chart-legend-val { margin-left: auto; font-weight: 600; color: var(--text-primary); font-variant-numeric: tabular-nums; }

.chart-bars { display: flex; flex-direction: column; gap: 11px; }
.chart-bar-row { display: grid; grid-template-columns: 78px 1fr 28px; align-items: center; gap: 10px; }
.chart-bar-label { font-size: 12px; color: var(--text-secondary); }
.chart-bar-track { background: var(--border-light); border-radius: 999px; height: 9px; overflow: hidden; }
.chart-bar-fill { height: 100%; border-radius: 999px; min-width: 0; transition: width 0.4s ease; }
.chart-bar-val { font-size: 12px; font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; color: var(--text-primary); }

@media (max-width: 880px) {
  .charts-grid { grid-template-columns: 1fr; }
}

/* ===========================
   SITE STATUS (UniFi)
   =========================== */
.net-notice {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--brand-blue);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  color: var(--text-secondary);
}
.net-notice strong { color: var(--text-primary); }
.net-notice .subtle { font-size: 13px; margin-top: 4px; }
.net-notice code { background: var(--border-light); padding: 1px 5px; border-radius: 4px; font-family: var(--mono); font-size: 12px; }
.net-notice-error { border-left-color: var(--danger); }

.net-fetched { font-size: 12px; color: var(--text-muted); margin-bottom: 12px; }

.net-card-list { display: flex; flex-direction: column; gap: 10px; }

.net-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.net-card-down { border-color: var(--danger-border); }

.net-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  cursor: pointer;
}
.net-card-head:hover { background: var(--border-light); }
.net-card-name { font-weight: 600; font-size: 15px; color: var(--text-primary); }
.net-card-sub { font-size: 12px; color: var(--text-tertiary); margin-top: 2px; }
.net-unmatched { background: var(--border-light); color: var(--text-muted); padding: 1px 6px; border-radius: 4px; font-size: 10px; text-transform: uppercase; letter-spacing: 0.4px; }

.net-card-right { display: flex; align-items: center; gap: 14px; }
.net-card-counts { display: flex; gap: 10px; font-size: 12px; font-weight: 600; color: var(--text-secondary); }
.net-card-counts span { display: inline-flex; align-items: center; gap: 3px; }
.net-count-bad { color: var(--danger); }

.net-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
}
.net-up { background: #dcfce7; color: #166534; }
.net-down { background: #fee2e2; color: #991b1b; }

.net-chevron { color: var(--text-muted); display: inline-flex; transition: transform 0.2s ease; }
.net-chevron.open { transform: rotate(180deg); }

.net-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  padding: 0 16px 12px;
  font-size: 12px;
  color: var(--text-tertiary);
}
.net-card-meta:empty { display: none; }

.net-dev-list { border-top: 1px solid var(--border-light); padding: 6px 0; }
.net-dev-empty { padding: 12px 16px; color: var(--text-muted); font-size: 13px; }
.net-dev-row {
  display: grid;
  grid-template-columns: 16px 1.5fr 1fr 1fr 80px;
  align-items: center;
  gap: 10px;
  padding: 7px 16px;
  font-size: 13px;
}
.net-dev-row:hover { background: var(--border-light); }
.net-dev-name { color: var(--text-primary); font-weight: 500; }
.net-dev-console { font-size: 10px; color: var(--brand-blue); background: rgba(39,86,196,0.1); padding: 1px 5px; border-radius: 4px; font-weight: 600; }
.net-dev-model, .net-dev-ip { color: var(--text-tertiary); font-family: var(--mono); font-size: 11px; }
.net-dev-state { text-align: right; font-weight: 600; font-size: 12px; text-transform: capitalize; }
.net-dev-state.net-online { color: #16a34a; }
.net-dev-state.net-offline { color: var(--danger); }
.net-dev-state.net-unknown { color: var(--text-muted); }

.dev-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.dev-online { background: #16a34a; }
.dev-offline { background: var(--danger); }
.dev-unknown { background: var(--text-muted); }

@media (max-width: 720px) {
  .net-dev-row { grid-template-columns: 16px 1fr 70px; }
  .net-dev-model, .net-dev-ip { display: none; }
}

/* ===========================
   FILTERS
   =========================== */
.filters {
  display: flex;
  gap: 8px;
  margin-bottom: 1rem;
  align-items: center;
  flex-wrap: wrap;
}

.filters select {
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  background: white;
  cursor: pointer;
  font-family: inherit;
}

.filter-clear {
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 12px;
  background: white;
  cursor: pointer;
  color: var(--text-tertiary);
}

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

/* ===========================
   TICKETS LIST
   =========================== */
.tickets-list {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.ticket-row {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-light);
  cursor: pointer;
  transition: background 0.1s;
}

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

.ticket-row-content {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.ticket-row-main { flex: 1; min-width: 0; }

.ticket-row-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
  flex-wrap: wrap;
}

.ticket-id {
  font-size: 11px;
  color: var(--text-tertiary);
  font-family: var(--mono);
}

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

.ticket-row-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 6px;
}

.ticket-row-side {
  text-align: right;
  flex-shrink: 0;
}

.ticket-row-date {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.ticket-row-assignee {
  font-size: 11px;
  color: var(--text-primary);
  font-weight: 500;
}

.ticket-row-assignee.unassigned {
  color: var(--text-muted);
  font-style: italic;
  font-weight: 400;
}

.empty-state {
  padding: 3rem;
  text-align: center;
  color: var(--text-muted);
}

.empty-state svg { opacity: 0.3; margin-bottom: 8px; }
.empty-state p { margin: 0; font-size: 14px; }
.empty-state p.subtle { margin-top: 4px; font-size: 12px; }

/* ===========================
   BADGES
   =========================== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 500;
}

.badge svg { width: 12px; height: 12px; }

.status-Open { background: #e0f2fe; color: #0c4a6e; }
.status-Assigned { background: #ede9fe; color: #5b21b6; }
.status-In-Progress, .status-InProgress { background: #fef3c7; color: #854d0e; }
.status-Resolved { background: #dcfce7; color: #166534; }
.status-Closed { background: #f1f5f9; color: #475569; }

.priority-Low { background: #e0f2fe; color: #0c4a6e; border-left: 3px solid #0284c7; }
.priority-Medium { background: #fef3c7; color: #854d0e; border-left: 3px solid #d97706; }
.priority-High { background: #ffedd5; color: #9a3412; border-left: 3px solid #ea580c; }
.priority-Critical { background: #fee2e2; color: #991b1b; border-left: 3px solid #dc2626; }

.role-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 500;
}

.role-badge.role-SUPER_ADMIN { background: #fef2f2; color: #991b1b; }
.role-badge.role-FIELD_TECH { background: #eff6ff; color: #1e40af; }
.role-badge.role-GENERAL_USER { background: #f1f5f9; color: #475569; }

.location-tag {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  color: var(--text-tertiary);
}

.dept-tag {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid transparent;
}
.dept-POS { background: #ede9fe; color: #6d28d9; border-color: #ddd6fe; }
.dept-IT { background: #dbeafe; color: #1d4ed8; border-color: #bfdbfe; }
.dept-Maintenance { background: #fef3c7; color: #b45309; border-color: #fde68a; }

/* ===========================
   INVENTORY VIEW
   =========================== */
.inv-toolbar { margin-bottom: 1rem; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.inv-cat-filter {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: white;
  font-size: 13px;
  color: var(--text-primary);
}
.inv-search {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 12px;
  max-width: 420px;
  color: var(--text-tertiary);
}
.inv-search input {
  border: none;
  outline: none;
  flex: 1;
  font-size: 13px;
  background: transparent;
  color: var(--text-primary);
}

.inv-table {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.inv-header, .inv-row {
  display: grid;
  grid-template-columns: 1.8fr 1.4fr 0.8fr 1.6fr 80px;
  padding: 12px 16px;
  align-items: center;
  gap: 8px;
}
.inv-header {
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-tertiary);
}
.inv-row {
  border-bottom: 1px solid var(--border-light);
  font-size: 13px;
}
.inv-row:last-child { border-bottom: none; }
.inv-name { font-weight: 500; color: var(--text-primary); }
.inv-qty {
  display: inline-block;
  min-width: 28px;
  text-align: center;
  font-weight: 600;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 2px 8px;
}
.inv-loc { display: flex; align-items: center; gap: 5px; color: var(--text-secondary); }
.inv-loc-sub { color: var(--text-tertiary); font-size: 12px; }
.inv-empty { padding: 32px 16px; text-align: center; color: var(--text-muted); font-size: 13px; }

.inv-cat-tag {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid transparent;
  white-space: nowrap;
}
.inv-cat-IT-Equipment { background: #dbeafe; color: #1d4ed8; border-color: #bfdbfe; }
.inv-cat-POS-Equipment { background: #ede9fe; color: #6d28d9; border-color: #ddd6fe; }
.inv-cat-Car-Wash-Equipment { background: #ccfbf1; color: #0f766e; border-color: #99f6e4; }
.inv-cat-none { font-size: 11px; color: var(--text-muted); font-style: italic; }

@media (max-width: 720px) {
  .inv-header, .inv-row { grid-template-columns: 1.6fr 1.2fr 0.6fr 80px; }
  .inv-header > *:nth-child(4), .inv-row > *:nth-child(4) { display: none; }
}

.site-list-header, .site-list-row {
  display: grid;
  grid-template-columns: 0.9fr 2.2fr 0.5fr 0.6fr 1.6fr 60px;
  padding: 12px 16px;
  align-items: center;
  gap: 8px;
}
.site-list-header {
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-tertiary);
}
.site-list-row {
  border-bottom: 1px solid var(--border-light);
  font-size: 13px;
}
.site-list-row:last-child { border-bottom: none; }
.site-list-code { font-weight: 600; color: var(--text-primary); }
.site-list-name { font-weight: 500; color: var(--text-primary); }
.site-list-sub { font-size: 11px; color: var(--text-tertiary); margin-top: 2px; }

@media (max-width: 760px) {
  .site-list-header, .site-list-row { grid-template-columns: 0.9fr 1.8fr 0.5fr 60px; }
  .site-list-header > *:nth-child(4), .site-list-row > *:nth-child(4),
  .site-list-header > *:nth-child(5), .site-list-row > *:nth-child(5) { display: none; }
}

/* ===========================
   METRICS VIEW
   =========================== */
.metric-range-toggle {
  display: inline-flex;
  gap: 4px;
  background: var(--surface-2, #f1f5f9);
  border: 1px solid var(--border, #e2e8f0);
  border-radius: var(--radius-lg);
  padding: 4px;
}
.metric-range-btn {
  border: none;
  background: transparent;
  color: var(--text-secondary, #475569);
  font-size: 13px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: var(--radius-md, 8px);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.metric-range-btn:hover { color: var(--text-primary, #0f172a); }
.metric-range-btn.active {
  background: #2756c4;
  color: #fff;
}

.metric-kpis {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 1.25rem;
}
.metric-kpi {
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  color: white;
}
.metric-kpi-value { font-size: 30px; font-weight: 800; line-height: 1; }
.metric-kpi-label { font-size: 12px; font-weight: 600; opacity: 0.92; margin-top: 6px; text-transform: uppercase; letter-spacing: 0.04em; }
.kpi-created { background: linear-gradient(135deg, #2a2a8c, #2756c4); }
.kpi-assigned { background: linear-gradient(135deg, #6d28d9, #9333ea); }
.kpi-resolved { background: linear-gradient(135deg, #0f766e, #15b8a6); }
.kpi-closed { background: linear-gradient(135deg, #b3185f, #d6168f); }

.metric-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.metric-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.metric-card-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 14px 16px 10px;
}
.metric-card-head h3 { margin: 0; font-size: 15px; }
.metric-card-hint { font-size: 11px; color: var(--text-muted); }

.metric-table { width: 100%; }
.metric-row {
  display: grid;
  grid-template-columns: 1.6fr repeat(4, 1fr);
  align-items: center;
  padding: 10px 16px;
  border-top: 1px solid var(--border-light);
  font-size: 13px;
}
.metric-head {
  border-top: 1px solid var(--border);
  background: var(--bg);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-tertiary);
}
.metric-row-label { font-weight: 600; color: var(--text-primary); }
.metric-cell { text-align: center; font-variant-numeric: tabular-nums; }
.metric-row .metric-created { font-weight: 700; color: var(--brand-blue); }
.metric-row .metric-assigned { color: var(--brand-purple); }
.metric-row .metric-resolved { color: var(--brand-teal); }
.metric-row .metric-closed { color: var(--brand-magenta); }
.metric-row.clickable { cursor: pointer; transition: background 0.12s; }
.metric-row.clickable:hover { background: rgba(39,86,196,0.06); }
.metric-empty { padding: 22px 16px; text-align: center; color: var(--text-muted); font-size: 13px; }

.metric-deepdive {
  margin-top: 16px;
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 18px 20px;
  border-top: 3px solid transparent;
  border-image: var(--brand-gradient-bar) 1;
}
.metric-deepdive-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 8px;
}
.metric-deepdive-head h3 { margin: 0 0 2px; font-size: 17px; }
.metric-deepdive .metric-table { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; margin-bottom: 4px; }
.metric-deepdive .metric-head { border-top: none; }

.metric-ticket-list { display: flex; flex-direction: column; gap: 6px; }
.metric-ticket-loc { font-size: 12px; color: var(--text-tertiary); }
.metric-ticket-assignee { font-size: 12px; color: var(--text-tertiary); margin-left: auto; }

.chart-grid {
  display: grid;
  grid-template-columns: 0.85fr 1.05fr 1.05fr;
  gap: 16px;
  margin-bottom: 16px;
}
.chart-card { padding-bottom: 8px; }
.donut-wrap { display: flex; justify-content: center; align-items: center; padding: 14px 0 20px; }
.donut { width: 168px; height: 168px; }
.donut-total { font-size: 28px; font-weight: 800; fill: var(--text-primary); }
.donut-sub { font-size: 11px; fill: var(--text-muted); letter-spacing: 0.04em; }

.chart-bars { padding: 8px 16px 18px; display: flex; flex-direction: column; gap: 11px; }
.chart-bar-row { display: grid; grid-template-columns: 92px 1fr 30px; align-items: center; gap: 10px; }
.chart-bar-label { font-size: 12px; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chart-bar-track { background: var(--border-light); border-radius: 999px; height: 14px; overflow: hidden; }
.chart-bar-fill { height: 100%; display: flex; border-radius: 999px; overflow: hidden; min-width: 3px; }
.bar-seg { display: block; }
.chart-bar-value { font-size: 12px; font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; color: var(--text-primary); }

.chart-status-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  padding: 12px 16px;
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: 16px;
}
.chart-legend-item { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-secondary); }
.chart-legend-item strong { color: var(--text-primary); }
.chart-swatch { width: 12px; height: 12px; border-radius: 3px; display: inline-block; flex-shrink: 0; }

.chart-grid.dd-charts { grid-template-columns: 0.8fr 1.2fr; }

@media (max-width: 980px) {
  .chart-grid, .chart-grid.dd-charts { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .metric-grid { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .metric-kpis { grid-template-columns: repeat(2, 1fr); }
}

/* ===========================
   PHOTOS
   =========================== */
.btn-sm { padding: 5px 10px; font-size: 12px; }
.photo-uploader { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.photo-thumbs { display: flex; flex-wrap: wrap; gap: 8px; }
.photo-thumb { position: relative; width: 84px; height: 84px; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); }
.photo-thumb img { width: 100%; height: 100%; object-fit: cover; cursor: zoom-in; display: block; }
.photo-thumb-del {
  position: absolute; top: 3px; right: 3px;
  width: 20px; height: 20px; border-radius: 50%;
  border: none; background: rgba(15,23,42,0.7); color: white;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; padding: 0;
}
.photo-thumb-del:hover { background: var(--danger); }

.photo-groups { display: flex; flex-direction: column; gap: 14px; margin-bottom: 8px; }
.photo-group { border: 1px solid var(--border-light); border-radius: var(--radius); padding: 10px 12px; }
.photo-group-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.photo-group-label { font-size: 12px; font-weight: 600; color: var(--text-secondary); }
.photo-group-count { color: var(--text-muted); font-weight: 400; margin-left: 2px; }
.photo-empty { font-size: 12px; color: var(--text-muted); font-style: italic; }

.photo-lightbox {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(0,0,0,0.85);
  display: flex; align-items: center; justify-content: center;
  padding: 3vh 3vw; cursor: zoom-out;
}
.photo-lightbox img { max-width: 96vw; max-height: 94vh; border-radius: 8px; box-shadow: 0 10px 40px rgba(0,0,0,0.5); }
.photo-lightbox-close {
  position: fixed; top: 18px; right: 22px;
  width: 40px; height: 40px; border-radius: 50%;
  border: none; background: rgba(255,255,255,0.15); color: white;
  display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.photo-lightbox-close:hover { background: rgba(255,255,255,0.3); }

/* Attachments */
.file-list { display: flex; flex-wrap: wrap; gap: 8px; }
.file-chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--border-light); border: 1px solid var(--border);
  border-radius: 999px; padding: 5px 8px 5px 10px; font-size: 12px; color: var(--text-secondary);
}
.file-chip-name { font-weight: 500; color: var(--text-primary); max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-chip-size { color: var(--text-muted); }
.file-chip-del { border: none; background: transparent; cursor: pointer; color: var(--text-muted); display: flex; padding: 2px; border-radius: 50%; }
.file-chip-del:hover { background: rgba(0,0,0,0.08); color: var(--danger); }

.file-attachments { display: flex; flex-direction: column; gap: 6px; }
.file-row {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border: 1px solid var(--border); border-radius: var(--radius);
}
.file-row-icon { color: var(--brand-blue); display: flex; flex-shrink: 0; }
.file-row-name {
  flex: 1; text-align: left; border: none; background: transparent; cursor: pointer;
  font-size: 13px; font-weight: 500; color: var(--brand-blue); padding: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.file-row-name:hover { text-decoration: underline; }
.file-row-size { font-size: 12px; color: var(--text-muted); flex-shrink: 0; }
.file-row-actions { display: flex; gap: 2px; flex-shrink: 0; }

/* ===========================
   TRIP PLANNING VIEW
   =========================== */
.trip-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}
.trip-control-label { font-size: 13px; font-weight: 600; color: var(--text-secondary); }
#trip-tech {
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: white;
  font-size: 14px;
  min-width: 300px;
  color: var(--text-primary);
}
.trip-panel {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
}
.trip-empty { padding: 28px 8px; text-align: center; color: var(--text-muted); font-size: 14px; }

.trip-home {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-secondary);
  padding: 10px 12px;
  background: var(--bg);
  border-radius: var(--radius);
  margin-bottom: 14px;
}
.trip-home.muted { color: var(--text-muted); font-style: italic; }
.trip-home input { width: 16px; height: 16px; }

.trip-summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border-light);
  margin-bottom: 14px;
  font-size: 13px;
  color: var(--text-secondary);
  flex-wrap: wrap;
}

.trip-assign-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding-bottom: 14px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--border-light);
  font-size: 13px;
  color: var(--text-secondary);
  flex-wrap: wrap;
}

.assign-list { display: flex; flex-direction: column; gap: 6px; max-height: 50vh; overflow-y: auto; }
.assign-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
}
.assign-row:hover { border-color: var(--brand-blue); background: rgba(39,86,196,0.04); }
.assign-row input { width: 16px; height: 16px; flex-shrink: 0; }
.assign-row-title { font-size: 13px; color: var(--text-primary); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.assign-row-sub { font-size: 12px; color: var(--text-tertiary); display: flex; align-items: center; gap: 5px; margin-top: 3px; }

.trip-stops { display: flex; flex-direction: column; gap: 10px; }
.trip-stop {
  display: grid;
  grid-template-columns: 32px 28px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: opacity 0.15s, border-color 0.15s;
}
.trip-stop.excluded { opacity: 0.5; background: var(--bg); }
.trip-stop-order {
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  background: var(--brand-gradient);
  color: white; font-weight: 800; font-size: 14px;
  border-radius: 50%;
}
.trip-stop.excluded .trip-stop-order { background: var(--text-muted); }
.trip-stop-include input { width: 16px; height: 16px; }
.trip-stop-site { font-size: 13px; color: var(--text-primary); display: flex; align-items: center; gap: 5px; }
.trip-stop-addr { font-size: 12px; color: var(--text-tertiary); margin: 2px 0 6px; }
.trip-stop-tickets { display: flex; flex-wrap: wrap; gap: 6px; }
.trip-ticket {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; color: var(--text-secondary);
  background: var(--border-light);
  padding: 2px 8px; border-radius: 999px; cursor: pointer;
}
.trip-ticket:hover { background: rgba(39,86,196,0.1); color: var(--brand-blue); }
.trip-stop-actions { display: flex; align-items: center; gap: 2px; }
.trip-stop-actions .icon-btn[disabled] { opacity: 0.3; cursor: not-allowed; }

@media (max-width: 720px) {
  .trip-stop { grid-template-columns: 28px 24px 1fr; }
  .trip-stop-actions { grid-column: 1 / -1; justify-content: flex-end; }
  #trip-tech { min-width: 0; flex: 1; }
}

/* Saved/scheduled trips + editor meta */
.section-label { font-size: 13px; font-weight: 700; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.03em; margin: 22px 0 10px; }

.trip-card-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 8px; }
.trip-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
}
.trip-card.active { border-color: var(--brand-blue); box-shadow: 0 0 0 2px rgba(39,86,196,0.15); }
.trip-card-title { font-size: 15px; font-weight: 600; color: var(--text-primary); display: flex; align-items: center; gap: 8px; }
.trip-mine-tag { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; background: var(--brand-blue); color: #fff; padding: 1px 7px; border-radius: 999px; }
.trip-card-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; font-size: 12px; color: var(--text-tertiary); margin-top: 5px; }
.trip-card-meta span { display: inline-flex; align-items: center; gap: 4px; }
.trip-date-badge { background: #e0f2fe; color: #075985; font-weight: 600; padding: 2px 9px; border-radius: 999px; }
.trip-date-badge.past { background: #fee2e2; color: #991b1b; }
.trip-date-badge.none { background: var(--border-light); color: var(--text-muted); }
.trip-card-stops { font-size: 11px; color: var(--text-tertiary); margin-top: 6px; font-family: 'JetBrains Mono', monospace; }
.trip-card-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }

.trip-meta-row { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.trip-meta-field { display: flex; flex-direction: column; gap: 5px; flex: 1; min-width: 180px; }
.trip-meta-field input, .trip-meta-field select {
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: white;
  font-size: 14px;
  color: var(--text-primary);
}
.trip-stop-prio { font-size: 10px; font-weight: 600; color: var(--text-muted); margin-left: 6px; text-transform: uppercase; letter-spacing: 0.03em; }
.trip-meta-field #trip-tech { min-width: 0; width: 100%; }

@media (max-width: 720px) {
  .trip-card { flex-direction: column; align-items: flex-start; }
  .trip-card-actions { width: 100%; justify-content: flex-end; }
}

/* ===========================
   MAP VIEW
   =========================== */
.map-container {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1rem;
  margin-bottom: 1rem;
}

.map-svg {
  width: 100%;
  height: auto;
  display: block;
}

.map-svg .state-marker { cursor: pointer; }
.map-svg .state-marker path { transition: fill 0.15s, filter 0.15s; }
.map-svg .state-marker:not(.state-disabled):hover path {
  filter: brightness(1.08);
  stroke: #0f172a;
  stroke-width: 1.5;
}
.map-svg .state-marker.state-disabled { cursor: default; }
.map-svg .state-marker.state-dim { opacity: 0.32; }
.map-svg .state-marker.state-dim.state-disabled { opacity: 0.2; }
.map-svg .site-pin { cursor: pointer; }
.map-svg .site-pin:hover circle:last-child { stroke: #0f172a; }
.map-svg .state-tooltip { pointer-events: none; }
.site-unmapped { font-size: 11px; font-weight: 400; color: var(--text-muted); }
.site-card-flash { animation: cardflash 1.4s ease; }
@keyframes cardflash {
  0%, 100% { box-shadow: none; }
  20% { box-shadow: 0 0 0 3px rgba(39,86,196,0.45); }
}

.state-panel {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
}

.state-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.state-panel-title {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.state-panel-subtitle {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--text-tertiary);
}

.tech-list {
  margin-bottom: 1rem;
  padding: 10px 12px;
  background: var(--bg);
  border-radius: var(--radius);
}

.tech-list-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.tech-list-items {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tech-chip {
  background: #dbeafe;
  color: #1e40af;
  padding: 3px 8px;
  border-radius: 5px;
  font-size: 11px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.state-ticket {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  margin-bottom: 8px;
  transition: border-color 0.15s;
}

.state-ticket:hover { border-color: var(--text-tertiary); }

/* ===========================
   USERS TABLE
   =========================== */
.users-table {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.users-table-header {
  display: grid;
  grid-template-columns: 1.5fr 1.5fr 1fr 1fr 80px;
  padding: 10px 16px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  font-size: 11px;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.users-table-row {
  display: grid;
  grid-template-columns: 1.5fr 1.5fr 1fr 1fr 80px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-light);
  font-size: 13px;
  align-items: center;
}

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

.user-name-cell { font-weight: 500; color: var(--text-primary); }
.user-username { font-size: 11px; color: var(--text-muted); }

.role-badge.role-custom { background: #ede9fe; color: #6d28d9; }

.roles-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}
.role-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
}
.role-card-name { font-weight: 600; font-size: 14px; color: var(--text-primary); display: flex; align-items: center; gap: 6px; }
.role-card-meta { font-size: 12px; color: var(--text-muted); margin-top: 3px; }
.role-system-tag {
  font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em;
  background: var(--border-light); color: var(--text-tertiary);
  padding: 1px 6px; border-radius: 999px; margin-left: 4px;
}

.cap-list {
  display: flex; flex-direction: column; gap: 2px;
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 4px; max-height: 320px; overflow-y: auto;
}
.cap-row {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 9px 10px; border-radius: var(--radius); cursor: pointer;
}
.cap-row:hover { background: var(--bg); }
.cap-row input { width: 16px; height: 16px; margin-top: 2px; flex-shrink: 0; }
.cap-label { font-size: 13px; font-weight: 500; color: var(--text-primary); }
.cap-desc { font-size: 12px; color: var(--text-tertiary); }

.row-actions {
  display: flex;
  gap: 4px;
  justify-content: flex-end;
}

.icon-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-tertiary);
  padding: 4px;
  border-radius: 4px;
  display: flex;
  align-items: center;
}

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

/* ===========================
   MODAL
   =========================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1rem;
  animation: fadeIn 0.15s ease-out;
}

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

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

.modal {
  background: white;
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow: auto;
  animation: slideUp 0.2s ease-out;
}

.modal.modal-md { max-width: 480px; }
.modal.modal-lg { max-width: 640px; }

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

.modal-header h3 {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
}

.modal-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-tertiary);
  padding: 4px;
}
.modal-close:hover { color: var(--text-primary); }

.modal-body {
  padding: 1.25rem 1.5rem;
}

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

.modal-footer.with-left { justify-content: space-between; }

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

.ticket-meta {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px 16px;
  margin-bottom: 1.25rem;
  padding: 12px 14px;
  background: var(--bg);
  border-radius: var(--radius);
  font-size: 12px;
}

.ticket-meta .meta-label { color: var(--text-muted); }
.ticket-meta strong { color: var(--text-primary); }

.section-label {
  margin: 0 0 8px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.ticket-description {
  margin: 0 0 1.25rem;
  font-size: 13px;
  color: #334155;
  line-height: 1.6;
  white-space: pre-wrap;
}

.manage-box {
  margin-bottom: 1.25rem;
  padding: 12px 14px;
  background: #f1f5f9;
  border-radius: var(--radius);
}

.updates-list {
  display: grid;
  gap: 8px;
  margin-bottom: 1rem;
}

.update-item {
  padding: 10px 12px;
  background: var(--bg);
  border-radius: var(--radius);
  border-left: 3px solid #cbd5e1;
}

.update-item.comment {
  background: #fefce8;
  border-left-color: #facc15;
}

.update-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 2px;
}

.update-author { font-size: 12px; font-weight: 500; color: var(--text-primary); }
.update-time { font-size: 11px; color: var(--text-muted); }
.update-text { margin: 0; font-size: 13px; color: #334155; line-height: 1.5; }

.permission-preview {
  margin-top: 1rem;
  padding: 10px 12px;
  background: var(--bg);
  border-radius: var(--radius);
  font-size: 12px;
}

.permission-preview-title {
  font-weight: 500;
  color: #334155;
  margin-bottom: 6px;
}

.permission-preview ul {
  margin: 0;
  padding-left: 18px;
  color: var(--text-tertiary);
  line-height: 1.6;
}

/* ===========================
   TOASTS
   =========================== */
.toast-container {
  position: fixed;
  top: 16px;
  right: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 1000;
  pointer-events: none;
}

.toast {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 13px;
  box-shadow: var(--shadow-md);
  pointer-events: auto;
  animation: slideIn 0.2s ease-out;
  max-width: 320px;
  display: flex;
  align-items: center;
  gap: 8px;
}

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

.toast.toast-success { border-left: 3px solid #16a34a; }
.toast.toast-error { border-left: 3px solid #dc2626; }
.toast.toast-info { border-left: 3px solid #2563eb; }

/* ===========================
   RESPONSIVE
   =========================== */
@media (max-width: 768px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .users-table-header,
  .users-table-row { grid-template-columns: 1.5fr 1fr 80px; }
  .users-table-header > *:nth-child(2),
  .users-table-row > *:nth-child(2),
  .users-table-header > *:nth-child(4),
  .users-table-row > *:nth-child(4) { display: none; }
  .form-row { grid-template-columns: 1fr; }
  .main { padding: 1rem; }
  .header { padding: 10px 16px; }
  .header-left { gap: 12px; }
  .nav-btn span { display: none; }
  .user-info { display: none; }
}

/* ===========================
   SITE SELECTOR (searchable dropdown)
   =========================== */
.site-selector {
  position: relative;
}

.site-selector-input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #cbd5e1;
  border-radius: var(--radius);
  font-size: 14px;
  outline: none;
  background: white;
  font-family: inherit;
  color: var(--text-primary);
  transition: border-color 0.15s, box-shadow 0.15s;
  box-sizing: border-box;
}

.site-selector-input:focus {
  border-color: #0f172a;
  box-shadow: 0 0 0 3px rgba(15,23,42,0.1);
}

.site-selector-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  max-height: 280px;
  overflow-y: auto;
  z-index: 200;
}

.site-selector-dropdown.open {
  display: block;
}

.site-selector-item {
  padding: 8px 12px;
  cursor: pointer;
  border-bottom: 1px solid var(--border-light);
  transition: background 0.1s;
}

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

.site-selector-item-main {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}

.site-selector-item-main strong {
  font-family: var(--mono);
  font-size: 12px;
  background: #f1f5f9;
  padding: 1px 6px;
  border-radius: 4px;
  color: #0f172a;
  font-weight: 500;
}

.site-selector-item-sub {
  font-size: 11px;
  color: var(--text-tertiary);
  margin-top: 2px;
  padding-left: 2px;
}

.site-selector-empty {
  padding: 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  font-style: italic;
}

.site-selector-none {
  background: var(--bg);
}

.form-hint {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ===========================
   SITE DETAILS BOX (in ticket modal)
   =========================== */
.site-details-box {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: var(--radius);
  padding: 10px 14px;
  margin-bottom: 1.25rem;
  font-size: 13px;
}

.site-details-header {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #1e40af;
  margin-bottom: 4px;
  font-size: 14px;
}

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

/* ===========================
   SITE CARDS in map state panel
   =========================== */
.sites-grid {
  display: grid;
  gap: 8px;
  margin-top: 4px;
}

.site-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: white;
}

.site-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 10px 12px;
  gap: 12px;
}

.site-card-code {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 500;
  background: #f1f5f9;
  padding: 2px 8px;
  border-radius: 4px;
  display: inline-block;
  margin-bottom: 4px;
  color: #0f172a;
}

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

.site-card-address {
  font-size: 11px;
  color: var(--text-tertiary);
  margin-top: 2px;
}

.site-card-meta {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 4px;
}

.site-card-header-right {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  flex-shrink: 0;
}

.site-card-count {
  text-align: center;
  background: var(--bg);
  border-radius: var(--radius);
  padding: 6px 12px;
  min-width: 50px;
  flex-shrink: 0;
}

.site-card-count.active {
  background: #fee2e2;
  color: #991b1b;
}

.site-card-count {
  font-size: 18px;
  font-weight: 600;
}

.site-card-count-label {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 500;
  margin-top: 2px;
  opacity: 0.7;
}

.site-card-tickets {
  border-top: 1px solid var(--border-light);
  padding: 6px 12px;
  background: var(--bg);
  border-radius: 0 0 var(--radius) var(--radius);
}

.site-ticket-mini {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  font-size: 12px;
  cursor: pointer;
  border-bottom: 1px solid var(--border-light);
  transition: opacity 0.1s;
}

.site-ticket-mini:last-child { border-bottom: none; }
.site-ticket-mini:hover { opacity: 0.7; }

.site-ticket-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-primary);
  font-weight: 500;
}

/* Sites table grid responsive */
@media (max-width: 768px) {
  .users-table-header,
  .users-table-row {
    grid-template-columns: 1.5fr 1fr 1fr 80px;
  }
}
