/* standard.css: the one set of content components (DESIGN.md, #105, D25–D27).
   Loaded after every tab stylesheet, so a component looks the same on every tab; css/tab-*.css keep only
   layout. Values come from css/variables.css (tokens); a new variant is a change of DESIGN.md first.
   Domain classes that are the same component are listed next to the standard class (one definition). */

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: var(--spacing-2);
    block-size: var(--control-h); min-block-size: 0; padding: 0 var(--spacing-4);
    border: 1px solid transparent; border-radius: var(--radius-control);
    font-size: var(--control-font); font-weight: 600; line-height: 1; white-space: nowrap; text-decoration: none;
}
.btn .icon { width: var(--btn-icon); height: var(--btn-icon); flex: none; }
.btn--outline, .btn--secondary { background: var(--color-bg-card); color: var(--color-text); border-color: var(--color-border); }
.btn--outline:hover:not(:disabled), .btn--secondary:hover:not(:disabled) { background: var(--color-bg-subtle); border-color: var(--color-slate-500); }
.btn--ghost { background: transparent; color: var(--color-text-secondary); border-color: transparent; }
.btn--ghost:hover:not(:disabled) { background: var(--color-bg-subtle); color: var(--color-text); }
.btn--danger-text:hover:not(:disabled) { color: var(--status-danger-fg); background: var(--status-danger-bg); }
.btn--sm { block-size: var(--control-h-sm); padding: 0 var(--spacing-3); border-radius: var(--radius-lg); font-size: var(--font-size-xs); }
.btn--icon { inline-size: var(--control-h); padding: 0; }
.btn--icon.btn--sm { inline-size: var(--control-h-sm); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
.btn:focus-visible { outline: 2px solid var(--color-primary-500); outline-offset: 2px; }
.btn.is-loading { position: relative; color: transparent; pointer-events: none; }
.btn.is-loading::after {
    content: ''; position: absolute; width: 16px; height: 16px; border-radius: 50%; border: 2px solid currentColor;
    border-color: var(--btn-primary-fg) transparent var(--btn-primary-fg) transparent; animation: std-spin .8s linear infinite;
}
.btn--outline.is-loading::after, .btn--ghost.is-loading::after { border-color: var(--color-text) transparent var(--color-text) transparent; }
@keyframes std-spin { to { transform: rotate(360deg); } }

/* ---------- Fields ---------- */
.input, .select {
    block-size: var(--control-h); padding: 0 12px; border: 1px solid var(--color-border); border-radius: var(--radius-control);
    font-size: var(--field-font); line-height: normal; background: var(--color-bg-card); color: var(--color-text);
}
textarea.input { block-size: auto; min-block-size: 88px; padding: 10px 12px; }
.input::placeholder { color: var(--color-text-muted); opacity: 1; }
.input:focus, .select:focus { outline: none; border-color: var(--color-primary-500); box-shadow: var(--focus-ring); }
.input[aria-invalid="true"], .select[aria-invalid="true"], .field--error .input, .field--error .select { border-color: var(--status-danger-fg); }
.label { font-size: var(--font-size-sm); font-weight: 500; color: var(--color-text-secondary); }
/* Field = label + control with a 6 px gap (mockup .field); list filters have a 12 px label (.field--filter) */
.ledger-toolbar__field, .entry-dialog .field, .acct-form__extra .field { gap: var(--field-gap); }
.ledger-toolbar__field > .label { font-size: var(--font-size-xs); }
/* List-card filter bar ends 12 px above the list, as the mockup .inv-filters */
.ledger-card .ledger-toolbar { padding-bottom: var(--spacing-3); }
.field__error { font-size: var(--font-size-xs); font-weight: 500; color: var(--status-danger-fg); }
.field__hint { font-size: var(--font-size-xs); font-weight: 400; color: var(--color-text-muted); }

/* ---------- Card ---------- */
.card {
    background: var(--color-bg-card); border: 1px solid color-mix(in srgb, var(--color-border) 55%, transparent);
    border-radius: var(--radius-card); box-shadow: var(--shadow-card); padding: var(--spacing-6);
}
.card--flush { padding: 0; }
/* Collapsible note card (Podatki „Jak liczymy”): 16 / 24 px, on the phone too (mockup .tax-how, D28) */
.card--note, .card.card--note { padding: var(--spacing-4) var(--spacing-6); }
.card__head { display: flex; align-items: center; justify-content: space-between; gap: var(--spacing-3); flex-wrap: wrap; margin-bottom: var(--spacing-4); }
.card__title, .set-card__title, .bank-conn__title, .sim-compare__title, .panel-card__title, .sim-card__title {
    font-size: var(--font-size-lg); font-weight: 600; line-height: var(--line-height-tight); letter-spacing: var(--letter-spacing-normal); color: var(--color-text);
}
.card__sub { font-size: var(--font-size-sm); color: var(--color-text-muted); }

/* ---------- Tile ---------- */
.stat-tile, .sum-tile {
    --tile-accent: var(--color-slate-500);
    border: 1px solid color-mix(in srgb, var(--color-border) 55%, transparent); border-left: 4px solid var(--tile-accent);
    border-radius: var(--radius-card); box-shadow: var(--shadow-card); background: var(--color-bg-card);
}
.sum-tile__main { padding: var(--spacing-3) var(--spacing-4); }
/* Summary tile = mockup .inv-summary__tile: 8/16 padding, 12 px label, 17 px amount, one 11 px sub line */
.stat-tile { gap: 0; padding: var(--tile-pad); border-radius: var(--radius-tile); box-shadow: var(--shadow-sm); }
.sum-tile { padding: 0; }
.stat-tile--info, .sum-tile--info { --tile-accent: var(--color-primary-500); }
.stat-tile--accent, .sum-tile--accent { --tile-accent: var(--color-accent-500); }
.stat-tile--asset, .sum-tile--asset { --tile-accent: var(--color-purple-500); }
.stat-tile--warn, .sum-tile--warn { --tile-accent: var(--color-warning-500); }
.stat-tile--success, .sum-tile--success { --tile-accent: var(--color-success-500); }
.stat-tile--neutral, .stat-tile--total, .sum-tile--total { --tile-accent: var(--color-slate-500); }
.stat-tile--total, .sum-tile--total { background: var(--color-bg-subtle); }
.stat-tile__label, .sum-tile__label {
    /* One row height with or without a TH / KF / ŚT badge, so the amounts line up across tiles */
    display: flex; align-items: center; gap: var(--spacing-2); min-block-size: var(--badge-h);
    font-size: var(--font-size-2xs); font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--color-text-muted);
}
.stat-tile__value, .sum-tile__value {
    font-size: var(--font-size-xl); font-weight: 700; line-height: var(--line-height-tight); letter-spacing: var(--letter-spacing-tight); font-variant-numeric: tabular-nums;
}
/* The note / trend line is always two lines tall, so tiles of every tab have one height */
.sum-tile__note, .sum-tile__main > .delta { font-size: var(--font-size-xs); line-height: 1.4; min-block-size: calc(2 * 1.4 * var(--font-size-xs)); }
.stat-tile__label { min-block-size: 0; font-size: var(--font-size-xs); letter-spacing: .04em; }
.stat-tile__value { font-size: var(--font-size-lg); line-height: var(--line-height-normal); }
.stat-tile__note { font-size: var(--font-size-2xs); line-height: var(--line-height-normal); color: var(--color-text-muted); }

