/* ===== Buchhaltung – Light Theme (matches Art Assistant) ===== */

:root {
    --bg: #f5f5f7;
    --sidebar-bg: #ffffff;
    --surface: #ffffff;
    --surface-hover: #f0f0f3;
    --border: #e2e4e9;
    --border-light: #eef0f4;
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --primary-light: rgba(79,70,229,.08);
    --accent: #6366f1;
    --text: #1a1a2e;
    --text-muted: #64748b;
    --text-dim: #94a3b8;
    --success: #16a34a;
    --success-bg: rgba(22,163,74,.08);
    --danger: #dc2626;
    --danger-bg: rgba(220,38,38,.08);
    --warning: #d97706;
    --warning-bg: rgba(217,119,6,.08);
    --info: #2563eb;
    --info-bg: rgba(37,99,235,.08);
    --radius: 12px;
    --radius-sm: 8px;
    --sidebar-width: 240px;
    --sidebar-collapsed: 60px;
    --header-height: 56px;
    --shadow-sm: 0 1px 2px rgba(0,0,0,.05);
    --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
    --shadow-md: 0 4px 12px rgba(0,0,0,.08);
    --shadow-lg: 0 10px 30px rgba(0,0,0,.1);
}

/* ===== Reset ===== */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: 17.5px; }
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.6;
}
p, li, td, th, label, input, textarea, select, button, .form-control, .btn {
    line-height: 1.55;
}
h1, h2, h3, h4, h5, h6 { line-height: 1.35; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ===== Layout ===== */
.app-layout {
    display: grid;
    grid-template-columns: var(--sidebar-width) 1fr;
    grid-template-rows: var(--header-height) 1fr;
    min-height: 100vh;
    transition: grid-template-columns .25s ease;
}
.app-layout.sidebar-collapsed { grid-template-columns: var(--sidebar-collapsed) 1fr; }

/* ===== Sidebar ===== */
.sidebar {
    grid-row: 1 / -1;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: width .25s ease;
    width: var(--sidebar-width);
    z-index: 100;
}
.sidebar-collapsed .sidebar { width: var(--sidebar-collapsed); }

.sidebar-logo {
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid var(--border);
    height: var(--header-height);
    flex-shrink: 0;
}
.sidebar-logo .logo-icon {
    width: 32px; height: 32px; min-width: 32px;
    background: var(--primary);
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
}
.sidebar-logo .logo-text {
    font-weight: 800; font-size: .9rem;
    white-space: nowrap; overflow: hidden;
    transition: opacity .2s;
}
.sidebar-collapsed .sidebar-logo .logo-text { opacity: 0; width: 0; }
.sidebar-collapsed .sidebar-logo {
    justify-content: center;
    padding: 12px 0;
    gap: 0;
}

.sidebar-nav { padding: 8px 8px; flex: 1; overflow-y: auto; overflow-x: hidden; }
.sidebar-nav .nav-section {
    font-size: .65rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: .8px; color: var(--text-dim);
    padding: 14px 8px 4px; white-space: nowrap;
    transition: opacity .2s;
}
.sidebar-collapsed .nav-section { opacity: 0; height: 0; padding: 0; overflow: hidden; }

.sidebar-nav .nav-item {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 10px; border-radius: var(--radius-sm);
    color: var(--text-muted); font-size: .85rem; font-weight: 500;
    cursor: pointer; transition: all .15s; text-decoration: none;
    white-space: nowrap; overflow: hidden;
}
.sidebar-nav .nav-item:hover { background: var(--surface-hover); color: var(--text); text-decoration: none; }
.sidebar-nav .nav-item.active { background: var(--primary-light); color: var(--primary); }
.sidebar-nav .nav-item svg {
    width: 18px; height: 18px; flex-shrink: 0;
    stroke: currentColor; fill: none; stroke-width: 1.8;
    stroke-linecap: round; stroke-linejoin: round;
}
.sidebar-nav .nav-item span {
    transition: opacity .2s; overflow: hidden;
}
.sidebar-collapsed .nav-item span { opacity: 0; width: 0; }

.sidebar-footer {
    padding: 10px 14px; border-top: 1px solid var(--border);
    font-size: .78rem; color: var(--text-dim);
    white-space: nowrap; overflow: hidden;
    transition: opacity .2s;
}
.sidebar-collapsed .sidebar-footer { opacity: 0; }

/* Sidebar toggle button */
.sidebar-toggle {
    width: 28px; height: 28px; border-radius: 6px;
    border: 1px solid var(--border); background: var(--surface);
    color: var(--text-muted); cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: all .15s; flex-shrink: 0;
}
.sidebar-toggle:hover { background: var(--surface-hover); color: var(--text); }
.sidebar-toggle svg { transition: transform .25s ease; }
.sidebar-collapsed .sidebar-toggle svg { transform: rotate(180deg); }

/* Mobile burger */
.mobile-burger {
    display: none; width: 36px; height: 36px;
    border-radius: var(--radius-sm); border: 1px solid var(--border);
    background: var(--surface); color: var(--text);
    cursor: pointer; align-items: center; justify-content: center;
}
.mobile-overlay {
    display: none; position: fixed; inset: 0;
    background: rgba(0,0,0,.3); z-index: 99;
}
.mobile-overlay.active { display: block; }

/* ===== Header ===== */
.header {
    background: var(--sidebar-bg);
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 20px; height: var(--header-height);
}
.header-left { display: flex; align-items: center; gap: 12px; }
.header-title { font-size: 1rem; font-weight: 700; }
.header-actions { display: flex; align-items: center; gap: 12px; }

/* ===== Main Content ===== */
.main-content {
    padding: 20px;
    overflow-y: auto;
    max-height: calc(100vh - var(--header-height));
}

/* ===== Cards ===== */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}
.card-header {
    padding: 14px 18px;
    display: flex; align-items: center; justify-content: space-between;
    border-bottom: 1px solid var(--border-light);
}
.card-title { font-size: .85rem; font-weight: 700; }
.card-body { padding: 18px; }

