/* ═══════════════════════════════════════════════════════════════════
   MARANDU ASISTENCIAS — Design System
   Data-Dense Dashboard · Inter · Blue primary palette
   ═══════════════════════════════════════════════════════════════════ */

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

/* ── Tokens ────────────────────────────────────────────────────── */
:root {
  /* Superficies */
  --bg:           #f8fafc;
  --bg-subtle:    #f1f5f9;
  --white:        #ffffff;

  /* Sidebar */
  --sidebar-bg:   #0f172a;
  --sidebar-hover:#1e293b;

  /* Marca — Enterprise Blue */
  --primary:      #1e40af;
  --primary-dk:   #1e3a8a;
  --primary-lt:   #eff6ff;
  --primary-mid:  #dbeafe;

  /* Texto */
  --text:         #0f172a;
  --text-2:       #1e293b;
  --text-muted:   #64748b;
  --text-subtle:  #94a3b8;

  /* Bordes */
  --border:       #e2e8f0;
  --border-2:     #cbd5e1;

  /* Semánticos */
  --green:        #15803d;  --green-lt: #f0fdf4;  --green-bd: #bbf7d0;
  --red:          #dc2626;  --red-lt:   #fef2f2;  --red-bd:   #fecaca;
  --amber:        #b45309;  --amber-lt: #fffbeb;  --amber-bd: #fde68a;
  --violet:       #7c3aed;  --violet-lt:#faf5ff;

  /* Sombras */
  --shadow-xs:   0 1px 2px rgba(0,0,0,.05);
  --shadow-sm:   0 1px 3px rgba(0,0,0,.07),0 1px 2px rgba(0,0,0,.04);
  --shadow-md:   0 4px 16px rgba(0,0,0,.09),0 2px 4px rgba(0,0,0,.04);
  --shadow-lg:   0 10px 32px rgba(0,0,0,.11),0 4px 10px rgba(0,0,0,.06);

  /* Radio */
  --r-sm: 6px;  --r-md: 10px;  --r-lg: 14px;  --r-xl: 18px;

  /* Animación */
  --dur-fast: 120ms;
  --dur-base: 200ms;
  --dur-slow: 300ms;
  --ease: cubic-bezier(.4,0,.2,1);
}

/* ── Base ──────────────────────────────────────────────────────── */
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  font-size: 13px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.layout { display: flex; height: 100vh; height: 100dvh; }

/* ══════════════════════════════════════════════════════════════════
   SIDEBAR
   ══════════════════════════════════════════════════════════════════ */
.sidebar {
  width: 240px;
  min-width: 240px;
  background: var(--sidebar-bg);
  color: #fff;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-right: 1px solid rgba(255,255,255,.04);
  flex-shrink: 0;
  position: relative;
  z-index: 30;
  transition: width .2s ease, min-width .2s ease;
}

/* ── Sidebar head ── */
.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 14px 12px;
  border-bottom: 1px solid rgba(255,255,255,.06);
  flex-shrink: 0;
  gap: 8px;
  overflow: hidden;
}
.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
  overflow: hidden;
}
.logo-icon-wrap {
  width: 34px; height: 34px;
  background: var(--primary);
  border-radius: var(--r-sm);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; color: #fff;
}
.logo-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
}
.logo-title { font-size: 14px; font-weight: 700; letter-spacing: -.2px; overflow: hidden; text-overflow: ellipsis; }
.logo-sub   { font-size: 10px; color: rgba(255,255,255,.35); margin-top: 1px; letter-spacing: .2px; }

.sidebar-collapse-btn {
  width: 26px; height: 26px;
  background: transparent; border: none;
  border-radius: var(--r-sm);
  color: rgba(255,255,255,.3); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; transition: background .15s, color .15s;
}
.sidebar-collapse-btn:hover { background: rgba(255,255,255,.1); color: rgba(255,255,255,.8); }

