/* Receipt Book — shared tokens, base, buttons, nav, theme toggle, toast */

:root {
    --bg: #f7f8fc;
    --surface: #ffffff;
    --surface-2: #eef1f8;
    --text: #0f172a;
    --text-muted: #5b6478;
    --border: #e2e6ef;
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --primary-text: #ffffff;
    --accent: #10b981;
    --focus: #818cf8;
    --paper: #ffffff;
    --paper-text: #0f172a;
    --paper-muted: #64748b;
    --paper-border: #e5e7eb;
    --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 12px 32px -8px rgba(15, 23, 42, .14);
    --radius: 14px;
    --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

:root[data-theme="dark"] {
    --bg: #0b1020;
    --surface: #131a2e;
    --surface-2: #1a2238;
    --text: #e8ebf4;
    --text-muted: #9aa3b8;
    --border: #262f48;
    --primary: #7c74ff;
    --primary-hover: #918bff;
    --primary-text: #0b1020;
    --accent: #34d399;
    --focus: #a5b4fc;
    --paper: #f8fafc;
    --paper-text: #0f172a;
    --paper-muted: #64748b;
    --paper-border: #e2e8f0;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 16px 40px -8px rgba(0, 0, 0, .55);
}

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

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

body {
    margin: 0;
    font-family: var(--font);
    font-size: 16px;
    line-height: 1.55;
    color: var(--text);
    background: var(--bg);
    transition: background-color .2s ease, color .2s ease;
}

a { color: inherit; }

/* Native dropdown lists use the system's own colours, so the hovered option
   stays readable (custom backgrounds on <select> leak into the list on Windows) */
select { color-scheme: light; }
:root[data-theme="dark"] select { color-scheme: dark; }
select option, select optgroup { background-color: Canvas; color: CanvasText; font-size: 16px; }
select option { font-weight: 400; }
select optgroup { font-weight: 700; font-style: normal; }

h1, h2, h3 { line-height: 1.15; letter-spacing: -.02em; margin: 0; }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }

.container { width: 100%; max-width: 1160px; margin: 0 auto; padding: 0 16px; }

