/* SuperVPG Control Center - Main Stylesheet */
:root {
    color-scheme: dark;
    --bg: #08111f;
    --panel: #111d30;
    --line: #263650;
    --muted: #91a3bd;
    --text: #edf4ff;
    --blue: #3984ff;
    --green: #2ecc91;
    --red: #ff6b78;
    --amber: #f7bd4a;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: radial-gradient(ellipse at top, #142744 0, #08111f 48%);
    font: 15px/1.5 system-ui, -apple-system, Segoe UI, sans-serif;
    color: var(--text);
}

button, input, select, textarea {
    font: inherit;
}

button {
    cursor: pointer;
    border: 1px solid #355078;
    border-radius: 10px;
    padding: 9px 13px;
    background: #1b3150;
    color: white;
    transition: all 0.15s ease;
}

button:hover {
    background: #25426b;
}

button.primary {
    background: var(--blue);
    border-color: var(--blue);
    font-weight: 700;
}

button.primary:hover {
    background: #2b73e6;
}

button.danger {
    border-color: #713e4a;
    background: #3d1c23;
    color: #ffb6be;
}

button.danger:hover {
    background: #542530;
}

button:disabled {
    opacity: .5;
    cursor: not-allowed;
}

.wrap {
    max-width: 1240px;
    margin: auto;
    padding: 24px;
}

