/* ============================================================
   8Views Automations Hub — Complete Stylesheet
   Brand: Teal (#28bdc7) on Light background
   ============================================================ */

/* ── Reset & Base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary:        #28bdc7;
  --primary-dark:   #1fa8b1;
  --primary-light:  #e8f8fa;
  --primary-pale:   #f0fbfc;
  --accent:         #a08b00;
  --accent-light:   #fdf8e1;

  --bg:             #f5f7f9;
  --surface:        #ffffff;
  --surface-hover:  #f9fafb;
  --border:         #e5e9ef;
  --border-light:   #f1f4f7;

  --text-primary:   #1a2332;
  --text-secondary: #64748b;
  --text-muted:     #94a3b8;

  --cat-alerts:     #f59e0b;
  --cat-alerts-bg:  #fef3c7;
  --cat-reports:    #3b82f6;
  --cat-reports-bg: #dbeafe;
  --cat-monitoring: #8b5cf6;
  --cat-monitor-bg: #ede9fe;
  --cat-hr:         #ec4899;
  --cat-hr-bg:      #fce7f3;

  --success:        #10b981;
  --danger:         #ef4444;
  --warning:        #f59e0b;

  --radius-sm:   6px;
  --radius:      10px;
  --radius-lg:   16px;
  --radius-xl:   20px;

  --shadow-sm:   0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow:      0 4px 12px rgba(0,0,0,.08), 0 1px 4px rgba(0,0,0,.04);
  --shadow-lg:   0 12px 32px rgba(0,0,0,.12), 0 4px 12px rgba(0,0,0,.06);
  --shadow-drawer: -8px 0 40px rgba(0,0,0,.14);

  --transition: 200ms ease;
  --transition-slow: 350ms ease;

  --font: 'Inter', system-ui, -apple-system, sans-serif;
}

html { font-size: 16px; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ── Typography ───────────────────────────────────────────── */
h1, h2, h3, h4 { font-weight: 600; line-height: 1.3; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
h4 { font-size: 0.9rem; }
p  { color: var(--text-secondary); font-size: 0.9rem; }
a  { color: var(--primary); text-decoration: none; }

/* ── Utility ──────────────────────────────────────────────── */
.hidden { display: none !important; }
.flex   { display: flex; }
.gap-1  { gap: 8px; }
.gap-2  { gap: 16px; }

/* ── Scrollbar ────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--border-light); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ============================================================
   HEADER
   ============================================================ */
.header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 32px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

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

.header-logo {
  height: 36px;
  width: auto;
}

.header-logo-fallback {
  width: 36px;
  height: 36px;
  background: var(--primary);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: -0.5px;
}

.header-title {
  display: flex;
  flex-direction: column;
}

.header-title .company {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  font-weight: 500;
}

.header-title .product {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.1;
}

.header-meta {
  display: flex;
  align-items: center;
  gap: 16px;
}

.header-badge {
  background: var(--primary-light);
  color: var(--primary-dark);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 20px;
}

/* ============================================================
   TAB NAVIGATION
   ============================================================ */
.tab-nav {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 32px;
  display: flex;
  gap: 4px;
  position: sticky;
  top: 64px;
  z-index: 99;
}

.tab-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 16px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-secondary);
  font-family: var(--font);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: color var(--transition), border-color var(--transition);
  white-space: nowrap;
  margin-bottom: -1px;
}

.tab-btn:hover { color: var(--primary); }

.tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: 600;
}

.tab-btn svg { width: 16px; height: 16px; flex-shrink: 0; }

/* ============================================================
   MAIN CONTENT AREA
   ============================================================ */
.main {
  max-width: 1280px;
  margin: 0 auto;
  padding: 32px;
}

.tab-content { display: none; }
.tab-content.active { display: block; }

/* ============================================================
   SECTION HEADERS
   ============================================================ */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.section-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
}

