/* ═══════════════════════════════════════════════════════════════════
   FuelTrak design system — "Clean & Light iOS"
   Tokens + shared components used by every page. Light is the default
   theme; `html[data-theme="dark"]` flips to the dark palette. Templates
   keep page-specific rules inline and load this file FIRST so their
   own rules can override where needed.
   ═══════════════════════════════════════════════════════════════════ */

:root {
    /* ── Typography ── */
    --font: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI',
            Inter, Roboto, sans-serif;

    /* ── Chrome (page background, topbar, rails) ── */
    --bg:        #f2f2f7;   /* iOS grouped background */
    --surface:   #ffffff;   /* raised card surface */
    --surface-2: #ffffff;   /* elevated surface on chrome (one step up) */
    --surface-3: #e5e5ea;   /* pressed / hover fill */
    --border:    rgba(60,60,67,0.12);   /* hairline separator */
    --fill:      rgba(120,120,128,0.12); /* iOS quaternary fill — inset tiles, controls */

    --text:      #1c1c1e;
    --muted:     #6e6e73;
    --dim:       #48484a;

    /* ── Semantic color ── */
    --accent:      #007aff;  /* interactive: links, active states, primary buttons */
    --accent-press:#0071eb;
    --green:       #1e8e3e;  /* text-safe on white (price drops, savings) */
    --green-vivid: #34c759;  /* fills, badges, icons */
    --red:         #d70015;  /* text-safe on white (price increases) */
    --red-vivid:   #ff3b30;  /* fills, badges, destructive buttons */
    --yellow:      #b25000;  /* text-safe warning on white */
    --yellow-vivid:#ff9f0a;

    /* ── Cards ── */
    --card-bg:        #ffffff;
    --card-bg-2:      #ffffff;
    --card-bg-hover:  #f7f7f9;
    --card-border:    rgba(60,60,67,0.10);
    --card-text:      #1c1c1e;
    --card-muted:     #6e6e73;
    --card-dim:       #48484a;
    --card-shadow:    0 1px 2px rgba(0,0,0,0.04), 0 4px 14px rgba(0,0,0,0.05);
    --card-shadow-hov:0 2px 6px rgba(0,0,0,0.06), 0 10px 28px rgba(0,0,0,0.09);
    --card-accent-fg: #1c1c1e;

    /* ── Frosted chrome (topbar / tab bar) ── */
    --frost-bg: rgba(249,249,251,0.82);

    /* ── Geometry ── */
    --radius:    18px;   /* cards */
    --radius-sm: 12px;   /* controls, inputs, list groups */
    --sidebar-w: 200px;
    --panel-w:   300px;
}

html[data-theme="dark"] {
    --bg:        #000000;
    --surface:   #1c1c1e;
    --surface-2: #2c2c2e;
    --surface-3: #3a3a3c;
    --border:    rgba(84,84,88,0.48);
    --fill:      rgba(120,120,128,0.22);

    --text:      #f2f2f7;
    --muted:     #98989f;
    --dim:       #c7c7cc;

    --accent:      #0a84ff;
    --accent-press:#0974df;
    --green:       #30d158;
    --green-vivid: #30d158;
    --red:         #ff453a;
    --red-vivid:   #ff453a;
    --yellow:      #ffd60a;
    --yellow-vivid:#ff9f0a;

    --card-bg:        #1c1c1e;
    --card-bg-2:      #2c2c2e;
    --card-bg-hover:  #3a3a3c;
    --card-border:    rgba(84,84,88,0.36);
    --card-text:      #f2f2f7;
    --card-muted:     #98989f;
    --card-dim:       #c7c7cc;
    --card-shadow:    0 1px 2px rgba(0,0,0,0.35), inset 0 1px 0 rgba(255,255,255,0.02);
    --card-shadow-hov:0 8px 24px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.03);
    --card-accent-fg: #f2f2f7;

    --frost-bg: rgba(18,18,20,0.8);
}

/* ── Base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font-family: inherit; }

/* ── Frosted chrome ───────────────────────────────────────────────── */
.ft-frosted {
    background: var(--frost-bg);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    backdrop-filter: blur(20px) saturate(180%);
}

