:root {
    --bg: #0f1419;
    --bg-card: #1a2332;
    --bg-input: #0d1117;
    --border: #2d3a4f;
    --text: #e6edf3;
    --text-muted: #8b949e;
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --success: #22c55e;
    --danger: #ef4444;
    --warning: #f59e0b;
    --radius: 8px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

/* Navbar */
.navbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    height: 56px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    font-size: 1.1rem;
}

.nav-links { display: flex; align-items: center; gap: 8px; margin-left: auto; }

/* User profile dropdown */
.nav-user-menu { position: relative; margin-left: 12px; }
.nav-user-trigger {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 12px 6px 6px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--bg-input);
    color: var(--text);
    cursor: pointer;
    font: inherit;
    font-size: 0.9rem;
    transition: border-color 0.15s, background 0.15s;
}
.nav-user-trigger:hover,
.nav-user-menu.open .nav-user-trigger {
    border-color: var(--primary);
    background: rgba(59, 130, 246, 0.08);
}
.nav-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    color: #fff;
    font-weight: 700;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.nav-user-name {
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 500;
}
.nav-chevron {
    opacity: 0.6;
    transition: transform 0.2s;
}
.nav-user-menu.open .nav-chevron { transform: rotate(180deg); }

.nav-user-dropdown {
    display: none;
    position: fixed;
    top: 60px;
    right: 16px;
    min-width: 260px;
    max-width: min(320px, calc(100vw - 24px));
    background: var(--bg-card);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
    overflow: hidden;
    z-index: 1001;
    animation: dropdownIn 0.15s ease;
}
.nav-user-dropdown.open { display: block; }
@keyframes dropdownIn {
    from { opacity: 0; transform: translateY(-6px); }
    to { opacity: 1; transform: translateY(0); }
}
.nav-dropdown-header {
    padding: 16px 16px 12px;
    text-align: center;
    background: rgba(255, 255, 255, 0.02);
}
.nav-dropdown-name {
    font-weight: 700;
    font-size: 1rem;
    color: var(--text);
}
.nav-dropdown-role {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 2px;
}
.nav-dropdown-balance {
    margin-top: 10px;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--success);
}
.nav-dropdown-note {
    margin-top: 8px;
    font-size: 0.75rem;
    color: var(--text-muted);
    line-height: 1.4;
    padding: 6px 10px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 6px;
}
.nav-dropdown-divider {
    height: 1px;
    background: var(--border);
    margin: 0 12px;
}
.nav-dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.9rem;
    transition: background 0.12s, color 0.12s;
}
.nav-dropdown-item:hover {
    background: rgba(59, 130, 246, 0.1);
    color: var(--text);
}
.nav-dropdown-item.active { color: var(--primary); font-weight: 600; }
.nav-dropdown-logout {
    display: block;
    margin: 12px 16px 16px;
    padding: 10px 16px;
    text-align: center;
    background: #14b8a6;
    color: #fff !important;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
    border-radius: 8px;
    transition: background 0.15s, filter 0.15s;
}
.nav-dropdown-logout:hover { background: #0d9488; filter: brightness(1.05); }

.nav-user { font-size: 0.85rem; margin-left: 8px; }
.text-danger { color: var(--danger); }
.alert-info {
    background: rgba(59, 130, 246, 0.12);
    border: 1px solid rgba(59, 130, 246, 0.3);
    color: var(--text);
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 16px;
}
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { filter: brightness(1.05); }
.btn-icon { min-width: 32px; font-weight: 700; font-size: 1.1rem; line-height: 1; padding: 6px 10px; }
.nav-links a {
    color: var(--text-muted);
    text-decoration: none;
    padding: 8px 14px;
    border-radius: var(--radius);
    font-size: 0.9rem;
}
.nav-links a:hover, .nav-links a.active {
    color: var(--text);
    background: rgba(59, 130, 246, 0.15);
}

.nav-mobile-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: 999;
    opacity: 0;
    transition: opacity 0.2s ease;
}
body.nav-menu-open .nav-mobile-backdrop {
    display: block;
    opacity: 1;
}

