:root {
    --bg-page: #f8fafc;
    --bg-card: #ffffff;
    --border: #e2e8f0;
    --text: #0f172a;
    --muted: #64748b;
    --primary: #3b82f6;
    --primary-dark: #2563eb;
    --success: #10b981;
    --danger: #ef4444;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.06), 0 1px 2px -1px rgb(0 0 0 / 0.06);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.07), 0 2px 4px -2px rgb(0 0 0 / 0.07);
    font-family: 'Inter', system-ui, sans-serif;
}

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

body {
    background: var(--bg-page);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    font-size: 14.5px;
    line-height: 1.55;
}

/* ─── Layout ───────────────────────────────── */

.view {
    display: none;
    min-height: 100vh;
}

#login-view {
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #eff6ff 0%, #e0e7ff 100%);
}

#app-view {
    display: none;
    flex-direction: row;
    height: 100vh;
    overflow: hidden;
}

/* ─── Login Card ───────────────────────────── */

.login-card {
    background: var(--bg-card);
    padding: 2.5rem 2.75rem;
    border-radius: var(--radius-lg);
    width: 380px;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border);
    text-align: center;
}

.logo {
    font-size: 1.85rem;
    font-weight: 700;
    color: var(--primary);
    letter-spacing: -0.03em;
}

.subtitle {
    color: var(--muted);
    font-size: 0.875rem;
    margin-bottom: 2.2rem;
}

/* ─── Forms ────────────────────────────────── */

.input-group {
    text-align: left;
    margin-bottom: 1.25rem;
}

.input-group label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--muted);
    margin-bottom: 0.4rem;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.input-group input,
.select-input {
    width: 100%;
    padding: 0.6rem 0.85rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.9rem;
    color: var(--text);
    background: white;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.input-group input:focus,
.select-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 0.75rem;
}

/* ─── Buttons ──────────────────────────────── */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.55rem 1.1rem;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 500;
    border: none;
    cursor: pointer;
    transition: all 0.15s ease;
    text-decoration: none;
}

.btn.full-width {
    width: 100%;
    justify-content: center;
}

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

.btn.primary:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.btn.text {
    background: transparent;
    color: var(--muted);
}

.btn.text:hover {
    background: #f1f5f9;
    color: var(--text);
}

.btn.danger-text {
    background: transparent;
    color: var(--danger);
    font-size: 0.8rem;
    padding: 0.3rem 0.6rem;
}

.btn.danger-text:hover {
    background: #fee2e2;
}

.btn.text-sm {
    background: transparent;
    color: var(--primary);
    font-size: 0.78rem;
    padding: 0.22rem 0.55rem;
    border: 1px solid #bfdbfe;
    border-radius: var(--radius-sm);
}

.btn.text-sm:hover {
    background: #eff6ff;
    border-color: var(--primary);
}

/* Amber warning button for Disable action */
.btn-warn {
    color: #b45309 !important;
    border-color: #fcd34d !important;
}

.btn-warn:hover {
    background: #fef3c7 !important;
}

/* Disabled client row */
tr.row-disabled td {
    opacity: 0.5;
}

tr.row-disabled td:first-child {
    opacity: 1;
    /* badge stays vivid */
}

/* ─── Sidebar ──────────────────────────────── */

.sidebar {
    width: 240px;
    background: var(--bg-card);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.sidebar-header {
    padding: 1.5rem 1.25rem;
    border-bottom: 1px solid var(--border);
}

.logo-small {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--primary);
    letter-spacing: -0.02em;
}

.sidebar-nav {
    flex: 1;
    padding: 1rem 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.6rem 0.85rem;
    border-radius: var(--radius-md);
    color: var(--muted);
    font-weight: 500;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.15s;
    text-decoration: none;
}

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

.nav-item.active {
    background: #eff6ff;
    color: var(--primary);
    font-weight: 600;
}

