/* =========================================
   Basis / Reset
========================================= */

:root {
    --bg: #f4f7fb;
    --bg-accent: #eef4ff;
    --bg-soft: #f8fbff;
    --surface: rgba(255, 255, 255, 0.92);
    --surface-2: #ffffff;
    --surface-3: #f7f9fc;
    --border: rgba(148, 163, 184, 0.24);
    --border-strong: rgba(148, 163, 184, 0.38);

    --text: #152033;
    --text-soft: #334155;
    --text-muted: #64748b;

    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --primary-soft: rgba(59, 130, 246, 0.12);
    --success: #16a34a;
    --warning: #d97706;
    --danger: #dc2626;
    --neutral: #64748b;

    --shadow-sm: 0 6px 18px rgba(15, 23, 42, 0.08);
    --shadow: 0 16px 40px rgba(15, 23, 42, 0.10);
    --shadow-lg: 0 24px 60px rgba(15, 23, 42, 0.14);
    --radius: 18px;
    --radius-sm: 12px;

    --content-width: 1360px;
    --header-height: 76px;
    --sidebar-width: 18rem;

    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.25rem;
    --space-6: 1.5rem;
    --space-8: 2rem;
    --space-10: 2.5rem;
    --space-12: 3rem;

    --font-sans:
        Inter,
        ui-sans-serif,
        system-ui,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        Roboto,
        "Helvetica Neue",
        Arial,
        sans-serif;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    font-size: 16px;
    color-scheme: light;
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: var(--font-sans);
    background:
        radial-gradient(circle at top left, rgba(59, 130, 246, 0.16), transparent 25%),
        radial-gradient(circle at top right, rgba(14, 165, 233, 0.10), transparent 24%),
        linear-gradient(180deg, #fbfdff 0%, var(--bg) 100%);
    color: var(--text);
    line-height: 1.5;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
}

img,
svg {
    display: block;
    max-width: 100%;
}

button,
input,
select,
textarea {
    font: inherit;
    color: inherit;
}

button {
    cursor: pointer;
}

a {
    color: inherit;
    text-decoration: none;
}

[hidden] {
    display: none !important;
}

/* =========================================
   Accessibility
========================================= */

.skip-link {
    position: absolute;
    left: -9999px;
    top: 0;
    z-index: 1000;
    padding: 0.75rem 1rem;
    border-radius: 0 0 12px 12px;
    background: var(--primary);
    color: #fff;
    box-shadow: var(--shadow-sm);
}

.skip-link:focus {
    left: 1rem;
    top: 0;
}

:focus-visible {
    outline: 3px solid rgba(59, 130, 246, 0.32);
    outline-offset: 2px;
}

/* =========================================
   Layout
========================================= */

.app {
    width: min(100%, var(--content-width));
    margin: 0 auto;
    padding: var(--space-5);
}

.app-shell {
    position: relative;
}

.app-shell::before {
    content: "";
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.34);
    opacity: 0;
    pointer-events: none;
    transition: opacity 180ms ease;
    z-index: 25;
}

.app-shell.nav-open::before {
    opacity: 1;
    pointer-events: auto;
}

.app-header {
    position: sticky;
    top: 0;
    z-index: 20;
    min-height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    padding: var(--space-5) 0 var(--space-4);
    backdrop-filter: blur(14px);
    background: linear-gradient(
        180deg,
        rgba(244, 247, 251, 0.95) 0%,
        rgba(244, 247, 251, 0.82) 100%
    );
}

.brand {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    min-width: 0;
}

.brand--auth {
    align-items: flex-start;
}

.brand__logo {
    width: 3rem;
    height: 3rem;
    display: grid;
    place-items: center;
    border-radius: 16px;
    background: linear-gradient(135deg, var(--primary), #60a5fa);
    color: #fff;
    font-size: 1.25rem;
    font-weight: 800;
    box-shadow: 0 10px 28px rgba(59, 130, 246, 0.28);
    flex-shrink: 0;
}

.brand__text h1 {
    margin: 0;
    font-size: clamp(1.15rem, 2vw, 1.65rem);
    line-height: 1.15;
    font-weight: 750;
    letter-spacing: -0.025em;
}

.brand__text p {
    margin: 0.18rem 0 0;
    color: var(--text-muted);
    font-size: 0.95rem;
}

.eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    margin-bottom: var(--space-2);
    color: var(--primary-hover);
    font-weight: 700;
    font-size: 0.8rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    flex-wrap: wrap;
    justify-content: flex-end;
}

