:root {
    --primary: #1a2238;
    --primary-2: #283556;
    --accent: #2d6cdf;
    --accent-soft: #eaf1fb;
    --income: #198754;
    --expense-b: #dc3545;
    --expense-p: #6f42c1;
    --cost: #fd7e14;
    --receivable: #0d6efd;
    --pending: #f0ad4e;
    --bg: #f5f6fa;
    --surface: #ffffff;
    --border: #e4e7ee;
    --text: #1c2333;
    --text-muted: #6b7280;
    --sidebar-w: 240px;
}

[data-bs-theme="dark"] {
    --primary: #0e1424;
    --primary-2: #1a2238;
    --accent: #4a8df0;
    --accent-soft: #1c2942;
    --bg: #0f1320;
    --surface: #181d2c;
    --border: #2a3145;
    --text: #e6e8ee;
    --text-muted: #97a0b4;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
    font-size: 0.95rem;
}

.app-wrapper { display: flex; min-height: 100vh; }

.sidebar {
    background: var(--primary);
    color: #cbd2e3;
    width: var(--sidebar-w);
    min-height: 100vh;
    position: fixed;
    inset: 0 auto 0 0;
    display: flex;
    flex-direction: column;
    z-index: 1040;
    transition: transform 0.25s ease;
}

.sidebar-brand {
    padding: 20px 22px;
    font-size: 1.25rem;
    font-weight: 600;
    color: #fff;
    letter-spacing: 0.3px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-nav { padding: 12px 10px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.sidebar-nav .nav-link {
    color: #b9c1d6;
    padding: 10px 14px;
    border-radius: 8px;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.92rem;
    transition: all 0.15s ease;
}
.sidebar-nav .nav-link:hover { background: rgba(255,255,255,0.07); color: #fff; }
.sidebar-nav .nav-link.active { background: var(--accent); color: #fff; box-shadow: 0 2px 8px rgba(45,108,223,0.35); }
.sidebar-nav .nav-link i { font-size: 1.05rem; }
.sidebar-section-label {
    color: rgba(185, 193, 214, 0.55);
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding: 10px 14px 2px;
}

.sidebar-footer { padding: 12px 14px; border-top: 1px solid rgba(255,255,255,0.06); }

.main-area { flex: 1; margin-left: var(--sidebar-w); display: flex; flex-direction: column; min-width: 0; }

.topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 14px 22px;
    display: flex;
    align-items: center;
    gap: 12px;
    position: sticky;
    top: 0;
    z-index: 1030;
}
.topbar-title { font-size: 1.15rem; font-weight: 600; margin: 0; }
.topbar-actions { gap: 10px; }

.main-content { padding: 22px; flex: 1; }

.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.45); z-index: 1035; }
.sidebar-overlay.show { display: block; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 1px 3px rgba(0,0,0,0.04); }
.card-header { background: transparent; border-bottom: 1px solid var(--border); font-weight: 600; }
.table thead th { background: var(--bg); font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.4px; color: var(--text-muted); border-bottom: 1px solid var(--border); }
.table td { vertical-align: middle; padding: 12px 10px; }

.kpi-card { border-left: 4px solid var(--accent); }
.kpi-value { font-size: 1.5rem; font-weight: 700; margin: 0; }
.kpi-label { font-size: 0.78rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }
.kpi-card.income { border-left-color: var(--income); }
.kpi-card.expense-b { border-left-color: var(--expense-b); }
.kpi-card.expense-p { border-left-color: var(--expense-p); }
.kpi-card.cost { border-left-color: var(--cost); }
.kpi-card.receivable { border-left-color: var(--receivable); }

.badge-status { font-size: 0.72rem; padding: 5px 10px; border-radius: 6px; font-weight: 500; }
.badge-draft { background: #6c757d; color: #fff; }
.badge-quoted { background: #0dcaf0; color: #000; }
.badge-approved { background: #0d6efd; color: #fff; }
.badge-inprogress { background: #6f42c1; color: #fff; }
.badge-waiting { background: #fd7e14; color: #fff; }
.badge-completed { background: #198754; color: #fff; }
.badge-cancelled { background: #dc3545; color: #fff; }

.empty-state { padding: 50px 22px; text-align: center; color: var(--text-muted); }
.empty-state i { font-size: 3rem; opacity: 0.55; }

.btn-primary { background: var(--accent); border-color: var(--accent); }
.btn-primary:hover { background: #1f59bd; border-color: #1f59bd; }

.form-label { font-size: 0.85rem; font-weight: 500; }
.form-control, .form-select { border-radius: 8px; }
.input-group-text { background: var(--bg); border-color: var(--border); }

.login-page { background: linear-gradient(135deg, var(--primary) 0%, var(--primary-2) 100%); }
.login-wrapper { padding: 16px; }
.login-card { max-width: 420px; width: 100%; border-radius: 18px; border: none; }
.login-card .form-control { padding: 12px 14px; }

@media (max-width: 767.98px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.show { transform: translateX(0); }
    .main-area { margin-left: 0; }
}

.loading-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.35); display: flex; align-items: center; justify-content: center; z-index: 1080; }
.spinner-box { background: var(--surface); padding: 18px 26px; border-radius: 12px; }

.toast-flash { position: fixed; top: 18px; right: 18px; z-index: 1090; min-width: 280px; }

/* Mobil için tablolar otomatik yatay kaydırma kaygacı */
@media (max-width: 767.98px) {
    .main-content { padding: 14px; }
    .topbar { padding: 10px 14px; gap: 8px; }
    .topbar-title { font-size: 1rem; max-width: 55vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .kpi-value { font-size: 1.2rem; }
    .kpi-label { font-size: 0.7rem; }
    .card-body { padding: 12px; }
    .table td, .table th { padding: 9px 6px; font-size: 0.85rem; }
    /* Dar ekranda inline sabit genişlik yok sayılır */
    [style*="width:150px"], [style*="width:170px"] { width: 100% !important; max-width: 100% !important; }
    .modal-dialog { margin: 6px; }
    .modal-body { padding: 14px !important; }
    .toast-flash { left: 10px; right: 10px; top: 10px; min-width: 0; }
}

/* Geniş ekran yardımcıları */
.w-auto-sm { width: auto; }

.topbar-actions { flex-wrap: wrap; row-gap: 6px; }
@media (max-width: 575.98px) {
    #quickAddBtn span, .topbar-actions .d-none.d-md-inline { display: none !important; }
    #quickAddBtn { padding: 4px 8px; }
    .topbar-actions .dropdown-toggle span { display: none; }
}

/* Erişilebilirlik: klavye odağı her zaman görünür */
:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: 4px;
}
.sidebar .nav-link:focus-visible { outline-color: #fff; }
.btn:focus-visible, .form-control:focus-visible, .form-select:focus-visible {
    box-shadow: 0 0 0 0.2rem rgba(45, 108, 223, 0.35);
}

/* Hareket azaltma tercihi: animasyon/geçişleri kapat */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* Mobil dokunma alanları (minimum 44px) */
@media (max-width: 767.98px) {
    #sidebarToggle, #themeToggle, #quickAddBtn, .dropdown-toggle { min-height: 44px; min-width: 44px; }
}
