:root {
    --bg: #f6f8fb;
    --card: #ffffff;
    --line: #d9e0ea;
    --text: #1b2838;
    --primary: #0b57d0;
    --success: #e8f5e9;
    --error: #fdecea;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: Arial, Helvetica, sans-serif;
    background: var(--bg);
    color: var(--text);
}

/* ── Topbar ───────────────────────────────────────── */
.topbar {
    background: #0f172a;
    color: white;
    padding: 18px 0;
}

.topbar-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
}

.topbar-title h1 {
    margin: 0 0 4px;
    font-size: 24px;
}

.topbar-title p {
    margin: 0;
    opacity: .8;
    font-size: 13px;
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
    flex-shrink: 0;
}

.topbar-user span {
    opacity: .9;
}

.user-role-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .4px;
    text-transform: uppercase;
}

.badge-admin {
    background: #fbbf24;
    color: #78350f;
}

.badge-consulta {
    background: #38bdf8;
    color: #0c4a6e;
}

.btn-logout {
    display: inline-block;
    padding: 6px 14px;
    border-radius: 6px;
    border: 1px solid rgba(255,255,255,.35);
    background: transparent;
    color: white;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
}

.btn-logout:hover {
    background: rgba(255,255,255,.15);
}

/* ── Navigation ──────────────────────────────────── */
.nav {
    background: #1e293b;
    margin-bottom: 24px;
}

.nav .container {
    display: flex;
    gap: 0;
}

.nav a {
    display: inline-block;
    padding: 12px 20px;
    color: #94a3b8;
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
    border-bottom: 3px solid transparent;
    transition: color .15s, border-color .15s;
}

.nav a:hover {
    color: #e2e8f0;
}

.nav a.active {
    color: white;
    border-bottom-color: var(--primary);
}

/* ── Container & cards ───────────────────────────── */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px;
}

.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
}

/* ── Grids ───────────────────────────────────────── */
.grid-2, .grid-3 {
    display: grid;
    gap: 14px;
}

.grid-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

/* ── Form elements ───────────────────────────────── */
label {
    display: block;
    margin-bottom: 6px;
    font-weight: 700;
    font-size: 14px;
}

input[type="text"],
input[type="password"],
input[type="file"],
input[type="date"],
input:not([type]),
select,
textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    font-size: 14px;
    background-color: #ffffff;
    font-family: inherit;
}

select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%2364748b' viewBox='0 0 16 16'%3E%3Cpath d='M7.247 11.14 2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 12px;
    padding-right: 40px !important;
}

input[type="checkbox"],
input[type="radio"] {
    accent-color: var(--primary);
}

input[type="text"]:focus,
input[type="password"]:focus,
input[type="date"]:focus,
input:not([type]):focus,
select:focus,
textarea:focus {
    outline: 2px solid var(--primary);
    outline-offset: 1px;
    border-color: var(--primary);
}

button, .secondary {
    display: inline-block;
    padding: 10px 16px;
    border-radius: 8px;
    border: 0;
    text-decoration: none;
    cursor: pointer;
    background: var(--primary);
    color: white;
    font-weight: 700;
    font-size: 14px;
}

.secondary {
    background: #475569;
}

.actions {
    margin-top: 16px;
    display: flex;
    gap: 10px;
}

.align-end {
    display: flex;
    align-items: flex-end;
}

/* ── Messages ────────────────────────────────────── */
.message {
    margin-top: 14px;
    padding: 12px 14px;
    border-radius: 8px;
    font-size: 14px;
}

.message.success {
    background: var(--success);
    color: #1b5e20;
}

.message.error {
    background: var(--error);
    color: #b71c1c;
}

/* ── Table ───────────────────────────────────────── */
.table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 1200px;
}

th, td {
    border: 1px solid var(--line);
    padding: 10px;
    text-align: left;
    vertical-align: top;
    font-size: 14px;
}

th {
    background: #eef2f7;
}

/* ── Login page ──────────────────────────────────── */
.login-wrapper {
    min-height: 76vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 40px 44px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 4px 24px rgba(0,0,0,.08);
}

.login-card h2 {
    margin: 0 0 6px;
    font-size: 22px;
}

.login-card .subtitle {
    margin: 0 0 28px;
    color: #64748b;
    font-size: 14px;
}

.field {
    margin-bottom: 16px;
}

.btn-primary {
    width: 100%;
    padding: 12px;
    font-size: 15px;
    border-radius: 8px;
    border: 0;
    background: var(--primary);
    color: white;
    font-weight: 700;
    cursor: pointer;
}

.btn-primary:hover {
    opacity: .9;
}

.divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 20px 0;
    color: #94a3b8;
    font-size: 13px;
}

.divider::before, .divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--line);
}

.btn-ms {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 11px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: white;
    color: var(--text);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: background .15s;
}

.btn-ms:hover {
    background: #f1f5f9;
}

.validation-summary {
    background: var(--error);
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 13px;
    margin-bottom: 16px;
    color: #b91c1c;
}

.validation-summary ul {
    margin: 0;
    padding: 0 0 0 18px;
}

/* ── Config page ─────────────────────────────────── */
.radio-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 12px 0;
}

.radio-group label {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    font-weight: 400;
    cursor: pointer;
    line-height: 1.4;
}

.radio-group input[type="radio"] {
    width: auto;
    margin-top: 3px;
    accent-color: var(--primary);
    flex-shrink: 0;
}

/* ── CECO filter notice (en Consulta) ────────────── */
.ceco-filter-notice {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 13px;
    color: #1d4ed8;
    margin-bottom: 16px;
}

.ceco-filter-notice strong {
    background: #dbeafe;
    border-radius: 4px;
    padding: 1px 6px;
    font-family: monospace;
}

/* ── Responsive ──────────────────────────────────── */
@media (max-width: 960px) {
    .grid-2, .grid-3 {
        grid-template-columns: 1fr;
    }

    .topbar-inner {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
}
