/* ══════════════════════════════════════════════════════════════════
   Bayu – LevelHeads Design System
   ══════════════════════════════════════════════════════════════════ */

/* ── Brand tokens ────────────────────────────────────────────────── */

:root {
    /* Palette */
    --brand-yellow: #fcc953;
    --brand-dark: #2c1e10;
    --brand-bg: #faf8f5;
    --brand-surface: #ffffff;
    --brand-muted-surface: #f5f2ee;
    --brand-text: #1a1a1a;
    --brand-text-muted: #6b5f53;
    --brand-text-subtle: #555555;
    --brand-border-weak: #e3ddd5;
    --brand-border-strong: #3d2b1a;

    /* Typography */
    --font-display: "Montserrat", system-ui, sans-serif;
    --font-body: "Inter", system-ui, sans-serif;
    --font-mono: "IBM Plex Mono", ui-monospace, monospace;

    /* Effects */
    --shadow-card: 6px 6px 0 rgba(44, 30, 16, 0.10);
    --shadow-soft: 0 10px 30px rgba(44, 30, 16, 0.10);
    --shadow-sm: 0 1px 3px rgba(44, 30, 16, 0.08);

    /* Spacing scale */
    --space-1: 4px;  --space-2: 8px;  --space-3: 12px;
    --space-4: 16px; --space-5: 20px; --space-6: 24px;
    --space-8: 32px; --space-10: 40px; --space-12: 48px;

    /* Radii */
    --radius-sm: 4px; --radius-md: 6px; --radius-lg: 8px; --radius-xl: 12px;

    /* Transitions */
    --transition-fast: 0.2s ease-in-out;

    /* Density (comfortable defaults) */
    --density-row-height: 48px;
    --density-row-padding: 0.75rem 1rem;
    --density-card-padding: 1rem;
    --density-form-gap: 1rem;

    /* Semantic status (unchanged) */
    --color-paid: #2e7d32;
    --color-unpaid: #e65100;
    --color-late: #c62828;
    --color-disputed: #6a1b9a;
    --color-open: #1565c0;
    --color-in-progress: #f9a825;
    --color-resolved: #2e7d32;
    --color-escalated: #c62828;
    --color-supporting: #2e7d32;
    --color-contradicting: #c62828;
    --color-neutral: #757575;
    --color-create: #1565c0;
    --color-update: #f9a825;
    --color-delete: #c62828;
    --color-landlord-bg: #fff3e0;
    --color-ours-bg: #e8f5e9;
}

/* ── Pico overrides ──────────────────────────────────────────────── */

[data-theme="light"] {
    --pico-background-color: var(--brand-bg);
    --pico-color: var(--brand-text);
    --pico-primary: var(--brand-dark);
    --pico-primary-background: var(--brand-dark);
    --pico-primary-hover: #1a1108;
    --pico-primary-hover-background: #1a1108;
    --pico-primary-focus: rgba(252, 201, 83, 0.5);
    --pico-font-family: var(--font-body);
    --pico-border-radius: 6px;
    --pico-card-background-color: var(--brand-surface);
    --pico-card-border-color: var(--brand-border-weak);
    --pico-card-box-shadow: var(--shadow-card);
    --pico-form-element-active-border-color: var(--brand-yellow);
    --pico-muted-border-color: var(--brand-border-weak);
}

/* ── Selection ───────────────────────────────────────────────────── */

::selection {
    background: var(--brand-yellow);
    color: var(--brand-dark);
}

/* ── Base ────────────────────────────────────────────────────────── */

body {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    font-family: var(--font-body);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: geometricPrecision;
}

/* ── Global transitions on interactive elements ─────────────────────── */

a, button, [role="button"], input, select, textarea, .badge, .badge-filter {
    transition: all var(--transition-fast);
}

/* ── Scrollbar theming ──────────────────────────────────────────────── */

body, .table-responsive {
    scrollbar-width: thin;
    scrollbar-color: var(--brand-border-weak) transparent;
}

body::-webkit-scrollbar,
.table-responsive::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

body::-webkit-scrollbar-track,
.table-responsive::-webkit-scrollbar-track {
    background: transparent;
}

body::-webkit-scrollbar-thumb,
.table-responsive::-webkit-scrollbar-thumb {
    background: var(--brand-border-weak);
    border-radius: 3px;
}

body::-webkit-scrollbar-thumb:hover,
.table-responsive::-webkit-scrollbar-thumb:hover {
    background: var(--brand-text-muted);
}

main {
    flex: 1;
}

