/**
 * OLA Bid Helper — Styles
 * Dark theme, MOBILE-FIRST, gold accent
 * Version: 1.0.2
 *
 * Mobile-first: base styles = phone (375px)
 * Desktop overrides at @media (min-width: 768px)
 */

/* ─── Reset & Base ──────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg-primary: #0f1117;
    --bg-secondary: #1a1d27;
    --bg-card: #21242f;
    --bg-input: #2a2d3a;
    --bg-hover: #2f3344;
    --text-primary: #e8e9ed;
    --text-secondary: #9ca3af;
    --text-dim: #6b7280;
    --accent: #d4a843;
    --accent-hover: #e0ba5c;
    --accent-dim: rgba(212, 168, 67, 0.15);
    --positive: #22c55e;
    --positive-dim: rgba(34, 197, 94, 0.15);
    --negative: #ef4444;
    --negative-dim: rgba(239, 68, 68, 0.15);
    --warning: #f59e0b;
    --warning-dim: rgba(245, 158, 11, 0.15);
    --border: #2a2d3a;
    --border-light: #363a48;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 2px 8px rgba(0,0,0,0.3);
    --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --mono: 'SF Mono', 'Fira Code', 'Cascadia Code', 'Consolas', monospace;
    --nav-height: 64px;
    --header-height: 56px;
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: var(--font);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: hidden;
    overscroll-behavior: none;
}

/* ─── Typography ────────────────────────────────────────── */
h1, h2, h3, h4 { font-weight: 600; line-height: 1.2; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.1rem; }

.mono { font-family: var(--mono); }
.accent { color: var(--accent); }
.positive { color: var(--positive); }
.negative { color: var(--negative); }
.dim { color: var(--text-dim); font-size: 0.85rem; }

/* ─── Layout ────────────────────────────────────────────── */
.app-container {
    max-width: 100%;
    margin: 0 auto;
    /* space for fixed bottom nav + safe area */
    padding-bottom: calc(var(--nav-height) + var(--safe-bottom) + 12px);
}

.view {
    display: none;
    padding: 12px;
}

.view.active { display: block; }

/* ─── Header ────────────────────────────────────────────── */
.app-header {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    padding: 10px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
    height: var(--header-height);
}

.app-logo {
    display: flex;
    align-items: center;
    gap: 10px;
}

.app-logo-icon {
    width: 36px;
    height: 36px;
    background: var(--accent);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    font-weight: 800;
    color: var(--bg-primary);
    flex-shrink: 0;
}

.app-logo-text {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-primary);
}

.app-logo-sub {
    font-size: 0.65rem;
    color: var(--text-dim);
    display: block;
    margin-top: -2px;
}

/* Header Add Button — large enough to tap easily */
.header-action {
    background: var(--accent-dim);
    border: 1px solid var(--accent);
    color: var(--accent);
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    min-height: 44px;
    display: flex;
    align-items: center;
    white-space: nowrap;
}

.header-action:active { background: var(--accent); color: var(--bg-primary); }

/* ─── Bottom Navigation ─────────────────────────────────── */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-around;
    height: calc(var(--nav-height) + var(--safe-bottom));
    padding-bottom: var(--safe-bottom);
    z-index: 100;
}

/* Each nav item is a large tap target — minimum 44x44 */
.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    text-decoration: none;
    color: var(--text-dim);
    font-size: 0.65rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    gap: 2px;
    cursor: pointer;
    transition: color 0.15s;
    border: none;
    background: none;
    padding: 8px 0;
    min-height: 44px;
    -webkit-touch-callout: none;
    user-select: none;
}

.nav-item .nav-icon { font-size: 1.4rem; }
.nav-item.active { color: var(--accent); }
.nav-item:active { color: var(--accent); opacity: 0.8; }

/* ─── Cards ─────────────────────────────────────────────── */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px;
    margin-bottom: 12px;
}

.card-title {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 12px;
}

/* ─── Form Elements ─────────────────────────────────────── */
.form-group { margin-bottom: 16px; }

.form-label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 6px;
    font-weight: 500;
}

/* Inputs: 16px font prevents iOS auto-zoom, 48px height = easy tap */
.form-input, .form-select, .form-textarea {
    width: 100%;
    padding: 12px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 16px; /* MUST be 16px — prevents iOS zoom on focus */
    min-height: 48px;
    transition: border-color 0.2s;
    -webkit-appearance: none;
    appearance: none;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-dim);
}

