/* ===================================================================
   Daily KPIs – Custom theme on top of Pico CSS
   Blue/grey color scheme, professional look
   =================================================================== */

:root {
    --primary: #2c4a7c;
    --primary-hover: #1e3660;
    --primary-light: #e8eef6;
    --accent: #3b82f6;
    --accent-light: #dbeafe;
    --bg: #f0f4f8;
    --bg-card: #ffffff;
    --text: #1e293b;
    --text-muted: #64748b;
    --border: #cbd5e1;
    --danger: #dc2626;
    --danger-bg: #fef2f2;
    --danger-border: #fca5a5;
    --warning: #f59e0b;
    --warning-bg: #fffbeb;
    --success: #16a34a;
    --success-bg: #f0fdf4;
    --info: #0ea5e9;
    --info-bg: #f0f9ff;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.06);
    --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
    --radius: 8px;
}

/* --- Pico overrides --- */
:root {
    --pico-primary: #2c4a7c;
    --pico-primary-hover: #1e3660;
}

/* Reset Pico's aggressive article styling for our custom cards */
article.status-card-sm,
article.kpi-box,
article.chart-container,
article.account-card {
    --pico-block-spacing-vertical: 0;
    --pico-block-spacing-horizontal: 0;
    margin-bottom: 0 !important;
    border: none !important;
}

body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ===== Error Banner ===== */
.error-banner {
    position: sticky;
    top: 0;
    z-index: 1000;
    background: var(--danger);
    color: #fff;
    text-align: center;
    padding: 0.6rem 1rem;
    font-weight: 600;
    font-size: 0.95rem;
    letter-spacing: 0.01em;
    box-shadow: 0 2px 4px rgba(220,38,38,0.3);
}

/* ===== Header ===== */
.app-header {
    background: linear-gradient(135deg, #1e3a5f 0%, #2c4a7c 100%);
    color: #fff;
    padding: 0;
    box-shadow: var(--shadow-md);
    position: sticky;
    top: 0;
    z-index: 900;
}

.error-banner ~ .app-header {
    position: relative;
}

.header-inner {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0.6rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: nowrap;
}

.app-title {
    margin: 0 0.5rem 0 0;
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    white-space: nowrap;
    color: #fff;
}

.header-nav {
    display: flex;
    gap: 0.25rem;
    flex-wrap: nowrap;
    flex: 1;
    justify-content: center;
    flex-shrink: 1;
    min-width: 0;
}

.header-nav a {
    color: rgba(255,255,255,0.85);
    text-decoration: none;
    padding: 0.25rem 0.4rem;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 500;
    transition: background 0.15s, color 0.15s;
    white-space: nowrap;
}

.header-nav a:hover,
.header-nav a.active {
    background: rgba(255,255,255,0.18);
    color: #fff;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    white-space: nowrap;
    flex-shrink: 0;
}

.lang-btn {
    background: rgba(255,255,255,0.15);
    color: #fff;
    border: 1px solid rgba(255,255,255,0.3);
    padding: 0.25rem 0.6rem;
    border-radius: 4px;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}
.lang-btn:hover {
    background: rgba(255,255,255,0.3);
}

.user-info {
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.logout-btn {
    background: rgba(255,255,255,0.15);
    color: #fff;
    border: 1px solid rgba(255,255,255,0.3);
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 0.78rem;
    cursor: pointer;
    transition: background 0.15s;
}
.logout-btn:hover {
    background: rgba(220,38,38,0.5);
}

/* ===== Main content ===== */
main.container {
    max-width: 1860px;
    padding: 1rem 1.5rem;
    flex: 1;
}

.page { animation: fadeIn 0.2s ease-in; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ===== Login ===== */
.login-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 60vh;
}

.login-card {
    max-width: 380px;
    width: 100%;
    padding: 2rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    background: var(--bg-card);
}

.login-card h2 {
    text-align: center;
    color: var(--primary);
    margin-bottom: 1.5rem;
}

.form-error {
    background: var(--danger-bg);
    color: var(--danger);
    border: 1px solid var(--danger-border);
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    font-size: 0.85rem;
    margin-bottom: 0.75rem;
}

.form-info {
    background: var(--info-bg);
    color: var(--info);
    border: 1px solid #7dd3fc;
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    font-size: 0.85rem;
    margin-top: 0.75rem;
}

/* ===== Daily Dashboard Header Row =====
   H2 on its own line (left-aligned), status cards below centered over the
   month picker. With only 2 cards visible (permission-filtered), they sit
   centered; with 5 cards they spread across the row. */
.daily-header-row {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
    margin-bottom: 1rem;
}
.daily-header-row h2 {
    margin: 0;
    white-space: nowrap;
    font-size: 1.3rem;
}
.daily-header-row .status-cards-compact {
    margin-bottom: 0;
}

/* ===== Compact Status Cards (top row) ===== */
.status-cards-compact {
    display: grid !important;
    grid-template-columns: repeat(auto-fit, minmax(200px, 300px));
    gap: 0.75rem;
    margin: 0 auto 1.25rem;
    justify-content: center;
    width: 100%;
}

.status-card-sm {
    background: var(--bg-card) !important;
    border-radius: var(--radius) !important;
    box-shadow: var(--shadow-sm) !important;
    padding: 0.2rem 0.5rem !important;
    margin: 0 !important;
    display: flex;
    flex-direction: column;
    gap: 0;
    max-height: 45px;
    overflow: hidden;
    border-left: 3px solid var(--primary);
    border-top: none;
    border-right: none;
    border-bottom: none;
}

/* When JS sets style="display: none" to hide a permission-restricted card
   it must win over the flex rule above. */
.status-card-sm[style*="display: none"],
.status-card-sm[style*="display:none"] {
    display: none !important;
}

.sc-label {
    font-size: 0.6rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    line-height: 1.1;
    white-space: normal;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.sc-value {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--primary);
    font-variant-numeric: tabular-nums;
}

.sc-value.danger { color: var(--danger); }
.sc-value.success { color: var(--success); }
.sc-value.warning { color: var(--warning); }

.sc-sub {
    font-size: 0.6rem;
    color: var(--text-muted);
    line-height: 1.2;
}

/* ===== Month Picker ===== */
.month-picker {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 1rem;
    overflow: visible;
    position: relative;
}
.daily-export-wrap {
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
}
#page-monthly .month-picker {
    justify-content: center;
}
.md-picker-spacer { flex: 1; }
.md-picker-right {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 0.75rem;
}

.mp-btn {
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    width: 2rem;
    height: 2rem;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    line-height: 1;
    transition: background 0.15s;
}

.mp-btn:hover {
    background: var(--primary-hover);
}

.mp-label {
    font-size: 1rem;
    font-weight: 700;
    color: var(--primary);
    min-width: 160px;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

/* ===== KPI Summary Row ===== */
.kpi-summary-row {
    display: grid !important;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}

.kpi-box {
    background: var(--bg-card) !important;
    border-radius: var(--radius) !important;
    box-shadow: var(--shadow) !important;
    padding: 0.6rem !important;
    margin: 0 !important;
}

.kpi-title {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-bottom: 0.3rem;
}

.kpi-amount {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text);
    font-variant-numeric: tabular-nums;
    margin-bottom: 0.2rem;
}

.kpi-compare {
    font-size: 0.75rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.3rem;
    flex-wrap: wrap;
}

.kpi-compare .kpi-arrow {
    font-size: 0.85rem;
    line-height: 1;
}

.kpi-compare.positive { color: var(--success); }
.kpi-compare.negative { color: var(--danger); }

.kpi-prev-label {
    font-size: 0.68rem;
    color: var(--text-muted);
    font-weight: 400;
}

/* ===== Old Status Cards (used on Liquidity page) ===== */
.status-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.status-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 0;
    overflow: hidden;
    margin: 0;
}

