:root {
    --bg: #f1f5f9;
    --surface: #ffffff;
    --sidebar: #0f172a;
    --sidebar-hover: #1e293b;
    --sidebar-active: #2563eb;
    --text: #0f172a;
    --muted: #64748b;
    --border: #e2e8f0;
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --success: #16a34a;
    --danger: #dc2626;
    --warning: #d97706;
    --radius: 8px;
}

* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    font-size: 14px;
    color: var(--text);
    background: var(--bg);
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Layout */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
    width: 245px;
    background: var(--sidebar);
    color: #e2e8f0;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}
.sidebar-brand {
    padding: 16px 18px;
    font-size: 16px;
    font-weight: 700;
    border-bottom: 1px solid #1e293b;
    display: flex;
    align-items: center;
    gap: 10px;
    color: #fff;
}
.sidebar-brand span.badge-port {
    font-size: 10px;
    background: #2563eb;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 600;
}
.sidebar-nav { padding: 10px 8px; flex: 1; overflow-y: auto; }
.nav-section {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: #94a3b8;
    padding: 12px 12px 4px;
    font-weight: 600;
}
.nav-link {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 8px 12px;
    border-radius: 6px;
    color: #cbd5e1;
    font-size: 13.5px;
    margin-bottom: 2px;
    transition: background .15s;
}
.nav-link:hover { background: var(--sidebar-hover); color: #fff; text-decoration: none; }
.nav-link.active { background: var(--sidebar-active); color: #fff; font-weight: 600; }

.main-area { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 10px 22px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}
.topbar-title { font-size: 17px; font-weight: 700; margin: 0; }
.topbar-controls { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.nomina-switcher select {
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 13px;
    background: #f8fafc;
    font-weight: 600;
}
.user-pill {
    font-size: 12.5px;
    background: #f1f5f9;
    padding: 5px 10px;
    border-radius: 20px;
    color: var(--text);
}

.content { padding: 20px 22px; flex: 1; }

/* Cards & Grids */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 18px;
    margin-bottom: 18px;
    box-shadow: 0 1px 2px rgba(0,0,0,.03);
}
.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
    flex-wrap: wrap;
}
.card-title { font-size: 15px; font-weight: 700; margin: 0; }

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}
.kpi-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 16px;
}
.kpi-label { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; }
.kpi-value { font-size: 24px; font-weight: 700; margin-top: 4px; color: var(--text); }
.kpi-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }

.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--border); text-align: left; }
th { background: #f8fafc; font-weight: 600; color: #334155; white-space: nowrap; }
tr:hover td { background: #f8fafc; }
.text-right { text-align: right; }
.text-center { text-align: center; }

/* Forms & Buttons */
.form-group { margin-bottom: 12px; }
.form-group label { display: block; font-size: 12.5px; font-weight: 600; color: #334155; margin-bottom: 4px; }
.form-control {
    width: 100%;
    padding: 7px 10px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-size: 13.5px;
    font-family: inherit;
    background: #fff;
}
.form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 2px rgba(37,99,235,.15); }
.form-inline { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 13px;
    border-radius: 6px;
    border: 1px solid transparent;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    text-decoration: none;
}
.btn:hover { text-decoration: none; opacity: .92; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-light { background: #f1f5f9; color: var(--text); border-color: #cbd5e1; }
.btn-sm { padding: 4px 9px; font-size: 12px; }

/* Badges & Alerts */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11.5px;
    font-weight: 600;
}
.badge-green { background: #dcfce7; color: #166534; }
.badge-red { background: #fee2e2; color: #991b1b; }
.badge-blue { background: #dbeafe; color: #1e40af; }
.badge-amber { background: #fef3c7; color: #92400e; }
.badge-gray { background: #e2e8f0; color: #334155; }

.alert {
    padding: 10px 14px;
    border-radius: 6px;
    margin-bottom: 14px;
    font-size: 13.5px;
    border: 1px solid transparent;
}
.alert-success { background: #dcfce7; color: #166534; border-color: #bbf7d0; }
.alert-danger { background: #fee2e2; color: #991b1b; border-color: #fecaca; }
.alert-info { background: #dbeafe; color: #1e40af; border-color: #bfdbfe; }

/* Tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; flex-wrap: wrap; }
.tab-link {
    padding: 8px 14px;
    font-size: 13px;
    font-weight: 600;
    color: var(--muted);
    border-bottom: 2px solid transparent;
}
.tab-link:hover { color: var(--text); text-decoration: none; }
.tab-link.active { color: var(--primary); border-bottom-color: var(--primary); }

/* Login */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0f172a 0%, #1e3a8a 100%);
    padding: 20px;
}
.login-box {
    background: #fff;
    width: 100%;
    max-width: 390px;
    border-radius: 10px;
    padding: 28px;
    box-shadow: 0 20px 40px rgba(0,0,0,.25);
}

/* Print */
@media print {
    .sidebar, .topbar, .no-print { display: none !important; }
    .main-area, .content { padding: 0 !important; margin: 0 !important; }
    .card { border: none; box-shadow: none; }
    body { background: #fff; }
}
