:root {
    --ink:          #111827;
    --paper:        #ffffff;
    --line:         #e5e7eb;
    --bg:           #f9fafb;
    --accent:       #3b82f6;
    --accent-soft:  #eff6ff;
    --muted:        #6b7280;
    --positive:     #10b981;
    --warning:      #f59e0b;
    --danger:       #ef4444;
    --body:         'Inter', sans-serif;
    --display:      'Outfit', 'Inter', sans-serif;
    --mono:         'JetBrains Mono', 'Courier New', monospace;
    --radius:       12px;
    --shadow:       0 4px 12px rgba(0,0,0,0.05);
    --sidebar-w:    260px;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--body); font-size: 14px; line-height: 1.55; }

.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }
main { padding: 28px 40px; min-width: 0; overflow-y: auto; }

/* ══════════════════════════
   SIDEBAR
══════════════════════════ */
aside.side {
    background: var(--paper);
    border-right: 1px solid var(--line);
    position: sticky;
    top: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 0;
    overflow: hidden;
}

/* ── Logo ── */
.side-header {
    padding: 24px 20px 20px;
    border-bottom: 1px solid var(--line);
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: var(--display);
    font-size: 20px;
    font-weight: 800;
    letter-spacing: -0.03em;
    color: white;
}

.logo-icon {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, #3b82f6, #6366f1);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 4px 10px rgba(99,102,241,0.4);
}

.logo em {
    font-style: normal;
    background: linear-gradient(90deg, #60a5fa, #a78bfa);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.logo-tagline {
    font-family: var(--mono);
    font-size: 9px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: rgba(255,255,255,0.35);
    margin-top: 6px;
}

/* ── Nav ── */
.side-nav {
    flex: 1;
    overflow-y: auto;
    padding: 12px 10px;
}
.side-nav::-webkit-scrollbar { width: 0; }

.nav-group { margin-bottom: 4px; }

.nav-group-label {
    font-family: var(--mono);
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--muted);
    padding: 8px 10px 4px;
    opacity: 0.7;
}

.nav-divider {
    height: 1px;
    background: var(--line);
    margin: 8px 10px;
    border-radius: 1px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    width: 100%;
    border: none;
    background: transparent;
    border-radius: 8px;
    cursor: pointer;
    color: var(--muted);
    font-family: var(--body);
    font-size: 13.5px;
    font-weight: 500;
    text-align: left;
    transition: all 0.15s;
    margin-bottom: 1px;
    text-decoration: none;
    position: relative;
}
.nav-item:hover {
    background: var(--bg);
    color: var(--ink);
}
.nav-item.active {
    background: var(--accent-soft);
    color: var(--accent);
    font-weight: 600;
}
.nav-item.active .nav-icon { color: var(--accent); }

.nav-icon {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 7px;
    background: rgba(0,0,0,0.04);
    flex-shrink: 0;
    color: var(--muted);
    transition: all 0.15s;
}
.nav-item:hover .nav-icon { background: rgba(59,130,246,0.08); color: var(--accent); }
.nav-item.active .nav-icon { background: rgba(59,130,246,0.12); }

.nav-label { flex: 1; }

.nav-badge {
    background: var(--accent);
    color: white;
    font-family: var(--mono);
    font-size: 9px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 99px;
    display: none;
}
.nav-badge:not(:empty) { display: inline-block; }

.nav-new {
    font-family: var(--mono);
    font-size: 8px;
    font-weight: 700;
    letter-spacing: 0.08em;
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
    padding: 2px 6px;
    border-radius: 4px;
}

.nav-ext {
    color: var(--muted);
    opacity: 0.5;
    flex-shrink: 0;
}

/* ── User card ── */
.side-footer {
    border-top: 1px solid var(--line);
    padding: 14px 10px;
    background: var(--paper);
}

.user-pill {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: 10px;
    transition: background 0.15s;
}
.user-pill:hover { background: #f0f4ff; border-color: var(--accent-soft); }

.avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), #6366f1);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 13px;
    flex-shrink: 0;
    letter-spacing: -0.01em;
    box-shadow: 0 2px 6px rgba(59,130,246,0.3);
}

.user-meta { flex: 1; min-width: 0; }
.user-meta strong {
    display: block;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--ink);
}
.user-meta span {
    display: block;
    font-family: var(--mono);
    font-size: 9px;
    color: var(--muted);
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 0.06em;
    margin-top: 1px;
}

