/*
 * Dashboard — Minimal Financial SaaS
 *
 * The page is intentionally built from a small set of surfaces: one summary
 * surface, two data surfaces (accounts and cards) and three action surfaces.
 * Inner boxes were removed; grouping is carried by spacing, alignment and
 * hairlines. All values and links come from the existing viewmodel.
 */

.cb-v2-content {
    width: min(1360px, 100%);
    margin: 0 auto;
    padding-top: 18px;
}

/* --- Page heading ------------------------------------------------------- */

.cb-v2-heading-row {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 28px;
    margin-bottom: 14px;
}

.cb-v2-heading-copy {
    min-width: 0;
}

.cb-v2-heading-meta {
    margin: 0 0 5px;
    color: var(--v2-subtle);
    font-size: 10.5px;
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    letter-spacing: 0.055em;
    text-transform: uppercase;
}

.cb-v2-heading-row h1 {
    margin: 0;
    color: var(--v2-text);
    font-size: 23px;
    font-weight: 680;
    letter-spacing: -0.032em;
    line-height: 1.15;
    text-wrap: balance;
}

.cb-v2-heading-row > .cb-v2-heading-copy > p:last-child {
    max-width: 62ch;
    margin: 6px 0 0;
    color: var(--v2-muted);
    font-size: 13px;
    line-height: 1.5;
}

.cb-v2-context-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 2px;
}

.cb-v2-context-actions a {
    display: inline-flex;
    min-height: 34px;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 0 10px;
    border: 1px solid transparent;
    border-radius: 8px;
    color: var(--v2-muted);
    font-size: 12px;
    font-weight: 600;
    transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease;
}

.cb-v2-context-actions a:hover {
    border-color: var(--v2-border);
    background: var(--v2-surface);
    color: var(--v2-text);
}

.cb-v2-context-actions svg {
    width: 15px;
    height: 15px;
    color: var(--v2-subtle);
    transition: color 160ms ease;
}

.cb-v2-context-actions a:hover svg {
    color: var(--v2-accent);
}

/* --- Layout ------------------------------------------------------------- */

.cb-v2-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr);
    gap: 16px;
    align-items: stretch;
}

.cb-v2-left-column,
.cb-v2-right-column {
    display: grid;
    gap: 16px;
    min-width: 0;
    align-content: start;
}

.cb-v2-bottom-grid {
    display: grid;
    grid-column: 1 / -1;
    grid-template-columns: minmax(0, 1.02fr) minmax(0, 0.82fr) minmax(0, 1.35fr);
    gap: 16px;
    align-items: start;
}

/* --- Shared surface ----------------------------------------------------- */

.cb-v2-panel,
.cb-v2-card-section {
    min-width: 0;
    border: 1px solid var(--v2-border);
    border-radius: 14px;
    background: var(--v2-surface);
}

.cb-v2-panel {
    padding: 16px;
}

.cb-v2-card-section {
    padding: 16px;
}

.cb-v2-panel-header,
.cb-v2-section-heading {
    display: flex;
    min-width: 0;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.cb-v2-panel-header h2,
.cb-v2-section-heading h2 {
    margin: 0;
    color: var(--v2-text);
    font-size: 14.5px;
    font-weight: 660;
    letter-spacing: -0.014em;
}

.cb-v2-panel-header > a:not(.cb-v2-text-link) {
    display: grid;
    width: 28px;
    height: 28px;
    place-items: center;
    border-radius: 7px;
    color: var(--v2-muted);
}

.cb-v2-panel-header > a:not(.cb-v2-text-link):hover {
    background: var(--v2-surface-hover);
    color: var(--v2-text);
}

.cb-v2-panel-header > a:not(.cb-v2-text-link) svg {
    width: 15px;
    height: 15px;
}

.cb-v2-text-link,
.cb-v2-section-heading > a {
    display: inline-flex;
    min-height: 32px;
    align-items: center;
    gap: 4px;
    margin-block: -7px;
    padding-block: 7px;
    color: var(--v2-muted);
    font-size: 11.5px;
    font-weight: 600;
    white-space: nowrap;
    transition: color 160ms ease;
}

.cb-v2-text-link svg {
    width: 12px;
    height: 12px;
}

.cb-v2-text-link:hover,
.cb-v2-section-heading > a:hover {
    color: var(--v2-accent-strong);
}

.cb-v2-count {
    display: inline-grid;
    min-width: 19px;
    height: 19px;
    margin-left: 4px;
    padding: 0 6px;
    place-items: center;
    border-radius: 999px;
    background: var(--v2-surface-2);
    color: var(--v2-subtle);
    font-size: 10px;
    font-variant-numeric: tabular-nums;
    font-weight: 650;
    vertical-align: 1px;
}

/* --- Financial summary -------------------------------------------------- */

.cb-v2-financial-panel {
    grid-column: 1 / -1;
    padding: 16px 18px;
}

.cb-v2-financial-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.25fr) minmax(300px, 0.9fr);
    gap: 34px;
    align-items: center;
    margin-top: 9px;
}