footer {
    text-align: center;
    padding: var(--space-6) 0;
    color: var(--brand-text-muted);
    font-size: 0.8rem;
    border-top: 1px solid var(--brand-border-weak);
    margin-top: var(--space-8);
    font-family: var(--font-display);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* ── Headings ────────────────────────────────────────────────────── */

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-display);
}

h1 { font-weight: 900; font-size: 1.75rem; letter-spacing: -0.02em; }
h2 { font-weight: 800; font-size: 1.35rem; letter-spacing: -0.01em; }
h3 { font-weight: 700; font-size: 1.05rem; }
h4 { font-weight: 700; font-size: 0.9rem; text-transform: uppercase; letter-spacing: 0.04em; }

/* ── Links ───────────────────────────────────────────────────────── */

a {
    color: var(--brand-dark);
}

a:hover {
    color: var(--brand-yellow);
    text-decoration-thickness: 2px;
    text-underline-offset: 2px;
}

/* ── Nav ─────────────────────────────────────────────────────────── */

nav {
    background: var(--brand-dark);
    padding: var(--space-2) var(--space-4);
}

nav ul:last-child {
    gap: var(--space-2);
}

nav a,
nav a:visited {
    color: rgba(255, 255, 255, 0.75);
    text-decoration: none;
}

nav a:hover {
    color: var(--brand-yellow);
}

nav a.active {
    color: var(--brand-dark);
    background: var(--brand-yellow);
    padding: 0.2rem 0.6rem;
    border-radius: var(--radius-sm);
    border-bottom: none;
    font-weight: 700;
    text-decoration: none;
}

nav li strong {
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 1.1rem;
}

nav li strong a,
nav li strong a:visited {
    color: #ffffff;
}

nav small {
    color: rgba(255, 255, 255, 0.6);
}

nav .btn-sm,
nav [role="button"].outline.secondary {
    color: rgba(255, 255, 255, 0.7);
    border-color: rgba(255, 255, 255, 0.3);
    background: transparent;
    padding: 0.25rem 0.5rem;
    font-size: 0.8rem;
    font-family: var(--font-display);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

nav .btn-sm:hover,
nav [role="button"].outline.secondary:hover {
    color: var(--brand-dark);
    background: var(--brand-yellow);
    border-color: var(--brand-yellow);
}

.btn-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.8rem;
}

.input-sm {
    padding: 0.2rem 0.4rem;
    width: 5rem;
    display: inline-block;
}

/* ── Buttons ─────────────────────────────────────────────────────── */

button,
[role="button"],
input[type="submit"],
input[type="button"] {
    font-family: var(--font-display);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    border-width: 3px;
    box-shadow: 4px 4px 0 rgba(44, 30, 16, 0.10);
}

button:hover,
[role="button"]:hover,
input[type="submit"]:hover,
input[type="button"]:hover {
    background: var(--brand-yellow);
    border-color: var(--brand-dark);
    color: var(--brand-dark);
    transform: translateY(-2px);
    box-shadow: var(--shadow-soft);
}

button:active,
[role="button"]:active,
input[type="submit"]:active {
    transform: translateY(0);
    box-shadow: 2px 2px 0 rgba(44, 30, 16, 0.10);
}

/* ── Button variants ────────────────────────────────────────────── */

.btn-primary {
    background: var(--brand-dark);
    color: #ffffff;
    border-color: var(--brand-dark);
}

.btn-primary:hover {
    background: var(--brand-yellow);
    color: var(--brand-dark);
    border-color: var(--brand-dark);
}

.btn-secondary {
    background: var(--brand-surface);
    color: var(--brand-dark);
    border-color: var(--brand-border-strong);
}

.btn-secondary:hover {
    background: var(--brand-dark);
    color: #ffffff;
    border-color: var(--brand-dark);
}

.btn-ghost {
    background: transparent;
    color: var(--brand-dark);
    border-color: transparent;
    box-shadow: none;
}

.btn-ghost:hover {
    background: var(--brand-muted-surface);
    color: var(--brand-dark);
    border-color: transparent;
    box-shadow: none;
}

.btn-ghost:active {
    box-shadow: none;
}

.btn-danger {
    background: var(--color-late);
    color: #ffffff;
    border-color: var(--color-late);
}

.btn-danger:hover {
    background: #a31f1f;
    color: #ffffff;
    border-color: #a31f1f;
}

/* ── Empty states ───────────────────────────────────────────────── */

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--space-12) var(--space-6);
    text-align: center;
    background: var(--brand-muted-surface);
    border-radius: var(--radius-xl);
    border: 1px dashed var(--brand-border-weak);
}