@media (max-width: 768px) {
    .navbar {
        padding: 0 10px;
        height: 52px;
        position: sticky;
        top: 0;
        z-index: 900;
    }
    .nav-brand { font-size: 0.95rem; gap: 8px; }
    .nav-links {
        gap: 2px;
        margin-left: auto;
        flex: 1;
        justify-content: flex-end;
        min-width: 0;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        padding-right: 2px;
    }
    .nav-links::-webkit-scrollbar { display: none; }
    .nav-links > a {
        padding: 6px 9px;
        font-size: 0.78rem;
        white-space: nowrap;
        flex-shrink: 0;
    }
    .nav-links > a.nav-link-topup {
        display: none;
    }
    .nav-user-menu { margin-left: 2px; flex-shrink: 0; }
    .nav-user-trigger {
        padding: 4px;
        gap: 0;
        border-radius: 50%;
    }
    .nav-user-name,
    .nav-chevron { display: none; }
    .nav-avatar { width: 36px; height: 36px; }

    body.nav-menu-open { overflow: hidden; }

    .nav-user-dropdown.open {
        top: auto;
        bottom: 0;
        left: 0;
        right: 0;
        min-width: 0;
        width: 100%;
        max-width: none;
        border-radius: 16px 16px 0 0;
        border-bottom: none;
        box-shadow: 0 -8px 40px rgba(0, 0, 0, 0.5);
        max-height: min(85vh, 520px);
        overflow-y: auto;
        animation: sheetUp 0.22s ease;
    }
    @keyframes sheetUp {
        from { opacity: 0; transform: translateY(100%); }
        to { opacity: 1; transform: translateY(0); }
    }
    .nav-dropdown-header { padding: 20px 16px 14px; }
    .nav-dropdown-note { font-size: 0.8rem; }
    .nav-dropdown-item { padding: 14px 18px; font-size: 0.95rem; }
    .nav-dropdown-logout {
        margin: 8px 16px calc(16px + env(safe-area-inset-bottom, 0px));
        padding: 14px 16px;
        font-size: 1rem;
    }
}

.logo-icon {
    width: 36px; height: 36px;
    background: linear-gradient(135deg, var(--primary), #8b5cf6);
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    font-weight: 800; font-size: 0.85rem;
}
.logo-icon.sm { width: 28px; height: 28px; font-size: 0.7rem; }

/* Layout */
.container { max-width: 1200px; margin: 0 auto; padding: 24px; }

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}
.page-header h1 { font-size: 1.75rem; }

.text-muted { color: var(--text-muted); font-size: 0.9rem; }
.text-center { text-align: center; }

/* Stats */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
}
.stat-card.highlight { border-color: var(--primary); }
.stat-value { font-size: 1.75rem; font-weight: 700; }
.stat-label { color: var(--text-muted); font-size: 0.85rem; margin-top: 4px; }

.info-banner {
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.3);
    border-radius: var(--radius);
    padding: 14px 18px;
    margin-bottom: 24px;
    font-size: 0.9rem;
}

/* Card */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 24px;
}
.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}
.card-header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}
.filter-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    color: var(--text-muted);
}
.filter-label select {
    background: var(--bg-input);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 6px 10px;
}
.inline-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}
.card h2 { font-size: 1.1rem; margin-bottom: 16px; }
.card-header h2 { margin-bottom: 0; }

.table-search {
    margin-bottom: 14px;
    max-width: 360px;
}
.table-search input {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 0.9rem;
}
.table-search input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.12);
}
.col-auto-renew { white-space: nowrap; }

.form-toggle-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}
.form-toggle-row small {
    flex: 1 1 100%;
    margin-top: 4px;
}

/* Table */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--border); }
th { color: var(--text-muted); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em; }
td code { background: var(--bg-input); padding: 2px 6px; border-radius: 4px; font-size: 0.85rem; }

.port-badge {
    display: inline-block;
    background: var(--bg-input);
    border: 1px solid var(--border);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.8rem;
    margin: 2px;
    font-family: monospace;
}

.info-table { width: 100%; margin: 12px 0; }
.info-table th, .info-table td { font-size: 0.9rem; }
.info-table td .port-input {
    width: 100%;
    max-width: 120px;
    padding: 8px 10px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 0.85rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    transition: border-color 0.15s ease;
}
.info-table td .port-input::placeholder { color: var(--text-muted); opacity: 0.8; }
.info-table td .port-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.15);
}
.info-table td .port-input::-webkit-outer-spin-button,
.info-table td .port-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
.info-table td .port-input[type="number"] {
    -moz-appearance: textfield;
    appearance: textfield;
}