.nav-item .icon {
    font-size: 1rem;
    flex-shrink: 0;
}

.sidebar-footer {
    padding: 1.25rem;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.user-info {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text);
}

/* ─── Main Content ─────────────────────────── */

.main-content {
    flex: 1;
    overflow-y: auto;
    padding: 2.25rem 2.75rem;
    background: var(--bg-page);
}

.panel {
    display: none;
    animation: fadeUp 0.25s ease;
}

.panel.active {
    display: block;
}

@keyframes fadeUp {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.75rem;
}

.header h2 {
    font-size: 1.4rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

/* ─── Stat Cards ───────────────────────────── */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.25rem;
    margin-bottom: 1.75rem;
}

.stat-card {
    background: var(--bg-card);
    padding: 1.5rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    transition: box-shadow 0.2s;
}

.stat-card:hover {
    box-shadow: var(--shadow-md);
}

.stat-value {
    font-size: 2.25rem;
    font-weight: 700;
    letter-spacing: -0.04em;
    color: var(--primary);
    line-height: 1;
    margin-bottom: 0.5rem;
}

.stat-label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--muted);
}

/* ─── Cards ────────────────────────────────── */

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

.card-header {
    padding: 1.1rem 1.5rem;
    border-bottom: 1px solid var(--border);
}

.card-header h3 {
    font-size: 0.95rem;
    font-weight: 600;
}

.mt-2 {
    margin-top: 1.75rem;
}

/* ─── Tables ───────────────────────────────── */

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.table th {
    padding: 0.75rem 1.5rem;
    text-align: left;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--muted);
    border-bottom: 1px solid var(--border);
    background: #fafafa;
}

.table td {
    padding: 0.9rem 1.5rem;
    border-bottom: 1px solid var(--border);
}

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

.table tbody tr:hover {
    background: #fafbfc;
}

.empty-row {
    color: var(--muted);
    font-style: italic;
    text-align: center;
    padding: 2rem !important;
}

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

.mono {
    font-family: ui-monospace, monospace;
    font-size: 0.8rem;
}

/* ─── Badges ───────────────────────────────── */

.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.04em;
}

.badge.success {
    background: #dcfce7;
    color: #15803d;
}

.badge.neutral {
    background: #f1f5f9;
    color: #475569;
}

.badge.danger {
    background: #fee2e2;
    color: #b91c1c;
}

.badge.primary-badge {
    background: #dbeafe;
    color: #1d4ed8;
}

/* ─── Code Pills ───────────────────────────── */

.code-pill {
    display: inline-block;
    background: #f1f5f9;
    border: 1px solid var(--border);
    padding: 1px 7px;
    border-radius: 4px;
    font-family: ui-monospace, monospace;
    font-size: 0.8rem;
    color: #475569;
}

/* ─── Modals ───────────────────────────────── */

.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.35);
    backdrop-filter: blur(2px);
    align-items: center;
    justify-content: center;
    z-index: 100;
    animation: fadein 0.15s ease;
}

@keyframes fadein {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.modal {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    width: 520px;
    max-width: 95vw;
    box-shadow: 0 20px 60px rgb(0 0 0 / 0.2);
    border: 1px solid var(--border);
    animation: slideUp 0.2s ease;
}

@keyframes slideUp {
    from {
        transform: translateY(12px);
        opacity: 0;
    }

    to {
        transform: none;
        opacity: 1;
    }
}

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

.modal-header h3 {
    font-size: 1.05rem;
    font-weight: 600;
}

.modal-close {
    background: transparent;
    border: none;
    font-size: 1.1rem;
    cursor: pointer;
    color: var(--muted);
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
}

.modal-close:hover {
    background: #f1f5f9;
}

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
    padding: 1.25rem 1.5rem;
    border-top: 1px solid var(--border);
}

/* ─── Error Message ────────────────────────── */

.error-msg {
    font-size: 0.85rem;
    min-height: 20px;
    color: var(--danger);
}