.empty-state-icon {
    font-size: 56px;
    opacity: 0.3;
    margin-bottom: var(--space-4);
    line-height: 1;
}

.empty-state p {
    color: var(--brand-text-muted);
    margin-bottom: var(--space-4);
    font-size: 0.95rem;
}

.empty-state a[role="button"],
.empty-state .btn-primary {
    margin-top: var(--space-2);
}

/* ── Loading spinner ────────────────────────────────────────────── */

.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--brand-border-weak);
    border-top-color: var(--brand-yellow);
    border-radius: 50%;
    animation: spinner-rotate 0.6s linear infinite;
    margin: var(--space-6) auto;
}

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

/* ── Flash message animation ────────────────────────────────────── */

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

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

.flash {
    animation: flash-in 0.3s ease-out;
}

.flash.flash-dismissing {
    animation: flash-out 0.3s ease-in forwards;
}

/* ── Modal system ───────────────────────────────────────────────── */

.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 2000;
    background: rgba(44, 30, 16, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity var(--transition-fast);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}

.modal-overlay.active {
    opacity: 1;
}

.modal-content {
    background: var(--brand-surface);
    border: 3px solid var(--brand-dark);
    border-radius: var(--radius-lg);
    padding: var(--space-8);
    box-shadow: var(--shadow-soft);
    max-width: 420px;
    width: 90%;
    transform: translateY(16px);
    transition: transform var(--transition-fast);
}

.modal-overlay.active .modal-content {
    transform: translateY(0);
}

.modal-content p {
    font-size: 1rem;
    margin-bottom: var(--space-6);
}

.modal-actions {
    display: flex;
    gap: var(--space-3);
    justify-content: flex-end;
}

/* ── Side panel ─────────────────────────────────────────────────── */

.side-panel-overlay {
    position: fixed;
    inset: 0;
    z-index: 1500;
    background: rgba(44, 30, 16, 0.4);
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-fast);
}

.side-panel-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.side-panel {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 1501;
    width: 420px;
    max-width: 90vw;
    background: var(--brand-surface);
    border-left: 3px solid var(--brand-dark);
    box-shadow: -8px 0 30px rgba(44, 30, 16, 0.15);
    transform: translateX(100%);
    transition: transform var(--transition-fast);
    overflow-y: auto;
    padding: var(--space-6);
}

.side-panel.active {
    transform: translateX(0);
}

.side-panel-close {
    position: absolute;
    top: var(--space-3);
    right: var(--space-3);
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--brand-text-muted);
    box-shadow: none;
    padding: var(--space-1);
    text-transform: none;
    line-height: 1;
}

.side-panel-close:hover {
    color: var(--brand-dark);
    background: none;
    box-shadow: none;
}

.side-panel-close:active {
    transform: none;
    box-shadow: none;
}

.side-panel-body {
    margin-top: var(--space-8);
}

/* ── Cards / Articles ────────────────────────────────────────────── */

article {
    border: 3px solid var(--brand-dark);
    border-radius: var(--radius-xl);
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

article:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-soft);
}

article.card-static,
article.card-static:hover {
    transform: none;
    box-shadow: var(--shadow-card);
}

article > header {
    margin: calc(-1 * var(--pico-block-spacing-vertical)) calc(-1 * var(--pico-block-spacing-horizontal)) var(--space-4) calc(-1 * var(--pico-block-spacing-horizontal));
    padding: var(--space-3) var(--space-4);
    background: var(--brand-muted-surface);
    border-bottom: 2px solid var(--brand-border-weak);
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
}

/* ── Flash messages ──────────────────────────────────────────────── */

.flash {
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-4);
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: 2px solid;
}

