/* =================================== */
/* styles.css (Minimalist/Pro Theme)   */
/* =================================== */

/* Reset & Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #4f46e5;
    --primary-dark: #4338ca;
    --bg: #f7f8fa;
    --surface: #ffffff;
    --text: #1a202c;
    --text-light: #6b7280;
    --border: #e4e7eb;
    --error: #e53e3e;
    --success-bg: #ecfdf5;
    --success-text: #065f46;
    --disabled-bg: #fef2f2;
    --disabled-text: #b91c1c;
    --warning-bg: #fffbeb;
    --warning-text: #b45309;
    --radius: 8px;
    --radius-sm: 6px;
    --radius-lg: 12px;
    --radius-full: 9999px;
    --shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --focus-ring: 0 0 0 3px rgba(79, 70, 229, 0.2);
}

:root[data-theme="dark"] {
    /* Calm dark tokens from client/apps/web/res/themes/shared/css/_calm-tokens.pcss */
    --calm-color-brand: #3663f2;
    --calm-color-accent: #3176ff;
    --calm-color-accent-hover: #4f7fff;
    --calm-color-accent-pressed: #2955cb;
    --calm-color-success: #19d475;
    --calm-color-warning: #f3972e;
    --calm-color-error: #d3363d;
    --calm-text-primary: #f5f5f6;
    --calm-text-secondary: #77829c;
    --calm-text-disabled: #444c5d;
    --calm-text-on-solid-primary: #ffffff;
    --calm-icon-primary: #f5f5f6;
    --calm-icon-secondary: #65708a;
    --calm-icon-tertiary: #444c5d;
    --calm-bg-base: #05060f;
    --calm-bg-upper: #10111a;
    --calm-bg-subtle: #171823;
    --calm-bg-border-bright: #33374c;
    --calm-bg-border: #272d3b;
    --calm-bg-overlay: rgb(5 6 15 / 80%);
    --calm-bg-disabled: #14141e;
    --calm-bg-quaternary: rgb(49 118 255 / 10%);
    --calm-bg-danger-pressed: #190a13;
    --calm-bg-accent-subtle: var(--calm-bg-quaternary);
    --calm-border-default: #272d3b;
    --calm-border-subtle: color-mix(in srgb, var(--calm-border-default) 55%, transparent);
    --calm-border-hovered: #3b455d;
    --calm-border-focused: #3176ff;
    --calm-border-critical: #d3363d;
    --calm-focus-ring: color-mix(in srgb, var(--calm-border-focused) 28%, transparent);
    --calm-elevation-shadow-sm: 0 3px 8px rgb(0 0 0 / 15%);

    /* IM semantic aliases */
    --primary: var(--calm-color-accent);
    --primary-dark: var(--calm-color-accent-hover);
    --bg: var(--calm-bg-base);
    --surface: var(--calm-bg-upper);
    --text: var(--calm-text-primary);
    --text-light: var(--calm-text-secondary);
    --border: var(--calm-border-default);
    --error: var(--calm-color-error);
    --success-bg: color-mix(in srgb, var(--calm-color-success) 16%, var(--calm-bg-upper));
    --success-text: var(--calm-color-success);
    --disabled-bg: var(--calm-bg-danger-pressed);
    --disabled-text: var(--calm-color-error);
    --warning-bg: color-mix(in srgb, var(--calm-color-warning) 14%, var(--calm-bg-upper));
    --warning-text: var(--calm-color-warning);
    --shadow: var(--calm-elevation-shadow-sm);
    --shadow-md: 0 12px 28px rgb(0 0 0 / 35%);
    --focus-ring: 0 0 0 3px var(--calm-focus-ring);
    color-scheme: dark;
}

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

input,
select,
textarea,
button {
    font: inherit;
}

input,
select,
textarea {
    background: var(--surface);
    color: var(--text);
    border-color: var(--border);
}