.cb-v2-label {
    margin: 0 0 3px;
    color: var(--v2-muted);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.015em;
}

.cb-v2-balance {
    margin: 0;
    color: var(--v2-text);
    font-size: 38px;
    font-variant-numeric: tabular-nums;
    font-weight: 730;
    letter-spacing: -0.055em;
    line-height: 1.05;
    overflow-wrap: anywhere;
}

.cb-v2-balance.is-negative,
.cb-v2 .is-negative {
    color: var(--v2-danger);
}

.cb-v2 .is-positive {
    color: var(--v2-positive);
}

.cb-v2-trend {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 9px;
    color: var(--v2-subtle);
    font-size: 11.5px;
}

.cb-v2-trend strong {
    display: inline-flex;
    align-items: center;
    padding: 2px 7px;
    border-radius: 5px;
    background: var(--v2-surface-2);
    color: var(--v2-muted);
    font-size: 11px;
    font-variant-numeric: tabular-nums;
    font-weight: 650;
}

.cb-v2-trend.is-positive strong {
    background: color-mix(in srgb, var(--v2-positive) 11%, transparent);
    color: var(--v2-positive);
}

.cb-v2-trend.is-negative strong {
    background: color-mix(in srgb, var(--v2-danger) 11%, transparent);
    color: var(--v2-danger);
}

.cb-v2-balance-breakdown {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0;
    border-left: 1px solid var(--v2-border);
}

.cb-v2-balance-breakdown > div {
    display: grid;
    gap: 3px;
    min-width: 0;
    padding: 2px 0 2px 24px;
}

.cb-v2-balance-breakdown > div + div {
    border-left: 1px solid var(--v2-border);
    padding-left: 24px;
}

.cb-v2-balance-breakdown span {
    display: flex;
    min-width: 0;
    align-items: center;
    gap: 6px;
    color: var(--v2-muted);
    font-size: 11px;
    font-weight: 600;
}

.cb-v2-balance-breakdown svg {
    width: 13px;
    height: 13px;
    color: var(--v2-subtle);
}

.cb-v2-balance-breakdown strong {
    overflow-wrap: anywhere;
    color: var(--v2-text);
    font-size: 18px;
    font-variant-numeric: tabular-nums;
    font-weight: 690;
    letter-spacing: -0.025em;
}

