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

:root {
    --bg: #0b0f17;
    --bg-elevated: #111827;
    --bg-card: #151d2e;
    --bg-hover: #1a2438;
    --border: rgba(255, 255, 255, 0.08);
    --border-strong: rgba(255, 255, 255, 0.14);
    --text: #f1f5f9;
    --text-muted: #94a3b8;
    --text-dim: #64748b;
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --primary-glow: rgba(59, 130, 246, 0.25);
    --success: #22c55e;
    --success-bg: rgba(34, 197, 94, 0.12);
    --danger: #ef4444;
    --danger-bg: rgba(239, 68, 68, 0.12);
    --warning: #f59e0b;
    --warning-bg: rgba(245, 158, 11, 0.12);
    --sidebar-w: 260px;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.35);
    --font: 'Inter', system-ui, -apple-system, sans-serif;
}

html, body {
    height: 100%;
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

.app-body {
    min-height: 100vh;
    display: flex;
}

.sidebar {
    width: var(--sidebar-w);
    min-height: 100vh;
    background: var(--bg-elevated);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 200;
    transition: transform 0.25s ease;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 24px 20px;
    border-bottom: 1px solid var(--border);
}

.brand-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--primary), #6366f1);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.brand-icon svg {
    width: 20px;
    height: 20px;
    color: #fff;
}

.brand-text {
    display: flex;
    flex-direction: column;
}

.brand-name {
    font-weight: 700;
    font-size: 15px;
    letter-spacing: -0.02em;
}

.brand-sub {
    font-size: 12px;
    color: var(--text-muted);
}

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: background 0.15s, color 0.15s;
}

.nav-item svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.nav-item:hover {
    background: var(--bg-hover);
    color: var(--text);
}

.nav-item.active {
    background: var(--primary-glow);
    color: var(--primary);
}

.sidebar-footer {
    padding: 16px 12px 20px;
    border-top: 1px solid var(--border);
}

.user-chip {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 14px;
    margin-bottom: 8px;
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: var(--bg-hover);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 600;
    color: var(--primary);
}

.user-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
}

.nav-item.logout {
    color: var(--danger);
}

.nav-item.logout:hover {
    background: var(--danger-bg);
    color: var(--danger);
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 150;
}

.sidebar-overlay.open {
    display: block;
}

.main-wrap {
    flex: 1;
    margin-left: var(--sidebar-w);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    width: calc(100% - var(--sidebar-w));
}

.topbar {
    height: 64px;
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
    background: rgba(11, 15, 23, 0.85);
    backdrop-filter: blur(12px);
    position: sticky;
    top: 0;
    z-index: 100;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.menu-toggle {
    display: none;
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    width: 40px;
    height: 40px;
    cursor: pointer;
    align-items: center;
    justify-content: center;
}

.menu-toggle svg {
    width: 20px;
    height: 20px;
}

.page-title {
    font-size: 18px;
    font-weight: 600;
    letter-spacing: -0.02em;
}

.page-subtitle {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 2px;
}

.content {
    flex: 1;
    padding: 24px;
    max-width: 1400px;
    width: 100%;
}

.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    margin-bottom: 20px;
    border: 1px solid transparent;
}

.alert-success {
    background: var(--success-bg);
    border-color: rgba(34, 197, 94, 0.3);
    color: #86efac;
}

.alert-error {
    background: var(--danger-bg);
    border-color: rgba(239, 68, 68, 0.3);
    color: #fca5a5;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.stat-label {
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 500;
}

.stat-value {
    font-size: 32px;
    font-weight: 700;
    letter-spacing: -0.03em;
    line-height: 1;
}

.stat-value.online { color: var(--success); }
.stat-value.offline { color: var(--danger); }
.stat-value.primary { color: var(--primary); }

.stat-hint {
    font-size: 12px;
    color: var(--text-dim);
}

.panel-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 20px;
}

.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.card-header {
    padding: 18px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.card-title {
    font-size: 15px;
    font-weight: 600;
}

.card-body {
    padding: 20px;
}

.info-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.info-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    font-size: 14px;
}

.info-list .label {
    color: var(--text-muted);
}

.info-list .value {
    font-weight: 500;
    text-align: right;
    word-break: break-all;
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
}

.badge-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
}

.badge-online {
    background: var(--success-bg);
    color: var(--success);
}

.badge-online .badge-dot {
    background: var(--success);
    box-shadow: 0 0 8px var(--success);
}

.badge-offline {
    background: var(--danger-bg);
    color: var(--danger);
}

.badge-offline .badge-dot {
    background: var(--danger);
}

.badge-inactive {
    background: rgba(100, 116, 139, 0.15);
    color: var(--text-muted);
}

.badge-inactive .badge-dot {
    background: var(--text-dim);
}

.badge-active {
    background: var(--success-bg);
    color: var(--success);
}

.badge-paused {
    background: var(--warning-bg);
    color: var(--warning);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    font-family: inherit;
    border: none;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s, transform 0.1s;
}