/* ---------- Tables (domain tables are the same component) ---------- */
:is(.table, .ledger-table, .dash-recent__table, .tax-table, .pack-table, .acct-table, .kpir-table, .apit-table, .sim-months, .rules-table, .zk-table) { font-size: var(--font-size-sm); }
:is(.table, .ledger-table, .dash-recent__table, .tax-table, .pack-table, .acct-table, .kpir-table, .apit-table, .sim-months, .rules-table, .zk-table) thead th {
    padding: var(--th-pad); font-size: var(--font-size-2xs); font-weight: 600; letter-spacing: .05em; text-transform: uppercase;
    color: var(--color-text-muted); border-bottom: 1px solid var(--color-border);
}
:is(.table, .ledger-table, .dash-recent__table, .tax-table, .pack-table, .acct-table, .kpir-table, .apit-table, .sim-months, .rules-table, .zk-table) tbody td {
    padding: var(--td-pad); font-size: var(--font-size-sm); border-bottom: 1px solid var(--color-border-light);
}
.table--dense tbody td, .table--dense tbody th { padding: var(--td-pad-dense); }

/* ---------- Chip (filter), pill (status) ---------- */
.chip, .list-chip, .bank-chip, .set-pill {
    display: inline-flex; align-items: center; gap: var(--spacing-2); block-size: var(--chip-h); min-block-size: 0;
    padding: 0 var(--spacing-3) 0 var(--spacing-4); border: 1px solid var(--color-border); border-radius: var(--radius-full);
    font-size: var(--font-size-sm); font-weight: 600; line-height: 1; white-space: nowrap;
}
/* Static chip (DESIGN.md chip-static, mockup .chip): read-only status, 26 px, radius 8, 12/600 */
.chip.chip--static { block-size: var(--chip-static-h, 26px); padding: 0 10px; gap: 6px; border-color: transparent; border-radius: var(--radius-lg);
    background: var(--color-slate-100); color: var(--color-text-secondary); font-size: var(--font-size-xs); }
