:root {
    --ink: #111111;
    --muted: #5a5a5a;
    --paper: #ffffff;
    --line: #1d1d1d;
    --screen: #eef1f3;
}

* {
    box-sizing: border-box;
}

body {
    min-width: 320px;
    margin: 0;
    color: var(--ink);
    background: var(--screen);
    font-family: Arial, Helvetica, sans-serif;
}

body.demo-fade-out {
    animation: demo-fade-out .8s ease forwards;
}

@keyframes demo-fade-out {
    to {
        opacity: 0;
        transform: scale(.985);
    }
}

@media (prefers-reduced-motion: reduce) {
    body.demo-fade-out {
        animation-duration: 1ms;
    }
}

.access-page {
    display: grid;
    min-height: 100vh;
    place-items: center;
    padding: 24px;
}

.access-card {
    width: min(100%, 380px);
    padding: 32px;
    border: 1px solid #d4dadd;
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 8px 24px rgba(23, 33, 39, .12);
}

.access-card h1 {
    margin: 0 0 8px;
    font-size: 1.6rem;
}

.access-card p {
    color: var(--muted);
    font-size: .9rem;
}

.access-card label {
    display: block;
    margin: 18px 0 6px;
    font-weight: 700;
}

.access-card input {
    width: 100%;
    min-height: 42px;
    padding: 8px 10px;
    border: 1px solid #aeb8bd;
    border-radius: 4px;
    font: inherit;
}

.access-card form > button {
    width: 100%;
    min-height: 42px;
    margin-top: 22px;
    border: 0;
    border-radius: 4px;
    color: #fff;
    background: #176b4d;
    font: inherit;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
}

.access-error {
    padding: 10px;
    color: #8b1e1e !important;
    background: #fff0f0;
}

.site-header {
    position: sticky;
    top: 0;
    z-index: 10;
    padding: 8px 0;
    background: rgba(255, 255, 255, .96);
    border-bottom: 1px solid #d4dadd;
}

.site-nav {
    display: flex;
    width: min(1100px, calc(100% - 32px));
    margin: 0 auto;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
}

.site-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #1d2c35;
    font-weight: 700;
    text-decoration: none;
    white-space: nowrap;
}

