:root {
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.25rem;
    --space-6: 1.5rem;
    --space-7: 2rem;
    --space-8: 3rem;

    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-pill: 999px;

    --text-xs: 0.75rem;
    --text-sm: 0.8125rem;
    --text-base: 0.875rem;
    --text-md: 1rem;
    --text-lg: 1.125rem;
    --text-xl: 1.375rem;
    --text-2xl: 1.75rem;

    --text-label: var(--text-md);
    --text-note: var(--text-md);
    --text-meta: var(--text-base);

    --weight-normal: 400;
    --weight-medium: 500;
    --weight-semibold: 600;
    --weight-bold: 700;

    --leading-tight: 1.25;
    --leading-normal: 1.5;

    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04), 0 1px 3px rgba(15, 23, 42, 0.06);
    --shadow-md: 0 2px 4px rgba(15, 23, 42, 0.04), 0 4px 12px rgba(15, 23, 42, 0.08);
    --shadow-lg: 0 8px 16px rgba(15, 23, 42, 0.08), 0 16px 40px rgba(15, 23, 42, 0.12);

    --bg-body: #f6f7f9;
    --bg-card: #ffffff;
    --bg-main: #ffffff;
    --bg-subtle: #f8fafc;
    --bg-hover: #f1f5f9;
    --bg-sidebar: #1e293b;
    --bg-sidebar-hover: rgba(255, 255, 255, 0.07);
    --bg-sidebar-active: rgba(255, 255, 255, 0.12);

    --text-main: #1e293b;
    --text-muted: #334155;
    --text-subtle: #64748b;
    --text-light: #f8fafc;
    --text-inverse: #ffffff;

    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --primary-subtle: #eef2ff;
    --primary-border: #c7d2fe;

    --secondary: #0ea5e9;

    --success: #059669;
    --success-subtle: #ecfdf5;
    --success-border: #a7f3d0;

    --danger: #dc2626;
    --danger-hover: #b91c1c;
    --danger-subtle: #fef2f2;
    --danger-border: #fecaca;

    --warning: #d97706;
    --warning-subtle: #fffbeb;
    --warning-border: #fde68a;

    --info: #2563eb;
    --info-subtle: #eff6ff;
    --info-border: #bfdbfe;
    --accent: #f59e0b;

    --border-color: #e2e8f0;
    --border-strong: #cbd5e1;

    --focus-ring: 0 0 0 3px rgba(79, 70, 229, 0.35);
    --sidebar-width: 260px;
    --content-max: 1400px;
    --transition: 150ms cubic-bezier(0.4, 0, 0.2, 1);

    --font-sans: 'Plus Jakarta Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    --font-mono: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace;
}

*:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
    border-radius: var(--radius-sm);
}

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

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

code,
kbd,
pre,
.mono {
    font-family: var(--font-mono);
    font-size: var(--text-meta);
}

.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--space-4);
    margin-bottom: var(--space-6);
    flex-wrap: wrap;
}

.page-title-row {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.page-title {
    margin: 0;
    font-size: var(--text-2xl);
    font-weight: var(--weight-bold);
    line-height: var(--leading-tight);
    letter-spacing: -0.02em;
    color: var(--text-main);
}

.page-subtitle {
    margin: var(--space-2) 0 0;
    font-size: var(--text-note);
    color: var(--text-muted);
    max-width: 68ch;
}

.page-actions {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    flex-wrap: wrap;
}

.breadcrumb {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    margin-bottom: var(--space-3);
    font-size: var(--text-note);
    color: var(--text-muted);
}

.breadcrumb a {
    color: var(--text-muted);
    text-decoration: none;
}

.breadcrumb a:hover {
    color: var(--primary);
}

.page-header + .page-tabs {
    margin-top: calc(var(--space-2) - var(--space-6));
}

.page-tabs {
    display: flex;
    align-items: center;
    gap: var(--space-1);
    margin: 0 0 var(--space-6);
    padding: 0;
    list-style: none;
    border-bottom: 1px solid var(--border-color);
    overflow-x: auto;
    overflow-y: hidden;
}

.page-tab {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-4);
    margin-bottom: -1px;
    border: none;
    border-bottom: 2px solid transparent;
    background: none;
    font-size: var(--text-md);
    font-weight: var(--weight-medium);
    color: var(--text-muted);
    text-decoration: none;
    white-space: nowrap;
    transition: color 0.15s ease, border-color 0.15s ease;
}