code {
    background: var(--bg);
    border: 1px solid var(--border);
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, Courier, monospace;
    font-size: 0.9em;
    color: var(--primary-dark);
}

/* Loading */
#loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100vh;
    gap: 1rem;
    color: var(--text-light);
}

.spinner {
    width: 36px;
    height: 36px;
    border: 4px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Error */
.error-box {
    max-width: 500px;
    margin: 2rem auto;
    padding: 2rem;
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    text-align: center;
}

.error-box h2 {
    color: var(--error);
    margin-bottom: 1rem;
}

/* Header */
header {
    background: var(--surface);
    padding: 1.25rem 2rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

header h1 {
    font-size: 1.5rem;
    font-weight: 700;
}

.user-info {
    font-size: 0.9rem;
    color: var(--text-light);
    display: flex;
    align-items: center;
}

/* Tabs */
.tabs {
    display: flex;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0 1.5rem;
    gap: 0.5rem;
}

.tab {
    padding: 0.75rem 1.25rem;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-light);
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
}

.tab:hover {
    color: var(--text);
}

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

/* Main */
main {
    padding: 1.5rem 2rem;
    max-width: 1400px;
    margin: 0 auto;
}

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

.section-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
}

input[type="search"] {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.9rem;
    width: 300px;
    background: var(--surface);
    transition: all 0.2s;
}

input[type="search"]:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: var(--focus-ring);
}

/* Tab Content */
.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* Grid */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
}

/* Card */
.card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 1rem;
    border: 1px solid var(--border);
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.card-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 0.75rem;
}

.card-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius);
    object-fit: cover;
    background: var(--bg);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.card-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
}

.card-subtitle {
    font-size: 0.8rem;
    color: var(--text-light);
}

