:root {
    --gob-guinda: #611232;
    --gob-guinda-dark: #3f0b20;
    --gob-guinda-light: #9d2449;
    --gob-gold: #a57f2c;
    --ink: #252525;
    --muted: #5f6368;
    --line: #d8d8d8;
    --surface: #ffffff;
    --soft: #f5f5f5;
    --success: #246b45;
    --danger: #a82035;
}

*, *::before, *::after { box-sizing: border-box; }
html { min-height: 100%; }
body {
    min-height: 100vh;
    margin: 0;
    padding-top: 0 !important;
    color: var(--ink);
    background: #fff;
    font-family: "Noto Sans", "Montserrat", Arial, sans-serif;
    letter-spacing: 0;
}
a { color: var(--gob-guinda); }

.institutional-header {
    position: relative !important;
    inset: auto !important;
    z-index: 1;
    width: 100% !important;
    max-width: none !important;
    margin: 0 !important;
    min-height: 76px;
    color: #fff;
    background: var(--gob-guinda);
    border-bottom: 5px solid var(--gob-gold);
}
.institutional-header__inner,
.service-bar__inner,
.institutional-footer__inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
}
.institutional-header__inner { min-height: 71px; }
.institutional-brand {
    display: inline-flex;
    align-items: center;
    gap: 16px;
    color: #fff;
    text-decoration: none;
    white-space: nowrap;
}
.institutional-brand:hover,
.institutional-brand:focus { color: #fff; text-decoration: none; }
.institutional-brand__government-logo { width: 185px; height: 58px; object-fit: contain; }
.institutional-brand__separator { width: 1px; height: 34px; background: rgba(255,255,255,.55); }
.institutional-brand__agency { font-size: 21px; font-weight: 700; }
.institutional-header__actions { display: flex; align-items: center; justify-content: flex-end; gap: 20px; }
.institutional-header__label { font-size: 14px; color: rgba(255,255,255,.85); }
.header-link { color: #fff; font-weight: 600; text-decoration: none; }
.header-link:hover, .header-link:focus { color: #fff; text-decoration: underline; }

.service-bar { color: #fff; background: var(--gob-guinda-dark); }
.service-bar__inner { min-height: 86px; justify-content: flex-start; }
.service-bar img { width: 68px; height: 56px; object-fit: contain; }
.service-bar strong, .service-bar span { display: block; }
.service-bar strong { font-size: 18px; }
.service-bar span { color: rgba(255,255,255,.78); font-size: 14px; }

.auth-main {
    min-height: calc(100vh - 76px);
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(360px, .85fr);
    background: linear-gradient(90deg, var(--gob-guinda-dark) 0 50%, #f2f2f2 50% 100%);
}
.auth-message {
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 72px max(32px, calc((100vw - 1170px) / 2));
    color: #fff;
    background: linear-gradient(125deg, var(--gob-guinda-dark), var(--gob-guinda-light));
}
.auth-message__logo {
    align-self: center;
    width: 280px;
    height: 216px;
    margin: 0 0 28px;
    object-fit: contain;
    filter: drop-shadow(0 12px 18px rgba(0,0,0,.18));
}
.auth-message h1 { max-width: 700px; margin: 0 0 22px; color: #fff; font-size: clamp(36px, 5vw, 62px); line-height: 1.08; font-weight: 700; }
.auth-message p { max-width: 620px; margin: 0; color: rgba(255,255,255,.9); font-size: 20px; line-height: 1.55; }
.auth-form-zone { display: flex; align-items: center; justify-content: center; padding: 48px 32px; }
.auth-panel {
    width: min(100%, 470px);
    padding: 36px;
    background: var(--surface);
    border-top: 6px solid var(--gob-guinda);
    box-shadow: 0 12px 32px rgba(0,0,0,.15);
}
.auth-panel h2 { margin: 0 0 8px; font-size: 28px; }
.auth-panel__intro { margin: 0 0 28px; color: var(--muted); }
.required { color: var(--danger); }
.form-group { margin-bottom: 22px; }
.form-group label { display: block; margin-bottom: 7px; font-weight: 700; }
.form-control {
    width: 100%;
    min-height: 48px;
    border: 1px solid #777;
    border-radius: 3px;
    background: #fff;
    color: var(--ink);
    font-size: 16px;
}
.form-control:focus { border-color: var(--gob-guinda); box-shadow: 0 0 0 3px rgba(97,18,50,.16); }
.password-wrap { position: relative; }
.password-wrap .form-control { padding-right: 52px; }
.password-toggle {
    position: absolute;
    right: 8px;
    top: 7px;
    width: 36px;
    height: 36px;
    border: 0;
    background: transparent;
    color: var(--gob-guinda);
    font-size: 20px;
    cursor: pointer;
}
.btn-government,
.btn-secondary-government,
.btn-danger-government {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 10px 22px;
    border: 1px solid transparent;
    border-radius: 3px;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
}
.btn-government { color: #fff; background: var(--gob-guinda); border-color: var(--gob-guinda); }
.btn-government:hover, .btn-government:focus { color: #fff; background: var(--gob-guinda-dark); text-decoration: none; }
.btn-secondary-government { color: var(--gob-guinda); background: #fff; border-color: var(--gob-guinda); }
.btn-secondary-government:hover { color: #fff; background: var(--gob-guinda); text-decoration: none; }
.btn-danger-government { color: #fff; background: var(--danger); border-color: var(--danger); }
.btn-block { width: 100%; }
.alert-government { margin-bottom: 22px; padding: 14px 16px; border-left: 5px solid; background: #f7f7f7; }
.alert-government--error { color: #711526; border-color: var(--danger); background: #fbeff1; }
.alert-government--success { color: #174b31; border-color: var(--success); background: #edf7f1; }

.page-main { min-height: calc(100vh - 270px); padding: 44px 0 64px; }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 34px; padding-bottom: 18px; border-bottom: 1px solid var(--line); }
.page-heading h1 { margin: 0 0 8px; font-size: 36px; }
.page-heading p { margin: 0; color: var(--muted); }
.identity-summary { display: flex; align-items: center; gap: 12px; color: var(--muted); }
.identity-summary strong { color: var(--ink); }

.systems-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 22px; }
.system-card { display: flex; flex-direction: column; min-height: 250px; padding: 26px; border: 1px solid var(--line); border-top: 5px solid var(--gob-guinda); background: #fff; }
.system-card__tag { color: var(--gob-guinda); font-size: 13px; font-weight: 700; text-transform: uppercase; }
.system-card h2 { margin: 12px 0 10px; font-size: 23px; }
.system-card p { flex: 1; color: var(--muted); line-height: 1.55; text-align: left; }
.system-card__role { margin-bottom: 18px; font-size: 14px; }

.admin-toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.admin-toolbar .form-control { max-width: 430px; }
.table-shell { overflow-x: auto; border: 1px solid var(--line); }
.admin-table { width: 100%; min-width: 980px; margin: 0; border-collapse: collapse; }
.admin-table th { padding: 13px 14px; color: #fff; background: var(--gob-guinda); text-align: left; }
.admin-table td { padding: 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.admin-table tr:last-child td { border-bottom: 0; }
.admin-table tr:hover td { background: #faf7f8; }
.status-badge, .access-badge { display: inline-block; margin: 2px 4px 2px 0; padding: 4px 8px; border-radius: 2px; font-size: 12px; font-weight: 700; }
.status-badge--active { color: #174b31; background: #dcefe3; }
.status-badge--inactive { color: #6e1a29; background: #f5dce1; }
.access-badge { color: #493508; background: #f1e5c5; }
.actions { display: flex; flex-wrap: wrap; gap: 7px; }
.btn-small { min-height: 34px; padding: 6px 10px; font-size: 13px; }

dialog {
    width: min(94vw, 900px);
    max-height: 92vh;
    padding: 0;
    border: 0;
    border-top: 6px solid var(--gob-guinda);
    background: #fff;
    box-shadow: 0 20px 60px rgba(0,0,0,.28);
}
dialog::backdrop { background: rgba(31,15,22,.62); }
.dialog-header { display: flex; align-items: center; justify-content: space-between; padding: 22px 26px; border-bottom: 1px solid var(--line); }
.dialog-header h2 { margin: 0; font-size: 24px; }
.dialog-close { border: 0; background: transparent; color: var(--ink); font-size: 30px; cursor: pointer; }
.dialog-body { padding: 26px; overflow-y: auto; }
.dialog-footer { display: flex; justify-content: flex-end; gap: 10px; padding: 18px 26px; border-top: 1px solid var(--line); background: var(--soft); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px 22px; }
.form-grid .form-group { margin: 0; }
.form-span-2 { grid-column: 1 / -1; }
.access-section { margin-top: 24px; padding-top: 22px; border-top: 1px solid var(--line); }
.access-section h3 { margin: 0 0 18px; font-size: 20px; }
.access-toggle { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; font-weight: 700; }
.access-toggle input { width: 19px; height: 19px; accent-color: var(--gob-guinda); }
.system-fields[hidden] { display: none; }
.help-text { margin-top: 6px; color: var(--muted); font-size: 13px; }

.institutional-footer { padding: 34px 0; color: #fff; background: var(--gob-guinda-dark); border-top: 5px solid var(--gob-gold); }
.institutional-footer p { margin: 5px 0 0; color: rgba(255,255,255,.75); }
.institutional-footer__links { display: flex; gap: 24px; }
.institutional-footer a { color: #fff; }

@media (max-width: 991px) {
    .institutional-header__label { display: none; }
    .auth-main { grid-template-columns: 1fr; background: #f2f2f2; }
    .auth-message { min-height: 380px; padding: 52px 32px; }
    .auth-message h1 { font-size: 42px; }
    .systems-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 767px) {
    .institutional-header__inner { align-items: flex-start; flex-direction: column; padding-top: 16px; padding-bottom: 16px; }
    .institutional-header__actions { width: 100%; justify-content: flex-start; flex-wrap: wrap; gap: 14px; }
    .institutional-brand__government-logo { width: 155px; height: 48px; }
    .institutional-brand__agency { font-size: 18px; }
    .service-bar__inner { padding-top: 12px; padding-bottom: 12px; }
    .auth-message { min-height: 320px; }
    .auth-message__logo { width: 190px; height: 147px; margin-bottom: 22px; }
    .auth-message h1 { font-size: 34px; }
    .auth-message p { font-size: 17px; }
    .auth-form-zone { padding: 28px 16px 44px; }
    .auth-panel { padding: 28px 22px; }
    .page-heading { align-items: flex-start; flex-direction: column; }
    .systems-grid { grid-template-columns: 1fr; }
    .form-grid { grid-template-columns: 1fr; }
    .form-span-2 { grid-column: auto; }
    .admin-toolbar { align-items: stretch; flex-direction: column; }
    .admin-toolbar .form-control { max-width: none; }
    .institutional-footer__inner { align-items: flex-start; flex-direction: column; }
}