.section-sub {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ============================================================
   STAT TILES
   ============================================================ */
/* ============================================================
   CATALOG STATS ROW (top of catalog page)
   ============================================================ */
.catalog-stats-row {
  display: flex;
  gap: 16px;
  margin-bottom: 24px;
}

.catalog-stat-card {
  flex: 1;
  background: var(--surface);
  border-radius: 14px;
  padding: 20px 22px;
  border: 1px solid var(--border);
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.catalog-stat-label {
  font-size: 11px;
  color: #94A3B8;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.catalog-stat-value {
  font-size: 28px;
  font-weight: 700;
  color: #1A2332;
  line-height: 1.1;
}

.catalog-stat-trend {
  font-size: 12px;
  font-weight: 500;
  margin-top: 6px;
}

.trend-up   { color: #10B981; }
.trend-down { color: #EF4444; }
.trend-neutral { color: #94A3B8; }

/* Split stat card (two metrics side by side with divider) */
.catalog-stat-card--split {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  padding: 0;
  flex: 2;
}
.stat-half {
  flex: 1;
  padding: 20px 22px;
}
.stat-divider {
  width: 1px;
  background: var(--border);
  margin: 16px 0;
  flex-shrink: 0;
}

/* ── Category Colors ──────────────────────────────────────── */
.cat-alerts    { color: var(--cat-alerts);     background: var(--cat-alerts-bg); }
.cat-reports   { color: var(--cat-reports);    background: var(--cat-reports-bg); }
.cat-monitoring { color: var(--cat-monitoring); background: var(--cat-monitor-bg); }
.cat-hr        { color: var(--cat-hr);         background: var(--cat-hr-bg); }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.badge.cat-alerts    { color: var(--cat-alerts);     background: var(--cat-alerts-bg); }
.badge.cat-reports   { color: var(--cat-reports);    background: var(--cat-reports-bg); }
.badge.cat-monitoring { color: var(--cat-monitoring); background: var(--cat-monitor-bg); }
.badge.cat-hr        { color: var(--cat-hr);         background: var(--cat-hr-bg); }

/* ============================================================
   CATALOG — SEARCH & FILTER
   ============================================================ */
.catalog-controls {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.search-wrap {
  position: relative;
  flex: 1;
  min-width: 240px;
  max-width: 400px;
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  width: 16px;
  height: 16px;
}

.search-input {
  width: 100%;
  padding: 10px 12px 10px 38px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 0.875rem;
  background: var(--surface);
  color: var(--text-primary);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}

.search-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(40,189,199,.12);
}

.filter-tabs {
  display: flex;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 3px;
  gap: 2px;
}

.filter-tab {
  padding: 6px 14px;
  border: none;
  border-radius: calc(var(--radius) - 2px);
  background: none;
  font-family: var(--font);
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}

.filter-tab:hover { color: var(--text-primary); background: var(--bg); }

.filter-tab.active {
  background: var(--primary);
  color: white;
  box-shadow: var(--shadow-sm);
}

.results-count {
  font-size: 0.8rem;
  color: var(--text-muted);
  white-space: nowrap;
  margin-left: auto;
}

.filter-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
}

.vertical-filter {
  padding: 6px 14px;
  border-radius: calc(var(--radius) - 2px);
  font-size: 0.8rem;
  font-weight: 500;
  font-family: var(--font);
  border: none;
  background: none;
  color: var(--text-secondary);
  cursor: pointer;
  flex-shrink: 0;
  outline: none;
  transition: all var(--transition);
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' fill='none'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%2394a3b8' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 6px center;
  padding-right: 22px;
}

.vertical-filter:hover {
  color: var(--text-primary);
  background-color: var(--bg);
}

.vertical-filter:focus {
  background-color: var(--bg);
  color: var(--text-primary);
}

/* ============================================================
   AUTOMATION CARDS
   ============================================================ */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}

.auto-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 0;
  cursor: pointer;
  transition: all var(--transition);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  position: relative;
}

.auto-card::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  border-radius: 0;
}

.auto-card.cat-alerts::before    { background: var(--cat-alerts); }
.auto-card.cat-reports::before   { background: var(--cat-reports); }
.auto-card.cat-monitoring::before { background: var(--cat-monitoring); }
.auto-card.cat-hr::before        { background: var(--cat-hr); }

.auto-card:hover {
  box-shadow: var(--shadow);
  transform: translateY(-2px);
  border-color: rgba(40,189,199,.3);
}

.card-body {
  padding: 20px 20px 16px 24px;
  flex: 1;
}

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

.card-name {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.3;
}

.card-summary {
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 14px;
}

.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px 14px 24px;
  border-top: 1px solid var(--border-light);
  background: var(--surface-hover);
}

