/* Importing Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@700;900&family=DM+Sans:wght@400;500;700&display=swap');

/* CSS Variables for colors */
:root {
    --color-primary: #0A2342;
    --color-secondary: #2E8B57;
    --color-accent: #E07A5F;
    --color-warning: #F4A261;
    --color-bg: #FAF9F6;
    --color-surface: #FFFFFF;
    --color-text: #1A1A2E;
    --color-text-muted: #6B7280;
    --color-border: #E5E7EB;
    --radius: 8px;      /* cards and panels; controls use 6px */
    --focus: 2px solid var(--color-primary);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'DM Sans', sans-serif;
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.6;
    min-height: 100vh;
    padding: 2rem;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
}

/* Header: one flat light bar with a hairline (logo, menu, user) */
.header {
    display: flex;
    align-items: center;
    gap: 2rem;
    padding-bottom: 0.75rem;
    margin-bottom: 2rem;
    border-bottom: 1px solid var(--color-border);
    position: relative;
}

.logo {
    font-family: 'Playfair Display', serif;
    font-size: 1.5rem;
    font-weight: 900;
    letter-spacing: -0.02em;
    color: var(--color-primary);
    white-space: nowrap;
}

.header-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--color-surface);
    padding: 1.25rem 1.5rem;
    border-radius: var(--radius);
    border: 1px solid var(--color-border);
}

.stat-label {
    display: block;
    font-size: 0.875rem;
    color: var(--color-text-muted);
    margin-bottom: 0.35rem;
    font-weight: 500;
}

.stat-value {
    display: block;
    overflow-wrap: anywhere;
    font-size: 2rem;
    font-weight: 700;
    line-height: 1.2;
    font-variant-numeric: tabular-nums;
}

.stat-value.is-ok   { color: #1E6B45; }
.stat-value.is-low  { color: #92400E; }
.stat-value.is-over { color: #B4452E; }

/* Section Styles */
section {
    background: var(--color-surface);
    padding: 2.5rem;
    border-radius: var(--radius);
    margin-bottom: 2rem;
    border: 1px solid var(--color-border);
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--color-border);
}

.section-header h2 {
    font-family: 'Playfair Display', serif;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--color-primary);
}

/* Budget Section */
.budget-controls {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
}

.budget-controls input {
    flex: 1;
}

.budget-alert {
    padding: 1rem;
    border-radius: 8px;
    font-weight: 500;
}

.budget-alert.success {
    background: #D1FAE5;
    color: #065F46;
    border: 1px solid #6EE7B7;
}

.budget-alert.warning {
    background: #FEF3C7;
    color: #92400E;
    border: 1px solid #FCD34D;
}

.budget-alert.danger {
    background: #FEE2E2;
    color: #991B1B;
    border: 1px solid #FCA5A5;
}

.hidden {
    display: none !important;
}

/* Form Styles */
.expense-form {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group label {
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--color-text);
    font-size: 0.875rem;
}

input,
select {
    padding: 0.875rem 1rem;
    border: 1px solid #C9CDD3;
    border-radius: 6px;
    font-size: 1rem;
    min-height: 44px;
    font-family: 'DM Sans', sans-serif;
    transition: border-color 0.15s ease;
    background: var(--color-surface);
}

input:focus,
select:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(10, 35, 66, 0.1);
}

/* Button Styles */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 0 1.5rem;
    border: 1px solid transparent;
    border-radius: 6px;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: background-color 0.15s ease, transform 0.1s ease;
    font-family: 'DM Sans', sans-serif;
}

.btn:active {
    transform: translateY(1px);
}

.btn-primary {
    background: var(--color-primary);
    color: white;
}

.btn-primary:hover {
    background: #163B5E;
}

/* Destructive actions (Clear All, Delete my account): outlined, not filled */
.btn-secondary {
    background: transparent;
    color: #B4452E;
    border-color: #B4452E;
}

.btn-secondary:hover {
    background: #FDF1EE;
}

/* Buttons keep their natural width. Only the buttons in the login card use btn-full. */
.btn-full {
    width: 100%;
}

.expense-form > .btn {
    align-self: flex-start;
    min-width: 11rem;
}

/* Charts Container */
.charts-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr));
    gap: 2rem;
    margin-top: 2rem;
}

.chart-card {
    background: var(--color-bg);
    padding: 1.5rem;
    border-radius: 10px;
    border: 1px solid var(--color-border);
    min-width: 0;        /* prevents grid blowout when content is wider than cell */
    overflow: hidden;
}

