/* crmtool.app – Stylesheet der Leptos-Oberfläche.
   Keine Inline-Styles (CSP); dynamische Werte setzt die App nur über CSSOM (style:…). */

/* ==========================================================================
   1. Design tokens
   ========================================================================== */
/* Palette: #212121 / #323232 (dark surfaces), #0D7377 secondary, #14FFEC primary.
   Dark is the default theme and uses the palette as is. The light theme derives from it with #0D7377 as
   the main colour, because the neon #14FFEC is unreadable on white (contrast 1.2:1). */
:root {
    --palette-dark: #212121;
    --palette-surface: #323232;
    --palette-secondary: #0d7377;
    --palette-primary: #14ffec;

    --bg-color: #f3f5f5;
    --card-bg-color: #ffffff;
    --card-border-color: #e2e7e7;
    --surface-secondary: #eef2f2;
    --surface-hover: rgba(13, 115, 119, 0.05);

    --text-color: #212121;
    --text-secondary: #545b5b;
    --text-faint: #687070;

    --primary-color: var(--palette-secondary);
    --primary-hover: #0a5c5f;
    --primary-soft: rgba(13, 115, 119, 0.1);
    --on-primary: #ffffff;
    --highlight-bg: linear-gradient(135deg, var(--palette-secondary), #0a4f52);

    --success-color: #1a7f37;
    --success-soft: rgba(26, 127, 55, 0.1);
    --warning-text: #8a5a00;
    --warning-soft: rgba(255, 184, 0, 0.16);
    --danger-color: #c62828;
    --danger-soft: rgba(198, 40, 40, 0.09);
    --on-danger: #ffffff;

    --radius-sm: 8px;
    --radius-md: 16px;
    --radius-lg: 24px;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04), 0 8px 24px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 20px 50px rgba(0, 0, 0, 0.18);
    --focus-ring: 0 0 0 3px rgba(13, 115, 119, 0.35);

    --input-bg: #ffffff;
    --input-border: #d3dada;
    --border-color-light: #e2e7e7;
    --header-bg: #ffffff;
    --pie-rest-color: #dde4e4;
    --toast-bg: var(--palette-dark);
    --toast-success-bg: var(--palette-secondary);
    --backdrop: rgba(33, 33, 33, 0.55);
}

body.dark-mode {
    --bg-color: var(--palette-dark);
    --card-bg-color: var(--palette-surface);
    --card-border-color: rgba(255, 255, 255, 0.07);
    --surface-secondary: rgba(255, 255, 255, 0.06);
    --surface-hover: rgba(20, 255, 236, 0.05);

    --text-color: #ececec;
    --text-secondary: #b3b3b3;
    --text-faint: #a0a0a0;

    --primary-color: var(--palette-primary);
    --primary-hover: #6bfff4;
    --primary-soft: rgba(20, 255, 236, 0.12);
    --on-primary: var(--palette-dark);
    --highlight-bg: linear-gradient(135deg, var(--palette-secondary), #0a5558);

    --success-color: #4ade80;
    --success-soft: rgba(74, 222, 128, 0.12);
    --warning-text: #ffd166;
    --warning-soft: rgba(255, 209, 102, 0.12);
    --danger-color: #ff6b6b;
    --danger-soft: rgba(255, 107, 107, 0.14);
    --on-danger: var(--palette-dark);

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.25);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 20px 50px rgba(0, 0, 0, 0.5);
    --focus-ring: 0 0 0 3px rgba(20, 255, 236, 0.35);

    --input-bg: #2a2a2a;
    --input-border: rgba(255, 255, 255, 0.14);
    --border-color-light: rgba(255, 255, 255, 0.07);
    --header-bg: var(--palette-surface);
    --pie-rest-color: rgba(255, 255, 255, 0.12);
    --toast-bg: #3d3d3d;
    --backdrop: rgba(0, 0, 0, 0.65);
}

/* ==========================================================================
   2. Base
   ========================================================================== */
@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 100 900;
    font-display: swap;
    src: url('/fonts/inter-latin-var.woff2') format('woff2');
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    font-family: 'Inter', system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    margin: 0;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

body.modal-open {
    overflow: hidden;
}

a {
    color: var(--primary-color);
}

:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
}

code {
    font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

.text-muted {
    color: var(--text-secondary);
}

.text-danger {
    color: var(--danger-color);
    font-weight: 600;
}

.small {
    font-size: 0.8rem;
}

.num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.mr-auto {
    margin-right: auto;
}

.plain-list {
    margin: 0;
    padding-left: 1.2rem;
    color: var(--text-secondary);
}

.plain-list li {
    margin: 0.3rem 0;
}

/* ==========================================================================
   3. Layout: sidebar, main area, page header
   ========================================================================== */
.app-shell {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 232px;
    flex-shrink: 0;
    background: var(--header-bg);
    border-right: 1px solid var(--card-border-color);
    display: flex;
    flex-direction: column;
    padding: 1.25rem 0.85rem;
    position: sticky;
    top: 0;
    height: 100vh;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0 0.5rem 1.25rem;
    font-weight: 800;
    font-size: 1.15rem;
    letter-spacing: -0.02em;
    color: var(--text-color);
    text-decoration: none;
}

.brand-mark {
    width: 28px;
    height: 28px;
    fill: var(--primary-color);
    stroke: var(--on-primary);
    stroke-width: 2;
    stroke-linecap: round;
}

.side-nav {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    flex: 1;
}

.side-link {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.6rem 0.75rem;
    border-radius: 10px;
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.9rem;
    text-decoration: none;
    transition: background 0.15s, color 0.15s;
}

.side-link:hover {
    background: var(--surface-secondary);
    color: var(--text-color);
}

.side-link.active {
    background: var(--primary-soft);
    color: var(--primary-color);
}

.side-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.side-label {
    flex: 1;
    white-space: nowrap;
}

.side-count {
    min-width: 22px;
    padding: 0.05rem 0.45rem;
    border-radius: 999px;
    background: var(--danger-color);
    color: var(--on-danger);
    font-size: 0.72rem;
    font-weight: 700;
    text-align: center;
}

.sidebar-foot {
    border-top: 1px solid var(--border-color-light);
    padding-top: 0.9rem;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.sidebar-user {
    font-size: 0.8rem;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding: 0 0.25rem;
}

/* A button that reads like a link inside running text (an action, not a navigation). */
.link-btn {
    display: inline;
    padding: 0;
    border: 0;
    background: none;
    color: var(--primary-color);
    font: inherit;
    text-decoration: underline;
    text-underline-offset: 2px;
    cursor: pointer;
}

.link-btn:focus-visible {
    outline: none;
    border-radius: 3px;
    box-shadow: var(--focus-ring);
}

/* Theme toggle on the left, lock and sign-out on the right – icons only, names in title/aria-label. */
.sidebar-actions {
    display: flex;
    gap: 0.25rem;
    align-items: center;
}

.sidebar-spacer {
    flex: 1;
}

.icon-btn {
    width: 36px;
    height: 36px;
    display: inline-grid;
    place-items: center;
    padding: 0;
    border: 0;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: background-color 0.15s, color 0.15s;
}

.icon-btn:hover {
    background: var(--surface-hover);
    color: var(--text-color);
}

/* The main action of a row (e.g. "Verlängert & abgerechnet"): filled. */
.icon-btn.primary {
    background: var(--primary-color);
    color: var(--on-primary);
}

.icon-btn.primary:hover {
    background: var(--primary-hover);
    color: var(--on-primary);
}

.icon-btn:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
}

.icon-btn svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.main-area {
    flex: 1;
    min-width: 0;
    padding: 1.75rem 2rem 3rem;
}

.tab-content {
    animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(4px);
    }

    to {
        opacity: 1;
        transform: none;
    }
}

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

