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

:root {
    --bg: #f5f6fa;
    --bg-white: #ffffff;
    --bg-hover: #f0f2f8;
    --border: #e8eaef;
    --border-light: #f0f1f5;
    --text: #1e2138;
    --text-muted: #6e7191;
    --text-dim: #a0a3bd;
    --accent: #5b6abf;
    --accent-light: #eef0ff;
    --green: #00b894;
    --green-bg: #e6f9f4;
    --green-text: #00866b;
    --red: #e74c6f;
    --red-bg: #fdeef2;
    --red-text: #c0354d;
    --orange: #f59e0b;
    --orange-bg: #fef6e6;
    --orange-text: #a16b07;
    --blue: #4e7cf6;
    --blue-bg: #edf2fe;
    --blue-text: #2c5ce0;
    --sidebar-w: 240px;
    --topbar-h: 56px;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 1px 3px rgba(30,33,56,0.06);
    --shadow-lg: 0 8px 24px rgba(30,33,56,0.12);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    font-size: 14px;
}

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

/* ── Sidebar ──────────────────────────────────────────────────────────── */
.sidebar {
    width: var(--sidebar-w);
    background: var(--bg-white);
    border-right: 1px solid var(--border);
    position: fixed;
    top: 0; left: 0; bottom: 0;
    display: flex;
    flex-direction: column;
    z-index: 200;
    transition: transform 0.25s ease;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px 20px 24px;
}
.logo-icon {
    width: 36px; height: 36px;
    background: var(--accent);
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    color: white; font-size: 13px; font-weight: 700;
    flex-shrink: 0;
}
.logo-title { font-weight: 700; font-size: 15px; display: block; color: var(--text); }
.logo-sub { font-size: 11px; color: var(--text-dim); display: block; margin-top: 1px; }

.sidebar-nav { flex: 1; padding: 0 12px; overflow-y: auto; }

.nav-section {
    font-size: 10px; font-weight: 700; color: var(--text-dim);
    text-transform: uppercase; letter-spacing: 0.08em;
    padding: 20px 12px 6px;
}

.nav-item {
    display: flex; align-items: center; gap: 12px;
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    text-decoration: none;
    font-size: 13px; font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    margin-bottom: 2px;
}
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; stroke: currentColor; }
.nav-item:hover { background: var(--bg-hover); color: var(--text); }
.nav-item.active {
    background: var(--accent-light);
    color: var(--accent);
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--border);
}
.sidebar-user {
    display: flex; align-items: center; gap: 10px;
}
.user-avatar {
    width: 32px; height: 32px; border-radius: 50%;
    background: var(--accent);
    display: flex; align-items: center; justify-content: center;
    color: white; font-size: 12px; font-weight: 600;
}
.user-name { font-size: 13px; font-weight: 600; display: block; color: var(--text); }
.user-role { font-size: 11px; color: var(--text-dim); display: block; }

/* ── Main wrapper ─────────────────────────────────────────────────────── */
.main-wrapper {
    flex: 1;
    margin-left: var(--sidebar-w);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ── Topbar ───────────────────────────────────────────────────────────── */
.topbar {
    height: var(--topbar-h);
    background: var(--bg-white);
    border-bottom: 1px solid var(--border);
    padding: 0 28px;
    display: flex; align-items: center; justify-content: space-between;
    position: sticky; top: 0; z-index: 100;
    flex-shrink: 0;
}
.topbar-left { display: flex; align-items: center; gap: 16px; }
.page-title { font-size: 17px; font-weight: 700; letter-spacing: -0.01em; }
.topbar-right { display: flex; align-items: center; gap: 16px; }
.topbar-date { font-size: 13px; color: var(--text-muted); font-weight: 500; }

.present-badge {
    display: flex; align-items: center; gap: 6px;
    background: var(--green-bg);
    color: var(--green-text);
    padding: 5px 14px;
    border-radius: 99px;
    font-size: 12px; font-weight: 600;
}
.present-dot {
    width: 7px; height: 7px; border-radius: 50%;
    background: var(--green);
    animation: pulse 2s infinite;
}
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:0.3} }

.mobile-toggle {
    display: none;
    background: none; border: none; color: var(--text); cursor: pointer; padding: 4px;
}

/* ── Main content ─────────────────────────────────────────────────────── */
.main-content { flex: 1; padding: 24px 28px; }

/* ── Page bar (filters, week nav) ─────────────────────────────────────── */
.page-bar {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 20px; flex-wrap: wrap; gap: 12px;
}
.page-bar-left { display: flex; align-items: center; gap: 12px; }

