:root {
    --bg-100: #090d14;
    --bg-200: #111827;
    --bg-300: #1f2937;
    --bg-400: #263244;

    --card: rgba(17,24,39,.92);
    --card-solid: #111827;

    --border: rgba(255,255,255,.08);

    --white: #ffffff;
    --white-100: #ffffff;
    --white-90: rgba(255,255,255,.9);
    --white-70: rgba(255,255,255,.7);
    --white-60: rgba(255,255,255,.6);
    --white-50: rgba(255,255,255,.5);

    --primary: #38bdf8;
    --success: #22c55e;
    --danger: #ef4444;
    --warning: #f59e0b;

    --blue: #38bdf8;
    --green: #34d399;
    --red: #fb7185;
    --orange: #fbbf24;
    --purple: #a78bfa;
    --cyan: #22d3ee;
    --indigo: #818cf8;
    --yellow: #fde047;
    --pink: #f472b6;

    --radius: 18px;
    --shadow: 0 18px 50px rgba(0,0,0,.18);
}

html[data-theme="light"],
[data-theme="light"] {
    --bg-100: #f4f7fb;
    --bg-200: #ffffff;
    --bg-300: #e5e7eb;
    --bg-400: #d1d5db;

    --card: rgba(255,255,255,.92);
    --card-solid: #ffffff;

    --border: rgba(15,23,42,.1);

    --white: #0f172a;
    --white-100: #0f172a;
    --white-90: rgba(15,23,42,.92);
    --white-70: rgba(15,23,42,.7);
    --white-60: rgba(15,23,42,.6);
    --white-50: rgba(15,23,42,.5);

    --shadow: 0 18px 50px rgba(15,23,42,.08);
}

@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap");

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background:
        radial-gradient(circle at top left, rgba(56,189,248,.14), transparent 32rem),
        radial-gradient(circle at bottom right, rgba(167,139,250,.12), transparent 30rem),
        var(--bg-100);
    color: var(--white-90);
    font-family: "Inter", Arial, Helvetica, sans-serif;
    font-size: 14px;
}

button,
input,
select,
textarea {
    font-family: inherit;
}

a {
    color: inherit;
    text-decoration: none;
}

.content-shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.topbar {
    height: 60px;
    padding: 0 20px;
    border-bottom: 1px solid var(--border);
    background: transparent;
    backdrop-filter: blur(16px);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    position: sticky;
    top: 0;
    z-index: 30;
}

html[data-theme="light"] .topbar,
[data-theme="light"] .topbar {
    background: rgba(255,255,255,.76);
}

.topbar-actions,
.actions,
.form-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.header-brand,
.brand-inline {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-mark {
    width: 38px;
    height: 38px;
    border-radius: 14px;
    display: grid;
    place-items: center;
    color: var(--blue);
    background: rgba(56,189,248,.12);
    border: 1px solid rgba(56,189,248,.25);
}

.brand-inline strong {
    display: block;
    color: var(--white-90);
    letter-spacing: .08em;
    font-size: 14px;
}

.brand-inline span {
    display: block;
    margin-top: 3px;
    color: var(--white-50);
    font-size: 12px;
}

.header-logo {
    height: 48px;
    width: auto;
    object-fit: contain;
}

.icon-btn {
    width: 30px;
    height: 30px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: rgba(255,255,255,.06);
    color: var(--white-90);
    cursor: pointer;
    display: grid;
    place-items: center;
}

.theme-btn,
.btn,
.btn-soft,
.btn-primary {
    min-height: 30px;
    padding: 0 15px;
    border-radius: 12px;
    border: 1px solid var(--border);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: var(--white-90);
    background: rgba(255,255,255,.06);
    cursor: pointer;
    text-decoration: none;
    font-size: 13px;
    font-weight: 700;
    transition: .18s ease;
}

.btn:hover,
.btn-soft:hover,
.btn-primary:hover,
.theme-btn:hover,
.icon-btn:hover {
    transform: translateY(-1px);
    background: rgba(255,255,255,.1);
}

.btn-soft {
    color: var(--blue);
    background: rgba(56,189,248,.12);
    border-color: rgba(56,189,248,.24);
}

.btn-soft.danger,
.btn.danger {
    color: var(--red);
    background: rgba(251,113,133,.12);
    border-color: rgba(251,113,133,.22);
}

.btn-primary {
    color: #020617;
    background: var(--blue);
    border-color: var(--blue);
    box-shadow: none;
}

.user-badge {
    min-height: 30px;
    padding: 0 14px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255,255,255,.05);
    border: 1px solid var(--border);
    color: var(--white-70);
    font-size: 13px;
    font-weight: 700;
}

