/* Ball Sniffer — design system base.
   Palette: Porcelain #FBFAF8 bg · White cards · Ink #211D26 · Ash #736D7B
            Guava #E0455E accent · score bands green / amber / red.
   Type:    Bricolage Grotesque (display) + Inter (UI/body). */
:root {
    --bg: #FBFAF8;
    --surface: #FFFFFF;
    --surface-2: #F4F2F6;
    --border: #E9E6EE;
    --text: #211D26;
    --muted: #736D7B;
    --accent: #E0455E;
    --accent-ink: #B22843;
    --accent-soft: #FCEDF0;
    --good: #0B8F5F;
    --good-soft: #E5F5EE;
    --mid: #D97706;
    --mid-soft: #FDF3E3;
    --danger: #D92D20;
    --danger-soft: #FDECEA;
    --radius: 16px;
    --shadow: 0 1px 2px rgba(33,29,38,.05), 0 8px 24px rgba(33,29,38,.06);
    --shadow-lg: 0 12px 48px rgba(33,29,38,.18);
    --font-display: "Bricolage Grotesque", "Inter", -apple-system, sans-serif;
    --font-body: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --topbar-h: 58px;
    --tabbar-h: 60px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { scroll-padding-top: calc(var(--topbar-h) + 12px); }
body {
    background: var(--bg);
    color: var(--text);
    font: 15px/1.55 var(--font-body);
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; }
button { font-family: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

.container { width: 100%; max-width: 1024px; margin: 0 auto; padding: 20px 16px 48px; flex: 1; }

/* Headings */
h1 { font-family: var(--font-display); font-size: 1.9rem; font-weight: 800; letter-spacing: -.02em; margin: 0 0 4px; }
h2 { font-family: var(--font-display); font-weight: 700; letter-spacing: -.01em; }
h3 { font-family: var(--font-display); font-weight: 700; font-size: 1.05rem; }
.page-sub { color: var(--muted); margin: 0 0 20px; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.page-head .page-sub { margin-bottom: 16px; }

/* ── Top bar ─────────────────────────────────────────────── */
.topbar {
    position: sticky; top: 0; z-index: 40;
    background: rgba(251,250,248,.88);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
}
.topbar__inner {
    max-width: 1024px; margin: 0 auto; padding: 0 16px;
    height: var(--topbar-h);
    display: flex; align-items: center; gap: 16px;
}
.topbar__brand {
    font-family: var(--font-display);
    font-weight: 800; font-size: 1.2rem; letter-spacing: -.02em;
    display: inline-flex; align-items: center; gap: 8px;
}
.topbar__mascot { height: 32px; width: auto; }

/* Cross-page fade (View Transitions API; no-op where unsupported) */
@view-transition { navigation: auto; }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: .16s; }
.topbar__links { margin-left: auto; display: flex; align-items: center; gap: 2px; }
.topbar__links a { padding: 8px 12px; border-radius: 999px; color: var(--muted); font-weight: 600; font-size: .92rem; transition: color .15s, background .15s; }
.topbar__links a:hover { color: var(--text); background: var(--surface-2); }
.topbar__links a.is-active { color: var(--accent-ink); background: var(--accent-soft); }
.topbar__side { display: flex; align-items: center; gap: 10px; }
.topbar__avatar {
    width: 34px; height: 34px; border-radius: 50%;
    background: var(--accent-soft); color: var(--accent-ink);
    display: inline-flex; align-items: center; justify-content: center;
    font-weight: 800; font-size: .9rem; overflow: hidden; border: 1px solid var(--border);
}
.topbar__avatar img { width: 100%; height: 100%; object-fit: cover; }
.topbar__logout { color: var(--muted); font-weight: 600; font-size: .88rem; }
.topbar__logout:hover { color: var(--text); }
.topbar__login {
    background: var(--text); color: var(--surface) !important;
    padding: 8px 16px; border-radius: 999px; font-weight: 700; font-size: .9rem;
}

/* ── Bottom tab bar (mobile) ─────────────────────────────── */
.tabbar {
    display: none;
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
    background: rgba(255,255,255,.94);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-top: 1px solid var(--border);
    padding-bottom: env(safe-area-inset-bottom, 0);
}
.tabbar__item {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 3px; height: var(--tabbar-h);
    color: var(--muted); font-size: .66rem; font-weight: 600; letter-spacing: .01em;
}
.tabbar__item svg { width: 23px; height: 23px; stroke-width: 1.8; }
.tabbar__item.is-active { color: var(--accent-ink); }
.tabbar__item.is-active svg { stroke-width: 2.3; }

@media (max-width: 720px) {
    .tabbar { display: flex; }
    .topbar__links, .topbar__logout { display: none; }
    .topbar__side { margin-left: auto; }
    body { padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px)); }
    h1 { font-size: 1.6rem; }
    .container { padding: 16px 16px 32px; }
}

/* Flash */
.flash-wrap { max-width: 1024px; margin: 14px auto 0; padding: 0 16px; width: 100%; }
.flash { padding: 12px 16px; border-radius: 12px; margin-bottom: 8px; font-weight: 600; font-size: .92rem; border: 1px solid var(--border); background: var(--surface); }
.flash--success { background: var(--good-soft); border-color: rgba(11,143,95,.25); color: #065F42; }
.flash--error   { background: var(--danger-soft); border-color: rgba(217,45,32,.25); color: #A11205; }
.flash--warning { background: var(--mid-soft); border-color: rgba(217,119,6,.25); color: #92500A; }

/* Cards + grid */
.grid { display: grid; gap: 14px; }
.grid--stats { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.grid--cards { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.stat { text-align: center; }
.stat__num { font-family: var(--font-display); font-size: 2rem; font-weight: 800; color: var(--accent); font-variant-numeric: tabular-nums; }
.stat__label { color: var(--muted); font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; }

/* Buttons + forms */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    padding: 10px 18px; border-radius: 999px;
    font-weight: 700; font-size: .92rem; cursor: pointer;
    border: 1px solid var(--border); background: var(--surface); color: var(--text);
    transition: background .15s, border-color .15s, transform .1s;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: scale(.98); }
.btn--primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn--primary:hover { background: var(--accent-ink); border-color: var(--accent-ink); }
.btn--block { width: 100%; }
.btn--sm { padding: 7px 13px; font-size: .85rem; }

.field { margin-bottom: 16px; }
.field label { display: block; font-weight: 600; margin-bottom: 6px; color: var(--text); font-size: .9rem; }
.input {
    width: 100%; padding: 11px 14px; border-radius: 12px;
    border: 1px solid var(--border); background: var(--surface); color: var(--text);
    font-size: 1rem; font-family: inherit; transition: border-color .15s, box-shadow .15s;
}
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
select.input { appearance: none; -webkit-appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 6 6.5 11 1.5' fill='none' stroke='%23736D7B' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 34px; }
.input--compact { width: auto; padding: 8px 12px; font-size: .88rem; border-radius: 999px; }
select.input--compact { padding-right: 30px; background-position: right 10px center; }
.error-text { color: var(--danger); font-size: .85rem; margin-top: 6px; }

/* Auth */
.auth { max-width: 400px; margin: 6vh auto; width: 100%; }
.auth__hint { color: var(--muted); font-size: .85rem; margin-top: 14px; text-align: center; }

/* Footer */
.footer { border-top: 1px solid var(--border); color: var(--muted); padding: 18px 0; font-size: .82rem; text-align: center; }
@media (max-width: 720px) { .footer { display: none; } }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