.card-stat {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.card-stat svg { width: 14px; height: 14px; color: var(--text-muted); }

.card-stat-value { font-weight: 600; color: var(--text-primary); }

.card-start {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.card-arrow {
  width: 16px;
  height: 16px;
  color: var(--text-muted);
  transition: color var(--transition), transform var(--transition);
}

.auto-card:hover .card-arrow {
  color: var(--primary);
  transform: translateX(2px);
}

/* no-results */
.no-results {
  grid-column: 1 / -1;
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.no-results svg { width: 48px; height: 48px; margin-bottom: 12px; opacity: 0.3; }
.no-results p { font-size: 1rem; }

/* ============================================================
   DETAIL DRAWER
   ============================================================ */
.drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.35);
  z-index: 200;
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--transition-slow), visibility var(--transition-slow);
  backdrop-filter: blur(2px);
}

.drawer-overlay.open {
  opacity: 1;
  visibility: visible;
}

.drawer {
  position: fixed;
  right: 0;
  top: 0;
  bottom: 0;
  width: 520px;
  background: var(--surface);
  z-index: 201;
  box-shadow: var(--shadow-drawer);
  transform: translateX(100%);
  transition: transform var(--transition-slow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.drawer.open { transform: translateX(0); }

.drawer-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: var(--surface);
  flex-shrink: 0;
}

.drawer-header-info { flex: 1; min-width: 0; }

.drawer-title {
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.3;
  margin-bottom: 6px;
}

.drawer-close {
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: all var(--transition);
  flex-shrink: 0;
}

.drawer-close:hover { background: var(--bg); color: var(--text-primary); }
.drawer-close svg { width: 16px; height: 16px; }

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

.drawer-section {
  margin-bottom: 24px;
}

.drawer-section-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.drawer-section-content {
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.65;
}

.drawer-meta-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.drawer-meta-row svg { width: 14px; height: 14px; flex-shrink: 0; }

.drawer-stats-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 24px;
}

.drawer-stat-box {
  background: var(--bg);
  border-radius: var(--radius);
  padding: 14px 16px;
  border: 1px solid var(--border-light);
}

.drawer-stat-box .val {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--primary);
  line-height: 1.2;
}

.drawer-stat-box .lbl {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 3px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.kpi-list {
  list-style: none;
}

.kpi-list li {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 0.82rem;
  color: var(--text-secondary);
  padding: 5px 0;
  border-bottom: 1px solid var(--border-light);
}

.kpi-list li:last-child { border-bottom: none; }

.kpi-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--primary);
  margin-top: 6px;
  flex-shrink: 0;
}

/* ============================================================
   ANALYTICS TAB
   ============================================================ */
.analytics-summary-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 28px;
}

.analytics-stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
  text-align: center;
}

.analytics-stat .val {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--primary);
}

.analytics-stat .lbl {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.charts-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 28px;
}

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

.chart-card-title {
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 16px;
}

.chart-wrap {
  position: relative;
  height: 200px;
}

/* Drilldown */
.drilldown-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 24px;
}

.drilldown-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 16px;
  flex-wrap: wrap;
}

.drilldown-select {
  flex: 1;
  min-width: 240px;
  max-width: 380px;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 0.875rem;
  color: var(--text-primary);
  background: var(--bg);
  outline: none;
  cursor: pointer;
  transition: border-color var(--transition);
}

.drilldown-select:focus { border-color: var(--primary); }

.drilldown-charts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 20px;
}