/* ── Nav section ── */
.nav-section { display: flex; flex-direction: column; gap: 2px; padding: 10px 10px 6px; flex-shrink: 0; }
.nav-tab {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px;
  background: transparent;
  border: none; border-radius: var(--r-sm);
  color: rgba(255,255,255,.5);
  cursor: pointer;
  font-size: 13px; font-weight: 500; font-family: inherit;
  transition: all .15s; text-align: left;
  white-space: nowrap; overflow: hidden; width: 100%;
}
.nav-tab:hover  { background: rgba(255,255,255,.07); color: rgba(255,255,255,.85); }
.nav-tab.active { background: var(--primary); color: #fff; }
.nav-icon  { flex-shrink: 0; }
.nav-label { overflow: hidden; text-overflow: ellipsis; }

/* ── Divider ── */
.sidebar-divider { height: 1px; background: rgba(255,255,255,.06); margin: 0 10px; flex-shrink: 0; }

/* ── Personas search wrap ── */
.sidebar-search-wrap { padding: 10px 14px 0; flex-shrink: 0; }
.search-wrap { position: relative; display: flex; align-items: center; }
.search-icon { position: absolute; left: 9px; color: rgba(255,255,255,.3); pointer-events: none; }
.people-search-input {
  width: 100%; padding: 7px 10px 7px 28px;
  background: rgba(255,255,255,.07); border: 1px solid rgba(255,255,255,.1);
  border-radius: var(--r-sm); color: #fff; font-size: 12px; font-family: inherit;
  outline: none; transition: border-color .15s;
}
.people-search-input::placeholder { color: rgba(255,255,255,.28); }
.people-search-input:focus        { border-color: var(--primary); }
.people-count { font-size: 10px; color: rgba(255,255,255,.28); margin-top: 6px; }

/* ── Days head ── */
.sidebar-days-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 18px 4px; flex-shrink: 0;
}
.sidebar-label-text {
  font-size: 10px; color: rgba(255,255,255,.28);
  text-transform: uppercase; letter-spacing: .8px; font-weight: 600;
}
.sidebar-days-total {
  font-size: 10px; color: rgba(255,255,255,.4); font-weight: 600;
  background: rgba(255,255,255,.08); padding: 1px 7px; border-radius: 20px;
}

/* ── Days scroll ── */
.sidebar-days-scroll { flex: 1; overflow-y: auto; padding-bottom: 4px; }
.loading-small { color: rgba(255,255,255,.3); font-size: 11px; padding: 10px 18px; }

/* ── Month groups & day items ── */
.month-group   { }
.month-header  {
  display: flex; align-items: center; justify-content: space-between;
  padding: 7px 18px 3px;
  cursor: pointer; user-select: none;
  color: rgba(255,255,255,.35); font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .7px; transition: color .15s;
}
.month-header:hover   { color: rgba(255,255,255,.7); }
.month-days.collapsed { display: none; }
.day-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 18px; cursor: pointer;
  border-left: 2px solid transparent; transition: background .12s;
}
.day-item:hover  { background: var(--sidebar-hover); }
.day-item.active { background: rgba(37,99,235,.2); border-left-color: var(--primary); }
.day-item-left   { display: flex; flex-direction: column; gap: 1px; }
.day-date        { font-size: 12px; font-weight: 500; color: rgba(255,255,255,.8); }
.day-today       { font-size: 9px; color: #60a5fa; font-weight: 700; letter-spacing: .4px; }
.day-badge       { background: rgba(255,255,255,.1); color: rgba(255,255,255,.55); font-size: 10px; font-weight: 600; padding: 2px 7px; border-radius: 20px; min-width: 26px; text-align: center; }

/* ── Sidebar footer ── */
.sidebar-foot { padding: 10px 16px; border-top: 1px solid rgba(255,255,255,.06); flex-shrink: 0; }
.sync-info    { font-size: 10px; color: rgba(255,255,255,.28); display: flex; align-items: center; gap: 5px; }

/* ── Collapsed state (desktop only — see media queries) ── */
/* ── Mobile overlay ── */
.sidebar-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.5); z-index: 40;
  backdrop-filter: blur(2px);
}
.sidebar-overlay.active { display: block; }

/* ── Mobile topbar ── */
.mobile-topbar {
  display: none; align-items: center; justify-content: space-between;
  padding: 0 16px; height: 52px;
  background: var(--white); border-bottom: 1px solid var(--border);
  flex-shrink: 0; z-index: 10;
}
.mobile-menu-btn {
  width: 36px; height: 36px; background: transparent; border: none;
  border-radius: var(--r-sm); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted); transition: background .15s;
}
.mobile-menu-btn:hover { background: var(--bg-subtle); }
.mobile-title { font-size: 15px; font-weight: 700; color: var(--text); }

/* ══════════════════════════════════════════════════════════════════
   MAIN
   ══════════════════════════════════════════════════════════════════ */
.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-width: 0; }

/* Header */
.header {
  padding: 14px 24px;
  background: var(--white);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; flex-shrink: 0;
}
.header-left h1    { font-size: 17px; font-weight: 700; letter-spacing: -.3px; }
.page-subtitle     { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.header-controls   { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* Buttons */
.btn-secondary {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 14px;
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--r-sm);
  cursor: pointer; font-size: 12px; font-weight: 500; font-family: inherit;
  color: var(--text-muted); transition: all .15s;
}
.btn-secondary:hover { background: var(--primary-lt); color: var(--primary-dk); border-color: var(--primary); }
.btn-back {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 14px;
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--r-sm);
  cursor: pointer; font-size: 12px; font-weight: 500; font-family: inherit;
  color: var(--text-muted); transition: all .15s;
}
.btn-back:hover { background: var(--primary-lt); color: var(--primary-dk); border-color: var(--primary); }