.card-description {
    color: var(--text-light);
    font-size: 0.875rem;
    margin-bottom: 1rem;
    min-height: 42px; /* 3 lines */
    display: -webkit-box;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* Card icon image sizing */
.card-icon img {
    width: 40px;
    height: 40px;
    display: block;
    object-fit: contain;
    border-radius: 6px;
}

.card-icon {
    width: 40px;
    height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.badge {
    padding: 0.2rem 0.6rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: capitalize;
}

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

.badge-disabled {
    background: var(--disabled-bg);
    color: var(--disabled-text);
}

.tag-badge {
    background: var(--calm-bg-accent-subtle, var(--bg));
    color: var(--primary);
}

.status-draft {
    background: var(--calm-bg-border, var(--border));
    color: var(--text);
}

.status-submitted,
.status-in-review {
    background: var(--calm-bg-accent-subtle, var(--warning-bg));
    color: var(--primary);
}

.status-approved {
    background: var(--success-bg);
    color: var(--success-text);
}

.status-rejected {
    background: var(--disabled-bg);
    color: var(--disabled-text);
}

.status-archived {
    background: var(--bg);
    color: var(--text-light);
}

.submission-checks,
.submission-check-item,
.code-preview {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
}

.submission-checks {
    margin-top: 0.5rem;
    padding: 0.5rem;
}

.submission-check-item {
    padding: 0.75rem;
}

.submission-check-item.status-approved {
    border-left: 3px solid var(--success-text);
}

.submission-check-item.status-rejected {
    border-left: 3px solid var(--error);
}

.submission-check-item.status-in-review {
    border-left: 3px solid var(--warning-text);
}

.submission-check-item .badge {
    margin-left: 0.5rem;
}

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

.submission-filter-select {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.5rem;
}

.code-preview {
    margin-top: 0.5rem;
    padding: 1rem;
    overflow-x: auto;
    white-space: pre-wrap;
    font-size: 0.85rem;
}

/* Buttons */
.btn {
    padding: 0.625rem 1.25rem;
    border: none;
    border-radius: var(--radius-lg);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-family: inherit;
    text-decoration: none;
    position: relative;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}

.btn:active {
    transform: translateY(1px);
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    pointer-events: none;
}

.btn-primary,
button.btn-primary {
    padding: 0.625rem 1.25rem;
    border: none;
    border-radius: var(--radius-lg);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-family: inherit;
    text-decoration: none;
    position: relative;
    overflow: hidden;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    box-shadow: 0 2px 8px rgba(79, 70, 229, 0.3);
}

.btn-primary:hover,
button.btn-primary:hover {
    background: linear-gradient(135deg, var(--primary-dark) 0%, #3730a3 100%);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.4);
    transform: translateY(-1px);
}

.btn-primary:active,
button.btn-primary:active {
    box-shadow: 0 1px 4px rgba(79, 70, 229, 0.3);
    transform: translateY(1px);
}

.btn-secondary,
button.btn-secondary {
    padding: 0.625rem 1.25rem;
    border-radius: var(--radius-lg);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-family: inherit;
    text-decoration: none;
    position: relative;
    overflow: hidden;
    background: var(--surface);
    color: var(--text);
    border: 1.5px solid var(--border);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.btn-secondary:hover,
button.btn-secondary:hover {
    background: var(--bg);
    border-color: #9ca3af;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
    transform: translateY(-1px);
}

.btn-secondary:active,
button.btn-secondary:active {
    background: #e5e7eb;
    transform: translateY(1px);
}

.btn-danger,
button.btn-danger {
    padding: 0.625rem 1.25rem;
    border: none;
    border-radius: var(--radius-lg);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-family: inherit;
    text-decoration: none;
    position: relative;
    overflow: hidden;
    background: linear-gradient(135deg, var(--error) 0%, #c53030 100%);
    color: white;
    box-shadow: 0 2px 8px rgba(229, 62, 62, 0.3);
}

.btn-danger:hover,
button.btn-danger:hover {
    background: linear-gradient(135deg, #c53030 0%, #9b2c2c 100%);
    box-shadow: 0 4px 12px rgba(229, 62, 62, 0.4);
    transform: translateY(-1px);
}

.btn-danger:active,
button.btn-danger:active {
    box-shadow: 0 1px 4px rgba(229, 62, 62, 0.3);
    transform: translateY(1px);
}

.btn-success,
button.btn-success {
    padding: 0.625rem 1.25rem;
    border: none;
    border-radius: var(--radius-lg);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-family: inherit;
    text-decoration: none;
    position: relative;
    overflow: hidden;
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
}

.btn-success:hover,
button.btn-success:hover {
    background: linear-gradient(135deg, #059669 0%, #047857 100%);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.4);
    transform: translateY(-1px);
}

.btn-success:active,
button.btn-success:active {
    box-shadow: 0 1px 4px rgba(16, 185, 129, 0.3);
    transform: translateY(1px);
}

.btn-warning,
button.btn-warning {
    padding: 0.625rem 1.25rem;
    border: none;
    border-radius: var(--radius-lg);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-family: inherit;
    text-decoration: none;
    position: relative;
    overflow: hidden;
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: white;
    box-shadow: 0 2px 8px rgba(245, 158, 11, 0.3);
}

.btn-warning:hover,
button.btn-warning:hover {
    background: linear-gradient(135deg, #d97706 0%, #b45309 100%);
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.4);
    transform: translateY(-1px);
}

.btn-warning:active,
button.btn-warning:active {
    box-shadow: 0 1px 4px rgba(245, 158, 11, 0.3);
    transform: translateY(1px);
}

.btn-sm,
.btn-primary.btn-sm,
.btn-secondary.btn-sm,
.btn-danger.btn-sm,
.btn-success.btn-sm,
.btn-warning.btn-sm {
    padding: 0.375rem 0.875rem !important;
    font-size: 0.8125rem !important;
}

.btn-lg,
.btn-primary.btn-lg,
.btn-secondary.btn-lg,
.btn-danger.btn-lg,
.btn-success.btn-lg,
.btn-warning.btn-lg {
    padding: 0.875rem 1.75rem !important;
    font-size: 1rem !important;
}

.btn:disabled,
.btn-primary:disabled,
.btn-secondary:disabled,
.btn-danger:disabled,
.btn-success:disabled,
.btn-warning:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    pointer-events: none;
}

.button-group {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--surface);
    border-radius: var(--radius);
    max-width: 550px;
    width: 90%;
    max-height: 85vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border);
}

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

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

.close-btn {
    background: none;
    border: none;
    font-size: 1.75rem;
    cursor: pointer;
    color: var(--text-light);
    padding: 0;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s;
}

.close-btn:hover {
    color: var(--text);
}

.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
}

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

/* Form */
.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    font-size: 0.875rem;
}

.form-group input[type="text"],
.form-group input[type="password"],
.form-group input[type="email"],
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-family: inherit;
    background: var(--surface);
    transition: all 0.2s;
}

.form-group input[type="text"]:focus,
.form-group input[type="password"]:focus,
.form-group input[type="email"]:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: var(--focus-ring);
}