/* Badges */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
}
.badge-success { background: rgba(34, 197, 94, 0.2); color: var(--success); }
.badge-muted { background: rgba(139, 148, 158, 0.2); color: var(--text-muted); }
.badge-online { background: rgba(34, 197, 94, 0.15); color: #4ade80; font-weight: 600; }
.badge-offline { background: rgba(239, 68, 68, 0.1); color: #f87171; }
.badge-disabled { background: rgba(245, 158, 11, 0.15); color: var(--warning); }
.badge-expired { background: rgba(239, 68, 68, 0.15); color: #f87171; }

.row-readonly { opacity: 0.85; }
.row-readonly .port-badge { opacity: 0.6; }

.hidden { display: none !important; }

.btn-warning { background: var(--warning); color: #111; border: none; }
.btn-warning:hover { filter: brightness(1.05); }

.payment-methods { display: grid; gap: 8px; }
.payment-method-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
}
.payment-method-item:has(input:checked) { border-color: var(--primary); background: rgba(59, 130, 246, 0.08); }
.payment-logo { width: 28px; height: 28px; object-fit: contain; }
.topup-qr-wrap { text-align: center; margin: 16px 0; }
.topup-qr { max-width: 280px; border-radius: 8px; background: #fff; padding: 8px; }

/* Topup page */
.topup-container { max-width: 960px; }

.topup-hero {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 28px 32px;
    margin-bottom: 24px;
    border-radius: 14px;
    border: 1px solid rgba(59, 130, 246, 0.35);
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.18) 0%, rgba(139, 92, 246, 0.12) 100%);
}
.topup-hero-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 6px;
}
.topup-hero-balance {
    font-size: clamp(1.75rem, 4vw, 2.25rem);
    font-weight: 800;
    margin-bottom: 6px;
    background: linear-gradient(90deg, #93c5fd, #c4b5fd);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}
.topup-hero-icon {
    font-size: 2.5rem;
    width: 72px;
    height: 72px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.08);
    flex-shrink: 0;
}

.topup-grid {
    display: grid;
    grid-template-columns: 1.2fr 0.8fr;
    gap: 20px;
    align-items: start;
}
@media (max-width: 860px) {
    .topup-grid { grid-template-columns: 1fr; }
    .topup-hero { padding: 22px 20px; }
    .topup-hero-icon { display: none; }
}

.topup-card { margin-bottom: 0; }
.topup-card-head { margin-bottom: 20px; }
.topup-card-head h2 { margin-bottom: 6px; }

.amount-presets {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}
.amount-chip {
    padding: 8px 14px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--bg-input);
    color: var(--text-muted);
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s, color 0.15s;
}
.amount-chip:hover {
    border-color: var(--primary);
    color: var(--text);
}
.amount-chip.active {
    border-color: var(--primary);
    background: rgba(59, 130, 246, 0.12);
    color: #93c5fd;
}

.amount-input-wrap {
    display: flex;
    align-items: stretch;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-input);
    overflow: hidden;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.amount-input-wrap:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
}
.amount-prefix {
    display: flex;
    align-items: center;
    padding: 0 14px;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.9rem;
    border-right: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.02);
}
.amount-input {
    flex: 1;
    border: none;
    background: transparent;
    color: var(--text);
    font-size: 1.1rem;
    font-weight: 600;
    padding: 12px 14px;
    min-width: 0;
}
.amount-input:focus { outline: none; }
.amount-input::-webkit-outer-spin-button,
.amount-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.amount-input[type="number"] { -moz-appearance: textfield; appearance: textfield; }

.payment-methods {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    grid-auto-rows: 1fr;
    gap: 10px;
    align-items: stretch;
}
@media (max-width: 520px) {
    .payment-methods { grid-template-columns: 1fr; }
}