.flash-success { background: #e8f5e9; color: #2e7d32; border-color: #2e7d32; }
.flash-error   { background: #fbe9e7; color: #c62828; border-color: #c62828; }
.flash-info    { background: #e3f2fd; color: #1565c0; border-color: #1565c0; }

.flash-close {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0 0.5rem;
    color: inherit;
    box-shadow: none;
    text-transform: none;
}

.flash-close:hover {
    background: none;
    box-shadow: none;
    opacity: 0.6;
}

/* ── Page header ─────────────────────────────────────────────────── */

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-6);
    padding-bottom: var(--space-4);
    border-bottom: 2px solid var(--brand-border-weak);
    flex-wrap: wrap;
    gap: var(--space-4);
}

.page-header h2 { margin: 0; }

.page-header div {
    display: flex;
    gap: var(--space-2);
    align-items: center;
}

/* ── Login (Dispatch-style) ───────────────────────────────────────── */

.login-body {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    background:
        radial-gradient(ellipse 80% 80% at 20% 80%, rgba(252, 201, 83, 0.25) 0%, transparent 60%),
        radial-gradient(ellipse 60% 60% at 80% 20%, rgba(44, 30, 16, 0.08) 0%, transparent 50%),
        var(--brand-bg);
    padding: var(--space-6);
}

.login-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

.login-card {
    max-width: 420px;
    width: 90%;
    border: 3px solid var(--brand-dark);
    box-shadow: var(--shadow-card);
    padding: 40px 44px 36px;
    text-align: center;
    animation: fade-in 0.4s ease-out;
}

.login-logo {
    margin-bottom: var(--space-4);
}

.login-logo-img {
    width: 100px;
    height: 100px;
    animation: login-bounce 0.6s ease-out;
}

@keyframes login-bounce {
    0% { transform: translateY(-12px); opacity: 0; }
    50% { transform: translateY(4px); opacity: 1; }
    100% { transform: translateY(0); }
}

.login-title {
    font-family: var(--font-display);
    font-size: 1.25rem;
    font-weight: 800;
    letter-spacing: -0.01em;
    color: var(--brand-text-muted);
    margin-bottom: var(--space-1);
}

.login-brand {
    color: var(--brand-dark);
}

.login-subtitle {
    color: var(--brand-text-muted);
    font-size: 0.9rem;
    margin-bottom: var(--space-6);
}

.login-card form {
    text-align: left;
}

.login-card label {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    color: var(--brand-text-muted);
}

.login-btn {
    width: 100%;
    height: 48px;
    font-size: 0.95rem;
    margin-top: var(--space-3);
    background: var(--brand-dark);
    color: #ffffff;
    border-color: var(--brand-dark);
}

.login-btn:hover {
    background: var(--brand-yellow);
    color: var(--brand-dark);
    border-color: var(--brand-dark);
    transform: translateY(-2px);
    box-shadow: var(--shadow-card);
}

.login-btn:active {
    transform: translateY(0);
    box-shadow: none;
}

.login-error {
    background: #fef2f2;
    color: #b91c1c;
    border: 1px solid #fecaca;
    border-radius: var(--radius-md);
    padding: var(--space-3);
    font-size: 0.85rem;
    margin-bottom: var(--space-4);
    text-align: left;
}

.login-footer {
    margin-top: var(--space-6);
    color: var(--brand-text-muted);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    opacity: 0.6;
}

@media (max-width: 768px) {
    .login-card {
        padding: 32px 28px 28px;
    }

    .login-logo-img {
        width: 80px;
        height: 80px;
    }
}

/* ── Badges ──────────────────────────────────────────────────────── */

.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.6rem;
    border-radius: 10px;
    font-size: 0.7rem;
    font-weight: 700;
    font-family: var(--font-display);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: white;
    min-height: 22px;
}

.badge-paid, .badge-resolved, .badge-supporting  { background: var(--color-paid); }
.badge-unpaid                                      { background: var(--color-unpaid); }
.badge-late, .badge-escalated, .badge-contradicting { background: var(--color-late); }
.badge-disputed                                    { background: var(--color-disputed); }
.badge-open                                        { background: var(--color-open); }
.badge-in_progress, .badge-in-progress             { background: var(--brand-dark); color: var(--brand-yellow); }
.badge-neutral                                     { background: var(--color-neutral); }
.badge-create                                      { background: var(--color-create); }
.badge-update                                      { background: var(--color-update); color: var(--brand-dark); }
.badge-delete                                      { background: var(--color-delete); }

.badge-filter {
    background: var(--brand-muted-surface);
    color: var(--brand-text-muted);
    border: 2px solid var(--brand-border-weak);
    text-decoration: none;
    cursor: pointer;
    padding: 0.35rem 0.75rem;
    font-size: 0.75rem;
}

.badge-filter.active {
    background: var(--brand-dark);
    color: var(--brand-yellow);
    border-color: var(--brand-dark);
}

/* ── Amounts ─────────────────────────────────────────────────────── */

