: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-light: #eff6ff;
    --success: #16a34a;
    --success-bg: #dcfce7;
    --danger: #dc2626;
    --danger-bg: #fee2e2;
    --warning: #d97706;
    --warning-bg: #fef3c7;
    --radius: 12px;
    --sidebar-w: 260px;
    --topbar-h: 64px;
}

* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
}
a { color: inherit; }

.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;
}
.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), #60a5fa);
    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:hover { background: rgba(255,255,255,0.05); color: #fff; }
.sidebar-item.active {
    background: rgba(37,99,235,0.15);
    color: var(--sidebar-text-active);
    border-inline-start-color: var(--primary);
    font-weight: 600;
}
.sidebar-item .icon { width: 18px; text-align: center; flex-shrink: 0; }

/* --- 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;
}
.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 {
    display: none; position: absolute; top: 110%; inset-inline-end: 0; background: var(--card-bg);
    border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,0.12);
    min-width: 170px; z-index: 30; overflow: hidden;
}
.lang-switcher:hover .lang-menu, .lang-switcher:focus-within .lang-menu { display: block; }
.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: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; }
.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;
}
.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;
}
.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;
}
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: 600; text-decoration: none; display: inline-block;
}
button:hover, .btn:hover { filter: brightness(1.08); }
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; }

.badge { padding: 0.2rem 0.55rem; border-radius: 6px; font-size: 0.72rem; font-weight: 600; }
.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; }

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; }

@media (max-width: 900px) {
    .sidebar { display: none; }
    .main-wrap { margin-inline-start: 0; }
}
