/* ===== TOKEN ===== */
:root {
    --ink: #1c1a17;
    --ink-soft: #5c5750;
    --paper: #f6f3ee;
    --card: #ffffff;
    --line: #e2dcd2;
    --brass: #b08d57;
    --brass-deep: #8f6f3f;
    --error: #a3352c;
    --error-bg: #fbe9e6;
    --radius: 14px;
    --shadow: 0 10px 30px rgb(28 26 23 / .08);
    --font-ui: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
    :root {
        --ink: #efeae2;
        --ink-soft: #a7a097;
        --paper: #161412;
        --card: #211e1a;
        --line: #342f29;
        --error-bg: #3a1f1c;
        --shadow: 0 10px 30px rgb(0 0 0 / .4);
    }
}

/* ===== BASE ===== */
*, *::before, *::after { box-sizing: border-box; }

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

body {
    margin: 0;
    min-height: 100dvh;
    font-family: var(--font-ui);
    font-size: 1rem;
    line-height: 1.5;
    color: var(--ink);
    background: var(--paper);
    -webkit-font-smoothing: antialiased;
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

img { display: block; max-width: 100%; height: auto; }

/* ===== LOGIN ===== */
.auth {
    display: grid;
    place-items: center;
    padding: 1.5rem 1rem;
}

.auth__card {
    width: 100%;
    max-width: 24rem;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: clamp(1.5rem, 5vw, 2.25rem);
    animation: rise .5s cubic-bezier(.2, .8, .2, 1) both;
}

.auth__logo {
    display: grid;
    place-items: center;
    padding: .75rem 1rem;
    margin: 0 auto 1.25rem;
    border-radius: 10px;
}

/* in dark mode il PNG a inchiostro scuro va su una placca chiara */
@media (prefers-color-scheme: dark) {
    .auth__logo, .topbar__logo { background: #f6f3ee; }
    .topbar__logo { padding: .35rem .6rem; border-radius: 8px; }
}

.auth__logo img { width: min(100%, 220px); height: auto; }

.auth__title {
    margin: 0;
    font-size: 1.375rem;
    font-weight: 600;
    letter-spacing: -.01em;
    text-align: center;
}

.auth__subtitle {
    margin: .25rem 0 1.5rem;
    text-align: center;
    color: var(--brass-deep);
    font-size: .75rem;
    font-weight: 600;
    letter-spacing: .17em;
    text-transform: uppercase;
}

.auth__error {
    margin: 0 0 1rem;
    padding: .75rem .9rem;
    border-radius: 10px;
    background: var(--error-bg);
    color: var(--error);
    font-size: .9375rem;
}

.auth__form { display: grid; gap: 1rem; }

/* ===== CAMPI ===== */
.field { display: grid; gap: .4rem; }

.field__label {
    font-size: .8125rem;
    font-weight: 600;
    letter-spacing: .04em;
    color: var(--ink-soft);
}

.field__input {
    width: 100%;
    font: inherit;
    font-size: 1rem; /* ≥16px evita lo zoom automatico su iOS */
    color: var(--ink);
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: .8rem .95rem;
    min-height: 48px;
    transition: border-color .15s, box-shadow .15s;
}

.field__input:focus {
    outline: none;
    border-color: var(--brass);
    box-shadow: 0 0 0 3px rgb(176 141 87 / .25);
}

/* ===== BOTTONI ===== */
.btn {
    font: inherit;
    font-weight: 600;
    letter-spacing: .02em;
    color: #fff;
    background: var(--brass);
    border: 0;
    border-radius: 10px;
    padding: .85rem 1.25rem;
    min-height: 48px;
    cursor: pointer;
    transition: background .15s, transform .15s;
}

.btn:hover { background: var(--brass-deep); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 3px solid rgb(176 141 87 / .45); outline-offset: 2px; }

.btn--ghost {
    color: var(--ink);
    background: transparent;
    border: 1px solid var(--line);
    min-height: 40px;
    padding: .5rem .9rem;
}

.btn--ghost:hover { background: var(--card); }

/* ===== DASHBOARD (segnaposto) ===== */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: .75rem 1rem;
    background: var(--card);
    border-bottom: 1px solid var(--line);
}

.topbar__logout { display: flex; align-items: center; gap: .75rem; margin: 0; }
.topbar__user { font-size: .9375rem; color: var(--ink-soft); }

.content { padding: 1.5rem 1rem; max-width: 60rem; margin: 0 auto; }

/* ===== PREFERENZE UTENTE ===== */
@keyframes rise {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
    .auth__card { animation: none; }
    .field__input, .btn { transition: none; }
}

@media (prefers-contrast: more) {
    :root { --line: #8a8278; }
    .field__input { border-width: 2px; }
}