.drilldown-chart-wrap {
  position: relative;
  height: 180px;
}

/* Trigger log */
.trigger-log-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}

.trigger-log-table th {
  text-align: left;
  padding: 8px 12px;
  color: var(--text-muted);
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  border-bottom: 2px solid var(--border);
}

.trigger-log-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-light);
  color: var(--text-secondary);
}

.trigger-log-table tr:last-child td { border-bottom: none; }
.trigger-log-table tr:hover td { background: var(--surface-hover); }

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

.log-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--primary-light);
  color: var(--primary);
  font-size: 0.65rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  text-transform: uppercase;
}

/* ============================================================
   LOADING STATE
   ============================================================ */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: #fff;
  z-index: 500;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
}

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

.loading-text {
  font-size: 0.875rem;
  color: var(--text-muted);
  font-weight: 500;
}

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ============================================================
   TOAST NOTIFICATIONS
   ============================================================ */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: var(--text-primary);
  color: white;
  padding: 12px 18px;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  pointer-events: all;
  animation: slideUp 0.3s ease;
  max-width: 320px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.toast.success { background: var(--success); }
.toast.error   { background: var(--danger); }

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

/* ============================================================
   ADMIN PANEL STYLES
   ============================================================ */

/* Admin Login */
.admin-login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}

.admin-login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 40px;
  width: 400px;
  box-shadow: var(--shadow-lg);
  text-align: center;
}

.admin-login-card .logo-wrap {
  margin-bottom: 24px;
}

.admin-login-card h2 {
  margin-bottom: 6px;
  font-size: 1.25rem;
}

.admin-login-card p {
  margin-bottom: 28px;
  font-size: 0.875rem;
}

.form-group {
  margin-bottom: 16px;
  text-align: left;
}

.form-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 0.875rem;
  color: var(--text-primary);
  background: var(--surface);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(40,189,199,.12);
}

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

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

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

.login-error {
  background: #fef2f2;
  border: 1px solid #fca5a5;
  color: var(--danger);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 0.8rem;
  margin-bottom: 16px;
  display: none;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}

.btn svg { width: 16px; height: 16px; }

.btn-primary {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }

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

.btn-danger {
  background: white;
  color: var(--danger);
  border-color: #fca5a5;
}
.btn-danger:hover { background: #fef2f2; }

.btn-sm { padding: 6px 12px; font-size: 0.78rem; }
.btn-full { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Admin Layout */
.admin-shell {
  display: grid;
  grid-template-columns: 280px 1fr;
  min-height: 100vh;
}

.admin-sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.admin-sidebar-header {
  padding: 20px;
  border-bottom: 1px solid var(--border);
}

.admin-sidebar-header .brand {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.admin-sidebar-header .sub {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.admin-nav {
  padding: 12px 8px;
  flex: 1;
}

.admin-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius);
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-family: var(--font);
  margin-bottom: 2px;
}

.admin-nav-item:hover { background: var(--bg); color: var(--text-primary); }
.admin-nav-item.active { background: var(--primary-light); color: var(--primary); font-weight: 600; }
.admin-nav-item svg { width: 16px; height: 16px; flex-shrink: 0; }

.admin-nav-section {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  font-weight: 700;
  color: var(--text-muted);
  padding: 12px 12px 4px;
}

.admin-sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--border);
}

.admin-main {
  background: var(--bg);
  padding: 32px;
  overflow-y: auto;
}

.admin-page { display: none; }
.admin-page.active { display: block; }

/* Admin Automations List */
.admin-list-table {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.admin-list-table table {
  width: 100%;
  border-collapse: collapse;
}

.admin-list-table th {
  padding: 12px 16px;
  text-align: left;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--text-muted);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.admin-list-table td {
  padding: 12px 16px;
  font-size: 0.875rem;
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
}

.admin-list-table tr:last-child td { border-bottom: none; }
.admin-list-table tr:hover td { background: var(--surface-hover); }

.admin-actions {
  display: flex;
  gap: 6px;
}

/* Usage Editor */
.usage-editor {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

.usage-editor-form {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
}

.usage-log-view {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  overflow-x: auto;
}

/* Page header */
.admin-page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.admin-page-header h2 { font-size: 1.1rem; }

/* Automation form panel */
.auto-form-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 24px;
}

.form-section-title {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 14px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border-light);
}