.page-tab:hover {
    color: var(--text-main);
    border-bottom-color: var(--border-strong);
}

.page-tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.page-tab:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
    border-radius: var(--radius-sm);
}

.card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: var(--space-6);
    margin-bottom: var(--space-6);
}

.card-flush {
    padding: 0;
    overflow: hidden;
}

.card-header {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    margin: 0 0 var(--space-5);
    font-size: var(--text-lg);
    font-weight: var(--weight-semibold);
    color: var(--text-main);
}

.card-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    margin-bottom: var(--space-5);
    flex-wrap: wrap;
}

.card-header-row .card-header {
    margin-bottom: 0;
}

.card-flush .card-header-row .card-header {
    padding: 0;
    border-bottom: none;
}

.card-description {
    margin: calc(-1 * var(--space-3)) 0 var(--space-5);
    font-size: var(--text-note);
    color: var(--text-muted);
    max-width: 72ch;
}

.card-flush .card-header,
.card-flush .card-header-row {
    padding: var(--space-5) var(--space-6);
    margin-bottom: 0;
    border-bottom: 1px solid var(--border-color);
}

.card-toolbar {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-4) var(--space-6);
    background-color: var(--bg-subtle);
    border-bottom: 1px solid var(--border-color);
}

.card-toolbar > .form-control {
    flex: 1;
}

.card-body {
    padding: var(--space-6);
}

.card-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: var(--space-2);
    padding-top: var(--space-5);
    margin-top: var(--space-5);
    border-top: 1px solid var(--border-color);
}

.section-divider {
    height: 1px;
    background-color: var(--border-color);
    border: none;
    margin: var(--space-6) 0;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    height: 42px;
    padding: 0 var(--space-5);
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: var(--text-base);
    font-weight: var(--weight-semibold);
    line-height: 1;
    white-space: nowrap;
    text-decoration: none;
    cursor: pointer;
    box-sizing: border-box;
    transition: background-color var(--transition), border-color var(--transition), color var(--transition);
}

.btn:disabled,
.btn[aria-disabled="true"],
.btn.is-loading {
    opacity: 0.55;
    pointer-events: none;
}

.btn-sm {
    height: 32px;
    padding: 0 var(--space-3);
    font-size: var(--text-meta);
}

.btn-lg {
    height: 46px;
    padding: 0 var(--space-6);
    font-size: var(--text-md);
}

.btn-block {
    width: 100%;
}

.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
}

.btn-primary {
    background-color: var(--primary);
    color: var(--text-inverse);
    box-shadow: 0 4px 10px rgba(79, 70, 229, 0.3);
}

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

.btn-secondary {
    background-color: var(--bg-subtle);
    border-color: var(--border-strong);
    color: var(--text-main);
}

.btn-secondary:hover {
    background-color: var(--bg-hover);
}

.btn-outline {
    background-color: transparent;
    border-color: var(--border-strong);
    color: var(--text-main);
}

.btn-outline:hover {
    background-color: var(--bg-hover);
    border-color: var(--text-subtle);
}

.btn-success {
    background-color: var(--success);
    color: var(--text-inverse);
    box-shadow: 0 4px 10px rgba(5, 150, 105, 0.3);
}

.btn-success:hover {
    background-color: #047857;
}

.btn-danger {
    background-color: var(--danger);
    color: var(--text-inverse);
}

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

.btn-danger-outline {
    background-color: transparent;
    border-color: var(--danger-border);
    color: var(--danger);
}

.btn-danger-outline:hover {
    background-color: var(--danger-subtle);
}

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

.btn-ghost:hover {
    background-color: var(--bg-hover);
    color: var(--text-main);
}

.btn-group {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    flex-wrap: wrap;
}

