/* ============================================================
   Magax Hub TI — Gestión de equipo informático
   Magax Servicios Tecnológicos · Cliente: Alimentsa S.A.
   ============================================================ */

:root {
  /* Product name: change data-product-name in HTML + PRODUCT_NAME in JS */
  --primary: #0d47a1;
  --primary-dark: #062a5c;
  --primary-light: #1976d2;
  --primary-50: #e3f2fd;
  --primary-100: #bbdefb;
  --accent: #00bcd4;
  --accent-light: #4dd0e1;
  --cyan: #00bcd4;
  --cyan-dark: #0097a7;
  --warn: #e65100;
  --danger: #c62828;
  --success: #2e7d32;
  --info: #0277bd;

  --bg: #f4f7fb;
  --surface: #ffffff;
  --sidebar-bg: #0a1628;
  --sidebar-hover: #132338;
  --sidebar-active: #0d47a1;
  --topbar-h: 56px;
  --sidebar-w: 260px;

  --text: #212121;
  --text-secondary: #616161;
  --text-muted: #9e9e9e;
  --text-on-dark: #e0e0e0;
  --border: #e0e0e0;
  --border-light: #eeeeee;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow: 0 2px 8px rgba(0,0,0,.08), 0 1px 3px rgba(0,0,0,.06);
  --shadow-md: 0 4px 16px rgba(0,0,0,.1);
  --radius: 8px;
  --radius-sm: 4px;
  --radius-lg: 12px;
  --font: 'Roboto', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --mono: 'Roboto Mono', 'Consolas', monospace;
  --transition: 0.2s ease;
}

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

html { font-size: 14px; scroll-behavior: smooth; }

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

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, select, textarea { font-family: inherit; font-size: 0.95rem; }
img { max-width: 100%; }
ul { list-style: none; }
table { border-collapse: collapse; width: 100%; }

/* ---------- Screen visibility ---------- */
.screen { display: none; min-height: 100vh; }
.screen.active { display: block; }
.app-shell { display: none; min-height: 100vh; }
.app-shell.active { display: flex; }

/* ============================================================
   LOGIN
   ============================================================ */
.login-screen {
  display: none;
  min-height: 100vh;
  background: linear-gradient(135deg, #062a5c 0%, #0d47a1 45%, #00838f 100%);
  align-items: center;
  justify-content: center;
  padding: 24px;
  position: relative;
  overflow: hidden;
}
.login-screen.active { display: flex; }

.login-screen::before {
  content: '';
  position: absolute;
  width: 600px; height: 600px;
  border-radius: 50%;
  background: rgba(255,255,255,.04);
  top: -200px; right: -150px;
}
.login-screen::after {
  content: '';
  position: absolute;
  width: 400px; height: 400px;
  border-radius: 50%;
  background: rgba(255,255,255,.03);
  bottom: -100px; left: -100px;
}

.login-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
  width: 100%;
  max-width: 420px;
  padding: 48px 40px 36px;
  position: relative;
  z-index: 1;
}

.login-logo {
  text-align: center;
  margin-bottom: 32px;
}
.login-logo .logo-mark {
  width: 56px; height: 56px;
  background: var(--primary);
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 12px;
  box-shadow: 0 4px 12px rgba(13,71,161,.4);
}
.login-logo h1 {
  font-size: 1.5rem;
  font-weight: 500;
  color: var(--text);
  letter-spacing: -0.02em;
}
.login-logo p {
  color: var(--text-secondary);
  font-size: 0.875rem;
  margin-top: 4px;
}

.form-group { margin-bottom: 20px; }
.form-group label {
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.form-control {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fafafa;
  color: var(--text);
  transition: border-color var(--transition), box-shadow var(--transition);
}
.form-control:focus {
  outline: none;
  border-color: var(--primary);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(13,71,161,.15);
}
.form-control::placeholder { color: var(--text-muted); }

.login-options {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  font-size: 0.875rem;
}
.login-options label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-secondary);
  cursor: pointer;
}
.login-options input[type="checkbox"] {
  width: 16px; height: 16px;
  accent-color: var(--primary);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
  transition: all var(--transition);
  white-space: nowrap;
  line-height: 1.4;
}
.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 2px 4px rgba(13,71,161,.3);
}
.btn-primary:hover {
  background: var(--primary-dark);
  box-shadow: 0 4px 8px rgba(13,71,161,.4);
  text-decoration: none;
}
.btn-outline {
  background: transparent;
  color: var(--primary);
  border: 1px solid var(--primary);
}
.btn-outline:hover { background: var(--primary-50); text-decoration: none; }
.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}
.btn-ghost:hover { background: var(--border-light); text-decoration: none; }
.btn-sm { padding: 6px 12px; font-size: 0.8rem; }
.btn-block { width: 100%; padding: 14px; font-size: 1rem; }
.btn-icon {
  width: 36px; height: 36px;
  padding: 0;
  border-radius: 50%;
  color: var(--text-secondary);
}
.btn-icon:hover { background: var(--border-light); }

