/* ============ TOKENS (Dark / Grün — "Nachtschicht") ============ */
:root {
    --ground: #101215;
    --surface: #1A1D22;
    --surface-2: #21252B;
    --surface-3: #282C33;
    --ink: #F2F4F5;
    --ink-muted: #97A099;
    --ink-faint: #676F72;
    --accent: #059669;
    --accent-bright: #34D399;
    --accent-strong: #047A56;
    --accent-soft: rgba(52, 211, 153, 0.14);
    --accent-on: #FFFFFF;
    --line: rgba(255, 255, 255, 0.08);
    --line-strong: rgba(255, 255, 255, 0.16);
    --warn: #F5A623;
    --warn-soft: rgba(245, 166, 35, 0.14);
    --warn-ink: #F5A623;
    --danger: #F0473E;
    --danger-soft: rgba(240, 71, 62, 0.14);
    --ok: #34D399;
    --business: #C08A3E;
    --business-strong: #A5732F;
    --business-on: #16130B;
    --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.35), 0 1px 1px rgba(0, 0, 0, 0.25);
    --shadow-2: 0 20px 40px rgba(0, 0, 0, 0.45), 0 4px 14px rgba(0, 0, 0, 0.3);
    --glow-accent: 0 0 0 1px rgba(52, 211, 153, 0.28), 0 16px 40px rgba(5, 150, 105, 0.35);
    --radius-s: 10px;
    --radius-m: 16px;
    --radius-l: 22px;
    --tap-min: 44px;
    --sidebar-w: 264px;
    --ease: cubic-bezier(0.16, 1, 0.3, 1);
    --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--ground);
    color: var(--ink);
}
body {
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 16px;
    line-height: 1.45;
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
}

a { color: var(--accent-bright); }
.tnum { font-variant-numeric: tabular-nums; }

h1 { font-size: 1.6rem; font-weight: 800; letter-spacing: -0.02em; margin: 0 0 0.75rem; color: var(--ink); }
h2 { font-size: 1.15rem; font-weight: 750; letter-spacing: -0.01em; margin: 1.5rem 0 0.75rem; color: var(--ink); }

/* ============ APP SHELL / SIDEBAR ============ */
.app-shell {
    display: flex;
    align-items: flex-start;
    min-height: 100vh;
}
.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    width: var(--sidebar-w);
    flex-shrink: 0;
    background: var(--surface);
    border-right: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    padding: 1.25rem 1rem;
    gap: 1.25rem;
    overflow-y: auto;
}
.sidebar-top {
    display: flex;
    align-items: center;
    gap: 0.65rem;
}
.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--accent-soft);
    color: var(--accent-bright);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 0.85rem;
    flex-shrink: 0;
    letter-spacing: 0.02em;
}
.sidebar-user-text { display: flex; flex-direction: column; min-width: 0; }
.sidebar-user-name {
    font-weight: 750;
    font-size: 0.92rem;
    color: var(--ink);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sidebar-app-name { font-size: 0.76rem; color: var(--ink-muted); }
.sidebar-add {
    margin-left: auto;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-s);
    background: var(--accent);
    color: var(--accent-on);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    text-decoration: none;
    box-shadow: var(--shadow-1);
    transition: transform 0.2s var(--ease-spring), box-shadow 0.2s var(--ease), background 0.2s var(--ease);
}
.sidebar-add:hover { background: var(--accent-strong); transform: translateY(-1px) scale(1.04); box-shadow: var(--shadow-2); }
.sidebar-add:active { transform: scale(0.94); }

.sidebar-nav { display: flex; flex-direction: column; gap: 0.15rem; flex: 1; }
.sidebar-section-label {
    font-size: 0.68rem;
    font-weight: 750;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--ink-faint);
    margin: 1rem 0.7rem 0.35rem;
}
.sidebar-section-label:first-child { margin-top: 0; }

.navlink {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    text-decoration: none;
    color: var(--ink-muted);
    font-size: 0.875rem;
    font-weight: 650;
    padding: 0.6rem 0.75rem;
    border-radius: var(--radius-s);
    min-height: var(--tap-min);
    position: relative;
    transition: background 0.18s var(--ease), color 0.18s var(--ease), transform 0.18s var(--ease);
}
.navlink:hover { background: var(--surface-2); color: var(--ink); transform: translateX(2px); }
.navlink.active { background: var(--accent); color: var(--accent-on); box-shadow: var(--shadow-1); }
.navlink.active svg { opacity: 1; }
.navlink svg { opacity: 0.85; flex-shrink: 0; transition: opacity 0.18s var(--ease); }