.amount {
    font-family: var(--font-mono);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

/* ── Tables ──────────────────────────────────────────────────────── */

.table-responsive {
    overflow-x: auto;
}

table {
    border: 2px solid var(--brand-dark);
    border-collapse: collapse;
}

table td, table th {
    padding: 10px 12px;
}

table td {
    border-bottom: 1px solid var(--brand-border-weak);
}

table thead th {
    background: var(--brand-dark);
    color: var(--brand-yellow);
    font-family: var(--font-display);
    font-weight: 700;
    text-transform: uppercase;
    font-size: 0.8rem;
    letter-spacing: 0.03em;
}

table tbody tr {
    transition: background var(--transition-fast);
}

table tbody tr:hover {
    background: var(--brand-muted-surface);
}

tr.status-disputed { border-left: 3px solid var(--color-disputed); }
tr.status-late     { border-left: 3px solid var(--color-late); }
tr.status-unpaid   { border-left: 3px solid var(--color-unpaid); }

/* ── Forms ────────────────────────────────────────────────────────── */

input, select, textarea {
    font-size: 16px;
    border: 1px solid var(--brand-border-weak);
}

input:focus-visible, select:focus-visible, textarea:focus-visible {
    border-color: var(--brand-yellow);
    outline: 2px solid var(--brand-yellow);
    outline-offset: 1px;
    box-shadow: none;
}

label {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--brand-text-subtle);
}

.form-actions {
    display: flex;
    gap: var(--space-2);
    margin-top: var(--space-4);
}

.inline-form {
    display: inline;
}

.filter-bar {
    display: flex;
    gap: var(--space-2);
    margin-bottom: var(--space-6);
    flex-wrap: wrap;
}

details.filters-panel {
    background: var(--brand-muted-surface);
    border-radius: var(--radius-lg);
    padding: var(--space-4);
    border: 1px solid var(--brand-border-weak);
    margin-bottom: var(--space-6);
}

.filters-panel summary {
    font-family: var(--font-display);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    font-size: 0.85rem;
}

/* ── Proof ────────────────────────────────────────────────────────── */

.proof-item {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: 0.25rem 0;
}

.proof-card {
    margin-bottom: var(--space-2);
}

.proof-thumb {
    max-width: 200px;
    max-height: 150px;
    border-radius: var(--radius-md);
    border: 2px solid var(--brand-border-weak);
}

.proof-file {
    display: inline-block;
    padding: var(--space-2) var(--space-4);
    background: var(--brand-muted-surface);
    border-radius: var(--radius-md);
}

.proof-badge {
    display: inline-block;
    background: #e3f2fd;
    color: #1565c0;
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 700;
    font-family: var(--font-display);
}

.dropzone-input {
    border: 2px dashed var(--brand-border-weak);
    padding: var(--space-4);
    border-radius: var(--radius-md);
    transition: border-color 0.2s, background 0.2s;
}

.dropzone-input.dragover {
    border-color: var(--brand-yellow);
    background: rgba(252, 201, 83, 0.1);
}

/* ── Disputes ────────────────────────────────────────────────────── */

.disputes-grid {
    display: grid;
    gap: var(--space-4);
}

.dispute-card header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.dispute-comparison {
    gap: var(--space-6);
}

.claim {
    padding: var(--space-4);
    border-radius: var(--radius-md);
}

.landlord-claim {
    background: var(--color-landlord-bg);
    border-left: 4px solid #e65100;
}

.our-response {
    background: var(--color-ours-bg);
    border-left: 4px solid #2e7d32;
}

.evidence-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

.evidence-item {
    padding: var(--space-3);
    border-radius: var(--radius-md);
    background: var(--brand-muted-surface);
    display: flex;
    align-items: center;
    gap: var(--space-3);
    flex-wrap: wrap;
}

.evidence-supporting  { border-left: 3px solid var(--color-supporting); }
.evidence-contradicting { border-left: 3px solid var(--color-contradicting); }
.evidence-neutral     { border-left: 3px solid var(--color-neutral); }

/* ── Timeline ────────────────────────────────────────────────────── */