.login-footer {
  text-align: center;
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid var(--border-light);
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ============================================================
   APP SHELL — Sidebar + Topbar
   ============================================================ */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  color: var(--text-on-dark);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: transform var(--transition);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  height: var(--topbar-h);
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar-brand .logo-mark {
  width: 36px; height: 36px;
  background: var(--primary);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
  color: #fff;
  flex-shrink: 0;
}
.sidebar-brand .brand-text {
  font-size: 1.1rem;
  font-weight: 500;
  color: #fff;
  letter-spacing: -0.01em;
}
.sidebar-brand .brand-sub {
  font-size: 0.7rem;
  color: rgba(255,255,255,.5);
  font-weight: 400;
}

.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
  overflow-y: auto;
}
.nav-section {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(255,255,255,.35);
  padding: 12px 12px 6px;
  font-weight: 600;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: rgba(255,255,255,.7);
  font-size: 0.9rem;
  font-weight: 400;
  transition: all var(--transition);
  margin-bottom: 2px;
  cursor: pointer;
  text-decoration: none;
}
.nav-item:hover {
  background: var(--sidebar-hover);
  color: #fff;
  text-decoration: none;
}
.nav-item.active {
  background: var(--sidebar-active);
  color: #fff;
  font-weight: 500;
}
.nav-item .nav-icon {
  width: 20px;
  text-align: center;
  font-size: 1.1rem;
  opacity: 0.9;
  flex-shrink: 0;
}
.nav-item .nav-badge {
  margin-left: auto;
  background: rgba(255,255,255,.15);
  color: #fff;
  font-size: 0.7rem;
  padding: 2px 7px;
  border-radius: 10px;
  font-weight: 600;
}
.nav-item.active .nav-badge { background: rgba(255,255,255,.25); }

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid rgba(255,255,255,.08);
  font-size: 0.75rem;
  color: rgba(255,255,255,.4);
  text-align: center;
}

/* Main content area */
.main-wrap {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-width: 0;
}

.topbar {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow-sm);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 16px;
}
.page-title {
  font-size: 1.15rem;
  font-weight: 500;
  color: var(--text);
}
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--text-muted);
}
.breadcrumb span { color: var(--text-secondary); }

.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}
.topbar-search {
  position: relative;
  margin-right: 8px;
}
.topbar-search input {
  width: 220px;
  padding: 8px 12px 8px 36px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--bg);
  font-size: 0.85rem;
  transition: all var(--transition);
}
.topbar-search input:focus {
  outline: none;
  border-color: var(--primary);
  background: #fff;
  width: 280px;
  box-shadow: 0 0 0 3px rgba(13,71,161,.1);
}
.topbar-search .search-icon {
  position: absolute;
  left: 12px; top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 0.9rem;
  pointer-events: none;
}

.notif-btn {
  position: relative;
  width: 40px; height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  font-size: 1.2rem;
}
.notif-btn:hover { background: var(--bg); }
.notif-dot {
  position: absolute;
  top: 8px; right: 8px;
  width: 8px; height: 8px;
  background: var(--danger);
  border-radius: 50%;
  border: 2px solid #fff;
}

.user-menu {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px 4px 4px;
  border-radius: 24px;
  cursor: pointer;
  transition: background var(--transition);
  margin-left: 4px;
}
.user-menu:hover { background: var(--bg); }
.user-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.85rem;
}
.user-info { line-height: 1.2; }
.user-info .user-name { font-size: 0.85rem; font-weight: 500; color: var(--text); }
.user-info .user-role { font-size: 0.7rem; color: var(--text-muted); }

/* Content */
.content {
  flex: 1;
  padding: 24px 28px 40px;
  max-width: 1440px;
}

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

/* ============================================================
   COMPONENTS
   ============================================================ */

/* Cards */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-light);
  overflow: hidden;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-light);
}
.card-header h3 {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text);
}
.card-body { padding: 20px; }
.card-body.no-pad { padding: 0; }