.form-input::placeholder { color: var(--text-dim); }

.form-input[type="number"] { font-family: var(--mono); font-size: 16px; }

.form-select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%239ca3af' stroke-width='2' fill='none'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 38px;
}

.form-textarea { resize: vertical; min-height: 80px; }

/* On mobile, form-row stacks single-column by default */
.form-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0;
}

.form-hint {
    font-size: 0.75rem;
    color: var(--text-dim);
    margin-top: 4px;
}

/* Toggle switch — larger tap area */
.toggle-group {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    min-height: 44px;
}

.toggle {
    position: relative;
    width: 52px;
    height: 30px;
    flex-shrink: 0;
}

.toggle input { opacity: 0; width: 0; height: 0; position: absolute; }

.toggle-slider {
    position: absolute;
    inset: 0;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 15px;
    cursor: pointer;
    transition: background 0.2s;
}

.toggle-slider::before {
    content: '';
    position: absolute;
    width: 22px;
    height: 22px;
    left: 4px;
    top: 3px;
    background: var(--text-dim);
    border-radius: 50%;
    transition: transform 0.2s, background 0.2s;
}

.toggle input:checked + .toggle-slider { background: var(--accent-dim); border-color: var(--accent); }
.toggle input:checked + .toggle-slider::before { transform: translateX(21px); background: var(--accent); }

.toggle-label { font-size: 0.95rem; color: var(--text-secondary); }

/* ─── Buttons ───────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 12px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    text-decoration: none;
    min-height: 48px;
    -webkit-touch-callout: none;
    user-select: none;
}

.btn-accent { background: var(--accent); color: var(--bg-primary); }
.btn-accent:active { background: var(--accent-hover); transform: scale(0.97); }
.btn-success { background: var(--positive); color: #fff; }
.btn-success:active { opacity: 0.85; transform: scale(0.97); }
.btn-danger { background: var(--negative); color: #fff; }
.btn-danger:active { opacity: 0.85; transform: scale(0.97); }
.btn-ghost { background: transparent; color: var(--text-secondary); padding: 10px; min-height: 44px; }
.btn-ghost:active { background: var(--bg-hover); color: var(--text-primary); }
.btn-outline { background: transparent; border: 1px solid var(--border-light); color: var(--text-secondary); }
.btn-outline:active { border-color: var(--accent); color: var(--accent); }

.btn-sm { padding: 10px 14px; font-size: 0.85rem; min-height: 40px; }
.btn-block { width: 100%; }
.btn-delete:active { color: var(--negative); }

.btn-group { display: flex; gap: 8px; flex-wrap: wrap; }

/* ─── GPS Location Button ───────────────────────────────── */
.btn-gps {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 14px;
    background: var(--bg-hover);
    border: 1px dashed var(--border-light);
    border-radius: var(--radius-sm);
    color: var(--accent);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    min-height: 48px;
    transition: background 0.15s, border-color 0.15s;
}

.btn-gps:active {
    background: var(--accent-dim);
    border-color: var(--accent);
    transform: scale(0.97);
}

.btn-gps.loading {
    opacity: 0.7;
    pointer-events: none;
}

.gps-icon {
    font-size: 1.2rem;
}

.gps-status {
    font-size: 0.8rem;
    padding: 8px 0 0;
    color: var(--text-muted);
    text-align: center;
}

.gps-status.error { color: var(--negative); }
.gps-status.success { color: var(--positive); }

/* ─── Distance List (after GPS) ─────────────────────────── */
.distance-list {
    margin-top: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.distance-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    background: var(--bg-hover);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}

.distance-item:active {
    border-color: var(--accent);
    background: var(--accent-dim);
}

.distance-item.nearest {
    border-color: var(--accent);
    background: var(--accent-dim);
}

.distance-item .loc-name {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-primary);
}

