:root {
    --bg: #050505;
    --card: #121212;
    --card-border: rgba(255, 255, 255, 0.08);
    --text: #ffffff;
    --muted: #d1d5db;
    --accent: #7dd3fc;
    --heading: #cdeafe;
    --danger: #ff6b6b;
    --success: #7dd36f;
}

[data-theme="light"] {
    --bg: #f4f4f4;
    --card: #ffffff;
    --card-border: rgba(0, 0, 0, 0.08);
    --text: #000000;
    --muted: #374151;
    --accent: #0ea5e9;
    --heading: #0f172a;
    --danger: #dc2626;
    --success: #15803d;
}

* {
    box-sizing: border-box;
}

body {
    font-family: "Inter", "Segoe UI", -apple-system, BlinkMacSystemFont, sans-serif;
    margin: 0;
    padding: 0 0 40px;
    background-color: var(--bg);
    color: var(--text);
    min-height: 100vh;
}

.app-shell {
    max-width: 1100px;
    margin: 0 auto;
    padding: 16px;
}

.app-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 0 8px;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.app-header h1,
.title-block h1 {
    margin: 0;
    font-size: 1.6rem;
}

.app-nav {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 0 0 16px;
    padding: 12px;
    border-radius: 12px;
    border: 1px solid var(--card-border);
    background: rgba(255, 255, 255, 0.04);
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-4px);
    transition: max-height 0.3s ease, opacity 0.25s ease, transform 0.25s ease, visibility 0.25s ease;
}

.app-nav.open {
    display: flex;
    max-height: 420px;
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.app-nav a {
    display: block;
    border-radius: 10px;
    padding: 10px 12px;
    border: 1px solid var(--card-border);
    background: rgba(255, 255, 255, 0.05);
    color: var(--text);
    text-decoration: none;
    font-weight: 600;
}

.nav-toggle {
    width: 44px;
    height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    border: 1px solid var(--card-border);
    background: rgba(255, 255, 255, 0.05);
    font-size: 1.1rem;
    transition: transform 0.25s ease, border-color 0.25s ease, background-color 0.25s ease;
}

.nav-toggle[aria-expanded="true"] {
    border-color: rgba(125, 211, 252, 0.5);
    background: rgba(125, 211, 252, 0.1);
}

.nav-toggle.open {
    transform: rotate(90deg);
}

.quick-nav a,
button,
select,
input,
textarea {
    font: inherit;
}

[data-theme-toggle] {
    width: 44px;
    height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
    font-size: 1.2rem;
}

.quick-nav a,
button,
.ghost-btn,
.primary-btn,
.secondary-btn,
.chip-btn {
    border-radius: 999px;
    padding: 10px 16px;
    border: 1px solid transparent;
    text-decoration: none;
    color: var(--text);
    background: rgba(255, 255, 255, 0.08);
    transition: background 0.2s ease, border 0.2s ease, color 0.2s ease;
    cursor: pointer;
}

button:focus-visible {
    outline: 2px solid rgba(125, 211, 252, 0.6);
    outline-offset: 2px;
}

button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.ghost-btn {
    border-color: var(--card-border);
    background: transparent;
}

.ghost-btn:hover,
.quick-nav a:hover,
.chip-btn:hover,
button:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.18);
}

.primary-btn {
    background: linear-gradient(120deg, var(--accent), #38bdf8);
    color: #ffffff;
    font-weight: 600;
}

[data-theme="light"] .primary-btn {
    color: #0f172a;
}

.secondary-btn {
    background: rgba(125, 211, 252, 0.12);
    border: 1px solid rgba(125, 211, 252, 0.4);
    font-weight: 600;
}

.chip-btn {
    border: 1px solid var(--card-border);
    background: rgba(255, 255, 255, 0.04);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 0.95rem;
    font-weight: 500;
}

.chip-btn .chip-label {
    flex: 1 1 auto;
    text-align: left;
}

.chip-btn .chip-price {
    font-size: 0.85rem;
    padding: 2px 8px;
    border-radius: 999px;
    background: rgba(125, 211, 252, 0.18);
    color: var(--accent);
}

[data-theme="light"] .chip-btn .chip-price {
    color: #0369a1;
}

.card,
.simple-card {
    background: var(--card);
    border: 1px solid var(--card-border);
    border-radius: 20px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
}

.simple-card {
    max-width: 520px;
    margin-left: auto;
    margin-right: auto;
    text-align: center;
}

.card h2,
.simple-card h2 {
    margin-top: 0;
    font-size: 1.2rem;
    color: var(--heading);
}

.card h3,
.simple-card h3 {
    color: var(--heading);
}

.form-stack {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 16px;
}

.input-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
}

input,
select,
textarea {
    width: 100%;
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid var(--card-border);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text);
}

input:focus,
select:focus,
textarea:focus {
    outline: 2px solid rgba(125, 211, 252, 0.6);
    border-color: transparent;
}

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

.debt-grid,
.balance-grid,
.link-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
}

.debt-card,
.balance-card {
    border-radius: 16px;
    padding: 16px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--card-border);
}

.debt-card .amount,
.balance-card p {
    font-size: 1.4rem;
    margin: 4px 0 0;
    font-weight: 600;
}

.debt-card.high-debt {
    border-color: rgba(255, 107, 107, 0.8);
    background: rgba(255, 107, 107, 0.08);
}

.history-wrapper,
.section-stack {
    display: grid;
    gap: 12px;
}


.history-filters {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 10px;
    width: 100%;
}

.history-filter {
    width: 100%;
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
}

.history-filters button {
    width: 100%;
}

@media (min-width: 560px) {
    .history-filters button {
        width: auto;
    }
}

@media (max-width: 640px) {
    .history-filters {
        grid-template-columns: minmax(0, 1fr);
    }
}