.status-card header {
    background: var(--primary-light);
    color: var(--primary);
    padding: 0.6rem 1rem !important;
    margin: 0 !important;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    border-bottom: none !important;
}

.status-value {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--primary);
    text-align: center;
    padding: 1rem;
    margin: 0;
}

.status-value.danger { color: var(--danger); }
.status-value.success { color: var(--success); }
.status-value.warning { color: var(--warning); }

/* ===== Charts ===== */
.chart-container {
    background: var(--bg-card) !important;
    border-radius: var(--radius) !important;
    box-shadow: var(--shadow) !important;
    padding: 0 !important;
    overflow: hidden;
    margin-bottom: 1.25rem !important;
}

.chart-container header {
    background: var(--primary-light);
    color: var(--primary);
    padding: 0.6rem 1rem !important;
    margin: 0 !important;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    border-bottom: none !important;
}

.chart-container .chart-wrapper {
    position: relative;
    height: 360px;
    padding: 0.75rem 1rem 1rem 1rem;
}

.chart-container canvas {
    max-height: 100%;
}

/* Global BA Filter (above KPI boxes) */
.global-ba-filter {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    padding: 0.5rem 1rem;
    margin: 0.5rem 0;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    flex-wrap: wrap;
}

.global-ba-filter label {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    white-space: nowrap;
    margin-bottom: 0;
}

.global-ba-filter label:hover {
    color: var(--text);
}

.global-ba-filter input[type="checkbox"] {
    width: 15px;
    height: 15px;
    margin: 0;
    cursor: pointer;
    accent-color: var(--primary);
}

.global-ba-filter .ba-swatch {
    display: inline-block;
    width: 11px;
    height: 11px;
    border-radius: 2px;
    vertical-align: middle;
}

/* ===== Filter Bars ===== */
.filter-bar {
    display: flex;
    align-items: flex-end;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
    background: var(--bg-card);
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

.filter-bar label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 0;
}

.filter-bar input[type="date"],
.filter-bar select {
    padding: 0.35rem 0.5rem;
    font-size: 0.85rem;
    margin-bottom: 0;
}

.filter-bar button {
    padding: 0.4rem 1rem;
    font-size: 0.85rem;
    margin-bottom: 0;
}

.severity-filter {
    display: flex;
    gap: 2px;
    margin-left: auto;
}
.sev-btn {
    padding: 0.3rem 0.7rem;
    font-size: 0.75rem;
    border: 1px solid var(--border);
    background: #fff;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: 0;
}
.sev-btn:first-child { border-radius: var(--radius) 0 0 var(--radius); }
.sev-btn:last-child { border-radius: 0 var(--radius) var(--radius) 0; }
.sev-btn.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}
.sev-btn:hover:not(.active) {
    background: var(--primary-light);
}

/* ===== Detail Filter Bar (Orders/Revenue pages) ===== */
.detail-filter-bar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 0.75rem;
    background: var(--bg-card);
    padding: 0.4rem 0.75rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.filter-sep {
    width: 1px;
    height: 22px;
    background: var(--border);
    margin: 0 0.2rem;
}

/* Period toggles (MTD / YTD / Custom) */
.toggle-btn {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: 0.2rem 0.55rem;
    border-radius: 4px;
    font-size: 0.73rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
    margin: 0;
    line-height: 1.4;
}
.toggle-btn:hover { border-color: var(--primary); color: var(--primary); background: transparent; }
.toggle-btn.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

/* BA toggle buttons */
.ba-toggle {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    margin: 0;
    line-height: 1.4;
}
.ba-toggle:hover { border-color: var(--primary); background: transparent; }
.ba-toggle.active {
    background: var(--primary-light);
    color: var(--primary);
    border-color: var(--primary);
}

/* Inline date pickers */
.custom-dates input[type="date"] {
    height: 28px !important;
    font-size: 12px !important;
    padding: 2px 4px !important;
    width: 130px;
    margin-bottom: 0;
    line-height: 1 !important;
}
.custom-dates label {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 0;
}

/* Month picker inside detail filter bar */
.detail-month-picker {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}
.detail-month-picker .dmp-btn {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: 0 0.35rem;
    border-radius: 4px;
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    line-height: 26px;
    height: 28px;
    margin: 0;
    transition: all 0.15s;
}
.detail-month-picker .dmp-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: transparent;
}
.detail-month-picker .dmp-label {
    font-size: 0.73rem;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    min-width: 90px;
    text-align: center;
}