.sidebar-bottom { border-top: 1px solid var(--line); padding-top: 0.85rem; }
.sidebar-bottom .logout-form { margin: 0; }
.sidebar-bottom .btn-ghost { width: 100%; justify-content: flex-start; padding-left: 0.75rem; }

.app-main { flex: 1; min-width: 0; }

/* Legacy top-nav selectors kept for any cached/edge include; unused in the
   sidebar shell but harmless if referenced. */
.topnav { display: none; }
.brand { display: none; }

/* ============ LAYOUT ============ */
.page {
    max-width: 900px;
    margin: 0 auto;
    padding: 2rem 1.75rem 4rem;
}
.page-wide { max-width: 1680px; }

.auth-card {
    max-width: 420px;
    margin: 3rem auto;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-m);
    padding: 2rem;
    box-shadow: var(--shadow-2);
    animation: fadeInUp 0.5s var(--ease) both;
}

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-m);
    padding: 1.25rem;
    margin-bottom: 1rem;
    box-shadow: var(--shadow-1);
    transition: transform 0.22s var(--ease), box-shadow 0.22s var(--ease), border-color 0.22s var(--ease);
}
.card:hover { transform: translateY(-2px); box-shadow: var(--shadow-2); border-color: var(--line-strong); }

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 1rem;
}

/* ============ DASHBOARD WIDGETS ============ */
.dash-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1rem;
    align-items: start;
}
.dash-main { display: flex; flex-direction: column; gap: 1rem; min-width: 0; }
.dash-side { display: flex; flex-direction: column; gap: 1rem; min-width: 0; }

.topstat-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}
.topstat {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-m);
    padding: 1.1rem 1.25rem;
    text-decoration: none;
    color: inherit;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    transition: transform 0.22s var(--ease), box-shadow 0.22s var(--ease), border-color 0.22s var(--ease);
}
.topstat:hover { transform: translateY(-3px); box-shadow: var(--shadow-2); border-color: var(--line-strong); }
.topstat-label { font-size: 0.8rem; color: var(--ink-muted); font-weight: 600; }
.topstat-value { font-size: 1.85rem; font-weight: 800; letter-spacing: -0.02em; color: var(--ink); }
.topstat-delta {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    width: fit-content;
    font-size: 0.76rem;
    font-weight: 750;
    padding: 0.2rem 0.5rem;
    border-radius: 999px;
}
.topstat-delta.up { background: var(--accent-soft); color: var(--accent-bright); }
.topstat-delta.down { background: var(--danger-soft); color: var(--danger); }
.topstat-delta.neutral { background: var(--surface-2); color: var(--ink-muted); }

.card-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 1rem;
}
.card-head h2 { margin: 0; font-size: 1rem; }
.card-head .card-sub { font-size: 0.82rem; color: var(--ink-muted); }
.card-head .see-all {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--accent-bright);
    text-decoration: none;
    flex-shrink: 0;
}
.card-head .see-all:hover { text-decoration: underline; }

/* ============ RANKED LISTS ("Popular episodes"-Stil) ============ */
.ranked-row {
    display: flex;
    align-items: center;
    gap: 0.9rem;
    padding: 0.7rem 0;
    border-bottom: 1px solid var(--line);
    text-decoration: none;
    color: inherit;
    transition: background 0.15s var(--ease);
}
.ranked-row:last-child { border-bottom: none; }
a.ranked-row:hover { background: var(--surface-2); margin: 0 -0.5rem; padding-left: 0.5rem; padding-right: 0.5rem; border-radius: var(--radius-s); }
.rank-badge {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    background: var(--surface-3);
    color: var(--ink-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 750;
    font-size: 0.85rem;
    flex-shrink: 0;
}
.ranked-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 0.15rem; }
.ranked-title { font-weight: 750; font-size: 0.95rem; color: var(--ink); text-decoration: none; }
.ranked-title:hover { color: var(--accent-bright); }
.ranked-sub { font-size: 0.82rem; color: var(--ink-muted); }
.ranked-meta { text-align: right; display: flex; flex-direction: column; align-items: flex-end; gap: 0.15rem; flex-shrink: 0; }
.ranked-meta-value { font-size: 0.88rem; color: var(--ink); font-weight: 700; }
.ranked-status { font-size: 0.78rem; font-weight: 750; white-space: nowrap; }
.ranked-status.ok { color: var(--accent-bright); }
.ranked-status.warn { color: var(--warn); }
.ranked-status.danger { color: var(--danger); }

