:root {
    --et-accent: #0f766e;
    --et-accent-hover: #0d9488;
    --et-accent-muted: #ccfbf1;
    --et-coin: #fbbf24;
    --et-coin-dark: #d97706;
    --et-sidebar: #0f172a;
    --et-sidebar-hover: rgba(255, 255, 255, 0.08);
    --et-sidebar-active: #0f766e;
    --et-sidebar-text: #cbd5e1;
    --et-canvas: #f8fafc;
    --et-card: #ffffff;
    --et-border: #e2e8f0;
    --et-text: #0f172a;
    --et-muted: #64748b;
    --et-shadow: 0 1px 2px rgba(15, 23, 42, 0.06), 0 8px 24px rgba(15, 23, 42, 0.04);
    --rz-primary: #0f766e;
    --rz-primary-dark: #115e59;
    --rz-primary-light: #14b8a6;
    --rz-success: #0f766e;
}

html, body {
    height: 100%;
    background: var(--et-canvas);
    -webkit-text-size-adjust: 100%;
    color: var(--et-text);
    font-family: "Segoe UI", "Helvetica Neue", Helvetica, Arial, sans-serif;
}

.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.page-header h1 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 650;
    letter-spacing: -0.02em;
}

.page-subtitle {
    margin: 0.35rem 0 0;
    color: var(--et-muted);
    font-size: 0.95rem;
}

.empty-copy {
    margin: 0;
    padding: 0.5rem;
}

.page-header-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

.content-card {
    background: var(--et-card);
    border: 1px solid var(--et-border);
    border-radius: 12px;
    box-shadow: var(--et-shadow);
    overflow: hidden;
    padding: 0.75rem;
}

/* Pages that fill the viewport: the card stretches to the bottom of the
   content area and the grid body owns the scrolling instead of the page. */