.pay-method-card {
    position: relative;
    cursor: pointer;
    margin: 0;
    display: flex;
    min-height: 84px;
    height: 100%;
}
.pay-method-radio {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
    pointer-events: none;
}
.pay-method-inner {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    width: 100%;
    height: 84px;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--bg-input);
    transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
    box-sizing: border-box;
}
.pay-method-card:hover .pay-method-inner {
    border-color: rgba(59, 130, 246, 0.45);
}
.pay-method-radio:checked + .pay-method-inner {
    border-color: var(--primary);
    background: rgba(59, 130, 246, 0.1);
    box-shadow: 0 0 0 1px rgba(59, 130, 246, 0.25);
}
.pay-method-logo-wrap {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    padding: 6px;
}
.payment-logo { width: 100%; height: 100%; object-fit: contain; }
.payment-logo-fallback { font-size: 1.25rem; }
.pay-method-text {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.pay-method-title {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text);
    line-height: 1.25;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.pay-method-sub {
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.pay-method-check {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 2px solid var(--border);
    flex-shrink: 0;
    position: relative;
    transition: border-color 0.15s, background 0.15s;
}
.pay-method-radio:checked + .pay-method-inner .pay-method-check {
    border-color: var(--primary);
    background: var(--primary);
}
.pay-method-radio:checked + .pay-method-inner .pay-method-check::after {
    content: '';
    position: absolute;
    left: 5px;
    top: 2px;
    width: 5px;
    height: 9px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.payment-methods-loading { pointer-events: none; }
.pay-method-skeleton {
    height: 84px;
    border-radius: 10px;
    background: linear-gradient(90deg, var(--bg-input) 25%, rgba(255,255,255,0.06) 50%, var(--bg-input) 75%);
    background-size: 200% 100%;
    animation: skeletonShimmer 1.2s ease infinite;
}
@keyframes skeletonShimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.topup-submit { margin-top: 8px; padding: 12px 20px; font-size: 1rem; }

.topup-info-card h2 { margin-bottom: 16px; }
.topup-steps {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-bottom: 20px;
}
.topup-steps li {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    font-size: 0.9rem;
    color: var(--text-muted);
    line-height: 1.45;
}
.topup-steps li span {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: rgba(59, 130, 246, 0.15);
    color: #93c5fd;
    font-size: 0.8rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.topup-note {
    padding: 14px;
    border-radius: var(--radius);
    background: rgba(245, 158, 11, 0.08);
    border: 1px solid rgba(245, 158, 11, 0.25);
    font-size: 0.85rem;
    color: var(--text-muted);
    line-height: 1.5;
}
.topup-note strong { color: var(--warning); }

.topup-result-card { margin-top: 0; }
.topup-result-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 12px;
}
.topup-result-head h2 { margin-bottom: 4px; }
.topup-status-badge {
    display: inline-block;
    padding: 6px 14px;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.topup-status-badge.pending { background: rgba(245, 158, 11, 0.15); color: var(--warning); }
.topup-status-badge.success { background: rgba(34, 197, 94, 0.15); color: var(--success); }
.topup-status-badge.failed,
.topup-status-badge.expired { background: rgba(239, 68, 68, 0.15); color: var(--danger); }
.topup-validity { margin-bottom: 20px; }

.topup-qr-section { margin: 20px 0; }
.topup-qr-wrap {
    display: inline-flex;
    padding: 16px;
    border-radius: 14px;
    background: #fff;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
    margin: 0 auto 12px;
}
.topup-qr-section { text-align: center; }
.topup-qr { display: block; width: 240px; height: 240px; }

.topup-va-section { margin: 20px 0; }
.topup-va-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 12px;
}
.topup-va-item {
    padding: 14px;
    border-radius: var(--radius);
    background: var(--bg-input);
    border: 1px solid var(--border);
}
.topup-va-label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 6px;
}
.topup-va-number-box {
    padding: 16px;
    border-radius: var(--radius);
    border: 1px dashed rgba(59, 130, 246, 0.4);
    background: rgba(59, 130, 246, 0.06);
}
.topup-va-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 8px;
}
.topup-va-row code {
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    color: #93c5fd;
}

.topup-result-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

.col-notes { max-width: 200px; font-size: 0.9rem; color: var(--text-muted); }

.uptime { display: block; color: var(--text-muted); font-size: 0.75rem; margin-top: 2px; }

/* Toggle switch */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    vertical-align: middle;
    cursor: pointer;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
    position: absolute;
    inset: 0;
    background: #374151;
    border-radius: 24px;
    transition: 0.2s;
}
.toggle-slider:before {
    content: '';
    position: absolute;
    width: 18px; height: 18px;
    left: 3px; bottom: 3px;
    background: #fff;
    border-radius: 50%;
    transition: 0.2s;
}
.toggle-switch input:checked + .toggle-slider { background: var(--success); }
.toggle-switch input:checked + .toggle-slider:before { transform: translateX(20px); }
.toggle-label {
    margin-left: 8px;
    font-size: 0.85rem;
    vertical-align: middle;
    color: var(--text-muted);
}
.col-account { white-space: nowrap; }
.col-connection { min-width: 100px; }