.form-group {
    margin-bottom: var(--space-5);
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: var(--space-4);
}
.form-row-4 {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}
@media (max-width: 992px) {
    .form-row-4 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}
@media (max-width: 640px) {
    .form-row-4 {
        grid-template-columns: minmax(0, 1fr);
    }
}

.filter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: var(--space-4);
    align-items: end;
}

.filter-grid label {
    font-size: var(--text-meta);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.filter-actions {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

/* Label on the left, control on the right — one field per line. */
.form-line {
    display: grid;
    grid-template-columns: 200px minmax(0, 1fr);
    gap: var(--space-4);
    align-items: start;
    margin-bottom: var(--space-5);
}

.form-line > label,
.form-line > .form-label {
    margin-bottom: 0;
    padding-top: 10px;
}

.form-line-field {
    max-width: 420px;
}

.form-line-field-sm {
    max-width: 120px;
}

.form-line-field-wide {
    max-width: none;
}

.form-line-field .form-hint:first-child {
    margin-top: 0;
}

label,
.form-label {
    display: block;
    margin-bottom: var(--space-2);
    font-size: var(--text-label);
    font-weight: var(--weight-semibold);
    color: var(--text-main);
}

.form-hint {
    margin-top: var(--space-2);
    font-size: var(--text-note);
    color: var(--text-muted);
}

.form-error {
    margin-top: var(--space-2);
    font-size: var(--text-note);
    font-weight: var(--weight-medium);
    color: var(--danger);
}

.required-mark {
    color: var(--danger);
    margin-left: 2px;
}

input[type="text"],
input[type="password"],
input[type="number"],
input[type="email"],
input[type="tel"],
input[type="url"],
input[type="search"],
input[type="date"],
select,
textarea,
.form-input,
.form-control {
    width: 100%;
    height: 40px;
    padding: 0 var(--space-3);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    background-color: var(--bg-card);
    color: var(--text-main);
    font-family: inherit;
    font-size: var(--text-base);
    line-height: var(--leading-normal);
    box-sizing: border-box;
    appearance: none;
    -webkit-appearance: none;
    transition: border-color var(--transition), box-shadow var(--transition);
}

textarea,
textarea.form-input,
textarea.form-control {
    height: auto;
    min-height: 96px;
    padding: var(--space-3);
    resize: vertical;
}

select {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%2364748b' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right var(--space-3) center;
    background-size: 1.15rem;
    padding-right: var(--space-8);
}

input:focus,
select:focus,
textarea:focus,
.form-input:focus,
.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: var(--focus-ring);
}

input:disabled,
select:disabled,
textarea:disabled {
    background-color: var(--bg-hover);
    color: var(--text-muted);
    cursor: not-allowed;
}

input::placeholder,
textarea::placeholder {
    color: var(--text-subtle);
}

.input-group {
    display: flex;
    align-items: stretch;
    gap: var(--space-2);
}

.input-group .btn {
    flex-shrink: 0;
}

.checkbox-row {
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    margin-bottom: var(--space-3);
}

.checkbox-row input[type="checkbox"],
.checkbox-row input[type="radio"] {
    width: 18px;
    height: 18px;
    margin: 2px 0 0;
    flex-shrink: 0;
    accent-color: var(--primary);
    cursor: pointer;
}

.checkbox-row label {
    margin-bottom: 0;
    font-weight: var(--weight-medium);
    cursor: pointer;
}

.limit-list {
    display: flex;
    flex-direction: column;
}

.limit-row {
    display: grid;
    grid-template-columns: minmax(180px, 280px) 1fr;
    align-items: center;
    gap: var(--space-4);
    padding: var(--space-4) 0;
    border-bottom: 1px solid var(--border-color);
}

.limit-row:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.limit-row > label {
    margin-bottom: 0;
    font-size: var(--text-md);
}

.limit-choices {
    display: flex;
    align-items: center;
    gap: var(--space-6);
    flex-wrap: wrap;
}

.limit-choice {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    margin-bottom: 0;
    font-size: var(--text-md);
    font-weight: var(--weight-medium);
    cursor: pointer;
}

.limit-choice input[type="radio"] {
    width: 18px;
    height: 18px;
    margin: 0;
    flex-shrink: 0;
    accent-color: var(--primary);
    cursor: pointer;
}

.limit-choice .form-control {
    width: 150px;
}

.limit-choice input[type="radio"]:not(:checked) + .form-control {
    background-color: var(--bg-hover);
    color: var(--text-muted);
}

@media (max-width: 640px) {
    .limit-row {
        grid-template-columns: 1fr;
        gap: var(--space-3);
    }
}

.table-wrap {
    width: 100%;
    overflow-x: auto;
    border-radius: var(--radius-lg);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--text-base);
}