.main-wrap {
    flex: 1;
    width: min(1280px, calc(100% - 32px));
    margin: 0 auto;
    padding: 30px 0;
}

.footer {
    width: min(1280px, calc(100% - 32px));
    margin: 30px auto 18px;
    padding-top: 18px;
    border-top: 1px solid var(--border);
    color: var(--white-50);
    display: flex;
    justify-content: space-between;
    gap: 14px;
    font-size: 13px;
}

.footer a {
    color: var(--blue);
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.hero-card {
    padding: 24px;
    border-radius: 18px;
    background: var(--card);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 22px;
    margin-bottom: 22px;
}

.hero-icon,
.hero-logo-wrap {
    width: 76px;
    height: 76px;
    border-radius: 26px;
    display: grid;
    place-items: center;
    background: rgba(56,189,248,.12);
    border: 1px solid rgba(56,189,248,.24);
    font-size: 34px;
    flex-shrink: 0;
}

.hero-card h1 {
    margin: 0;
    font-size: 24px;
    color: var(--white-90);
}

.hero-card p {
    margin: 8px 0 0;
    color: var(--white-50);
}

.hero-badges {
    margin-top: 16px;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.status-pill,
.status {
    min-height: 30px;
    padding: 0 12px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    font-weight: 800;
}

.status-good,
.status.success {
    color: var(--green);
    background: rgba(52,211,153,.12);
    border: 1px solid rgba(52,211,153,.24);
}

.status-warn,
.status.warning {
    color: var(--orange);
    background: rgba(251,191,36,.12);
    border: 1px solid rgba(251,191,36,.24);
}

.status-danger,
.status.danger {
    color: var(--red);
    background: rgba(251,113,133,.12);
    border: 1px solid rgba(251,113,133,.24);
}

.grid,
.dashboard-grid,
.gateway-overview {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 18px;
    margin-bottom: 22px;
}

.grid.two,
.gateway-live-row {
    display: grid;
    grid-template-columns: 1.4fr .8fr .8fr;
    gap: 18px;
    margin-bottom: 22px;
}

.card,
.form-box,
.module-card,
.gateway-stat-card {
    padding: 22px;
    border-radius: 22px;
    background: var(--card);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    margin-bottom: 15px;
    position: relative;
    overflow: hidden;
}

.module-card {
    min-height: 60px;
    display: block;
}

.module-card:hover,
.card:hover,
.form-box:hover,
.gateway-stat-card:hover {
    border-color: rgba(56,189,248,.28);
}

.module-icon,
.gateway-stat-icon {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    display: grid;
    place-items: center;
    background: rgba(255,255,255,.06);
    border: 1px solid var(--border);
    font-size: 17px;
}

.module-card h3 {
    margin: 18px 0 6px;
    font-size: 18px;
    color: var(--white-90);
}

.module-card p,
.gateway-stat-text p,
.card-note {
    margin: 0;
    color: var(--white-50);
    font-size: 12px;
}

.module-meta,
.gateway-stat-text span,
.card-title {
    display: block;
    margin-top: 14px;
    margin-bottom: 8px;
    color: var(--white-70);
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
}

.gateway-stat-head {
    display: flex;
    justify-content: space-between;
    gap: 14px;
}

.gateway-stat-text strong,
.card-value {
    color: var(--white-90);
    font-size: 20px;
    font-weight: 800;
    word-break: break-word;
}

.card-value {
    display: block;
    font-size: 24px;
}

.dashboard-section-title {
    margin: 5px 0 16px;
}

.dashboard-section-title h2 {
    margin: 0;
    font-size: 20px;
    color: var(--white-90);
}

.dashboard-section-title span {
    color: var(--white-50);
    font-size: 13px;
}

.ring-wrap {
    width: 76px;
    height: 76px;
    flex: 0 0 auto;
}

.ring-wrap svg {
    width: 76px;
    height: 76px;
    transform: rotate(-90deg);
}

.ring-bg {
    fill: none;
    stroke: rgba(255,255,255,.1);
    stroke-width: 3.8;
}

.ring-progress {
    fill: none;
    stroke-width: 3.8;
    stroke-linecap: round;
}

.ring-good .ring-progress {
    stroke: var(--green);
}

.ring-warn .ring-progress {
    stroke: var(--orange);
}

.ring-danger .ring-progress {
    stroke: var(--red);
}

.ring-label {
    fill: var(--white-90);
    font-size: 8px;
    font-weight: 800;
    text-anchor: middle;
    dominant-baseline: middle;
    transform: rotate(90deg);
    transform-origin: 18px 18px;
}

label {
    display: block;
    margin-bottom: 8px;
    color: var(--white-70);
    font-size: 14px;
    font-weight: 700;
}

input,
select,
textarea,
.form-control {
    width: 100%;
    min-height: 34px;
    padding: 0 15px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: rgba(255,255,255,.055);
    color: var(--white-90);
    outline: none;
    font-size: 12px;
    margin-bottom: 14px;
}

textarea {
    min-height: 120px;
    padding: 14px 15px;
    resize: vertical;
}

input:focus,
select:focus,
textarea:focus,
.form-control:focus {
    border-color: rgba(56,189,248,.55);
    box-shadow: 0 0 0 3px rgba(56,189,248,.12);
}

select {
    appearance: none;
    background:
        linear-gradient(45deg, transparent 50%, var(--white-70) 50%),
        linear-gradient(135deg, var(--white-70) 50%, transparent 50%),
        rgba(255,255,255,.055);
    background-position:
        calc(100% - 20px) 50%,
        calc(100% - 14px) 50%,
        0 0;
    background-size: 6px 6px, 6px 6px, 100% 100%;
    background-repeat: no-repeat;
    padding-right: 44px;
}

select option {
    background: var(--card-solid);
    color: var(--white-90);
}

.table-wrap {
    overflow-x: auto;
    border-radius: 16px;
}

table,
.table {
    width: 100%;
    border-collapse: collapse;
}

table th,
.table th {
    text-align: left;
    padding: 14px;
    color: var(--white-70);
    border-bottom: 1px solid var(--border);
    font-size: 12px;
    text-transform: uppercase;
}

table td,
.table td {
    padding: 14px;
    border-bottom: 1px solid var(--border);
    color: var(--white-70);
    vertical-align: top;
}

tbody tr:hover {
    background: rgba(255,255,255,.035);
}

pre,
.output-box {
    margin: 0;
    padding: 18px;
    border-radius: 18px;
    background: rgba(0,0,0,.28);
    border: 1px solid var(--border);
    color: var(--white-90);
    white-space: pre-wrap;
    overflow-x: auto;
    font-family: Consolas, Monaco, monospace;
    font-size: 13px;
}

code {
    font-family: Consolas, Monaco, monospace;
    font-size: 12px;
}

.alert,
.success-card {
    margin-bottom: 18px;
    padding: 14px 16px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    gap: 9px;
    font-weight: 700;
}

.alert,
.alert.error {
    color: var(--red);
    background: rgba(251,113,133,.12);
    border: 1px solid rgba(251,113,133,.24);
}

.alert.success,
.success-card {
    color: var(--green);
    background: rgba(52,211,153,.12);
    border: 1px solid rgba(52,211,153,.24);
}

.login-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 22px;
}

.login-box,
.login-card {
    width: min(440px, 100%);
    padding: 30px;
    border-radius: 28px;
    background: var(--card);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}

.login-title {
    font-size: 26px;
    font-weight: 800;
    color: var(--white-90);
    text-align: center;
}

.login-subtitle {
    text-align: center;
    color: var(--white-50);
    margin: 8px 0 24px;
}

.login-btn {
    width: 100%;
}

.icon-blue { color: #38bdf8 !important; }
.icon-green { color: #34d399 !important; }
.icon-red { color: #fb7185 !important; }
.icon-orange { color: #fbbf24 !important; }
.icon-purple { color: #a78bfa !important; }
.icon-cyan { color: #22d3ee !important; }
.icon-indigo { color: #818cf8 !important; }
.icon-yellow { color: #fde047 !important; }
.icon-pink { color: #f472b6 !important; }

* {
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,.12) transparent;
}

::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,.12);
    border-radius: 100px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255,255,255,.22);
}

@media (max-width: 960px) {
    .grid,
    .dashboard-grid,
    .gateway-overview,
    .grid.two,
    .gateway-live-row {
        grid-template-columns: repeat(2, 1fr);
    }

    .topbar {
        padding: 0 14px;
    }
}

@media (max-width: 680px) {
    .topbar {
        height: auto;
        min-height: 60px;
        padding: 14px;
        flex-direction: column;
        align-items: stretch;
    }

    .topbar-actions {
        justify-content: space-between;
    }

    .main-wrap {
        width: min(100% - 24px, 1280px);
        padding-top: 22px;
    }

    .grid,
    .dashboard-grid,
    .gateway-overview,
    .grid.two,
    .gateway-live-row {
        grid-template-columns: 1fr;
    }

    .hero-card {
        align-items: flex-start;
        flex-direction: column;
    }

    .footer {
        flex-direction: column;
        text-align: center;
        align-items: center;
    }
}
