:root {
    --bg: #f1f5f9;
    --panel: #ffffff;
    --sidebar: #0f172a;
    --sidebar-hover: #1e293b;
    --accent: #2563eb;
    --accent-dark: #1d4ed8;
    --text: #0f172a;
    --muted: #64748b;
    --border: #e2e8f0;
    --green: #16a34a;
    --red: #dc2626;
    --orange: #ea580c;
    --amber: #d97706;
    --blue: #2563eb;
    --purple: #7c3aed;
    --radius: 10px;
}

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

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

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

.app { display: flex; min-height: 100vh; }

.sidebar {
    width: 230px;
    min-width: 230px;
    background: var(--sidebar);
    color: #cbd5e1;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.brand { padding: 20px 18px 14px; border-bottom: 1px solid rgba(255,255,255,.08); }
.brand-logo {
    display: block;
    width: 100%;
    max-height: 52px;
    object-fit: contain;
    background: #fff;
    border-radius: 8px;
    padding: 6px 10px;
    margin-bottom: 8px;
}
.brand-name { font-size: 18px; font-weight: 700; color: #fff; letter-spacing: .3px; }
.brand-sub { font-size: 11px; color: #94a3b8; margin-top: 2px; }

.nav { flex: 1; padding: 10px 0; }
.nav-group { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: #64748b; padding: 14px 18px 6px; }
.nav-link {
    display: block;
    padding: 9px 18px;
    color: #cbd5e1;
    font-size: 13.5px;
    border-left: 3px solid transparent;
}
.nav-link:hover { background: var(--sidebar-hover); color: #fff; text-decoration: none; }
.nav-link.active { background: var(--sidebar-hover); border-left-color: var(--accent); color: #fff; font-weight: 600; }

.sidebar-foot { padding: 12px 0 16px; border-top: 1px solid rgba(255,255,255,.08); }

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

.topbar {
    background: var(--panel);
    border-bottom: 1px solid var(--border);
    padding: 12px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 10;
}
.topbar-title { font-size: 16px; font-weight: 700; }
.topbar-user { display: flex; align-items: center; gap: 10px; }
.user-name { font-weight: 600; }
.user-rol { color: var(--muted); font-size: 12px; }

.content { padding: 24px; flex: 1; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 20px; }
.card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    border-top: 3px solid var(--blue);
    color: var(--text);
    display: block;
    transition: transform .12s ease, box-shadow .12s ease;
}
.card:hover { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(2,6,23,.08); text-decoration: none; }
.card-label { font-size: 12px; color: var(--muted); }
.card-value { font-size: 20px; font-weight: 700; margin-top: 4px; }
.card-green { border-top-color: var(--green); }
.card-orange { border-top-color: var(--orange); }
.card-amber { border-top-color: var(--amber); }
.card-red { border-top-color: var(--red); }
.card-purple { border-top-color: var(--purple); }

.mini-cards { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 18px; }
.mini-card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px 16px;
    display: flex;
    flex-direction: column;
    color: var(--text);
}
.mini-card:hover { text-decoration: none; border-color: var(--accent); }
.mini-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }
.mini-value { font-size: 17px; font-weight: 700; margin-top: 2px; }

.panel {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px;
    margin-bottom: 18px;
}
.panel-title { font-size: 14px; font-weight: 700; margin-bottom: 12px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.table-panel { padding: 8px 0 12px; overflow-x: auto; }

table { width: 100%; border-collapse: collapse; }
th {
    text-align: left;
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--muted);
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
td { padding: 9px 12px; border-bottom: 1px solid #f1f5f9; vertical-align: middle; }
tr:hover td { background: #f8fafc; }
td.actions { white-space: nowrap; }
td.actions .inline { display: inline; }

table.kv th { width: 160px; color: var(--muted); text-transform: none; letter-spacing: 0; font-size: 13px; }
table.kv td { border-bottom: 1px solid #f1f5f9; }

.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 600;
    background: #e2e8f0;
    color: #334155;
    white-space: nowrap;
}
.badge-green { background: #dcfce7; color: #15803d; }
.badge-red { background: #fee2e2; color: #b91c1c; }
.badge-orange { background: #ffedd5; color: #c2410c; }
.badge-amber { background: #fef3c7; color: #92400e; }
.badge-blue { background: #dbeafe; color: #1d4ed8; }
.badge-purple { background: #ede9fe; color: #6d28d9; }

.ev-img {
    display: block;
    max-width: 160px;
    max-height: 90px;
    border-radius: 6px;
    border: 1px solid #e2e8f0;
    object-fit: cover;
}
.nota-cell { max-width: 280px; white-space: normal; min-width: 180px; }

.btn {
    display: inline-block;
    background: var(--accent);
    color: #fff;
    border: 1px solid var(--accent);
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
    transition: background .12s;
    line-height: 1.4;
}
.btn:hover { background: var(--accent-dark); text-decoration: none; }
.btn-ghost { background: #fff; color: var(--text); border-color: var(--border); }
.btn-ghost:hover { background: #f8fafc; }
.btn-warn { background: #fff; color: #92400e; border-color: #fcd34d; }
.btn-warn:hover { background: #fef3c7; }
.btn-danger { background: #fff; color: #b91c1c; border-color: #fecaca; }
.btn-danger:hover { background: #fee2e2; }
.btn-sm { padding: 4px 10px; font-size: 12px; border-radius: 6px; }
.btn-block { display: block; width: 100%; text-align: center; }

.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.search-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

label { display: block; font-size: 12.5px; font-weight: 600; color: #334155; margin-bottom: 4px; }
label input[type="checkbox"] { display: inline; width: auto; margin-right: 6px; }
.check-label { display: inline; font-weight: 400; margin: 0 10px 0 0; }

input[type="text"], input[type="password"], input[type="email"], input[type="number"],
input[type="date"], input[type="time"], select, textarea {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 13.5px;
    font-family: inherit;
    background: #fff;
    color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: 2px solid #bfdbfe; border-color: var(--accent); }
.inp-sm { width: 90px !important; padding: 4px 6px !important; }

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
.form-actions { margin-top: 18px; display: flex; gap: 10px; }

.alert {
    padding: 11px 14px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 13.5px;
    font-weight: 500;
}
.alert-success { background: #dcfce7; color: #15803d; border: 1px solid #bbf7d0; }
.alert-error { background: #fee2e2; color: #b91c1c; border: 1px solid #fecaca; }

.empty { color: var(--muted); text-align: center; padding: 22px !important; font-style: italic; }
.muted { color: var(--muted); font-size: 12.5px; }
.debt { color: var(--red); font-weight: 700; }
.row-item { padding: 8px 0; border-bottom: 1px solid #f1f5f9; }
.row-item:last-child { border-bottom: none; }
.row-title { font-weight: 600; font-size: 13.5px; }
.row-sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.row-past td { opacity: .65; }
.row-debt td { background: #fef2f2; }
.link-small { font-size: 12.5px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 1000px) { .grid-2 { grid-template-columns: 1fr; } }

.pagination { display: flex; gap: 6px; padding: 14px 12px 4px; flex-wrap: wrap; }
.page {
    display: inline-flex;
    min-width: 30px;
    height: 30px;
    align-items: center;
    justify-content: center;
    padding: 0 8px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #fff;
    color: var(--text);
    font-size: 13px;
}
.page:hover { border-color: var(--accent); text-decoration: none; }
.page.current { background: var(--accent); border-color: var(--accent); color: #fff; }

.bar-chart { display: flex; align-items: flex-end; gap: 8px; height: 220px; padding: 10px 4px 0; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; }
.bar-value { font-size: 11px; color: var(--muted); margin-bottom: 4px; white-space: nowrap; }
.bar { width: 70%; max-width: 42px; background: var(--accent); border-radius: 4px 4px 0 0; min-height: 2px; }
.bar-label { font-size: 11px; color: var(--muted); margin-top: 6px; }

/* Login */
.login-body { background: linear-gradient(135deg, #0f172a, #1e3a8a); display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-card {
    background: #fff;
    border-radius: 14px;
    padding: 34px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 20px 50px rgba(0,0,0,.35);
}
.login-brand { text-align: center; margin-bottom: 22px; }
.login-logo {
    display: block;
    max-width: 220px;
    max-height: 64px;
    margin: 0 auto 6px;
    object-fit: contain;
}
.login-brand h1 { font-size: 24px; color: var(--sidebar); }
.login-brand p { color: var(--muted); font-size: 13px; }
.login-card label { margin-top: 10px; }
.login-card .btn { margin-top: 18px; }

@media (max-width: 760px) {
    .sidebar { width: 100%; min-width: 0; height: auto; position: static; }
    .app { flex-direction: column; }
}

.report { padding: 26px; }
.report-head { text-align: center; border-bottom: 2px solid var(--text); padding-bottom: 12px; margin-bottom: 16px; }
.report-head h2 { font-size: 20px; }
.report-head h3 { font-size: 16px; color: var(--muted); margin-top: 2px; }
.report-head p { font-size: 12px; color: var(--muted); margin-top: 6px; }
.report h4 { margin: 18px 0 8px; font-size: 14px; }
.report table.kv td { font-size: 14px; padding: 8px 12px; }
.report tfoot td { border-top: 2px solid var(--text); font-weight: 700; background: #fff !important; }
.report-foot { margin-top: 30px; font-size: 12px; color: var(--muted); }

@media print {
    body { background: #fff !important; }
    .sidebar, .topbar, .no-print { display: none !important; }
    .app { display: block; }
    .main { display: block; }
    .content { padding: 0 !important; }
    .panel { border: none !important; padding: 0 !important; margin: 0 !important; box-shadow: none !important; }
    .mini-cards, .cards { display: none !important; }
    table { font-size: 11px; }
    a { text-decoration: none; color: #000; }
}