.chip.chip--static.chip--info { background: var(--status-info-bg); color: var(--status-info-fg); }
.pill { display: inline-flex; align-items: center; gap: 6px; min-block-size: var(--pill-h); padding: var(--pill-pad); border-radius: var(--radius-full); font-size: var(--font-size-xs); font-weight: 600; line-height: 1.4; }

/* ---------- Badge, counter ---------- */
.badge, .doc-badge, .list-badge, .type-mark, .set-kf-item__badge {
    display: inline-flex; align-items: center; block-size: var(--badge-h); padding: 0 var(--badge-pad-x); border-radius: var(--radius-md);
    font-size: var(--font-size-2xs); font-weight: 700; letter-spacing: .02em; line-height: 1; white-space: nowrap;
}
.count, .subnav__count, .list-chip__count, .bank-chip__count, .count-badge {
    display: inline-flex; align-items: center; justify-content: center; block-size: var(--badge-h); min-inline-size: var(--badge-h); padding: 0 6px;
    border-radius: var(--radius-full); font-size: var(--font-size-2xs); font-weight: 600; line-height: 1;
}
/* Chip / filter-button counter = mockup .quick__count (22.4 px, 12 px); sub-tab counter = .segmented__count */
.list-chip__count, .bank-chip__count, .count-badge { block-size: var(--count-h); min-inline-size: var(--count-h); font-size: var(--font-size-xs); }
.subnav__count { block-size: auto; min-inline-size: 0; padding: 1px 7px; line-height: var(--line-height-normal); }
/* Sub-tab switch = mockup .segmented: 4 px padding, 2 px gap, 36 px buttons */
.subnav { gap: 2px; }

/* ---------- Notice and note ---------- */
.notice { display: flex; gap: var(--spacing-3); align-items: flex-start; }
/* Pulpit „Wymaga uwagi” rows are notices with a button (own grid layout) */
.notice, .dash-attention__item { padding: var(--spacing-3) var(--spacing-4); border-radius: var(--radius-xl); font-size: var(--font-size-sm); }
.notice > .icon { width: 1.25rem; height: 1.25rem; flex: none; margin-top: 1px; }
.note { display: flex; gap: var(--spacing-2); align-items: flex-start; font-size: var(--font-size-xs); color: var(--color-text-muted); }
.note > .icon { width: 1rem; height: 1rem; flex: none; }
/* An empty note takes no room (no stray gap under the switch) */
.note:empty, .kpir__basis:empty { display: none; }