/* Small export button */
.export-btn-sm {
    background: var(--success);
    color: #fff;
    border: none;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 0.72rem;
    font-weight: 600;
    cursor: pointer;
    margin-left: auto;
    white-space: nowrap;
    line-height: 1.4;
    margin-bottom: 0;
}
.export-btn-sm:hover { background: #15803d; }

/* ===== Detail Summary Bar ===== */
.detail-summary-bar {
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
    margin-bottom: 0.5rem;
    padding: 0.4rem 0.75rem;
    background: var(--accent-light);
    border-radius: var(--radius);
    font-size: 0.82rem;
    align-items: center;
    min-height: 1.6rem;
}
.detail-summary-bar:empty { display: none; }
.summary-compare { font-size: 0.78rem; font-weight: 600; }
.summary-compare.positive { color: var(--success); }
.summary-compare.negative { color: var(--danger); }

/* ===== Column Filters ===== */
.column-filters { display: none; }

/* ===== Compact Detail Tables ===== */
.sortable-table {
    font-size: 12px;
    border-collapse: collapse;
    width: 100%;
    table-layout: fixed;
}
.sortable-table th,
.sortable-table td {
    padding: 2px 4px !important;
    white-space: nowrap;
    overflow: hidden;
    line-height: 1.3;
}
.sortable-table td.ellip {
    text-overflow: ellipsis;
    max-width: 0; /* forces ellipsis with table-layout:fixed */
}
.sortable-table td.ellip[title] {
    cursor: default;
}
/* Sticky thead — detail pages only (pages with sortable-table) */
.sortable-table thead {
    position: sticky;
    top: 0;
    z-index: 2;
}
.sortable-table thead th {
    background: var(--primary);
    color: #fff;
    cursor: pointer;
    user-select: none;
    font-weight: 600;
    font-size: 11px;
    text-transform: none;
    border-bottom: none;
    position: relative;
}
.sortable-table thead th:hover {
    background: var(--primary-hover);
}
.sort-indicator {
    margin-left: 0.15rem;
    font-size: 0.55rem;
    opacity: 0.5;
}
.sort-active .sort-indicator {
    opacity: 1;
}

/* Column widths */
.col-datum    { width: 75px; }
.col-auftrag  { width: 100px; }
.col-artnr    { width: 80px; }
.col-bez      { width: 180px; }
.col-kdnr     { width: 60px; }
.col-kunde    { width: 150px; }
.col-gb       { width: 40px; }
.col-menge    { width: 70px; }
.col-epreis   { width: 80px; }
.col-gpreis   { width: 90px; }
.col-rabatt   { width: 55px; }
.col-typ      { width: 45px; }
.col-pe       { width: 45px; }

/* Column resize handle */
.col-resize-handle {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 5px;
    cursor: col-resize;
    background: transparent;
    z-index: 3;
}
.col-resize-handle:hover,
.col-resize-handle.dragging {
    background: rgba(255,255,255,0.4);
}

/* ===== Inline Header Filters ===== */
.filter-row th {
    padding: 1px 2px !important;
    background: var(--primary-light) !important;
    border-bottom: 2px solid var(--border);
}
.th-filter {
    width: 100% !important;
    height: 22px !important;
    font-size: 11px !important;
    padding: 1px 4px !important;
    line-height: 1 !important;
    border: 1px solid #ccc !important;
    margin: 0 !important;
    border-radius: 2px !important;
    background: #fff !important;
    color: var(--text);
    box-sizing: border-box !important;
}
.th-filter::placeholder { color: #bbb; font-size: 10px !important; }
.th-filter:focus {
    outline: none !important;
    border-color: var(--accent) !important;
    box-shadow: 0 0 0 1px var(--accent-light) !important;
}

/* ===== Pagination Bar ===== */
.pagination-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    padding: 0.5rem 0;
    font-size: 0.82rem;
}
.pagination-bar:empty { display: none; }

.pagination-bar button {
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 0.15rem 0.45rem;
    border-radius: 4px;
    font-size: 0.75rem;
    cursor: pointer;
    margin: 0;
    line-height: 1.4;
}
.pagination-bar button:hover:not(:disabled) {
    border-color: var(--primary);
    color: var(--primary);
}
.pagination-bar button:disabled {
    opacity: 0.35;
    cursor: default;
}
.pagination-bar button.pg-active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}
.pagination-bar .page-info {
    font-size: 0.73rem;
    color: var(--text-muted);
    margin-left: 0.5rem;
}

/* ===== Summary Bars ===== */
.summary-bar {
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
    padding: 0.6rem 1rem;
    background: var(--accent-light);
    border-radius: var(--radius);
    font-size: 0.85rem;
}

.summary-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.summary-label {
    font-weight: 600;
    color: var(--primary);
}

.summary-value {
    font-weight: 700;
    color: var(--text);
}

/* ===== Data Tables ===== */
.table-scroll {
    overflow-x: auto;
    margin-bottom: 1rem;
}
/* Detail pages: vertical scroll with sticky header */
.table-scroll:has(.sortable-table) {
    max-height: calc(100vh - 260px);
    overflow-y: auto;
    overflow-x: hidden;
    position: relative;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
    background: var(--bg-card);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}