.bignum { font-size: 2.1rem; font-weight: 800; letter-spacing: -0.02em; color: var(--ink); }
.bignum .unit { font-size: 1.05rem; font-weight: 700; color: var(--ink-muted); }

.chart-bars {
    display: flex;
    align-items: flex-end;
    gap: 0.65rem;
    height: 140px;
    margin-top: 1.25rem;
}
.chart-bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 0.5rem; height: 100%; justify-content: flex-end; }
.chart-bar {
    width: 100%;
    max-width: 34px;
    background: linear-gradient(180deg, var(--accent-bright), var(--accent));
    border-radius: 7px 7px 3px 3px;
    transform: scaleY(0);
    transform-origin: bottom;
    animation: growBar 0.7s var(--ease) forwards;
}
.chart-bar-label { font-size: 0.72rem; color: var(--ink-faint); font-weight: 600; }

.gauge-wrap { display: flex; flex-direction: column; align-items: center; gap: 0.5rem; padding: 0.5rem 0 0.25rem; }
.gauge-value { font-size: 2rem; font-weight: 800; color: var(--ink); margin-top: -4.4rem; }
.gauge-caption { font-size: 0.8rem; color: var(--ink-muted); text-align: center; }
.gauge-scale { display: flex; justify-content: space-between; width: 100%; font-size: 0.72rem; color: var(--ink-faint); margin-top: 0.25rem; }
.gauge-arc-bg { stroke: var(--surface-3); }
.gauge-arc {
    stroke: var(--accent-bright);
    stroke-linecap: round;
    transition: stroke-dashoffset 1s var(--ease) 0.15s;
}

.cta-card {
    background: linear-gradient(155deg, var(--accent-strong), var(--accent) 60%, #0c7a52);
    border: none;
    border-radius: var(--radius-m);
    padding: 1.35rem 1.4rem;
    color: #fff;
    box-shadow: var(--glow-accent);
    position: relative;
    overflow: hidden;
}
.cta-card::after {
    content: "";
    position: absolute;
    inset: -40% -20% auto auto;
    width: 180px;
    height: 180px;
    background: radial-gradient(circle, rgba(255,255,255,0.18), transparent 70%);
    pointer-events: none;
}
.cta-card .cta-label { font-size: 0.78rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: rgba(255,255,255,0.75); margin-bottom: 0.4rem; }
.cta-card h3 { margin: 0 0 0.5rem; font-size: 1.25rem; font-weight: 800; letter-spacing: -0.01em; line-height: 1.25; }
.cta-card p { margin: 0 0 1rem; font-size: 0.88rem; color: rgba(255,255,255,0.88); line-height: 1.5; }
.cta-card .btn-cta {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    background: rgba(255,255,255,0.16);
    color: #fff;
    border: 1px solid rgba(255,255,255,0.3);
    padding: 0.5rem 0.9rem;
    border-radius: var(--radius-s);
    font-weight: 700;
    font-size: 0.85rem;
    text-decoration: none;
    transition: background 0.18s var(--ease), transform 0.18s var(--ease);
}
.cta-card .btn-cta:hover { background: rgba(255,255,255,0.28); transform: translateX(2px); }
.cta-card.calm { background: linear-gradient(155deg, var(--surface-3), var(--surface-2) 70%); box-shadow: var(--shadow-1); }
.cta-card.calm .cta-label { color: var(--accent-bright); }
.cta-card.calm p { color: var(--ink-muted); }
.cta-card.calm .btn-cta { background: var(--accent-soft); color: var(--accent-bright); border-color: transparent; }

.live-dot {
    display: inline-block;
    width: 7px; height: 7px;
    border-radius: 50%;
    background: var(--danger);
    margin-right: 0.35rem;
    animation: pulseDot 1.6s ease-in-out infinite;
}

/* ============ FORMS & BUTTONS ============ */
form { display: flex; flex-direction: column; gap: 0.9rem; }
form.inline { flex-direction: row; align-items: center; gap: 0.5rem; }

label {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--ink);
}