.app-layout {
    display: block;
}

.app-content-shell {
    min-width: 0;
}

.main-content {
    padding: var(--space-4) 0 var(--space-8);
}

.app-footer {
    padding: var(--space-4) 0 var(--space-8);
    color: var(--text-muted);
    text-align: center;
}

/* =========================================
   Login / Auth Screen
========================================= */

.auth-screen {
    min-height: calc(100vh - 2 * var(--space-5));
    display: grid;
    place-items: center;
}

.auth-screen__inner {
    width: min(100%, 34rem);
}

.auth-panel {
    position: relative;
    overflow: hidden;
}

.auth-panel::before {
    content: "";
    position: absolute;
    inset: 0 0 auto;
    height: 6px;
    background: linear-gradient(90deg, var(--primary), #38bdf8);
}

.auth-panel__header {
    margin-bottom: var(--space-6);
}

/* =========================================
   Navigation / Views
========================================= */

.app-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 30;
    width: min(88vw, var(--sidebar-width));
    height: 100dvh;
    padding: calc(var(--space-10) + env(safe-area-inset-top, 0px)) var(--space-4) var(--space-4);
    background: rgba(255, 255, 255, 0.97);
    border-right: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    transform: translateX(calc(-100% - 2rem));
    opacity: 0;
    pointer-events: none;
    transition: transform 200ms ease, opacity 200ms ease;
    overflow-y: auto;
}

.app-shell.nav-open .app-sidebar {
    transform: translateX(0);
    opacity: 1;
    pointer-events: auto;
}

.main-nav {
    display: grid;
    gap: var(--space-2);
    padding: var(--space-2);
    border: 1px solid var(--border);
    border-radius: 20px;
    background: linear-gradient(180deg, rgba(248, 250, 252, 0.96), rgba(255, 255, 255, 0.94));
    box-shadow: var(--shadow-sm);
}

.nav-tab {
    border: 0;
    border-radius: 14px;
    padding: 0.9rem 1rem;
    background: transparent;
    color: var(--text-soft);
    font-weight: 700;
    text-align: left;
    white-space: nowrap;
    transition: background-color 160ms ease, color 160ms ease, transform 160ms ease, box-shadow 160ms ease;
}

.nav-tab:hover {
    background: rgba(59, 130, 246, 0.10);
    color: var(--text);
}

.nav-tab.is-active {
    background: linear-gradient(135deg, var(--primary), var(--primary-hover));
    color: #fff;
    box-shadow: 0 8px 22px rgba(37, 99, 235, 0.22);
}

.view {
    display: none;
}

.view.is-visible {
    display: block;
}

.subview {
    display: none;
}

.subview.is-visible {
    display: block;
}

.section-header {
    margin-bottom: var(--space-5);
}

.section-header h2 {
    margin: 0 0 0.35rem;
    font-size: clamp(1.3rem, 2vw, 1.85rem);
    letter-spacing: -0.02em;
}

.section-header p {
    margin: 0;
    color: var(--text-muted);
}

/* =========================================
   Status Bar
========================================= */

.status-bar {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-3);
    margin: 0 0 var(--space-5);
}

.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    min-height: 2.35rem;
    padding: 0.5rem 0.85rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.92);
    color: var(--text-soft);
    font-size: 0.92rem;
    font-weight: 650;
    box-shadow: var(--shadow-sm);
}

.status-pill::before {
    content: "";
    width: 0.6rem;
    height: 0.6rem;
    border-radius: 50%;
    background: currentColor;
    opacity: 0.9;
}

.status-pill--neutral {
    color: var(--neutral);
}

.status-pill--success {
    color: var(--success);
}

.status-pill--warning {
    color: var(--warning);
}

