:root {
    --bg: #f4f6f8;
    --surface: #ffffff;
    --border: #e2e6ea;
    --text: #1f2933;
    --text-muted: #6b7684;
    --accent: #2563eb;
    --accent-hover: #1d4ed8;
    --ok-bg: #e6f6ec;
    --ok-text: #1a7f37;
    --warn-bg: #fff4e5;
    --warn-text: #9a6700;
    --err-bg: #fdecea;
    --err-text: #c0392b;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 14px 24px;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 28px;
}

.brand {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text);
    text-decoration: none;
}

.topnav {
    display: flex;
    gap: 4px;
}

.topnav a {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 600;
    padding: 6px 12px;
    border-radius: 6px;
}

.topnav a:hover {
    background: var(--bg);
    color: var(--text);
}

.topnav a.active {
    background: var(--accent);
    color: #fff;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 16px;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.btn-logout {
    color: var(--accent);
    text-decoration: none;
    font-weight: 600;
}
.btn-logout:hover { color: var(--accent-hover); }

main {
    max-width: 1200px;
    margin: 24px auto;
    padding: 0 24px 48px;
}

.filters {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 16px;
    margin-bottom: 16px;
    align-items: end;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 0.85rem;
}

.field label {
    color: var(--text-muted);
    font-weight: 600;
}

.field input, .field select {
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.9rem;
    min-width: 150px;
}

.field select[multiple] {
    min-width: 160px;
    padding: 4px;
}

.field-hint {
    color: var(--text-muted);
    font-size: 0.75rem;
}

.field-actions {
    flex-direction: row;
    gap: 8px;
}

button, .btn-clear {
    padding: 9px 16px;
    border-radius: 6px;
    border: none;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
}

button {
    background: var(--accent);
    color: #fff;
}
button:hover { background: var(--accent-hover); }

.btn-clear {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
}
.btn-clear:hover { background: var(--bg); }

.btn-export {
    background: transparent;
    color: var(--ok-text);
    border: 1px solid var(--ok-text);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
}
.btn-export:hover { background: var(--ok-bg); }
.btn-export-disabled {
    color: var(--text-muted);
    border: 1px solid var(--border);
    cursor: not-allowed;
    opacity: 0.6;
}

.summary {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 10px;
}

.table-wrap {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
    min-width: 900px;
}

thead th {
    text-align: left;
    padding: 12px 14px;
    background: var(--bg);
    color: var(--text-muted);
    font-weight: 600;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

tbody td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

tbody tr:hover { background: #fafbfc; }

.empty {
    text-align: center;
    color: var(--text-muted);
    padding: 32px 0 !important;
}

.empty-state {
    background: var(--surface);
    border: 1px dashed var(--border);
    border-radius: 10px;
    padding: 40px 24px;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.95rem;
}

.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 600;
    background: var(--bg);
    color: var(--text-muted);
}
.badge-ok { background: var(--ok-bg); color: var(--ok-text); }
.badge-warn { background: var(--warn-bg); color: var(--warn-text); }
.badge-err { background: var(--err-bg); color: var(--err-text); }

.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-top: 20px;
    font-size: 0.9rem;
}

.pagination a {
    color: var(--accent);
    text-decoration: none;
    padding: 6px 10px;
    border-radius: 6px;
}
.pagination a:hover { background: var(--surface); }
.pagination a.disabled {
    color: var(--text-muted);
    pointer-events: none;
    opacity: 0.5;
}
.page-indicator { color: var(--text-muted); }

/* Login */
.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}

.login-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 32px;
    width: 100%;
    max-width: 340px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.06);
}

.login-card h1 {
    font-size: 1.3rem;
    margin: 0 0 4px;
}

.subtitle {
    color: var(--text-muted);
    font-size: 0.88rem;
    margin: 0 0 20px;
}

.login-card form {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.login-card label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-top: 8px;
}

.login-card input {
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.95rem;
}

.login-card button {
    margin-top: 18px;
    padding: 10px;
}

.alert {
    background: var(--err-bg);
    color: var(--err-text);
    padding: 10px 12px;
    border-radius: 6px;
    font-size: 0.85rem;
    margin-bottom: 12px;
}

/* Menú principal */
.page-title {
    font-size: 1.05rem;
    color: var(--text-muted);
    margin: 0 0 16px;
}

.menu-title {
    font-size: 1.4rem;
    margin: 24px 0 20px;
    text-align: center;
}

.menu-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    max-width: 980px;
    margin: 0 auto;
}

.menu-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 28px 24px;
    text-decoration: none;
    color: var(--text);
    transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.menu-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 24px rgba(0,0,0,0.08);
    border-color: var(--accent);
}

.menu-card-icon {
    font-size: 2rem;
    margin-bottom: 10px;
}

.menu-card-title {
    font-weight: 700;
    font-size: 1.05rem;
    margin-bottom: 6px;
}

.menu-card-desc {
    color: var(--text-muted);
    font-size: 0.88rem;
    line-height: 1.4;
}

/* Estadísticas */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.stat-tile {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 18px 20px;
}

.stat-value {
    font-size: 1.7rem;
    font-weight: 700;
    line-height: 1.2;
}

.stat-value.stat-ok { color: var(--ok-text); }

.stat-label {
    color: var(--text-muted);
    font-size: 0.82rem;
    margin-top: 4px;
}

.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 20px;
}

.panel-title {
    font-size: 0.95rem;
    margin: 0 0 16px;
    color: var(--text);
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.panel-header .panel-title {
    margin: 0;
}

.hbar-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.hbar-row {
    display: grid;
    grid-template-columns: 120px 1fr 60px;
    align-items: center;
    gap: 10px;
    font-size: 0.85rem;
}

.hbar-label { color: var(--text-muted); }

.hbar-track {
    background: var(--bg);
    border-radius: 4px;
    height: 14px;
    overflow: hidden;
}

.hbar-track-sm { height: 8px; width: 100px; }

.hbar-fill {
    height: 100%;
    border-radius: 4px;
    min-width: 2px;
}

.bar-ok { background: var(--ok-text); }
.bar-warn { background: var(--warn-text); }
.bar-err { background: var(--err-text); }
.bar-accent { background: var(--accent); }

.hbar-value {
    text-align: right;
    font-weight: 600;
    color: var(--text);
}

.vbar-wrap {
    overflow-x: auto;
}

.vbar-chart {
    display: flex;
    align-items: flex-end;
    gap: 4px;
    height: 160px;
    min-width: min-content;
}

.vbar {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    width: 20px;
    height: 100%;
    flex: 0 0 auto;
}

.vbar-fill {
    width: 100%;
    background: var(--accent);
    border-radius: 3px 3px 0 0;
    min-height: 3px;
}

.vbar:hover .vbar-fill { background: var(--accent-hover); }

.vbar-label {
    margin-top: 6px;
    font-size: 0.65rem;
    color: var(--text-muted);
    writing-mode: vertical-rl;
    transform: rotate(180deg);
    white-space: nowrap;
}

.td-bar { width: 110px; }