.timeline-container {
    border: 3px solid var(--brand-dark);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.timeline-header {
    background: var(--brand-dark);
    color: var(--brand-yellow);
    padding: var(--space-3) var(--space-4);
    border-bottom: none;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.timeline-row {
    display: grid;
    grid-template-columns: 1fr 1.5fr 1.5fr 0.8fr;
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--brand-border-weak);
    transition: background 0.2s;
}

.timeline-row:hover {
    background: var(--brand-muted-surface);
}

.timeline-row.has-dispute {
    background: rgba(252, 201, 83, 0.10);
}

.timeline-row.status-disputed {
    background: #f3e5f5;
}

.timeline-col {
    padding: 0 0.5rem;
}

.timeline-date .category-tag {
    display: block;
    font-size: 0.8rem;
    color: var(--brand-text-muted);
    font-family: var(--font-display);
    font-weight: 700;
}

.timeline-fact {
    padding: 0.25rem 0;
}

.timeline-fact .indicator {
    font-weight: 600;
}

.timeline-fact.paid .indicator { color: var(--color-paid); }
.timeline-fact.unpaid .indicator { color: var(--color-unpaid); }

.timeline-claim p {
    margin: 0.25rem 0;
    font-size: 0.9rem;
}

.our-counter {
    margin-top: var(--space-2);
    padding: var(--space-2);
    background: var(--color-ours-bg);
    border-radius: var(--radius-md);
}

.no-dispute {
    color: var(--brand-text-muted);
    font-style: italic;
}

.timeline-legend {
    margin-top: var(--space-6);
    display: flex;
    gap: var(--space-2);
    align-items: center;
    flex-wrap: wrap;
}

.timeline-filters {
    margin-bottom: var(--space-6);
    align-items: end;
}

.print-actions {
    margin-top: var(--space-6);
    text-align: center;
}

/* ── Dashboard ───────────────────────────────────────────────────── */

.stats-grid {
    margin-bottom: var(--space-6);
}

.stat-card {
    text-align: center;
    border: 3px solid var(--brand-dark);
}

.stat-card header {
    font-family: var(--font-display);
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--brand-text-muted);
}

.stat-value {
    font-family: var(--font-display);
    font-size: 2rem;
    font-weight: 900;
    margin: 0;
    color: var(--brand-dark);
}