.site-logo img { width: 48px; height: 48px; object-fit: contain; }
.site-nav ul { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 14px; margin: 0; padding: 0; list-style: none; }
.site-nav a:not(.site-logo) { color: #1d2c35; font-size: .84rem; font-weight: 600; text-decoration: none; }
.site-nav a:not(.site-logo):hover { color: #1667c7; }

.admin-page {
    width: min(900px, calc(100% - 32px));
    margin: 0 auto;
    padding: 32px 0;
}

.admin-header,
.user-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.admin-header h1,
.admin-card h2 {
    margin: 0;
}

.eyebrow {
    margin: 0 0 6px;
    color: #52636c;
    font-size: .78rem;
    font-weight: 700;
    letter-spacing: .12em;
    text-transform: uppercase;
}

.admin-header button,
.admin-form button,
.user-row button {
    min-height: 42px;
    padding: 8px 12px;
    border: 0;
    border-radius: 4px;
    color: #fff;
    background: #176b4d;
    font: inherit;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
}

.admin-header form button { background: #59655f; }

.admin-card {
    margin-top: 24px;
    padding: 24px;
    border: 1px solid #d4dadd;
    border-radius: 8px;
    background: #fff;
}

.admin-form {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px 14px;
    align-items: end;
    margin-top: 18px;
}

.form-field {
    display: flex;
    min-width: 0;
    flex-direction: column;
    gap: 6px;
}

.form-field label {
    font-weight: 700;
}

.admin-form input,
.admin-form select {
    min-height: 40px;
    padding: 8px;
    border: 1px solid #aeb8bd;
    border-radius: 4px;
    font: inherit;
}

.password-field {
    display: flex;
    align-items: stretch;
}

.password-field input {
    flex: 1;
    min-width: 0;
}

.toggle-password {
    width: 42px;
    min-width: 42px;
    padding: 6px 10px;
    border: 1px solid #176b4d;
    border-left: 0;
    border-radius: 0 4px 4px 0;
    color: #176b4d;
    background: #e9f3ee;
    font-size: 1rem;
    cursor: pointer;
}

.admin-form .toggle-password,
.password-form .toggle-password {
    flex: 0 0 42px;
    width: 42px !important;
    min-width: 42px !important;
    max-width: 42px;
    margin: 0;
    justify-self: auto;
}

.admin-form button {
    grid-column: 1 / -1;
    justify-self: start;
    min-width: 150px;
}

.admin-message {
    padding: 12px;
    color: #155b3b;
    background: #e9f6ee;
}

.credentials-card {
    margin-top: 24px;
    padding: 20px 24px;
    border: 1px solid #d6a400;
    border-radius: 8px;
    background: #fff8df;
}

.credentials-card h2 {
    margin: 0 0 8px;
}

.credentials-card p {
    margin: 8px 0;
}

.credentials-card code {
    padding: 3px 6px;
    border-radius: 3px;
    background: #fff;
    font-size: 1rem;
}

.credential-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 14px;
}

.credential-actions button,
.credential-actions a {
    display: inline-flex;
    min-height: 42px;
    align-items: center;
    padding: 8px 12px;
    border: 0;
    border-radius: 4px;
    color: #fff;
    background: #176b4d;
    font: inherit;
    font-size: 1rem;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
}

.credential-actions a {
    background: #176b4d;
}

.user-list {
    margin-top: 14px;
}

.user-row {
    padding: 14px 0;
    border-top: 1px solid #e1e6e8;
}

.user-row span {
    display: block;
    margin-top: 4px;
    color: var(--muted);
    font-size: .85rem;
}

.user-row .danger {
    background: #a62c2c;
}

.user-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-end;
}

.password-form {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.password-form input {
    min-width: 150px;
    min-height: 40px;
    padding: 8px;
    border: 1px solid #aeb8bd;
    border-radius: 4px;
    font: inherit;
}

.password-form .password-field {
    display: flex;
}

.limit-form {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
}

.limit-form label {
    font-size: .8rem;
    font-weight: 700;
}

.limit-form input {
    width: 64px;
    height: 40px !important;
    min-height: 40px !important;
    box-sizing: border-box;
    padding: 8px;
    border: 1px solid #aeb8bd;
    border-radius: 4px;
    font: inherit;
}

.user-row .delete {
    background: #a62c2c;
}

.page-shell {
    position: relative;
    width: min(100%, 960px);
    margin: 0 auto;
    padding: 24px;
}

.toolbar {
    display: flex;
    position: absolute;
    top: 38px;
    right: max(42px, calc((100% - 760px) / 2 + 18px));
    z-index: 2;
    justify-content: flex-end;
    gap: 10px;
    margin: 0;
}

.toolbar form {
    margin: 0;
}

.toolbar a,
.toolbar button {
    min-height: 42px;
    padding: 8px 12px;
    border: 0;
    border-radius: 4px;
    color: #ffffff;
    background: #176b4d;
    font: inherit;
    font-size: 1rem;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
}

.toolbar button:hover,
.toolbar a:hover {
    background: #10563d;
}

.toolbar form button { background: #59655f; }
.toolbar form button:hover { background: #47534f; }

.access-card form > button,
.admin-header button:not(.toggle-password),
.admin-form button:not(.toggle-password),
.user-row button:not(.toggle-password),
.credential-actions button,
.credential-actions a,
.toolbar button,
.toolbar a {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-size: .76rem;
    font-weight: 400;
    line-height: 1.15;
}

.toolbar button:disabled {
    cursor: wait;
    opacity: .6;
}

.notice {
    position: relative;
    container-type: inline-size;
    width: min(100%, 760px);
    aspect-ratio: 595.5 / 842.25;
    margin: 0 auto;
    background: var(--paper) url('sundee-template.png') center / 100% 100% no-repeat;
    box-shadow: 0 7px 25px rgba(23, 33, 39, .14);
}

body.demo-mode .notice::before {
    position: absolute;
    z-index: 1;
    top: 42.1%;
    left: 6.2%;
    width: 33.4%;
    aspect-ratio: 1;
    border-radius: 3px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    color: #102a43;
    background: #ffffff;
    content: "QR - QR - QR - QR - QR - QR\AQR - QR - QR - QR - QR - QR\AQR - QR - QR - QR - QR - QR\AQR - QR - QR - QR - QR - QR\AQR - QR - QR - QR - QR - QR\AQR - QR - QR - QR - QR - QR\AQR - QR - QR - QR - QR - QR\AQR - QR - QR - QR - QR - QR";
    font-size: clamp(.45rem, 2.1cqw, 1rem);
    font-weight: 800;
    line-height: 4cqw;
    text-align: center;
    white-space: pre;
    pointer-events: none;
}

body.demo-mode .notice::after {
    position: absolute;
    z-index: 2;
    top: 31.5%;
    left: 50%;
    max-width: 90%;
    color: #050505;
    content: "Muestra Demo\A No Oficial";
    font-size: clamp(1.45rem, 6.5cqw, 3rem);
    font-weight: 800;
    line-height: .98;
    text-align: center;
    white-space: pre;
    text-shadow: 0 1px 1px rgba(255, 255, 255, .28);
    transform: translate(-50%, -50%);
    pointer-events: none;
}

.dynamic-value {
    position: absolute;
    left: calc(68% + 75px);
    width: 26%;
    max-width: 26%;
    overflow: hidden;
    transform: translateX(-50%);
    color: #000;
    font-size: clamp(.65rem, 3cqw, 2.35rem);
    font-weight: 700;
    line-height: 1.1;
    white-space: nowrap;
    text-overflow: clip;
    text-align: center;
}

.dynamic-usd { top: 45.2%; }
.dynamic-eur { top: 53.6%; }
.dynamic-date { top: 62%; }

.status {
    position: absolute;
    right: 5%;
    bottom: 2.5%;
    left: 5%;
    min-height: 1.2em;
    margin: 0;
    color: var(--muted);
    font-size: .7rem;
    text-align: center;
}

@media (max-width: 620px) {
    .site-nav { align-items: flex-start; flex-direction: column; gap: 8px; }
    .site-nav ul { justify-content: flex-start; gap: 10px 14px; }
    .page-shell {
        padding: 12px;
    }

    .toolbar {
        top: 22px;
        right: 22px;
        flex-wrap: wrap;
    }

    .dynamic-value {
        left: 68%;
        width: 28%;
        max-width: 28%;
        font-size: clamp(.6rem, 3cqw, 1rem);
    }

    .admin-form {
        grid-template-columns: 1fr;
    }

    .user-row {
        align-items: flex-start;
        flex-direction: column;
    }

    .user-actions {
        justify-content: flex-start;
    }
}

@media print {
    @page {
        size: A4 portrait;
        margin: 0;
    }

    body {
        background: #ffffff;
    }

    body.demo-mode {
        display: none !important;
    }

    .page-shell {
        width: 100%;
        padding: 0;
    }

    .toolbar,
    .status {
        display: none;
    }

    .notice {
        width: 100%;
        box-shadow: none;
    }
}