input, select, textarea {
    font: inherit;
    font-size: 0.95rem;
    color: var(--ink);
    padding: 0.65rem 0.8rem;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-s);
    background: var(--surface-2);
    min-height: var(--tap-min);
    max-width: 100%;
    min-width: 0;
    transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease), background 0.15s var(--ease);
}
textarea { min-height: 80px; }
label { min-width: 0; }
input::placeholder, textarea::placeholder { color: var(--ink-faint); }
input:hover, select:hover, textarea:hover { border-color: var(--ink-faint); }
input:focus-visible, select:focus-visible, textarea:focus-visible {
    outline: none;
    border-color: var(--accent-bright);
    background: var(--surface-3);
    box-shadow: 0 0 0 3px var(--accent-soft);
}
select { color-scheme: dark; }

.btn {
    appearance: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    min-height: var(--tap-min);
    padding: 0.65rem 1.15rem;
    border-radius: var(--radius-s);
    border: none;
    font: inherit;
    font-weight: 700;
    font-size: 0.9rem;
    cursor: pointer;
    text-decoration: none;
    transition: transform 0.15s var(--ease-spring), box-shadow 0.15s var(--ease), background 0.15s var(--ease), border-color 0.15s var(--ease);
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--accent); color: var(--accent-on); box-shadow: var(--shadow-1); }
.btn-primary:hover { background: var(--accent-strong); box-shadow: var(--shadow-2); transform: translateY(-1px); }
.btn-secondary { background: var(--surface-2); color: var(--ink); border: 1px solid var(--line-strong); }
.btn-secondary:hover { background: var(--surface-3); border-color: var(--ink-faint); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(1.12); }
.btn-business { background: var(--business); color: var(--business-on); box-shadow: var(--shadow-1); }
.btn-business:hover { background: var(--business-strong); box-shadow: var(--shadow-2); transform: translateY(-1px); }
.btn-ghost {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    background: transparent;
    border: 1px solid var(--line-strong);
    color: var(--ink);
    font: inherit;
    font-size: 0.85rem;
    font-weight: 650;
    padding: 0.55rem 0.9rem;
    border-radius: var(--radius-s);
    cursor: pointer;
    transition: background 0.18s var(--ease), border-color 0.18s var(--ease);
    min-height: var(--tap-min);
}
.btn-ghost:hover { background: var(--surface-2); border-color: var(--ink-faint); }

/* ============ DROPZONE ============ */
.dropzone {
    border: 2px dashed var(--line-strong);
    border-radius: var(--radius-m);
    padding: 2rem 1rem;
    text-align: center;
    background: var(--surface-2);
    margin-top: 1rem;
    transition: border-color 0.15s var(--ease), background 0.15s var(--ease);
}
.dropzone-active { border-color: var(--accent-bright); background: var(--accent-soft); }
.dropzone-label {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.35rem;
    cursor: pointer;
    color: var(--ink-muted);
    font-weight: 600;
}
.dropzone-label svg { color: var(--ink-faint); }
.dropzone-filename:not(:empty) { font-weight: 700; color: var(--ink); }

.tax-doc-item { padding: 0.65rem 0; border-bottom: 1px solid var(--line); }
.tax-doc-item:last-child { border-bottom: none; }
.tax-doc-item .list-row { padding: 0; border-bottom: none; }
.tax-doc-item details { margin-top: 0.65rem; }
.tax-doc-item details form {
    margin-top: 0.65rem;
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: flex-end;
    max-width: 640px;
}
.btn-sm { min-height: 36px; padding: 0.4rem 0.75rem; font-size: 0.8rem; border-radius: 8px; }

/* ============ FILTER TOOLBAR ============ */
.filter-form {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 0.9rem 1.25rem;
    margin-bottom: 1.5rem;
    padding-bottom: 1.1rem;
    border-bottom: 1px solid var(--line);
}
.filter-form label {
    flex: 1 1 180px;
    gap: 0.4rem;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--ink-faint);
}
.filter-form select { width: 100%; min-height: auto; padding: 0.55rem 0.8rem; font-weight: 600; font-size: 0.875rem; }
.filter-form noscript { align-self: flex-end; }

