:root {
    --sidebar-bg: #0f172a;
    --sidebar-text: #94a3b8;
    --sidebar-text-active: #ffffff;
    --sidebar-section: #64748b;
    --bg: #f1f5f9;
    --card-bg: #ffffff;
    --border: #e2e8f0;
    --text: #0f172a;
    --text-muted: #64748b;
    --primary: #2563eb;
    --primary-end: #60a5fa;
    --success: #16a34a;
    --danger: #dc2626;
    --warning: #d97706;
    --radius: 12px;
    --sidebar-w: 260px;
    --topbar-h: 64px;
    --primary-light: color-mix(in srgb, var(--primary) 12%, var(--card-bg));
    --primary-glow: color-mix(in srgb, var(--primary) 15%, transparent);
    --success-bg: color-mix(in srgb, var(--success) 16%, var(--card-bg));
    --danger-bg: color-mix(in srgb, var(--danger) 16%, var(--card-bg));
    --warning-bg: color-mix(in srgb, var(--warning) 16%, var(--card-bg));
    --shadow-sm: 0 1px 2px rgba(15,23,42,0.05);
    --shadow-md: 0 8px 24px -8px rgba(15,23,42,0.14), 0 1px 2px rgba(15,23,42,0.04);
    --shadow-card: 0 1px 3px rgba(15,23,42,0.04), 0 1px 2px rgba(15,23,42,0.03);
}
[data-theme="dark"] {
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
    --shadow-md: 0 10px 28px -8px rgba(0,0,0,0.45), 0 1px 2px rgba(0,0,0,0.3);
    --shadow-card: 0 1px 3px rgba(0,0,0,0.3), 0 1px 2px rgba(0,0,0,0.2);
}