/* ---------- Horizontal scroll container: a wide table scrolls inside its card, with an edge shadow ---------- */
.scroll-x {
    overflow-x: auto;
    background:
        linear-gradient(to right, var(--color-bg-card) 30%, transparent) left center / 40px 100% no-repeat local,
        linear-gradient(to left, var(--color-bg-card) 30%, transparent) right center / 40px 100% no-repeat local,
        radial-gradient(farthest-side at 0 50%, var(--scroll-shadow), transparent) left center / 14px 100% no-repeat scroll,
        radial-gradient(farthest-side at 100% 50%, var(--scroll-shadow), transparent) right center / 14px 100% no-repeat scroll,
        var(--color-bg-card);
}

/* ---------- Folding card / section: one arrow ▸ for every <details> (turns down when open) ---------- */
:is(.tax-how > summary, .sim-details__summary, .sim-more__summary, .set-legacy__summary) {
    display: flex; align-items: center; gap: var(--spacing-2); list-style: none; cursor: pointer;
}
:is(.tax-how > summary, .sim-details__summary, .sim-more__summary, .set-legacy__summary)::-webkit-details-marker { display: none; }
:is(.tax-how > summary, .sim-details__summary, .sim-more__summary, .set-legacy__summary)::before {
    content: ''; flex: none; width: .45rem; height: .45rem; margin: 0 2px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor;
    transform: rotate(-45deg); transition: transform var(--transition-fast);
}
details[open] > :is(summary.sim-details__summary, summary.sim-more__summary, summary.set-legacy__summary)::before,
details.tax-how[open] > summary::before { transform: rotate(45deg); }
@media (prefers-reduced-motion: reduce) {
    :is(.tax-how > summary, .sim-details__summary, .sim-more__summary, .set-legacy__summary)::before { transition: none; }
}

/* Card header: no rule under it (DESIGN.md › Components › Karta) */
.card__header { border-bottom: 0; }

/* ---------- Empty state ---------- */
.empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: var(--spacing-2); padding: 40px 24px; }
.empty__title { font-size: var(--font-size-lg); font-weight: 600; line-height: var(--line-height-tight); }
.empty__text { max-width: 28rem; font-size: var(--font-size-sm); color: var(--color-text-muted); }

/* ---------- Phone ---------- */
/* Phone (mockup views.css ≤ 860 px): three tiles in a row, smaller tile type */
@media (max-width: 860px) {
    .stat-row:not(.bank-tiles) { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--spacing-2); } /* Bank: own phone tile layout (css/tab-bank.css) */
    .stat-tile { padding: var(--tile-pad-phone); border-radius: var(--radius-xl); }
    .stat-tile__label { font-size: var(--tile-label-font-phone); letter-spacing: .02em; }
    .stat-tile__value { font-size: var(--font-size-sm); }
}
/* Phone: controls keep the desktop sizes (40 / 32 px, 13 px), as in the mockup; a card, also a flush one, gets 16 px (D28) */
@media (max-width: 767px) {
    .card, .card--flush { padding: var(--spacing-4); border-radius: var(--radius-tile); }
    .card.card--note { padding: var(--spacing-4) var(--spacing-6); }
    .subnav { width: 100%; }
    .subnav__btn { flex: none; min-height: 0; block-size: var(--segment-btn-h); padding: 0 var(--spacing-2); font-size: var(--font-size-sm); }
}

/* Header actions stay one control tall also on the phone (shell, DESIGN.md) */
.page-header__right .btn { block-size: var(--control-h); min-block-size: 0; }
