/* ============================================================
   Talonario Digital — sistema de diseño
   Dirección: editorial botánico / lujo suave femenino
   ============================================================ */

:root {
    --paper:       #faf3ee;
    --paper-tint:  #f3e3db;
    --surface:     #fffcfa;
    --ink:         #3b2a2e;
    --ink-soft:    #8a6f74;
    --wine:        #7c2e42;
    --wine-hi:     #8f3852;
    --wine-deep:   #5b1f30;
    --blush:       #d98ca0;
    --blush-soft:  #efd2da;
    --line:        #ecd7d1;
    --line-strong: #e0c3bb;
    --gold:        #b98a4b;
    --ring:        rgba(124, 46, 66, .18);
    --shadow-sm:   0 2px 10px -4px rgba(91, 31, 48, .18);
    --shadow-md:   0 18px 44px -20px rgba(91, 31, 48, .40);
    --shadow-lg:   0 40px 80px -32px rgba(91, 31, 48, .38);
    --radius:      16px;
    --radius-lg:   26px;
    --font-display: "Fraunces", Georgia, serif;
    --font-body:    "Mulish", -apple-system, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
    font-family: var(--font-body);
    color: var(--ink);
    background: var(--paper);
    line-height: 1.55;
    min-height: 100vh;
    position: relative;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* ---- atmósfera de fondo: brillos + grano ---- */
.bg-atmosphere {
    position: fixed;
    inset: 0;
    z-index: -2;
    background:
        radial-gradient(60% 45% at 82% -8%, rgba(217, 140, 160, .30), transparent 60%),
        radial-gradient(55% 40% at -10% 8%, rgba(185, 138, 75, .14), transparent 55%),
        radial-gradient(80% 60% at 50% 120%, rgba(124, 46, 66, .10), transparent 60%),
        var(--paper);
}
.bg-atmosphere::after {
    content: "";
    position: absolute;
    inset: 0;
    opacity: .5;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.4'/%3E%3C/svg%3E");
    mix-blend-mode: multiply;
}

/* ---- tipografía ---- */
h1, h2, h3 { font-family: var(--font-display); font-weight: 500; line-height: 1.12; color: var(--ink); letter-spacing: -.01em; }
a { color: var(--wine); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }

.eyebrow {
    font-size: .72rem;
    letter-spacing: .22em;
    text-transform: uppercase;
    color: var(--wine);
    font-weight: 700;
}
.muted { color: var(--ink-soft); }

/* ---- topbar ---- */
.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    backdrop-filter: saturate(140%) blur(10px);
    background: rgba(250, 243, 238, .78);
    border-bottom: 1px solid var(--line);
}
.topbar__in {
    max-width: 720px;
    margin: 0 auto;
    padding: 14px 22px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.wordmark {
    display: inline-flex;
    align-items: center;
    gap: 11px;
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 1.3rem;
    color: var(--wine-deep);
    letter-spacing: -.015em;
}
.wordmark:hover { text-decoration: none; }
.wordmark svg { width: 34px; height: 34px; color: var(--blush); }
.topbar__link { font-size: .86rem; color: var(--ink-soft); font-weight: 600; }

/* ---- contenedor ---- */
.shell { max-width: 620px; margin: 0 auto; padding: 34px 22px 64px; }

/* ---- botones ---- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-family: var(--font-body);
    font-weight: 700;
    font-size: .98rem;
    padding: .82rem 1.4rem;
    border-radius: 12px;
    border: 1px solid transparent;
    cursor: pointer;
    transition: transform .18s ease, box-shadow .18s ease, background .18s ease;
    text-decoration: none;
}
.btn:hover { text-decoration: none; }
.btn--wine {
    color: #fff5f2;
    background: linear-gradient(180deg, var(--wine-hi), var(--wine-deep));
    box-shadow: var(--shadow-sm);
}
.btn--wine:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.btn--wine:active { transform: translateY(0); }
.btn--ghost {
    color: var(--wine);
    background: var(--surface);
    border-color: var(--line-strong);
}
.btn--ghost:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.btn--block { width: 100%; }

/* ---- campos de formulario ---- */
.field { display: block; margin-top: 1.1rem; }
.field:first-child { margin-top: 0; }
.field > label,
.form label {
    display: block;
    font-size: .71rem;
    letter-spacing: .14em;
    text-transform: uppercase;
    font-weight: 700;
    color: var(--ink-soft);
    margin-bottom: .42rem;
}
input:not([type=checkbox]):not([type=radio]):not([type=file]):not([type=submit]),
select, textarea {
    width: 100%;
    font-family: var(--font-body);
    font-size: 1rem;
    color: var(--ink);
    background: var(--surface);
    border: 1px solid var(--line-strong);
    border-radius: 12px;
    padding: .78rem .95rem;
    transition: border-color .16s ease, box-shadow .16s ease;
}
input::placeholder, textarea::placeholder { color: #c6aaae; }
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--wine);
    box-shadow: 0 0 0 4px var(--ring);
}
input[type=file] { font-size: .9rem; color: var(--ink-soft); margin-top: .3rem; }
input[type=color] { width: 54px; height: 40px; padding: 2px; border-radius: 10px; border: 1px solid var(--line-strong); background: var(--surface); }
.form p { margin: 0; }
.form p + p { margin-top: 1.1rem; }
.form .btn { margin-top: 1.6rem; }

