:root {
    --bg: #f5f6f8;
    --surface: #ffffff;
    --surface-2: #f0f1f4;
    --border: #dcdfe4;
    --text: #1a1d23;
    --text-muted: #6b7280;
    --primary: #2f6fed;
    --primary-hover: #2558c4;
    --success: #1e8e5a;
    --danger: #d64545;
    --radius: 10px;
}

/* --- Koyu Tema (data-theme="dark" ile aktif olur) -------------------- */
[data-theme="dark"] {
    --bg: #071019;
    --surface: #0b2436;
    --surface-2: #102c3f;
    --border: #1c3a4a;
    --text: #e8f5f0;
    --text-muted: #8fb5ae;
    --primary: #00e0a4;
    --primary-hover: #00c090;
    --success: #3ddc84;
    --danger: #ff5c5c;
}
[data-theme="dark"] body {
    background:
        radial-gradient(circle at 15% 10%, rgba(0, 224, 164, 0.10), transparent 40%),
        radial-gradient(circle at 85% 90%, rgba(0, 180, 216, 0.08), transparent 45%),
        linear-gradient(135deg, #061019 0%, #0b2436 50%, #081a22 100%);
    background-attachment: fixed;
}
[data-theme="dark"] .sidebar { background: rgba(11, 36, 54, 0.75); backdrop-filter: blur(6px); }
[data-theme="dark"] .surface,
[data-theme="dark"] .panel,
[data-theme="dark"] .auth-box,
[data-theme="dark"] .kpi-card,
[data-theme="dark"] table { background: rgba(11, 36, 54, 0.75); backdrop-filter: blur(4px); }
[data-theme="dark"] button, [data-theme="dark"] .btn { color: #04211a; }
[data-theme="dark"] .alert-error { background: rgba(255,92,92,0.12); color: #ff9d9d; border-color: rgba(255,92,92,0.35); }
[data-theme="dark"] .alert-success { background: rgba(61,220,132,0.12); color: #8ff5b8; border-color: rgba(61,220,132,0.35); }
[data-theme="dark"] .badge-success { background: rgba(61,220,132,0.15); color: #8ff5b8; }
[data-theme="dark"] .badge-danger { background: rgba(255,92,92,0.15); color: #ff9d9d; }

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
}

a { color: var(--primary); text-decoration: none; }

/* --- Giriş Sayfası ------------------------------------------- */
.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}

.auth-box {
    width: 100%;
    max-width: 360px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 32px;
    text-align: center;
}

.auth-box h1 { margin: 0 0 4px; font-size: 24px; }
.auth-box .subtitle { color: var(--text-muted); margin: 0 0 24px; font-size: 14px; }
.auth-box form { text-align: left; display: flex; flex-direction: column; gap: 6px; }
.auth-box label { font-size: 13px; color: var(--text-muted); margin-top: 10px; }

input[type="text"], input[type="password"], input[type="number"], input[type="date"], select, textarea {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 10px 12px;
    color: var(--text);
    font-size: 14px;
    width: 100%;
}

button, .btn {
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 11px 16px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 18px;
}
button:hover, .btn:hover { background: var(--primary-hover); }

.alert { padding: 10px 14px; border-radius: 6px; font-size: 14px; margin-bottom: 14px; }
.alert-error { background: rgba(214,69,69,0.08); color: #b83232; border: 1px solid rgba(214,69,69,0.35); }
.alert-success { background: rgba(30,142,90,0.08); color: #1e8e5a; border: 1px solid rgba(30,142,90,0.35); }

/* --- Uygulama Kabuğu (sidebar + içerik) ------------------------ */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
    width: 220px;
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 20px 0;
    flex-shrink: 0;
}

.sidebar-brand { font-weight: 700; font-size: 18px; padding: 0 20px 20px; }

.sidebar nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.sidebar nav a {
    color: var(--text-muted);
    padding: 10px 20px;
    font-size: 14px;
}
.sidebar nav a:hover { background: var(--surface-2); color: var(--text); }
.sidebar nav a.active { background: var(--surface-2); color: var(--primary); border-right: 2px solid var(--primary); }
.sidebar nav a.sub-link { padding-left: 34px; font-size: 13px; color: var(--text-muted); opacity: 0.85; }
.sidebar nav a.sub-link:hover { opacity: 1; }

.sidebar-footer {
    padding: 14px 20px 0;
    border-top: 1px solid var(--border);
    margin-top: 14px;
    font-size: 13px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    color: var(--text-muted);
}

.theme-toggle-btn {
    background: var(--surface-2);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 8px 10px;
    font-size: 13px;
    text-align: left;
    cursor: pointer;
    margin: 2px 0;
}
.theme-toggle-btn:hover { background: var(--border); }

.content { flex: 1; padding: 28px 32px; max-width: 1200px; }
.content-header h1 { margin: 0 0 20px; font-size: 22px; }

.hint { color: var(--text-muted); font-size: 13px; margin-top: 24px; max-width: 640px; }

/* --- KPI Kartları --------------------------------------------- */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
}

.kpi-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 20px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.kpi-label { font-size: 13px; color: var(--text-muted); }
.kpi-value { font-size: 26px; font-weight: 700; }
.kpi-value.positive { color: var(--success); }
.kpi-value.negative { color: var(--danger); }
.kpi-sub { font-size: 12px; color: var(--text-muted); }

/* --- Tablolar (ileriki modüller için) -------------------------- */
table { width: 100%; border-collapse: collapse; background: var(--surface); border-radius: var(--radius); overflow: hidden; }
th, td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--border); font-size: 14px; }
th { color: var(--text-muted); font-weight: 600; font-size: 12px; text-transform: uppercase; }
th:hover { color: var(--primary); }
.sort-arrow { color: var(--primary); font-size: 10px; }
tr:last-child td { border-bottom: none; }

/* --- Paneller (modül sayfalarındaki bölümler) ------------------ */
.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 22px;
    margin-top: 20px;
}
.panel table { border: 1px solid var(--border); }
.panel h2 { margin: 0 0 6px; font-size: 16px; }
.panel .hint { margin-top: 0; margin-bottom: 14px; }

/* --- Form satırları ---------------------------------------------- */
.inline-form .form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 14px;
    margin-bottom: 4px;
}
.inline-form label { font-size: 13px; color: var(--text-muted); display: block; margin: 10px 0 6px; }
.inline-form button { margin-top: 16px; }