/* KPI cards */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
  margin-bottom: 24px;
}
.kpi-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-light);
  padding: 20px 22px;
  display: flex;
  align-items: flex-start;
  gap: 16px;
  transition: box-shadow var(--transition);
}
.kpi-card:hover { box-shadow: var(--shadow); }
.kpi-icon {
  width: 48px; height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  flex-shrink: 0;
}
.kpi-icon.blue { background: var(--primary-50); color: var(--primary); }
.kpi-icon.teal { background: #e0f2f1; color: var(--accent); }
.kpi-icon.orange { background: #fff3e0; color: var(--warn); }
.kpi-icon.green { background: #e8f5e9; color: var(--success); }
.kpi-icon.purple { background: #f3e5f5; color: #7b1fa2; }
.kpi-icon.red { background: #ffebee; color: var(--danger); }
.kpi-data { flex: 1; min-width: 0; }
.kpi-label {
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-weight: 400;
  margin-bottom: 4px;
}
.kpi-value {
  font-size: 1.75rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.02em;
  line-height: 1.2;
}
.kpi-trend {
  font-size: 0.75rem;
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 4px;
}
.kpi-trend.up { color: var(--success); }
.kpi-trend.down { color: var(--danger); }
.kpi-trend.neutral { color: var(--text-muted); }

/* Grid layouts */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 24px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; margin-bottom: 24px; }
.grid-2-1 { display: grid; grid-template-columns: 2fr 1fr; gap: 20px; margin-bottom: 24px; }
.grid-1-2 { display: grid; grid-template-columns: 1fr 2fr; gap: 20px; margin-bottom: 24px; }

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  white-space: nowrap;
}
.badge-success { background: #e8f5e9; color: #2e7d32; }
.badge-warning { background: #fff3e0; color: #e65100; }
.badge-danger { background: #ffebee; color: #c62828; }
.badge-info { background: #e3f2fd; color: #1565c0; }
.badge-neutral { background: #f5f5f5; color: #616161; }
.badge-purple { background: #f3e5f5; color: #7b1fa2; }
.badge-teal { background: #e0f2f1; color: #00695c; }

/* Tables */
.table-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.table-toolbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.table-toolbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}
.search-box {
  position: relative;
}
.search-box input {
  width: 260px;
  padding: 8px 12px 8px 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: 0.85rem;
}
.search-box input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(13,71,161,.1);
}
.search-box .icon {
  position: absolute;
  left: 10px; top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
}
.filter-select {
  padding: 8px 32px 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface) 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='%239e9e9e' d='M6 8L1 3h10z'/%3E%3C/svg%3E") no-repeat right 10px center;
  appearance: none;
  font-size: 0.85rem;
  color: var(--text);
  cursor: pointer;
}
.filter-select:focus {
  outline: none;
  border-color: var(--primary);
}

.data-table {
  width: 100%;
  font-size: 0.875rem;
}
.data-table thead th {
  background: #fafbfc;
  padding: 12px 16px;
  text-align: left;
  font-weight: 500;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.data-table tbody td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-light);
  color: var(--text);
  vertical-align: middle;
}
.data-table tbody tr {
  transition: background var(--transition);
  cursor: pointer;
}
.data-table tbody tr:hover { background: #f8fafc; }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table .cell-primary { font-weight: 500; color: var(--text); }
.data-table .cell-muted { color: var(--text-secondary); font-size: 0.8rem; }
.data-table .cell-link { color: var(--primary); font-weight: 500; }
.data-table .cell-link:hover { text-decoration: underline; }

.table-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  border-top: 1px solid var(--border-light);
  font-size: 0.8rem;
  color: var(--text-secondary);
}
.pagination {
  display: flex;
  align-items: center;
  gap: 4px;
}
.pagination button {
  width: 32px; height: 32px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  font-size: 0.85rem;
}
.pagination button:hover { background: var(--bg); }
.pagination button.active {
  background: var(--primary);
  color: #fff;
}
.pagination button:disabled { opacity: 0.4; cursor: not-allowed; }

/* Progress bars */
.progress-bar {
  height: 8px;
  background: var(--border-light);
  border-radius: 4px;
  overflow: hidden;
  width: 100%;
}
.progress-bar .fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.4s ease;
}
.progress-bar .fill.green { background: var(--success); }
.progress-bar .fill.blue { background: var(--primary); }
.progress-bar .fill.orange { background: var(--warn); }
.progress-bar .fill.red { background: var(--danger); }
.progress-bar .fill.teal { background: var(--accent); }

.load-indicator {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 120px;
}
.load-indicator .pct {
  font-size: 0.8rem;
  font-weight: 500;
  min-width: 36px;
  text-align: right;
}

/* Activity feed */
.activity-list { }
.activity-item {
  display: flex;
  gap: 14px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border-light);
}
.activity-item:last-child { border-bottom: none; }
.activity-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  margin-top: 5px;
  flex-shrink: 0;
}
.activity-dot.blue { background: var(--primary); }
.activity-dot.green { background: var(--success); }
.activity-dot.orange { background: var(--warn); }
.activity-dot.teal { background: var(--accent); }
.activity-dot.purple { background: #7b1fa2; }
.activity-content { flex: 1; }
.activity-content .act-text { font-size: 0.875rem; color: var(--text); }
.activity-content .act-text strong { font-weight: 500; }
.activity-content .act-time { font-size: 0.75rem; color: var(--text-muted); margin-top: 2px; }

/* Status distribution */
.status-bars { display: flex; flex-direction: column; gap: 14px; }
.status-bar-row {
  display: flex;
  align-items: center;
  gap: 12px;
}
.status-bar-row .label {
  width: 90px;
  font-size: 0.8rem;
  color: var(--text-secondary);
  flex-shrink: 0;
}
.status-bar-row .bar-track {
  flex: 1;
  height: 10px;
  background: var(--border-light);
  border-radius: 5px;
  overflow: hidden;
}
.status-bar-row .bar-fill {
  height: 100%;
  border-radius: 5px;
}
.status-bar-row .count {
  width: 36px;
  text-align: right;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text);
}

/* Avatar stack / member */
.member-cell {
  display: flex;
  align-items: center;
  gap: 10px;
}
.avatar-sm {
  width: 32px; height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 600;
  color: #fff;
  flex-shrink: 0;
}
.avatar-md {
  width: 44px; height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  font-weight: 600;
  color: #fff;
  flex-shrink: 0;
}
.av-1 { background: #1565c0; }
.av-2 { background: #00897b; }
.av-3 { background: #6a1b9a; }
.av-4 { background: #e65100; }
.av-5 { background: #c62828; }
.av-6 { background: #4527a0; }
.av-7 { background: #00695c; }
.av-8 { background: #ad1457; }

/* Detail page */
.detail-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 20px;
}
.detail-header-left h2 {
  font-size: 1.4rem;
  font-weight: 500;
  margin-bottom: 6px;
}
.detail-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  color: var(--text-secondary);
  font-size: 0.85rem;
}
.detail-meta .sep { color: var(--border); }
.detail-actions { display: flex; gap: 8px; flex-shrink: 0; }

.spec-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
}
.spec-item {
  padding: 14px 0;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  gap: 12px;
}
.spec-item:nth-last-child(-n+2) { border-bottom: none; }
.spec-label {
  width: 140px;
  font-size: 0.8rem;
  color: var(--text-secondary);
  flex-shrink: 0;
}
.spec-value {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text);
}

.timeline { position: relative; padding-left: 24px; }
.timeline::before {
  content: '';
  position: absolute;
  left: 6px; top: 4px; bottom: 4px;
  width: 2px;
  background: var(--border);
}
.timeline-item {
  position: relative;
  padding-bottom: 20px;
}
.timeline-item:last-child { padding-bottom: 0; }
.timeline-item::before {
  content: '';
  position: absolute;
  left: -21px; top: 4px;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--primary);
  border: 2px solid #fff;
  box-shadow: 0 0 0 2px var(--primary-100);
}
.timeline-item .tl-date {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 2px;
}
.timeline-item .tl-text {
  font-size: 0.875rem;
  color: var(--text);
}

/* Charts (CSS-based) */
.chart-bars {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  height: 180px;
  padding-top: 20px;
}
.chart-bar-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
  justify-content: flex-end;
}
.chart-bar {
  width: 100%;
  max-width: 48px;
  border-radius: 4px 4px 0 0;
  background: var(--primary);
  transition: height 0.5s ease;
  position: relative;
}
.chart-bar:hover { opacity: 0.85; }
.chart-bar .bar-tooltip {
  position: absolute;
  top: -24px; left: 50%;
  transform: translateX(-50%);
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
}
.chart-bar-label {
  font-size: 0.7rem;
  color: var(--text-secondary);
  margin-top: 8px;
  text-align: center;
}

.donut-wrap {
  display: flex;
  align-items: center;
  gap: 32px;
  justify-content: center;
  padding: 12px 0;
}
.donut {
  width: 140px; height: 140px;
  border-radius: 50%;
  position: relative;
  flex-shrink: 0;
}
.donut-hole {
  position: absolute;
  inset: 28px;
  background: var(--surface);
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.donut-hole .donut-val {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1;
}
.donut-hole .donut-lbl {
  font-size: 0.7rem;
  color: var(--text-muted);
}
.legend-list { display: flex; flex-direction: column; gap: 10px; }
.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  color: var(--text-secondary);
}
.legend-dot {
  width: 10px; height: 10px;
  border-radius: 2px;
  flex-shrink: 0;
}
.legend-item .legend-val {
  margin-left: auto;
  font-weight: 500;
  color: var(--text);
  padding-left: 16px;
}

/* Team cards */
.team-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}
.team-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-light);
  padding: 24px;
  transition: box-shadow var(--transition);
}
.team-card:hover { box-shadow: var(--shadow); }
.team-card-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 16px;
}
.team-card-header .member-name {
  font-size: 1rem;
  font-weight: 500;
}
.team-card-header .member-role {
  font-size: 0.8rem;
  color: var(--text-secondary);
}
.team-card-body { }
.team-stat {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  font-size: 0.85rem;
}
.team-stat .stat-label { color: var(--text-secondary); }
.team-stat .stat-value { font-weight: 500; }
.specialty-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 12px 0;
}
.tag {
  padding: 3px 10px;
  background: var(--primary-50);
  color: var(--primary);
  border-radius: 12px;
  font-size: 0.7rem;
  font-weight: 500;
}