.bar-chart {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.bar-row {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.bar-label {
    min-width: 100px;
    font-size: 0.85rem;
    text-align: right;
}

.bar-track {
    flex: 1;
    height: 24px;
    background: var(--brand-muted-surface);
    border-radius: 4px;
    overflow: hidden;
}

.bar-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.6s ease;
    min-width: 2px;
}

.bar-value {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    min-width: 70px;
}

/* ── Action group ────────────────────────────────────────────────── */

.action-group {
    display: flex;
    gap: var(--space-2);
    align-items: center;
    flex-wrap: wrap;
}

.generate-form {
    display: inline-flex;
    gap: 0.25rem;
    align-items: center;
}

/* ── Audit ────────────────────────────────────────────────────────── */

code {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    word-break: break-all;
}

/* ── Description list ────────────────────────────────────────────── */

dl {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.25rem 1rem;
}

dt {
    font-family: var(--font-display);
    font-weight: 700;
    text-transform: uppercase;
    color: var(--brand-text-muted);
    font-size: 0.8rem;
    letter-spacing: 0.02em;
}

dd {
    margin: 0;
}

/* ── Print ────────────────────────────────────────────────────────── */

@media print {
    nav, footer, .print-actions, .timeline-filters, .page-header a,
    .page-header form, .btn-sm, button { display: none !important; }

    * { box-shadow: none !important; }

    .timeline-container { border: 2px solid #000; }
    .timeline-row { break-inside: avoid; border-bottom: 1px solid #ccc; }
    .badge { border: 1px solid currentColor; }

    table thead th {
        print-color-adjust: exact;
        -webkit-print-color-adjust: exact;
    }

    .timeline-header {
        print-color-adjust: exact;
        -webkit-print-color-adjust: exact;
    }

    body { font-size: 10pt; }
}

/* ── Calendar ────────────────────────────────────────────────────── */

.calendar-week {
    margin-bottom: var(--space-8);
}

.week-heading {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--brand-text-muted);
    border-bottom: 2px solid var(--brand-border-weak);
    padding-bottom: 0.5rem;
    margin-bottom: 0.75rem;
}

.calendar-event {
    display: flex;
    align-items: flex-start;
    gap: var(--space-4);
    padding: var(--space-3);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-2);
    border-left: 4px solid var(--brand-border-weak);
    background: var(--brand-surface);
    transition: background 0.2s;
}

.calendar-event:hover {
    background: var(--brand-muted-surface);
}

.calendar-event.category-cleaning { border-left-color: #4caf50; }
.calendar-event.category-pet      { border-left-color: #ff9800; }
.calendar-event.category-maintenance { border-left-color: #2196f3; }
.calendar-event.category-errand   { border-left-color: #9c27b0; }
.calendar-event.category-general  { border-left-color: var(--brand-dark); }

.calendar-event.pet-due {
    background: #fff8e1;
}

.event-date-col {
    min-width: 90px;
    text-align: center;
    font-family: var(--font-mono);
    font-size: 0.85rem;
}

.event-date-col small {
    display: block;
    color: var(--brand-text-muted);
}

.event-body {
    flex: 1;
}

.event-title {
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.event-desc {
    display: block;
    color: var(--brand-text-muted);
    font-size: 0.85rem;
}

.event-assigned {
    display: block;
    color: var(--brand-text-muted);
    font-size: 0.8rem;
    font-style: italic;
}

.event-actions {
    display: flex;
    gap: 0.25rem;
    align-items: center;
    flex-shrink: 0;
}

/* Event category badges */
.badge-general     { background: var(--brand-dark); }
.badge-cleaning    { background: #4caf50; }
.badge-pet         { background: #ff9800; color: var(--brand-dark); }
.badge-maintenance { background: #2196f3; }
.badge-errand      { background: #9c27b0; }
.badge-upcoming    { background: var(--color-open); }
.badge-done        { background: var(--color-paid); }
.badge-cancelled   { background: var(--color-neutral); }

/* ── Pets ────────────────────────────────────────────────────────── */

.pets-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: var(--space-4);
}

.pet-card {
    border: 3px solid var(--brand-dark);
}

.pet-card h3 { margin: 0; }

.pet-card .form-actions { margin-top: var(--space-2); }

.pet-card header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.pet-profile {
    border: 3px solid var(--brand-dark);
    margin-bottom: var(--space-6);
}

.records-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

.record-item {
    padding: var(--space-3);
    border-radius: var(--radius-md);
    background: var(--brand-surface);
    border: 1px solid var(--brand-border-weak);
    border-left: 4px solid var(--brand-border-weak);
}

.record-item.record-vet_visit     { border-left-color: #2196f3; }
.record-item.record-vaccination   { border-left-color: #4caf50; }
.record-item.record-medication    { border-left-color: #ff9800; }
.record-item.record-weight        { border-left-color: #9c27b0; }
.record-item.record-grooming      { border-left-color: #e91e63; }

.record-header {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    flex-wrap: wrap;
    margin-bottom: 0.25rem;
}

.record-date {
    color: var(--brand-text-muted);
    font-family: var(--font-mono);
    font-size: 0.8rem;
    margin-left: auto;
}

.record-desc {
    font-size: 0.9rem;
    color: var(--brand-text-muted);
    margin: 0.25rem 0;
}

.record-meta {
    display: flex;
    gap: var(--space-4);
    flex-wrap: wrap;
    margin-bottom: var(--space-2);
}

.record-meta small {
    color: var(--brand-text-muted);
    font-size: 0.8rem;
}

.record-due strong {
    color: var(--color-unpaid);
}

.badge-record-vet_visit     { background: #2196f3; }
.badge-record-vaccination   { background: #4caf50; }
.badge-record-medication    { background: #ff9800; color: var(--brand-dark); }
.badge-record-weight        { background: #9c27b0; }
.badge-record-grooming      { background: #e91e63; }

/* ── Settings ────────────────────────────────────────────────────── */

/* Settings page uses existing article/card styles — no additional rules needed */

/* ── Hamburger toggle ───────────────────────────────────────────── */

.hamburger-toggle {
    display: none;
    flex-direction: column;
    gap: 4px;
    background: none;
    border: none;
    padding: var(--space-2);
    cursor: pointer;
    box-shadow: none;
    text-transform: none;
    letter-spacing: 0;
}

.hamburger-toggle span {
    display: block;
    width: 20px;
    height: 2px;
    background: rgba(255, 255, 255, 0.75);
    border-radius: 1px;
    transition: all var(--transition-fast);
}

.hamburger-toggle:hover span {
    background: var(--brand-yellow);
}

.hamburger-toggle:hover {
    background: none;
    box-shadow: none;
}

.hamburger-toggle:active {
    transform: none;
    box-shadow: none;
}

.hamburger-menu {
    background: var(--brand-dark);
    border-bottom: 2px solid var(--brand-yellow);
    padding: var(--space-3) var(--space-4);
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.hamburger-menu[hidden] {
    display: none;
}

.hamburger-menu a {
    color: rgba(255, 255, 255, 0.75);
    text-decoration: none;
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-md);
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 0.9rem;
}

.hamburger-menu a:hover,
.hamburger-menu a.active {
    color: var(--brand-yellow);
    background: rgba(252, 201, 83, 0.1);
}

/* ── Mobile bottom nav ──────────────────────────────────────────── */

.mobile-bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background: var(--brand-dark);
    border-top: 2px solid var(--brand-yellow);
    padding: var(--space-2) 0;
    padding-bottom: calc(var(--space-2) + env(safe-area-inset-bottom, 0px));
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    justify-content: space-around;
    align-items: center;
}

.mobile-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    color: rgba(255, 255, 255, 0.6);
    text-decoration: none;
    font-size: 0.65rem;
    font-family: var(--font-display);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    min-width: 44px;
    min-height: 44px;
    justify-content: center;
    padding: var(--space-1);
}

.mobile-nav-item:hover,
.mobile-nav-item.active {
    color: var(--brand-yellow);
}

.mobile-nav-item svg {
    width: 20px;
    height: 20px;
}

/* ── Responsive ──────────────────────────────────────────────────── */

/* Tablet breakpoint */
@media (max-width: 1024px) {
    nav .nav-links {
        gap: var(--space-1);
    }

    nav .nav-links a {
        font-size: 0.85rem;
    }

    .nav-display-name {
        display: none;
    }
}

/* Mobile breakpoint */
@media (max-width: 768px) {
    .nav-links {
        display: none !important;
    }

    .nav-user {
        display: none !important;
    }

    .hamburger-toggle {
        display: flex;
    }

    .mobile-bottom-nav {
        display: flex;
    }

    main {
        padding-bottom: 80px;
    }

    .timeline-row {
        grid-template-columns: 1fr;
        gap: var(--space-2);
    }

    .timeline-header { display: none; }

    .timeline-col::before {
        content: attr(data-label);
        display: block;
        font-family: var(--font-display);
        font-weight: 700;
        font-size: 0.7rem;
        text-transform: uppercase;
        letter-spacing: 0.02em;
        color: var(--brand-text-muted);
        margin-bottom: 0.25rem;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
    }

    dl {
        grid-template-columns: 1fr;
    }

    dt { margin-top: 0.5rem; }

    .calendar-event {
        flex-direction: column;
        gap: var(--space-2);
    }

    .event-date-col {
        text-align: left;
    }

    .event-actions {
        width: 100%;
    }

    .pets-grid {
        grid-template-columns: 1fr;
    }

    .record-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .record-date {
        margin-left: 0;
    }

    .side-panel {
        width: 90vw;
    }
}

/* ── Skip link ──────────────────────────────────────────────────── */

.skip-link {
    position: absolute;
    top: -100%;
    left: var(--space-4);
    background: var(--brand-yellow);
    color: var(--brand-dark);
    padding: var(--space-2) var(--space-4);
    border-radius: 0 0 var(--radius-md) var(--radius-md);
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 0.85rem;
    text-decoration: none;
    z-index: 3000;
    transition: top var(--transition-fast);
}

.skip-link:focus {
    top: 0;
}

/* ── Focus-visible ring system ──────────────────────────────────── */

a:focus-visible,
button:focus-visible,
[role="button"]:focus-visible,
[role="tab"]:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
.badge-filter:focus-visible,
summary:focus-visible {
    outline: 2px solid var(--brand-yellow);
    outline-offset: 2px;
}

a:focus:not(:focus-visible),
button:focus:not(:focus-visible),
[role="button"]:focus:not(:focus-visible),
[role="tab"]:focus:not(:focus-visible),
input:focus:not(:focus-visible),
select:focus:not(:focus-visible),
textarea:focus:not(:focus-visible),
.badge-filter:focus:not(:focus-visible),
summary:focus:not(:focus-visible) {
    outline: none;
}

/* ── Density: compact mode ──────────────────────────────────────── */

body.density-compact {
    --density-row-height: 36px;
    --density-row-padding: 0.4rem 0.75rem;
    --density-card-padding: 0.75rem;
    --density-form-gap: 0.5rem;
}

body.density-compact article {
    padding: var(--density-card-padding);
}

body.density-compact .timeline-row {
    padding: var(--density-row-padding);
}

body.density-compact .calendar-event {
    padding: var(--density-row-padding);
}

body.density-compact table td,
body.density-compact table th {
    padding: 0.35rem 0.5rem;
}

body.density-compact .form-actions {
    gap: var(--density-form-gap);
}

/* Density toggle buttons */
.density-toggle {
    display: inline-flex;
    gap: var(--space-2);
    margin-top: var(--space-3);
}

.density-toggle button {
    font-size: 0.8rem;
    padding: var(--space-2) var(--space-4);
}

.density-toggle button.active {
    background: var(--brand-dark);
    color: var(--brand-yellow);
    border-color: var(--brand-dark);
}

/* ── Entrance animations ────────────────────────────────────────── */

@keyframes fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slide-in-up {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes scale-in {
    from {
        opacity: 0;
        transform: scale(0.85);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.badge {
    animation: scale-in 0.2s ease-out;
}

article {
    animation: fade-in 0.3s ease-out;
}

.calendar-event {
    animation: slide-in-up 0.25s ease-out;
}

/* ── Reduced motion ─────────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}