.logout-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--muted);
    padding: 6px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
    flex-shrink: 0;
}
.logout-btn:hover { color: var(--danger); background: #fef2f2; }

/* Header Banner */
.crumb { font-family: var(--mono); font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 8px; }
.banner { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 24px; padding: 32px 40px; background: linear-gradient(135deg, #1e293b, #0f172a); color: white; border-radius: 20px; margin-bottom: 32px; box-shadow: 0 10px 25px -5px rgba(0,0,0,0.1); position: relative; overflow: hidden; }
.banner::after { content: ''; position: absolute; top: -50%; right: -20%; width: 300px; height: 300px; background: radial-gradient(circle, rgba(59, 130, 246, 0.2), transparent 70%); border-radius: 50%; }
.banner h1 { margin: 0 0 8px; font-size: 28px; font-weight: 800; letter-spacing: -0.03em; }
.banner .meta { color: rgba(255,255,255,0.6); font-size: 14px; }
.banner-stats { display: flex; gap: 32px; }
.b-stat .val { font-size: 24px; font-weight: 800; display: block; }
.b-stat .lab { font-size: 11px; color: rgba(255,255,255,0.5); text-transform: uppercase; font-weight: 700; }

/* Sections & Cards */
.section { display: none; }
.section.active { display: block; }

.card { background: var(--paper); border: 1px solid var(--line); border-radius: 16px; padding: 24px; margin-bottom: 24px; box-shadow: var(--shadow); }
.card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.card-title { font-size: 18px; font-weight: 700; letter-spacing: -0.02em; }

/* Grid of Instances */
.instances-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 20px; }
.inst-card { background: var(--paper); border: 1px solid var(--line); border-radius: 16px; padding: 20px; transition: 0.2s; position: relative; }
.inst-card:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: 0 10px 20px rgba(0,0,0,0.05); }
.inst-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 16px; }
.inst-info strong { display: block; font-size: 16px; margin-bottom: 4px; }
.inst-info code { font-family: var(--mono); font-size: 12px; color: var(--muted); background: var(--bg); padding: 2px 6px; border-radius: 4px; }
.inst-status { font-size: 11px; font-weight: 700; text-transform: uppercase; padding: 4px 10px; border-radius: 20px; display: flex; align-items: center; gap: 6px; }
.status-connected { background: #dcfce7; color: #166534; }
.status-disconnected { background: #fee2e2; color: #991b1b; }
.dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.inst-footer { display: flex; gap: 8px; margin-top: 16px; border-top: 1px solid var(--line); padding-top: 16px; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; padding: 10px 18px; border-radius: 8px; font-weight: 600; font-size: 13px; cursor: pointer; transition: 0.2s; border: none; gap: 8px; }
.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover { background: #2563eb; }
.btn-danger { background: var(--danger); color: white; border: none; }
.btn-danger:hover { background: #dc2626; }
.btn-danger-soft { background: #fef2f2; color: var(--danger); border: 1px solid #fee2e2; }
.btn-danger-soft:hover { background: #fee2e2; }
.btn-outline { background: white; color: var(--ink); border: 1px solid var(--line); }
.btn-danger:hover { background: var(--danger); color: white; }
.btn-sm { padding: 6px 12px; font-size: 11px; }

/* Modals */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.5); backdrop-filter: blur(4px); display: flex; align-items: center; justify-content: center; z-index: 1000; }
.modal { background: var(--paper); width: 100%; max-width: 440px; border-radius: 20px; padding: 32px; box-shadow: 0 25px 50px -12px rgba(0,0,0,0.25); }
.modal h2 { margin-top: 0; font-size: 22px; font-weight: 800; letter-spacing: -0.02em; }

.form-group { margin-bottom: 20px; }
.form-group label { display: block; font-weight: 600; margin-bottom: 6px; font-size: 13px; color: var(--muted); }
.form-control, input[type="text"], input[type="email"], input[type="password"], input[type="tel"] { width: 100%; padding: 12px 16px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); font-family: inherit; font-size: 14px; transition: 0.2s; }
.form-control:focus, input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* Billing Table */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th { text-align: left; padding: 12px 16px; font-size: 11px; text-transform: uppercase; color: var(--muted); border-bottom: 1px solid var(--line); }
.data-table td { padding: 16px; border-bottom: 1px solid var(--line); }

/* Empty States */
.empty { padding: 80px 40px; text-align: center; color: var(--muted); }
.empty-icon { font-size: 48px; margin-bottom: 16px; display: block; }

/* Toast */
.toast-container { position: fixed; bottom: 32px; right: 32px; display: flex; flex-direction: column; gap: 8px; z-index: 2000; }
.toast { background: var(--ink); color: white; padding: 12px 24px; border-radius: 12px; font-weight: 600; box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1); animation: slideUp 0.3s ease; }
@keyframes slideUp { from { transform: translateY(100%); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* Spinner */
.spinner { width: 24px; height: 24px; border: 3px solid rgba(0,0,0,0.1); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