.top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.mark {
    display: grid;
    place-items: center;
    width: 46px;
    height: 46px;
    border-radius: 14px;
    background: linear-gradient(135deg, #3984ff, #8b5cf6);
    font-weight: 900;
    font-size: 20px;
}

.sub, .muted {
    color: var(--muted);
}

h1 {
    font-size: clamp(22px, 3vw, 32px);
    margin: 0;
}

h2 {
    font-size: 17px;
    margin: 0 0 15px;
}

.panel {
    background: linear-gradient(160deg, rgba(20, 34, 56, .96), rgba(12, 23, 39, .96));
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 20px;
    box-shadow: 0 18px 45px #0002;
}

.login {
    max-width: 420px;
    margin: 7vh auto;
}

.field {
    display: grid;
    gap: 7px;
    margin: 15px 0;
}

.field input, .field select, .field textarea {
    width: 100%;
    padding: 12px;
    border-radius: 10px;
    border: 1px solid #354762;
    background: #081321;
    color: white;
}

.field input:focus, .field select:focus, .field textarea:focus {
    outline: none;
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(57, 132, 255, 0.25);
}

.login-input-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.login-input-wrap .input-icon {
    position: absolute;
    left: 14px;
    width: 20px;
    height: 20px;
    color: var(--muted);
    pointer-events: none;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.login-input-wrap input {
    padding-left: 44px;
    padding-right: 46px;
}

.password-toggle {
    position: absolute;
    right: 8px;
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--muted);
}

.password-toggle:hover {
    color: var(--text);
    background: transparent;
}

.password-toggle svg {
    width: 21px;
    height: 21px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

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

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

.metric {
    font-size: 29px;
    font-weight: 800;
    margin-top: 7px;
}

.metric-label {
    color: var(--muted);
    font-size: 13px;
}

.apps {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.app {
    border: 1px solid var(--line);
    background: #0c1829;
    border-radius: 14px;
    padding: 16px;
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
}

.app-name {
    font-weight: 750;
}

.app-id {
    font-size: 12px;
    color: var(--muted);
}

.app-url {
    font-size: 12px;
    color: #64b5f6;
    word-break: break-all;
    margin-top: 3px;
}

.pill {
    display: inline-block;
    border-radius: 999px;
    padding: 3px 9px;
    font-size: 12px;
    font-weight: 700;
}

.active {
    background: #123d32;
    color: #6ff0bd;
}

.inactive {
    background: #40242d;
    color: #ff9eaa;
}

.maintenance {
    background: #43371c;
    color: #ffd77d;
}

.row-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 12px;
}

.section-head {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
    margin-bottom: 14px;
}

.table-wrap {
    overflow: auto;
}

table {
    border-collapse: collapse;
    width: 100%;
    min-width: 720px;
    font-size: 13px;
}

th, td {
    text-align: left;
    padding: 11px 10px;
    border-bottom: 1px solid #263650;
    white-space: nowrap;
}

th {
    color: #9eb0c8;
    font-weight: 600;
}

td.path {
    max-width: 260px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.hidden {
    display: none !important;
}

.page-view {
    min-width: 0;
}

.page-view > section {
    margin-bottom: 18px;
}

.error {
    color: #ff9da7;
    margin-top: 10px;
}

.ok {
    color: #77e5b7;
    margin-top: 10px;
}

.footer {
    font-size: 12px;
    color: #8294ad;
    text-align: center;
    padding: 24px;
}

.notice {
    font-size: 13px;
    color: #a9bbd4;
    margin-top: 10px;
}

/* Toast Backdrop & Modals */
.toast-backdrop {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: grid;
    place-items: center;
    padding: 18px;
    background: rgba(2, 8, 18, .58);
    backdrop-filter: blur(6px);
}

.toast-card {
    width: min(100%, 410px);
    text-align: center;
    border: 1px solid #2d4261;
    border-radius: 24px;
    padding: 28px 24px 22px;
    background: linear-gradient(155deg, #172941, #0b1728);
    box-shadow: 0 28px 90px #000b;
    animation: modal-in .18s ease-out;
}

.toast-symbol {
    width: 68px;
    height: 68px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    margin: 0 auto 17px;
    font-size: 34px;
    font-weight: 800;
}

.toast-card.success .toast-symbol {
    background: rgba(46, 204, 145, .13);
    border: 2px solid #2ecc91;
    color: #62e8b2;
}

.toast-card.error .toast-symbol {
    background: rgba(255, 107, 120, .12);
    border: 2px solid #ff6b78;
    color: #ff8792;
}

.toast-card.info .toast-symbol {
    background: rgba(57, 132, 255, .13);
    border: 2px solid #3984ff;
    color: #76adff;
}

.toast-card h2 {
    font-size: 22px;
    margin: 0 0 9px;
}

.toast-card p {
    color: #b5c4d8;
    line-height: 1.65;
    margin: 0;
}

.toast-card button {
    min-width: 115px;
    margin-top: 23px;
    padding: 11px 20px;
    border-radius: 12px;
    background: #3984ff;
    border-color: #3984ff;
    font-weight: 750;
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: grid;
    place-items: center;
    padding: 18px;
    background: rgba(2, 8, 18, .78);
    backdrop-filter: blur(7px);
}

.confirm-modal {
    width: min(100%, 430px);
    border: 1px solid #344968;
    border-radius: 22px;
    padding: 25px;
    background: linear-gradient(160deg, #172840, #0d192b);
    box-shadow: 0 28px 90px #0009;
    animation: modal-in .16s ease-out;
}

.confirm-icon {
    display: grid;
    place-items: center;
    width: 54px;
    height: 54px;
    border-radius: 17px;
    margin-bottom: 17px;
    background: #4b351c;
    color: #ffd27a;
    font-size: 26px;
    font-weight: 800;
}

.confirm-modal h2 {
    font-size: 21px;
    margin: 0 0 9px;
}

.confirm-modal p {
    color: #b5c4d8;
    margin: 0;
    line-height: 1.6;
}

.confirm-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 25px;
}

.confirm-actions .cancel {
    background: #17263b;
    border-color: #354863;
    color: #d7e3f3;
}

.confirm-actions .confirm-danger {
    background: #d9475a;
    border-color: #d9475a;
    font-weight: 750;
}

.confirm-actions .confirm-primary {
    background: #3984ff;
    border-color: #3984ff;
    font-weight: 750;
}

@keyframes modal-in {
    from {
        opacity: 0;
        transform: translateY(7px) scale(.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Responsive Grid & Layout */
@media (max-width: 420px) {
    .confirm-modal {
        padding: 21px;
    }
    .confirm-actions button {
        flex: 1;
    }
}

@media (max-width: 800px) {
    .grid, .grid-2 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .apps {
        grid-template-columns: 1fr;
    }
    .wrap {
        padding: 15px;
    }
    .top {
        align-items: flex-start;
    }
    .panel {
        padding: 15px;
    }
}

@media (max-width: 420px) {
    .grid, .grid-2 {
        grid-template-columns: 1fr 1fr;
    }
    .metric {
        font-size: 24px;
    }
}

/* Sidebar Navigation */
.app-layout {
    display: grid;
    grid-template-columns: 252px minmax(0, 1fr);
    gap: 20px;
    max-width: 1500px;
    margin: auto;
    padding: 18px;
    align-items: start;
}

.side-nav {
    position: sticky;
    top: 16px;
    padding: 16px 12px;
    background: #081321;
    border: 1px solid var(--line);
    border-radius: 18px;
    min-height: calc(100vh - 32px);
}

.side-brand {
    display: flex;
    gap: 11px;
    align-items: center;
    padding: 4px 6px 22px;
}

.side-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border: 1px solid transparent;
    border-radius: 11px;
    color: #c6d5e9;
    text-decoration: none;
    margin: 4px 0;
}

.side-link:hover, .side-link.current {
    background: #1b3150;
    border-color: #304968;
    color: #fff;
}

.side-group {
    font-size: 12px;
    font-weight: 800;
    letter-spacing: .08em;
    color: #8fa3bf;
    margin: 19px 10px 7px;
}

.side-link svg {
    width: 20px;
    height: 20px;
    flex: none;
    stroke: currentColor;
    fill: none;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.side-logout {
    width: 100%;
    margin-top: 25px;
}

.mobile-nav {
    display: none;
}

.nav-shade {
    display: none;
}

.userbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 16px;
    margin: 0 0 18px;
    background: rgba(8, 19, 33, .92);
    border: 1px solid var(--line);
    border-radius: 16px;
}

.userbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.header-menu {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    flex: none;
    padding: 0;
    background: #1b3150;
    border: 1px solid #355078;
}

.header-menu svg {
    width: 22px;
    height: 22px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
}

.vpg-logo {
    width: 44px;
    height: 44px;
    object-fit: contain;
    flex: none;
}

.side-vpg-logo {
    width: 44px;
    height: 44px;
    object-fit: contain;
    flex: none;
}

.userbar-brand {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 800;
}

.session-badge {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 8px 12px;
    border-radius: 999px;
    background: #123d32;
    color: #6ff0bd;
    font-size: 13px;
    font-weight: 750;
    white-space: nowrap;
}

.session-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: currentColor;
}

.profile-wrap {
    position: relative;
}

.profile-trigger {
    display: flex;
    align-items: center;
    gap: 8px;
    background: transparent;
    border-color: transparent;
    padding: 5px;
}

.profile-avatar {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: linear-gradient(135deg, #3984ff, #8b5cf6);
    font-size: 20px;
    font-weight: 900;
}

.profile-menu {
    position: absolute;
    right: 0;
    top: calc(100% + 10px);
    width: 245px;
    padding: 14px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 15px;
    box-shadow: 0 20px 50px #0006;
    z-index: 100;
}

.profile-menu button {
    width: 100%;
    text-align: left;
    margin-top: 10px;
}

.chevron {
    width: 18px;
    height: 18px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.logged-in #logout {
    display: none !important;
}

.logged-in .userbar {
    display: flex;
}

.userbar {
    display: none;
}

.userbar.hidden {
    display: none !important;
}

@media (max-width: 900px) {
    .app-layout {
        display: block;
        padding: 0;
    }
    .main-content {
        min-width: 0;
    }
    .userbar {
        position: sticky;
        top: 0;
        z-index: 80;
        border-radius: 0;
        margin: 0 -15px 18px;
        padding: 10px 12px;
    }
    .userbar-brand .sub {
        display: none;
    }
    .session-badge {
        padding: 7px 9px;
        font-size: 12px;
    }
    .profile-avatar {
        width: 38px;
        height: 38px;
    }
    .side-nav {
        position: fixed;
        z-index: 120;
        inset: 0 auto 0 0;
        width: min(84vw, 330px);
        height: 100dvh;
        min-height: 0;
        overflow-y: auto;
        border-radius: 0 18px 18px 0;
        transform: translateX(-105%);
        transition: transform .2s ease;
    }
    .side-nav.open {
        transform: translateX(0);
    }
    .nav-shade.show {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 110;
        background: #020812bb;
    }
    .main-content .wrap {
        padding: 15px;
    }
    .main-content .top {
        margin-top: 12px;
    }
}

@media (min-width: 901px) {
    .nav-shade {
        display: none !important;
    }
}

body:not(.logged-in) .nav-shade {
    display: none !important;
}

@media (max-width: 480px) {
    .userbar {
        gap: 8px;
    }
    .userbar-left {
        gap: 8px;
    }
    .userbar-brand {
        gap: 7px;
    }
    .vpg-logo {
        width: 36px;
        height: 36px;
    }
    .userbar-brand > div {
        font-size: 14px;
    }
    .session-badge {
        max-width: 106px;
        overflow: hidden;
    }
    .profile-trigger {
        gap: 3px;
        padding: 2px;
    }
    .profile-avatar {
        width: 34px;
        height: 34px;
    }
    .profile-avatar img {
        width: 31px !important;
        height: 31px !important;
    }
}

.login-logo {
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 0 auto 18px;
}

.login-logo img {
    display: block;
    width: 110px;
    height: 110px;
    object-fit: contain;
}
