/* ==========================================================================
   Auth System - stylesheet
   Plain CSS, no framework. Mobile-first, works down to 320px.
   ========================================================================== */

:root {
    --bg:          #eef2f8;
    --bg-grad-a:   #6366f1;
    --bg-grad-b:   #8b5cf6;
    --surface:     #ffffff;
    --surface-2:   #f7f8fb;
    --border:      #e2e6ef;
    --text:        #14181f;
    --text-muted:  #6b7280;
    --primary:     #4f46e5;
    --primary-dk:  #4338ca;
    --danger:      #dc2626;
    --danger-bg:   #fef2f2;
    --success:     #059669;
    --success-bg:  #ecfdf5;
    --warn:        #d97706;
    --radius:      14px;
    --shadow:      0 10px 40px rgba(20, 24, 31, .10);
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg:         #0e1117;
        --surface:    #171b23;
        --surface-2:  #1e232d;
        --border:     #2b313d;
        --text:       #e7eaf0;
        --text-muted: #9aa3b2;
        --danger-bg:  #2a1618;
        --success-bg: #0f2620;
        --shadow:     0 10px 40px rgba(0, 0, 0, .45);
    }
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    font-size: 16px;
    line-height: 1.55;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}

/* --- Auth pages: centred card on a gradient ------------------------------ */

body.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px 16px;
    background: linear-gradient(135deg, var(--bg-grad-a), var(--bg-grad-b));
}

.card {
    width: 100%;
    max-width: 420px;
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 32px 28px;
}

.card__head { margin-bottom: 22px; }

.card__head h1 {
    margin: 0 0 6px;
    font-size: 1.5rem;
    letter-spacing: -.02em;
}

.card__foot {
    margin: 22px 0 0;
    padding-top: 18px;
    border-top: 1px solid var(--border);
    text-align: center;
    font-size: .9rem;
    color: var(--text-muted);
}

.muted { margin: 0; color: var(--text-muted); font-size: .92rem; }

a { color: var(--primary); text-decoration: none; font-weight: 600; }
a:hover { text-decoration: underline; }

/* --- Form fields --------------------------------------------------------- */

.field { margin-bottom: 18px; }

.field__row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 8px;
}

label {
    display: block;
    margin-bottom: 6px;
    font-size: .875rem;
    font-weight: 600;
}

input[type="text"],
input[type="email"],
input[type="password"] {
    width: 100%;
    padding: 11px 13px;
    font: inherit;
    color: var(--text);
    background: var(--surface-2);
    border: 1.5px solid var(--border);
    border-radius: 10px;
    transition: border-color .15s, box-shadow .15s;
}

input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, .16);
}

.field.has-error input {
    border-color: var(--danger);
    background: var(--danger-bg);
}

.input-group { position: relative; display: flex; }
.input-group input { padding-right: 62px; }

.toggle {
    position: absolute;
    top: 50%;
    right: 8px;
    transform: translateY(-50%);
    padding: 5px 9px;
    font: inherit;
    font-size: .78rem;
    font-weight: 600;
    color: var(--text-muted);
    background: transparent;
    border: 0;
    border-radius: 7px;
    cursor: pointer;
}
.toggle:hover { color: var(--primary); background: var(--border); }

small.error {
    display: block;
    min-height: 1.1em;
    margin-top: 5px;
    font-size: .8rem;
    color: var(--danger);
}

/* Password strength meter */
.meter {
    height: 4px;
    margin-top: 8px;
    background: var(--border);
    border-radius: 99px;
    overflow: hidden;
}
.meter__bar {
    display: block;
    height: 100%;
    width: 0;
    border-radius: 99px;
    background: var(--danger);
    transition: width .25s, background .25s;
}
.meter__bar[data-level="2"] { background: var(--warn); }
.meter__bar[data-level="3"] { background: var(--success); }

/* --- Buttons ------------------------------------------------------------- */