.data-table th {
    padding: var(--space-3) var(--space-4);
    background-color: var(--bg-subtle);
    border-bottom: 1px solid var(--border-color);
    font-size: var(--text-meta);
    font-weight: var(--weight-semibold);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    text-align: left;
    white-space: nowrap;
}

.data-table td {
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--border-color);
    color: var(--text-main);
    vertical-align: middle;
}

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

.data-table tbody tr:hover {
    background-color: var(--bg-subtle);
}

.data-table tbody tr.row-muted td {
    opacity: 0.55;
}

.data-table .cell-actions {
    text-align: right;
    white-space: nowrap;
}

.data-table .cell-numeric {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.data-table .cell-primary {
    font-weight: var(--weight-semibold);
}

.detail-list {
    display: grid;
    grid-template-columns: minmax(8rem, max-content) minmax(0, 1fr);
    gap: var(--space-3) var(--space-5);
    margin: 0;
    align-items: baseline;
}

.detail-list dt {
    font-size: var(--text-meta);
    font-weight: var(--weight-semibold);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.detail-list dd {
    margin: 0;
    font-size: var(--text-md);
    color: var(--text-main);
    word-break: break-word;
}

@media (max-width: 640px) {
    .detail-list {
        grid-template-columns: minmax(0, 1fr);
        gap: var(--space-1);
    }

    .detail-list dd {
        margin-bottom: var(--space-3);
    }
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    padding: 3px var(--space-2);
    border: 1px solid transparent;
    border-radius: var(--radius-pill);
    font-size: var(--text-meta);
    font-weight: var(--weight-semibold);
    line-height: 1.4;
    white-space: nowrap;
}

.badge-neutral {
    background-color: var(--bg-hover);
    border-color: var(--border-color);
    color: var(--text-muted);
}

.badge-success {
    background-color: var(--success-subtle);
    border-color: var(--success-border);
    color: var(--success);
}

.badge-danger {
    background-color: var(--danger-subtle);
    border-color: var(--danger-border);
    color: var(--danger);
}

.badge-warning {
    background-color: var(--warning-subtle);
    border-color: var(--warning-border);
    color: var(--warning);
}

.badge-info {
    background-color: var(--info-subtle);
    border-color: var(--info-border);
    color: var(--info);
}

.badge-primary {
    background-color: var(--primary-subtle);
    border-color: var(--primary-border);
    color: var(--primary);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
    background-color: currentColor;
}

[hidden] {
    display: none !important;
}

.alert {
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    padding: var(--space-4);
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    margin-bottom: var(--space-5);
    font-size: var(--text-note);
    font-weight: var(--weight-medium);
}

.alert i {
    margin-top: 2px;
    flex-shrink: 0;
}

.alert-error {
    background-color: var(--danger-subtle);
    border-color: var(--danger-border);
    color: var(--danger-hover);
}

.alert-success {
    background-color: var(--success-subtle);
    border-color: var(--success-border);
    color: #047857;
}

.alert-info {
    background-color: var(--info-subtle);
    border-color: var(--info-border);
    color: #1d4ed8;
}

.alert-warning {
    background-color: var(--warning-subtle);
    border-color: var(--warning-border);
    color: #b45309;
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--space-3);
    padding: var(--space-8) var(--space-6);
    text-align: center;
}

.empty-state-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background-color: var(--bg-hover);
    color: var(--text-subtle);
    font-size: var(--text-xl);
}

