:root {
    --bg-primary: #f2f2f2;
    --bg-secondary: #ffffff;
    --text-primary: #212529;
    --text-secondary: #545454;
    --text-muted: #717171;
    --border-color: #dee2e6;
    --shadow: rgba(0, 0, 0, 0.1);
    --accent-color: #1FB846;
    --accent-hover: #1a9e3a;
    --button-bg: #1565c0;
    --button-hover: #0d47a1;
    --empty-icon-opacity: 0.5;

    /* Table specific colors */
    --positive-color: #1FB846;
    --negative-color: #c82333;
    --neutral-color: #000000;
    --hover-bg: #d4edda;
    --selected-bg: #d4edda;
    --accumulated-bg: #d4edda;
    --accumulated-border: #c3e6cb;
    --initial-balance-bg: #d4edda;
    --initial-balance-total-bg: #c3e6cb;
    --table-hover-bg: #f8f9fa;
    --table-header-bg: #f8f9fa;
    --table-header-hover-bg: #e9ecef;

    /* Local edit indicators */
    --edited-bg: #fffbea;
    --edited-bg-hover: #fff4cc;
    --edited-outline: rgb(243, 213, 16);

    /* Highlight color for UI elements */
    --highlight-color: #1FB846;
    --highlight-color-light: rgba(31, 184, 70, 0.1);

    /* Cashflow table row backgrounds */
    --bg-cashflow-table: #ffffff;
    --bg-cashflow-category: #f5f5f5;
    --bg-cashflow-subcategory: #ebebeb;
    --bg-cashflow-subsubcategory: #e0e0e0;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg-primary: #1a1a1a;
        --bg-secondary: #2d2d2d;
        --text-primary: #ffffff;
        --text-secondary: #c4c4c4;
        --text-muted: #9e9e9e;
        --border-color: #404040;
        --shadow: rgba(0, 0, 0, 0.3);
        --accent-color: #1FB846;
        --accent-hover: #25d050;
        --button-bg: #4299e1;
        --button-hover: #3182ce;
        --empty-icon-opacity: 0.3;

        /* Table specific colors for dark mode */
        --positive-color: #1FB846;
        --negative-color: #ef5350;
        --neutral-color: #ffffff;
        --hover-bg: #2d4a2d;
        --selected-bg: #2d4a2d;
        --accumulated-bg: #2d4a2d;
        --accumulated-border: #3d5a3d;
        --initial-balance-bg: #2d4a2d;
        --initial-balance-total-bg: #3d5a3d;

        /* Local edit indicators for dark mode */
        --edited-bg: #3d3418;
        --edited-bg-hover: #4d4420;
        --edited-outline: rgb(234, 179, 8);
        --table-hover-bg: #404040;
        --table-header-bg: #2d2d2d;
        --table-header-hover-bg: #404040;

        /* Highlight color for UI elements */
        --highlight-color: #1FB846;
        --highlight-color-light: rgba(31, 184, 70, 0.15);

        /* Cashflow table row backgrounds */
        --bg-cashflow-table: #2d2d2d;
        --bg-cashflow-category: #353535;
        --bg-cashflow-subcategory: #3d3d3d;
        --bg-cashflow-subsubcategory: #454545;
    }
}

html, body {
    height: 100dvh;
    margin: 0;
    padding: 0;
    overflow: hidden;
}

/* ── Landing Page ── */

#landing {
    height: 100dvh;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.landing-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 2rem;
    gap: 4rem;
}

.landing-hero {
    text-align: center;
    max-width: 600px;
}

.landing-title {
    font-size: 3.5rem;
    font-weight: 700;
    margin: 0 0 0.5rem;
    color: var(--accent-color);
    letter-spacing: -0.02em;
}

.landing-tagline {
    font-size: 1.5rem;
    font-weight: 500;
    color: var(--text-primary);
    margin: 0 0 1.25rem;
    line-height: 1.4;
}

.landing-description {
    font-size: 1.05rem;
    color: var(--text-secondary);
    margin: 0 0 2rem;
    line-height: 1.7;
    text-align: left;
}

#landing #apple-sign-in-button {
    position: static;
    display: flex;
    justify-content: center;
}

.landing-features {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 2rem;
    max-width: 860px;
    width: 100%;
}

.landing-feature {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 2rem 1.5rem;
    text-align: center;
}

.feature-icon {
    font-size: 2rem;
    margin-bottom: 0.75rem;
}

.landing-feature h3 {
    font-size: 1.05rem;
    font-weight: 600;
    margin: 0 0 0.5rem;
    color: var(--text-primary);
}

.landing-feature p {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin: 0;
    line-height: 1.6;
}

.landing-footer {
    border-top: 1px solid var(--border-color);
    padding: 1.5rem 2rem;
}

.landing-footer-content {
    text-align: center;
}

.landing-footer-links {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.landing-footer-links a {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.85rem;
    transition: color 0.15s ease;
}

.landing-footer-links a:hover {
    color: var(--accent-color);
}

.landing-footer-separator {
    color: var(--text-muted);
    font-size: 0.85rem;
}

.landing-footer-copy {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin: 0;
}

@media (max-width: 700px) {
    .landing-features {
        grid-template-columns: 1fr;
        max-width: 400px;
    }

    .landing-title {
        font-size: 2.5rem;
    }

    .landing-tagline {
        font-size: 1.2rem;
    }
}

body {
    font-family: ui-rounded, "SF Pro Rounded", -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    user-select: none;
    -webkit-user-select: none;
    -webkit-font-smoothing: antialiased;
}

.hidden {
    display: none !important;
}

/* ── Apple Sign In Button ── */

/* Prevent our CSS from interfering with CloudKit JS rendered button */
#apple-sign-in-button * {
    all: revert;
}

.apple-auth-button {
    display: grid !important;
    border-radius: 8px !important;
}

/* ── Main App Layout ── */

#app {
    position: relative;
    height: 100dvh;
    display: grid;
    grid-template-columns: 300px var(--cashflow-width, 1fr) var(--divider-width, 32px) var(--transactions-width, 1fr);
    grid-template-rows: 1fr auto;
    grid-template-areas:
        'widgets cashflow divider transactions'
        'footer footer footer footer';
    overflow: hidden;
    padding: 30px 30px 0 30px;
    box-sizing: border-box;
}

#widgetsPanel {
    grid-area: widgets;
    padding-right: 24px;
}

#pageFooter {
    grid-area: footer;
}

#cashflowTable {
    grid-area: cashflow;
}

#transactionsTable {
    grid-area: transactions;
}

/* Resize divider */
.resize-divider {
    grid-area: divider;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: col-resize;
    user-select: none;
    -webkit-user-select: none;
    z-index: 10;
}

.resize-handle {
    width: 4px;
    height: 48px;
    border-radius: 2px;
    background: var(--border-color);
    transition: background 0.15s ease, height 0.15s ease;
}

body.resizing {
    cursor: col-resize !important;
    user-select: none !important;
    -webkit-user-select: none !important;
}

body.resizing * {
    cursor: col-resize !important;
    pointer-events: none !important;
}

body.resizing .resize-divider,
body.resizing .resize-divider * {
    pointer-events: auto !important;
}