/* ============ FLASH ============ */
.flash {
    padding: 0.75rem 1rem;
    border-radius: var(--radius-s);
    margin-bottom: 1rem;
    font-weight: 700;
    animation: fadeInUp 0.35s var(--ease) both;
}
.flash-success { background: var(--accent-soft); color: var(--accent-bright); }
.flash-error { background: var(--danger-soft); color: var(--danger); }

/* ============ LISTS (TO-DOS) ============ */
.todo-item, .list-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 0;
    border-bottom: 1px solid var(--line);
}
.todo-item:last-child, .list-row:last-child { border-bottom: none; }
.todo-item input[type="checkbox"] {
    width: 26px;
    height: 26px;
    min-height: auto;
    flex-shrink: 0;
    accent-color: var(--accent-bright);
}
.todo-item.done .todo-text { text-decoration: line-through; color: var(--ink-faint); }
.todo-text { flex: 1; }
.todo-meta { font-size: 0.8rem; color: var(--ink-faint); }

/* ============ TABLES ============ */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; background: var(--surface); }
th, td { text-align: left; padding: 0.8rem 0.6rem; border-bottom: 1px solid var(--line); }
thead th {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--ink-faint);
    padding-top: 0.85rem;
    padding-bottom: 0.5rem;
}
tbody tr { transition: background 0.15s var(--ease); }
tbody tr:hover { background: var(--surface-2); }
tbody tr:nth-child(even):not(.deadline-soon) { background: rgba(255,255,255,0.02); }
tr.deadline-soon td { background: var(--warn-soft); }

.badge {
    display: inline-block;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.01em;
    padding: 0.28rem 0.6rem;
    border-radius: 6px;
    white-space: nowrap;
    background: var(--surface-3);
    color: var(--ink-muted);
}
.badge-abo { background: rgba(79, 158, 232, 0.16); color: #7DB6F0; }
.badge-vertrag { background: rgba(167, 139, 250, 0.16); color: #B7A5F5; }
.badge-mitgliedschaft { background: var(--accent-soft); color: var(--accent-bright); }
.badge-versicherung { background: rgba(240, 129, 168, 0.16); color: #F4A3C2; }

/* ============ CATEGORY GROUPS ============ */
.category-group { margin-bottom: 2rem; }
.category-group-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.35rem 1rem;
    margin-bottom: 1.15rem;
    padding-bottom: 0.65rem;
    border-bottom: 2px solid var(--line-strong);
    cursor: pointer;
    list-style: none;
    user-select: none;
}
.category-group-header::-webkit-details-marker { display: none; }
.category-group-header h2 { margin: 0; display: flex; align-items: center; gap: 0.65rem; }
.category-group-header h2 .group-icon {
    width: 32px; height: 32px;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--accent-soft);
    color: var(--accent-bright);
    border-radius: 9px;
    flex-shrink: 0;
}
.category-group-header .chevron { color: var(--ink-faint); flex-shrink: 0; transition: transform 0.2s var(--ease), color 0.2s var(--ease); }
.category-group-header:hover .chevron { color: var(--ink-muted); }
.category-group[open] > .category-group-header .chevron { transform: rotate(90deg); }
.category-group-total { text-align: right; white-space: nowrap; font-weight: 800; color: var(--ink); }
.category-group-total .unit { font-size: 0.78rem; color: var(--ink-muted); font-weight: 600; }

/* ============ VIEW TOGGLE (Karten/Liste) ============ */
.view-toggle {
    display: inline-flex;
    gap: 0.2rem;
    background: var(--surface-2);
    padding: 0.25rem;
    border-radius: var(--radius-s);
    align-self: center;
}
.view-toggle a {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 7px;
    color: var(--ink-muted);
    text-decoration: none;
    transition: background 0.15s var(--ease), color 0.15s var(--ease);
}
.view-toggle a:hover { color: var(--ink); }
.view-toggle a.active { background: var(--accent); color: var(--accent-on); }

/* ============ FAHRTENBUCH ============ */
.trip-table { width: 100%; border-collapse: collapse; }
.trip-table th {
    padding: 0 0.75rem 0.7rem;
    text-align: left;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--ink-faint);
    border-bottom: 2px solid var(--line-strong);
    white-space: nowrap;
}
.trip-table td {
    padding: 0.8rem 0.75rem;
    border-top: 1px solid var(--line);
    vertical-align: middle;
    font-size: 0.9rem;
    color: var(--ink);
    overflow-wrap: anywhere;
}
.trip-table tbody tr { transition: background 0.15s var(--ease); }
.trip-table tbody tr:hover { background: var(--surface-2); }
.trip-date { display: block; font-weight: 700; }
.trip-weekday { display: block; font-size: 0.75rem; color: var(--ink-faint); font-weight: 600; }
.trip-place { color: var(--ink); text-decoration: none; }
a.trip-place:hover { color: var(--accent-bright); }
.trip-place-from { color: var(--ink-muted); }
.trip-vehicle {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    background: var(--accent-soft);
    color: var(--accent-bright);
    font-size: 0.75rem;
    font-weight: 700;
    white-space: nowrap;
}
.trip-distance { text-align: right; font-weight: 750; white-space: nowrap; }
.trip-mileage { text-align: right; color: var(--ink-muted); white-space: nowrap; }

