:root {
    --sidebar: #101b2d;
    --sidebar-hover: #1d2b44;
    --sidebar-active: #263754;
    --primary: #2563eb;
    --primary-soft: #eff6ff;
    --text: #14213d;
    --muted: #6b7890;
    --border: #e7ebf2;
    --bg: #f6f8fc;
    --white: #ffffff;
    --success: #0a9f6e;
    --danger: #e5484d;
    --warning: #d99000;
    --shadow: 0 2px 12px rgba(20, 33, 61, .05);
    --radius: 12px;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
    min-height: 100%;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family:
        Inter,
        ui-sans-serif,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        Roboto,
        Arial,
        sans-serif;
    font-size: 14px;
    line-height: 1.5;
}

a {
    color: inherit;
    text-decoration: none;
}

button,
input,
select {
    font: inherit;
}

/* Layout */

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

.admin-sidebar {
    width: 240px;
    min-width: 240px;
    min-height: 100vh;
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 50;
    display: flex;
    flex-direction: column;
    background: var(--sidebar);
    color: #dce5f3;
    padding: 20px 14px;
}

.admin-main {
    width: calc(100% - 240px);
    min-height: 100vh;
    margin-left: 240px;
}

/* Branding */

.brand {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 4px 10px 28px;
}

.brand-mark {
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    border-radius: 10px;
    background: linear-gradient(135deg, #f4b63f, #ffd978);
    color: #172033;
    font-size: 19px;
    font-weight: 800;
}

.brand-name {
    color: #fff;
    font-size: 20px;
    font-weight: 750;
    letter-spacing: -.4px;
}

.brand-subtitle {
    margin-top: -3px;
    color: #91a0b8;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 1.8px;
    text-transform: uppercase;
}

/* Sidebar navigation */

.sidebar-section {
    margin: 8px 10px 8px;
    color: #6f809a;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.sidebar-link {
    min-height: 43px;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 12px;
    border-radius: 9px;
    color: #aebbd0;
    font-size: 14px;
    font-weight: 500;
    transition: .15s ease;
}

.sidebar-link:hover {
    background: var(--sidebar-hover);
    color: #fff;
}

.sidebar-link.active {
    background: var(--sidebar-active);
    color: #fff;
    box-shadow: inset 3px 0 0 #3b82f6;
}

.sidebar-icon {
    width: 20px;
    text-align: center;
    font-size: 17px;
}

.sidebar-bottom {
    margin-top: auto;
}

/* Upgrade / support card */

.sidebar-promo {
    margin: 18px 2px 4px;
    padding: 18px 15px;
    border: 1px solid rgba(148, 163, 184, .25);
    border-radius: 11px;
    background: rgba(255, 255, 255, .025);
}

.sidebar-promo-title {
    margin-bottom: 7px;
    color: #fff;
    font-size: 14px;
    font-weight: 700;
}

.sidebar-promo-text {
    margin-bottom: 14px;
    color: #9ba9bd;
    font-size: 12px;
    line-height: 1.55;
}

.sidebar-promo-button {
    width: 100%;
    padding: 9px 10px;
    border: 1px solid #3b82f6;
    border-radius: 7px;
    color: #fff;
    background: #2563eb;
    font-size: 12px;
    font-weight: 650;
    text-align: center;
}

/* Topbar */

.topbar {
    height: 72px;
    display: flex;
    align-items: center;
    gap: 18px;
    padding: 0 26px;
    background: #fff;
    border-bottom: 1px solid var(--border);
}

.menu-button {
    display: none;
    border: 0;
    background: transparent;
    color: var(--text);
    font-size: 22px;
    cursor: pointer;
}

.search-box {
    width: min(540px, 48vw);
    height: 42px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 14px;
    border: 1px solid #e1e6ef;
    border-radius: 9px;
    background: #f7f9fc;
    color: #8a96aa;
}

.search-box input {
    width: 100%;
    border: 0;
    outline: 0;
    background: transparent;
    color: var(--text);
}

.search-box input::placeholder {
    color: #8d99ad;
}

.topbar-spacer {
    flex: 1;
}

.date-selector {
    height: 42px;
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 0 13px;
    border: 1px solid #e1e6ef;
    border-radius: 9px;
    background: #fff;
    color: #34435d;
    font-size: 13px;
    font-weight: 600;
}

.icon-button {
    width: 40px;
    height: 40px;
    display: grid;
    place-items: center;
    position: relative;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: #596981;
    font-size: 18px;
}

.notification-dot {
    width: 7px;
    height: 7px;
    position: absolute;
    top: 8px;
    right: 8px;
    border: 2px solid #fff;
    border-radius: 50%;
    background: #ef4444;
}

.admin-profile {
    display: flex;
    align-items: center;
    gap: 10px;
    padding-left: 5px;
}

.admin-avatar {
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: #334765;
    color: #fff;
    font-size: 12px;
    font-weight: 700;
}

.admin-info {
    line-height: 1.25;
}

.admin-name {
    color: var(--text);
    font-size: 13px;
    font-weight: 700;
}

.admin-email {
    color: var(--muted);
    font-size: 11px;
}

/* Content */

.page-content {
    padding: 28px;
}

.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 24px;
}