.status-pill--danger {
    color: var(--danger);
}

/* =========================================
   Panels / Cards
========================================= */

.panel,
.card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(255, 255, 255, 0.94));
    box-shadow: var(--shadow);
}

.panel {
    padding: var(--space-6);
}

.panel--narrow {
    width: min(100%, 34rem);
    margin: 0 auto;
}

.panel__header {
    margin-bottom: var(--space-5);
}

.panel__header h2 {
    margin: 0 0 0.35rem;
    font-size: 1.5rem;
}

.panel__header p {
    margin: 0;
    color: var(--text-muted);
}

.card {
    padding: var(--space-5);
}

.card__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    margin-bottom: var(--space-4);
}

.card__header h3 {
    margin: 0;
    font-size: 1.05rem;
}

.card-grid {
    display: grid;
    gap: var(--space-5);
    grid-template-columns: repeat(12, minmax(0, 1fr));
}

.card-grid > .card {
    grid-column: span 12;
}

.card-grid--summary > .summary-card {
    grid-column: span 12;
}

.summary-card {
    min-height: 10rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    background:
        linear-gradient(180deg, rgba(239, 246, 255, 0.82), rgba(255, 255, 255, 0.96));
}

.summary-card h3 {
    margin: 0;
    color: var(--text-soft);
    font-size: 1rem;
    font-weight: 650;
}

.metric {
    margin: var(--space-4) 0 0.25rem;
    font-size: clamp(1.9rem, 3vw, 2.6rem);
    line-height: 1;
    letter-spacing: -0.03em;
    font-weight: 800;
}

.metric-caption {
    margin: 0;
    color: var(--text-muted);
    font-size: 0.95rem;
}

/* =========================================
   Formulare
========================================= */

.form {
    display: grid;
    gap: var(--space-4);
}

.form-row {
    display: grid;
    gap: 0.45rem;
}

.form-row label {
    color: var(--text-soft);
    font-size: 0.95rem;
    font-weight: 650;
}

.form-row input,
.form-row select,
.form-row textarea {
    width: 100%;
    min-height: 3rem;
    padding: 0.85rem 0.95rem;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: #fff;
    color: var(--text);
    transition: border-color 160ms ease, box-shadow 160ms ease, background-color 160ms ease;
}

.form-row textarea {
    min-height: 7rem;
    resize: vertical;
}

.form-row input::placeholder,
.form-row textarea::placeholder {
    color: #94a3b8;
}

.form-row input:hover,
.form-row select:hover,
.form-row textarea:hover {
    border-color: var(--border-strong);
}

.form-row input:focus,
.form-row select:focus,
.form-row textarea:focus {
    border-color: rgba(59, 130, 246, 0.7);
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.15);
    outline: none;
}

.form-actions {
    display: flex;
    gap: var(--space-3);
    flex-wrap: wrap;
    padding-top: var(--space-2);
}

.form-message {
    min-height: 1.5rem;
    margin: 0;
    color: var(--text-muted);
}

/* =========================================
   Buttons
========================================= */

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    min-height: 2.75rem;
    padding: 0.72rem 1rem;
    border: 1px solid transparent;
    border-radius: 14px;
    font-weight: 700;
    transition:
        transform 160ms ease,
        background-color 160ms ease,
        border-color 160ms ease,
        color 160ms ease,
        box-shadow 160ms ease;
}

.button:hover {
    transform: translateY(-1px);
}

.button:active {
    transform: translateY(0);
}

.button:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none;
}

.button--primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-hover));
    color: #fff;
    box-shadow: 0 10px 24px rgba(37, 99, 235, 0.24);
}