.btn:active {
    transform: scale(0.98);
}

.btn-primary {
    background: var(--primary);
    color: #fff;
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-secondary {
    background: var(--bg-hover);
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    border-color: var(--border-strong);
}

.btn-danger {
    background: var(--danger-bg);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.25);
}

.btn-danger:hover {
    background: rgba(239, 68, 68, 0.2);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
}

.btn-icon {
    padding: 8px;
    min-width: 36px;
}

.toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-card);
}

table.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

table.data-table th,
table.data-table td {
    padding: 14px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

table.data-table th {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    background: rgba(0, 0, 0, 0.2);
}

table.data-table tr:last-child td {
    border-bottom: none;
}

table.data-table tr:hover td {
    background: rgba(255, 255, 255, 0.02);
}

.cell-url {
    font-family: ui-monospace, monospace;
    font-size: 12px;
    color: var(--text-muted);
    max-width: 280px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.form-grid {
    display: grid;
    gap: 16px;
}

.form-grid.cols-2 {
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 6px;
}

input[type="text"],
input[type="password"],
input[type="url"],
input[type="number"] {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.15s, box-shadow 0.15s;
}

input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

.form-hint {
    font-size: 12px;
    color: var(--text-dim);
    margin-top: 6px;
}

.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-muted);
}

.empty-state p {
    margin-bottom: 16px;
}

.modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 300;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal.open {
    display: flex;
}

.modal-dialog {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    width: 100%;
    max-width: 480px;
    box-shadow: var(--shadow);
}

.modal-header {
    padding: 18px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-header h3 {
    font-size: 16px;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 22px;
    line-height: 1;
    padding: 4px;
}

.modal-body {
    padding: 20px;
}

.modal-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

code, .code-block {
    font-family: ui-monospace, monospace;
    font-size: 12px;
    background: var(--bg);
    padding: 2px 8px;
    border-radius: 4px;
    border: 1px solid var(--border);
}

.code-block {
    display: block;
    padding: 12px 14px;
    word-break: break-all;
    margin-top: 8px;
}

.status-ok {
    color: var(--success);
}

.status-warn {
    color: var(--warning);
}

.auth-page {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 1fr 1fr;
}

.auth-hero {
    background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 50%, #0b0f17 100%);
    padding: 48px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.auth-hero::before {
    content: '';
    position: absolute;
    width: 500px;
    height: 500px;
    border-radius: 50%;
    background: radial-gradient(circle, var(--primary-glow) 0%, transparent 70%);
    top: -100px;
    right: -100px;
    pointer-events: none;
}

.auth-hero-content {
    position: relative;
    z-index: 1;
    max-width: 480px;
}

.auth-hero .logo-mark {
    width: 56px;
    height: 56px;
    border-radius: 14px;
    background: linear-gradient(135deg, var(--primary), #6366f1);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 32px;
}

.auth-hero .logo-mark svg {
    width: 28px;
    height: 28px;
    color: #fff;
}

.auth-hero h1 {
    font-size: 36px;
    font-weight: 700;
    letter-spacing: -0.03em;
    line-height: 1.15;
    margin-bottom: 16px;
}

.auth-hero .lead {
    font-size: 16px;
    color: var(--text-muted);
    line-height: 1.6;
    margin-bottom: 40px;
}

.feature-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.feature-list li {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    font-size: 14px;
    color: var(--text-muted);
}

.feature-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: rgba(59, 130, 246, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.feature-icon svg {
    width: 18px;
    height: 18px;
    color: var(--primary);
}

.feature-list strong {
    display: block;
    color: var(--text);
    font-weight: 600;
    margin-bottom: 2px;
}

.auth-panel {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 48px 32px;
    background: var(--bg);
}

.auth-form-wrap {
    width: 100%;
    max-width: 400px;
}

.auth-form-wrap h2 {
    font-size: 24px;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-bottom: 8px;
}

.auth-form-wrap .subtitle {
    color: var(--text-muted);
    font-size: 14px;
    margin-bottom: 32px;
}

.auth-form .form-group {
    margin-bottom: 20px;
}

.auth-form .btn-primary {
    width: 100%;
    padding: 12px;
    margin-top: 8px;
}

.auth-meta {
    margin-top: 32px;
    padding-top: 24px;
    border-top: 1px solid var(--border);
}

.auth-meta p {
    font-size: 12px;
    color: var(--text-dim);
    margin-bottom: 8px;
}

@media (max-width: 960px) {
    .auth-page {
        grid-template-columns: 1fr;
    }

    .auth-hero {
        padding: 32px 24px;
        min-height: auto;
    }

    .auth-hero h1 {
        font-size: 28px;
    }

    .feature-list {
        display: none;
    }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

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

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

    .menu-toggle {
        display: flex;
    }

    .content {
        padding: 16px;
    }

    .topbar {
        padding: 0 16px;
    }

    table.data-table th:nth-child(4),
    table.data-table td:nth-child(4) {
        display: none;
    }
}