/* Controls */
.control-group { position: relative; display: flex; align-items: center; }
.control-icon  { position: absolute; left: 9px; color: var(--text-muted); pointer-events: none; }
.date-picker, .input-filter {
  height: 32px; border: 1px solid var(--border); border-radius: var(--r-sm);
  padding: 0 10px 0 28px; font-size: 12px; font-family: inherit;
  color: var(--text); background: var(--white); outline: none; transition: border-color .15s;
}
.date-picker:focus, .input-filter:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.1); }
.input-filter { width: 170px; }
.select-filter {
  height: 32px; border: 1px solid var(--border); border-radius: var(--r-sm);
  padding: 0 10px; font-size: 12px; font-family: inherit;
  color: var(--text); background: var(--white); outline: none; cursor: pointer;
  transition: border-color .15s;
}
.select-filter:focus { border-color: var(--primary); }

/* Date mode: un día / período */
.date-mode-toggle {
  display: inline-flex;
  padding: 3px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  gap: 2px;
}
.date-mode-btn {
  padding: 5px 12px;
  border: none;
  border-radius: 6px;
  background: transparent;
  font-size: 11px;
  font-weight: 600;
  font-family: inherit;
  color: var(--text-muted);
  cursor: pointer;
  transition: all .15s;
}
.date-mode-btn:hover { color: var(--text); }
.date-mode-btn.active {
  background: var(--white);
  color: var(--primary-dk);
  box-shadow: 0 1px 2px rgba(0,0,0,.06);
}
.date-range-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.date-range-sep {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
}
.date-picker-end { padding-left: 10px !important; }
.range-presets {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
.preset-btn {
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--white);
  font-size: 11px;
  font-weight: 500;
  font-family: inherit;
  color: var(--text-muted);
  cursor: pointer;
  transition: all .15s;
}
.preset-btn:hover {
  border-color: var(--primary);
  color: var(--primary-dk);
  background: var(--primary-lt);
}
.range-day-section {
  margin-bottom: 20px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--r);
  overflow: hidden;
}
.range-day-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.range-day-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