.form-group small {
    font-size: 0.8rem;
    color: var(--text-light);
    margin-top: 0.25rem;
    display: block;
}

.helper-text {
    color: var(--text-light);
    display: block;
    font-size: 0.85rem;
    margin-top: 0.5rem;
}

.helper-text-compact {
    font-size: 0.75rem;
}

.required-marker {
    color: var(--error);
}

.widget-param-label {
    color: var(--text-light);
    display: block;
    font-size: 0.75rem;
    margin-bottom: 0.25rem;
}

.embed-hint {
    color: var(--warning-text);
    font-size: 0.9rem;
    margin-top: 0.5rem;
    padding: 0.75rem;
}

.embed-hint code {
    color: var(--warning-text);
}

.permission-option-group {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    display: grid;
    gap: 0.75rem;
    padding: 1rem;
}

.permission-level-group {
    background: var(--calm-bg-accent-subtle, var(--bg));
    border-left: 3px solid var(--primary);
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.9rem;
}

.checkbox-label input[type="checkbox"] {
    width: auto;
    margin: 0;
    accent-color: var(--primary);
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 2.5rem;
    color: var(--text-light);
    background: var(--surface);
    border: 2px dashed var(--border);
    border-radius: var(--radius);
}

.empty-state h3 {
    margin-bottom: 0.5rem;
    color: var(--text);
}

/* Login Screen */
.login-box {
    max-width: 450px;
    margin: 4rem auto;
    padding: 2.5rem;
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    text-align: center;
}

.login-box h2 {
    margin-bottom: 0.5rem;
}

.login-box p {
    color: var(--text-light);
    margin-bottom: 2rem;
}

.auth-methods {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.auth-btn {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.25rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
}

.auth-btn:hover {
    border-color: var(--primary);
    background: #f7f7ff;
    box-shadow: var(--shadow);
    transform: translateY(-1px);
}

.auth-icon {
    font-size: 1.75rem;
}

.auth-btn strong {
    display: block;
    font-size: 1.05rem;
    color: var(--text);
    margin-bottom: 0.25rem;
}

.auth-btn small {
    color: var(--text-light);
    font-size: 0.85rem;
}

#openid-form {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}

#openid-form input {
    width: 100%;
    margin-bottom: 1rem;
    text-align: center;
}

#openid-form .btn-primary {
    width: 100%;
    margin-bottom: 0.5rem;
}
#openid-form .btn-secondary {
    width: 100%;
}


/* User Badge */
#user-badge {
    margin-left: 0.75rem;
    text-transform: uppercase;
    font-size: 0.7rem;
}

/* Permissions Section */
.permissions-section {
    margin-bottom: 2rem;
}

.permissions-section h3 {
    margin-bottom: 1rem;
    font-size: 1.1rem;
    font-weight: 600;
}