.page-title {
    margin: 0;
    font-size: 27px;
    line-height: 1.2;
    letter-spacing: -.6px;
}

.page-subtitle {
    margin: 6px 0 0;
    color: var(--muted);
    font-size: 13px;
}

.page-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* KPI cards */

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}

.kpi-card {
    min-width: 0;
    padding: 17px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: #fff;
    box-shadow: var(--shadow);
}

.kpi-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.kpi-icon {
    width: 40px;
    height: 40px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    font-size: 17px;
}

.kpi-icon.blue {
    background: #eaf3ff;
    color: #2563eb;
}

.kpi-icon.green {
    background: #e5f8f0;
    color: #079669;
}

.kpi-icon.purple {
    background: #f1edff;
    color: #7048e8;
}

.kpi-icon.gold {
    background: #fff6df;
    color: #bd7900;
}

.kpi-icon.red {
    background: #fff0f1;
    color: #df3d58;
}

.kpi-icon.teal {
    background: #e5f8f6;
    color: #0a9c91;
}

.kpi-label {
    margin-top: 11px;
    color: #62708a;
    font-size: 12px;
}

.kpi-value {
    margin-top: 2px;
    color: #101c35;
    font-size: 22px;
    font-weight: 750;
    letter-spacing: -.4px;
}

.kpi-change {
    margin-top: 7px;
    color: var(--success);
    font-size: 11px;
    font-weight: 650;
}

/* Cards */

.card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: #fff;
    box-shadow: var(--shadow);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
    padding: 18px 18px 0;
}

.card-title {
    margin: 0;
    color: #15213a;
    font-size: 15px;
    font-weight: 750;
}

.card-action {
    color: #2563eb;
    font-size: 12px;
    font-weight: 650;
}

/* Analytics */

.analytics-grid {
    display: grid;
    grid-template-columns: minmax(0, 2.2fr) minmax(300px, .8fr);
    gap: 16px;
    margin-bottom: 16px;
}

.performance-card {
    min-height: 210px;
}

.chart-tabs {
    display: flex;
    gap: 24px;
    padding: 14px 18px 0;
    border-bottom: 1px solid #edf0f5;
}

.chart-tab {
    padding-bottom: 11px;
    border-bottom: 2px solid transparent;
    color: #71809a;
    font-size: 12px;
    cursor: pointer;
}

.chart-tab.active {
    border-bottom-color: #2563eb;
    color: #2563eb;
    font-weight: 700;
}

.chart-area {
    min-height: 120px;
    padding: 22px 18px 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #9aa6b8;
}