/* ── Buttons ──────────────────────────────────────────────────────── */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
    border: none; border-radius: var(--radius-sm);
    font-size: 0.9rem; font-weight: 600; cursor: pointer;
    padding: 0.6rem 1.1rem; min-height: 40px;
    transition: background 0.15s, opacity 0.15s, transform 0.1s;
    text-decoration: none;
}
.btn:active { transform: scale(0.97); }
.btn-filled  { background: var(--accent); color: #fff; }
.btn-filled:hover { background: var(--accent-press); }
.btn-tinted  { background: color-mix(in srgb, var(--accent) 13%, transparent); color: var(--accent); }
.btn-tinted:hover { background: color-mix(in srgb, var(--accent) 20%, transparent); }
.btn-plain   { background: transparent; color: var(--accent); }
.btn-plain:hover { background: var(--fill); }
.btn-danger  { background: var(--red-vivid); color: #fff; }
.btn-gray    { background: var(--fill); color: var(--text); }

/* ── Segmented control (period tabs, admin tabs) ─────────────────── */
.seg {
    display: inline-flex; align-items: stretch;
    background: var(--fill); border-radius: 9px; padding: 2px;
    gap: 2px;
}
.seg > button, .seg > .seg-item {
    border: none; background: transparent; cursor: pointer;
    padding: 0.28rem 0.8rem; border-radius: 7px;
    font-size: 0.78rem; font-weight: 600; color: var(--text);
    transition: background 0.15s, box-shadow 0.15s, color 0.15s;
    white-space: nowrap;
}
.seg > button.active, .seg > .seg-item.active {
    background: var(--surface);
    box-shadow: 0 1px 4px rgba(0,0,0,0.12);
    color: var(--text);
}
html[data-theme="dark"] .seg > button.active,
html[data-theme="dark"] .seg > .seg-item.active { background: #636366; }

/* ── iOS inset-grouped list ───────────────────────────────────────── */
.ft-list {
    background: var(--surface);
    border-radius: var(--radius-sm);
    overflow: hidden;
    box-shadow: var(--card-shadow);
}
.ft-list-row {
    display: flex; align-items: center; gap: 0.75rem;
    padding: 0.7rem 1rem; min-height: 44px;
    position: relative;
}
.ft-list-row + .ft-list-row::before {
    content: ''; position: absolute; top: 0; left: 1rem; right: 0;
    height: 1px; background: var(--border);
}
.ft-list-row:active { background: var(--surface-3); }

/* ── Card ─────────────────────────────────────────────────────────── */
.ft-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius);
    box-shadow: var(--card-shadow);
    color: var(--card-text);
}

/* ── Badges / pills ───────────────────────────────────────────────── */
.pill {
    display: inline-flex; align-items: center; gap: 4px;
    font-size: 0.68rem; font-weight: 700; letter-spacing: 0.03em;
    padding: 3px 9px; border-radius: 999px; white-space: nowrap;
}
.pill-green  { background: color-mix(in srgb, var(--green-vivid) 16%, transparent); color: var(--green); }
.pill-red    { background: color-mix(in srgb, var(--red-vivid) 14%, transparent);   color: var(--red); }
.pill-blue   { background: color-mix(in srgb, var(--accent) 13%, transparent);      color: var(--accent); }
.pill-gray   { background: var(--fill); color: var(--muted); }

/* ── Form fields ──────────────────────────────────────────────────── */
.ft-field {
    width: 100%;
    padding: 0.7rem 0.95rem; min-height: 44px;
    background: var(--fill);
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    color: var(--text); font-size: 0.95rem;
    transition: border-color 0.15s, background 0.15s;
}
.ft-field::placeholder { color: var(--muted); }
.ft-field:focus { outline: none; border-color: var(--accent); background: var(--surface); }

/* ── Skeleton shimmer (loading states) ────────────────────────────── */
.skeleton {
    position: relative; overflow: hidden;
    background: var(--fill); border-radius: 8px; color: transparent !important;
}
.skeleton::after {
    content: ''; position: absolute; inset: 0;
    transform: translateX(-100%);
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.45), transparent);
    animation: ft-shimmer 1.4s infinite;
}
html[data-theme="dark"] .skeleton::after {
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.08), transparent);
}
@keyframes ft-shimmer { 100% { transform: translateX(100%); } }

/* ── Bottom tab bar (mobile) ──────────────────────────────────────── */
.tabbar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 90;
    border-top: 1px solid var(--border);
    padding-bottom: env(safe-area-inset-bottom);
}
.tabbar-inner {
    display: flex; justify-content: space-around; align-items: center;
    height: 52px; max-width: 500px; margin: 0 auto;
}
.tabbar a {
    display: flex; flex-direction: column; align-items: center; gap: 2px;
    color: var(--muted); text-decoration: none;
    font-size: 0.62rem; font-weight: 500;
    padding: 0.25rem 1.1rem; min-width: 64px;
    transition: color 0.15s;
}
.tabbar a.active { color: var(--accent); }
.tabbar a svg { width: 23px; height: 23px; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.tabbar a:active { opacity: 0.6; }

/* ── Scrollbars (subtle, iOS-like) ────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-thumb { background: rgba(120,120,128,0.3); border-radius: 3px; }
::-webkit-scrollbar-track { background: transparent; }
