@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

/* =========================================================
   GosatPlusProxy design tokens
   ========================================================= */
:root {
    --gsp-bg: #f5f6f8;
    --gsp-surface: #ffffff;
    --gsp-surface-alt: #fafbfc;
    --gsp-border: #e5e7eb;
    --gsp-border-strong: #d1d5db;

    --gsp-text: #111827;
    --gsp-text-muted: #6b7280;
    --gsp-text-dim: #9ca3af;

    --gsp-primary: #2563eb;
    --gsp-primary-hover: #1d4ed8;
    --gsp-primary-soft: #eff6ff;
    --gsp-success: #10b981;
    --gsp-success-soft: #ecfdf5;
    --gsp-warning: #f59e0b;
    --gsp-warning-soft: #fffbeb;
    --gsp-danger: #ef4444;
    --gsp-danger-soft: #fef2f2;

    --gsp-sidebar-bg: #0f172a;
    --gsp-sidebar-bg-2: #1e293b;
    --gsp-sidebar-text: #cbd5e1;
    --gsp-sidebar-text-active: #ffffff;
    --gsp-sidebar-active-bg: rgba(59, 130, 246, 0.15);
    --gsp-sidebar-active-border: #3b82f6;

    --gsp-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
    --gsp-shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
    --gsp-shadow-lg: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 4px 10px -3px rgba(0, 0, 0, 0.05);

    --gsp-radius-sm: 0.375rem;
    --gsp-radius: 0.5rem;
    --gsp-radius-lg: 0.75rem;

    --gsp-sidebar-width: 240px;
    --gsp-topbar-height: 60px;
}

/* =========================================================
   Base
   ========================================================= */
*, *::before, *::after { box-sizing: border-box; }

html, body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    background: var(--gsp-bg);
    color: var(--gsp-text);
    font-size: 14px;
    margin: 0;
    line-height: 1.5;
}

code, pre, .font-mono { font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace; }

a { color: var(--gsp-primary); text-decoration: none; }
a:hover { color: var(--gsp-primary-hover); text-decoration: underline; }

h1, h2, h3, h4, h5 { color: var(--gsp-text); font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 1.875rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; }

h1:focus { outline: none; }

/* =========================================================
   Layout: page shell, sidebar, topbar
   ========================================================= */
.gsp-page {
    display: flex;
    min-height: 100vh;
}

.gsp-sidebar {
    width: var(--gsp-sidebar-width);
    flex-shrink: 0;
    background: var(--gsp-sidebar-bg);
    color: var(--gsp-sidebar-text);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; bottom: 0; left: 0;
    z-index: 100;
    overflow-y: auto;
}

.gsp-sidebar-brand {
    height: var(--gsp-topbar-height);
    padding: 0 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.625rem;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    color: #fff;
    font-weight: 700;
    font-size: 1.125rem;
    letter-spacing: -0.02em;
}
.gsp-sidebar-brand .gsp-brand-mark {
    width: 28px; height: 28px;
    border-radius: 6px;
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-weight: 700; font-size: 0.875rem;
}

.gsp-sidebar-section {
    padding: 1rem 0.75rem 0.25rem;
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #64748b;
}