/* --- Aksan renkleri (tema seciciden data-accent ile degistirilir) --- */
[data-accent="violet"] { --primary: #7c3aed; --primary-end: #a78bfa; }
[data-accent="teal"] { --primary: #0d9488; --primary-end: #2dd4bf; }
[data-accent="amber"] { --primary: #d97706; --primary-end: #fbbf24; }
[data-accent="rose"] { --primary: #e11d48; --primary-end: #fb7185; }

/* --- Karanlik mod --- */
[data-theme="dark"] {
    --sidebar-bg: #0a0f1c;
    --bg: #0b1220;
    --card-bg: #161f30;
    --border: #2a3548;
    --text: #e6ebf2;
    --text-muted: #93a0b8;
}
[data-theme="dark"] .topbar-icon-btn,
[data-theme="dark"] .lang-btn,
[data-theme="dark"] button.secondary { background: var(--card-bg); }
[data-theme="dark"] input[type=text],
[data-theme="dark"] input[type=password],
[data-theme="dark"] input[type=email],
[data-theme="dark"] input[type=number],
[data-theme="dark"] input[type=url],
[data-theme="dark"] select,
[data-theme="dark"] textarea { background: var(--bg); }

* { box-sizing: border-box; }
html { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
body {
    margin: 0;
    font-family: 'Manrope', 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
}
a { color: inherit; }
h1, h2, h3 { font-weight: 800; letter-spacing: -0.01em; text-wrap: balance; }
strong, b, .name, .stat-value, .gauge-value { font-weight: 700; }

.app-shell { display: flex; min-height: 100vh; }

/* --- Sidebar --- */
.sidebar {
    width: var(--sidebar-w);
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    flex-shrink: 0;
    position: fixed;
    inset-inline-start: 0;
    top: 0;
    bottom: 0;
    overflow-y: auto;
    padding-bottom: 1rem;
    box-shadow: 1px 0 0 rgba(255,255,255,0.04) inset, var(--shadow-md);
}
.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 1.2rem 1.4rem;
    color: #fff;
    font-weight: 700;
    font-size: 1.05rem;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}
.sidebar-logo .logo-icon {
    width: 30px; height: 30px; border-radius: 8px;
    background: linear-gradient(135deg, var(--primary), var(--primary-end));
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.sidebar-section {
    padding: 1rem 1.4rem 0.4rem;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    color: var(--sidebar-section);
}
.sidebar-item {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.55rem 1.4rem;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 0.87rem;
    border-inline-start: 3px solid transparent;
}
.sidebar-item { transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease; }
.sidebar-item:hover { background: rgba(255,255,255,0.06); color: #fff; }
.sidebar-item.active {
    background: var(--primary-glow);
    color: var(--sidebar-text-active);
    border-inline-start-color: var(--primary);
    font-weight: 700;
}
.sidebar-item.active .icon { color: color-mix(in srgb, var(--primary) 55%, white); }
.sidebar-item .icon { width: 18px; height: 18px; text-align: center; flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center; }
.icon-svg { width: 18px; height: 18px; flex-shrink: 0; vertical-align: -4px; }
.logo-icon .icon-svg { width: 16px; height: 16px; color: #fff; }
.topbar-icon-btn .icon-svg { width: 18px; height: 18px; }
.topbar-search .search-icon .icon-svg { width: 16px; height: 16px; color: var(--text-muted); }

/* --- Topbar --- */
.main-wrap {
    flex: 1;
    margin-inline-start: var(--sidebar-w);
    display: flex;
    flex-direction: column;
    min-width: 0;
}
.topbar {
    height: var(--topbar-h);
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    position: sticky;
    top: 0;
    z-index: 10;
    gap: 1rem;
    box-shadow: var(--shadow-sm);
}
.topbar-search {
    flex: 1;
    max-width: 420px;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--bg);
    border-radius: 8px;
    padding: 0.5rem 0.8rem;
    color: var(--text-muted);
    font-size: 0.85rem;
}
.topbar-search input {
    border: none; background: transparent; outline: none; flex: 1; font-size: 0.85rem; color: var(--text);
}
.topbar-right { display: flex; align-items: center; gap: 0.9rem; }
.topbar-icon-btn {
    width: 36px; height: 36px; border-radius: 8px; border: 1px solid var(--border);
    background: var(--card-bg); display: flex; align-items: center; justify-content: center;
    cursor: pointer; color: var(--text-muted); position: relative; text-decoration: none;
    font-size: 1rem;
}
.lang-switcher { position: relative; }
.lang-btn {
    display: flex; align-items: center; gap: 0.4rem; border: 1px solid var(--border); background: var(--card-bg);
    border-radius: 8px; padding: 0.45rem 0.7rem; cursor: pointer; font-size: 0.85rem; color: var(--text);
}
.lang-menu {
    position: absolute; top: 110%; inset-inline-end: 0; background: var(--card-bg);
    border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow-md);
    min-width: 170px; z-index: 30; overflow: hidden;
    opacity: 0; visibility: hidden; transform: translateY(-4px) scale(0.98);
    transition: opacity 0.14s ease, transform 0.14s ease, visibility 0.14s;
    transform-origin: top right;
}
[dir="rtl"] .lang-menu { transform-origin: top left; }
.lang-switcher:hover .lang-menu, .lang-switcher:focus-within .lang-menu {
    opacity: 1; visibility: visible; transform: translateY(0) scale(1);
}
@media (prefers-reduced-motion: reduce) {
    .lang-menu { transition: opacity 0.01ms; transform: none; }
}
.lang-menu a { display: flex; align-items: center; gap: 0.6rem; padding: 0.55rem 0.9rem; font-size: 0.85rem; text-decoration: none; color: var(--text); }
.lang-menu a { transition: background 0.1s ease; }
.lang-menu a:hover { background: var(--bg); }
.lang-menu a.active { color: var(--primary); font-weight: 600; }

.user-menu { display: flex; align-items: center; gap: 0.6rem; cursor: pointer; }
.avatar {
    width: 34px; height: 34px; border-radius: 50%; background: var(--primary);
    color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 0.8rem;
    flex-shrink: 0;
}
.user-menu .name { font-size: 0.85rem; font-weight: 600; line-height: 1.1; }
.user-menu .role { font-size: 0.72rem; color: var(--text-muted); }

/* --- Content --- */
.content { padding: 1.6rem; flex: 1; animation: panelFadeIn 0.22s ease; }
@keyframes panelFadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
    .content { animation: none; }
}
.page-header { margin-bottom: 1.4rem; }
.page-header h1 { margin: 0 0 0.2rem; font-size: 1.4rem; }
.page-header p { margin: 0; color: var(--text-muted); font-size: 0.88rem; }

.card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.4rem;
    margin-bottom: 1.4rem;
    box-shadow: var(--shadow-card);
}
.card h2 { margin: 0 0 0.8rem; font-size: 1rem; }
.card.success { border-inline-start: 4px solid var(--success); }
.card.error { border-inline-start: 4px solid var(--danger); }
.hint { color: var(--text-muted); font-size: 0.85rem; }

/* --- Stat cards (home) --- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 1.1rem; margin-bottom: 1.4rem; }
.stat-card {
    background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 1.2rem; display: flex; align-items: flex-start; gap: 0.9rem;
    box-shadow: var(--shadow-card);
    transition: box-shadow 0.15s ease, transform 0.15s ease;
}
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.stat-icon {
    width: 44px; height: 44px; border-radius: 10px; display: flex; align-items: center; justify-content: center;
    font-size: 1.2rem; flex-shrink: 0; color: #fff;
}
.stat-value { font-size: 1.5rem; font-weight: 700; line-height: 1.1; }
.stat-label { font-size: 0.8rem; color: var(--text-muted); margin: 0.15rem 0 0.5rem; }
.stat-link { font-size: 0.78rem; color: var(--primary); text-decoration: none; font-weight: 600; }

/* --- Forms --- */
input[type=text], input[type=password], input[type=email], input[type=number], input[type=url], select, textarea {
    padding: 0.55rem 0.7rem; border-radius: 8px; border: 1px solid var(--border);
    background: var(--card-bg); color: var(--text); font-size: 0.85rem; font-family: inherit;
    transition: border-color 0.12s ease, box-shadow 0.12s ease;
}
input[type=text]:hover, input[type=password]:hover, input[type=email]:hover, input[type=number]:hover, input[type=url]:hover, select:hover, textarea:hover {
    border-color: color-mix(in srgb, var(--primary) 40%, var(--border));
}
input[type=text]:focus, input[type=password]:focus, input[type=email]:focus, input[type=number]:focus, input[type=url]:focus, select:focus, textarea:focus {
    outline: none; border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}
button, .btn {
    padding: 0.55rem 1.1rem; background: var(--primary); color: #fff; border: none; border-radius: 8px;
    cursor: pointer; font-size: 0.85rem; font-weight: 700; text-decoration: none; display: inline-block;
    box-shadow: 0 1px 2px rgba(15,23,42,0.08), 0 0 0 1px color-mix(in srgb, var(--primary) 40%, transparent);
    transition: filter 0.15s ease, transform 0.1s ease;
}
button:hover, .btn:hover { filter: brightness(1.08); }
button:active, .btn:active { transform: translateY(1px); }
button:focus-visible, .btn:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
    outline: 2px solid var(--primary); outline-offset: 2px;
}
button.danger { background: var(--danger); }
button.small { padding: 0.35rem 0.7rem; font-size: 0.78rem; }
button.secondary { background: var(--bg); color: var(--text); border: 1px solid var(--border); }

/* --- Tables --- */
table { width: 100%; border-collapse: collapse; }
th { text-align: start; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.03em; color: var(--text-muted); padding: 0.6rem; border-bottom: 1px solid var(--border); }
td { padding: 0.7rem 0.6rem; border-bottom: 1px solid var(--border); font-size: 0.85rem; }
tbody tr { transition: background 0.12s ease; }
tbody tr:hover { background: var(--bg); }
tbody tr:last-child td { border-bottom: none; }

.badge { padding: 0.2rem 0.55rem; border-radius: 6px; font-size: 0.72rem; font-weight: 700; display: inline-flex; align-items: center; gap: 0.35rem; }
.badge.on::before, .badge.success::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--success); flex-shrink: 0; }
.badge.on, .badge.success { background: var(--success-bg); color: var(--success); }
.badge.off, .badge.error { background: var(--danger-bg); color: var(--danger); }
.badge.role { background: var(--primary-light); color: var(--primary); }
.badge.neutral { background: var(--bg); color: var(--text-muted); }