.empty-state-title {
    margin: 0;
    font-size: var(--text-md);
    font-weight: var(--weight-semibold);
    color: var(--text-main);
}

.empty-state-text {
    margin: 0;
    max-width: 44ch;
    color: var(--text-muted);
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--space-4);
}

.stat {
    padding: var(--space-4) var(--space-5);
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
}

.stat-label {
    display: block;
    font-size: var(--text-meta);
    font-weight: var(--weight-semibold);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.stat-value {
    display: block;
    margin-top: var(--space-2);
    font-size: var(--text-xl);
    font-weight: var(--weight-bold);
    font-variant-numeric: tabular-nums;
    color: var(--text-main);
}

.stat-value.stat-value-text {
    font-size: var(--text-md);
    font-weight: var(--weight-semibold);
    line-height: var(--leading-tight);
}

.stat-sub {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    flex-wrap: wrap;
    margin-top: var(--space-2);
    min-height: 22px;
    font-size: var(--text-note);
    color: var(--text-muted);
}

.stat-sub > .truncate {
    min-width: 0;
}

.stat-meta {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: var(--space-2);
    margin-top: var(--space-3);
}

a.stat {
    display: block;
    text-decoration: none;
    color: inherit;
    transition: box-shadow var(--transition), border-color var(--transition);
}

a.stat:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-sm);
}

.meter {
    height: 6px;
    margin-top: var(--space-3);
    border-radius: var(--radius-pill);
    background-color: var(--bg-hover);
    overflow: hidden;
}

.meter-fill {
    height: 100%;
    border-radius: var(--radius-pill);
    background-color: var(--primary);
    transition: width var(--transition);
}

.meter-fill.is-warning {
    background-color: var(--warning);
}

.meter-fill.is-danger {
    background-color: var(--danger);
}

.tool-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: var(--space-4);
}

.tool-card {
    display: flex;
    align-items: flex-start;
    gap: var(--space-4);
    padding: var(--space-5);
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    text-decoration: none;
    color: inherit;
    transition: border-color var(--transition), box-shadow var(--transition), background-color var(--transition);
}

.tool-card:hover {
    border-color: var(--primary-border);
    background-color: var(--bg-card);
    box-shadow: var(--shadow-md);
}

.tool-icon-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    flex-shrink: 0;
    border-radius: var(--radius-md);
    background-color: var(--primary-subtle);
    color: var(--primary);
    font-size: var(--text-md);
}

.tool-card-title {
    display: block;
    font-size: var(--text-md);
    font-weight: var(--weight-semibold);
    color: var(--text-main);
}

.tool-card-text {
    display: block;
    margin-top: 2px;
    font-size: var(--text-note);
    color: var(--text-muted);
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: var(--space-4);
    background-color: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(2px);
}

.modal-backdrop.show {
    display: flex;
}

.modal {
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    overflow-y: auto;
    background-color: var(--bg-card);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    padding: var(--space-6);
}

.modal-title {
    margin: 0 0 var(--space-2);
    font-size: var(--text-lg);
    font-weight: var(--weight-semibold);
}

.modal-text {
    margin: 0 0 var(--space-5);
    color: var(--text-muted);
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: var(--space-2);
}