.week-nav { display: flex; align-items: center; gap: 2px; }
.week-nav .arrow {
    width: 34px; height: 34px;
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    background: var(--bg-white);
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    color: var(--text-muted); font-size: 16px;
    transition: all 0.15s;
}
.week-nav .arrow:hover { background: var(--bg-hover); color: var(--text); }
.week-label {
    font-size: 13px; font-weight: 600;
    padding: 0 12px; min-width: 220px; text-align: center;
    color: var(--text);
}

/* ── Card ─────────────────────────────────────────────────────────────── */
.card {
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

/* ── Tables ───────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th {
    text-align: left; padding: 11px 16px;
    font-size: 11px; font-weight: 600; color: var(--text-dim);
    text-transform: uppercase; letter-spacing: 0.04em;
    background: #fafbfd;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-light);
    font-size: 13px; vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: #fafbfd; }
tr.clickable { cursor: pointer; }

/* ── Grid table (cuadrante semanal) ───────────────────────────────────── */
.grid-table th { text-align: center; padding: 12px 6px; }
.grid-table th:first-child { text-align: left; padding-left: 16px; min-width: 220px; }
.grid-table td { text-align: center; padding: 10px 6px; }
.grid-table td:first-child { text-align: left; padding-left: 16px; }

.day-col { font-size: 11px; line-height: 1.3; }
.day-col .d-name { font-weight: 700; text-transform: uppercase; color: var(--text-muted); }
.day-col .d-num { color: var(--text-dim); font-weight: 500; }

.cell-pair {
    display: flex; flex-direction: column;
    align-items: center; gap: 4px;
    min-height: 44px; justify-content: center;
}
.punch-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 6px;
    font-size: 11px; font-weight: 600;
    min-width: 52px; text-align: center;
}
.punch-in { background: var(--green-bg); color: var(--green-text); }
.punch-out { background: var(--red-bg); color: var(--red-text); }
.cell-empty {
    font-size: 11px; color: var(--text-dim);
    font-style: italic;
}

/* ── Avatar ───────────────────────────────────────────────────────────── */
.avatar {
    width: 34px; height: 34px; border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 12px; font-weight: 700; color: white; flex-shrink: 0;
}
.emp-cell { display: flex; align-items: center; gap: 12px; }
.emp-name { font-weight: 600; color: var(--text); font-size: 13px; }
.emp-dept { font-size: 11px; color: var(--text-dim); margin-top: 1px; }