/* --- Gauges --- */
.gauge-row { display: flex; gap: 1.6rem; flex-wrap: wrap; }
.gauge { text-align: center; }
.gauge svg { transform: rotate(-90deg); }
.gauge-value { font-size: 1.2rem; font-weight: 700; }
.gauge-label { font-size: 0.78rem; color: var(--text-muted); margin-top: 0.4rem; }

/* --- Bars --- */
.bar-row { margin-bottom: 0.9rem; }
.bar-row .bar-top { display: flex; justify-content: space-between; font-size: 0.82rem; margin-bottom: 0.35rem; }
.bar-bg { background: var(--bg); border-radius: 6px; height: 8px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 6px; background: var(--primary); }

/* --- Shortcuts grid --- */
.shortcut-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 0.8rem; }
.shortcut { display: flex; flex-direction: column; align-items: center; gap: 0.5rem; padding: 1rem 0.5rem; border-radius: 10px; border: 1px solid var(--border); text-decoration: none; color: var(--text); font-size: 0.78rem; text-align: center; }
.shortcut:hover { background: var(--bg); }
.shortcut .icon-box { width: 40px; height: 40px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 1.1rem; color: #fff; }
.shortcut .icon-box .icon-svg, .stat-icon .icon-svg { width: 20px; height: 20px; }

pre { white-space: pre-wrap; word-break: break-word; font-family: 'Cascadia Code', Consolas, monospace; font-size: 0.8rem; background: var(--bg); padding: 0.8rem; border-radius: 8px; }
code { font-family: 'Cascadia Code', Consolas, monospace; }

/* --- Footer --- */
.app-footer { text-align: center; color: var(--text-muted); font-size: 0.78rem; padding: 1.2rem 0; }

.mobile-menu-btn { display: none; }
.sidebar-backdrop {
    display: none;
    position: fixed; inset: 0; background: rgba(0,0,0,0.45); z-index: 39;
}
.sidebar-close-btn { display: none; }

@media (max-width: 900px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        z-index: 40;
        box-shadow: 0 0 40px rgba(0,0,0,0.3);
    }
    [dir="rtl"] .sidebar { transform: translateX(100%); }
    .sidebar.open { transform: translateX(0); }
    .sidebar-backdrop.open { display: block; }
    .main-wrap { margin-inline-start: 0; }
    .mobile-menu-btn { display: flex; }
    .sidebar-close-btn {
        display: flex; align-items: center; justify-content: center;
        width: 32px; height: 32px; border-radius: 8px; border: none;
        background: rgba(255,255,255,0.08); color: #fff; cursor: pointer;
        margin-inline-start: auto;
    }
    .sidebar-logo { justify-content: space-between; }
    .topbar-search { display: none; }

    .card { padding: 1rem; }

    table {
        display: block;
        max-width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    table thead, table tbody { display: table; width: max-content; min-width: 100%; }
    table tr { display: table-row; }
    th, td { white-space: nowrap; padding: 0.55rem 0.5rem; font-size: 0.78rem; }
}


/* --- Tema secici --- */
.theme-swatch {
    width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--card-bg);
    box-shadow: 0 0 0 1px var(--border); cursor: pointer; padding: 0; flex-shrink: 0;
}
.theme-swatch.active { box-shadow: 0 0 0 2px var(--primary); }
.theme-swatch-row { display: flex; gap: 0.6rem; padding: 0.9rem; }
.theme-mode-row { display: flex; align-items: center; justify-content: space-between; padding: 0 0.9rem 0.9rem; border-top: 1px solid var(--border); margin-top: 0.2rem; padding-top: 0.8rem; font-size: 0.85rem; }
.theme-mode-toggle { display: flex; align-items: center; gap: 0.4rem; border: 1px solid var(--border); background: var(--bg); border-radius: 8px; padding: 0.4rem 0.7rem; cursor: pointer; color: var(--text); font-size: 0.8rem; }
.theme-mode-toggle .icon-svg { width: 15px; height: 15px; }


