:root {
    --talca-red: #ff1738;
    --talca-red-dark: #c91531;
    --talca-red-deep: #9f0c25;
    --talca-red-soft: #fff1f3;
    --ink: #17191d;
    --muted: #69707a;
    --line: #dfe3e8;
    --surface: #ffffff;
    --background: #f7f7f8;
    --shadow: 0 24px 70px rgba(88, 13, 28, .13);
}

* { box-sizing: border-box; }

html { min-width: 320px; background: var(--background); }

body {
    margin: 0;
    min-height: 100vh;
    color: var(--ink);
    background: var(--background);
    font-family: "Segoe UI Variable", "Segoe UI", Arial, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

button,
input { font: inherit; }

.page {
    min-height: 100vh;
    display: grid;
    grid-template-columns: minmax(340px, 44%) minmax(0, 1fr);
}

.brand-panel {
    position: relative;
    overflow: hidden;
    display: flex;
    min-height: 100vh;
    padding: clamp(40px, 6vw, 88px);
    color: #ffffff;
    background:
        radial-gradient(circle at 12% 0, rgba(255,255,255,.16), transparent 27%),
        linear-gradient(145deg, #ff2847 0%, var(--talca-red) 38%, var(--talca-red-dark) 100%);
}

.brand-panel::before,
.brand-panel::after {
    content: "";
    position: absolute;
    pointer-events: none;
}

.brand-panel::before {
    inset: 0;
    opacity: .22;
    background-image:
        linear-gradient(rgba(255,255,255,.28) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,.28) 1px, transparent 1px);
    background-size: 64px 64px;
    mask-image: linear-gradient(to bottom right, transparent 4%, #000 78%);
}

.brand-panel::after {
    width: 390px;
    height: 390px;
    right: -205px;
    bottom: -205px;
    border: 76px solid rgba(255,255,255,.14);
    border-radius: 50%;
}

.brand-content {
    position: relative;
    z-index: 1;
    width: min(100%, 540px);
    display: flex;
    flex-direction: column;
}

.municipal-logo {
    display: block;
    width: min(380px, 88%);
    height: auto;
    margin: -16px 0 0 -8px;
    object-fit: contain;
}

.brand-copy { margin-top: clamp(24px, 4vh, 42px); }

.eyebrow {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 0 0 18px;
    font-size: .78rem;
    font-weight: 750;
    letter-spacing: .16em;
    text-transform: uppercase;
    color: #ffffff;
}

.eyebrow::before {
    content: "";
    width: 34px;
    height: 2px;
    background: currentColor;
}

.brand-copy h1 {
    max-width: 570px;
    margin: 0;
    font-size: clamp(2.15rem, 4vw, 4.6rem);
    font-weight: 760;
    line-height: .98;
    letter-spacing: -.055em;
    text-wrap: balance;
    color: #ffffff;
}

.brand-copy p {
    max-width: 480px;
    margin: 26px 0 0;
    color: rgba(255,255,255,.88);
    font-size: 1rem;
}

.brand-footer {
    margin-top: auto;
    padding-top: 54px;
    color: rgba(255,255,255,.76);
    font-size: .82rem;
}

.login-panel {
    display: grid;
    place-items: center;
    min-height: 100vh;
    padding: clamp(30px, 7vw, 96px);
    background:
        radial-gradient(circle at 88% 8%, rgba(255,23,56,.09), transparent 26%),
        radial-gradient(circle at 6% 94%, rgba(255,23,56,.045), transparent 28%),
        #ffffff;
}

.login-shell { width: min(100%, 450px); }

.mobile-logo { display: none; }

.system-label {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    margin-bottom: 34px;
    color: var(--talca-red-dark);
    font-size: .78rem;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.system-label::before {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--talca-red);
    box-shadow: 0 0 0 5px rgba(255,23,56,.11);
}

.login-card {
    padding: clamp(30px, 4vw, 46px);
    border: 1px solid rgba(223,227,232,.9);
    border-radius: 18px;
    background: rgba(255,255,255,.96);
    box-shadow: var(--shadow);
}

.login-card h2 {
    margin: 0;
    font-size: clamp(1.8rem, 3vw, 2.35rem);
    line-height: 1.12;
    letter-spacing: -.035em;
}

.intro {
    margin: 13px 0 30px;
    color: var(--muted);
}

.field { margin-bottom: 20px; }

.field label {
    display: block;
    margin-bottom: 8px;
    color: #30343a;
    font-size: .9rem;
    font-weight: 670;
}

.input-wrap { position: relative; }

.input-icon {
    position: absolute;
    top: 50%;
    left: 15px;
    width: 20px;
    height: 20px;
    color: #818894;
    transform: translateY(-50%);
    pointer-events: none;
}

.field input {
    width: 100%;
    min-height: 52px;
    padding: 12px 50px 12px 46px;
    border: 1px solid #cfd4db;
    border-radius: 10px;
    outline: none;
    color: var(--ink);
    background: var(--surface);
    transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}

.field input::placeholder { color: #99a0aa; }

.field input:hover { border-color: #aab1bb; }

.field input:focus {
    border-color: var(--talca-red);
    box-shadow: 0 0 0 4px rgba(244,30,60,.12);
}

.password-toggle {
    position: absolute;
    top: 50%;
    right: 9px;
    min-width: 38px;
    min-height: 36px;
    padding: 6px;
    border: 0;
    border-radius: 7px;
    color: #69707a;
    background: transparent;
    cursor: pointer;
    transform: translateY(-50%);
}

.password-toggle:hover { color: var(--talca-red); background: var(--talca-red-soft); }
.password-toggle:focus-visible { outline: 3px solid rgba(244,30,60,.25); }

.password-toggle svg { display: block; width: 22px; height: 22px; margin: auto; }

.alert {
    display: flex;
    gap: 11px;
    margin-bottom: 20px;
    padding: 13px 14px;
    border: 1px solid #f4b9c2;
    border-radius: 9px;
    color: #861327;
    background: var(--talca-red-soft);
    font-size: .88rem;
}

.alert svg { flex: 0 0 auto; width: 20px; height: 20px; margin-top: 1px; }

.submit-button,
.logout-button {
    width: 100%;
    min-height: 52px;
    border: 0;
    border-radius: 10px;
    color: #fff;
    background: var(--talca-red);
    box-shadow: 0 10px 22px rgba(244,30,60,.22);
    font-weight: 730;
    cursor: pointer;
    transition: transform .18s ease, background .18s ease, box-shadow .18s ease;
}

.submit-button:hover,
.logout-button:hover {
    background: var(--talca-red-dark);
    box-shadow: 0 12px 26px rgba(201,21,49,.25);
    transform: translateY(-1px);
}

.submit-button:active,
.logout-button:active { transform: translateY(0); }

.submit-button:focus-visible,
.logout-button:focus-visible { outline: 3px solid rgba(244,30,60,.28); outline-offset: 3px; }

.support-note {
    margin: 24px 0 0;
    color: var(--muted);
    font-size: .82rem;
    line-height: 1.45;
    text-align: center;
}

.support-note span,
.support-note strong { display: block; }

.support-note strong { margin-top: 2px; color: #454b54; font-weight: 680; }

.security-note {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin: 20px 0 0;
    padding-top: 0;
    border-top: 0;
    color: var(--muted);
    font-size: .78rem;
}

.security-note svg { flex: 0 0 auto; width: 17px; height: 17px; margin-top: 1px; color: var(--talca-red); }

.authenticated-icon {
    display: grid;
    place-items: center;
    width: 58px;
    height: 58px;
    margin-bottom: 24px;
    border-radius: 16px;
    color: #fff;
    background: var(--talca-red);
    box-shadow: 0 12px 28px rgba(244,30,60,.24);
}

.authenticated-icon svg { width: 29px; height: 29px; }
.account-name { margin: 0 0 26px; color: var(--muted); word-break: break-word; }

.honeypot {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
}

.legal {
    margin: 26px 0 0;
    color: #848b95;
    font-size: .76rem;
    text-align: center;
}

@media (max-width: 860px) {
    .page { grid-template-columns: 1fr; }
    .brand-panel { min-height: auto; padding: 30px 28px 38px; }
    .brand-content { width: 100%; }
    .municipal-logo { width: 180px; margin: -28px 0 -22px -20px; }
    .brand-copy { margin-top: 14px; }
    .brand-copy h1 { max-width: 620px; font-size: clamp(2rem, 8vw, 3.1rem); }
    .brand-copy p { margin-top: 16px; }
    .brand-footer { display: none; }
    .login-panel { min-height: auto; padding: 44px 20px 54px; place-items: start center; }
    .system-label { margin-bottom: 20px; }
}

@media (max-width: 640px) {
    .brand-panel { display: none; }
    .login-panel {
        min-height: 100vh;
        min-height: 100svh;
        padding: clamp(20px, 6vw, 32px);
        place-items: center;
    }
    .login-shell { width: min(100%, 450px); }
    .mobile-logo {
        display: block;
        width: min(58vw, 210px);
        height: auto;
        margin: 0 auto 22px;
    }
}

@media (max-width: 480px) {
    .login-panel { padding-inline: 14px; }
    .login-card { padding: 27px 22px; border-radius: 14px; }
    .mobile-logo { width: min(62vw, 190px); margin-bottom: 18px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