.info-box {
    background: var(--surface);
    padding: 1.25rem;
    border-radius: var(--radius);
    border-left: 4px solid var(--primary);
    border-top: 1px solid var(--border);
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
}

.info-box p {
    margin-bottom: 0.5rem;
    color: var(--text);
}

.info-box p:last-child {
    margin-bottom: 0;
}

.info-box ul {
    list-style-type: none;
    padding-left: 0;
}

.info-box ul li {
    margin-bottom: 0.4rem;
    padding-left: 1rem;
    position: relative;
}

.info-box ul li::before {
    content: "→";
    position: absolute;
    left: 0;
    color: var(--primary);
    font-weight: bold;
}

/* These styles replace the JS inline styles for permissions */
.permissions-stats {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    margin-bottom: 1.5rem;
    padding: 1rem;
}

.user-permissions-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow);
}

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

.user-header h4 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
}

.permission-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    /* border-left is set by JS */
}

.permission-tone-default {
    border-left: 3px solid var(--primary);
}

.permission-tone-widgets {
    border-left: 3px solid color-mix(in srgb, var(--primary) 70%, #c936f2);
}

.permission-tone-bridges,
.permission-tone-configure {
    border-left: 3px solid var(--warning-text);
}

.permission-tone-bots,
.permission-tone-admin {
    border-left: 3px solid var(--success-text);
}

.permission-info strong {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.permission-badges {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.permission-note {
    color: var(--text-light);
    font-size: 0.9rem;
    margin-top: 1rem;
}

.etherpad-instance-list {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    max-height: 240px;
    overflow-y: auto;
    padding: 0.75rem;
}

.empty-state-compact {
    padding: 1rem;
}

.etherpad-instance {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 0.75rem;
    padding: 0.75rem;
}

.etherpad-instance-meta {
    color: var(--text-light);
    font-size: 0.75rem;
}

.etherpad-instance-meta-small {
    color: var(--text-light);
    font-size: 0.7rem;
}


/* Toggle Switch */
.toggle {
    position: relative;
    display: inline-block;
    width: 38px;
    height: 20px;
}

.toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--border);
    transition: 0.3s;
    border-radius: 20px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 14px;
    width: 14px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
    box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

.toggle input:checked + .toggle-slider {
    background-color: var(--primary);
}

.toggle input:checked + .toggle-slider:before {
    transform: translateX(18px);
}

/* Config Management */
.config-section {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.config-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 1.5rem;
    border: 1px solid var(--border);
}

.config-card h3 {
    margin-bottom: 0.5rem;
    font-size: 1.1rem;
    font-weight: 600;
}

.config-card p {
    color: var(--text-light);
    margin-bottom: 1rem;
}

.validation-result,
.diff-result {
    background: var(--bg);
    padding: 1rem;
    border-radius: var(--radius);
    margin-top: 1rem;
    border: 1px solid var(--border);
}

.validation-result h5,
.diff-result h5 {
    margin-bottom: 0.75rem;
    font-weight: 600;
}

.validation-errors {
    background: var(--disabled-bg);
    border-left: 4px solid var(--error);
    padding: 1rem;
    border-radius: var(--radius);
    margin-top: 0.5rem;
}

.validation-warnings {
    background: var(--warning-bg);
    border-left: 4px solid var(--warning-text);
    padding: 1rem;
    border-radius: var(--radius);
    margin-top: 0.5rem;
}

.validation-errors h6,
.validation-warnings h6,
.diff-section h6 {
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.validation-errors ul,
.validation-warnings ul,
.diff-section ul {
    margin-left: 1.5rem;
    font-size: 0.9rem;
}

.validation-errors li,
.validation-warnings li,
.diff-section li {
    margin-bottom: 0.25rem;
}

.diff-section {
    margin-top: 0.75rem;
}

/* Alert */
.alert {
    padding: 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    border-left: 4px solid;
    font-size: 0.9rem;
}

.alert-warning {
    background: var(--warning-bg);
    border-color: var(--warning-text);
    color: var(--warning-text);
}

.alert-error {
    background: var(--disabled-bg);
    border-color: var(--error);
    color: var(--disabled-text);
}

.alert-success {
    background: var(--success-bg);
    border-color: var(--success-text);
    color: var(--success-text);
}

.alert-info {
    background: #eff6ff;
    border-color: #2563eb;
    color: #1d4ed8;
}


/* Pre/Code for config preview */
pre {
    background: var(--bg);
    color: var(--text);
    padding: 1rem;
    border-radius: var(--radius);
    overflow-x: auto;
    font-size: 0.85rem;
    line-height: 1.5;
    max-height: 400px;
    border: 1px solid var(--border);
}

/* Config changes preview */
.changes-list {
    background: var(--bg);
    padding: 1rem;
    border-radius: var(--radius);
}

.changes-list h6 {
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
    color: var(--text);
}

.changes-list ul {
    margin-left: 1.5rem;
    list-style: disc;
}

.changes-list li {
    margin-bottom: 0.25rem;
    font-size: 0.9rem;
    color: var(--text-light);
}

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

.change-modified {
    color: var(--warning-text);
}

.change-removed {
    color: var(--error);
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    max-width: 400px;
}

.toast {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
    border-left: 4px solid;
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    animation: slideIn 0.3s ease-out;
    min-width: 320px;
}

@keyframes slideIn {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOut {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(400px);
        opacity: 0;
    }
}

.toast.hiding {
    animation: slideOut 0.3s ease-out;
}

.toast-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
}

.toast-content {
    flex: 1;
}

.toast-title {
    font-weight: 600;
    margin-bottom: 0.25rem;
    font-size: 0.95rem;
}

.toast-message {
    font-size: 0.875rem;
    color: var(--text-light);
    line-height: 1.4;
}

.toast-close {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-light);
    font-size: 1.25rem;
    padding: 0;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: color 0.2s;
}

.toast-close:hover {
    color: var(--text);
}

.toast-success {
    border-left-color: #10b981;
}

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

.toast-warning {
    border-left-color: var(--warning-text);
}

.toast-info {
    border-left-color: var(--primary);
}

/* Confirm Dialog */
.confirm-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 10000;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease-out;
}