.gsp-sidebar-nav { padding: 0.25rem 0.5rem; }
.gsp-sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.5rem 0.75rem;
    border-radius: var(--gsp-radius-sm);
    color: var(--gsp-sidebar-text);
    font-weight: 500;
    font-size: 0.875rem;
    margin-bottom: 0.125rem;
    transition: background 120ms ease, color 120ms ease;
    border: none;
    background: transparent;
    width: 100%;
    text-align: left;
    cursor: pointer;
}
.gsp-sidebar-nav .nav-link:hover {
    background: rgba(255,255,255,0.04);
    color: #fff;
    text-decoration: none;
}
.gsp-sidebar-nav .nav-link.active {
    background: var(--gsp-sidebar-active-bg);
    color: var(--gsp-sidebar-text-active);
}
.gsp-sidebar-nav .nav-link i,
.gsp-sidebar-nav .nav-link .bi {
    width: 18px; height: 18px;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 1rem;
    color: #94a3b8;
}
.gsp-sidebar-nav .nav-link.active i,
.gsp-sidebar-nav .nav-link.active .bi { color: #60a5fa; }

.gsp-sidebar-footer {
    margin-top: auto;
    padding: 0.75rem;
    border-top: 1px solid rgba(255,255,255,0.06);
}

/* Main content area */
.gsp-main {
    flex: 1;
    margin-left: var(--gsp-sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-width: 0;
}

.gsp-topbar {
    height: var(--gsp-topbar-height);
    background: var(--gsp-surface);
    border-bottom: 1px solid var(--gsp-border);
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    gap: 1rem;
    position: sticky; top: 0; z-index: 50;
}
.gsp-topbar-title { font-weight: 600; font-size: 1rem; color: var(--gsp-text); }
.gsp-topbar-spacer { flex: 1; }
.gsp-topbar-user {
    display: flex; align-items: center; gap: 0.625rem;
    padding: 0.375rem 0.75rem;
    border-radius: var(--gsp-radius);
    background: var(--gsp-surface-alt);
    border: 1px solid var(--gsp-border);
    font-size: 0.875rem;
    color: var(--gsp-text);
}
.gsp-topbar-user .gsp-avatar {
    width: 28px; height: 28px; border-radius: 50%;
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    color: #fff; font-weight: 600; font-size: 0.75rem;
    display: flex; align-items: center; justify-content: center;
}

.gsp-content {
    flex: 1;
    padding: 1.75rem 2rem;
    width: 100%;
}

/* =========================================================
   Page header (title + actions)
   ========================================================= */
.gsp-page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    gap: 1rem;
    flex-wrap: wrap;
}
.gsp-page-header h1, .gsp-page-header h2 {
    margin: 0 0 0.25rem 0;
}
.gsp-page-header .gsp-page-subtitle {
    color: var(--gsp-text-muted);
    font-size: 0.9375rem;
    margin: 0;
}
.gsp-page-header-actions { display: flex; gap: 0.5rem; }

/* =========================================================
   Cards / panels
   ========================================================= */
.gsp-card {
    background: var(--gsp-surface);
    border: 1px solid var(--gsp-border);
    border-radius: var(--gsp-radius);
    box-shadow: var(--gsp-shadow-sm);
    overflow: hidden;
}
.gsp-card-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--gsp-border);
    display: flex; align-items: center; justify-content: space-between;
    background: var(--gsp-surface-alt);
}
.gsp-card-header h3, .gsp-card-header h4 { margin: 0; font-size: 0.9375rem; }
.gsp-card-body { padding: 1.25rem; }
.gsp-card-body.no-padding { padding: 0; }

/* Stat card */
.gsp-stat {
    background: var(--gsp-surface);
    border: 1px solid var(--gsp-border);
    border-radius: var(--gsp-radius);
    padding: 1.125rem 1.25rem;
    box-shadow: var(--gsp-shadow-sm);
    transition: box-shadow 150ms ease;
}
.gsp-stat:hover { box-shadow: var(--gsp-shadow); }
.gsp-stat-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--gsp-text-muted);
    font-weight: 600;
    margin-bottom: 0.375rem;
}
.gsp-stat-value {
    font-size: 1.875rem;
    font-weight: 700;
    color: var(--gsp-text);
    line-height: 1.1;
    letter-spacing: -0.02em;
}
.gsp-stat-meta {
    margin-top: 0.5rem;
    font-size: 0.8125rem;
    color: var(--gsp-text-muted);
}
.gsp-stat-icon {
    float: right;
    width: 36px; height: 36px;
    border-radius: var(--gsp-radius);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.125rem;
    margin-top: -0.25rem;
}
.gsp-stat-icon.primary { background: var(--gsp-primary-soft); color: var(--gsp-primary); }
.gsp-stat-icon.success { background: var(--gsp-success-soft); color: var(--gsp-success); }
.gsp-stat-icon.warning { background: var(--gsp-warning-soft); color: var(--gsp-warning); }
.gsp-stat-icon.danger { background: var(--gsp-danger-soft); color: var(--gsp-danger); }

/* =========================================================
   Tables
   ========================================================= */
