:root {
    --sidebar-w: 250px;
    --sidebar-bg: #0f172a;
    --sidebar-text: #94a3b8;
    --sidebar-hover: #1e293b;
    --topbar-h: 60px;
    --page-bg: #f1f5f9;
}

* { scrollbar-width: thin; scrollbar-color: #cbd5e1 transparent; }

body {
    background: var(--page-bg);
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    min-height: 100vh;
}

/* ===== Sidebar ===== */
.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--sidebar-w);
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    z-index: 1030;
    display: flex;
    flex-direction: column;
    transition: transform .25s ease;
}
.sidebar .brand {
    display: flex;
    align-items: center;
    gap: .65rem;
    padding: 1.1rem 1.25rem;
    color: #fff;
    font-weight: 700;
    font-size: 1.05rem;
    letter-spacing: .3px;
    border-bottom: 1px solid rgba(148, 163, 184, .15);
}
.sidebar .brand .logo {
    width: 34px; height: 34px;
    border-radius: .6rem;
    background: linear-gradient(135deg, #6366f1, #3b82f6);
    display: grid; place-items: center;
    font-size: 1.1rem;
}
.sidebar .brand img.mark { width: 34px; height: 34px; flex: none; }
.sidebar .brand a, .brand { text-decoration: none; }
.sidebar .brand small { display: block; font-size: .65rem; font-weight: 500; color: var(--sidebar-text); }
.sidebar .nav-section {
    padding: 1rem 1.25rem .35rem;
    font-size: .68rem;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: #64748b;
}
.sidebar .nav-link {
    display: flex;
    align-items: center;
    gap: .75rem;
    color: var(--sidebar-text);
    padding: .58rem 1.1rem;
    margin: 1px 10px;
    border-radius: .55rem;
    font-size: .9rem;
    font-weight: 500;
    transition: background .15s, color .15s;
}
.sidebar .nav-link i { font-size: 1.05rem; width: 20px; text-align: center; }
.sidebar .nav-link:hover { background: var(--sidebar-hover); color: #e2e8f0; }
.sidebar .nav-link.active {
    background: linear-gradient(90deg, rgba(99,102,241,.25), rgba(99,102,241,.08));
    color: #a5b4fc;
    box-shadow: inset 3px 0 0 #6366f1;
}
.sidebar .footer-note {
    margin-top: auto;
    padding: 1rem 1.25rem;
    font-size: .72rem;
    border-top: 1px solid rgba(148, 163, 184, .15);
    color: #64748b;
}

/* ===== Topbar ===== */
.main { margin-left: var(--sidebar-w); min-height: 100vh; }
.topbar {
    height: var(--topbar-h);
    background: #fff;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    position: sticky;
    top: 0;
    z-index: 1020;
}
.topbar .page-title { font-size: 1.02rem; font-weight: 600; color: #0f172a; margin: 0; }
.topbar .menu-toggle { display: none; }
.topbar .user-chip {
    display: flex; align-items: center; gap: .7rem;
}
.topbar .avatar {
    width: 34px; height: 34px; border-radius: 50%;
    background: linear-gradient(135deg, #6366f1, #3b82f6);
    color: #fff; display: grid; place-items: center;
    font-weight: 700; font-size: .85rem;
}
.topbar .user-meta { line-height: 1.15; }
.topbar .user-meta b { font-size: .85rem; color: #0f172a; display: block; }
.topbar .user-meta span { font-size: .72rem; color: #64748b; }

.content { padding: 1.5rem; max-width: 1240px; }

/* ===== Cards ===== */
.card { border: 0; box-shadow: 0 1px 3px rgba(15, 23, 42, .07), 0 4px 14px rgba(15, 23, 42, .04); }
.card .card-header { background: transparent; border-bottom: 1px solid #f1f5f9; font-weight: 600; }
.stat-card { border-radius: 1rem; }
.stat-card .stat-icon {
    width: 46px; height: 46px; border-radius: .8rem;
    display: grid; place-items: center; font-size: 1.3rem; color: #fff;
}
.stat-card .stat-label { font-size: .74rem; text-transform: uppercase; letter-spacing: .8px; color: #64748b; font-weight: 600; }
.stat-card .stat-value { font-size: 1.45rem; font-weight: 700; color: #0f172a; line-height: 1.2; }
.stat-card .stat-sub { font-size: .76rem; color: #94a3b8; }

.bg-grad-primary { background: linear-gradient(135deg, #6366f1, #3b82f6); }
.bg-grad-success { background: linear-gradient(135deg, #10b981, #059669); }
.bg-grad-warning { background: linear-gradient(135deg, #f59e0b, #d97706); }
.bg-grad-danger { background: linear-gradient(135deg, #ef4444, #dc2626); }
.bg-grad-info { background: linear-gradient(135deg, #06b6d4, #0891b2); }
.bg-grad-dark { background: linear-gradient(135deg, #334155, #0f172a); }

/* ===== Badges & tables ===== */
.badge-soft-success { background: #dcfce7; color: #166534; }
.badge-soft-danger { background: #fee2e2; color: #991b1b; }
.badge-soft-warning { background: #fef3c7; color: #92400e; }
.badge-soft-info { background: #e0f2fe; color: #075985; }
.badge-soft-secondary { background: #e2e8f0; color: #475569; }

.table thead th {
    font-size: .7rem;
    text-transform: uppercase;
    letter-spacing: .8px;
    color: #64748b;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    font-weight: 600;
    padding: .65rem .9rem;
}
.table td { padding: .7rem .9rem; vertical-align: middle; border-color: #f1f5f9; }
.table-hover tbody tr:hover { background: #f8fafc; }

/* ===== Content pieces ===== */
.section-title { font-size: .95rem; font-weight: 700; color: #0f172a; margin-bottom: 1rem; display: flex; align-items: center; gap: .5rem; }
.status-orb { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.status-orb.on { background: #22c55e; box-shadow: 0 0 0 4px rgba(34,197,94,.18); }
.status-orb.off { background: #ef4444; box-shadow: 0 0 0 4px rgba(239,68,68,.18); }
.kv { display: flex; justify-content: space-between; padding: .5rem 0; border-bottom: 1px dashed #e2e8f0; font-size: .87rem; }
.kv:last-child { border-bottom: 0; }
.kv .k { color: #64748b; }
.kv .v { font-weight: 600; color: #0f172a; }

.btn-brand { background: linear-gradient(135deg, #6366f1, #3b82f6); border: 0; color: #fff; }
.btn-brand:hover { filter: brightness(1.08); color: #fff; }

/* ===== Auth pages ===== */
.auth-wrap { min-height: 100vh; display: flex; }
.auth-hero {
    flex: 1.1;
    background:
        radial-gradient(1000px 500px at -10% -10%, rgba(99,102,241,.35), transparent),
        radial-gradient(800px 500px at 110% 110%, rgba(59,130,246,.28), transparent),
        #0f172a;
    color: #cbd5e1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 4rem;
}
.auth-hero h1 { color: #fff; font-weight: 800; letter-spacing: -.5px; }
.auth-hero .feat { display: flex; gap: .8rem; align-items: flex-start; margin-top: 1.25rem; font-size: .92rem; }
.auth-hero .feat i {
    width: 34px; height: 34px; border-radius: .55rem; flex: none;
    background: rgba(99,102,241,.2); color: #a5b4fc;
    display: grid; place-items: center;
}
.auth-form-side { flex: 1; display: flex; align-items: center; justify-content: center; padding: 2rem; background: #fff; }

/* ===== Responsive ===== */
@media (max-width: 991.98px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.show { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.35); }
    .main { margin-left: 0; }
    .topbar .menu-toggle { display: inline-flex; }
    .content { padding: 1rem; }
    .auth-hero { display: none; }
}
.sidebar-backdrop {
    display: none; position: fixed; inset: 0;
    background: rgba(15,23,42,.45); z-index: 1025;
}
.sidebar-backdrop.show { display: block; }

/* ===== Dashboard admin ===== */
.dash-overview, .log-feed-card, .meter-card, .trx-card { border-radius: 1rem; }
.card .card-header { font-size: .92rem; }

.dash-live {
    display: inline-flex; align-items: center; gap: .4rem;
    font-size: .68rem; font-weight: 700; letter-spacing: .8px;
    color: #166534; background: #dcfce7;
    padding: .25rem .6rem; border-radius: 999px;
}
.dash-live-dot {
    width: 7px; height: 7px; border-radius: 50%;
    background: #22c55e; animation: livePulse 1.4s ease-in-out infinite;
}
@keyframes livePulse { 0%, 100% { opacity: 1; } 50% { opacity: .3; } }

.dash-bento { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.dash-bento-cell {
    position: relative; display: block; text-decoration: none; color: inherit;
    background: #f8fafc; border: 1px solid #e2e8f0; border-radius: .9rem;
    padding: 1rem 1.05rem; min-height: 118px; overflow: hidden;
    transition: transform .15s, box-shadow .15s, border-color .15s;
}
.dash-bento-cell:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(15, 23, 42, .08);
    border-color: #cbd5e1;
    color: inherit;
}
.dash-bento-tag {
    display: block; max-width: calc(100% - 44px);
    font-size: .63rem; font-weight: 700; letter-spacing: .8px;
    text-transform: uppercase; color: #94a3b8;
}
.dash-bento-icon {
    position: absolute; top: .85rem; right: .9rem;
    width: 34px; height: 34px; border-radius: 50%;
    display: grid; place-items: center; font-size: .95rem;
}
.dash-bento-value { font-size: 1.4rem; font-weight: 800; line-height: 1.15; margin-top: 1.1rem; color: #0f172a; }
.dash-bento-value.money { font-size: 1.05rem; }
.dash-bento-label { font-size: .72rem; color: #94a3b8; margin-top: .2rem; }

.dash-bento-info .dash-bento-icon { background: #e0f2fe; color: #0284c7; }
.dash-bento-info .dash-bento-value { color: #0284c7; }
.dash-bento-success .dash-bento-icon { background: #dcfce7; color: #16a34a; }
.dash-bento-success .dash-bento-value { color: #16a34a; }
.dash-bento-warning .dash-bento-icon { background: #fef3c7; color: #d97706; }
.dash-bento-warning .dash-bento-value { color: #d97706; }
.dash-bento-muted .dash-bento-icon { background: #fee2e2; color: #dc2626; }
.dash-bento-muted .dash-bento-value { color: #dc2626; }

.log-feed { max-height: 348px; overflow-y: auto; }
.log-feed-item {
    display: flex; gap: .85rem; padding: .7rem .25rem;
    border-bottom: 1px dashed #e2e8f0;
}
.log-feed-item:last-child { border-bottom: 0; }
.log-feed-icon {
    width: 36px; height: 36px; border-radius: 50%; flex: none;
    display: grid; place-items: center; color: #fff; font-size: .9rem;
}
.log-feed-body { flex: 1; min-width: 0; }
.log-feed-head {
    display: flex; justify-content: space-between; gap: .5rem;
    font-size: .87rem; color: #0f172a;
}
.log-feed-head small { color: #94a3b8; font-weight: 500; white-space: nowrap; }
.log-feed-msg { font-size: .76rem; color: #64748b; }
.log-feed-ip {
    background: #f1f5f9; border-radius: .35rem;
    padding: .05rem .35rem; margin-left: .35rem;
    font-family: Consolas, monospace; font-size: .72rem; color: #475569;
}

.meter-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .9rem; }
.meter-item { display: flex; gap: .8rem; align-items: center; }
.meter-icon {
    width: 38px; height: 38px; border-radius: .65rem; flex: none;
    display: grid; place-items: center; font-size: 1rem;
}
.meter-icon.soft-success { background: #dcfce7; color: #166534; }
.meter-icon.soft-info { background: #e0f2fe; color: #075985; }
.meter-icon.soft-primary { background: #e0e7ff; color: #3730a3; }
.meter-icon.soft-danger { background: #fee2e2; color: #991b1b; }
.meter-info { flex: 1; min-width: 0; }
.meter-head { display: flex; justify-content: space-between; font-size: .8rem; color: #334155; }
.meter-head b { color: #0f172a; }
.meter-bar { height: 6px; background: #e2e8f0; border-radius: 999px; margin-top: .3rem; }
.meter-sub { font-size: .7rem; color: #94a3b8; margin-top: .25rem; }
.meter-meta {
    background: #f8fafc; border: 1px solid #e2e8f0;
    border-radius: .7rem; padding: .35rem .8rem; margin-top: 1rem;
}

.trx-block { padding: .9rem .4rem; }
.trx-value { font-size: 1.7rem; font-weight: 800; margin: 0; }
.trx-note { font-size: .78rem; color: #94a3b8; }

@media (max-width: 991.98px) {
    .dash-bento { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 575.98px) {
    .dash-bento { grid-template-columns: 1fr; }
    .trx-value { font-size: 1.4rem; }
}