.distance-item .loc-address {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.distance-item .loc-miles {
    font-weight: 700;
    font-size: 0.95rem;
    font-family: var(--mono);
    color: var(--accent);
    white-space: nowrap;
}

.distance-item .loc-miles small {
    font-weight: 400;
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* ─── Calculator Results ────────────────────────────────── */
.result-grid {
    display: grid;
    gap: 0;
}

.result-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}

.result-row:last-child { border-bottom: none; }

.result-label {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.result-value {
    font-family: var(--mono);
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.result-total {
    padding: 14px 0 10px;
    border-top: 2px solid var(--accent);
    border-bottom: none;
    margin-top: 4px;
}

.result-total .result-label {
    font-size: 1.15rem;
    color: var(--accent);
    font-weight: 700;
}

.result-total .result-value {
    font-size: 1.5rem;
    color: var(--accent);
    font-weight: 700;
}

/* ─── Savings Display ───────────────────────────────────── */
.savings-card {
    border-left: 3px solid var(--positive);
    padding-left: 12px;
}

.savings-card.over-retail {
    border-left-color: var(--negative);
}

/* ─── Max Bid Reverse ───────────────────────────────────── */
.max-bid-result {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--accent-dim);
    border: 1px solid var(--accent);
    border-radius: var(--radius-sm);
    padding: 14px 16px;
    margin-top: 10px;
}

.max-bid-label {
    font-size: 0.95rem;
    color: var(--accent);
    font-weight: 600;
}

.max-bid-value {
    font-family: var(--mono);
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--accent);
}

/* ─── Item Cards ────────────────────────────────────────── */
.item-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px;
    margin-bottom: 12px;
    transition: border-color 0.2s;
}

.item-card.card-warning { border-left: 3px solid var(--warning); }
.item-card.card-danger { border-left: 3px solid var(--negative); }

/* On mobile: stack name above badges */
.item-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 8px;
    margin-bottom: 10px;
}

.item-name {
    font-size: 1rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
    order: 1;
}

.item-badges {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
    order: 2;
}

.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 5px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.badge-status { color: #fff; }

.badge-category {
    background: var(--bg-hover);
    color: var(--text-secondary);
}

.item-body { margin-bottom: 10px; }

.item-cost-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.item-cost-row .label,
.item-savings .label,
.item-profit .label {
    font-size: 0.8rem;
    color: var(--text-dim);
    margin-right: 4px;
}

.item-cost-row .value,
.item-savings .value,
.item-profit .value {
    font-family: var(--mono);
    font-size: 0.95rem;
    font-weight: 600;
}

.item-savings, .item-profit {
    margin-bottom: 8px;
    font-size: 0.85rem;
}

.item-notes {
    font-size: 0.8rem;
    color: var(--text-dim);
    padding: 8px 0;
    border-top: 1px solid var(--border);
    margin-top: 8px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Item actions: full-width on mobile for easy tapping */
.item-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    padding-top: 10px;
    border-top: 1px solid var(--border);
}

.item-actions .btn-sm {
    flex: 1;
    min-width: 0;
}

.item-actions .btn-ghost {
    flex: 0 0 auto;
    min-width: 44px;
    min-height: 44px;
    font-size: 1.1rem;
}

/* ─── Threshold Bars ────────────────────────────────────── */
.threshold-bar { margin: 8px 0; }

.threshold-track {
    width: 100%;
    height: 8px;
    background: var(--bg-input);
    border-radius: 4px;
    overflow: hidden;
}

.threshold-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.3s;
}

.threshold-safe { background: var(--positive); }
.threshold-warning { background: var(--warning); }
.threshold-danger { background: var(--negative); }

.threshold-label {
    font-size: 0.75rem;
    color: var(--text-dim);
    font-family: var(--mono);
    margin-top: 3px;
    display: block;
}

/* ─── Filter Bar — horizontal scroll on mobile ──────────── */
.filter-bar {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 4px;
    flex-wrap: nowrap;
}

.filter-bar::-webkit-scrollbar { display: none; }

.filter-btn {
    padding: 10px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 24px;
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
    flex-shrink: 0;
    min-height: 44px;
}

.filter-btn:active { border-color: var(--accent); color: var(--text-primary); }
.filter-btn.active { background: var(--accent-dim); border-color: var(--accent); color: var(--accent); }

.filter-btn .count {
    font-size: 0.75rem;
    opacity: 0.7;
    margin-left: 4px;
}

/* Filter controls: stack vertically on mobile */
.filter-controls {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 14px;
}