.view-header h2 {
    margin: 0;
    font-size: 1.6rem;
    font-weight: 800;
    letter-spacing: -0.02em;
}

/* ==========================================================================
   4. Cards, KPIs, pills, chips
   ========================================================================== */
.page-card,
.finor-card {
    background-color: var(--card-bg-color);
    border: 1px solid var(--card-border-color);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
}

.page-card {
    margin-bottom: 1.5rem;
}

.import-preview {
    border-color: var(--primary-color);
}

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

.card-title {
    font-size: 1.1rem;
    font-weight: 700;
    margin: 0 0 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.card-header .card-title {
    margin-bottom: 0.15rem;
}

.card-subtitle {
    margin: 0.15rem 0 0;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.dashboard-card {
    background-color: var(--card-bg-color);
    border: 1px solid var(--card-border-color);
    padding: 1.25rem 1.5rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

.dashboard-card h3 {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin: 0 0 0.4rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.dashboard-card .value {
    font-size: 1.75rem;
    font-weight: 700;
    margin: 0;
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
}

.value.positive {
    color: var(--success-color);
}

.value.negative {
    color: var(--danger-color);
}

.value-divider {
    color: var(--text-faint);
    font-weight: 400;
}

.dashboard-card .sub-value {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin: 0.35rem 0 0;
    font-variant-numeric: tabular-nums;
}

.kpi-highlight {
    background: var(--highlight-bg);
    border: none;
}

.kpi-highlight h3,
.kpi-highlight .sub-value,
.kpi-highlight .value.positive {
    color: #fff;
}

.kpi-highlight h3,
.kpi-highlight .sub-value {
    opacity: 0.85;
}

.toolbar {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.chip-toggle {
    position: relative;
    cursor: pointer;
    user-select: none;
}

.chip-toggle input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.chip-toggle span {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.4rem 0.85rem;
    border-radius: 999px;
    border: 1px solid var(--input-border);
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    transition: all 0.15s ease;
}

.chip-toggle span::before {
    content: '';
    width: 8px;
    height: 8px;
    border-radius: 50%;
    border: 1.5px solid currentColor;
}

.chip-toggle:hover span {
    color: var(--text-color);
}

.chip-toggle input:checked + span {
    background: var(--primary-soft);
    border-color: transparent;
    color: var(--primary-color);
}

.chip-toggle input:checked + span::before {
    background: currentColor;
}

.chip-toggle input:focus-visible + span {
    box-shadow: var(--focus-ring);
}

.tag {
    display: inline-block;
    padding: 0.1rem 0.55rem;
    border-radius: 6px;
    background: var(--surface-secondary);
    font-size: 0.8rem;
    font-weight: 500;
}

/* ==========================================================================
   5. Task lists ("Handlungsbedarf", expiring costs and licenses)
   ========================================================================== */

.expiring-item {
    display: grid;
    grid-template-columns: 120px minmax(140px, 1.2fr) minmax(140px, 1fr) 110px 110px 236px;
    gap: 1rem;
    align-items: center;
    padding: 0.7rem 1rem;
}

.expiring-list {
    list-style: none;
    padding: 0;
    margin: 0;
    max-height: 560px;
    overflow-y: auto;
    scrollbar-width: thin;
}

.compact-list {
    max-height: 320px;
}

.expiring-item {
    border-bottom: 1px solid var(--border-color-light);
    border-left: 3px solid transparent;
    transition: background-color 0.15s;
}

.expiring-item:last-child {
    border-bottom: none;
}

.expiring-item:hover {
    background-color: var(--surface-hover);
}

.expiring-item.expired {
    border-left-color: var(--danger-color);
    background-color: var(--danger-soft);
}

.expiring-date {
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    display: flex;
    flex-direction: column;
    line-height: 1.25;
}

.relative-date {
    font-weight: 500;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.expiring-item.expired .relative-date {
    color: var(--danger-color);
}

.expiring-name {
    min-width: 0;
    overflow-wrap: anywhere;
}

.expiring-item.expiring-item-compact {
    display: flex;
    gap: 1rem;
    padding: 0.65rem 0.75rem;
}

.expiring-date {
    width: 96px;
    flex-shrink: 0;
}

.expiring-name {
    flex: 1;
}

.expiring-price {
    font-variant-numeric: tabular-nums;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.no-data-text {
    color: var(--text-secondary);
    font-style: italic;
    padding: 1rem;
    list-style: none;
}

/* ==========================================================================
   6. Status badges
   ========================================================================== */
.status-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 700;
    white-space: nowrap;
}

.status-badge.status-active {
    background: var(--success-soft);
    color: var(--success-color);
}

.status-badge.status-inactive {
    background: var(--danger-soft);
    color: var(--danger-color);
}

/* ==========================================================================
   7. Tables
   ========================================================================== */
.table-container {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

th,
td {
    text-align: left;
    padding: 0.8rem 1rem;
    border-bottom: 1px solid var(--border-color-light);
    font-size: 0.9rem;
    vertical-align: middle;
}

th {
    background-color: var(--surface-secondary);
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    font-size: 0.7rem;
    letter-spacing: 0.05em;
    white-space: nowrap;
}

th:first-child {
    border-top-left-radius: 10px;
}

th:last-child {
    border-top-right-radius: 10px;
}

tbody tr:hover td {
    background-color: var(--surface-hover);
}

tr.row-clickable {
    cursor: pointer;
}

.row-inactive td {
    color: var(--text-secondary);
}

.row-inactive td strong {
    font-weight: 500;
}

.table-compact th,
.table-compact td {
    padding: 0.5rem 0.75rem;
    font-size: 0.82rem;
}

.sortable-header {
    cursor: pointer;
    user-select: none;
}

.sortable-header:hover {
    color: var(--text-color);
}

.sortable-header::after {
    content: '↕';
    margin-left: 0.35rem;
    opacity: 0.3;
}

.sortable-header.sort-asc::after {
    content: '↑';
    opacity: 1;
    color: var(--primary-color);
}

.sortable-header.sort-desc::after {
    content: '↓';
    opacity: 1;
    color: var(--primary-color);
}

.table-actions-cell {
    white-space: nowrap;
    text-align: right;
}

.empty-state {
    text-align: center;
    padding: 2.5rem 1rem;
    color: var(--text-secondary);
    border: 2px dashed var(--input-border);
    border-radius: var(--radius-md);
}

.empty-state p {
    margin: 0;
}

/* Revenue analysis */
.revenue-analysis-container {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1.5rem;
    align-items: start;
}

.share-cell {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    justify-content: flex-end;
}

.share-bar {
    width: 80px;
    height: 6px;
    border-radius: 3px;
    background: var(--surface-secondary);
    overflow: hidden;
    display: inline-block;
}

.share-bar span {
    display: block;
    height: 100%;
    background: var(--primary-color);
    border-radius: 3px;
}

.chart-box {
    text-align: center;
    background: var(--surface-secondary);
    padding: 1.5rem;
    border-radius: var(--radius-md);
    display: flex;
    flex-direction: column;
    align-items: center;
}

.chart-box-title {
    margin: 0;
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.legend-row {
    display: flex;
    gap: 1rem;
    margin-top: 0.5rem;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.legend-row span {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.legend-swatch {
    width: 10px;
    height: 10px;
    border-radius: 3px;
    display: inline-block;
}

.swatch-primary {
    background: var(--primary-color);
}

.swatch-rest {
    background: var(--pie-rest-color);
}

/* ==========================================================================
   8. Buttons
   ========================================================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.55rem 1.1rem;
    border-radius: 10px;
    font-family: inherit;
    font-weight: 600;
    font-size: 0.875rem;
    line-height: 1.2;
    cursor: pointer;
    border: 1px solid transparent;
    transition: background-color 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s;
}

.btn:active {
    transform: translateY(1px);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-sm {
    padding: 0.35rem 0.75rem;
    font-size: 0.8rem;
    border-radius: 8px;
}

.btn-block {
    width: 100%;
    margin-top: 0.5rem;
    padding: 0.75rem;
}

.btn-primary {
    background-color: var(--primary-color);
    color: var(--on-primary);
}

.btn-primary:hover:not(:disabled) {
    background-color: var(--primary-hover);
    box-shadow: 0 4px 14px var(--primary-soft);
}

.btn-secondary {
    background-color: var(--card-bg-color);
    color: var(--text-color);
    border-color: var(--input-border);
}

.btn-secondary:hover {
    background-color: var(--surface-secondary);
}

.btn-ghost-danger {
    background: transparent;
    color: var(--text-secondary);
}

.btn-ghost-danger:hover {
    color: var(--danger-color);
    background: var(--danger-soft);
}

.btn-danger-outline {
    background: transparent;
    color: var(--danger-color);
    border-color: var(--danger-color);
}

.btn-danger-outline:hover {
    background: var(--danger-color);
    color: var(--on-danger);
}

.btn-icon {
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-secondary);
    padding: 0.35rem 0.5rem;
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.85rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-icon:hover:not([disabled]) {
    background: var(--surface-secondary);
    color: var(--text-color);
}

.btn-icon-danger:hover:not([disabled]) {
    background: var(--danger-soft);
    color: var(--danger-color);
}

.btn-icon[disabled] {
    opacity: 0.3;
    cursor: default;
}

.file-button {
    position: relative;
    cursor: pointer;
}

/* ==========================================================================
   9. Forms
   ========================================================================== */
.form-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0 1.25rem;
}

@media (min-width: 768px) {
    .form-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .form-grid .grid-col-span-2 {
        grid-column: span 2;
    }
}

.form-grid > div {
    margin-bottom: 0.25rem;
}

label.form-label {
    display: block;
    font-size: 0.82rem;
    font-weight: 600;
    margin-bottom: 0.35rem;
}

.optional {
    font-weight: 400;
    color: var(--text-faint);
    font-size: 0.75rem;
    margin-left: 0.25rem;
}

.field-hint {
    font-size: 0.78rem;
    color: var(--text-secondary);
    margin: -0.6rem 0 1rem;
}

.hidden-fields .field-hint {
    margin: 0 0 0.75rem;
}

input[type="text"],
input[type="number"],
input[type="date"],
input[type="password"],
input[type="url"],
input[type="email"],
input[type="tel"],
input[type="search"],
select,
textarea {
    width: 100%;
    padding: 0.65rem 0.85rem;
    margin-bottom: 1rem;
    border: 1px solid var(--input-border);
    border-radius: 10px;
    background-color: var(--input-bg);
    color: var(--text-color);
    font-family: inherit;
    font-size: 0.9rem;
    transition: border-color 0.15s, box-shadow 0.15s;
}

/* Checkboxes: own look in both themes; the tick is an SVG in the colour that sits on --primary-color. */
input[type="checkbox"] {
    appearance: none;
    flex-shrink: 0;
    width: 18px;
    height: 18px;
    margin: 0;
    border: 1.5px solid var(--input-border);
    border-radius: 5px;
    background: var(--input-bg) center / 14px no-repeat;
    cursor: pointer;
    transition: background-color 0.12s, border-color 0.12s, box-shadow 0.12s;
}

input[type="checkbox"]:hover {
    border-color: var(--primary-color);
}

input[type="checkbox"]:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
}

input[type="checkbox"]:checked,
input[type="checkbox"]:indeterminate {
    border-color: var(--primary-color);
    background-color: var(--primary-color);
}

input[type="checkbox"]:checked {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3.5 8.5l3 3 6-7' fill='none' stroke='%23fff' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

input[type="checkbox"]:indeterminate {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4 8h8' fill='none' stroke='%23fff' stroke-width='2.2' stroke-linecap='round'/%3E%3C/svg%3E");
}

body.dark-mode input[type="checkbox"]:checked {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3.5 8.5l3 3 6-7' fill='none' stroke='%23212121' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

body.dark-mode input[type="checkbox"]:indeterminate {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4 8h8' fill='none' stroke='%23212121' stroke-width='2.2' stroke-linecap='round'/%3E%3C/svg%3E");
}

textarea {
    min-height: 90px;
    resize: vertical;
}

input::placeholder,
textarea::placeholder {
    color: var(--text-faint);
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: var(--focus-ring);
}

input:user-invalid,
select:user-invalid {
    border-color: var(--danger-color);
}

input[type="file"] {
    font-family: inherit;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

input[type="file"]::file-selector-button {
    font-family: inherit;
    font-weight: 600;
    padding: 0.45rem 0.9rem;
    margin-right: 0.75rem;
    border-radius: 8px;
    border: 1px solid var(--input-border);
    background: var(--card-bg-color);
    color: var(--text-color);
    cursor: pointer;
}

.form-checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0.25rem 0 1rem;
    font-size: 0.9rem;
    cursor: pointer;
}


.form-section-title {
    font-size: 0.95rem;
    font-weight: 700;
    margin: 1.5rem 0 0.75rem;
    padding-bottom: 0.4rem;
    border-bottom: 1px solid var(--border-color-light);
}

.form-actions {
    margin-top: 1.5rem;
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
}

.form-actions-left {
    justify-content: flex-start;
    margin-top: 0.5rem;
}

.form-error {
    color: var(--danger-color);
    background: var(--danger-soft);
    padding: 0.6rem 0.8rem;
    border-radius: 10px;
    font-size: 0.875rem;
    margin: 0.25rem 0 1rem;
}

.hidden-fields {
    padding-left: 1rem;
    border-left: 3px solid var(--primary-soft);
    margin: 0.25rem 0 1rem;
}

.narrow-form {
    max-width: 440px;
}

.file-row {
    display: flex;
    gap: 1rem;
    align-items: center;
    flex-wrap: wrap;
}

.filter-controls {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
    align-items: center;
    flex-wrap: wrap;
}

.filter-controls input,
.filter-controls select {
    margin-bottom: 0;
    width: auto;
    min-width: 160px;
    padding: 0.55rem 0.8rem;
    font-size: 0.875rem;
}

.filter-controls .search-input {
    flex: 1 1 280px;
    padding-left: 2.2rem;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238f9bba' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: 0.75rem center;
}

/* ==========================================================================
   10. Dialogs
   ========================================================================== */
.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background-color: var(--backdrop);
    backdrop-filter: blur(3px);
    overflow-y: auto;
    padding: 2rem 1rem;
}

.modal-content {
    position: relative;
    background-color: var(--card-bg-color);
    margin: 0 auto;
    padding: 2rem;
    border: 1px solid var(--card-border-color);
    width: 100%;
    max-width: 600px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    animation: modalSlide 0.2s ease-out;
}

.modal-content.modal-lg {
    max-width: 820px;
}

@keyframes modalSlide {
    from {
        opacity: 0;
        transform: translateY(-12px) scale(0.98);
    }

    to {
        opacity: 1;
        transform: none;
    }
}

.close-button {
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
}

.close-button:hover {
    background: var(--surface-secondary);
    color: var(--text-color);
}

.section-title {
    font-size: 1.35rem;
    font-weight: 800;
    margin: 0 2.5rem 1.25rem 0;
    letter-spacing: -0.01em;
}

.modal-subtitle {
    margin: -0.9rem 0 1rem;
}

.form-actions-sticky {
    position: sticky;
    bottom: -2rem;
    background: var(--card-bg-color);
    margin: 1.5rem -2rem -2rem;
    padding: 1rem 2rem;
    border-top: 1px solid var(--border-color-light);
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

.section-header-inline {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    border-bottom: 1px solid var(--border-color-light);
    margin: 1.5rem 0 0.5rem;
}

.section-header-inline .form-section-title {
    border: none;
    margin: 0;
}

.zugeordnete-dienstleistungen-liste {
    list-style: none;
    margin: 0 0 0.5rem;
    padding: 0;
}

.assigned-service-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 0.6rem 0;
    border-bottom: 1px solid var(--border-color-light);
}

.assigned-service-item:last-child {
    border-bottom: none;
}

.assigned-service-item .service-info {
    flex: 1;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.25rem 0.6rem;
}

.assigned-service-item .service-meta {
    font-size: 0.82rem;
    color: var(--text-secondary);
}

.assigned-service-item .service-meta.text-danger {
    color: var(--danger-color);
}

.assigned-service-item .actions {
    display: flex;
    gap: 0.25rem;
}

.history-container {
    max-height: 220px;
    overflow-y: auto;
    background: var(--surface-secondary);
    border-radius: var(--radius-sm);
    padding: 0.5rem 1rem;
}

.history-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.history-item {
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border-color-light);
}

.history-item:last-child {
    border-bottom: none;
}

.history-time {
    font-size: 0.72rem;
    color: var(--text-secondary);
}

.history-action {
    font-size: 0.88rem;
    font-weight: 600;
}

.history-details {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* ==========================================================================
   11. Feedback: toasts, progress
   ========================================================================== */
#toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1100;
    width: min(340px, calc(100vw - 40px));
    pointer-events: none;
}

.toast {
    background-color: var(--toast-bg);
    color: #fff;
    padding: 0.85rem 1rem;
    margin-top: 0.6rem;
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    font-size: 0.9rem;
    font-weight: 500;
    animation: toastIn 0.25s ease-out;
}

.toast.success {
    background-color: var(--toast-success-bg);
}

.toast.error {
    background-color: #b3261e;
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateY(12px);
    }

    to {
        opacity: 1;
        transform: none;
    }
}

.busy-overlay {
    position: fixed;
    inset: 0;
    z-index: 1200;
    background: var(--backdrop);
    display: flex;
    align-items: center;
    justify-content: center;
}

.busy-box {
    background: var(--card-bg-color);
    padding: 1.5rem 2rem;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    text-align: center;
}

.busy-box p {
    margin: 0;
}

.spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--surface-secondary);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 0.75rem;
}

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

/* ==========================================================================
   12. Sign-in screens
   ========================================================================== */
/* A fixed layer instead of a 100vh block: the page itself never scrolls (no 1px rounding at browser zoom,
   no rubber-banding); only a card taller than the window scrolls inside the layer. `margin: auto` centres the
   card without cutting off its top when it doesn't fit. */
.auth-wrap {
    position: fixed;
    inset: 0;
    display: flex;
    padding: 1.5rem;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: none;
}

.auth-wrap > * {
    margin: auto;
}

.auth-card {
    width: min(440px, 100%);
    background: var(--card-bg-color);
    border: 1px solid var(--card-border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 2rem;
}

.auth-brand {
    margin: 0;
    font-weight: 800;
    font-size: 0.85rem;
    letter-spacing: 0.04em;
    color: var(--primary-color);
}

.auth-title {
    margin: 0.25rem 0 1.25rem;
    font-size: 1.6rem;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.auth-links {
    margin: 1rem 0 0;
    text-align: center;
    font-size: 0.875rem;
}

.auth-note {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin: 1rem 0;
}

/* Password field with show/hide button (ui::PasswordInput) */
.pw-field {
    position: relative;
    margin-bottom: 1rem;
}

.pw-field input {
    margin-bottom: 0;
    padding-right: 2.75rem;
}

.pw-toggle {
    position: absolute;
    top: 50%;
    right: 0.3rem;
    transform: translateY(-50%);
    width: 2.1rem;
    height: 2.1rem;
    display: grid;
    place-items: center;
    padding: 0;
    border: 0;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
}

.pw-toggle:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
}

.pw-toggle svg {
    width: 1.15rem;
    height: 1.15rem;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* Six-box code entry (ui::CodeInput): an invisible input on top of the boxes takes the keystrokes. */
.code-input {
    position: relative;
    margin: 0.5rem 0 1rem;
}

.code-input input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    border: 0;
    opacity: 0;
    z-index: 1;
    cursor: text;
    font-size: 16px; /* keeps iOS from zooming in */
}

.code-boxes {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 0.5rem;
}

.code-box {
    aspect-ratio: 4 / 5;
    display: grid;
    place-items: center;
    border: 1px solid var(--input-border);
    border-radius: 12px;
    background: var(--input-bg);
    font-size: 1.6rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.code-box.filled {
    border-color: var(--primary-color);
}

.code-box.active {
    border-color: var(--primary-color);
    box-shadow: var(--focus-ring);
}

.code-box.active:not(.filled)::after {
    content: "";
    width: 2px;
    height: 1.5rem;
    background: var(--primary-color);
    animation: code-caret 1s steps(1) infinite;
}

@keyframes code-caret {
    50% { opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
    .code-box.active:not(.filled)::after { animation: none; }
}

.recovery-key {
    display: block;
    font-size: 1rem;
    letter-spacing: 0.04em;
    word-break: break-all;
    background: var(--surface-secondary);
    padding: 1rem;
    border-radius: 10px;
    margin: 0.75rem 0;
    user-select: all;
}

.qr-box {
    display: flex;
    justify-content: center;
    margin: 1rem 0 0.5rem;
}

.qr-box svg {
    width: 220px;
    height: 220px;
    border-radius: 12px;
}

.totp-secret {
    word-break: break-all;
    font-size: 0.8rem;
}

/* ==========================================================================
   13. Charts (SVG)
   ========================================================================== */
.pie-svg {
    width: 180px;
    height: 180px;
    margin: 1rem 0 0.5rem;
}

.pie-rest {
    stroke: var(--pie-rest-color);
}

.pie-part {
    stroke: var(--primary-color);
}

.pie-label {
    font-size: 26px;
    font-weight: 800;
    fill: var(--primary-color);
    font-family: inherit;
}

.line-chart {
    width: 100%;
    height: 240px;
    display: block;
}

.chart-line {
    stroke: var(--primary-color);
}

.chart-scale {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

.chart-empty {
    height: 240px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    text-align: center;
}

.donut-wrap {
    position: relative;
    width: 220px;
    height: 220px;
    margin: 1.5rem 0;
}

.donut-svg {
    width: 100%;
    height: 100%;
}

.donut-center {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.donut-total {
    font-size: 1.35rem;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}

.donut-center-sub {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.legend-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.4rem 1rem;
    width: 100%;
    font-size: 0.85rem;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.2rem 0.4rem;
    border-radius: 6px;
}

.legend-item span:last-child {
    margin-left: auto;
}

.legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}

/* ==========================================================================
   14. Investment
   ========================================================================== */
.finance-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1.5rem;
    padding-bottom: 2rem;
}

.finor-card {
    position: relative;
    overflow: hidden;
}

.top-gainers-container {
    display: flex;
    overflow-x: auto;
    gap: 1rem;
    padding: 0.25rem 0.25rem 0.75rem;
    margin-bottom: 0.5rem;
}

.top-gainers-container .finor-card {
    flex-shrink: 0;
}

.finance-empty-card {
    min-width: 260px;
    color: var(--text-secondary);
}

#widget-portfolio-value,
#widget-total-profits {
    min-height: 420px;
    display: flex;
    flex-direction: column;
}

#widget-total-profits {
    align-items: center;
    text-align: center;
}

#widget-my-assets {
    grid-column: 1 / -1;
}

.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    flex-wrap: wrap;
}

.finor-label {
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.95rem;
    margin: 0;
    align-self: flex-start;
}

.finor-metric-big {
    font-size: 2.4rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    margin: 0.25rem 0 0.5rem;
    font-variant-numeric: tabular-nums;
}

.trend-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    border-radius: 999px;
    font-size: 0.85rem;
    font-weight: 700;
    background: var(--surface-secondary);
    color: var(--text-secondary);
}

.trend-badge.positive {
    background: var(--success-soft);
    color: var(--success-color);
}

.trend-badge.negative {
    background: var(--danger-soft);
    color: var(--danger-color);
}

.chart-controls-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.chart-controls,
.view-toggle-container {
    display: inline-flex;
    gap: 0.2rem;
    background: var(--surface-secondary);
    padding: 0.2rem;
    border-radius: 10px;
}

.btn-timeframe,
.btn-view-toggle {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 0.3rem 0.65rem;
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.75rem;
    font-weight: 700;
    cursor: pointer;
}

.btn-timeframe:hover,
.btn-view-toggle:hover {
    color: var(--text-color);
}

.btn-timeframe.active,
.btn-view-toggle.active {
    background: var(--card-bg-color);
    color: var(--primary-color);
    box-shadow: var(--shadow-md);
}

body.dark-mode .btn-timeframe.active,
body.dark-mode .btn-view-toggle.active {
    background: var(--primary-soft);
}

.chart-canvas-wrap {
    flex-grow: 1;
    position: relative;
    width: 100%;
    min-height: 260px;
    margin-top: 1rem;
}

.asset-card {
    min-width: 210px;
    cursor: pointer;
    transition: transform 0.15s;
}

.asset-card:hover {
    transform: translateY(-2px);
}

.asset-card.selected {
    outline: 2px solid var(--primary-color);
    outline-offset: -2px;
}

.asset-card-head {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.asset-card-foot {
    margin-top: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
}

.asset-symbol {
    font-weight: 700;
}

.asset-icon-box {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    font-weight: 800;
    margin-right: 1rem;
    flex-shrink: 0;
    background: var(--surface-secondary);
}

.asset-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.9rem 1rem;
    border-radius: var(--radius-md);
    cursor: pointer;
    border-bottom: 1px solid var(--border-color-light);
}

.asset-item:hover {
    background: var(--surface-hover);
}

.asset-item-main {
    display: flex;
    align-items: center;
}

.asset-item-side {
    text-align: right;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.25rem;
}

.asset-actions {
    display: inline-flex;
    gap: 0.15rem;
}

.wallet-list {
    padding: 0.25rem 1rem 1rem 4.5rem;
}

.wallet-row {
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 1rem;
    align-items: center;
    padding: 0.4rem 0;
    border-bottom: 1px dashed var(--input-border);
    font-size: 0.9rem;
}

.wallet-list .btn {
    margin-top: 0.75rem;
}

/* ==========================================================================
   15. Work list (dashboard)
   ========================================================================== */
.worklist-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 320px;
    gap: 1.5rem;
    align-items: start;
    margin-bottom: 1.5rem;
}

.worklist-layout .page-card {
    margin-bottom: 0;
}

.worklist-side {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.worklist-progress {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1.25rem;
}

.progress-text {
    display: flex;
    gap: 0.75rem;
    align-items: baseline;
    flex-wrap: wrap;
}

.progress-text strong {
    font-size: 1.15rem;
}

.progress-track {
    height: 8px;
    border-radius: 999px;
    background: var(--surface-secondary);
    overflow: hidden;
}

.progress-fill {
    display: block;
    height: 100%;
    background: var(--success-color);
    border-radius: 999px;
    transition: width 0.3s ease;
}

/* Floats above the page instead of taking room in the list, so selecting never moves the rows.
   Centred in the content area (right of the 232px sidebar): left/right plus auto margins, so the
   slide-in animation keeps transform to itself. Toasts move up while it is shown. */
.bulk-bar {
    position: fixed;
    left: 232px;
    right: 0;
    bottom: 1.25rem;
    z-index: 900;
    width: max-content;
    max-width: calc(100vw - 232px - 2rem);
    margin-inline: auto;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    padding: 0.6rem 0.65rem 0.6rem 1rem;
    border: 1px solid var(--card-border-color);
    border-radius: 14px;
    background: var(--card-bg-color);
    box-shadow: var(--shadow-lg);
    font-weight: 600;
    font-size: 0.9rem;
    animation: bulk-in 0.18s ease-out;
}

@keyframes bulk-in {
    from { opacity: 0; transform: translateY(0.75rem); }
}

body:has(.bulk-bar) #toast-container {
    bottom: 5.5rem;
}

/* Without the sidebar the bar spans the bottom edge and the toasts move up above it. */
@media (max-width: 900px) {
    .bulk-bar {
        left: 1rem;
        right: 1rem;
        width: auto;
        max-width: none;
        margin-inline: 0;
    }

    body:has(.bulk-bar) #toast-container {
        bottom: 6.5rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    .bulk-bar { animation: none; }
}

.bulk-bar span {
    margin-right: auto;
}

.task-group {
    margin-bottom: 1.25rem;
}

/* Same left edge and spacing as the rows below: 0.5rem padding, a 20px check column, 0.85rem gap. */
.task-group-title {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    margin: 0 0 0.4rem;
    padding: 0 0.5rem;
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
}

.task-group.overdue .task-group-title {
    color: var(--danger-color);
}

.task-group-count {
    padding: 0.05rem 0.5rem;
    border-radius: 999px;
    background: var(--surface-secondary);
    font-size: 0.72rem;
}

.group-check {
    display: inline-flex;
    justify-content: center;
    flex: 0 0 20px;
}

.task-list,
.done-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

/* Rows adapt to the width of the list itself (container queries), not the window: one line with the icon
   actions on the right, or – when narrow – a card with the icons in its top-right corner. */
.worklist {
    container: worklist / inline-size;
}

.task-row {
    display: grid;
    grid-template-columns: 20px 104px minmax(0, 1fr) auto auto;
    grid-template-areas: "check when what money actions";
    gap: 0.4rem 0.85rem;
    align-items: center;
    padding: 0.75rem 0.5rem;
    border-bottom: 1px solid var(--border-color-light);
}

/* Held rows keep the (empty) check column, so every row lines up. */
.task-row.held {
    opacity: 0.8;
}

.task-check {
    grid-area: check;
    justify-self: center;
}

.task-when {
    grid-area: when;
}

.task-what {
    grid-area: what;
}

.task-money {
    grid-area: money;
    align-items: flex-end;
    text-align: right;
}

.money-line {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.money-amount {
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

/* Renewal period as a small circle: 1M, 3M, 1J … (1× = one-off). */
.period-badge {
    flex-shrink: 0;
    width: 30px;
    height: 30px;
    display: inline-grid;
    place-items: center;
    border: 1.5px solid var(--card-border-color);
    border-radius: 50%;
    background: var(--surface-secondary);
    color: var(--text-secondary);
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.task-actions {
    grid-area: actions;
}

@container worklist (max-width: 560px) {
    .task-row {
        grid-template-columns: 20px minmax(0, 1fr) auto;
        grid-template-areas:
            "check what actions"
            ".     when money";
    }

    .task-check {
        align-self: start;
        margin-top: 0.2rem;
    }

    .task-money {
        text-align: right;
    }

    .task-when {
        flex-direction: row;
        gap: 0.5rem;
    }

    .task-actions {
        align-self: start;
    }
}

.task-row:last-child {
    border-bottom: none;
}

.task-row:hover {
    background: var(--surface-hover);
}

.task-row {
    border-radius: 10px;
}

/* Main action at the far right: a round "done" button like in a to-do list. */
.done-btn,
.done-btn-slot {
    flex-shrink: 0;
    width: 34px;
    height: 34px;
    margin-left: 0.25rem;
}

.done-btn {
    display: inline-grid;
    place-items: center;
    padding: 0;
    border: 2px solid var(--primary-color);
    border-radius: 50%;
    background: transparent;
    color: var(--primary-color);
    cursor: pointer;
    transition: background-color 0.15s, color 0.15s, border-color 0.15s;
}

.done-btn:hover {
    background: var(--primary-color);
    color: var(--on-primary);
}

.done-btn:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
}

.done-btn svg {
    width: 16px;
    height: 16px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2.6;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* Held rows: "back to the list" is the main action, drawn quieter. */
.task-row.held .done-btn {
    border-color: var(--input-border);
    color: var(--text-secondary);
}

.task-row.held .done-btn:hover {
    border-color: var(--primary-color);
    background: transparent;
    color: var(--primary-color);
}

/* With a mouse, the list stays calm: secondary actions and selection boxes appear on the row being pointed
   at (or focused), and stay while something is selected. Touch screens always show them. */
@media (hover: hover) {
    .task-row .row-extra,
    .task-row .task-check,
    .task-group-title .group-check input {
        opacity: 0;
        transition: opacity 0.12s;
    }

    .task-row:hover .row-extra,
    .task-row:focus-within .row-extra,
    .row-extra:has(.hold-options),
    .task-row:hover .task-check,
    .task-row:focus-within .task-check,
    .task-group:hover .group-check input,
    .group-check input:focus-visible,
    .worklist.selecting .task-check,
    .worklist.selecting .group-check input {
        opacity: 1;
    }
}

.task-row.overdue .task-when small {
    color: var(--danger-color);
}

.task-when,
.task-what,
.task-money {
    display: flex;
    flex-direction: column;
    min-width: 0;
    line-height: 1.3;
}

.task-when strong {
    font-variant-numeric: tabular-nums;
}

.task-when small,
.task-money small {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.task-what strong {
    overflow-wrap: anywhere;
}

.task-customer {
    font-size: 0.85rem;
    color: var(--text-secondary);
    text-decoration: none;
    overflow-wrap: anywhere;
}

.task-customer:hover {
    color: var(--primary-color);
    text-decoration: underline;
}

.task-money {
    font-size: 0.875rem;
    font-variant-numeric: tabular-nums;
}

.task-actions {
    display: flex;
    gap: 0.25rem;
    align-items: center;
    justify-content: flex-end;
}

.hold-menu {
    position: relative;
}

.hold-options {
    position: absolute;
    right: 0;
    top: calc(100% + 4px);
    z-index: 20;
    min-width: 220px;
    display: flex;
    flex-direction: column;
    padding: 0.35rem;
    background: var(--card-bg-color);
    border: 1px solid var(--card-border-color);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
}

.hold-options button {
    text-align: left;
    padding: 0.55rem 0.7rem;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--text-color);
    font-family: inherit;
    font-size: 0.875rem;
    cursor: pointer;
}

.hold-options button:hover {
    background: var(--surface-secondary);
}

.worklist-empty {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    padding: 2rem 1rem;
    text-align: center;
}

.done-list li {
    display: flex;
    flex-direction: column;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border-color-light);
}

.done-list li:last-child {
    border-bottom: none;
}

.done-list a {
    font-weight: 600;
    text-decoration: none;
}

/* ==========================================================================
   16. Customer page
   ========================================================================== */
.back-link {
    display: inline-block;
    margin-bottom: 0.9rem;
    font-size: 0.875rem;
    font-weight: 600;
    text-decoration: none;
}

.customer-header {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 1rem 2rem;
    align-items: start;
}

.customer-title-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.customer-name {
    margin: 0;
    font-size: 1.6rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    overflow-wrap: anywhere;
}

.customer-contact {
    display: flex;
    gap: 0.4rem 1.25rem;
    flex-wrap: wrap;
    margin-top: 0.4rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.customer-stats {
    display: flex;
    gap: 2rem;
    margin: 0;
}

.customer-stats dt,
.contract-facts dt {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
}

.customer-stats dd {
    margin: 0.15rem 0 0;
    font-size: 1.3rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.customer-actions {
    grid-column: 1 / -1;
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.customer-actions .btn-ghost-danger {
    margin-left: auto;
}

.detail-tabs {
    display: flex;
    gap: 0.25rem;
    margin: 0 0 1rem;
    border-bottom: 1px solid var(--border-color-light);
    overflow-x: auto;
}

.detail-tab {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.65rem 0.9rem;
    border: none;
    border-bottom: 2px solid transparent;
    background: transparent;
    color: var(--text-secondary);
    font-family: inherit;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    white-space: nowrap;
}

.detail-tab:hover {
    color: var(--text-color);
}

.detail-tab.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

.detail-tab-count {
    padding: 0 0.45rem;
    border-radius: 999px;
    background: var(--surface-secondary);
    font-size: 0.72rem;
}

.contract-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.contract-card {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    padding: 1.1rem 1.2rem;
    background: var(--card-bg-color);
    border: 1px solid var(--card-border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
}

.contract-card.overdue {
    border-color: var(--danger-color);
}

.contract-card.inactive {
    opacity: 0.65;
}

.contract-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.75rem;
}

.contract-head h3 {
    margin: 0;
    font-size: 1rem;
    overflow-wrap: anywhere;
}

.contract-price {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.contract-price .text-muted {
    font-size: 0.85rem;
    font-weight: 500;
}

.contract-facts {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.5rem 1rem;
    margin: 0;
}

.contract-facts dd {
    margin: 0.1rem 0 0;
    font-size: 0.875rem;
    font-variant-numeric: tabular-nums;
}

.contract-actions {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
    margin-top: auto;
    padding-top: 0.4rem;
}

.contract-hint {
    margin: 0;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.access-list {
    margin: 0;
}

.access-row {
    display: grid;
    grid-template-columns: minmax(0, 260px) minmax(0, 1fr);
    gap: 1rem;
    align-items: center;
    padding: 0.55rem 0;
    border-bottom: 1px solid var(--border-color-light);
}

.access-row:last-child {
    border-bottom: none;
}

.access-row dt {
    display: flex;
    flex-direction: column;
    font-weight: 600;
    font-size: 0.875rem;
}

.access-group {
    font-size: 0.72rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.access-row dd {
    margin: 0;
    display: flex;
    gap: 0.35rem;
    align-items: center;
    min-width: 0;
}

.access-value {
    flex: 1;
    min-width: 0;
    overflow-wrap: anywhere;
    font-size: 0.85rem;
}

.notes-area {
    min-height: 220px;
}

.timeline {
    list-style: none;
    margin: 0;
    padding: 0 0 0 1rem;
    border-left: 2px solid var(--border-color-light);
}

.timeline-item {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    padding: 0 0 1rem 0.75rem;
    font-size: 0.9rem;
}

.timeline-item::before {
    content: "";
    position: absolute;
    left: -1.42rem;
    top: 0.35rem;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--primary-color);
    border: 2px solid var(--card-bg-color);
}

.timeline-time {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.toast {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.toast span {
    flex: 1;
}

.toast-action {
    pointer-events: auto;
    border: 1px solid rgba(255, 255, 255, 0.6);
    background: transparent;
    color: #fff;
    border-radius: 8px;
    padding: 0.3rem 0.65rem;
    font-family: inherit;
    font-weight: 700;
    font-size: 0.8rem;
    cursor: pointer;
}

.toast-action:hover {
    background: rgba(255, 255, 255, 0.15);
}

/* ==========================================================================
   17. Responsive
   ========================================================================== */
@media (max-width: 1180px) {
    .worklist-layout,
.revenue-analysis-container,
.finance-grid {
        grid-template-columns: 1fr;
    }

    #widget-portfolio-value,
#widget-total-profits {
        min-height: auto;
    }
}

/* Sidebar turns into a top bar with a scrollable navigation row */
@media (max-width: 900px) {
    .app-shell {
        flex-direction: column;
    }

    .sidebar {
        position: static;
        width: auto;
        height: auto;
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
        gap: 0.5rem;
        padding: 0.6rem 1rem;
        border-right: none;
        border-bottom: 1px solid var(--card-border-color);
    }

    .sidebar-brand {
        padding: 0;
    }

    .sidebar-foot {
        border: none;
        padding: 0;
        margin-left: auto;
        flex-direction: row;
        align-items: center;
    }

    .sidebar-user {
        display: none;
    }

    .side-nav {
        order: 3;
        flex: 1 0 100%;
        flex-direction: row;
        overflow-x: auto;
        scrollbar-width: none;
    }

    .side-nav::-webkit-scrollbar {
        display: none;
    }

    .side-link {
        flex-shrink: 0;
    }

    .main-area {
        padding: 1.25rem 1rem 2.5rem;
    }

    .customer-header {
        grid-template-columns: 1fr;
    }

    .customer-stats {
        gap: 1.25rem;
        flex-wrap: wrap;
    }

    .access-row {
        grid-template-columns: 1fr;
        gap: 0.25rem;
    }
}

@media (max-width: 760px) {
    .page-card,
.finor-card {
        padding: 1rem;
        border-radius: var(--radius-md);
    }

    .view-header h2,
.customer-name {
        font-size: 1.3rem;
    }

    .kpi-grid {
        grid-template-columns: 1fr 1fr;
        gap: 0.75rem;
    }

    .dashboard-card {
        padding: 0.9rem 1rem;
        border-radius: var(--radius-md);
    }

    .dashboard-card .value {
        font-size: 1.25rem;
    }

    .dashboard-card h3 {
        font-size: 0.65rem;
    }

    .filter-controls input,
.filter-controls select {
        flex: 1 1 100%;
    }

    /* Less important table columns */
    .col-optional {
        display: none;
    }

    .modal-backdrop {
        padding: 0;
    }

    .modal-content {
        border-radius: 0;
        min-height: 100%;
        padding: 1.25rem;
    }

    .form-actions-sticky {
        bottom: -1.25rem;
        margin: 1.5rem -1.25rem -1.25rem;
        padding: 0.75rem 1.25rem;
        border-radius: 0;
    }

    .wallet-list {
        padding-left: 1rem;
    }
}

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

.chart-stop {
    stop-color: var(--primary-color);
}