.history-list {
    max-height: 360px;
    overflow-y: auto;
    padding-right: 6px;
    border-radius: 12px;
    border: 1px solid var(--card-border);
    background: rgba(255, 255, 255, 0.03);
}

.history-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 16px;
}

.history-status {
    min-height: 20px;
}

.history-status.success {
    color: var(--success);
}

.history-status.error {
    color: var(--danger);
}

.history-entry.deleted {
    text-decoration: line-through;
    font-style: italic;
    opacity: 0.75;
}

.history-entry .badge.deleted {
    background: rgba(239, 68, 68, 0.12);
    color: #fca5a5;
    border: 1px solid rgba(239, 68, 68, 0.4);
}

.pos-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 10px;
}

.pos-grid .chip-btn {
    justify-content: space-between;
}

.cart-list {
    display: grid;
    gap: 8px;
}

.cart-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    border: 1px dashed var(--card-border);
    border-radius: 12px;
    padding: 10px 12px;
}

.cart-item h4 {
    margin: 0;
    font-size: 1rem;
    color: var(--heading);
}

.cart-item .helper-text {
    margin: 0;
}

.cart-controls {
    display: flex;
    gap: 6px;
    align-items: center;
}

.cart-controls button {
    padding: 8px 10px;
    border-radius: 10px;
}

.cart-total {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 700;
    padding: 12px 0 4px;
}

.history-entry {
    padding: 12px 16px;
    border-bottom: 1px solid var(--card-border);
    line-height: 1.4;
    position: relative;
}

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

.history-entry small {
    color: var(--muted);
}

.history-entry button.delete-entry {
    position: absolute;
    top: 12px;
    right: 16px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: transparent;
    color: var(--danger);
    padding: 4px 10px;
    font-size: 0.8rem;
}

.history-entry .restore-entry {
    position: absolute;
    top: 12px;
    right: 16px;
    border-radius: 12px;
    border: 1px solid rgba(125, 211, 252, 0.5);
    background: rgba(125, 211, 252, 0.12);
    color: var(--text);
    padding: 4px 10px;
    font-size: 0.8rem;
}

.badges {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 6px;
}

.badge {
    padding: 2px 10px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
    font-size: 0.8rem;
}

.helper-text {
    color: var(--muted);
    font-size: 0.9rem;
}

.link-grid a {
    display: block;
    text-decoration: none;
}

.link-grid .card {
    text-align: left;
}

.form-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 16px;
}

.notice {
    padding: 12px 16px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--card-border);
}

.checkbox-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border: 1px solid var(--card-border);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.04);
    width: 100%;
}

.checkbox-row span {
    flex: 1;
    line-height: 1.4;
}

.checkbox-row input[type="checkbox"] {
    flex: 0 0 auto;
    width: 22px;
    height: 22px;
    margin: 0;
    accent-color: var(--accent);
}

.quick-shortcuts {
    margin-top: 18px;
    display: grid;
    gap: 18px;
}

.quick-shortcut-block {
    border: 1px solid var(--card-border);
    border-radius: 16px;
    padding: 16px;
    background: rgba(255, 255, 255, 0.02);
}

.shortcut-heading {
    margin-bottom: 10px;
}

.shortcut-heading h3 {
    margin: 0;
    font-size: 1rem;
    color: var(--heading);
}

.quick-chip-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.quick-drink-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.quick-drink-grid .chip-btn {
    flex: 0 0 auto;
    min-width: 0;
    padding: 6px 10px;
    gap: 6px;
}

.quick-drink-grid .chip-label {
    font-size: 0.85rem;
}

.quick-drink-grid .chip-price {
    font-size: 0.72rem;
    padding: 2px 6px;
}

.quick-status {
    min-height: 20px;
    margin-top: 8px;
}

.quick-status.success {
    color: var(--success);
}

.quick-status.error {
    color: var(--danger);
}

.form-status {
    min-height: 20px;
}

.form-status.success {
    color: var(--success);
}

.form-status.error {
    color: var(--danger);
}

@media (max-width: 640px) {
    .app-header h1,
    .title-block h1 {
        font-size: 1.3rem;
    }

    .history-list {
        max-height: 280px;
    }
}

@media (max-width: 520px) {
    .input-grid,
    .history-filters {
        grid-template-columns: 1fr;
    }
}

@media (min-width: 768px) {
    .app-nav {
        display: flex;
        flex-direction: row;
        align-items: center;
        gap: 10px;
        padding: 0;
        border: none;
        background: transparent;
        max-height: none;
        opacity: 1;
        visibility: visible;
        transform: none;
    }

    .app-nav a {
        padding: 10px 14px;
    }

    .nav-toggle {
        display: none;
    }
}

/* --- 303 Club (Neubau) Ergänzungen --- */
.amount-in { color: var(--success); font-weight: 700; }
.amount-out { color: var(--danger); font-weight: 700; }
.history-entry .entry-head { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; }
.history-entry .entry-amount { font-variant-numeric: tabular-nums; white-space: nowrap; }
.entry-actions { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.entry-actions button { font-size: 0.8rem; padding: 4px 10px; }
.debt-card { cursor: pointer; }
.link-row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }

/* Mobil-Optimierung (Neubau) */
.link-row button { flex: 1 1 160px; }
.history-actions button { flex: 1 1 200px; }
@media (max-width: 640px) {
    .link-row button,
    .history-actions button { flex: 1 1 100%; }
    .cart-total { font-size: 1.05rem; }
    .entry-head { flex-wrap: wrap; }
    .debt-grid, .balance-grid { gap: 10px; }
}
@media (max-width: 400px) {
    .app-header h1 { font-size: 1.4rem; }
    .app-header .helper-text { display: none; }
}