/* Availability indicator */
.avail {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
}
.avail-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
}
.avail-dot.available { background: var(--success); }
.avail-dot.busy { background: var(--warn); }
.avail-dot.away { background: var(--text-muted); }
.avail-dot.offline { background: var(--danger); }

/* Empty / helpers */
.section-title {
  font-size: 1rem;
  font-weight: 500;
  margin-bottom: 16px;
  color: var(--text);
}
.mt-0 { margin-top: 0; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 0.8rem; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }

/* Simple bar chart horizontal for reports */
.h-bars { display: flex; flex-direction: column; gap: 16px; }
.h-bar-row { }
.h-bar-label {
  display: flex;
  justify-content: space-between;
  margin-bottom: 6px;
  font-size: 0.85rem;
}
.h-bar-label .name { color: var(--text-secondary); }
.h-bar-label .val { font-weight: 500; color: var(--text); }
.h-bar-track {
  height: 12px;
  background: var(--border-light);
  border-radius: 6px;
  overflow: hidden;
}
.h-bar-fill {
  height: 100%;
  border-radius: 6px;
}

/* Impact indicators */
.impact {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.8rem;
  font-weight: 500;
}
.impact-high { color: var(--danger); }
.impact-medium { color: var(--warn); }
.impact-low { color: var(--success); }