/* ===== Stats Grid ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px; margin-bottom: 20px;
}
.stat-card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 16px 18px;
    box-shadow: var(--shadow-sm);
}
.stat-label {
    font-size: .7rem; font-weight: 600; text-transform: uppercase;
    letter-spacing: .5px; color: var(--text-dim); margin-bottom: 4px;
}
.stat-value { font-size: 1.5rem; font-weight: 800; line-height: 1.2; }
.stat-sub { font-size: .75rem; color: var(--text-muted); margin-top: 3px; }

/* ===== Buttons ===== */
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 7px 14px; border-radius: var(--radius-sm);
    font-size: .82rem; font-weight: 600; border: none;
    cursor: pointer; text-decoration: none; transition: all .15s;
    font-family: inherit; line-height: 1.4;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-outline { background: transparent; color: var(--text-muted); border: 1px solid var(--border); }
.btn-outline:hover { border-color: var(--text-muted); color: var(--text); }
.btn-ghost { background: transparent; color: var(--primary); padding: 4px 8px; }
.btn-ghost:hover { background: var(--primary-light); }
.btn-sm { padding: 5px 10px; font-size: .75rem; }
.btn-lg { padding: 10px 20px; font-size: .9rem; }
.btn-icon { padding: 7px; }
.w-full { width: 100%; justify-content: center; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ===== Forms ===== */
.form-group { margin-bottom: 14px; }
.form-label {
    display: block; font-size: .72rem; font-weight: 600;
    color: var(--text-muted); margin-bottom: 5px;
    text-transform: uppercase; letter-spacing: .5px;
}
.form-control {
    width: 100%; padding: 9px 12px;
    background: var(--bg); border: 1px solid var(--border);
    border-radius: var(--radius-sm); color: var(--text);
    font-size: .875rem; font-family: inherit; transition: border .2s;
}
.form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79,70,229,.1); }
.form-control::placeholder { color: var(--text-dim); }
textarea.form-control { resize: vertical; }
select.form-control { cursor: pointer; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.form-hint { font-size: .72rem; color: var(--text-dim); margin-top: 3px; }

/* ===== Alerts ===== */
.alert {
    padding: 10px 14px; border-radius: var(--radius-sm);
    font-size: .82rem; margin-bottom: 14px;
    display: flex; align-items: flex-start; gap: 8px;
}
.alert-info { background: var(--info-bg); color: var(--info); border: 1px solid rgba(37,99,235,.15); }
.alert-success { background: var(--success-bg); color: var(--success); border: 1px solid rgba(22,163,74,.15); }
.alert-danger { background: var(--danger-bg); color: var(--danger); border: 1px solid rgba(220,38,38,.15); }
.alert-warning { background: var(--warning-bg); color: var(--warning); border: 1px solid rgba(217,119,6,.15); }

/* ===== Tables ===== */
.table-wrapper { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .85rem; }
th {
    text-align: left; padding: 9px 14px; font-weight: 600;
    font-size: .72rem; text-transform: uppercase; letter-spacing: .5px;
    color: var(--text-dim); border-bottom: 1px solid var(--border);
    white-space: nowrap; background: var(--bg);
}
td { padding: 9px 14px; border-bottom: 1px solid var(--border-light); vertical-align: middle; }
tr:hover td { background: var(--surface-hover); }
tr:last-child td { border-bottom: none; }

/* ===== Badges ===== */
.badge {
    display: inline-flex; align-items: center;
    padding: 2px 9px; border-radius: 20px;
    font-size: .72rem; font-weight: 600;
}
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-info { background: var(--info-bg); color: var(--info); }

/* ===== EÜR Specific ===== */
.euer-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 20px;
}
.euer-section { }
.euer-section h3 {
    font-size: .8rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: .5px; color: var(--text-dim); margin-bottom: 10px;
}
.euer-row {
    display: flex; justify-content: space-between; align-items: center;
    padding: 8px 0; border-bottom: 1px solid var(--border-light);
    font-size: .85rem;
}
.euer-row:last-child { border-bottom: none; }
.euer-row .label { color: var(--text-muted); }
.euer-row .value { font-weight: 700; font-variant-numeric: tabular-nums; }
.euer-total {
    display: flex; justify-content: space-between; align-items: center;
    padding: 12px 0; margin-top: 8px;
    border-top: 2px solid var(--border);
    font-size: 1rem;
}
.euer-total .label { font-weight: 700; }
.euer-total .value { font-weight: 800; font-size: 1.2rem; }
.euer-total .value.positive { color: var(--success); }
.euer-total .value.negative { color: var(--danger); }