/* Tardanza */
.tardanza-config-card {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: #fff7ed;
  border: 1px solid #fed7aa;
  border-radius: var(--r-sm);
  flex-wrap: wrap;
}
.tardanza-config-label {
  font-size: 11px;
  font-weight: 600;
  color: #9a3412;
}
.tardanza-config-hint {
  font-size: 10px;
  color: #c2410c;
}
.tardanza-save-status {
  font-size: 11px;
  font-weight: 600;
  min-width: 4em;
}
.tardanza-save-ok { color: #15803d; }
.tardanza-save-err { color: #dc2626; }
.tardanza-save-loading { color: #b45309; }
.btn-save-tardanza { padding: 5px 12px; }
.time-picker {
  height: 32px;
  border: 1px solid #fdba74;
  border-radius: var(--r-sm);
  padding: 0 8px;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  color: #9a3412;
  background: var(--white);
  outline: none;
}
.time-picker:focus {
  border-color: #ea580c;
  box-shadow: 0 0 0 3px rgba(234, 88, 12, .12);
}
.tardanza-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 14px;
  padding: 10px 14px;
  background: #fff7ed;
  border: 1px solid #fed7aa;
  border-radius: var(--r-sm);
  font-size: 12px;
  color: #9a3412;
}
.stat-icon-orange { background: #ffedd5; color: #c2410c; }
.stat-card-tardanza { border-color: #fed7aa; }
.status-tardanza {
  background: #ffedd5;
  color: #c2410c;
  border: 1px solid #fdba74;
}
.time-orange { color: #c2410c; }
.tardanza-min-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  background: #ffedd5;
  color: #c2410c;
  border: 1px solid #fdba74;
}
.chip-orange {
  background: #ffedd5;
  color: #c2410c;
  border: 1px solid #fdba74;
}

/* ══════════════════════════════════════════════════════════════════
   STATS BAR (Asistencias)
   ══════════════════════════════════════════════════════════════════ */
.stats-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 24px;
  background: var(--white); border-bottom: 1px solid var(--border);
  flex-wrap: wrap; flex-shrink: 0;
}
.stat-card {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 14px;
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--r-md);
}
.stat-icon-wrap {
  width: 30px; height: 30px; border-radius: var(--r-sm);
  background: var(--primary-lt); color: var(--primary-dk);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.stat-icon-green { background: var(--green-lt); color: var(--green); }
.stat-icon-red   { background: var(--red-lt);   color: var(--red);   }
.stat-icon-amber { background: var(--amber-lt); color: var(--amber); }
.stat-body  { display: flex; flex-direction: column; }
.stat-num   { font-size: 18px; font-weight: 700; line-height: 1; letter-spacing: -.5px; }
.stat-label { font-size: 10px; color: var(--text-muted); margin-top: 2px; font-weight: 500; }
.stat-edificios { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-left: 4px; }
.stat-edif { background: var(--bg-subtle); border: 1px solid var(--border); color: var(--text-muted); border-radius: 20px; padding: 4px 10px; font-size: 11px; }
.stat-edif strong { color: var(--text); }

/* ══════════════════════════════════════════════════════════════════
   RESUMEN VIEW — KPI Cards
   ══════════════════════════════════════════════════════════════════ */
.resumen-scroll {
  flex: 1; overflow-y: auto; padding: 20px 24px;
}

.kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.kpi-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 18px 20px;
  box-shadow: var(--shadow-xs);
  position: relative;
  overflow: hidden;
  transition: box-shadow var(--dur-base) var(--ease), transform var(--dur-base) var(--ease);
  cursor: default;
}
.kpi-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}
.kpi-card::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--border-2);
}
.kpi-green::before { background: var(--green); }
.kpi-blue::before  { background: var(--primary); }
.kpi-slate::before { background: #64748b; }

.kpi-header {
  display: flex; align-items: center; gap: 7px;
  font-size: 10px; font-weight: 700; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .6px;
  margin-bottom: 12px;
}
.kpi-value {
  font-size: 34px; font-weight: 800; letter-spacing: -1.5px;
  color: var(--text); line-height: 1;
  margin-bottom: 6px;
  font-variant-numeric: tabular-nums;
}
.kpi-footer { font-size: 11px; color: var(--text-muted); }
.kpi-delta  { font-size: 11px; font-weight: 700; margin-left: 2px; }
.delta-pos  { color: var(--green); }
.delta-neg  { color: var(--red); }

.kpi-progress-track {
  margin-top: 12px; height: 5px;
  background: var(--bg-subtle); border-radius: 99px; overflow: hidden;
}
.kpi-progress-fill { height: 100%; border-radius: 99px; transition: width .8s var(--ease); }
.kpi-progress-green { background: var(--green); }

/* ══════════════════════════════════════════════════════════════════
   RESUMEN VIEW — Charts
   ══════════════════════════════════════════════════════════════════ */
.charts-row {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 12px;
  margin-bottom: 16px;
}
.chart-side-stack { display: flex; flex-direction: column; gap: 12px; }

.chart-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.chart-card-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  padding: 14px 18px 12px;
  border-bottom: 1px solid var(--border);
}
.chart-title { font-size: 13px; font-weight: 600; color: var(--text); }
.chart-sub   { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.chart-area  { padding: 10px 14px 6px; }

/* SVG chart */
.trend-svg { display: block; width: 100%; }
.chart-grid       { stroke: var(--border); stroke-width: .8; }
.chart-axis       { stroke: var(--border-2); stroke-width: 1; }
.chart-line       { stroke: var(--primary); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart-dot        { fill: var(--primary); stroke: white; stroke-width: 1.5; }
.chart-dot-today  { fill: var(--primary); stroke: white; stroke-width: 2; }
.chart-avg-line   { stroke: var(--text-muted); stroke-width: 1; }
.chart-avg-label  { font-size: 9px; fill: var(--text-muted); font-family: inherit; }
.chart-axis-label { font-size: 10px; fill: var(--text-muted); font-family: inherit; }
.chart-today-label{ font-size: 10px; fill: var(--primary); font-weight: 600; font-family: inherit; }

/* Legend */
.chart-legend {
  display: flex; align-items: center; gap: 10px;
  font-size: 11px; color: var(--text-muted);
  flex-shrink: 0;
}
.legend-dot   { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 3px; }
.legend-blue  { background: var(--primary); }
.legend-line  { display: inline-block; width: 18px; height: 2px; border-radius: 1px; margin-right: 3px; vertical-align: middle; }
.legend-dashed{ background: var(--text-muted); }

/* Building bars */
.building-bars { padding: 14px 18px; display: flex; flex-direction: column; gap: 14px; }
.bar-item     { }
.bar-header   { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 5px; }
.bar-label    { font-size: 12px; font-weight: 500; color: var(--text-2); }
.bar-pct      { font-size: 14px; font-weight: 700; color: var(--text); }
.bar-track    { height: 8px; background: var(--bg-subtle); border-radius: 99px; overflow: hidden; }
.bar-fill     { height: 100%; border-radius: 99px; transition: width .6s ease; }
.bar-sub      { font-size: 10px; color: var(--text-muted); margin-top: 4px; }

/* Hour bars */
.hour-bars    { padding: 10px 18px 14px; }
.hour-chart   {
  display: flex; align-items: flex-end; gap: 3px;
  height: 72px; overflow-x: auto;
}
.hour-bar-col {
  display: flex; flex-direction: column; align-items: center;
  flex: 1; min-width: 20px; gap: 3px;
}
.hour-bar-fill  { width: 100%; border-radius: 3px 3px 0 0; min-height: 2px; transition: height .3s; }
.hour-bar-label { font-size: 9px; color: var(--text-subtle); white-space: nowrap; }
.hour-legend    { display: flex; gap: 12px; margin-top: 8px; }
.hour-legend-item { display: flex; align-items: center; gap: 4px; font-size: 10px; color: var(--text-muted); }
.hour-dot       { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }

/* ══════════════════════════════════════════════════════════════════
   HISTORIAL VIEW
   ══════════════════════════════════════════════════════════════════ */
.historial-month {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden; margin-bottom: 14px;
  box-shadow: var(--shadow-sm);
}
.historial-month-hdr {
  display: flex; align-items: center; justify-content: space-between;
  padding: 11px 18px;
  background: var(--bg-subtle); border-bottom: 1px solid var(--border);
}
.historial-month-name  { font-size: 13px; font-weight: 600; color: var(--text); }
.historial-month-badge {
  font-size: 10px; font-weight: 600; color: var(--text-muted);
  background: var(--white); border: 1px solid var(--border);
  padding: 1px 8px; border-radius: 20px;
}
.historial-row { cursor: pointer; transition: background .1s; }
.historial-row:hover td { background: #f5f8ff !important; }
.historial-active td   { background: var(--primary-lt) !important; }
.historial-arrow { color: var(--border-2); transition: color .1s; }
.historial-row:hover .historial-arrow { color: var(--primary); }

/* ── Analytics history table ─── */
.analytics-history-table td:first-child { font-size: 12px; }
.date-cell { font-variant-numeric: tabular-nums; }
.today-pill {
  display: inline-block; background: var(--primary-lt); color: var(--primary-dk);
  border: 1px solid #bfdbfe; border-radius: 20px;
  font-size: 9px; font-weight: 700; padding: 1px 6px;
  margin-left: 6px; text-transform: uppercase; letter-spacing: .4px;
}
.row-today td { background: #fafbff !important; }
.mini-bar-track { height: 6px; background: var(--bg-subtle); border-radius: 99px; overflow: hidden; width: 80px; }
.mini-bar-fill  { height: 100%; border-radius: 99px; }
.mini-bar-green { background: var(--green); }
.mini-bar-blue  { background: var(--primary); }

/* ══════════════════════════════════════════════════════════════════
   ASISTENCIAS — Building sections
   ══════════════════════════════════════════════════════════════════ */
.events-container { flex: 1; overflow-y: auto; padding: 18px 24px; }

.empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  height: 100%; gap: 12px; color: var(--text-muted); font-size: 13px;
}
.empty-icon-svg { color: var(--border-2); }

.building-section {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden; margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}
.building-header {
  display: flex; align-items: center; gap: 9px;
  padding: 11px 18px;
  background: var(--bg-subtle); border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.building-hdr-icon { color: var(--text-muted); flex-shrink: 0; }
.building-name     { font-size: 13px; font-weight: 600; flex: 1; min-width: 120px; }
.building-chips    { display: flex; gap: 5px; flex-wrap: wrap; align-items: center; }

/* Chips */
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 10px; font-weight: 600;
  padding: 2px 9px; border-radius: 20px; border: 1px solid;
  white-space: nowrap;
}
.chip-neutral { background: var(--bg);       color: var(--text-muted); border-color: var(--border); }
.chip-green   { background: var(--green-lt); color: var(--green);       border-color: var(--green-bd); }
.chip-red     { background: var(--red-lt);   color: var(--red);         border-color: var(--red-bd); }
.chip-amber   { background: var(--amber-lt); color: var(--amber);       border-color: var(--amber-bd); }

/* Building table */
.building-table-wrap { overflow-x: auto; }
.building-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.building-table thead th {
  padding: 8px 16px; text-align: left;
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px;
  color: var(--text-muted); background: var(--bg); border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.building-table tbody td { padding: 9px 16px; border-bottom: 1px solid #f1f5f9; vertical-align: middle; }
.building-table tbody tr:last-child td { border-bottom: none; }
.building-table tbody tr:hover td     { background: #fafbfd; }

/* Person cell */
.person-cell { display: flex; align-items: center; gap: 9px; }
.table-avatar {
  width: 30px; height: 30px; border-radius: 50%;
  font-size: 10px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; letter-spacing: .3px;
}
.person-name-cell { font-weight: 500; white-space: nowrap; }
.legajo-cell { color: var(--text-muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.day-col     { color: var(--text-muted); font-size: 11px; white-space: nowrap; font-weight: 500; }

/* Time */
.time-val {
  display: inline-flex; align-items: center; gap: 4px;
  font-weight: 600; font-variant-numeric: tabular-nums;
}
.time-green { color: #15803d; }
.time-red   { color: #dc2626; }
.time-empty { color: var(--text-subtle); }
.text-muted { color: var(--text-muted); }

/* Status badges */
.status-badge {
  display: inline-block; padding: 2px 9px;
  border-radius: 20px; font-size: 10px; font-weight: 600;
  white-space: nowrap; border: 1px solid;
}
.status-completo    { background: var(--green-lt); color: var(--green);  border-color: var(--green-bd); }
.status-presente    { background: var(--amber-lt); color: var(--amber);  border-color: var(--amber-bd); }
.status-sin-entrada { background: var(--bg-subtle);color: var(--text-muted); border-color: var(--border); }

/* time-group (historial persona) */
.time-group       { margin-bottom: 22px; }
.time-group-label { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .6px; color: var(--text-muted); margin-bottom: 8px; padding-bottom: 6px; border-bottom: 1px solid var(--border); }

/* ══════════════════════════════════════════════════════════════════
   PERSONAS — Grid y cards
   ══════════════════════════════════════════════════════════════════ */
.people-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 10px;
}

.person-card {
  background: var(--white);
  border-radius: var(--r-lg);
  padding: 14px 16px;
  border: 1px solid var(--border);
  cursor: pointer;
  box-shadow: var(--shadow-xs);
  display: flex; align-items: center; gap: 13px;
  transition: box-shadow var(--dur-base) var(--ease),
              border-color var(--dur-base) var(--ease),
              transform var(--dur-base) var(--ease);
  touch-action: manipulation;
  position: relative;
  overflow: hidden;
}
.person-card::after {
  content: '';
  position: absolute; inset: 0;
  background: var(--primary);
  opacity: 0;
  transition: opacity var(--dur-fast) var(--ease);
  pointer-events: none;
}
.person-card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--primary-mid);
  transform: translateY(-2px);
}
.person-card:active { transform: translateY(0) scale(.99); box-shadow: var(--shadow-xs); }

/* Avatar */
.person-avatar-placeholder {
  width: 46px; height: 46px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; font-weight: 700; flex-shrink: 0; letter-spacing: .5px;
  position: relative;
}
/* Dot de actividad sobre el avatar */
.person-activity-dot {
  position: absolute; bottom: 1px; right: 1px;
  width: 10px; height: 10px; border-radius: 50%;
  border: 2px solid var(--white);
}

.person-info   { flex: 1; min-width: 0; }
.person-name   { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text); }
.person-sub    { font-size: 11px; color: var(--text-muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.person-footer { display: flex; align-items: center; gap: 10px; margin-top: 6px; }
.person-foot-item {
  display: flex; align-items: center; gap: 4px;
  font-size: 11px; color: var(--text-muted);
}
.person-foot-item strong { color: var(--text-2); font-weight: 600; }

/* Activity pill */
.person-activity-pill {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 10px; font-weight: 600; padding: 2px 8px;
  border-radius: 20px; border: 1px solid;
  margin-top: 5px;
}
.pill-today  { background: #f0fdf4; color: #15803d; border-color: #bbf7d0; }
.pill-week   { background: var(--primary-lt); color: var(--primary); border-color: var(--primary-mid); }
.pill-month  { background: #fffbeb; color: #b45309; border-color: #fde68a; }
.pill-old    { background: var(--bg-subtle); color: var(--text-subtle); border-color: var(--border); }

.person-card-arrow { color: var(--border-2); flex-shrink: 0; transition: color var(--dur-fast), transform var(--dur-fast); }
.person-card:hover .person-card-arrow { color: var(--primary); transform: translateX(2px); }

/* ── Skeleton de personas ── */
.skeleton-person-card {
  background: var(--white); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 14px 16px;
  display: flex; align-items: center; gap: 13px;
  box-shadow: var(--shadow-xs);
}
.skeleton {
  background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
  background-size: 800px 100%;
  animation: shimmer 1.5s ease-in-out infinite;
  border-radius: var(--r-sm);
}
@keyframes shimmer {
  0%   { background-position: -400px 0; }
  100% { background-position: 400px 0; }
}
.sk-circle { border-radius: 50%; flex-shrink: 0; }
.sk-block  { border-radius: var(--r-sm); }

/* ── Person detail ── */
.person-detail-avatar {
  width: 48px; height: 48px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 17px; font-weight: 700; flex-shrink: 0; letter-spacing: .5px;
}
.person-detail-stats-grid { display: flex; gap: 8px; flex-wrap: wrap; }
.person-detail-stat {
  background: var(--primary-lt); border: 1px solid var(--primary-mid);
  border-radius: var(--r-md); padding: 8px 16px; text-align: center;
  transition: box-shadow var(--dur-fast) var(--ease);
}
.person-detail-stat:hover { box-shadow: var(--shadow-sm); }
.person-detail-stat .num { font-size: 18px; font-weight: 800; color: var(--primary-dk); letter-spacing: -.5px; font-variant-numeric: tabular-nums; }
.person-detail-stat .lbl { font-size: 10px; color: var(--text-muted); margin-top: 2px; font-weight: 500; text-transform: uppercase; letter-spacing: .4px; }

/* ── Entrada animada de las person-cards ── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
.person-card-enter {
  animation: fadeUp var(--dur-slow) var(--ease) both;
}

/* ══════════════════════════════════════════════════════════════════
   LOADING & UTILS
   ══════════════════════════════════════════════════════════════════ */
.loading {
  display: flex; align-items: center; justify-content: center;
  height: 180px; color: var(--text-muted); font-size: 13px; gap: 10px;
}
.spinner {
  width: 18px; height: 18px;
  border: 2px solid var(--border); border-top-color: var(--primary);
  border-radius: 50%; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ══════════════════════════════════════════════════════════════════
   RESPONSIVE
   ══════════════════════════════════════════════════════════════════ */
@media (max-width: 1100px) {
  .charts-row { grid-template-columns: 1fr; }
  .chart-side-stack { flex-direction: row; }
  .chart-side-stack .chart-card { flex: 1; }
}

/* ── Desktop collapsed sidebar ─────────────────────────────────── */
@media (min-width: 769px) {
  .sidebar.collapsed {
    width: 60px;
    min-width: 60px;
  }
  .sidebar.collapsed .logo-text,
  .sidebar.collapsed .nav-label,
  .sidebar.collapsed .sidebar-days-head,
  .sidebar.collapsed .sidebar-days-scroll,
  .sidebar.collapsed .sidebar-search-wrap,
  .sidebar.collapsed .sidebar-foot {
    display: none;
  }
  .sidebar.collapsed .nav-tab {
    justify-content: center;
    padding: 10px 8px;
  }
  .sidebar.collapsed .sidebar-head {
    justify-content: center;
    padding: 14px 10px 12px;
  }
  .sidebar.collapsed .sidebar-collapse-btn {
    display: none;
  }
  /* clicking the logo-icon-wrap uncollapses on desktop */
  .sidebar.collapsed .logo-icon-wrap {
    cursor: pointer;
  }
}

/* ── Mobile: sidebar as overlay drawer ─────────────────────────── */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 50;
    transform: translateX(-100%);
    transition: transform .25s cubic-bezier(.4,0,.2,1);
    width: 260px !important;
    min-width: 260px !important;
  }
  .sidebar.open { transform: translateX(0); }
  .mobile-topbar { display: flex; }
  /* sidebar siempre en modo completo en mobile */
  .sidebar .logo-text,
  .sidebar .nav-label,
  .sidebar .sidebar-foot { display: revert; }
  .sidebar .nav-tab       { justify-content: flex-start; padding: 8px 12px; }
  .sidebar .sidebar-head  { justify-content: space-between; padding: 14px 14px 12px; }
  .sidebar .sidebar-collapse-btn { display: flex; }

  .events-container, .resumen-scroll { padding: 12px 14px; }
  .header       { padding: 11px 14px; }
  .stats-bar    { padding: 8px 14px; }
  .kpi-row      { grid-template-columns: repeat(2, 1fr); }
  .chart-side-stack { flex-direction: column; }

  /* Edificios: scroll horizontal suave */
  .stat-edificios { overflow-x: auto; flex-wrap: nowrap; max-width: 100%; padding-bottom: 2px; }
  .select-filter  { max-width: 148px; }
  .date-picker    { width: 138px; }
  .people-grid    { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
}

/* ── Tabla asistencias: filas como cards ─────────────────────── */
@media (max-width: 768px) {
  #view-asistencias .building-section .building-table,
  #view-asistencias .building-section .building-table tbody { display: block; }
  #view-asistencias .building-section .building-table thead { display: none; }
  #view-asistencias .building-section .building-table tr {
    display: flex; align-items: center;
    padding: 9px 14px; gap: 6px;
    border-bottom: 1px solid #f1f5f9;
  }
  #view-asistencias .building-section .building-table td {
    display: flex; align-items: center;
    padding: 0; border: none !important; background: none !important;
  }
  /* Persona: espacio restante */
  #view-asistencias .building-section .building-table td:nth-child(1) { flex: 1 1 0; min-width: 0; overflow: hidden; }
  /* Legajo: oculto */
  #view-asistencias .building-section .building-table td:nth-child(2) { display: none; }
  /* Entrada / Salida */
  #view-asistencias .building-section .building-table td:nth-child(3),
  #view-asistencias .building-section .building-table td:nth-child(4) { flex-shrink: 0; }
  /* Estado: alineado a la derecha */
  #view-asistencias .building-section .building-table td:nth-child(5) { flex-shrink: 0; margin-left: auto; }

  /* Historial: ocultar columna Distribución */
  #historial-container .building-table thead th:nth-child(4),
  #historial-container .building-table tbody td:nth-child(4) { display: none; }
}

@media (max-width: 560px) {
  .kpi-row    { grid-template-columns: 1fr; }
  .stats-bar  { flex-wrap: wrap; gap: 6px; }

  /* Filtros asistencias: apilados */
  #view-asistencias .header-controls              { flex-direction: column; align-items: stretch; width: 100%; }
  #view-asistencias .header-controls .control-group { width: 100%; }
  #view-asistencias .header-controls .date-picker  { width: 100%; padding-left: 28px; }
  #view-asistencias .header-controls .input-filter { width: 100% !important; }
  #view-asistencias .header-controls .select-filter { width: 100%; max-width: none; }
  #view-asistencias .date-mode-toggle { width: 100%; justify-content: stretch; }
  #view-asistencias .date-mode-btn { flex: 1; text-align: center; }
  #view-asistencias .date-range-wrap { flex-direction: column; align-items: stretch; width: 100%; }
  #view-asistencias .date-range-wrap .btn-secondary { width: 100%; justify-content: center; }
  #view-asistencias .range-presets { width: 100%; }
  #view-asistencias .preset-btn { flex: 1; text-align: center; }
  #view-tardanzas .header-controls { flex-direction: column; align-items: stretch; width: 100%; }
  #view-tardanzas .tardanza-config-card { width: 100%; justify-content: flex-start; }
  #view-tardanzas .date-range-wrap { flex-direction: column; align-items: stretch; width: 100%; }

  /* Historial: ocultar también Día y Eventos */
  #historial-container .building-table thead th:nth-child(2),
  #historial-container .building-table thead th:nth-child(5),
  #historial-container .building-table tbody td:nth-child(2),
  #historial-container .building-table tbody td:nth-child(5) { display: none; }

  /* Detalle persona: ocultar Edificio */
  #person-events-container .building-table thead th:nth-child(4),
  #person-events-container .building-table tbody td:nth-child(4) { display: none; }

  /* Person detail header: apilado */
  #person-detail .header         { flex-direction: column; align-items: flex-start; gap: 10px; }
  #person-detail-stats           { width: 100%; }
  .person-detail-stats-grid      { flex-wrap: wrap; }
  .person-detail-stat            { flex: 1; min-width: 80px; }

  /* Search personas: ancho completo */
  #view-personas .header-controls { width: 100%; }
  #people-search                  { width: 100% !important; }
}

/* ══════════════════════════════════════════════════════════════════
   ACCESIBILIDAD & INTERACCIÓN GLOBAL
   ══════════════════════════════════════════════════════════════════ */

/* Focus visible — teclado */
:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
button:focus-visible, a:focus-visible,
input:focus-visible, select:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

/* Cursor y touch en todos los elementos interactivos */
button, .nav-tab, .day-item, .person-card,
.historial-row, .building-table tbody tr,
.person-card-arrow, .historial-arrow,
.month-header, .btn-back, .btn-secondary {
  cursor: pointer;
  touch-action: manipulation;
}

/* Transición global para todos los botones */
button { transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease); }

/* Empty states mejorados */
.empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  height: 100%; gap: 14px; color: var(--text-muted); font-size: 14px;
  padding: 48px 24px; text-align: center;
}
.empty-icon-svg { color: var(--border-2); margin-bottom: 4px; }
.empty-state h3 { font-size: 15px; font-weight: 600; color: var(--text-2); margin: 0; }
.empty-state p  { font-size: 13px; color: var(--text-muted); margin: 0; max-width: 280px; line-height: 1.6; }
.empty-action {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 18px;
  background: var(--primary); color: #fff;
  border: none; border-radius: var(--r-md);
  font-size: 13px; font-weight: 600; font-family: inherit;
  cursor: pointer; margin-top: 4px;
  transition: background var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}
.empty-action:hover { background: var(--primary-dk); transform: translateY(-1px); }

/* ── Building section header mejorado ── */
.building-header {
  display: flex; align-items: center; gap: 9px;
  padding: 12px 18px;
  background: linear-gradient(135deg, var(--bg-subtle) 0%, var(--white) 100%);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.building-hdr-icon { color: var(--primary); flex-shrink: 0; }
.building-name     { font-size: 13px; font-weight: 700; flex: 1; min-width: 120px; color: var(--text); }

/* ── Stat cards mejorados ── */
.stat-card {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 14px;
  background: var(--white); border: 1px solid var(--border); border-radius: var(--r-md);
  transition: box-shadow var(--dur-fast);
}
.stat-card:hover { box-shadow: var(--shadow-sm); }

/* ── Nav tabs sidebar — active indicator ── */
.nav-tab.active {
  background: rgba(30,64,175,.15);
  color: #93c5fd;
  position: relative;
}
.nav-tab.active::before {
  content: '';
  position: absolute; left: 0; top: 6px; bottom: 6px;
  width: 3px; background: #60a5fa;
  border-radius: 0 3px 3px 0;
}

/* ── Reduced motion ── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .skeleton { animation: none; background: #f1f5f9; }
}

/* ══════════════════════════════════════════════════════════════════
   SCROLLBARS & ICONS
   ══════════════════════════════════════════════════════════════════ */
::-webkit-scrollbar       { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

svg[data-lucide] { display: inline-block; vertical-align: middle; flex-shrink: 0; }