.gsp-table-wrap {
    background: var(--gsp-surface);
    border: 1px solid var(--gsp-border);
    border-radius: var(--gsp-radius);
    overflow-x: auto;
    box-shadow: var(--gsp-shadow-sm);
}
.gsp-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}
.gsp-table thead th {
    background: var(--gsp-surface-alt);
    border-bottom: 1px solid var(--gsp-border);
    padding: 0.75rem 1rem;
    text-align: left;
    font-weight: 600;
    color: var(--gsp-text-muted);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    white-space: nowrap;
}
.gsp-table tbody td {
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--gsp-border);
    vertical-align: middle;
    color: var(--gsp-text);
}
.gsp-table tbody tr:hover { background: var(--gsp-surface-alt); }
.gsp-table tbody tr:first-child td { border-top: none; }
.gsp-table .actions { white-space: nowrap; text-align: right; }
.gsp-table-empty {
    padding: 3rem 1rem;
    text-align: center;
    color: var(--gsp-text-muted);
}

/* =========================================================
   Forms
   ========================================================= */
.gsp-form .form-label,
.form-label {
    font-weight: 500;
    color: var(--gsp-text);
    font-size: 0.8125rem;
    margin-bottom: 0.375rem;
    display: block;
}

.form-control, .form-select {
    border: 1px solid var(--gsp-border-strong);
    border-radius: var(--gsp-radius-sm);
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    color: var(--gsp-text);
    background: var(--gsp-surface);
    transition: border-color 120ms ease, box-shadow 120ms ease;
    box-shadow: none;
}
.form-control:focus, .form-select:focus {
    border-color: var(--gsp-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
    outline: none;
}
.form-control::placeholder { color: var(--gsp-text-dim); }

.form-check-input {
    width: 1rem; height: 1rem;
    border: 1px solid var(--gsp-border-strong);
    cursor: pointer;
}
.form-check-input:checked { background-color: var(--gsp-primary); border-color: var(--gsp-primary); }
.form-check-input:focus { border-color: var(--gsp-primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15); }
.form-check-label { font-size: 0.875rem; color: var(--gsp-text); cursor: pointer; }

.valid.modified:not([type=checkbox]) { outline: none; border-color: var(--gsp-success); }
.invalid { outline: none; border-color: var(--gsp-danger); }
.validation-message { color: var(--gsp-danger); font-size: 0.8125rem; margin-top: 0.25rem; }

/* =========================================================
   Buttons
   ========================================================= */
.btn {
    font-weight: 500;
    font-size: 0.875rem;
    border-radius: var(--gsp-radius-sm);
    padding: 0.5rem 0.875rem;
    border: 1px solid transparent;
    transition: all 120ms ease;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    cursor: pointer;
    line-height: 1.3;
}
.btn:focus { box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15); outline: none; }

.btn-sm { padding: 0.3125rem 0.625rem; font-size: 0.8125rem; }
.btn-lg { padding: 0.625rem 1.25rem; font-size: 1rem; }

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

.btn-secondary {
    background: var(--gsp-surface);
    border-color: var(--gsp-border-strong);
    color: var(--gsp-text);
}
.btn-secondary:hover { background: var(--gsp-surface-alt); color: var(--gsp-text); border-color: var(--gsp-border-strong); }

.btn-outline-secondary {
    background: transparent;
    border-color: var(--gsp-border-strong);
    color: var(--gsp-text);
}
.btn-outline-secondary:hover { background: var(--gsp-surface-alt); color: var(--gsp-text); }