.filter-controls .form-input,
.filter-controls .form-select {
    min-height: 44px;
    font-size: 16px;
}

.search-input { width: 100%; }

/* ─── Dashboard ─────────────────────────────────────────── */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-bottom: 20px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 10px;
    text-align: center;
}

.stat-value {
    font-family: var(--mono);
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 2px;
    word-break: break-all;
}

.stat-label {
    font-size: 0.65rem;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    line-height: 1.3;
}

.dashboard-section { margin-bottom: 24px; }

.section-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

/* Budget card */
.budget-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px;
}

.budget-header {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 10px;
}

.budget-label { font-size: 0.9rem; color: var(--text-secondary); }

.budget-remaining { font-family: var(--mono); font-weight: 600; font-size: 1.1rem; }
.budget-remaining.safe { color: var(--positive); }
.budget-remaining.warning { color: var(--warning); }
.budget-remaining.danger { color: var(--negative); }

.budget-details {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    color: var(--text-dim);
    margin-top: 10px;
}

.budget-cycle {
    font-size: 0.75rem;
    color: var(--text-dim);
    margin-top: 6px;
}

/* Alert badges */
.alert-row { display: flex; gap: 8px; flex-wrap: wrap; }
.alert-badge {
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 600;
}
.alert-danger { background: var(--negative-dim); color: var(--negative); }
.alert-warning { background: var(--warning-dim); color: var(--warning); }

/* Category bars — stacked on mobile */
.category-bars { display: flex; flex-direction: column; gap: 14px; }

.category-row {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.category-label { font-size: 0.85rem; color: var(--text-secondary); font-weight: 500; }

.category-bar-track {
    height: 10px;
    background: var(--bg-input);
    border-radius: 5px;
    overflow: hidden;
}

.category-bar-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 5px;
    transition: width 0.4s;
}

.category-stats {
    font-size: 0.8rem;
}

.category-stats .mono { font-size: 0.85rem; font-weight: 600; }

/* Recent wins */
.recent-list {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.recent-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    min-height: 48px;
}

.recent-item:last-child { border-bottom: none; }

.recent-name {
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 60%;
}

.recent-cost {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--accent);
    font-family: var(--mono);
}

/* ─── Empty States ──────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 48px 20px;
    color: var(--text-dim);
}

.empty-state-icon { font-size: 2.5rem; margin-bottom: 12px; opacity: 0.5; }
.empty-state-text { font-size: 1rem; margin-bottom: 4px; }
.empty-state-sub { font-size: 0.85rem; }

.empty-state-inline {
    text-align: center;
    padding: 20px;
    color: var(--text-dim);
    font-size: 0.9rem;
}

.empty-state-inline a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 500;
}

/* ─── Settings ──────────────────────────────────────────── */
.settings-section {
    margin-bottom: 24px;
}

.settings-section-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 12px;
}

.settings-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.settings-version {
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-dim);
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

/* ─── Modal — full-screen on mobile ─────────────────────── */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 200;
    align-items: flex-end;
    justify-content: center;
}

.modal-overlay.active { display: flex; }