.btn {
    display: inline-block;
    width: 100%;
    padding: 12px 18px;
    font: inherit;
    font-weight: 600;
    border: 0;
    border-radius: 10px;
    cursor: pointer;
    transition: background .15s, transform .08s;
}
.btn:active { transform: translateY(1px); }

.btn--primary { color: #fff; background: var(--primary); }
.btn--primary:hover { background: var(--primary-dk); }

.btn--ghost {
    width: auto;
    padding: 8px 14px;
    font-size: .875rem;
    color: var(--text);
    background: var(--surface-2);
    border: 1px solid var(--border);
}
.btn--ghost:hover { background: var(--border); }

.inline { display: inline; margin: 0; }
.link-sm { font-size: .8rem; font-weight: 600; }

/* --- Alerts, toasts, demo box -------------------------------------------- */

.alert {
    margin: 0 0 18px;
    padding: 11px 14px;
    font-size: .875rem;
    border-radius: 10px;
    border: 1px solid transparent;
}
.alert--error   { color: var(--danger);  background: var(--danger-bg);  border-color: var(--danger); }
.alert--success { color: var(--success); background: var(--success-bg); border-color: var(--success); }

.toast {
    position: fixed;
    top: 18px;
    left: 50%;
    z-index: 50;
    transform: translateX(-50%);
    max-width: calc(100vw - 32px);
    padding: 11px 18px;
    font-size: .875rem;
    font-weight: 600;
    color: #fff;
    border-radius: 10px;
    box-shadow: var(--shadow);
    animation: toast-in .3s ease, toast-out .4s ease 4s forwards;
}
.toast--success { background: var(--success); }
.toast--error   { background: var(--danger); }

@keyframes toast-in  { from { opacity: 0; transform: translate(-50%, -14px); } }
@keyframes toast-out { to   { opacity: 0; transform: translate(-50%, -14px); visibility: hidden; } }

.demo-box {
    padding: 14px;
    font-size: .85rem;
    background: var(--surface-2);
    border: 1px dashed var(--border);
    border-radius: 10px;
}
.demo-box p { margin: 6px 0; color: var(--text-muted); }
.demo-box__link { word-break: break-all; font-size: .8rem; font-weight: 500; }

/* --- Dashboard ----------------------------------------------------------- */

body.app-page { background: var(--bg); }

.shell { min-height: 100vh; }

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 20px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.brand { font-weight: 700; letter-spacing: -.01em; }

.topbar__right { display: flex; align-items: center; gap: 12px; }

.avatar {
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    font-size: .95rem;
    font-weight: 700;
    color: #fff;
    background: linear-gradient(135deg, var(--bg-grad-a), var(--bg-grad-b));
    border-radius: 50%;
}

.dash {
    max-width: 880px;
    margin: 0 auto;
    padding: 36px 20px 60px;
}

.dash__title {
    margin: 0 0 4px;
    font-size: 1.85rem;
    letter-spacing: -.02em;
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 14px;
    margin: 28px 0;
}

.tile {
    padding: 16px 18px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
}

.tile__label {
    display: block;
    font-size: .75rem;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.tile__value {
    display: block;
    margin-top: 5px;
    font-size: 1.02rem;
    font-weight: 600;
    word-break: break-word;
}

.note {
    padding: 20px 22px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
}
.note h2 { margin: 0 0 10px; font-size: 1.05rem; }
.note ol { margin: 0; padding-left: 20px; color: var(--text-muted); font-size: .9rem; }
.note li { margin-bottom: 6px; }

code {
    padding: 1px 5px;
    font-size: .85em;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 5px;
}

/* --- Small screens ------------------------------------------------------- */

@media (max-width: 480px) {
    .card { padding: 26px 20px; }
    .card__head h1 { font-size: 1.32rem; }
    .dash { padding: 26px 16px 48px; }
    .dash__title { font-size: 1.45rem; }
    .grid { grid-template-columns: 1fr; }
}