.cb-v2-balance-breakdown small {
    overflow: hidden;
    color: var(--v2-subtle);
    font-size: 10.5px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* --- Accounts ----------------------------------------------------------- */

.cb-v2-account-list {
    display: grid;
    margin-top: 7px;
}

.cb-v2-account-row {
    display: grid;
    grid-template-columns: 32px minmax(0, 1fr) minmax(86px, auto);
    gap: 10px;
    align-items: center;
    min-width: 0;
    padding: 8px;
    margin-inline: -8px;
    border-bottom: 1px solid var(--v2-border);
    border-radius: 7px;
    transition: background-color 160ms ease;
}

.cb-v2-account-row:last-child {
    border-bottom: 0;
}

.cb-v2-account-row:hover {
    background: var(--v2-surface-hover);
}

.cb-v2-account-row:hover .cb-v2-account-copy strong,
.cb-v2-account-row:hover .cb-v2-account-amount strong {
    color: var(--v2-row-hover-text);
}

.cb-v2-provider-mark {
    display: grid;
    width: 30px;
    height: 30px;
    place-items: center;
    overflow: hidden;
    border-radius: 8px;
    background: var(--v2-provider, var(--v2-accent));
    color: #fff;
    padding: 2px;
    font-size: 8px;
    font-weight: 760;
    line-height: 1;
    letter-spacing: -0.04em;
    white-space: nowrap;
}

.cb-v2-provider-mark--image {
    padding: 0;
}

.cb-v2-account-copy,
.cb-v2-account-amount {
    display: grid;
    min-width: 0;
    gap: 1px;
}

.cb-v2-account-copy strong,
.cb-v2-account-amount strong {
    overflow: hidden;
    color: var(--v2-text);
    font-size: 12.5px;
    font-weight: 620;
    text-overflow: ellipsis;
    white-space: nowrap;
    transition: color 160ms ease;
}

.cb-v2-account-copy small,
.cb-v2-account-amount small {
    overflow: hidden;
    color: var(--v2-subtle);
    font-size: 10px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cb-v2-account-amount {
    text-align: right;
}

.cb-v2-account-amount strong,
.cb-v2-account-amount small {
    font-variant-numeric: tabular-nums;
}

.cb-v2-account-amount strong {
    overflow: visible;
    overflow-wrap: anywhere;
    text-overflow: clip;
    white-space: normal;
}

/* --- Cards and invoices -------------------------------------------------
   The Faturas hub composition (section chrome, rail, carousel and card tile)
   lives in faturas-index.css. Shared card foundations live in credit-cards.css. */

.cb-v2-section-tools {
    display: flex;
    align-items: center;
    gap: 6px;
}

.cb-v2-all-invoices-slide {
    display: none;
}

/* --- Next actions ------------------------------------------------------- */

.cb-v2-tabs {
    display: inline-flex;
    gap: 4px;
    margin: 10px 0 4px;
    padding: 4px;
    border: var(--ui-border-width) solid var(--ui-border);
    border-radius: var(--ui-radius-tab);
    background: var(--ui-tab-bg);
}

.cb-v2-tabs button {
    display: inline-flex;
    min-height: 34px;
    align-items: center;
    gap: 6px;
    padding: 0 12px;
    border: 1px solid transparent;
    border-radius: var(--ui-radius-tab-item);
    background: transparent;
    color: var(--ui-text-muted);
    cursor: pointer;
    font-size: 12px;
    font-weight: 620;
    transition: background-color var(--ui-transition), border-color var(--ui-transition), color var(--ui-transition);
}

.cb-v2-tabs button:hover {
    background: var(--ui-surface-hover);
    color: var(--ui-text);
}

.cb-v2-tabs button:focus-visible {
    outline: 2px solid var(--ui-focus);
    outline-offset: 2px;
}

.cb-v2-tabs button[aria-selected="true"] {
    border-color: var(--ui-tab-active-border);
    background: var(--ui-tab-active-bg);
    color: var(--ui-tab-active-fg);
    box-shadow: inset 0 1px 0 #ffffff14;
}

.cb-v2-tabs button > span {
    display: inline-grid;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    place-items: center;
    border-radius: var(--ui-radius-badge);
    background: var(--ui-surface);
    color: var(--ui-text-subtle);
    font-size: 9.5px;
    font-variant-numeric: tabular-nums;
    font-weight: 650;
}

.cb-v2-tabs button[aria-selected="true"] > span {
    background: color-mix(in srgb, var(--ui-accent) 14%, var(--ui-surface));
    color: var(--ui-tab-active-fg);
}

.cb-v2-action-total {
    margin: 10px 0 2px;
    color: var(--v2-subtle);
    font-size: 10.5px;
    font-weight: 500;
}

.cb-v2-action-total strong {
    color: var(--v2-text);
    font-variant-numeric: tabular-nums;
    font-weight: 650;
}

.cb-v2-action-total strong.is-positive {
    color: var(--v2-positive);
}

.cb-v2-action-list {
    display: grid;
}

.cb-v2-action-row {
    display: grid;
    grid-template-columns: 5px minmax(0, 1fr) auto;
    gap: 9px;
    align-items: center;
    min-width: 0;
    padding: 8px 7px;
    margin-inline: -7px;
    border-bottom: 1px solid var(--v2-border);
    border-radius: 7px;
    transition: background-color 160ms ease;
}

.cb-v2-action-row:last-child {
    border-bottom: 0;
}

.cb-v2-action-row:hover {
    background: var(--v2-surface-hover);
}

.cb-v2-action-dot {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--v2-subtle);
}

.cb-v2-action-row.is-overdue .cb-v2-action-dot {
    background: var(--v2-danger);
}

.cb-v2-action-row > span:nth-child(2) {
    display: grid;
    min-width: 0;
    gap: 1px;
}

.cb-v2-action-row strong {
    overflow: hidden;
    color: var(--v2-text);
    font-size: 12.5px;
    font-weight: 600;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cb-v2-action-row small {
    overflow: hidden;
    color: var(--v2-subtle);
    font-size: 10.5px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cb-v2-action-row b {
    color: var(--v2-text);
    font-size: 12px;
    font-variant-numeric: tabular-nums;
    font-weight: 650;
    white-space: nowrap;
}

.cb-v2-action-row.is-overdue b {
    color: var(--v2-danger);
}

.cb-v2-action-row.cb-v2-action-receivable b {
    color: var(--v2-positive);
}

/* --- Limits and goals --------------------------------------------------- */

.cb-v2-progress-list {
    display: grid;
    gap: 11px;
    margin-top: 12px;
}

.cb-v2-goals-panel .cb-v2-progress-list {
    grid-template-columns: minmax(0, 1fr);
    column-gap: 20px;
}

.cb-v2-limits-panel .cb-v2-progress-item-head,
.cb-v2-goals-panel .cb-v2-progress-item-head {
    flex-wrap: wrap;
}

.cb-v2-limits-panel .cb-v2-progress-item-head > span:last-child,
.cb-v2-goals-panel .cb-v2-progress-item-head > span:last-child {
    flex-basis: 100%;
    max-width: 100%;
    overflow: visible;
    padding-left: 18px;
    text-align: left;
    text-overflow: clip;
    white-space: normal;
}

.cb-v2-progress-item {
    display: grid;
    gap: 5px;
    min-width: 0;
    --meter-tone: var(--v2-tone-neutral);
}

.cb-v2-meter--ok { --meter-tone: var(--v2-tone-ok); }
.cb-v2-meter--attention { --meter-tone: var(--v2-tone-attention); }
.cb-v2-meter--near { --meter-tone: var(--v2-tone-near); }
.cb-v2-meter--exceeded { --meter-tone: var(--v2-tone-exceeded); }
.cb-v2-meter--progress { --meter-tone: var(--v2-tone-progress); }
.cb-v2-meter--complete { --meter-tone: var(--v2-tone-complete); }
.cb-v2-meter--initial { --meter-tone: var(--v2-tone-initial); }
.cb-v2-meter--info { --meter-tone: var(--v2-tone-info); }

.cb-v2-progress-item-head {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
}

.cb-v2-progress-icon {
    display: grid;
    flex: 0 0 auto;
    place-items: center;
    color: var(--meter-tone);
}

.cb-v2-progress-icon svg {
    width: 12px;
    height: 12px;
}

.cb-v2-progress-item-head > strong {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    color: var(--v2-text);
    font-size: 11.5px;
    font-weight: 610;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cb-v2-progress-item-head > span:last-child {
    flex: 0 1 auto;
    min-width: 0;
    overflow: hidden;
    color: var(--v2-muted);
    font-size: 10.5px;
    font-variant-numeric: tabular-nums;
    text-align: right;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cb-v2-progress-sep {
    color: var(--v2-subtle);
    font-size: 9.5px;
}

.cb-v2-progress-bar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 28px;
    gap: 7px;
    align-items: center;
}

.cb-v2-meter-track {
    display: block;
    width: 100%;
    height: 4px;
    overflow: hidden;
    appearance: none;
    -webkit-appearance: none;
    border: 0;
    border-radius: 4px;
    background: var(--v2-progress-track);
}

.cb-v2-meter-track::-webkit-progress-bar {
    border-radius: inherit;
    background: var(--v2-progress-track);
}

.cb-v2-meter-track::-webkit-progress-value {
    border-radius: inherit;
    background: var(--meter-tone);
}

.cb-v2-meter-track::-moz-progress-bar {
    border-radius: inherit;
    background: var(--meter-tone);
}

.cb-v2-progress-label {
    color: var(--meter-tone);
    font-size: 9.5px;
    font-variant-numeric: tabular-nums;
    font-weight: 650;
    text-align: right;
}

/* --- Empty states ------------------------------------------------------- */

.cb-v2-empty-state {
    display: grid;
    justify-items: start;
    gap: 6px;
    margin-top: 12px;
    padding: 14px;
    border: 1px dashed var(--v2-border);
    border-radius: 10px;
    color: var(--v2-muted);
}

.cb-v2-empty-state svg {
    width: 18px;
    height: 18px;
    color: var(--v2-subtle);
}

.cb-v2-empty-state p {
    margin: 0;
    font-size: 12px;
}

.cb-v2-empty-state a {
    color: var(--v2-accent-strong);
    font-size: 11.5px;
    font-weight: 600;
}

.cb-v2-empty-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px;
    border: 1px dashed var(--v2-border);
    border-radius: 10px;
    color: var(--v2-muted);
}

.cb-v2-empty-card > span {
    display: grid;
    flex: 1 1 auto;
    gap: 2px;
}

.cb-v2-empty-card strong {
    color: var(--v2-text);
    font-size: 12.5px;
    font-weight: 620;
}

.cb-v2-empty-card small {
    font-size: 10.5px;
}

.cb-v2-empty-card > svg {
    width: 16px;
    height: 16px;
    flex: 0 0 auto;
    color: var(--v2-subtle);
}

/* --- Responsive --------------------------------------------------------- */

@media (min-width: 768px) {
    .cb-v2-account-list {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        column-gap: 26px;
    }
}

@media (min-width: 1240px) and (max-width: 1399px) {
    .cb-v2-account-copy strong {
        display: -webkit-box;
        overflow: hidden;
        white-space: normal;
        text-overflow: clip;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 2;
    }
}

@media (min-width: 1240px) {
    .cb-v2-goals-panel .cb-v2-progress-list {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 1180px) {
    .cb-v2-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .cb-v2-bottom-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .cb-v2-goals-panel {
        grid-column: 1 / -1;
    }

    .cb-v2-goals-panel .cb-v2-progress-list {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 900px) {
    .cb-v2-heading-row {
        display: grid;
        gap: 14px;
        margin-bottom: 16px;
    }

    .cb-v2-context-actions {
        display: grid;
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: 2px;
        justify-content: stretch;
    }

    .cb-v2-context-actions a {
        justify-content: flex-start;
        padding-inline: 8px;
    }
}

@media (max-width: 767px) {
    .cb-v2-content {
        padding-top: 16px;
    }

    .cb-v2-heading-row h1 {
        font-size: 22px;
    }

    .cb-v2-context-actions {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .cb-v2-context-actions a {
        justify-content: flex-start;
        padding-inline: 8px;
    }

    .cb-v2-grid {
        display: flex;
        flex-direction: column;
        gap: 14px;
    }

    .cb-v2-left-column { display: contents; }

    .cb-v2-right-column {
        display: contents;
    }

    .cb-v2-bottom-grid {
        display: flex;
        flex-direction: column;
        gap: 14px;
    }

    .cb-v2-goals-panel .cb-v2-progress-list {
        grid-template-columns: minmax(0, 1fr);
    }

    .cb-v2-financial-panel {
        padding: 16px;
    }

    .cb-v2-financial-grid {
        grid-template-columns: minmax(0, 1fr);
        gap: 16px;
    }

    .cb-v2-balance {
        font-size: 36px;
    }

    .cb-v2-balance-breakdown {
        gap: 14px;
        border-top: 1px solid var(--v2-border);
        border-left: 0;
        padding-top: 14px;
    }

    .cb-v2-balance-breakdown > div {
        padding: 0;
    }

    .cb-v2-balance-breakdown > div + div {
        border-left: 0;
        padding-left: 0;
    }

    .cb-v2-balance-breakdown strong {
        font-size: 16px;
    }

    .cb-v2-account-list {
        grid-template-columns: minmax(0, 1fr);
    }

    .cb-v2-progress-item-head > span:last-child {
        max-width: 62%;
    }
}

@media (max-width: 420px) {
    .cb-v2-balance {
        font-size: 32px;
    }

    .cb-v2-panel,
    .cb-v2-card-section {
        padding: 14px;
    }

    .cb-v2-financial-panel {
        padding: 14px;
    }

    .cb-v2-balance-breakdown strong {
        font-size: 14.5px;
    }

    .cb-v2-section-tools .cb-v2-text-link {
        display: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .cb-v2-account-row,
    .cb-v2-action-row,
    .cb-v2-context-actions a {
        transition-duration: 0.01ms;
    }
}