.confirm-overlay.active {
    display: flex;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.confirm-dialog {
    background: var(--surface);
    border-radius: var(--radius);
    max-width: 450px;
    width: 90%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: scaleIn 0.2s ease-out;
}

@keyframes scaleIn {
    from {
        transform: scale(0.9);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

.confirm-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 1rem;
}

.confirm-icon {
    font-size: 2rem;
    flex-shrink: 0;
}

.confirm-title {
    font-size: 1.15rem;
    font-weight: 600;
    margin: 0;
}

.confirm-body {
    padding: 1.5rem;
    color: var(--text);
    line-height: 1.6;
}

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

/* Responsive */
@media (max-width: 768px) {
    .toast-container {
        left: 1rem;
        right: 1rem;
        max-width: none;
    }

    .toast {
        min-width: auto;
    }

    header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
        padding: 1rem;
    }

    .tabs {
        overflow-x: auto;
        padding: 0 0.5rem;
        white-space: nowrap;
    }

    main {
        padding: 1rem;
    }

    .grid {
        grid-template-columns: 1fr;
    }

    .section-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    input[type="search"] {
        width: 100%;
    }

    .button-group {
        flex-direction: column;
        width: 100%;
    }

    .button-group button {
        width: 100%;
    }

    .modal-content {
        width: 95%;
        max-height: 90vh;
    }

    .modal-body {
        padding: 1rem;
    }

    .modal-footer {
        flex-direction: column;
    }
    .modal-footer button {
        width: 100%;
    }

    .confirm-dialog {
        width: 95%;
    }

    .confirm-footer {
        flex-direction: column;
    }

    .confirm-footer button {
        width: 100%;
    }
}