.form-section-title:first-child { margin-top: 0; padding-top: 0; border-top: none; }

/* Status indicator */
.status-dot {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.75rem;
  font-weight: 600;
}

.status-dot::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-dot.active::before   { background: var(--success); }
.status-dot.inactive::before { background: var(--text-muted); }

/* ============================================================
   RESPONSIVE
   ============================================================ */

/* ── Tablet landscape ─────────────────────────────────────── */
@media (max-width: 1100px) {
  .cards-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ── Tablet portrait ──────────────────────────────────────── */
@media (max-width: 900px) {
  .charts-row       { grid-template-columns: 1fr; }
  .drilldown-charts { grid-template-columns: 1fr; }
  .admin-shell      { grid-template-columns: 1fr; }
  .admin-sidebar    { display: none; }
  .usage-editor     { grid-template-columns: 1fr; }

  .catalog-controls { flex-direction: column; align-items: stretch; gap: 12px; }
  .search-wrap { max-width: none; }
  .filter-row { flex-wrap: wrap; }
  .filter-tabs { overflow-x: auto; flex-shrink: 1; }
}

/* ── Mobile ───────────────────────────────────────────────── */
@media (max-width: 700px) {
  .main { padding: 16px 12px; }
  .header { padding: 0 12px; height: 56px; }
  .header-logo { height: 28px; }
  .header-title .company { font-size: 0.6rem; }
  .header-title .product { font-size: 0.85rem; }
  .header-badge { font-size: 0.65rem; padding: 3px 8px; }

  .tab-nav { padding: 0 4px; overflow-x: auto; top: 56px; gap: 0; }
  .tab-btn { padding: 10px 10px; font-size: 0.78rem; gap: 5px; }
  .tab-btn svg { width: 14px; height: 14px; }

  .catalog-stats-row { flex-direction: column; gap: 10px; }
  .catalog-stat-value { font-size: 22px; }
  .catalog-stat-card--split { flex-direction: column; }
  .stat-divider { width: auto; height: 1px; margin: 0 16px; }

  .catalog-controls { flex-direction: column; align-items: stretch; gap: 10px; }
  .search-wrap { max-width: none; min-width: 0; }
  .filter-row { flex-wrap: wrap; gap: 8px; }
  .filter-tabs { overflow-x: auto; flex-shrink: 1; min-width: 0; padding: 2px; }
  .filter-tab { padding: 5px 10px; font-size: 0.72rem; }
  .vertical-filter { font-size: 0.72rem; padding: 5px 20px 5px 10px; }
  .results-count { font-size: 0.72rem; }

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

  .section-header { margin-bottom: 12px; }
  .section-title { font-size: 0.95rem; }
  .section-sub { font-size: 0.75rem; }

  .charts-row { grid-template-columns: 1fr; gap: 16px; }
  .chart-card { padding: 16px; }
  .chart-card-title { font-size: 0.8rem; }

  .drilldown-card { padding: 16px; }
  .drilldown-header { flex-direction: column; gap: 10px; align-items: stretch; }
  .drilldown-select { width: 100%; }

  .analytics-summary-grid { grid-template-columns: 1fr; gap: 10px; }
  .analytics-stat { padding: 14px; }
  .analytics-stat .val { font-size: 1.4rem; }
  .analytics-stat .lbl { font-size: 0.68rem; }

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

/* ── Small mobile ─────────────────────────────────────────── */
@media (max-width: 420px) {
  .main { padding: 10px 8px; }
  .header { padding: 0 8px; }
  .header-brand { gap: 8px; }
  .header-title .product { font-size: 0.78rem; }

  .catalog-stat-card { padding: 14px 16px; }
  .catalog-stat-card--split { padding: 0; }
  .stat-half { padding: 14px 16px; }
  .catalog-stat-value { font-size: 20px; }
  .catalog-stat-label { font-size: 10px; }

  .filter-row { gap: 6px; }
  .vertical-filter { font-size: 0.68rem; padding: 5px 18px 5px 8px; }
}

/* ══════════════════════════════════════════════
   PEOPLE TAB
   ══════════════════════════════════════════════ */

.people-group {
  margin-bottom: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
}

.people-group-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background: #F8FAFC;
  border-bottom: 1px solid var(--border);
}

.people-dept-badge {
  font-size: 11px;
  font-weight: 700;
  color: var(--primary);
  background: #E0F7FA;
  padding: 3px 9px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

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

.person-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid #F1F5F9;
  cursor: pointer;
  transition: background 0.15s;
}
.person-row:last-child { border-bottom: none; }
.person-row:hover      { background: #F8FAFC; }
.person-row.expanded   { border-left: 3px solid var(--primary); background: #F0FDFE; }

.person-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
}

.person-info  { flex: 1; min-width: 0; }
.person-name  { font-size: 13px; font-weight: 600; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.person-email { font-size: 11px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.person-stats { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }

.person-stat-chip {
  font-size: 11px;
  font-weight: 600;
  color: #475569;
  background: #F1F5F9;
  padding: 3px 8px;
  border-radius: 20px;
  white-space: nowrap;
}
.person-stat-green { color: #059669; background: #D1FAE5; }

.person-chevron {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  color: var(--text-muted);
  transition: transform 0.2s;
}
.person-chevron.flipped { transform: rotate(180deg); }

.person-row.person-inactive { opacity: 0.7; }
.person-row.person-inactive .person-name { color: #94A3B8; }
.person-row.person-inactive .person-avatar { filter: grayscale(60%); }

.people-group-trend-btn {
  margin-left: auto;
  font-size: 11px;
  font-weight: 600;
  color: #0891B2;
  background: #E0F7FA;
  border: 1px solid #B2EBF2;
  border-radius: 20px;
  padding: 3px 10px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
}
.people-group-trend-btn:hover { background: #B2EBF2; }

.people-group-chart {
  display: none;
  padding: 12px 14px;
  background: #F8FAFC;
  border-bottom: 1px solid #E0F7FA;
}
.people-group-chart.open { display: block; }
.people-group-chart-title {
  font-size: 10px;
  font-weight: 700;
  color: #0891B2;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 10px;
}

/* Expanded section */
.person-expanded {
  padding: 12px 16px 16px;
  background: #FAFCFE;
  border-top: 1px solid #E0F7FA;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.person-auto-row { display: flex; flex-direction: row; align-items: center; gap: 16px; }

.person-auto-name {
  flex: 1;
  min-width: 80px;
  font-size: 13px;
  font-weight: 600;
  color: #334155;
}

.people-mini-chart {
  display: flex;
  gap: 4px;
  align-items: stretch;
  height: 60px;
  flex: 0 0 auto;
  min-width: 180px;
}

.people-mini-bar-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 2px;
  flex: 1;
}

.people-mini-bar-count {
  font-size: 9px;
  font-weight: 700;
  color: #334155;
  height: 12px;
  line-height: 12px;
  white-space: nowrap;
}

.people-mini-bar-track {
  flex: 1;
  width: 100%;
  background: #F1F5F9;
  border-radius: 3px;
  display: flex;
  align-items: flex-end;
  overflow: hidden;
  min-height: 4px;
}

.people-mini-bar-fill {
  width: 100%;
  border-radius: 3px 3px 0 0;
  min-height: 2px;
  transition: height 0.3s;
}

.people-mini-bar-month {
  font-size: 9px;
  color: var(--text-muted);
  white-space: nowrap;
}

.hours-view-btn {
  font-size: 12px;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 20px;
  border: 1.5px solid #e5e9ef;
  background: white;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
}
.hours-view-btn.active {
  background: #28bdc7;
  color: white;
  border-color: #28bdc7;
}