.sr-only {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

.skip-link { position: absolute; left: -999px; top: 8px; z-index: 100; background: var(--surface); padding: 8px 12px; }
.skip-link:focus { left: 8px; }

/* Buttons */
.btn {
    display: inline-flex; align-items: center; justify-content: center;
    gap: 8px; border: 0; border-radius: 10px; cursor: pointer;
    font: inherit; font-weight: 600; text-decoration: none;
    padding: 12px 20px; min-height: 44px;
    transition: transform .15s ease, background-color .15s ease, box-shadow .15s ease;
}
.btn:active { transform: translateY(1px); }
.btn--primary { background: var(--primary); color: var(--primary-text); box-shadow: 0 6px 16px -6px var(--primary); }
.btn--primary:hover { background: var(--primary-hover); }
.btn--light { background: #fff; color: #312e81; }
.btn--light:hover { background: #eef2ff; }
.btn--sm { padding: 8px 14px; min-height: 40px; font-size: 14px; }
.btn--lg { padding: 14px 26px; font-size: 17px; }

/* Nav */
.nav {
    position: sticky; top: 0; z-index: 20;
    background: color-mix(in srgb, var(--bg) 85%, transparent);
    backdrop-filter: saturate(160%) blur(10px);
    -webkit-backdrop-filter: saturate(160%) blur(10px);
    border-bottom: 1px solid var(--border);
}
.nav__inner { display: flex; align-items: center; gap: 16px; height: 64px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 700; }
.brand__mark {
    display: grid; place-items: center; width: 32px; height: 32px; border-radius: 9px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: #fff; font-size: 13px; letter-spacing: .02em;
}
.nav__links { display: none; gap: 24px; margin-left: 24px; }
.nav__links a { text-decoration: none; color: var(--text-muted); font-weight: 500; }
.nav__links a:hover { color: var(--text); }
.nav__actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.nav__cta { display: none; }
.nav__text { padding: 8px 6px; text-decoration: none; font-weight: 600; color: var(--text); white-space: nowrap; }
.nav__text:hover { color: var(--primary); }
.nav__actions .btn { white-space: nowrap; }
@media (max-width: 419px) {
    .nav .brand__name { display: none; }
}

.theme-toggle {
    width: 40px; height: 40px; border-radius: 10px; cursor: pointer;
    display: grid; place-items: center;
    background: var(--surface); color: var(--text); border: 1px solid var(--border);
}
.theme-toggle:hover { background: var(--surface-2); }
.icon { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon--sun { display: none; }
:root[data-theme="dark"] .icon--sun { display: block; }
:root[data-theme="dark"] .icon--moon { display: none; }

/* Toast */
.toast {
    position: fixed; left: 50%; bottom: 20px; z-index: 50;
    transform: translate(-50%, 12px); opacity: 0;
    max-width: calc(100% - 32px); padding: 12px 18px; border-radius: 12px;
    background: var(--text); color: var(--bg); font-size: 14px; box-shadow: var(--shadow);
    transition: opacity .2s ease, transform .2s ease;
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* Monthly / Yearly switch for plan prices */
.period-toggle { display: inline-flex; gap: 4px; padding: 4px; margin: 0 0 16px; border: 1px solid var(--border); border-radius: 999px; }
.period-toggle button { min-height: 36px; padding: 0 16px; border: 0; border-radius: 999px; background: transparent; color: var(--text-muted); font: inherit; font-weight: 600; cursor: pointer; }
.period-toggle button[aria-checked="true"] { background: var(--primary); color: var(--primary-text); }
.period-toggle button:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.period-toggle__save { margin-left: 4px; font-size: 12px; font-weight: 700; color: var(--accent); }
.period-toggle button[aria-checked="true"] .period-toggle__save { color: inherit; opacity: .85; }

/* Tooltips: any element with data-tip="…" (positioned by app.js).
   .help-tip is the small "?" beside a label for screens without hover. */
.tip {
    position: fixed; z-index: 1000; left: 0; top: 0;
    max-width: min(280px, calc(100vw - 16px));
    padding: 8px 11px; border-radius: 10px;
    background: #111827; color: #f9fafb;
    font: 500 13px/1.45 var(--font); letter-spacing: 0; text-align: left; white-space: normal;
    box-shadow: 0 8px 24px -6px rgba(15, 23, 42, .35);
    pointer-events: none; opacity: 0; transform: translateY(3px);
    transition: opacity .12s ease, transform .12s ease;
}
.tip.is-visible { opacity: 1; transform: none; }
.tip::after {
    content: ""; position: absolute; left: var(--tip-arrow, 50%); width: 8px; height: 8px;
    background: inherit; transform: translateX(-50%) rotate(45deg); bottom: -4px;
}
.tip--below::after { bottom: auto; top: -4px; }
.tip--right::after { left: -4px; top: var(--tip-arrow, 50%); bottom: auto; transform: translateY(-50%) rotate(45deg); }
:root[data-theme="dark"] .tip { background: #f1f5f9; color: #0f172a; box-shadow: 0 8px 24px -6px rgba(0, 0, 0, .6); }
@media (prefers-reduced-motion: reduce) { .tip { transition: none; transform: none; } }

.help-tip {
    display: inline-grid; place-items: center; flex: none;
    width: 18px; height: 18px; margin-left: 6px; padding: 0; vertical-align: middle;
    border: 1px solid var(--border); border-radius: 50%;
    background: var(--surface-2); color: var(--text-muted);
    font: 700 11px/1 var(--font); cursor: help; position: relative;
}
.help-tip:hover, .help-tip[aria-expanded="true"] { color: var(--primary); border-color: var(--primary); }
.help-tip::before { content: ""; position: absolute; inset: -10px; }