.modal {
    background: var(--bg-secondary);
    border-radius: var(--radius) var(--radius) 0 0;
    width: 100%;
    max-height: 95vh;
    max-height: 95dvh;
    display: flex;
    flex-direction: column;
    animation: slideUp 0.25s ease;
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 16px 12px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.modal-header h2 { font-size: 1.15rem; }

.modal-close {
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 1.8rem;
    cursor: pointer;
    padding: 4px 8px;
    line-height: 1;
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:active { color: var(--text-primary); }

.modal-body {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 16px;
}

/* Sticky footer for modal — always visible */
.modal-footer {
    display: flex;
    gap: 10px;
    padding: 12px 16px;
    padding-bottom: calc(12px + var(--safe-bottom));
    border-top: 1px solid var(--border);
    background: var(--bg-secondary);
    flex-shrink: 0;
}

.modal-footer .btn { flex: 1; }

/* ─── Confirm Dialog ────────────────────────────────────── */
.confirm-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 300;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.confirm-overlay.active { display: flex; }

.confirm-box {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px 24px;
    max-width: 350px;
    width: 100%;
    text-align: center;
}

.confirm-message {
    font-size: 1.05rem;
    margin-bottom: 24px;
    color: var(--text-primary);
    line-height: 1.4;
}

.confirm-actions {
    display: flex;
    gap: 10px;
}

.confirm-actions .btn { flex: 1; min-height: 48px; }

/* ─── Toast ─────────────────────────────────────────────── */
.toast-container {
    position: fixed;
    top: calc(var(--header-height) + 8px);
    left: 12px;
    right: 12px;
    z-index: 400;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.toast {
    padding: 12px 18px;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 600;
    transform: translateY(-20px);
    opacity: 0;
    transition: transform 0.3s ease, opacity 0.3s ease;
    box-shadow: var(--shadow);
    text-align: center;
    pointer-events: auto;
}

.toast.show { transform: translateY(0); opacity: 1; }
.toast-success { background: var(--positive); color: #fff; }
.toast-error { background: var(--negative); color: #fff; }


/* ═══════════════════════════════════════════════════════════
   DESKTOP OVERRIDES (768px+)
   ═══════════════════════════════════════════════════════════ */
@media (min-width: 768px) {
    :root {
        --nav-height: 0px;
    }

    .app-container {
        max-width: 900px;
        padding-bottom: 32px;
    }

    .view { padding: 24px; }

    /* Nav becomes top tab bar on desktop */
    .bottom-nav {
        position: static;
        max-width: 900px;
        margin: 0 auto;
        border-top: none;
        border-bottom: 1px solid var(--border);
        justify-content: center;
        gap: 4px;
        padding: 0 24px;
        height: auto;
    }

    .nav-item {
        flex: none;
        flex-direction: row;
        padding: 14px 24px;
        font-size: 0.85rem;
        gap: 8px;
        border-bottom: 2px solid transparent;
        border-radius: 0;
    }

    .nav-item.active {
        border-bottom-color: var(--accent);
    }

    .nav-item:hover { color: var(--text-primary); }

    /* Header */
    .header-action:hover { background: var(--accent); color: var(--bg-primary); }

    /* Forms go side-by-side on desktop */
    .form-row {
        grid-template-columns: 1fr 1fr;
        gap: 12px;
    }

    /* Filter controls in a row on desktop */
    .filter-controls {
        flex-direction: row;
    }

    .search-input { flex: 1; }

    .filter-controls .form-select {
        width: auto;
        min-width: 140px;
    }

    /* Dashboard 3 columns */
    .stat-grid { grid-template-columns: repeat(3, 1fr); }

    .stat-value { font-size: 1.3rem; }

    .budget-header {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
    }

    /* Category bars: inline grid on desktop */
    .category-row {
        display: grid;
        grid-template-columns: 120px 1fr auto;
        align-items: center;
        gap: 12px;
    }

    .category-stats { text-align: right; white-space: nowrap; }

    /* Item header back to side-by-side */
    .item-name {
        width: auto;
        max-width: 55%;
    }

    .item-header {
        flex-wrap: nowrap;
        justify-content: space-between;
    }

    .item-actions .btn-sm { flex: none; }

    /* Modal becomes centered card on desktop */
    .modal-overlay { align-items: center; }

    .modal {
        border-radius: var(--radius);
        max-width: 600px;
        max-height: 85vh;
    }

    .modal-footer {
        padding-bottom: 12px;
    }

    /* Toast from right on desktop */
    .toast-container {
        left: auto;
        right: 16px;
        max-width: 320px;
    }

    /* Buttons: hover states on desktop */
    .btn-accent:hover { background: var(--accent-hover); }
    .btn-success:hover { opacity: 0.9; }
    .btn-danger:hover { opacity: 0.9; }
    .btn-ghost:hover { background: var(--bg-hover); color: var(--text-primary); }
    .btn-outline:hover { border-color: var(--accent); color: var(--accent); }
    .btn-delete:hover { color: var(--negative); }
    .filter-btn:hover { border-color: var(--accent); color: var(--text-primary); }
    .item-card:hover { border-color: var(--border-light); }
    .empty-state-inline a:hover { text-decoration: underline; }
    .modal-close:hover { color: var(--text-primary); }
}

@media (min-width: 1024px) {
    .app-container { max-width: 1000px; }
}

/* ─── Utility ───────────────────────────────────────────── */
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.gap-1 { gap: 8px; }
.hidden { display: none !important; }