.tracker-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.4rem 0.8rem;
    border-radius: 999px;
    background: var(--surface-2);
    border: 1px solid var(--line);
    font-size: 0.8rem;
    font-weight: 650;
    color: var(--ink);
}
.tracker-pill-error { border-color: rgba(239, 110, 110, 0.4); }
.tracker-pill-sub { color: var(--ink-faint); font-weight: 600; }

/* ============ COMMITMENT LIST ROW (Listen-Ansicht) ============ */
.commitment-list { padding: 0.25rem 1.25rem; }
.commitment-list-row { gap: 0.9rem; flex-wrap: wrap; }
.commitment-list-row .ranked-meta { justify-content: center; }

/* ============ CONTRACT LIST CARDS (Verträge, Grid-Stil) ============ */
.mobile-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 0.75rem;
    align-items: start;
}
.mobile-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-m);
    padding: 0.9rem 1rem;
    box-shadow: var(--shadow-1);
    transition: transform 0.2s var(--ease), box-shadow 0.2s var(--ease), border-color 0.2s var(--ease);
    min-width: 0;
}
.mobile-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-2); border-color: var(--line-strong); }
.mobile-card:active { transform: scale(0.99); }
.mobile-card.deadline-soon { background: linear-gradient(180deg, var(--warn-soft), var(--surface) 140%); border-color: transparent; }
.mc-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 0.65rem; margin-bottom: 0.5rem; }
.mc-name { font-weight: 750; font-size: 0.95rem; overflow-wrap: anywhere; }
.mc-provider { color: var(--ink-muted); font-size: 0.82rem; margin-top: 0.2rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mc-cost { text-align: right; font-weight: 800; font-size: 1rem; white-space: nowrap; color: var(--ink); flex-shrink: 0; }
.mc-cost .todo-meta { text-align: right; }
.mc-bottom { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; padding-top: 0.6rem; margin-top: 0.15rem; border-top: 1px solid var(--line); }
.mc-deadline { font-size: 0.8rem; color: var(--ink-muted); }
.mc-deadline.soon { color: var(--warn-ink); font-weight: 700; }

.entry-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--accent-soft);
    color: var(--accent-bright);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 0.85rem;
    flex-shrink: 0;
}

/* ============ CARD OVERFLOW MENU (⋯) ============ */
.card-menu { position: relative; flex-shrink: 0; }
.card-menu summary {
    list-style: none;
    cursor: pointer;
    width: 32px;
    height: 32px;
    border-radius: var(--radius-s);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--ink-muted);
    transition: background 0.15s var(--ease), color 0.15s var(--ease);
}
.card-menu summary::-webkit-details-marker { display: none; }
.card-menu summary:hover { background: var(--surface-2); color: var(--ink); }
.card-menu[open] summary { background: var(--surface-2); color: var(--ink); }
.card-menu-list {
    position: absolute;
    right: 0;
    top: calc(100% + 4px);
    background: var(--surface-3);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-s);
    box-shadow: var(--shadow-2);
    padding: 0.4rem;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    min-width: 190px;
    z-index: 10;
    animation: fadeInUp 0.15s var(--ease) both;
}
.card-menu-list form { margin: 0; }
.card-menu-list button {
    width: 100%;
    text-align: left;
    background: none;
    border: none;
    color: var(--ink);
    font: inherit;
    font-size: 0.85rem;
    font-weight: 650;
    padding: 0.55rem 0.65rem;
    border-radius: 7px;
    cursor: pointer;
    min-height: auto;
    transition: background 0.12s var(--ease);
}
.card-menu-list button:hover { background: var(--surface-2); }
.card-menu-list button.danger-item { color: var(--danger); }