/* Responsive base (desktop refinements) */
@media (max-width: 1200px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .team-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-2-1, .grid-1-2 { grid-template-columns: 1fr; }
}

/* Print / presentation polish */
@media print {
  .sidebar, .topbar, .menu-toggle, .sidebar-backdrop, .sidebar-close { display: none !important; }
  .main-wrap { margin-left: 0; }
}

/* SVG icons inline helpers */
.icon-svg {
  width: 20px; height: 20px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.icon-svg-sm { width: 16px; height: 16px; }

/* ============================================================
   Client model updates — Jonathan Solano alignment
   ============================================================ */

.kpi-grid-6 {
  grid-template-columns: repeat(6, 1fr);
}
@media (max-width: 1400px) {
  .kpi-grid-6 { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 768px) {
  .kpi-grid-6 { grid-template-columns: repeat(2, 1fr); }
}

.cell-mono {
  font-family: var(--mono);
  font-size: 0.8rem;
  letter-spacing: 0.02em;
}

.table-scroll {
  overflow-x: auto;
}

/* Catalog tabs (Inventario / Equipo / Usuarios) */
.catalog-tabs {
  display: flex;
  gap: 4px;
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 4px;
  width: fit-content;
  box-shadow: var(--shadow-sm);
}
.catalog-tab {
  padding: 8px 18px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  transition: all var(--transition);
}
.catalog-tab:hover { background: var(--bg); color: var(--text); }
.catalog-tab.active {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 2px 4px rgba(13,71,161,.3);
}
.catalog-panel { display: none; }
.catalog-panel.active { display: block; }

/* Signature indicators (Actividades) */
.firma-ok {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--success);
  font-weight: 500;
  font-size: 0.8rem;
  white-space: nowrap;
}
.firma-pend {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--warn);
  font-weight: 500;
  font-size: 0.8rem;
  white-space: nowrap;
}