#last-update { margin-left: 12px; font-size: 0.85rem; }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: none;
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: var(--bg-input); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-danger { background: rgba(239, 68, 68, 0.15); color: var(--danger); border: 1px solid rgba(239, 68, 68, 0.3); }
.btn-danger:hover { background: rgba(239, 68, 68, 0.25); }
.btn-sm { padding: 5px 10px; font-size: 0.8rem; }
.btn-block { width: 100%; justify-content: center; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* Forms */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; margin-bottom: 6px; font-size: 0.9rem; font-weight: 500; }
.form-group small { display: block; color: var(--text-muted); font-size: 0.8rem; margin-top: 4px; }
.form-group input, .form-group select, .form-group textarea {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 0.9rem;
}
.form-group input:focus, .form-group select:focus {
    outline: none;
    border-color: var(--primary);
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 600px) { .form-row { grid-template-columns: 1fr; } }

.port-preview {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px;
    margin-bottom: 16px;
    font-size: 0.85rem;
}
.port-preview div { margin-top: 8px; font-family: monospace; }

/* Modal */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.modal.active { display: flex; }
.modal-content {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 24px;
}
.modal-lg { max-width: 720px; }
.modal-script { max-width: 860px; width: 100%; }
.modal-sub { margin-top: 4px; font-size: 0.85rem; }
.modal-header h2 { font-size: 1.2rem; margin: 0; }
.modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 16px;
    gap: 16px;
}
.modal-close {
    background: none; border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    line-height: 1;
    flex-shrink: 0;
}
.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.script-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    gap: 12px;
    flex-wrap: wrap;
}
.script-hint { font-size: 0.85rem; color: var(--text-muted); }
.script-lines {
    font-size: 0.8rem;
    color: var(--primary);
    background: rgba(59, 130, 246, 0.1);
    padding: 4px 10px;
    border-radius: 12px;
}

.script-terminal {
    background: #0d1117;
    border: 1px solid #30363d;
    border-radius: 8px;
    overflow: hidden;
}
.script-terminal textarea {
    display: block;
    width: 100%;
    min-height: 340px;
    max-height: 55vh;
    padding: 18px 20px;
    background: #0d1117;
    border: none;
    color: #7ee787;
    font-family: 'Consolas', 'Courier New', monospace;
    font-size: 0.9rem;
    line-height: 1.65;
    resize: vertical;
    outline: none;
    white-space: pre;
    overflow-wrap: normal;
    overflow-x: auto;
}
.script-terminal textarea::selection {
    background: rgba(59, 130, 246, 0.4);
    color: #fff;
}

/* Script box (legacy) */
.script-box {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    max-height: 400px;
    overflow: auto;
}
.script-box textarea {
    width: 100%;
    min-height: 180px;
    padding: 16px;
    background: var(--bg-input);
    border: none;
    color: var(--text);
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.85rem;
    line-height: 1.5;
    resize: vertical;
    outline: none;
}
.script-box pre {
    padding: 16px;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.8rem;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-all;
}

/* Detail grid */
.detail-grid {
    display: grid;
    grid-template-columns: 140px 1fr;
    gap: 8px 16px;
    font-size: 0.9rem;
    margin-bottom: 20px;
}
.detail-grid dt { color: var(--text-muted); }
.detail-grid dd code { font-size: 0.85rem; }

/* Alerts */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    font-size: 0.9rem;
}
.alert-error { background: rgba(239, 68, 68, 0.15); border: 1px solid rgba(239, 68, 68, 0.3); color: #fca5a5; }
.alert-success { background: rgba(34, 197, 94, 0.15); border: 1px solid rgba(34, 197, 94, 0.3); color: #86efac; }

/* Toast */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    padding: 14px 20px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.3s;
    z-index: 2000;
    font-size: 0.9rem;
}
.toast.show { transform: translateY(0); opacity: 1; }
.toast.success { border-color: var(--success); }
.toast.error { border-color: var(--danger); }

/* Login */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}
.login-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 40px;
    width: 100%;
    max-width: 400px;
}
.login-logo { text-align: center; margin-bottom: 32px; }
.login-logo .logo-icon { margin: 0 auto 16px; width: 56px; height: 56px; font-size: 1.2rem; }
.login-logo h1 { font-size: 1.5rem; }
.login-logo p { color: var(--text-muted); font-size: 0.9rem; }