.toast-stack {
    position: fixed;
    right: var(--space-5);
    bottom: var(--space-5);
    z-index: 1100;
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.toast {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    min-width: 280px;
    max-width: 420px;
    padding: var(--space-3) var(--space-4);
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-left: 3px solid var(--primary);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    font-size: var(--text-note);
    font-weight: var(--weight-medium);
}

.toast.is-success {
    border-left-color: var(--success);
}

.toast.is-error {
    border-left-color: var(--danger);
}

.skeleton {
    background: linear-gradient(90deg, var(--bg-hover) 25%, var(--bg-subtle) 50%, var(--bg-hover) 75%);
    background-size: 200% 100%;
    border-radius: var(--radius-sm);
    animation: skeleton-shimmer 1.4s ease-in-out infinite;
}

.skeleton-text {
    display: inline-block;
    width: 4rem;
    height: 1em;
    vertical-align: -0.125em;
}

@keyframes skeleton-shimmer {
    from {
        background-position: 200% 0;
    }

    to {
        background-position: -200% 0;
    }
}

.spinner {
    width: 16px;
    height: 16px;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    display: inline-block;
    animation: spin 0.7s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.code-block {
    padding: var(--space-4);
    background-color: #0f172a;
    color: #e2e8f0;
    border-radius: var(--radius-md);
    font-family: var(--font-mono);
    font-size: var(--text-meta);
    line-height: 1.6;
    overflow-x: auto;
    white-space: pre;
}

.code-block-scroll {
    max-height: 320px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-word;
}

.code-block-wrap {
    position: relative;
}

.code-block-wrap .code-block,
.code-block-wrap > pre {
    padding-right: calc(var(--space-4) + 56px);
}

.code-copy-btn {
    position: absolute;
    top: var(--space-2);
    right: calc(var(--space-2) + 16px);
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background-color: #1e293b;
    color: #cbd5e1;
    border: 1px solid #334155;
    border-radius: var(--radius-sm);
    font-size: var(--text-meta);
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.code-copy-btn:hover {
    background-color: #334155;
    color: #ffffff;
}

.code-copy-btn.is-copied {
    color: #4ade80;
    border-color: #4ade80;
}

.copy-field {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-3);
    background-color: var(--bg-subtle);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-family: var(--font-mono);
    font-size: var(--text-meta);
    word-break: break-all;
}

.grid-2 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
    gap: var(--space-6);
    align-items: start;
}

.grid-3 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: var(--space-4);
    align-items: start;
}

.stack {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
}

.row {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    flex-wrap: wrap;
}

.row-between {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    flex-wrap: wrap;
}

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

.text-danger {
    color: var(--danger);
}

.text-success {
    color: var(--success);
}

.text-sm {
    font-size: var(--text-meta);
}

small {
    font-size: var(--text-meta);
}

.text-note {
    font-size: var(--text-note);
    color: var(--text-muted);
}

.text-meta {
    font-size: var(--text-meta);
    color: var(--text-muted);
}

.text-right {
    text-align: right;
}

.truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.panel-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: var(--space-4);
}

.db-manual {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 180px;
}

.db-manual input {
    width: 100%;
}

.panel-choice {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    text-align: center;
    gap: var(--space-2);
    padding: var(--space-6) var(--space-5);
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    text-decoration: none;
    color: inherit;
    transition: border-color var(--transition), box-shadow var(--transition), background-color var(--transition);
}

.panel-choice:hover {
    border-color: var(--primary-border);
    box-shadow: var(--shadow-md);
}

.panel-grid-compact {
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: var(--space-3);
}

.panel-grid-compact .panel-choice {
    padding: var(--space-4) var(--space-3);
}

.panel-grid-compact .panel-choice-icon {
    width: 44px;
    height: 44px;
    margin-bottom: 0;
    font-size: var(--text-lg);
}

.panel-choice-pick {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
}

.panel-choice-radio {
    flex: none;
    width: 16px;
    height: 16px;
    margin: 0;
    accent-color: var(--primary);
    cursor: pointer;
}

label.panel-choice {
    position: relative;
    cursor: pointer;
}

label.panel-choice.is-selected {
    border-color: var(--primary);
    background-color: var(--primary-subtle);
    box-shadow: var(--shadow-md);
}

label.panel-choice:focus-within {
    border-color: var(--primary);
    outline: 2px solid var(--primary-border);
    outline-offset: 2px;
}

label.panel-choice.is-disabled {
    cursor: not-allowed;
    opacity: 0.55;
}

label.panel-choice.is-disabled:hover {
    border-color: var(--border-color);
    box-shadow: none;
}

.panel-choice-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    margin-bottom: var(--space-2);
    border-radius: var(--radius-lg);
    background-color: var(--primary-subtle);
    color: var(--primary);
    font-size: var(--text-xl);
}

/* Brand marks carry their own colours and aspect ratio, so they sit on the card
   itself rather than in the tinted tile the fallback glyphs use. */