/* Report type cards */
.report-type-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}
.report-type-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  padding: 16px 18px;
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  text-align: left;
  transition: all var(--transition);
  cursor: pointer;
  color: var(--text);
}
.report-type-card:hover {
  border-color: var(--primary-light);
  box-shadow: var(--shadow);
}
.report-type-card.active {
  border-color: var(--primary);
  background: var(--primary-50);
  box-shadow: 0 0 0 2px rgba(13,71,161,.2);
}
.report-type-card .rtc-icon {
  font-size: 1.25rem;
  line-height: 1;
}
.report-type-card .rtc-title {
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1.3;
}
.report-type-card .rtc-desc {
  font-size: 0.75rem;
  color: var(--text-muted);
}
.report-preview { display: none; }
.report-preview.active { display: block; }

.status-bar-row .label {
  width: 100px;
}


/* Magax logo images */
.logo-img {
  display: block;
  object-fit: contain;
}
.login-logo .logo-img {
  width: 160px;
  height: auto;
  margin: 0 auto 16px;
}
.sidebar-brand .logo-img {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: #fff;
  padding: 2px;
  flex-shrink: 0;
}
.sidebar-brand {
  height: auto;
  min-height: var(--topbar-h);
  padding: 14px 16px;
}
.nav-item.active {
  box-shadow: inset 3px 0 0 var(--cyan);
}
.alert-warranty {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 16px;
  background: #fff8e1;
  border: 1px solid #ffe082;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 0.875rem;
}
.alert-warranty.danger {
  background: #ffebee;
  border-color: #ef9a9a;
}
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}
.cal-day {
  min-height: 72px;
  background: #fafafa;
  border: 1px solid var(--border-light);
  border-radius: 4px;
  padding: 6px;
  font-size: 0.75rem;
}
.cal-day .day-num { font-weight: 600; color: var(--text-secondary); margin-bottom: 4px; }
.cal-day .cal-event {
  background: var(--primary-50);
  color: var(--primary-dark);
  border-left: 3px solid var(--cyan);
  padding: 2px 4px;
  border-radius: 2px;
  margin-top: 2px;
  font-size: 0.65rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cal-day.muted { opacity: 0.45; }
.cal-head {
  text-align: center;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  padding: 4px;
  text-transform: uppercase;
}
.module-tag {
  font-size: 0.65rem;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--primary-50);
  color: var(--primary-dark);
  font-weight: 600;
  margin-left: 6px;
}
.config-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}
.role-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  background: var(--surface);
}
.role-card h4 { margin-bottom: 8px; }
.role-card ul { margin-top: 8px; padding-left: 18px; list-style: disc; color: var(--text-secondary); font-size: 0.85rem; }
.tenant-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--primary-50);
  color: var(--primary-dark);
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 500;
}

.page-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.section-title { font-size: 1.25rem; font-weight: 500; }
.toolbar-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.text-sm { font-size: 0.85rem; }
.text-muted { color: var(--text-secondary); }


/* ============================================================
   Mobile / responsive UI — Magax Hub TI
   Breakpoints: 900px (drawer), 768px (phone), 480px (small)
   ============================================================ */

html { overflow-x: hidden; }
body { overflow-x: hidden; }
body.sidebar-open { overflow: hidden; touch-action: none; }

.menu-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  border-radius: var(--radius);
  color: var(--text);
  flex-shrink: 0;
  margin-left: -6px;
}
.menu-toggle:hover,
.menu-toggle:focus-visible {
  background: var(--bg);
  outline: none;
}
.menu-toggle .icon-svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; }

.sidebar-close {
  display: none;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  margin-left: auto;
  border-radius: var(--radius);
  color: rgba(255,255,255,.85);
  flex-shrink: 0;
}
.sidebar-close:hover { background: rgba(255,255,255,.1); color: #fff; }
.sidebar-close .icon-svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; }

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(6, 20, 40, .55);
  z-index: 90;
  opacity: 0;
  transition: opacity .2s ease;
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
}
.sidebar-backdrop.visible {
  display: block;
  opacity: 1;
}