/* ===== Month Filter ===== */
.filter-bar {
    display: flex; align-items: center; gap: 10px;
    margin-bottom: 16px; flex-wrap: wrap;
}
.filter-bar select, .filter-bar input {
    padding: 7px 12px; border: 1px solid var(--border);
    border-radius: var(--radius-sm); font-size: .82rem;
    background: var(--surface); color: var(--text);
    font-family: inherit;
}
.filter-bar select:focus, .filter-bar input:focus {
    outline: none; border-color: var(--primary);
}

/* ===== Modal ===== */
.modal-overlay {
    display: none; position: fixed; inset: 0;
    background: rgba(0,0,0,.4); z-index: 1000;
    align-items: center; justify-content: center;
}
.modal-overlay.active { display: flex; }
.modal {
    background: var(--surface); border-radius: var(--radius);
    padding: 24px; max-width: 560px; width: 90%;
    max-height: 90vh; overflow-y: auto;
    box-shadow: var(--shadow-lg);
}
.modal-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 16px;
}
.modal-header h2 { font-size: 1rem; font-weight: 700; }
.modal-close {
    width: 32px; height: 32px; border-radius: 6px;
    border: 1px solid var(--border); background: var(--surface);
    color: var(--text-muted); cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.2rem;
}
.modal-close:hover { background: var(--surface-hover); color: var(--text); }
.modal-actions {
    display: flex; gap: 10px; justify-content: flex-end;
    margin-top: 20px; padding-top: 16px;
    border-top: 1px solid var(--border-light);
}

/* ===== Empty State ===== */
.empty-state {
    text-align: center; padding: 40px 20px;
    color: var(--text-muted);
}
.empty-state svg { margin-bottom: 12px; opacity: .5; }
.empty-state p { font-size: .85rem; margin-bottom: 12px; }

/* ===== Utilities ===== */
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: .82rem; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.font-mono { font-variant-numeric: tabular-nums; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .app-layout {
        grid-template-columns: 1fr;
    }
    .sidebar {
        position: fixed; left: -260px;
        width: var(--sidebar-width); height: 100vh;
        transition: left .25s ease;
    }
    .sidebar.open { left: 0; }
    .mobile-burger { display: flex; }
    .sidebar-toggle { display: none; }
    .euer-grid { grid-template-columns: 1fr; }
    .form-row { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
    .main-content { padding: 12px; }
}