.panel-choice-icon-logo,
.panel-grid-compact .panel-choice-icon-logo {
    width: 100%;
    height: 40px;
    background: none;
    border-radius: 0;
}

/* Wordmarks are far wider than square marks — cap the width so no one panel's
   logo towers over the others. */
.panel-choice-logo {
    width: 100%;
    max-width: 130px;
    height: 100%;
    object-fit: contain;
}

.panel-choice-title {
    font-size: var(--text-md);
    font-weight: var(--weight-semibold);
    color: var(--text-main);
}

.panel-choice-text {
    font-size: var(--text-note);
    color: var(--text-muted);
}

.step-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    margin-right: 3px;
    border-radius: 50%;
    vertical-align: middle;
}

.checklist {
    margin: 0;
    padding-left: var(--space-6);
    font-size: var(--text-md);
    line-height: 1.8;
}

.step-list {
    display: grid;
    gap: var(--space-2);
    margin: 0;
    padding: 0;
    list-style: none;
    font-size: var(--text-md);
    color: var(--text-muted);
}

.step-list li {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.step-list .is-done,
.step-list .is-active,
.step-list .is-failed {
    color: var(--text-main);
}

.step-list .is-active {
    font-weight: var(--weight-semibold);
}

.step-list .is-done i {
    color: var(--success);
}

.step-list .is-active i {
    color: var(--primary);
}

.step-list .is-failed i {
    color: var(--danger);
}

.card-footer-between {
    justify-content: space-between;
}

.card-footer .checkbox-row {
    margin-bottom: 0;
}

.card-flush .card-footer {
    padding: var(--space-5) var(--space-6);
    margin-top: 0;
}

.card-flush > .alert {
    margin: 0 var(--space-6) var(--space-5);
}

.setting-list {
    display: flex;
    flex-direction: column;
}

.setting-row {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    padding: var(--space-4) 0;
    border-top: 1px solid var(--border-color);
}

.setting-row:first-child {
    padding-top: 0;
    border-top: none;
}

.setting-row:last-child {
    padding-bottom: 0;
}

.setting-row-icon {
    display: flex;
    flex: none;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    background-color: var(--bg-hover);
    color: var(--text-muted);
    font-size: var(--text-lg);
}

.setting-row-icon.is-done {
    background-color: var(--success-subtle);
    color: var(--success);
}

.setting-row-icon.is-todo {
    background-color: var(--warning-subtle);
    color: var(--warning);
}

.setting-row-body {
    flex: 1;
    min-width: 0;
}

.setting-row-title {
    font-weight: var(--weight-semibold);
    color: var(--text-main);
}

.setting-row-value {
    margin: var(--space-1) 0 0;
    font-size: var(--text-note);
    color: var(--text-muted);
    overflow-wrap: anywhere;
}

.setting-row-action {
    display: flex;
    flex: none;
    gap: var(--space-2);
}

.status-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    flex-wrap: wrap;
}

.status-summary-title {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    margin: 0;
    font-size: var(--text-lg);
    font-weight: var(--weight-semibold);
    color: var(--text-main);
}

.status-summary-text {
    margin: var(--space-2) 0 0;
    font-size: var(--text-note);
    color: var(--text-muted);
}

@media (max-width: 992px) {
    .grid-2,
    .grid-3,
    .form-row {
        grid-template-columns: 1fr;
    }

    .form-line {
        grid-template-columns: 1fr;
        gap: var(--space-2);
    }

    .form-line > label,
    .form-line > .form-label {
        padding-top: 0;
    }

    .page-header {
        flex-direction: column;
        align-items: stretch;
    }

    .card {
        padding: var(--space-5);
    }

    .toast-stack {
        left: var(--space-4);
        right: var(--space-4);
    }

    .setting-row {
        flex-wrap: wrap;
        align-items: flex-start;
    }

    .setting-row-action {
        width: 100%;
        padding-left: calc(40px + var(--space-4));
    }

    .toast {
        min-width: 0;
        max-width: none;
    }
}