.topbar-titles {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

/* Sticky first column for horizontal table scroll (desktop + tablet fallback) */
.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
}
.table-scroll .data-table {
  min-width: 640px;
}
.table-scroll .data-table th:first-child,
.table-scroll .data-table td:first-child {
  position: sticky;
  left: 0;
  z-index: 2;
  background: #fafbfc;
  box-shadow: 2px 0 4px rgba(0,0,0,.04);
}
.table-scroll .data-table tbody td:first-child {
  background: var(--surface);
}
.table-scroll .data-table tbody tr:hover td:first-child {
  background: #f8fafc;
}

/* ---------- Tablet / drawer ---------- */
@media (max-width: 900px) {
  .menu-toggle { display: inline-flex; }
  .sidebar-close { display: inline-flex; }

  .sidebar {
    transform: translateX(-100%);
    width: min(var(--sidebar-w), 86vw);
    box-shadow: none;
    z-index: 100;
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 8px 0 40px rgba(0,0,0,.35);
  }

  .main-wrap { margin-left: 0; }

  .topbar {
    padding: 0 12px 0 8px;
    height: 52px;
  }
  .page-title { font-size: 1.05rem; }
  .breadcrumb { font-size: 0.72rem; }
  .user-info { display: none; }
  .topbar-search { display: none; }

  .content {
    padding: 16px 16px calc(24px + env(safe-area-inset-bottom, 0px));
  }

  .kpi-grid,
  .kpi-grid-6 {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }

  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .team-grid { grid-template-columns: 1fr 1fr; }

  .nav-item {
    min-height: 44px;
    padding: 12px 14px;
  }

  .notif-btn {
    width: 44px;
    height: 44px;
  }

  .btn {
    min-height: 44px;
    padding: 10px 16px;
  }
  .btn-sm {
    min-height: 40px;
    padding: 8px 14px;
  }

  .catalog-tabs {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .catalog-tab {
    min-height: 44px;
    padding: 10px 16px;
    white-space: nowrap;
  }
}

/* ---------- Phone (~390×844) ---------- */
@media (max-width: 768px) {
  html { font-size: 15px; }

  .login-screen {
    padding: max(24px, env(safe-area-inset-top, 0px)) 16px max(24px, env(safe-area-inset-bottom, 0px));
    align-items: center;
    justify-content: center;
  }
  .login-card {
    padding: 32px 22px 28px;
    max-width: 100%;
  }
  .login-logo .logo-img { width: 132px; }
  .login-logo h1 { font-size: 1.35rem; }
  .login-options {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
  .login-options label { min-height: 44px; }
  .form-control { min-height: 48px; font-size: 1rem; }
  .btn-block { min-height: 48px; }

  .topbar {
    --topbar-h: 52px;
    height: 52px;
    padding: 0 10px 0 4px;
  }
  .topbar-left { gap: 8px; flex: 1; min-width: 0; }
  .page-title {
    font-size: 1rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 55vw;
  }
  .breadcrumb {
    display: none;
  }

  .content {
    padding: 14px 12px calc(28px + env(safe-area-inset-bottom, 0px));
  }

  .kpi-grid,
  .kpi-grid-6 {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-bottom: 16px;
  }
  .kpi-card {
    padding: 14px 12px;
    gap: 10px;
    flex-direction: column;
    align-items: flex-start;
  }
  .kpi-icon {
    width: 40px;
    height: 40px;
    font-size: 1.15rem;
    border-radius: 10px;
  }
  .kpi-value { font-size: 1.4rem; }
  .kpi-label { font-size: 0.75rem; }
  .kpi-trend { font-size: 0.7rem; }

  .page-toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }
  .toolbar-actions {
    width: 100%;
  }
  .toolbar-actions .btn {
    flex: 1;
  }

  /* Filters stack vertically */
  .table-toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
  .table-toolbar-left,
  .table-toolbar-right {
    flex-direction: column;
    align-items: stretch;
    width: 100%;
    gap: 8px;
  }
  .search-box { width: 100%; }
  .search-box input {
    width: 100%;
    min-height: 44px;
    font-size: 1rem;
  }
  .filter-select {
    width: 100%;
    min-height: 44px;
    font-size: 1rem;
  }
  .table-toolbar-right .btn { width: 100%; }

  .card-header {
    flex-wrap: wrap;
    gap: 8px;
    padding: 14px 14px;
  }
  .card-body { padding: 14px; }

  .section-title { font-size: 1.1rem; }

  /* Report type cards: 1 column on phone */
  .report-type-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }
  .report-type-card {
    min-height: 64px;
    padding: 14px 16px;
  }

  .team-grid { grid-template-columns: 1fr; }
  .config-grid { grid-template-columns: 1fr; }

  .table-footer {
    flex-direction: column;
    gap: 10px;
    align-items: stretch;
    padding: 12px 14px;
  }

  /* Mobile card-list for key data tables */
  .table-scroll.mobile-card-mode {
    overflow: visible;
  }
  .table-scroll.mobile-card-mode .data-table {
    min-width: 0;
    border-collapse: separate;
    border-spacing: 0 10px;
  }
  .table-scroll.mobile-card-mode .data-table thead {
    display: none;
  }
  .table-scroll.mobile-card-mode .data-table tbody tr {
    display: block;
    background: var(--surface);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 4px 0;
    margin: 0;
  }
  .table-scroll.mobile-card-mode .data-table tbody tr:hover {
    background: var(--surface);
  }
  .table-scroll.mobile-card-mode .data-table tbody td {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border-light);
    text-align: right;
    white-space: normal;
  }
  .table-scroll.mobile-card-mode .data-table tbody td:last-child {
    border-bottom: none;
  }
  .table-scroll.mobile-card-mode .data-table tbody td::before {
    content: attr(data-label);
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    text-align: left;
    flex: 0 0 42%;
    max-width: 42%;
  }
  .table-scroll.mobile-card-mode .data-table th:first-child,
  .table-scroll.mobile-card-mode .data-table td:first-child {
    position: static;
    box-shadow: none;
    background: transparent;
  }
  .table-scroll.mobile-card-mode .data-table tbody td:first-child {
    background: var(--primary-50);
    border-radius: var(--radius) var(--radius) 0 0;
    font-weight: 600;
  }

  /* Non-card tables: keep sticky + scroll */
  .table-scroll:not(.mobile-card-mode) .data-table {
    min-width: 560px;
  }

  .cal-grid { gap: 2px; }
  .cal-day { min-height: 52px; padding: 4px; font-size: 0.65rem; }
  .cal-day .cal-event { font-size: 0.55rem; }

  .status-bar-row .label { width: 80px; }

  .sidebar-brand .brand-text { font-size: 1rem; }
  .sidebar-brand .brand-sub {
    font-size: 0.65rem;
    max-width: 140px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

/* ---------- Small phones ---------- */
@media (max-width: 480px) {
  .login-card { padding: 28px 18px 24px; }
  .login-logo h1 { font-size: 1.2rem; }
  .login-logo p { font-size: 0.8rem; }

  .kpi-card { padding: 12px 10px; }
  .kpi-value { font-size: 1.25rem; }
  .kpi-icon { width: 36px; height: 36px; font-size: 1rem; }

  .page-title { max-width: 48vw; font-size: 0.95rem; }

  .content {
    padding: 12px 10px calc(32px + env(safe-area-inset-bottom, 0px));
  }

  .user-avatar { width: 32px; height: 32px; font-size: 0.75rem; }

  .table-scroll.mobile-card-mode .data-table tbody td {
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
    text-align: left;
  }
  .table-scroll.mobile-card-mode .data-table tbody td::before {
    max-width: 100%;
    flex: none;
  }
}


/* Reportes / flex toolbars on phone */
@media (max-width: 768px) {
  .page-view[data-page="reportes"] > .flex-between {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }
  .page-view[data-page="reportes"] > .flex-between .flex {
    flex-direction: column;
    width: 100%;
  }
  .page-view[data-page="reportes"] > .flex-between .filter-select,
  .page-view[data-page="reportes"] > .flex-between .btn {
    width: 100%;
  }
  .flex-between {
    flex-wrap: wrap;
    gap: 10px;
  }
}

.kpi-grid-4 {
  grid-template-columns: repeat(4, 1fr);
}
.mb-20 { margin-bottom: 20px; }
@media (max-width: 900px) {
  .kpi-grid-4 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 480px) {
  .kpi-grid-4 { grid-template-columns: repeat(2, 1fr); gap: 8px; }
}

@media (max-width: 768px) {
  .page-view[data-page="actividades"] > .flex-between {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }
  .page-view[data-page="actividades"] > .flex-between .btn {
    width: 100%;
  }
}