.content:has(.page-fill) {
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

.content:has(.page-fill) .page-header {
    flex-shrink: 0;
}

.page-fill {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.page-fill > .rz-data-grid {
    flex: 1;
    min-height: 0;
}

/* Radzen already makes .rz-data-grid a flex column whose data area scrolls;
   it only needs a bounded height to do so. */
.page-fill > .rz-data-grid > .rz-data-grid-data {
    /* same automatic-minimum-size trap one level down: without min-height the
       data area grows to its content instead of scrolling. */
    min-height: 0;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

/* Two wide cards read better than two narrow ones stranded in a 3-up grid. */
.stat-grid-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

/* Period pickers live inside the card of the chart they filter, so it is obvious
   which chart they apply to. They wrap instead of shrinking: a phone stacks them
   rather than squeezing three dropdowns onto one line. */
.card-filter-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.6rem;
    padding: 0.15rem 0.15rem 0.85rem;
    margin-bottom: 0.75rem;
    border-bottom: 1px solid var(--et-border);
}

/* The chart sizes itself in px (it grows with the number of bars), so the card
   only has to stop the SVG from touching the border. */
.content-card.chart-card {
    padding: 0.9rem 0.75rem 0.5rem;
}

.stat-card {
    background: var(--et-card);
    border: 1px solid var(--et-border);
    border-radius: 12px;
    box-shadow: var(--et-shadow);
    padding: 1.1rem 1.25rem;
}

.stat-card .stat-label {
    color: var(--et-muted);
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.stat-card .stat-value {
    display: block;
    margin-top: 0.35rem;
    font-size: 1.6rem;
    font-weight: 700;
    letter-spacing: -0.03em;
}

.stat-card .stat-hint {
    margin: 0.25rem 0 0;
    color: var(--et-muted);
    font-size: 0.85rem;
}

.shortcut-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.shortcut-card {
    display: block;
    background: var(--et-card);
    border: 1px solid var(--et-border);
    border-radius: 12px;
    box-shadow: var(--et-shadow);
    padding: 1rem 1.15rem;
    color: var(--et-text);
    text-decoration: none;
    transition: border-color 0.15s ease, transform 0.15s ease;
}

.shortcut-card:hover {
    border-color: var(--et-accent);
    color: var(--et-text);
    transform: translateY(-1px);
}

.shortcut-card strong {
    display: block;
    font-size: 0.95rem;
}

/* Grouping on the expenses list is fixed (year-month), so the drag-to-group
   panel Radzen shows when AllowGrouping is on would only be noise. */
.grid-fixed-grouping .rz-group-header {
    display: none;
}

.grid-fixed-grouping .group-month,
.grid-fixed-grouping .group-word {
    font-weight: 650;
}

.grid-fixed-grouping .group-count {
    margin-inline-start: 0.6rem;
    color: var(--et-muted);
    font-size: 0.85em;
    font-weight: 400;
}

/* The theme sets `.rz-grid-table { width: 100% }` and `table-layout: fixed`,
   which squeezes the declared column widths down to whatever space there is
   rather than overflowing - so on a narrow screen the columns are clipped and
   the data area has nothing to scroll. A page that needs its columns to keep
   their width sets --grid-min-width (the sum of them) on the card; the table
   then grows past the viewport and the data area scrolls.
   Selector is deliberately two classes deep: the theme link is injected at
   interactive render time and can end up after this file, so an equally
   specific `.rz-grid-table` rule would lose the cascade. */
.rz-data-grid .rz-grid-table {
    min-width: var(--grid-min-width, 100%);
}

.cell-subtle {
    color: var(--et-muted);
    font-size: 0.8em;
}

/* one translation of a word, in the words fly-out: the rule separates a row from
   the next one, so the notes field is read as belonging to the translation above it
   rather than to the pane. */
.translation-row + .translation-row {
    padding-top: 0.9rem;
    border-top: 1px solid var(--et-border);
}

/* the practice prompt: one word at a time, so the card is narrow and centred and the
   word itself is the largest thing on the page. */
.practice-card {
    max-width: 32rem;
    margin: 0 auto;
    padding: 0.5rem 0;
}

.practice-word {
    color: var(--et-text);
    font-size: 1.9rem;
    font-weight: 650;
    line-height: 1.2;
    text-align: center;
    overflow-wrap: anywhere;
}

.section-title {
    margin: 0 0 0.75rem;
    color: var(--et-text);
    font-size: 0.95rem;
    font-weight: 650;
}

/* app brand lockup: sidebar (dark) and public screens (light) */
.brand {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    min-height: 3.25rem;
    padding: 0 3.75rem 0 1rem;
    position: relative;
}

@media (min-width: 641px) {
    .brand {
        min-height: 3.5rem;
        padding: 0 1rem;
    }
}

.brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.85rem;
    height: 1.85rem;
    flex-shrink: 0;
}

.brand-mark svg {
    width: 100%;
    height: 100%;
}

.brand-name {
    color: #fff;
    font-size: 0.95rem;
    font-weight: 650;
    text-decoration: none;
    letter-spacing: -0.02em;
    line-height: 1.2;
}

.corner-brand {
    position: absolute;
    top: 1.25rem;
    left: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.55rem;
}

.corner-brand-mark {
    display: inline-flex;
    width: 2rem;
    height: 2rem;
    flex-shrink: 0;
}

.corner-brand-mark svg {
    width: 100%;
    height: 100%;
}

.corner-brand-name {
    color: var(--et-text);
    font-size: 0.95rem;
    font-weight: 650;
    letter-spacing: -0.02em;
}

.auth-screen {
    position: relative;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    background:
        radial-gradient(circle at top left, rgba(15, 118, 110, 0.18), transparent 40%),
        radial-gradient(circle at bottom right, rgba(15, 23, 42, 0.12), transparent 42%),
        var(--et-canvas);
}

.auth-card {
    width: min(420px, 100%);
    background: var(--et-card);
    border: 1px solid var(--et-border);
    border-radius: 16px;
    box-shadow: var(--et-shadow);
    padding: 2rem 1.75rem;
}

.auth-brand {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.portal-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 3rem;
    height: 3rem;
    flex-shrink: 0;
    filter: drop-shadow(0 6px 14px rgba(15, 118, 110, 0.25));
}

.portal-icon svg {
    width: 100%;
    height: 100%;
}

.auth-card h1 {
    margin: 0;
    font-size: 1.45rem;
    font-weight: 700;
}

.auth-card p {
    margin: 0.6rem 0 1.4rem;
    color: var(--et-muted);
}

.auth-card .btn-signin {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    border: 0;
    border-radius: 8px;
    background: var(--et-accent);
    color: #fff;
    font-size: 1rem;
    font-weight: 600;
    padding: 0.7rem 1rem;
}

.auth-card .btn-signin:hover {
    background: var(--et-accent-hover);
}

@media (max-width: 900px) {
    .stat-grid,
    .shortcut-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0.75rem;
        margin-bottom: 1rem;
    }

    .page-header {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }
}

/* ---------- phones ---------- */
@media (max-width: 640px) {
    .stat-grid,
    .shortcut-grid {
        grid-template-columns: 1fr;
    }

    .stat-card {
        padding: 0.85rem 1rem;
    }

    .stat-card .stat-value {
        font-size: 1.35rem;
    }

    .page-header {
        margin-bottom: 1rem;
    }

    .page-header h1 {
        font-size: 1.25rem;
    }

    .page-subtitle {
        font-size: 0.875rem;
    }

    .page-header-actions {
        flex-shrink: 1;
    }

    /* primary page action becomes a full-width, thumb-sized button */
    .page-header-actions .rz-button {
        width: 100%;
        justify-content: center;
        min-height: 2.75rem;
    }

    .content-card {
        border-radius: 10px;
        padding: 0.35rem;
    }

    .corner-brand {
        top: 1rem;
        left: 1rem;
    }

    .auth-screen {
        padding: 1rem;
        min-height: 100dvh;
    }

    .auth-card {
        padding: 1.5rem 1.15rem;
    }

    /* Radzen data grids: keep the table readable by letting it scroll inside
       the card instead of squeezing every column. */
    .rz-data-grid,
    .rz-datatable {
        max-width: 100%;
    }

    .rz-data-grid .rz-data-grid-data,
    .rz-datatable .rz-datatable-data,
    .rz-datatable-scrollable-body,
    .rz-datatable-scrollable-header {
        overflow: auto;
        -webkit-overflow-scrolling: touch;
    }

    .rz-grid-table th,
    .rz-grid-table td {
        padding: 0.45rem 0.5rem;
        font-size: 0.85rem;
        white-space: nowrap;
    }

    /* pager: wrap and stay tappable */
    .rz-paginator {
        flex-wrap: wrap;
        justify-content: center;
        gap: 0.15rem;
        padding: 0.35rem 0.25rem;
    }

    .rz-paginator .rz-paginator-element {
        min-width: 2.25rem;
        min-height: 2.25rem;
    }

    /* side pane and dialogs take the whole phone screen */
    .rz-dialog-side {
        width: 100% !important;
        max-width: 100% !important;
        left: 0 !important;
        right: 0 !important;
    }

    .rz-dialog {
        width: calc(100vw - 1.5rem) !important;
        max-width: calc(100vw - 1.5rem) !important;
    }

    .rz-dialog-content {
        max-height: 75dvh;
        overflow-y: auto;
    }

    /* full-width form controls inside panes */
    .rz-form-field,
    .rz-dropdown,
    .rz-datepicker,
    .rz-textarea,
    .rz-textbox,
    .rz-numeric {
        max-width: 100%;
    }
}

/* Prevent iOS from zooming when focusing an input. */
@media (max-width: 640px) {
    input,
    select,
    textarea,
    .rz-textbox,
    .rz-textarea,
    .rz-numeric input,
    .rz-dropdown-label {
        font-size: 16px;
    }
}

/* Radzen stacks every overlay off these two variables - the mask, the centred
   dialogs (confirm/alert) and the side panes all read them. Overriding the
   variables rather than individual classes keeps the pair in step: setting
   `.rz-dialog-mask` alone left the confirm dialog on the theme default of 1001,
   i.e. underneath its own mask.
   `html:root` outranks the theme's own `:root` no matter which stylesheet the
   browser loads last - the theme link is injected at interactive render time. */
html:root {
    --rz-dialog-mask-zindex: 1090;
    --rz-dialog-zindex: 1100;
}

.rz-dialog-side {
    top: 0;
}