.data-table thead th {
    background: var(--primary);
    color: #fff;
    padding: 0.55rem 0.75rem;
    text-align: left;
    font-weight: 600;
    white-space: nowrap;
    position: sticky;
    top: 0;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.data-table tbody td {
    padding: 0.45rem 0.75rem;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.data-table tbody tr:hover {
    background: var(--primary-light);
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

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

/* ===== Severity Badges ===== */
.badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 12px;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.badge-error { background: var(--danger-bg); color: var(--danger); border: 1px solid var(--danger-border); }
.badge-warning { background: var(--warning-bg); color: #92400e; border: 1px solid #fcd34d; }
.badge-info { background: var(--info-bg); color: #0369a1; border: 1px solid #7dd3fc; }
.badge-success { background: var(--success-bg); color: #166534; border: 1px solid #86efac; }

.badge-imported { background: var(--success-bg); color: var(--success); }
.badge-quarantined { background: var(--danger-bg); color: var(--danger); }

/* ===== Import Run Detail ===== */
.run-row { cursor: pointer; }
.run-row.expanded td { background: var(--primary-light); }
.run-detail-row td { padding: 0 !important; background: #fafbfc; border-bottom: 1px solid var(--border); }
.run-detail-row:hover td { background: #fafbfc; }
.run-detail-content { padding: 8px 12px; }
.run-detail-section { margin-bottom: 6px; font-size: 12px; line-height: 1.4; }
.run-detail-section strong { font-size: 12px; }
.run-detail-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
    margin-top: 3px;
}
.run-detail-table th {
    text-align: left;
    font-weight: 600;
    padding: 2px 8px;
    border-bottom: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 10px;
    text-transform: uppercase;
    height: 28px;
    line-height: 24px;
}
.run-detail-table td {
    padding: 2px 8px;
    border-bottom: 1px solid #f0f0f0;
    height: 28px;
    line-height: 24px;
}

/* ===== Admin Tabs ===== */
.admin-tabs {
    display: flex;
    gap: 0.25rem;
    margin-bottom: 1.5rem;
    border-bottom: 2px solid var(--border);
    padding-bottom: 0;
}

.admin-tab {
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    color: var(--text-muted);
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    margin-bottom: -2px;
    transition: color 0.15s, border-color 0.15s;
}

.admin-tab:hover {
    color: var(--primary);
}

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

.admin-panel { animation: fadeIn 0.15s ease-in; }

/* ===== Import ===== */
.import-btn {
    margin-bottom: 1rem;
}

.import-result {
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    font-size: 0.85rem;
}

.import-result.success {
    background: var(--success-bg);
    color: #166534;
    border: 1px solid #86efac;
}

.import-result.error {
    background: var(--danger-bg);
    color: var(--danger);
    border: 1px solid var(--danger-border);
}

/* ===== Export Form ===== */
.export-form {
    max-width: 600px;
}

/* ===== Cashpool Indicator ===== */
.cashpool-ok {
    color: var(--success);
    font-weight: 600;
}
.cashpool-warn {
    color: var(--warning);
    font-weight: 600;
}

/* ===== Liquidity Account Cards ===== */
.account-card {
    background: var(--bg-card) !important;
    border-radius: var(--radius) !important;
    box-shadow: var(--shadow) !important;
    padding: 0.4rem 0.6rem !important;
    margin: 0 !important;
}

.account-card .account-name {
    font-size: 0.65rem;
    color: var(--text-muted);
    font-weight: 600;
    margin-bottom: 0.1rem;
    line-height: 1.3;
}

.account-card .account-balance {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--primary);
    line-height: 1.2;
}

.account-card .account-iban {
    font-size: 0.6rem;
    color: var(--text-muted);
    margin-top: 0.05rem;
    font-family: monospace;
}

.account-card.master {
    border-left: 4px solid var(--accent);
}

.account-card.total-card {
    background: var(--primary-light) !important;
    border-left: 4px solid var(--primary) !important;
    grid-column: 1 / -1;
    padding: 0.5rem 0.7rem !important;
    max-height: none;
}

.account-card.total-card .account-balance {
    font-size: 1.1rem;
}

/* ===== Pivot Cashflow Table ===== */
.pivot-scroll {
    overflow-x: auto;
    margin-bottom: 1rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-card);
    box-shadow: var(--shadow-sm, 0 1px 3px rgba(0,0,0,.08));
}
.pivot-table {
    border-collapse: collapse;
    font-size: 12px;
    white-space: nowrap;
    width: max-content;
    min-width: 100%;
}
/* Sticky left category column */
.pivot-table th.pivot-cat-col,
.pivot-table td.pivot-cat-col {
    position: sticky;
    left: 0;
    z-index: 10;
    background: var(--bg-card, #fff);
    min-width: 180px;
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    padding: 0 10px;
    border-right: 2px solid var(--border);
}
/* Sticky right total column */
.pivot-table th.pivot-total-col,
.pivot-table td.pivot-total-cell {
    position: sticky;
    right: 0;
    z-index: 2;
    background: inherit;
    min-width: 100px;
    padding: 0 10px;
    border-left: 2px solid var(--border);
    font-weight: 600;
    text-align: right;
    font-variant-numeric: tabular-nums;
}
/* Header row */
.pivot-table thead tr {
    background: var(--primary);
    color: #fff;
}
.pivot-table thead th {
    padding: 4px 6px;
    text-align: center;
    font-weight: 600;
    font-size: 11px;
    line-height: 1.3;
    position: sticky;
    top: 0;
    z-index: 3;
}
.pivot-table thead th.pivot-cat-col,
.pivot-table thead th.pivot-total-col {
    z-index: 11;
    background: var(--primary);
}
.pivot-table thead th.pivot-kw-col {
    background: #3a5a8c;
}
/* Day columns */
.pivot-day-col { min-width: 72px; text-align: center; }
.pivot-day-cell {
    text-align: right;
    padding: 0 8px;
    height: 28px;
    line-height: 28px;
    font-variant-numeric: tabular-nums;
    color: var(--text-muted);
}
.pivot-day-cell.has-txns { color: var(--text); cursor: pointer; }
.pivot-day-cell.has-txns:hover { background: #e8eef6; }
.pivot-day-cell.positive { color: var(--success, #16a34a); }
.pivot-day-cell.negative { color: var(--danger); }
.pivot-day-cell.active-cell { background: var(--accent-light, #dbeafe); outline: 2px solid var(--primary); outline-offset: -2px; }
/* KW subtotal columns */
.pivot-kw-col { min-width: 80px; text-align: center; }
.pivot-kw-cell {
    text-align: right;
    padding: 0 8px;
    height: 28px;
    line-height: 28px;
    font-variant-numeric: tabular-nums;
    font-weight: 500;
    font-style: italic;
    background: #f0f4f8 !important;
    border-left: 1px solid var(--border);
    border-right: 1px solid var(--border);
}
.pivot-kw-cell.positive { color: var(--success, #16a34a); }
.pivot-kw-cell.negative { color: var(--danger); }
/* Section header row — force white-on-blue on ALL cells including sticky */
.pivot-section-header {
    cursor: pointer;
    user-select: none;
}
.pivot-section-header td,
.pivot-section-header td.pivot-cat-col,
.pivot-section-header td.pivot-total-cell,
.pivot-table .pivot-section-header td,
.pivot-table .pivot-section-header td.pivot-cat-col {
    background: var(--primary) !important;
    color: #ffffff !important;
    font-weight: 600;
    font-size: 13px;
    padding: 4px 10px;
    height: 28px;
    line-height: 20px;
    border-bottom: 1px solid var(--border);
    border-top: 1px solid var(--border);
}
.pivot-collapse-arrow {
    display: inline-block;
    width: 14px;
    font-size: 10px;
    text-align: center;
}
/* Category row */
.pivot-cat-row { background: var(--bg-card); }
.pivot-cat-row td {
    border-bottom: 1px solid #eee;
    height: 28px;
    line-height: 28px;
}
.pivot-cat-row td.pivot-cat-col {
    font-weight: 500;
    background: var(--bg-card, #fff);
}
.pivot-cat-row:hover td { background: var(--primary-light); }
.pivot-cat-row:hover td.pivot-kw-cell { background: #e4ebf3 !important; }
.pivot-cat-row:hover td.pivot-cat-col { background: var(--primary-light); }
.pivot-cat-row td.pivot-total-cell { background: var(--bg-card); }
.pivot-cat-row:hover td.pivot-total-cell { background: var(--primary-light); }
/* Section total row */
.pivot-section-total { background: #f8f9fa; }
.pivot-section-total td {
    font-weight: 600;
    border-top: 2px solid var(--border);
    border-bottom: 1px solid var(--border);
    height: 28px;
    line-height: 28px;
}
.pivot-section-total td.pivot-cat-col { background: #f8f9fa; }
.pivot-section-total td.pivot-total-cell { background: #f8f9fa; }
.pivot-section-total td.pivot-day-cell { color: var(--text); }
.pivot-section-total td.pivot-day-cell.positive { color: var(--success, #16a34a); }
.pivot-section-total td.pivot-day-cell.negative { color: var(--danger); }
/* Grand total row */
.pivot-grand-total { background: var(--primary-light); }
.pivot-grand-total td {
    font-weight: 700;
    font-size: 13px;
    border-top: 2px solid var(--primary);
    height: 32px;
    line-height: 32px;
}
.pivot-grand-total td.pivot-cat-col { background: var(--primary-light); }
.pivot-grand-total td.pivot-total-cell { background: var(--primary-light); }
.pivot-grand-total td.pivot-day-cell { color: var(--text); }
.pivot-grand-total td.pivot-day-cell.positive { color: var(--success, #16a34a); }
.pivot-grand-total td.pivot-day-cell.negative { color: var(--danger); }
/* Balance rows (Anfangssaldo / Endsaldo) */
.pivot-balance-row td {
    font-weight: 700;
    background: #e8edf2 !important;
    color: var(--text);
    border-top: 2px solid var(--border);
    font-size: 11px;
}
.pivot-balance-row td.pivot-cat-col { background: #e8edf2 !important; }
.pivot-balance-row td.pivot-total-cell { background: #e8edf2 !important; }
.pivot-balance-row .recon-error {
    background: #f8d7da !important;
    color: #721c24;
    font-weight: 700;
}
.pivot-balance-row .recon-warn {
    background: #fff3cd !important;
    color: #856404;
}
/* Detail row (expanded transactions below category) */
.pivot-detail-row { display: none !important; }
.pivot-ext-detail {
    background: #fafbfc;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 8px 12px;
    margin-top: 8px;
    max-height: 250px;
    overflow-y: auto;
}
.pivot-detail-content {
    padding: 6px 12px;
    max-height: 200px;
    overflow-y: auto;
}
.pivot-detail-header {
    font-weight: 600;
    font-size: 12px;
    margin-bottom: 4px;
    color: var(--primary);
}
.pivot-detail-table {
    /* Fixed layout + full width: every column except Verwendungszweck has a
       fixed width, so Verwendungszweck absorbs ALL remaining space (flexible,
       generous reading width). Betrag sits right after it. */
    table-layout: fixed;
    width: 100%;
    border-collapse: collapse;
    font-size: 11px;
}
.pivot-detail-table .col-datum   { width: 74px; }
.pivot-detail-table .col-empf    { width: 150px; }
.pivot-detail-table .col-betrag  { width: 104px; }
.pivot-detail-table .col-konto   { width: 120px; }
.pivot-detail-table .col-status  { width: 112px; }
/* Empfänger truncates if long; the amount stays put. */
.pivot-detail-table td.col-empf {
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
/* Verwendungszweck = the ONLY column without a fixed width → it takes the rest
   (much more reading width than before). Ellipsis only if it still overflows. */
.pivot-detail-table td.detail-ref-cell {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
/* Category column: dropdown/badge + action symbol on ONE line, vertically
   centered with the category text (inline-flex + align-items:center). */
.pivot-detail-table th.detail-cat-col { width: 196px; }
.pivot-detail-table td.detail-cat-cell { white-space: nowrap; line-height: 1; }
.pivot-detail-table td.detail-cat-cell .cat-cell-inner {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}
/* Both controls: same height, border-box and align-self:center so the action
   symbol is EXACTLY vertically centered with the category text (a select and a
   button otherwise center differently). */
.pivot-detail-table td.detail-cat-cell .cat-cell-inner > * {
    box-sizing: border-box;
    margin: 0;
    align-self: center;
}
.pivot-detail-table td.detail-cat-cell .cat-override-select { max-width: 150px; height: 24px; }
.pivot-detail-table td.detail-cat-cell .split-badge { line-height: 1; }
.pivot-detail-table td.detail-cat-cell .split-edit-btn {
    flex: 0 0 auto;
    height: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}
.pivot-detail-table th {
    text-align: left;
    font-weight: 600;
    padding: 2px 8px;
    border-bottom: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 10px;
    text-transform: uppercase;
}
.pivot-detail-table th.num { text-align: right; }
.pivot-detail-table td {
    padding: 2px 8px;
    border-bottom: 1px solid #f0f0f0;
    height: 24px;
    vertical-align: middle;
}
.pivot-detail-table td.num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}
/* Internal transfers section — distinct amber header (override sticky bg too) */
.pivot-section-header.internal-section td,
.pivot-section-header.internal-section td.pivot-cat-col,
.pivot-table .pivot-section-header.internal-section td,
.pivot-table .pivot-section-header.internal-section td.pivot-cat-col {
    background: #c28b00 !important;
    color: #ffffff !important;
    border-left: 3px solid #f0ad4e;
}
.pivot-detail-table .cat-override-select {
    font-size: 10px;
    padding: 1px 3px;
    height: 22px;
    max-width: 200px;
    vertical-align: middle;
    margin: 0 !important;
}
/* Virtual transaction rows (IC corrections) — italic, dimmed */
.pivot-detail-table tr.virtual-txn {
    font-style: italic;
    opacity: 0.7;
}
/* Category override dropdown in pivot detail table */
.cat-override-select {
    font-size: 10px;
    padding: 1px 4px;
    height: 22px;
    border: 1px solid var(--border);
    border-radius: 3px;
    background: #fff;
    max-width: 180px;
    cursor: pointer;
}
.cat-override-select:disabled {
    opacity: 0.5;
    cursor: wait;
}
/* Manual split (Phase 2b) */
.split-edit-btn {
    font-size: 11px;
    padding: 0 4px;
    height: 22px;
    border: 1px solid var(--border);
    border-radius: 3px;
    background: #fff;
    color: var(--text, #1e293b);
    cursor: pointer;
    line-height: 1;
}
.split-edit-btn:hover { background: var(--bg-muted, #f1f5f9); }
.split-badge {
    font-size: 10px;
    color: #7c3aed;
    font-weight: 600;
    white-space: nowrap;
}
.split-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}
.split-modal {
    background: #fff;
    border-radius: 8px;
    width: min(560px, 94vw);
    max-height: 90vh;
    overflow: auto;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    padding: 16px 18px;
}
.split-modal-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    font-size: 15px;
}
.split-modal-x, .split-modal-cancel {
    border: none;
    background: none;
    color: var(--text, #1e293b);
    cursor: pointer;
    font-size: 16px;
}
.split-modal-info { font-size: 13px; margin-bottom: 10px; }
.split-modal-ref {
    color: var(--text-muted, #64748b);
    font-size: 11px;
    margin-top: 2px;
    word-break: break-word;
}
.split-modal-table { width: 100%; border-collapse: collapse; }
.split-modal-table th {
    text-align: left;
    font-size: 11px;
    color: var(--text-muted, #64748b);
    padding: 2px 4px;
}
.split-modal-table td { padding: 3px 4px; }
.split-modal-table .split-cat,
.split-modal-table .split-amt {
    width: 100%;
    height: 34px;
    font-size: 0.9rem;
    line-height: 1.2;
    padding: 4px 8px;
    box-sizing: border-box;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: #fff;
}
.split-modal-table .split-amt { text-align: right; }
.split-rm {
    border: 1px solid var(--border);
    background: #fff;
    color: var(--text, #1e293b);
    border-radius: 3px;
    cursor: pointer;
    height: 34px;
    box-sizing: border-box;
}
.split-modal-actions-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 10px 0;
}
.split-addrow {
    border: 1px dashed var(--border);
    background: #fff;
    color: var(--text, #1e293b);
    border-radius: 4px;
    padding: 3px 8px;
    cursor: pointer;
    font-size: 12px;
}
.split-sum { font-size: 13px; font-weight: 600; }
.split-sum.ok { color: #16a34a; }
.split-sum.bad { color: #dc2626; }
.split-modal-foot {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    margin-top: 6px;
}
.split-modal-foot button { padding: 5px 12px; border-radius: 5px; cursor: pointer; }
.split-save {
    background: var(--primary, #2563eb);
    color: #fff;
    border: 1px solid var(--primary, #2563eb);
}
.split-save:disabled { opacity: 0.45; cursor: not-allowed; }
.split-del {
    background: #fff;
    color: #dc2626;
    border: 1px solid #dc2626;
}
/* Pico styles a bare <button> with WHITE text; secondary buttons must set a
   dark, readable color explicitly (otherwise white-on-white = invisible). */
.split-cancel {
    background: #fff;
    color: var(--text, #1e293b);
    border: 1px solid var(--border);
}
/* Rules manager (Phase 3) */
.rules-modal { width: min(720px, 96vw); }
.rules-table { font-size: 0.85rem; }
.rules-table th {
    text-align: left;
    font-size: 11px;
    color: var(--text-muted, #64748b);
    border-bottom: 1px solid var(--border);
    padding: 3px 6px;
}
.rules-table td { padding: 3px 6px; border-bottom: 1px solid #f1f5f9; vertical-align: middle; }
.rules-table .rule-pat { font-family: monospace; word-break: break-word; max-width: 240px; }
.rules-table .num { text-align: right; }
/* Match status indicators for internal transfers */
.match-ok { color: #16a34a; font-weight: 600; }
.match-pending { color: #d97706; font-weight: 600; }
.pivot-cat-col .match-pending,
.pivot-cat-col .match-ok { font-size: 0.75rem; margin-left: 0.3rem; }

/* Week picker (mirrors month picker) */
.detail-week-picker {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

/* ===== Resolve Button ===== */
.resolve-btn {
    padding: 0.2rem 0.5rem;
    font-size: 0.72rem;
    background: var(--success);
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}
.resolve-btn:hover {
    background: #15803d;
}

/* ===== Footer ===== */
.app-footer {
    background: var(--primary);
    color: rgba(255,255,255,0.7);
    padding: 0.75rem 0;
    text-align: center;
    margin-top: auto;
}

.app-footer small {
    font-size: 0.75rem;
}

/* ===== Empty State ===== */
.empty-state {
    text-align: center;
    padding: 2rem;
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* ===== Loading Spinner ===== */
.loading {
    text-align: center;
    padding: 2rem;
    color: var(--text-muted);
}

.loading::after {
    content: "";
    display: inline-block;
    width: 1.5rem;
    height: 1.5rem;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    margin-left: 0.5rem;
    vertical-align: middle;
}

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

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .header-inner {
        flex-direction: column;
        align-items: flex-start;
        padding: 0.5rem 1rem;
    }

    .header-nav {
        order: 3;
        justify-content: flex-start;
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .header-right {
        order: 2;
        align-self: flex-end;
        margin-top: -1.8rem;
    }

    .status-cards-compact {
        grid-template-columns: repeat(2, 1fr);
    }

    .kpi-summary-row {
        grid-template-columns: repeat(2, 1fr);
    }

    .status-cards {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    }

    .filter-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .filter-bar label,
    .filter-bar input,
    .filter-bar select,
    .filter-bar button {
        width: 100%;
    }

    main.container {
        padding: 1rem;
    }
}

/* ===== Monthly Dashboard ===== */
.ges-dropdown {
    color: var(--primary);
    border: 1px solid var(--border);
    padding: 0.2rem 1.6rem 0.2rem 0.4rem;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
    background-color: var(--bg-card);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%232c4a7c' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.4rem center;
    margin-left: 1rem;
    width: auto;
    max-width: 130px;
    min-width: 110px;
}
#md-month-picker .ges-dropdown {
    width: auto !important;
    max-width: 130px !important;
    height: 2rem;
    vertical-align: middle;
    margin-top: 0;
    margin-bottom: 0;
}
#md-month-picker input[type="checkbox"] {
    -webkit-appearance: checkbox;
    appearance: checkbox;
    width: 14px;
    height: 14px;
    margin: 0;
    cursor: pointer;
    accent-color: var(--primary);
}
.ges-dropdown option {
    background: var(--bg-card);
    color: var(--text);
}

.md-sub-tabs {
    display: flex;
    gap: 0.25rem;
    margin-bottom: 0.75rem;
    border-bottom: 2px solid var(--border);
    padding-bottom: 0;
}
.md-tab {
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    color: var(--text-muted);
    padding: 0.35rem 0.8rem;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    margin-bottom: -2px;
    transition: color 0.15s, border-color 0.15s;
}
.md-tab:hover { color: var(--primary); }
.md-tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.md-tab-content { animation: fadeIn 0.15s ease-in; }

/* Nur YTD toggle */
.md-ytd-toggle {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 0.4rem;
}
.md-toggle-label {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.3rem;
    margin-left: 0.75rem;
}
.md-toggle-label input { margin: 0; width: auto; }

/* KPI cards — compact */
.md-kpi-row {
    display: grid;
    grid-template-columns: repeat(auto-fill, 220px);
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}
#page-monthly .kpi-box {
    padding: 0.4rem 0.6rem;
    max-height: none;
    width: 220px;
    max-width: 220px;
    box-sizing: border-box;
}
#page-monthly .kpi-compare,
#page-monthly .kpi-compare-row,
#page-monthly .kpi-prev-label {
    white-space: nowrap;
}
#page-monthly .kpi-title {
    font-size: 0.6rem;
    margin-bottom: 0.1rem;
}
#page-monthly .kpi-amount {
    font-size: 1rem;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
#page-monthly .kpi-compare {
    font-size: 0.55rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
#page-monthly .kpi-arrow {
    font-size: 0.5rem;
}
#page-monthly .kpi-prev-label {
    font-size: 0.55rem;
    color: var(--text-muted);
}
.kpi-compare-row {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    flex-wrap: nowrap;
    font-size: 0.55rem;
}

.md-source-hint {
    text-align: center;
    font-size: 0.65rem;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
}

/* Section headers — compact */
.md-section {
    margin-bottom: 0.75rem;
}
.md-section-title {
    font-size: 12px;
    font-weight: 700;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-top: 16px;
    margin-bottom: 0.4rem;
    padding-bottom: 0.2rem;
    border-bottom: 2px solid var(--primary);
}

/* Three-col layout: left = stacked bar + table, right = history chart */
.md-three-col {
    display: flex;
    gap: 0.75rem;
    align-items: flex-start;
}
.md-left-col {
    flex: 1.5;
    min-width: 0;
}
.md-right-col {
    flex: 1;
    min-width: 0;
    position: relative;
    height: 150px;
}
.md-right-col canvas {
    position: absolute;
    top: 0; left: 0;
    width: 100% !important;
    height: 100% !important;
}

/* HTML stacked bar (replaces Chart.js) */
.md-stacked-bar {
    display: flex;
    height: 28px;
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 0.2rem;
}
.md-bar-segment {
    height: 100%;
    transition: opacity 0.15s;
    cursor: default;
}
.md-bar-segment:hover {
    opacity: 0.8;
}
.md-bar-scale {
    display: flex;
    justify-content: space-between;
    font-size: 9px;
    color: var(--text-muted);
    padding: 0 2px;
    margin-bottom: 0.4rem;
}
.md-bar-empty {
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-muted);
    padding: 0.5rem;
}
#page-monthly canvas {
    border: none !important;
    outline: none !important;
}

.md-table-wrap {
    overflow-x: auto;
}

/* GB table — compact */
.md-gb-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 11px;
    background: var(--bg-card);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    table-layout: fixed;
}
.md-gb-table th,
.md-gb-table td {
    padding: 4px 8px;
}
.md-gb-table th:first-child,
.md-gb-table td:first-child {
    width: 60px;
}
.md-gb-table th.num,
.md-gb-table td.num {
    text-align: right;
}
.md-gb-table thead th {
    background: var(--primary);
    color: #fff;
    text-align: left;
    font-weight: 600;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    white-space: nowrap;
}
.md-gb-table tbody td {
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.md-gb-table tbody tr:hover { background: var(--primary-light); }
.md-gb-table .total-row td {
    border-top: 2px solid var(--primary);
    font-weight: 700;
}
.md-gb-table .muted { color: var(--text-muted); }
.md-gb-table .positive { color: var(--success); }
.md-gb-table .negative { color: var(--danger); }

.gb-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 0.2rem;
    vertical-align: middle;
}

.md-kpi-sub {
    font-size: 0.55rem;
    color: var(--text-muted);
    margin-top: 0.1rem;
}
.md-na {
    color: var(--text-muted);
    font-size: 1.1rem;
}
.md-susa-card {
    opacity: 0.6;
}

.md-placeholder-msg {
    background: var(--info-bg);
    color: #0369a1;
    border: 1px solid #7dd3fc;
    padding: 1rem;
    border-radius: var(--radius);
    text-align: center;
    font-size: 0.78rem;
    margin: 1rem 0;
}

.md-susa-placeholder {
    padding: 1rem;
}

.susa-upload-link {
    background: var(--primary);
    color: #fff;
    border: none;
    padding: 0.4rem 1rem;
    border-radius: var(--radius);
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}
.susa-upload-link:hover {
    background: var(--primary-hover);
}

.susa-upload-area {
    max-width: 600px;
}
.susa-upload-info {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
}
.susa-upload-form {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    margin-bottom: 1rem;
}
.susa-upload-form input[type="file"] {
    font-size: 0.85rem;
}

/* GuV table styles */
.md-guv-table {
    margin-top: 0.75rem;
    font-size: 0.8rem;
    font-variant-numeric: tabular-nums;
}
.md-guv-table td,
.md-guv-table th {
    padding: 0.25rem 0.5rem;
}
.md-guv-table thead th {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
}
.md-guv-table .num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}
.md-guv-cat-row {
    cursor: pointer;
    background: #f1f5f9;
}
.md-guv-cat-row:hover { background: #e2e8f0; }
.md-guv-cat-row td {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text);
}
.md-guv-sub {
    padding-left: 1.5rem !important;
    color: var(--text-muted);
    font-size: 0.7rem;
    font-weight: 400;
}
.md-guv-subtotal {
    background: var(--primary-light) !important;
    border-top: 2px solid var(--primary);
}
.md-guv-subtotal td {
    font-weight: 700;
    font-size: 0.75rem;
    color: var(--primary);
}
.md-guv-detail td {
    font-size: 0.75rem;
    color: var(--text-muted);
}
.md-guv-sub-expandable { cursor: pointer; }
.md-guv-sub-expandable:hover { background: #f8fafc; }
.md-guv-konto td {
    font-size: 0.7rem;
    color: var(--text-muted);
    background: #fafbfc;
}
.md-guv-konto-label {
    padding-left: 3rem !important;
    font-weight: 400;
}
.md-guv-ic-marker {
    color: #fd7e14;
    font-size: 0.65rem;
    font-weight: 600;
}
.md-guv-caret {
    display: inline-block;
    width: 0.8em;
    color: var(--text-muted);
    font-size: 0.7em;
}
.md-guv-expand-btns {
    display: flex;
    gap: 0.4rem;
    margin-bottom: 0.5rem;
}
/* Admin: user management */
.role-badge {
    display: inline-block;
    background: var(--primary-light, #e8eef6);
    color: var(--primary, #2c4a7c);
    padding: 1px 7px;
    border-radius: 10px;
    font-size: 0.7rem;
    font-weight: 500;
    margin: 1px 2px;
}
.sm-btn {
    padding: 3px 10px;
    font-size: 0.7rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg-card);
    cursor: pointer;
    color: var(--text);
}
.sm-btn:hover { background: #e2e8f0; }
.sm-btn.outline { background: transparent; }
.sm-btn-danger { color: #dc3545; border-color: #dc3545; }
.sm-btn-danger:hover { background: #dc3545; color: #fff; }
tr.user-inactive td { opacity: 0.45; text-decoration: line-through; }
#user-dialog article { max-width: 400px; padding: 1.2rem; }
#user-form-roles label {
    display: flex; align-items: center; gap: 0.4rem;
    margin: 3px 0; font-size: 0.8rem; white-space: nowrap;
}
#user-form-roles input[type="checkbox"] { width: 16px; height: 16px; margin: 0; }
/* Role permission matrix dialog */
#role-perms-matrix { max-height: 60vh; overflow-y: auto; }
.role-perms-note {
    background: #fff7e6; border: 1px solid #ffd591; color: #ad6800;
    padding: 6px 12px; border-radius: 6px; font-size: 0.8rem; margin-bottom: 0.75rem;
}
.role-perms-group { margin: 0 0 0.75rem 0; padding: 0.5rem 0.75rem; }
.role-perms-group legend { font-weight: 600; font-size: 0.85rem; padding: 0 0.4rem; }
.role-perm-item {
    display: grid; grid-template-columns: 18px 200px 1fr; align-items: center;
    gap: 0.5rem; margin: 2px 0; font-size: 0.8rem; cursor: pointer;
}
.role-perm-item input[type="checkbox"] { width: 16px; height: 16px; margin: 0; }
.role-perm-code { font-family: monospace; color: var(--text); }
.role-perm-desc { color: var(--text-muted); }
/* Auto-import config form */
.import-config {
    background: var(--bg-card, #f8fafc); border: 1px solid var(--border, #e2e8f0);
    border-radius: 8px; padding: 1rem 1.25rem; margin-bottom: 1rem; max-width: 640px;
}
.import-config h3 { margin: 0 0 0.75rem 0; font-size: 0.95rem; }
.import-config .ic-check { display: flex; align-items: center; gap: 0.5rem; margin: 0.35rem 0; font-size: 0.85rem; }
.import-config .ic-check input { width: 16px; height: 16px; margin: 0; }
.import-config .ic-field { display: block; font-size: 0.8rem; color: var(--text-muted); margin: 0.45rem 0; }
.import-config .ic-field input {
    display: block; width: 100%; margin-top: 2px;
    height: 2.2rem; line-height: 1.3; padding: 0 0.5rem;
    box-sizing: border-box; font-size: 0.85rem;
}
.import-config .ic-field input#ic-time { width: 110px; }
.ic-status { margin-top: 0.6rem; font-size: 0.8rem; color: var(--text-muted); }
.import-note { font-size: 0.78rem; color: var(--text-muted); margin: 0.5rem 0 0.75rem 0; max-width: 640px; line-height: 1.4; }
/* Ergebnis + Personal tables — unified fixed width */
.md-overview-table {
    width: 550px !important;
    max-width: 550px !important;
    min-width: 550px !important;
    table-layout: fixed !important;
}
.md-overview-table th:first-child,
.md-overview-table td:first-child {
    width: 250px !important;
}

/* GuV table width constraints — 7 columns */
.md-guv-table {
    max-width: 950px;
    width: auto;
    table-layout: fixed;
}
.md-guv-table th:first-child,
.md-guv-table td:first-child {
    width: 250px;
}
.md-guv-table th:not(:first-child),
.md-guv-table td:not(:first-child) {
    width: 100px;
    text-align: right;
}

/* Bilanz table styles — matches GuV table design */
.md-bilanz-table {
    width: 750px;
    table-layout: fixed;
    margin-top: 0.75rem;
    font-size: 0.8rem;
    font-variant-numeric: tabular-nums;
}
.md-bilanz-table td:first-child,
.md-bilanz-table th:first-child {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.md-bilanz-table td,
.md-bilanz-table th {
    padding: 0.25rem 0.5rem;
}
.md-bilanz-table thead th {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
}
.md-bilanz-table .num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}
.md-bilanz-table td {
    font-size: 0.75rem;
    font-weight: 400;
}
.md-bilanz-subtotal {
    background: var(--primary-light) !important;
    border-top: 2px solid var(--primary);
}
.md-bilanz-subtotal td {
    font-weight: 700;
    font-size: 0.75rem;
    color: var(--primary);
}

/* Sub-tabs row with copy button */
.md-sub-tabs-row {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 0.75rem;
    border-bottom: 2px solid var(--border);
}
.md-sub-tabs-row .md-sub-tabs {
    margin-bottom: 0;
    border-bottom: none;
}
.md-sub-tabs-row .md-copy-btns,
.md-sub-tabs-row .md-export-buttons,
.md-sub-tabs-row .md-guv-export-buttons {
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    gap: 0.4rem;
    flex-shrink: 0;
}
.md-copy-btn {
    background: var(--bg-card); border: 1px solid var(--border); border-radius: 6px;
    padding: 4px 12px; font-size: 0.75rem; cursor: pointer; color: var(--text-secondary);
    transition: background .15s;
}
.md-copy-btn:hover { background: var(--border); }

/* Bilanz sections */
#md-tab-bilanz .md-section {
    margin-bottom: 1rem;
}
#md-tab-bilanz .md-section-title {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 2px solid var(--primary);
    padding-bottom: 0.25rem;
    margin-bottom: 0.5rem;
    color: var(--primary);
    font-weight: 700;
}
/* Bilanz table sizing now handled by .md-bilanz-table + colgroup */
/* Personal table in Monat tab — same constraints */
#md-section-personal .md-gb-table {
    max-width: 600px;
    width: auto;
}
#md-section-personal .md-gb-table th:first-child,
#md-section-personal .md-gb-table td:first-child {
    width: 200px;
}
#md-section-personal .md-gb-table th:not(:first-child),
#md-section-personal .md-gb-table td:not(:first-child) {
    width: 120px;
    text-align: right;
}

/* Margin cards — compact like KPI tiles */
#md-tab-guv .md-kpi-row .kpi-box {
    padding: 0.4rem 0.6rem;
}
#md-tab-guv .md-kpi-row .kpi-title {
    font-size: 0.6rem;
}
#md-tab-guv .md-kpi-row .kpi-amount {
    font-size: 1rem;
}
/* Margin cards: bold, emphasised month value (smaller than the YTD headline). */
#md-tab-guv .md-kpi-row .md-margin-month {
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--text);
    margin-top: 0.2rem;
}

/* Discreet info icon (consolidation disclaimer) — muted, smaller, help cursor.
   Native title tooltip on hover/focus; must not disturb the visual layout. */
.md-info-i {
    color: var(--text-muted);
    font-size: 0.85em;
    font-weight: 400;
    cursor: help;
    opacity: 0.65;
    vertical-align: baseline;
}
.md-info-i:hover, .md-info-i:focus { opacity: 1; outline: none; }

/* Hidden by Nur YTD toggle */
.md-hide-mtd { display: none !important; }

@media (max-width: 768px) {
    .md-kpi-row {
        grid-template-columns: repeat(2, 1fr);
    }
    .md-three-col {
        flex-direction: column;
    }
    .md-right-col {
        height: 120px;
    }
}

@media (max-width: 480px) {
    .status-cards-compact {
        grid-template-columns: 1fr;
    }

    .kpi-summary-row {
        grid-template-columns: 1fr;
    }

    .status-cards {
        grid-template-columns: 1fr;
    }

    .app-title {
        font-size: 1.1rem;
    }

    .header-nav a {
        font-size: 0.72rem;
        padding: 0.25rem 0.35rem;
    }
}

/* GuV Mapping Admin Table */
.guv-mapping-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 0.75rem;
}
.guv-mapping-header h3 {
    font-size: 1rem;
    margin: 0;
    padding: 0;
    line-height: 1;
}
.guv-mapping-header input[type="text"] {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
    height: auto;
    line-height: 1;
    margin-top: 0 !important;
    margin-bottom: 0 !important;
    border: 1px solid var(--border);
}
#guv-mapping-table-wrap {
    max-height: 70vh;
    overflow-y: auto;
}
.guv-mapping-table {
    font-size: 0.8rem;
}
.guv-mapping-table thead th {
    font-size: 0.7rem;
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--primary);
    /* Compact padding so narrow headers (N-WT/N-WiHo/IC) fit their fixed cols. */
    padding-left: 6px;
    padding-right: 6px;
}
.guv-mapping-table td,
.guv-mapping-table th {
    vertical-align: middle;
}
.guv-mapping-table tbody td {
    padding: 2px 6px;
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.guv-mapping-table tbody tr {
    height: auto;
}
.guv-mapping-table td:nth-child(3),
.guv-mapping-table td:nth-child(6),
.guv-mapping-table td:nth-child(8),
.guv-mapping-table td:nth-child(12),
.guv-mapping-table td:nth-child(13),
.guv-mapping-table td:nth-child(14) {
    text-align: center;
}
.guv-map-sel {
    font-size: 0.7rem;
    padding: 1px 3px;
    height: 22px;
    margin: 0;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg);
    width: 100%;
    max-width: 250px;
}
.guv-mapping-table input[type="checkbox"] {
    margin: 0;
    width: 14px;
    height: 14px;
    vertical-align: middle;
}

/* Unknown accounts modal */
.guv-unknown-modal {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}
.guv-unknown-content {
    background: #fff;
    border-radius: 8px;
    padding: 1.5rem;
    max-width: 950px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 4px 24px rgba(0,0,0,0.15);
}
.guv-unknown-content h3 {
    font-size: 1rem;
    color: var(--primary);
    margin: 0 0 0.5rem 0;
}
.guv-unknown-content select {
    font-size: 0.7rem;
    padding: 1px 3px;
    height: 22px;
}
.guv-unknown-content input[type="checkbox"] {
    width: 14px;
    height: 14px;
}

/* Import upload box (drag & drop) */
.upload-box {
    max-width: 600px;
    border: 2px dashed var(--border);
    border-radius: 8px;
    background: var(--bg-card);
    padding: 1.25rem 1.5rem;
    text-align: center;
    cursor: pointer;
    margin-bottom: 0.75rem;
    transition: border-color 0.15s, background 0.15s;
}
.upload-box:hover,
.upload-box.dragover {
    border-color: var(--accent);
    background: var(--accent-light);
}
.upload-box-icon {
    font-size: 1.5rem;
    margin-bottom: 0.25rem;
}
.upload-box-title {
    font-weight: 600;
    font-size: 0.9rem;
}
.upload-box-hint {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}
.upload-box-files {
    margin-top: 0.6rem;
    font-size: 0.8rem;
    text-align: left;
    display: none;
}
.upload-box-files .upload-file-row {
    display: flex;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.2rem 0.5rem;
    background: var(--primary-light);
    border-radius: 4px;
    margin-top: 0.25rem;
}

/* Imports-Tab: Auto-Import-Konfiguration und manueller Upload nebeneinander */
.admin-imports-row {
    display: flex;
    gap: 1rem;
    align-items: stretch;
    flex-wrap: wrap;
    margin-bottom: 1rem;
    max-width: 1100px;
}
.admin-imports-row .import-config {
    flex: 1 1 340px;
    margin-bottom: 0;
    max-width: none;
    display: flex;
    flex-direction: column;
}
.admin-imports-row .import-config form,
.admin-imports-row .import-manual-col .upload-box {
    flex: 1;
}
.admin-imports-row .upload-box {
    max-width: none;
    display: flex;
    flex-direction: column;
    justify-content: center;
    margin-bottom: 0.75rem;
}