/* --- Kaynak kullanim grafigi (harici kutuphanesiz) --- */
.usage-chart { width: 100%; }
.usage-svg { width: 100%; height: 220px; display: block; }
.usage-grid-line { stroke: var(--border); stroke-width: 1; }
.usage-chart-meta { display: flex; justify-content: space-between; margin-top: 0.6rem; font-size: 0.78rem; color: var(--text-muted); }


/* --- Bos durum hucreleri (colspan ile isaretli satirlar) --- */
td[colspan] {
    text-align: center;
    color: var(--text-muted);
    padding: 2.4rem 1rem;
    font-size: 0.85rem;
}
tbody tr:has(td[colspan]):hover { background: transparent; }


/* --- Ozel scrollbar --- */
.sidebar, .content, pre, textarea {
    scrollbar-width: thin;
    scrollbar-color: color-mix(in srgb, var(--sidebar-text) 35%, transparent) transparent;
}
.sidebar::-webkit-scrollbar, .content::-webkit-scrollbar, pre::-webkit-scrollbar, textarea::-webkit-scrollbar { width: 8px; height: 8px; }
.sidebar::-webkit-scrollbar-track, .content::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 8px; }
.sidebar::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.25); }
.content::-webkit-scrollbar-thumb, pre::-webkit-scrollbar-thumb, textarea::-webkit-scrollbar-thumb {
    background: color-mix(in srgb, var(--text-muted) 40%, transparent); border-radius: 8px;
}
.content::-webkit-scrollbar-thumb:hover, pre::-webkit-scrollbar-thumb:hover, textarea::-webkit-scrollbar-thumb:hover {
    background: color-mix(in srgb, var(--text-muted) 60%, transparent);
}