.button--primary:hover {
    background: linear-gradient(135deg, #4b91f8, var(--primary));
}

.button--secondary {
    background: var(--primary-soft);
    color: var(--primary-hover);
    border-color: rgba(59, 130, 246, 0.18);
}

.button--secondary:hover {
    background: rgba(59, 130, 246, 0.16);
    border-color: rgba(59, 130, 246, 0.26);
}

.button--ghost {
    background: rgba(255, 255, 255, 0.78);
    color: var(--text-soft);
    border-color: var(--border);
}

.button--ghost:hover {
    background: #fff;
    color: var(--text);
}

.button--small {
    min-height: 2.25rem;
    padding: 0.5rem 0.75rem;
    border-radius: 10px;
    font-size: 0.92rem;
}

.button--full {
    width: 100%;
}

.button--icon {
    min-width: 2.75rem;
}

.button__label {
    white-space: nowrap;
}

/* =========================================
   Listen / Details / Zustände
========================================= */

.list-container,
.detail-container {
    display: grid;
    gap: var(--space-3);
}

.list-item {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: var(--space-4);
    padding: var(--space-4);
    border: 1px solid var(--border);
    border-radius: 16px;
    background: linear-gradient(180deg, rgba(248, 250, 252, 0.96), rgba(255, 255, 255, 0.96));
}

.list-item__main {
    min-width: 0;
}

.list-item__title {
    margin: 0 0 0.2rem;
    font-size: 1rem;
    font-weight: 750;
    color: var(--text);
    word-break: break-word;
}

.list-item__meta {
    margin: 0;
    color: var(--text-muted);
    font-size: 0.94rem;
}

.list-item__side {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    align-items: flex-start;
}

.list-item__amount {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 800;
    color: var(--text);
}

.empty-state {
    min-height: 6rem;
    display: grid;
    place-items: center;
    padding: var(--space-5);
    border: 1px dashed rgba(148, 163, 184, 0.42);
    border-radius: 16px;
    color: var(--text-muted);
    background: linear-gradient(180deg, rgba(248, 250, 252, 0.82), rgba(255, 255, 255, 0.86));
    text-align: center;
}

.status-list {
    display: grid;
    gap: var(--space-4);
    margin: 0;
}

.status-list div {
    display: flex;
    justify-content: space-between;
    gap: var(--space-4);
    padding-bottom: var(--space-3);
    border-bottom: 1px solid rgba(148, 163, 184, 0.16);
}

.status-list div:last-child {
    padding-bottom: 0;
    border-bottom: 0;
}

.status-list dt {
    color: var(--text-muted);
    font-weight: 600;
}

.status-list dd {
    margin: 0;
    color: var(--text);
    font-weight: 700;
    text-align: right;
}

/* =========================================
   Nachrichten / Hilfsklassen
========================================= */

.message-box {
    padding: 0.9rem 1rem;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: rgba(248, 250, 252, 0.92);
    color: var(--text-soft);
}

.text-success {
    color: var(--success);
}

.text-warning {
    color: var(--warning);
}

.text-danger {
    color: var(--danger);
}

.text-muted {
    color: var(--text-muted);
}

/* =========================================
   Responsive
========================================= */

@media (min-width: 700px) {
    .list-item {
        grid-template-columns: minmax(0, 1fr) auto;
        align-items: center;
    }

    .list-item__side {
        align-items: flex-end;
    }

    .card-grid--summary > .summary-card {
        grid-column: span 6;
    }
}

@media (min-width: 980px) {
    .card-grid > .card:nth-child(1):nth-last-child(2),
    .card-grid > .card:nth-child(2):nth-last-child(1) {
        grid-column: span 6;
    }

    .card-grid--summary > .summary-card {
        grid-column: span 3;
    }
}

@media (max-width: 960px) {
    .app {
        padding: var(--space-4);
    }

    .app-header {
        padding-top: var(--space-4);
    }
}

@media (max-width: 760px) {
    .app {
        padding: var(--space-3);
    }

    .auth-screen {
        min-height: calc(100vh - 2 * var(--space-3));
    }

    .app-header {
        position: static;
        align-items: flex-start;
        flex-direction: column;
    }

    .header-actions {
        width: 100%;
        justify-content: flex-start;
    }

    .button__label {
        display: none;
    }

    .panel,
    .card {
        padding: var(--space-4);
    }

    .status-bar {
        gap: var(--space-2);
    }

    .status-pill {
        width: 100%;
        justify-content: flex-start;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation: none !important;
        transition: none !important;
        scroll-behavior: auto !important;
    }
}