.chart-card canvas {
    max-width: 100%;
}

.chart-card h3 {
    font-family: 'Playfair Display', serif;
    font-size: 1.25rem;
    margin-bottom: 1.5rem;
    color: var(--color-primary);
}

/* Expenses List Styles */
.expenses-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.expense-item {
    display: grid;
    grid-template-columns: 1fr auto auto;
    align-items: center;
    gap: 1.5rem;
    padding: 1rem 0;
    border-bottom: 1px solid var(--color-border);
    transition: background-color 0.15s ease;
}

.expense-item:hover {
    background: var(--color-bg);
}

.expense-info {
    min-width: 0;
}

.expense-info h4 {
    overflow-wrap: anywhere;
    font-weight: 600;
    font-size: 1rem;
    margin-bottom: 0.125rem;
    color: var(--color-text);
}

.expense-meta {
    display: flex;
    gap: 1rem;
    font-size: 0.875rem;
    color: var(--color-text-muted);
}

/* Category: a small colour dot and plain text, no coloured box behind the words */
.expense-category {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.category-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.expense-amount {
    font-size: 1.125rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: var(--color-text);
    text-align: right;
}

.expense-actions {
    display: flex;
    gap: 0.5rem;
}

.btn-icon {
    width: 44px;
    height: 44px;
    padding: 0;
    background: transparent;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease;
    font-size: 1rem;
}

.btn-icon:hover {
    background: var(--color-bg);
    border-color: var(--color-text-muted);
}

.btn-delete:hover {
    background: #FDF1EE;
    border-color: #B4452E;
}

.empty-state {
    text-align: center;
    padding: 3rem 2rem;
    color: var(--color-text-muted);
}

.empty-state p {
    font-size: 1.125rem;
}

/* ─── AI Natural Language Input ─────────────────────────────────────────── */

/* ─── Auth Screen ────────────────────────────────────────────────────────── */

.auth-overlay {
    position: fixed;
    inset: 0;
    background: var(--color-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 150;
    padding: 1rem;
}

.auth-overlay.hidden {
    display: none;
}

.auth-card {
    background: white;
    border-radius: var(--radius);
    padding: 2.5rem;
    width: 100%;
    max-width: 420px;
    border: 1px solid var(--color-border);
}

.auth-logo {
    font-family: 'Playfair Display', serif;
    font-size: 2.25rem;
    font-weight: 900;
    color: var(--color-primary);
    margin-bottom: 0.25rem;
}

.auth-tagline {
    color: var(--color-text-muted);
    font-size: 0.875rem;
    margin-bottom: 2rem;
}

.auth-tabs {
    display: flex;
    margin-bottom: 1.5rem;
    border-bottom: 2px solid var(--color-border);
}

.auth-tab {
    flex: 1;
    padding: 0.75rem;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    font-family: 'DM Sans', sans-serif;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--color-text-muted);
    cursor: pointer;
    transition: all 0.2s ease;
}

.auth-tab.active {
    color: var(--color-primary);
    border-bottom-color: var(--color-primary);
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.auth-error {
    background: #fee2e2;
    color: #991b1b;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    font-size: 0.875rem;
    margin: 0;
}

/* ─── Header user section ─────────────────────────────────────────────────── */

/* Header: user name and Log out, at the right end of the bar */
.header-user {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-left: auto;
}

.user-name {
    font-size: 0.9375rem;
    color: var(--color-text-muted);
    white-space: nowrap;
}

.btn-logout {
    background: transparent;
    color: var(--color-text);
    border: 1px solid var(--color-border);
    padding: 0 1rem;
    min-height: 44px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9375rem;
    font-family: 'DM Sans', sans-serif;
    font-weight: 600;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

.btn-logout:hover {
    background: var(--color-bg);
    border-color: var(--color-text-muted);
}

/* ─── Branding ───────────────────────────────────────────────────────────── */

.logo-ai {
    color: var(--color-accent);
    font-style: italic;
}

/* ─── Loading Overlay ────────────────────────────────────────────────────── */

.loading-overlay {
    position: fixed;
    inset: 0;
    background: var(--color-bg);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    z-index: 200;
    transition: opacity 0.4s ease;
}

.loading-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.loading-spinner {
    width: 28px;
    height: 28px;
    border: 2px solid var(--color-border);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.loading-overlay p {
    color: var(--color-text-muted);
    font-size: 0.95rem;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ─── Button loading state (CSS spinner replaces text) ───────────────────── */

.btn.loading {
    position: relative;
    color: transparent !important;
    pointer-events: none;
}

.btn.loading::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.35);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    inset: 0;
    margin: auto;
}

/* ─── Toast Notifications ────────────────────────────────────────────────── */

.toast-container {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    z-index: 300;
}

.toast {
    background: var(--color-primary);
    color: white;
    padding: 0.875rem 1.25rem;
    border-radius: 8px;
    font-size: 0.9rem;
    font-family: 'DM Sans', sans-serif;
    box-shadow: 0 4px 16px rgba(10, 35, 66, 0.2);
    max-width: 320px;
    line-height: 1.4;
    animation: toastIn 0.3s ease, toastOut 0.4s ease 2.6s forwards;
}

.toast.success { background: #2E8B57; }
.toast.error   { background: #B4452E; }
.toast.warning { background: #92400e; }

@keyframes toastIn {
    from { transform: translateX(110%); opacity: 0; }
    to   { transform: translateX(0);    opacity: 1; }
}

@keyframes toastOut {
    from { opacity: 1; transform: translateX(0); }
    to   { opacity: 0; transform: translateX(110%); }
}

/* ─── Expense item entrance animation ────────────────────────────────────── */

@keyframes fadeSlideIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ─── Streaming AI Summary ───────────────────────────────────────────────── */

.ai-summary-card {
    background: #F4F6F9;
    border: 1px solid var(--color-border);
    border-radius: 10px;
    padding: 1.25rem 1.5rem;
    margin-bottom: 1.5rem;
}

.ai-summary-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.ai-summary-label {
    font-size: 0.9rem;
    color: var(--color-text-muted);
    flex: 1;
}

.btn-sm {
    padding: 0 1rem;
    font-size: 0.9375rem;
}

.ai-summary-output {
    margin-top: 1rem;
    padding: 1rem 1.25rem;
    background: white;
    border-radius: 8px;
    border: 1px solid var(--color-border);
    min-height: 60px;
}

.ai-summary-output p {
    margin: 0;
    font-size: 0.95rem;
    line-height: 1.7;
    color: var(--color-text);
    white-space: pre-wrap;
}

/* Blinking cursor shown while streaming */
.stream-cursor {
    display: inline-block;
    color: var(--color-primary);
    font-weight: bold;
    animation: blink 0.8s step-end infinite;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0; }
}

/* ─── Budget Forecast Section ────────────────────────────────────────────── */

.risk-badge {
    font-size: 0.8125rem;
    font-weight: 700;
    padding: 0.3rem 0.9rem;
    border-radius: 20px;
}

.risk-low    { background: #d1fae5; color: #065f46; }
.risk-medium { background: #fef3c7; color: #92400e; }
.risk-high   { background: #fee2e2; color: #991b1b; }

.forecast-panel {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.forecast-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 1rem;
}

.forecast-metric {
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: 10px;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.metric-label {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--color-text-muted);
}

.metric-value {
    font-variant-numeric: tabular-nums;
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--color-primary);
    line-height: 1.2;
}

.metric-value.metric-danger { color: #B4452E; }

.metric-sub {
    font-size: 0.8125rem;
    color: var(--color-text-muted);
}

.forecast-subtitle {
    font-family: 'Playfair Display', serif;
    font-size: 1.1rem;
    color: var(--color-primary);
    margin-bottom: 0.25rem;
}

.category-forecasts {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.cat-forecast-item {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.cat-forecast-label {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--color-text);
}

.cat-forecast-values {
    font-size: 0.8125rem;
    font-weight: 400;
    color: var(--color-text-muted);
}

.cat-forecast-bar-track {
    height: 10px;
    background: var(--color-border);
    border-radius: 20px;
    display: flex;
    overflow: hidden;
}

.cat-forecast-bar-spent {
    height: 100%;
    background: var(--color-primary);
    border-radius: 20px 0 0 20px;
    transition: width 0.4s ease;
}

.cat-forecast-bar-projected {
    height: 100%;
    background: rgba(10, 35, 66, 0.28);
    transition: width 0.4s ease;
}

/* ─── Financial Insights Panel ───────────────────────────────────────────── */

.insights-panel {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.insight-item {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    padding: 0.875rem 0;
    border-bottom: 1px solid var(--color-border);
}

.insight-dot {
    width: 8px;
    height: 8px;
    min-width: 8px;
    background: var(--color-primary);
    border-radius: 50%;
    margin-top: 0.55rem;
}

.insight-item p {
    margin: 0;
    font-size: 1rem;
    color: var(--color-text);
    line-height: 1.5;
}

.insight-item.insight-warning .insight-dot { background: #D9822B; }
.insight-item.insight-danger .insight-dot  { background: #B4452E; }
.insight-item.insight-success .insight-dot { background: #1E6B45; }

.insights-empty {
    color: var(--color-text-muted);
    font-size: 0.95rem;
    text-align: center;
    padding: 2rem;
    margin: 0;
}

/* ─── AI suggested category badge ────────────────────────────────────────── */

/* AI suggested category badge (appears next to Category label) */
.ai-suggest-badge {
    display: inline-block;
    background: var(--color-primary);
    color: white;
    font-size: 0.8125rem;
    font-weight: 600;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    vertical-align: middle;
    margin-left: 0.4rem;
    text-transform: none;
}

/* ─── AI Natural Language Input ─────────────────────────────────────────── */

.nl-input-wrapper {
    margin-bottom: 2rem;
    padding: 1.5rem;
    background: #F4F6F9;
    border-radius: 10px;
    border: 1px solid var(--color-border);
}

.nl-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.nl-header p {
    color: var(--color-text-muted);
    font-size: 0.9rem;
    margin: 0;
}

.ai-badge {
    background: var(--color-primary);
    color: white;
    font-size: 0.8125rem;
    font-weight: 700;
    padding: 0.2rem 0.6rem;
    border-radius: 4px;
    flex-shrink: 0;
}

.nl-controls {
    display: flex;
    gap: 1rem;
}

.nl-controls input {
    flex: 1;
    border-color: var(--color-border);
}

.nl-controls input:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(10, 35, 66, 0.1);
}

.btn-ai {
    background: var(--color-primary);
    color: white;
    white-space: nowrap;
}

.btn-ai:hover {
    background: #163B5E;
}

.btn-ai:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.nl-preview {
    margin-top: 1rem;
    padding: 1rem 1.25rem;
    background: white;
    border-radius: 8px;
    border: 1px solid var(--color-border);
}

.preview-content {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-bottom: 0.5rem;
    font-size: 0.95rem;
}

.confidence-badge {
    margin-left: auto;
    font-size: 0.8125rem;
    color: var(--color-text-muted);
    background: #f3f4f6;
    padding: 0.2rem 0.7rem;
    border-radius: 20px;
}

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

.preview-error {
    color: #991b1b;
    font-size: 0.9rem;
    margin: 0;
}

.nl-divider {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-top: 1.5rem;
    color: var(--color-text-muted);
    font-size: 0.82rem;
}

.nl-divider::before,
.nl-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--color-border);
}

/* ─── Footer ──────────────────────────────────────────────────────────────── */

/* Footer */
.footer-credit {
    text-align: center;
    padding: 2rem 1rem;
    font-size: 0.875rem;
    color: var(--color-text-muted);
    font-weight: 400;
    opacity: 0.7;
}

/* ── Expense list filter ───────────────────────────────────────────────── */
.list-filter {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 1rem;
    margin-bottom: 0.75rem;
}

.list-filter .form-group {
    flex: 1 1 150px;
}

.list-filter-buttons {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.list-filter-label {
    color: var(--color-text-muted);
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

.btn-outline {
    background: transparent;
    color: var(--color-primary);
    border: 2px solid var(--color-border);
}

.btn-outline:hover {
    border-color: var(--color-primary);
}

/* ── Edit expense window ───────────────────────────────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(10, 35, 66, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 160;
    padding: 1rem;
}

.modal-overlay.hidden {
    display: none;
}

.modal-card {
    background: white;
    border-radius: 16px;
    padding: 2rem;
    width: 100%;
    max-width: 480px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 8px 32px rgba(10, 35, 66, 0.2);
}

.modal-card h2 {
    margin-bottom: 1.25rem;
}

.modal-card .form-group {
    margin-bottom: 1rem;
}

.modal-buttons {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    margin-top: 1.5rem;
}

/* Responsive Design */
@media (max-width: 768px) {
    body {
        padding: 1rem;
    }

    section {
        padding: 1.5rem;
    }

    .section-header h2 {
        font-size: 1.5rem;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .budget-controls {
        flex-direction: column;
    }

    /* Name and amount on one line; the edit and delete buttons on a line below */
    .expense-item {
        grid-template-columns: 1fr auto;
        gap: 0.5rem 1rem;
    }

    .expense-actions {
        grid-column: 1 / -1;
        justify-content: flex-end;
    }

    .charts-container {
        grid-template-columns: 1fr;
    }

    .nl-controls {
        flex-direction: column;
    }

    .confidence-badge {
        margin-left: 0;
    }

    /* AI summary header: stack vertically so button doesn't overflow */
    .ai-summary-header {
        flex-wrap: wrap;
    }

    #generateSummaryBtn {
        width: 100%;     /* button takes full width on mobile */
    }

    /* Let the charts keep their own height. A fixed max-height cut off the legend. */
    .chart-card canvas {
        max-height: none;
    }

}

/* ─── Multi-page menu (Sprint 3) ─────────────────────────────────────────── */

.main-nav {
    display: flex;
    gap: 0.25rem;
    overflow-x: auto; /* on a phone the menu scrolls sideways instead of wrapping */
}

.nav-link {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    padding: 0 0.75rem;
    color: var(--color-text-muted);
    text-decoration: none;
    font-size: 0.9375rem;
    font-weight: 500;
    white-space: nowrap;
    border-bottom: 2px solid transparent;
    transition: color 0.15s ease, border-color 0.15s ease;
}

.nav-link:hover {
    color: var(--color-text);
    border-bottom-color: var(--color-border);
}

/* The current page: ink text with a 2px bar */
.nav-link[aria-current="page"] {
    color: var(--color-primary);
    font-weight: 700;
    border-bottom-color: var(--color-primary);
}

/* Skip link: hidden until the first Tab */
.skip-link {
    position: absolute;
    left: 0;
    top: 0;
    transform: translateY(-200%);
    background: var(--color-primary);
    color: white;
    padding: 0 1rem;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    border-radius: 6px;
    z-index: 400;
}

.skip-link:focus {
    transform: none;
}

/* Small link in a section heading, e.g. "View all" */
.section-link {
    color: var(--color-primary);
    font-size: 0.9rem;
    font-weight: 600;
}

/* Expense row without the edit and delete buttons (dashboard) */
.expense-item.no-actions {
    grid-template-columns: 1fr auto;
}

@media (max-width: 768px) {
    .header {
        flex-wrap: wrap;
        gap: 0.25rem 1rem;
    }

    .main-nav {
        order: 3;
        flex-basis: 100%;
        margin: 0 -0.75rem;
        padding: 0 0.75rem;
    }

}

/* ─── Profile page (Sprint 4) ────────────────────────────────────────────── */

.danger-zone {
    border: 1px solid var(--color-accent);
}

.danger-text {
    color: var(--color-text-muted);
    margin-bottom: 1.25rem;
}

/* ─── AI summary error and retry (Sprint 5) ───────────────────────────────── */

.ai-summary-error {
    margin-top: 0.75rem;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    background: #FDECEA;
    border: 1px solid var(--color-accent);
    color: #8A2E1C;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}

.ai-summary-error.hidden {
    display: none;
}

.ai-summary-error p {
    margin: 0;
}

/* ─── Inline AI hints (Sprint 6, SRS 2.6) ──────────────────────────────────── */

.ai-hint {
    font-size: 0.875rem;
    color: var(--color-text-muted);
    margin: 0.75rem 0;
    line-height: 1.5;
}

/* ─── Taste pass: focus, motion, phone ───────────────────────────────────── */

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible {
    outline: var(--focus);
    outline-offset: 2px;
}

.section-link {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    text-decoration: none;
    background: linear-gradient(currentColor, currentColor) 0 100% / 0 1px no-repeat;
    transition: background-size 0.2s ease;
}

.section-link:hover {
    background-size: 100% 1px;
}

/* On a phone the main button of a form fills the width */
@media (max-width: 640px) {
    .expense-form > .btn,
    .nl-controls .btn {
        align-self: stretch;
        width: 100%;
    }
}

/* Reduced motion: everything rests (the loading spinners stay, they show progress) */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        transition-duration: 0.01ms !important;
    }
    .toast { animation-duration: 0.01ms !important; }
}