/* ── Badges ───────────────────────────────────────────────────────────── */
.badge {
    display: inline-flex; align-items: center;
    padding: 3px 12px; border-radius: 99px;
    font-size: 12px; font-weight: 600; white-space: nowrap;
}
.badge-green { background: var(--green-bg); color: var(--green-text); }
.badge-red { background: var(--red-bg); color: var(--red-text); }
.badge-orange { background: var(--orange-bg); color: var(--orange-text); }
.badge-blue { background: var(--blue-bg); color: var(--blue-text); }
.badge-gray { background: #f0f1f5; color: var(--text-dim); }

.status-met { background: var(--green-bg); color: var(--green-text); }
.status-over { background: var(--orange-bg); color: var(--orange-text); }
.status-under { background: var(--red-bg); color: var(--red-text); }

/* ── Drawer ───────────────────────────────────────────────────────────── */
.drawer-overlay {
    position: fixed; inset: 0;
    background: rgba(30,33,56,0.18);
    z-index: 500; opacity: 0; transition: opacity 0.2s;
}
.drawer-overlay.visible { opacity: 1; }

.drawer {
    position: fixed; top: 0; right: -440px;
    width: 420px; max-width: 92vw; height: 100vh;
    background: var(--bg-white);
    border-left: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    z-index: 501; overflow-y: auto;
    transition: right 0.28s cubic-bezier(0.4,0,0.2,1);
    padding: 28px;
}
.drawer.open { right: 0; }

.drawer-close {
    position: absolute; top: 20px; right: 20px;
    width: 30px; height: 30px;
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    background: var(--bg-white); cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    color: var(--text-dim); font-size: 18px;
    transition: all 0.15s;
}
.drawer-close:hover { background: var(--bg-hover); color: var(--text); }

.drawer-header {
    display: flex; align-items: center; gap: 14px;
    margin-bottom: 6px; padding-right: 40px;
}
.drawer-header .avatar { width: 44px; height: 44px; font-size: 15px; }
.drawer-title { font-size: 17px; font-weight: 700; color: var(--text); }
.drawer-subtitle { font-size: 12px; color: var(--text-dim); margin-top: 1px; }
.drawer-section {
    font-size: 13px; font-weight: 600; color: var(--text);
    margin: 20px 0 12px; padding-bottom: 8px;
    border-bottom: 1px solid var(--border-light);
}

/* ── Timeline ─────────────────────────────────────────────────────────── */
.timeline { padding: 4px 0; }
.tl-item { display: flex; gap: 14px; position: relative; padding-bottom: 24px; }
.tl-item:last-child { padding-bottom: 0; }
.tl-track { display: flex; flex-direction: column; align-items: center; width: 18px; flex-shrink: 0; }
.tl-dot {
    width: 12px; height: 12px; border-radius: 50%;
    border: 2.5px solid var(--accent);
    background: white; flex-shrink: 0; z-index: 1;
}
.tl-dot.green { border-color: var(--green); }
.tl-dot.red { border-color: var(--red); }
.tl-dot.orange { border-color: var(--orange); }
.tl-line { width: 2px; flex: 1; background: var(--border); margin-top: 4px; }
.tl-body { flex: 1; padding-top: 0; }
.tl-label { font-size: 14px; font-weight: 600; color: var(--text); }
.tl-time { font-size: 13px; color: var(--text-muted); margin-top: 1px; }
.tl-meta {
    font-size: 11px; color: var(--text-dim); margin-top: 3px;
    display: flex; align-items: center; gap: 4px;
}

/* ── Bar chart (drawer horas) ─────────────────────────────────────────── */
.bar-chart {
    display: flex; align-items: flex-end; gap: 10px;
    height: 170px; padding: 12px 0 0;
}
.bar-col {
    flex: 1; display: flex; flex-direction: column;
    align-items: center; gap: 5px;
    height: 100%; justify-content: flex-end;
}
.bar {
    width: 100%; max-width: 38px;
    border-radius: 6px 6px 0 0;
    min-height: 3px; transition: height 0.3s;
}
.bar.met { background: var(--green); }
.bar.over { background: var(--orange); }
.bar.under { background: var(--red); }
.bar.none { background: var(--border); min-height: 6px; }
.bar-val { font-size: 11px; color: var(--text-muted); font-weight: 600; }
.bar-lbl { font-size: 11px; color: var(--text-dim); font-weight: 600; margin-top: 2px; }
.chart-legend {
    display: flex; gap: 18px; justify-content: center;
    font-size: 11px; color: var(--text-muted); margin-top: 14px;
    padding-top: 14px; border-top: 1px solid var(--border-light);
}
.chart-legend span { display: flex; align-items: center; gap: 5px; }
.legend-dot { width: 10px; height: 10px; border-radius: 3px; }

/* ── Stats grid ───────────────────────────────────────────────────────── */
.stats-row {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 14px; margin-bottom: 22px;
}
.stat-card {
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px; box-shadow: var(--shadow);
}
.stat-label { font-size: 12px; color: var(--text-dim); margin-bottom: 4px; font-weight: 500; }
.stat-value { font-size: 28px; font-weight: 800; letter-spacing: -0.03em; }

/* ── Forms / Inputs ───────────────────────────────────────────────────── */
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
input, select {
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text); padding: 8px 14px;
    font-size: 13px; font-family: inherit; outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-light);
}
input::placeholder { color: var(--text-dim); }

.btn {
    background: var(--accent); color: white; border: none;
    border-radius: var(--radius-sm); padding: 8px 18px;
    font-size: 13px; font-weight: 600; font-family: inherit;
    cursor: pointer; transition: all 0.15s;
    display: inline-flex; align-items: center; gap: 6px;
}
.btn:hover { filter: brightness(1.1); }
.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-outline {
    background: var(--bg-white); border: 1px solid var(--border);
    color: var(--text-muted);
}
.btn-outline:hover { background: var(--bg-hover); color: var(--text); }
.btn-danger { background: var(--red); }

/* ── Modal ─────────────────────────────────────────────────────────────── */
.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(30,33,56,0.25);
    display: flex; align-items: center; justify-content: center;
    z-index: 1000;
}
.modal {
    background: var(--bg-white);
    border-radius: var(--radius); padding: 28px;
    width: 90%; max-width: 440px;
    box-shadow: var(--shadow-lg);
}
.modal h3 { margin-bottom: 20px; font-size: 17px; font-weight: 700; }
.form-group { margin-bottom: 16px; }
.form-group label {
    display: block; font-size: 12px; color: var(--text-muted);
    margin-bottom: 5px; font-weight: 600;
}
.form-group input { width: 100%; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 24px; }

/* ── Empty / Loading ──────────────────────────────────────────────────── */
.empty { text-align: center; padding: 48px 16px; color: var(--text-dim); font-size: 14px; }
.loading { text-align: center; padding: 40px; color: var(--text-dim); }

/* ── Responsive ───────────────────────────────────────────────────────── */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main-wrapper { margin-left: 0; }
    .main-content { padding: 16px; }
    .topbar { padding: 0 16px; }
    .mobile-toggle { display: block; }
    .drawer { width: 100%; max-width: 100%; }
}