.chart-placeholder {
    width: 100%;
    height: 120px;
    border-radius: 8px;
    background:
        linear-gradient(to bottom, transparent 24%, #eef2f7 25%, transparent 26%),
        linear-gradient(to bottom, transparent 49%, #eef2f7 50%, transparent 51%),
        linear-gradient(to bottom, transparent 74%, #eef2f7 75%, transparent 76%),
        linear-gradient(to right, transparent 24%, #f1f4f8 25%, transparent 26%),
        linear-gradient(to right, transparent 49%, #f1f4f8 50%, transparent 51%),
        linear-gradient(to right, transparent 74%, #f1f4f8 75%, transparent 76%);
}

/* Side analytics */

.analytics-side {
    display: grid;
    grid-template-rows: 1fr 1fr;
    gap: 16px;
}

.side-card {
    min-height: 182px;
}

.side-content {
    padding: 18px;
}

.big-stat {
    margin-top: 5px;
    color: #111d36;
    font-size: 27px;
    font-weight: 750;
}

.stat-up {
    margin-top: 3px;
    color: var(--success);
    font-size: 11px;
    font-weight: 650;
}

.device-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-top: 15px;
}

.device-item {
    padding: 10px;
    border-radius: 8px;
    background: #f7f9fc;
    text-align: center;
}

.device-label {
    color: #71809a;
    font-size: 10px;
}

.device-value {
    margin-top: 2px;
    color: #18233b;
    font-size: 13px;
    font-weight: 700;
}

/* Tables */

.table-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
}

.table-card {
    overflow: hidden;
}

.table-scroll {
    overflow-x: auto;
    padding: 12px 0 0;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
}

.admin-table th,
.admin-table td {
    padding: 11px 18px;
    border-bottom: 1px solid #eef1f5;
    text-align: left;
    white-space: nowrap;
    font-size: 12px;
}

.admin-table th {
    color: #7a879b;
    background: #fbfcfe;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
}

.admin-table td {
    color: #27344d;
}

.admin-table tr:last-child td {
    border-bottom: 0;
}

.table-name {
    color: #17223a;
    font-weight: 650;
}

.table-muted {
    color: #7b8799;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 10px;
    font-weight: 700;
}

.status-approved,
.status-active {
    background: #e7f8ef;
    color: #087b53;
}

.status-pending {
    background: #fff5dd;
    color: #a66a00;
}

.status-rejected,
.status-failed {
    background: #ffedef;
    color: #c62e42;
}

.status-paused {
    background: #eef1f5;
    color: #637087;
}

/* Buttons */

.btn {
    min-height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 0 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
    color: #34425b;
    font-size: 12px;
    font-weight: 650;
    cursor: pointer;
}

.btn-primary {
    border-color: #2563eb;
    background: #2563eb;
    color: #fff;
}

.btn-primary:hover {
    background: #1d4ed8;
}

/* Responsive */

@media (max-width: 1250px) {
    .kpi-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .table-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 1000px) {
    .analytics-grid {
        grid-template-columns: 1fr;
    }

    .analytics-side {
        grid-template-columns: repeat(2, 1fr);
        grid-template-rows: auto;
    }
}

@media (max-width: 800px) {
    .admin-sidebar {
        transform: translateX(-100%);
        transition: transform .2s ease;
    }

    .admin-sidebar.open {
        transform: translateX(0);
    }

    .admin-main {
        width: 100%;
        margin-left: 0;
    }

    .menu-button {
        display: block;
    }

    .search-box {
        width: 100%;
    }

    .admin-info {
        display: none;
    }

    .date-selector {
        display: none;
    }

    .page-content {
        padding: 20px;
    }

    .kpi-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 520px) {
    .topbar {
        padding: 0 15px;
        gap: 8px;
    }

    .search-box {
        min-width: 0;
    }

    .kpi-grid {
        grid-template-columns: 1fr;
    }

    .analytics-side {
        grid-template-columns: 1fr;
    }

    .page-header {
        display: block;
    }

    .page-actions {
        margin-top: 15px;
    }
}