.actions-row { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }

.empty-state { color: var(--ink-muted); padding: 1.5rem 0; text-align: center; }

/* ============ CALENDAR ============ */
.cal-grid { table-layout: fixed; }
.cal-grid th { text-align: center; }
.cal-cell { vertical-align: top; height: 84px; width: 14.28%; padding: 0.35rem; }
.cal-outside { background: rgba(255,255,255,0.015); color: var(--ink-faint); }
.cal-today { background: var(--accent-soft); }
.cal-daynum { font-weight: 700; font-size: 0.85rem; margin-bottom: 0.25rem; color: var(--ink); }
.cal-dot {
    display: block;
    font-size: 0.72rem;
    line-height: 1.3;
    padding: 0.1rem 0.35rem;
    border-radius: 6px;
    margin-bottom: 2px;
    text-decoration: none;
    color: inherit;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.cal-dot-commitment { background: rgba(167, 139, 250, 0.18); color: #C6B6F7; }
.cal-dot-vehicle { background: rgba(245, 166, 35, 0.18); color: #F7C05C; }
.cal-dot-reminder { background: rgba(79, 158, 232, 0.18); color: #8FC1F2; }

@media (max-width: 600px) {
    .cal-cell { height: 60px; padding: 0.25rem; }
    .cal-dot { font-size: 0.65rem; }
}

/* ============ STATS ============ */
.stat { display: flex; flex-direction: column; gap: 0.25rem; }
.stat .value { font-size: 2rem; font-weight: 800; letter-spacing: -0.02em; color: var(--accent-bright); }
.stat .label { color: var(--ink-muted); font-size: 0.9rem; }

/* ============ TRAFFIC LIGHT ============ */
.traffic {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}
.traffic-dot {
    display: inline-block;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    flex-shrink: 0;
}
.traffic-dot-none { background: var(--line-strong); }
.traffic-dot-ok { background: var(--ok); }
.traffic-dot-warn { background: var(--warn); }
.traffic-dot-danger { background: var(--danger); }
.traffic-danger { color: var(--danger); font-weight: 700; }
.estimated-marker {
    color: var(--ink-faint);
    font-weight: 400;
    cursor: help;
    border-bottom: 1px dotted var(--ink-faint);
}

.row-inactive-period { opacity: 0.5; }
.row-inactive-period:hover { opacity: 0.8; }

/* ============ COST HISTORY / VEHICLE LINK ============ */
.history-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.6rem 0;
    border-bottom: 1px solid var(--line);
}
.history-row:last-child { border-bottom: none; }
.history-delta { font-weight: 700; font-size: 0.85rem; }
.history-delta-up { color: var(--danger); }
.history-delta-down { color: var(--accent-bright); }
.history-delta-same { color: var(--ink-faint); }

.vehicle-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.8rem;
    color: var(--ink-muted);
}

/* ============ ANIMATIONS ============ */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(14px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes growBar {
    from { transform: scaleY(0); }
    to { transform: scaleY(1); }
}
@keyframes pulseDot {
    0%, 100% { box-shadow: 0 0 0 0 rgba(240, 71, 62, 0.55); }
    50% { box-shadow: 0 0 0 4px rgba(240, 71, 62, 0); }
}
@keyframes navSlideIn {
    from { opacity: 0; transform: translateX(-8px); }
    to { opacity: 1; transform: translateX(0); }
}

.reveal-in {
    animation: fadeInUp 0.5s var(--ease) both;
}
.sidebar .navlink { animation: navSlideIn 0.4s var(--ease) both; }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
        scroll-behavior: auto !important;
    }
    .chart-bar { transform: scaleY(1); }
}

/* ============ RESPONSIVE ============ */
@media (max-width: 900px) {
    .dash-grid { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
    .app-shell { flex-direction: column; align-items: stretch; }
    .app-main { width: 100%; min-width: 0; }
}

/* Das Fahrtenbuch hat sechs Spalten mit Adressen - es braucht frueher als der
   Rest der Anwendung die gestapelte Darstellung, sonst brechen lange
   Strassennamen mitten im Wort um. */
@media (max-width: 900px) {
    .trip-table thead { display: none; }
    .trip-table, .trip-table tbody, .trip-table tr, .trip-table td { display: block; width: 100%; }
    .trip-table tr {
        background: var(--surface-2);
        border: 1px solid var(--line);
        border-radius: var(--radius-m);
        margin-bottom: 0.6rem;
        padding: 0.25rem 0;
    }
    .trip-table td {
        border-top: none;
        display: flex;
        align-items: baseline;
        justify-content: space-between;
        gap: 1rem;
        padding: 0.35rem 0.85rem;
        text-align: right;
    }
    .trip-table td::before {
        content: attr(data-label);
        flex-shrink: 0;
        font-size: 0.7rem;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: 0.05em;
        color: var(--ink-faint);
        text-align: left;
    }
    .trip-table td[data-label="Datum"] { padding-top: 0.6rem; }
    .trip-table td[data-label="km-Stand"] { padding-bottom: 0.6rem; }
    .trip-date, .trip-weekday { display: inline; }
    .trip-weekday { margin-left: 0.35rem; }
}

/* Mit Fahrzeugspalte ist eine Spalte mehr im Spiel - die Adressen brauchen
   dann frueher die gestapelte Darstellung. */
@media (min-width: 901px) and (max-width: 1150px) {
    .trip-table-multi thead { display: none; }
    .trip-table-multi, .trip-table-multi tbody,
    .trip-table-multi tr, .trip-table-multi td { display: block; width: 100%; }
    .trip-table-multi tr {
        background: var(--surface-2);
        border: 1px solid var(--line);
        border-radius: var(--radius-m);
        margin-bottom: 0.6rem;
        padding: 0.25rem 0;
    }
    .trip-table-multi td {
        border-top: none;
        display: flex;
        align-items: baseline;
        justify-content: space-between;
        gap: 1rem;
        padding: 0.35rem 0.85rem;
        text-align: right;
    }
    .trip-table-multi td::before {
        content: attr(data-label);
        flex-shrink: 0;
        font-size: 0.7rem;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: 0.05em;
        color: var(--ink-faint);
        text-align: left;
    }
    .trip-table-multi .trip-date, .trip-table-multi .trip-weekday { display: inline; }
    .trip-table-multi .trip-weekday { margin-left: 0.35rem; }
}

@media (max-width: 760px) {
    .sidebar {
        position: sticky;
        top: 0;
        z-index: 20;
        width: 100%;
        height: auto;
        flex-direction: row;
        align-items: center;
        padding: 0.6rem 0.75rem;
        gap: 0.6rem;
        border-right: none;
        border-bottom: 1px solid var(--line);
    }
    .sidebar-top { flex-shrink: 0; }
    .sidebar-user-text { display: none; }
    .sidebar-add { width: 34px; height: 34px; }
    .sidebar-nav {
        flex-direction: row;
        flex: 1;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        gap: 0.2rem;
    }
    .sidebar-nav::-webkit-scrollbar { display: none; }
    .sidebar-section-label { display: none; }
    .navlink { flex-shrink: 0; padding: 0.55rem 0.6rem; }
    .navlink .navlabel { display: none; }
    .navlink { animation: none; }
    .sidebar-bottom { border-top: none; border-left: 1px solid var(--line); padding: 0 0 0 0.6rem; flex-shrink: 0; }
    .sidebar-bottom .btn-ghost { width: auto; padding: 0.5rem; }
    .sidebar-bottom .btn-ghost span { display: none; }

    .page { padding: 1.5rem 1rem 4rem; }
    .filter-form { flex-direction: column; align-items: stretch; }
    .filter-form label { flex: none; }

    .category-group-header { flex-wrap: wrap; row-gap: 0.35rem; }
    .category-group-total { margin-left: auto; }

    th, td { padding: 0.6rem 0.4rem; font-size: 0.9rem; }

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