/* ---- modal ---- */
.modal[hidden] { display: none; }
.modal { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal__backdrop { position: absolute; inset: 0; background: rgba(59, 42, 46, .55); }
.modal__card {
    position: relative; z-index: 1; width: 100%; max-width: 420px;
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg); padding: 28px 26px 22px;
    animation: rise .32s cubic-bezier(.2, .8, .2, 1) both;
}
.modal__x { position: absolute; top: 10px; right: 14px; background: none; border: none; font-size: 1.6rem; line-height: 1; color: var(--ink-soft); cursor: pointer; }
.modal__title { font-size: 1.4rem; margin-bottom: .25rem; }
.modal__lead { color: var(--ink-soft); font-size: .92rem; margin-bottom: 1.1rem; }
.modal__summary { list-style: none; padding: 0; margin: 0 0 1.3rem; display: grid; gap: .5rem; }
.modal__summary li { display: flex; justify-content: space-between; gap: 12px; padding: .5rem .8rem; background: var(--paper); border-radius: 10px; font-size: .9rem; }
.modal__summary .k { color: var(--ink-soft); }
.modal__summary .v { font-weight: 600; text-align: right; }
.modal__actions { display: flex; gap: 10px; justify-content: flex-end; }
.modal__actions .btn { margin-top: 0; }
.modal__errors { list-style: disc; padding-left: 1.3rem; margin: 0 0 1.3rem; color: #b23a52; font-size: .9rem; display: grid; gap: .3rem; text-align: left; }
.modal__badge { width: 54px; height: 54px; border-radius: 50%; display: grid; place-items: center; font-size: 1.7rem; font-weight: 700; margin: 0 auto .8rem; }
.modal__badge--ok { background: #e7f3ea; color: #2e7d4f; }
.modal__badge--err { background: #fbeaed; color: #b23a52; }
.modal [data-state=loading], .modal [data-state=success], .modal [data-state=error] { text-align: center; }
.spinner {
    width: 44px; height: 44px; margin: 6px auto 10px;
    border: 4px solid var(--blush-soft); border-top-color: var(--wine); border-radius: 50%;
    animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- páginas de error ---- */
.errorpage { text-align: center; padding: 8vh 1rem 4vh; }
.errorpage__code {
    font-family: var(--font-display); font-weight: 600; line-height: 1;
    font-size: clamp(4.5rem, 18vw, 8rem); color: var(--blush);
    letter-spacing: -.02em;
}
.errorpage h1 { font-size: 1.7rem; margin: .4rem 0 .5rem; }
.errorpage p { color: var(--ink-soft); max-width: 34ch; margin: 0 auto 1.6rem; }

/* ---- páginas de allauth no personalizadas (2FA, sesiones, email, clave) ---- */
.auth-content main {
    max-width: 480px; margin: 40px auto;
    background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--radius-lg); box-shadow: var(--shadow-md);
    padding: 32px 32px 28px;
    animation: rise .5s cubic-bezier(.2, .8, .2, 1) both;
}
.auth-content h1 { font-size: 1.65rem; margin-bottom: .5rem; }
.auth-content h2 { font-family: var(--font-display); font-weight: 500; font-size: 1.15rem; margin: 1.6rem 0 .5rem; color: var(--wine-deep); }
.auth-content > main > *:first-child, .auth-content h1 + * { margin-top: 0; }
.auth-content p { color: var(--ink-soft); margin: .35rem 0 .7rem; font-size: .95rem; line-height: 1.55; text-align: justify; hyphens: auto; }
.auth-content .muted-note { font-size: .85rem; color: var(--ink-soft); text-align: left; }
.auth-content ul { list-style: none; padding: 0; margin: .6rem 0 1.1rem; display: grid; gap: .55rem; }
.auth-content li {
    background: var(--paper); border: 1px solid var(--line); border-radius: 11px;
    padding: .7rem .95rem; font-size: .92rem;
}
.auth-content a:not(.btn) { color: var(--wine); font-weight: 600; }
.auth-content form { margin-top: 1rem; }
.auth-content label { display: block; font-size: .72rem; letter-spacing: .12em; text-transform: uppercase; font-weight: 700; color: var(--ink-soft); margin: .9rem 0 .4rem; }
.auth-content button,
.auth-content input[type=submit],
.auth-content a.button {
    display: inline-block; font-family: var(--font-body); font-weight: 700; font-size: .95rem;
    color: #fff5f2; background: linear-gradient(180deg, var(--wine-hi), var(--wine-deep));
    border: none; border-radius: 12px; padding: .7rem 1.3rem; cursor: pointer;
    margin-top: 1rem; text-decoration: none; transition: transform .18s ease, box-shadow .18s ease;
}
.auth-content button:hover,
.auth-content input[type=submit]:hover,
.auth-content a.button:hover { text-decoration: none; transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.auth-content .btn { color: #fff5f2; }
/* Código QR del 2FA: centrado y enmarcado */
.auth-content img {
    display: block; margin: 1.3rem auto; max-width: 200px; width: 100%;
    background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 10px;
}
/* Secreto del autenticador y códigos: monoespaciado y legible */
.auth-content input[readonly],
.auth-content code, .auth-content pre {
    font-family: ui-monospace, "SF Mono", Menlo, monospace; letter-spacing: .02em;
}
.auth-content pre {
    background: var(--paper); border: 1px solid var(--line); border-radius: 10px;
    padding: .8rem 1rem; overflow-x: auto; font-size: .9rem;
}

/* ---- timbre ---- */
.panel-title { font-family: var(--font-display); font-size: 1.15rem; font-weight: 500; margin-bottom: .8rem; }
.stamp-preview {
    display: flex; justify-content: center;
    background: #fffdfb; border: 1px solid var(--line); border-radius: 12px;
    padding: 14px; margin-bottom: .9rem;
}
.stamp-preview img { max-height: 90px; max-width: 100%; }
.color-choice { display: flex; gap: 18px; margin-bottom: 1rem; }
.color-choice label { display: flex; align-items: center; gap: 7px; font-weight: 600; font-size: .92rem; }
.color-choice input { width: auto; accent-color: var(--wine); }

/* ---- signature pad ---- */
.sig-current { display: flex; align-items: center; gap: 12px; margin-bottom: .7rem; }
.sig-current img { height: 46px; background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 4px; }
.sig-current .muted { font-size: .82rem; }
.sigpad { position: relative; border: 1.5px dashed var(--line-strong); border-radius: 14px; background: var(--surface); overflow: hidden; }
.sigpad canvas { display: block; width: 100%; height: 240px; touch-action: none; cursor: crosshair; }
.sigpad__hint {
    position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%);
    font-size: .78rem; color: #cbb0b4; pointer-events: none; letter-spacing: .02em;
}
.field__error, .errorlist, .form .errorlist {
    list-style: none;
    color: #b23a52;
    font-size: .84rem;
    margin-top: .4rem;
    font-weight: 600;
}

/* ---- panel / tarjeta ---- */
.panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 22px;
}

/* ---- encabezado de página ---- */
.page-head { margin-bottom: 26px; }
.page-head h1 { font-size: 2rem; margin-top: .2rem; }
.page-head p { color: var(--ink-soft); margin-top: .35rem; }

/* ---- alertas ---- */
.alert {
    border-radius: 12px;
    padding: .85rem 1rem;
    font-size: .9rem;
    margin-bottom: 1rem;
    border: 1px solid;
}
.alert--error { background: #fbeaed; border-color: #eec2ca; color: #8f2338; }
.alert--info  { background: #fff7ec; border-color: #f0dcb8; color: #8a6417; }
.alert ul { margin: .3rem 0 0 1.1rem; }

/* ---- AUTH ---- */
.auth-page { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; min-height: 100vh; padding: 28px 20px; }
.auth-card {
    width: 100%;
    max-width: 428px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    animation: rise .7s cubic-bezier(.2, .8, .2, 1) both;
}
.auth-card__crown {
    position: relative;
    padding: 30px 34px 22px;
    background:
        radial-gradient(120% 120% at 100% 0%, rgba(217, 140, 160, .38), transparent 62%),
        linear-gradient(180deg, var(--paper-tint), var(--surface));
    border-bottom: 1px solid var(--line);
    overflow: hidden;
}
.auth-card__crown .sprig {
    position: absolute;
    top: -14px; right: -10px;
    width: 130px; height: 130px;
    color: var(--blush);
    opacity: .55;
}
.auth-card__crown h1 { font-size: 1.9rem; margin-top: .5rem; }
.auth-card__crown p { color: var(--ink-soft); font-size: .92rem; margin-top: .3rem; max-width: 30ch; }
.auth-card__body { padding: 26px 34px 30px; }
.auth-card__body .btn { margin-top: 1.5rem; }
.auth-alt { text-align: center; margin-top: 1.25rem; font-size: .9rem; color: var(--ink-soft); }
.check-inline {
    display: flex; align-items: center; gap: 9px; margin-top: 1.1rem;
    font-size: .92rem; font-weight: 600; color: var(--ink);
    text-transform: none; letter-spacing: 0; cursor: pointer;
}
.check-inline input { width: auto; margin: 0; accent-color: var(--wine); width: 17px; height: 17px; }

/* stagger de campos al cargar */
.auth-card__body .field,
.auth-card__body .btn,
.auth-card__body .auth-alt { animation: rise .6s cubic-bezier(.2, .8, .2, 1) both; }
.auth-card__body > *:nth-child(1) { animation-delay: .06s; }
.auth-card__body > *:nth-child(2) { animation-delay: .12s; }
.auth-card__body > *:nth-child(3) { animation-delay: .18s; }
.auth-card__body > *:nth-child(4) { animation-delay: .24s; }
.auth-card__body > *:nth-child(5) { animation-delay: .30s; }

/* ---- DASHBOARD ---- */
.greeting { margin-bottom: 28px; }
.greeting .eyebrow { display: block; margin-bottom: .5rem; }
.greeting h1 { font-size: 2.15rem; }
.greeting h1 em { font-style: italic; color: var(--wine); }

.tiles { display: grid; gap: 14px; }
.tile {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 18px 20px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
    animation: rise .6s cubic-bezier(.2, .8, .2, 1) both;
}
.tile:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); border-color: var(--line-strong); text-decoration: none; }
.tile__icon {
    flex: 0 0 auto;
    width: 46px; height: 46px;
    display: grid; place-items: center;
    border-radius: 13px;
    background: var(--blush-soft);
    color: var(--wine);
}
.tile__icon svg { width: 22px; height: 22px; }
.tile__text h3 { font-size: 1.12rem; font-weight: 600; }
.tile__text p { font-size: .86rem; color: var(--ink-soft); }
.tile__arrow { margin-left: auto; color: var(--line-strong); transition: transform .18s ease, color .18s; }
.tile:hover .tile__arrow { transform: translateX(4px); color: var(--wine); }

.tile--primary {
    background: linear-gradient(155deg, var(--wine-hi), var(--wine-deep));
    border-color: transparent;
    box-shadow: var(--shadow-md);
}
.tile--primary .tile__text h3,
.tile--primary .tile__text p { color: #fdeef0; }
.tile--primary .tile__text p { opacity: .82; }
.tile--primary .tile__icon { background: rgba(255, 255, 255, .16); color: #fff; }
.tile--primary .tile__arrow { color: rgba(255, 255, 255, .6); }
.tile--primary:hover .tile__arrow { color: #fff; }

.tiles .tile:nth-child(1) { animation-delay: .05s; }
.tiles .tile:nth-child(2) { animation-delay: .11s; }
.tiles .tile:nth-child(3) { animation-delay: .17s; }
.tiles .tile:nth-child(4) { animation-delay: .23s; }

/* ---- catálogo ---- */
.inline-form { display: flex; gap: 10px; margin-bottom: 20px; }
.inline-form input { flex: 1; }
.exam-list { list-style: none; display: grid; gap: 9px; }
.exam-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: .8rem 1rem;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 12px;
}
.exam-row span { font-weight: 600; }
.link-danger { background: none; border: none; color: #b23a52; font-weight: 700; font-size: .82rem; cursor: pointer; padding: 0; }
.link-danger:hover { text-decoration: underline; }
.empty { color: var(--ink-soft); font-style: italic; }

/* ---- fieldset de exámenes en la orden ---- */
.exam-picker { border: 1px solid var(--line); background: var(--surface); border-radius: var(--radius); padding: 16px 18px; }
.exam-picker legend { font-family: var(--font-display); font-size: 1.05rem; padding: 0 6px; }
.check {
    display: flex; align-items: center; gap: 10px;
    padding: .55rem 0; font-weight: 500; line-height: 1.3; cursor: pointer;
    border-bottom: 1px dashed var(--line);
}
.check:last-of-type { border-bottom: none; }
.check input[type=checkbox] {
    width: 18px; height: 18px; margin: 0; flex: 0 0 auto;
    accent-color: var(--wine);
}
.add-exam { margin-top: .8rem; background: none; border: none; color: var(--wine); font-weight: 700; font-size: .88rem; cursor: pointer; padding: 0; }
.add-exam:hover { text-decoration: underline; }
.extra-exams { display: grid; gap: 9px; margin-top: .6rem; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 1.1rem; align-items: start; }
.grid-2 .field { margin-top: 0; }

/* ---- animación ---- */
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; } }

@media (max-width: 480px) {
    .greeting h1 { font-size: 1.8rem; }
    .page-head h1 { font-size: 1.7rem; }
    .grid-2 { grid-template-columns: 1fr; }
}