/* --- Rozetler (alış/satış vb.) ----------------------------------- */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}
.badge-success { background: rgba(30,142,90,0.12); color: #1e8e5a; }
.badge-danger { background: rgba(214,69,69,0.12); color: #b83232; }

/* --- Grafik kutusu ------------------------------------------------ */
.chart-wrap { max-width: 100%; height: 320px; position: relative; margin-top: 10px; }
.chart-wrap canvas { max-height: 320px !important; }

/* --- Filtre formu -------------------------------------------------- */
.filter-form { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 20px; }

.btn-secondary {
    display: inline-block;
    background: var(--surface-2);
    color: var(--text-muted);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 11px 16px;
    font-size: 14px;
    text-align: center;
}
.btn-secondary:hover { color: var(--text); }

/* --- Sayfalama ------------------------------------------------------ */
.pagination { display: flex; align-items: center; gap: 16px; margin-top: 16px; font-size: 14px; color: var(--text-muted); }
.pagination a { color: var(--primary); }

/* --- Tablo hücrelerinde K/Z renklendirme ----------------------------- */
td.positive { color: var(--success); }
td.negative { color: var(--danger); }

/* --- Alt başlıklar --------------------------------------------------- */
.sub-heading { font-size: 14px; color: var(--text-muted); margin: 22px 0 10px; text-transform: uppercase; letter-spacing: 0.4px; }

/* --- İki sütunlu düzen (kategori listeleri) --------------------------- */
.two-col { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 24px; }

/* --- Kategori listesi --------------------------------------------------- */
.category-list { list-style: none; padding: 0; margin: 0; }
.category-list li {
    display: flex; align-items: center; justify-content: space-between;
    padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 14px;
}
.category-list li:last-child { border-bottom: none; }

/* --- İkon butonlar (sil/pasife al) --------------------------------------- */
.btn-icon-danger {
    background: transparent; border: none; color: var(--danger);
    cursor: pointer; font-size: 15px; padding: 4px 8px; margin: 0;
}
.btn-icon-danger:hover { background: rgba(231,76,60,0.15); border-radius: 4px; }

/* --- Bütçe ilerleme çubuğu ------------------------------------------------ */
.budget-bar { width: 120px; height: 8px; background: var(--surface-2); border-radius: 4px; overflow: hidden; display: inline-block; vertical-align: middle; margin-right: 8px; }
.budget-bar-fill { height: 100%; background: var(--success); }
.budget-bar-fill.over { background: var(--danger); }

/* --- Bot log kutusu ------------------------------------------------------ */
.log-box {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 14px 16px;
    font-family: 'Courier New', monospace;
    font-size: 12px;
    line-height: 1.6;
    color: var(--text-muted);
    max-height: 500px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-word;
}

/* --- Mobil menü çubuğu (varsayılan gizli, sadece küçük ekranda görünür) --- */
.mobile-topbar {
    display: none;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 50;
}
.mobile-topbar .mobile-brand { font-weight: 700; font-size: 16px; display:flex; align-items:center; gap:8px; }
.mobile-topbar .mobile-brand img { height: 24px; width: 24px; border-radius: 6px; }
.hamburger-btn {
    background: none;
    border: 1px solid var(--border);
    border-radius: 6px;
    width: 40px;
    height: 40px;
    font-size: 20px;
    color: var(--text);
    cursor: pointer;
    line-height: 1;
}
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 90;
}
.sidebar-overlay.open { display: block; }

/* --- Tabletler ve küçük ekranlar --- */
@media (max-width: 900px) {
    .mobile-topbar { display: flex; }

    .app-shell { flex-direction: column; }

    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: 260px;
        max-width: 80vw;
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        z-index: 100;
        overflow-y: auto;
    }
    .sidebar.open { transform: translateX(0); }
    .sidebar-brand { display: none; } /* mobilde marka üstte, sidebar'da tekrar gösterilmiyor */

    .content { padding: 16px; }
    .content-header { display: none; } /* başlık zaten mobile-topbar'da (sayfa adı) gösterilebilir */

    .kpi-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
    .kpi-value { font-size: 20px; }

    /* Tabloları yatayda kaydırılabilir yap, düzeni bozmadan */
    .panel { padding: 14px 12px; overflow-x: auto; }
    table { min-width: 560px; }

    .inline-form .form-row { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
    .kpi-grid { grid-template-columns: 1fr; }
    table { min-width: 480px; }
}