.btn-outline-danger {
    background: transparent;
    border-color: #fecaca;
    color: var(--gsp-danger);
}
.btn-outline-danger:hover { background: var(--gsp-danger-soft); color: var(--gsp-danger); border-color: #fca5a5; }

.btn-link {
    background: transparent;
    border-color: transparent;
    color: var(--gsp-primary);
    padding: 0.25rem 0.5rem;
}
.btn-link:hover { background: var(--gsp-primary-soft); color: var(--gsp-primary-hover); text-decoration: none; }

/* =========================================================
   Badges
   ========================================================= */
.gsp-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.1875rem 0.5rem;
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: 9999px;
    border: 1px solid transparent;
}
.gsp-badge.success { background: var(--gsp-success-soft); color: #047857; border-color: #a7f3d0; }
.gsp-badge.danger  { background: var(--gsp-danger-soft);  color: #b91c1c; border-color: #fecaca; }
.gsp-badge.warning { background: var(--gsp-warning-soft); color: #b45309; border-color: #fde68a; }
.gsp-badge.info    { background: var(--gsp-primary-soft); color: var(--gsp-primary); border-color: #bfdbfe; }
.gsp-badge.muted   { background: #f3f4f6; color: var(--gsp-text-muted); border-color: var(--gsp-border); }
/* Distinct colours per wire protocol so newcamd / ext-newcamd / cccam are recognisable at a glance */
.gsp-badge.proto-newcamd { background: #eff6ff; color: #1d4ed8; border-color: #bfdbfe; }
.gsp-badge.proto-extnewcamd { background: #fffbeb; color: #b45309; border-color: #fde68a; }
.gsp-badge.proto-cccam { background: #f5f3ff; color: #6d28d9; border-color: #ddd6fe; }
.gsp-badge .gsp-dot {
    width: 6px; height: 6px; border-radius: 50%; background: currentColor;
}

/* =========================================================
   Modal
   ========================================================= */
.gsp-modal-backdrop {
    position: fixed; inset: 0;
    background: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(2px);
    z-index: 1040;
    animation: gsp-fade-in 120ms ease-out;
}
.gsp-modal {
    position: fixed; inset: 0;
    display: flex; align-items: flex-start; justify-content: center;
    padding: 5vh 1rem 1rem;
    z-index: 1050;
    overflow-y: auto;
    pointer-events: none;
}
.gsp-modal-dialog {
    background: var(--gsp-surface);
    border-radius: var(--gsp-radius-lg);
    box-shadow: var(--gsp-shadow-lg);
    width: 70vw;
    max-width: 100%;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    pointer-events: auto;
    animation: gsp-pop-in 150ms ease-out;
}
.gsp-modal-dialog > form {
    display: flex;
    flex-direction: column;
    min-height: 0;
    max-height: inherit;
}
.gsp-modal-dialog { min-width: 0; }
.gsp-modal-header, .gsp-modal-footer { flex-shrink: 0; }
.gsp-modal-header { gap: 0.75rem; }
.gsp-modal-header h5 { overflow-wrap: anywhere; }
.gsp-modal-body { min-height: 0; overscroll-behavior-y: contain; }
.gsp-modal-footer { flex-wrap: wrap; }
.gsp-modal-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--gsp-border);
    display: flex; align-items: center; justify-content: space-between;
}
.gsp-modal-header h5 { margin: 0; font-size: 1rem; font-weight: 600; }
.gsp-modal-close {
    background: transparent; border: none;
    width: 28px; height: 28px;
    border-radius: var(--gsp-radius-sm);
    color: var(--gsp-text-muted);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    font-size: 1rem;
}
.gsp-modal-close:hover { background: var(--gsp-surface-alt); color: var(--gsp-text); }
.gsp-modal-body { padding: 1.25rem; overflow-y: auto; flex: 1; }
.gsp-modal-footer {
    padding: 0.875rem 1.25rem;
    border-top: 1px solid var(--gsp-border);
    background: var(--gsp-surface-alt);
    display: flex; justify-content: flex-end; gap: 0.5rem;
}

@keyframes gsp-fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes gsp-pop-in {
    from { opacity: 0; transform: translateY(-8px) scale(0.98); }
    to   { opacity: 1; transform: none; }
}

/* =========================================================
   Toast
   ========================================================= */
.gsp-toast-container {
    position: fixed;
    top: 1rem; right: 1rem;
    z-index: 2000;
    display: flex; flex-direction: column; gap: 0.5rem;
    pointer-events: none;
}
.gsp-toast {
    background: var(--gsp-surface);
    border: 1px solid var(--gsp-border);
    border-left: 3px solid var(--gsp-primary);
    border-radius: var(--gsp-radius);
    padding: 0.625rem 1rem;
    box-shadow: var(--gsp-shadow-lg);
    min-width: 280px; max-width: 420px;
    pointer-events: auto;
    animation: gsp-slide-in 180ms ease-out;
    font-size: 0.875rem;
}
.gsp-toast.success { border-left-color: var(--gsp-success); }
.gsp-toast.danger  { border-left-color: var(--gsp-danger);  }
.gsp-toast.warning { border-left-color: var(--gsp-warning); }
.gsp-toast-title { font-weight: 600; margin-bottom: 0.125rem; }
.gsp-toast-body { color: var(--gsp-text-muted); }
@keyframes gsp-slide-in { from { transform: translateX(20px); opacity: 0; } to { transform: none; opacity: 1; } }

/* =========================================================
   Login page
   ========================================================= */
.gsp-login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background:
        radial-gradient(ellipse 80% 50% at 50% -20%, rgba(59,130,246,0.18), transparent 70%),
        radial-gradient(ellipse 60% 50% at 100% 100%, rgba(139,92,246,0.12), transparent 70%),
        #0f172a;
    color: #e2e8f0;
    padding: 2rem 1rem;
}
.gsp-login-card {
    width: 100%;
    max-width: 400px;
    background: rgba(15, 23, 42, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--gsp-radius-lg);
    padding: 2.25rem 2rem;
    box-shadow: 0 30px 60px -20px rgba(0,0,0,0.5);
    backdrop-filter: blur(20px);
}
.gsp-login-brand {
    display: flex; align-items: center; gap: 0.625rem;
    margin-bottom: 1.5rem;
}
.gsp-login-brand .gsp-brand-mark {
    width: 36px; height: 36px;
    border-radius: 8px;
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-weight: 700;
}
.gsp-login-title { font-size: 1.25rem; font-weight: 600; color: #fff; }
.gsp-login-subtitle { color: #94a3b8; font-size: 0.875rem; margin-bottom: 1.5rem; }
.gsp-login-card .form-label { color: #cbd5e1; font-size: 0.8125rem; }
.gsp-login-card .form-control {
    background: rgba(255,255,255,0.05);
    border-color: rgba(255,255,255,0.12);
    color: #fff;
}
.gsp-login-card .form-control::placeholder { color: #64748b; }
.gsp-login-card .form-control:focus {
    background: rgba(255,255,255,0.08);
    border-color: var(--gsp-primary);
    box-shadow: 0 0 0 3px rgba(59,130,246,0.25);
}
.gsp-login-card .btn-primary { width: 100%; padding: 0.625rem 1rem; font-size: 0.9375rem; }
.gsp-login-error {
    background: rgba(239, 68, 68, 0.12);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #fca5a5;
    padding: 0.625rem 0.875rem;
    border-radius: var(--gsp-radius-sm);
    font-size: 0.8125rem;
    margin-bottom: 1rem;
}
.gsp-login-footer { color: #64748b; font-size: 0.75rem; text-align: center; margin-top: 1.25rem; }

/* =========================================================
   Misc
   ========================================================= */
.gsp-empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--gsp-text-muted);
}
.gsp-empty-state .bi { font-size: 2rem; margin-bottom: 0.5rem; opacity: 0.5; }

.gsp-toolbar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}
.gsp-toolbar .gsp-search {
    position: relative; flex: 1; max-width: 320px;
}
.gsp-toolbar .gsp-search input {
    padding-left: 2rem;
}
.gsp-toolbar .gsp-search .bi {
    position: absolute; left: 0.625rem; top: 50%; transform: translateY(-50%);
    color: var(--gsp-text-muted);
    font-size: 0.875rem;
    pointer-events: none;
}

.text-muted { color: var(--gsp-text-muted) !important; }
.text-mono { font-family: 'JetBrains Mono', monospace; font-size: 0.8125rem; }

.blazor-error-boundary {
    background: var(--gsp-danger-soft);
    border: 1px solid #fca5a5;
    color: #b91c1c;
    padding: 0.75rem 1rem;
    border-radius: var(--gsp-radius);
    margin: 1rem;
}
.blazor-error-boundary::after { content: "Something went wrong while rendering this component."; }

#blazor-error-ui {
    background: #1e293b; color: #fff;
    bottom: 0; box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.2);
    display: none; left: 0; padding: 0.75rem 1.25rem; position: fixed;
    width: 100%; z-index: 1000;
}
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: 1rem; top: 0.75rem; }

/* Stacked sections within a page (Smart Routing, multi-table layouts) */
.gsp-section {
    margin-top: 1.75rem;
}
.gsp-section:first-of-type {
    margin-top: 1rem;
}
.gsp-section-header {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    margin-bottom: 0.75rem;
}
.gsp-section-header h2 {
    font-size: 1.05rem;
    font-weight: 600;
    margin: 0;
    color: var(--gsp-text);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.gsp-section-header h2 i {
    color: var(--gsp-primary);
}
.gsp-section-subtitle {
    font-size: 0.8125rem;
    color: var(--gsp-text-muted);
    line-height: 1.5;
}

/* Row-state highlights for tables (Smart Routing & similar) */
.gsp-table tbody tr.gsp-row-warning {
    background: rgba(234, 179, 8, 0.08);
}
.gsp-table tbody tr.gsp-row-muted td {
    color: var(--gsp-text-muted);
}

/* Mobile sidebar toggle (hamburger) — hidden on desktop, shown on mobile by the
   media query below. The backdrop sits between sidebar and main; clicking it closes. */
.gsp-sidebar-toggle {
    display: none;
    background: transparent;
    border: 1px solid var(--gsp-border);
    border-radius: var(--gsp-radius-sm);
    width: 36px; height: 36px;
    align-items: center; justify-content: center;
    color: var(--gsp-text);
    cursor: pointer;
    padding: 0;
}
.gsp-sidebar-toggle:hover { background: var(--gsp-surface-alt); }
.gsp-sidebar-toggle .bi { font-size: 1.25rem; }

.gsp-sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    z-index: 90;
    opacity: 0;
    transition: opacity 200ms ease;
}
.gsp-sidebar-backdrop.visible { opacity: 1; }

body.gsp-no-scroll, body.gsp-modal-open { overflow: hidden; }

/* Keep dense tables usable at tablet widths; phones get labeled record layouts. */
.gsp-content > *, .gsp-card-body, .gsp-page-header > *, .gsp-toolbar > * { min-width: 0; }
.gsp-page-header-actions { flex-wrap: wrap; align-items: center; }
.gsp-card-header { gap: 0.75rem; flex-wrap: wrap; }
.gsp-card-body, .gsp-page-subtitle, .gsp-stat { overflow-wrap: anywhere; }
.gsp-pagination { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 0.75rem; margin-top: 1rem; }
.gsp-pagination-summary, .gsp-pagination-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 0.375rem; }
.gsp-pagination-controls .btn { justify-content: center; }
.gsp-form-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.75rem; }
.gsp-form-actions > div { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.gsp-ca-id-row { display: flex; gap: 0.5rem; align-items: end; }
.gsp-ca-id-row > div { flex: 1; min-width: 0; }
.gsp-table .actions .btn { vertical-align: middle; }
button:focus-visible, a:focus-visible, summary:focus-visible { outline: 2px solid var(--gsp-primary); outline-offset: 3px; }

@media (max-width: 1023px) {
    .gsp-sidebar { transform: translateX(-100%); transition: transform 200ms ease; }
    .gsp-sidebar.open { transform: none; }
    .gsp-main { margin-left: 0; }
    .gsp-content { padding: 1.25rem; }
    .gsp-sidebar-toggle { display: inline-flex; }
    .gsp-sidebar-backdrop.visible { display: block; }
    .gsp-sidebar:not(.open) { visibility: hidden; }
    .gsp-sidebar.open { visibility: visible; }
    .gsp-sidebar { width: min(300px, calc(100vw - 3rem)); }
    .gsp-sidebar-nav .nav-link { min-height: 44px; }
}

@media (max-width: 767px) {
    html, body { font-size: 16px; }
    .gsp-content { padding: 1rem max(0.875rem, env(safe-area-inset-right)) max(1rem, env(safe-area-inset-bottom)) max(0.875rem, env(safe-area-inset-left)); }
    .gsp-topbar { padding: 0 0.875rem; gap: 0.5rem; }
    .gsp-topbar-user { min-width: 0; max-width: calc(100% - 4rem); }
    .gsp-topbar-user > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .gsp-avatar { flex-shrink: 0; }
    h1 { font-size: 1.5rem; }
    .gsp-page-header { gap: 0.875rem; }
    .gsp-page-header > div, .gsp-page-header-actions { width: 100%; }
    .gsp-page-header-actions > .btn { flex: 1 1 auto; justify-content: center; }
    .gsp-page-header-actions .form-select { max-width: 100%; }
    .gsp-toolbar { align-items: stretch; gap: 0.75rem; }
    .gsp-toolbar .gsp-search { flex-basis: 100%; max-width: none; }
    .gsp-toolbar > .d-flex { width: 100%; flex-wrap: wrap; margin-left: 0 !important; }
    .gsp-toolbar .form-select { max-width: 100%; flex: 1 1 auto; }
    .gsp-toolbar .form-check { margin-right: 0 !important; }
    .gsp-card-body { padding: 1rem; }
    .gsp-card-header { padding: 0.875rem 1rem; }

    /* Preserve every field and action rather than clipping the right-hand columns. */
    .gsp-table-mobile, .gsp-table-mobile tbody { display: block; width: 100%; }
    .gsp-table-mobile thead {
        position: absolute;
        width: 1px; height: 1px;
        padding: 0; margin: -1px;
        overflow: hidden; clip-path: inset(50%); white-space: nowrap;
    }
    .gsp-table-mobile tbody tr {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0.75rem 1rem;
        padding: 1rem;
        border-top: 1px solid var(--gsp-border-strong);
    }
    .gsp-table-mobile tbody tr:first-child { border-top: 0; }
    .gsp-table-mobile tbody td {
        display: block;
        min-width: 0;
        padding: 0;
        border: 0;
        text-align: left !important;
        overflow-wrap: anywhere;
        white-space: normal;
    }
    .gsp-table-mobile td[data-label]::before {
        content: attr(data-label);
        display: block;
        margin-bottom: 0.2rem;
        color: var(--gsp-text-muted);
        font: 500 0.75rem/1.4 'Inter', sans-serif;
    }
    .gsp-table-mobile td:first-child, .gsp-table-mobile td[colspan],
    .gsp-table-mobile td[data-label="Actions"] { grid-column: 1 / -1; }
    .gsp-table-mobile td[data-label="Actions"] {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        gap: 0.5rem;
        padding-top: 0.75rem;
        border-top: 1px solid var(--gsp-border);
    }
    .gsp-table-mobile td[data-label="Actions"]::before { flex-basis: 100%; }
    .gsp-table-mobile .gsp-badge { max-width: 100%; white-space: normal; }
    .gsp-table-mobile td.gsp-table-empty { padding: 1.5rem 0; }

    /* The form must participate in flex sizing so only its body scrolls. */
    .gsp-modal { padding: 0.5rem; height: var(--gsp-viewport-height, 100dvh); }
    .gsp-modal-dialog { width: 100%; max-height: calc(var(--gsp-viewport-height, 100dvh) - 1rem); }
    .gsp-modal-header, .gsp-modal-body, .gsp-modal-footer { padding: 1rem; }
    .gsp-modal-footer { padding-bottom: max(1rem, env(safe-area-inset-bottom)); }
    .gsp-modal-footer > .btn { flex: 1; justify-content: center; }
    .gsp-modal .gsp-table-mobile tbody tr { grid-template-columns: minmax(0, 1fr); padding: 1rem 0; }
    .gsp-modal .gsp-table-mobile td .form-control { width: 100% !important; }
    .gsp-modal-body .d-flex { min-width: 0; }
    .gsp-modal-body .d-flex:not(.flex-column) { flex-wrap: wrap; }
    .gsp-ca-id-row { flex-wrap: wrap; }
    .gsp-ca-id-row > div { flex-basis: 100%; }
    .gsp-pagination-summary { width: 100%; justify-content: space-between; }
    .gsp-pagination-controls { width: 100%; justify-content: center; flex-wrap: nowrap; }
    .gsp-pagination-controls .btn { padding-inline: 0.5rem; }
    .gsp-pagination-controls span { min-width: 0; font-size: 0.75rem; }
    .gsp-form-actions > div { width: 100%; }
    .gsp-form-actions .btn { flex: 1; justify-content: center; }
    .gsp-toast-container { left: 0.75rem; right: 0.75rem; top: max(0.75rem, env(safe-area-inset-top)); }
    .gsp-toast { min-width: 0; max-width: 100%; overflow-wrap: anywhere; }
    .gsp-login-card { padding: 1.5rem; }
    .gsp-login-page { min-height: 100dvh; padding: 1rem; }
    input.form-control, textarea.form-control, select.form-select { font-size: 1rem !important; min-height: 44px; }
    .btn, .btn-sm, .btn-link, .gsp-sidebar-toggle, .gsp-modal-close { min-height: 44px; min-width: 44px; }
    .gsp-modal-close, .gsp-sidebar-toggle { flex-shrink: 0; }
    .form-check { min-height: 44px; padding-top: 0.5rem; padding-bottom: 0.5rem; }
    .form-check-label { display: inline-block; min-height: 28px; }
    .form-check-input { width: 1.25rem; height: 1.25rem; }
    .form-switch .form-check-input { width: 2.5rem; }
}

@media (pointer: coarse) {
    .btn, .btn-sm, .btn-link, .gsp-modal-close, .gsp-sidebar-toggle { min-height: 44px; min-width: 44px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
