:root {
    --bg: #f4f5f7;
    --sidebar-bg: #1e293b;
    --sidebar-text: #94a3b8;
    --sidebar-active: #e2e8f0;
    --card-bg: #ffffff;
    --text: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --danger: #ef4444;
    --success: #22c55e;
    --warning: #f59e0b;
    --radius: 8px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

[x-cloak] { display: none !important; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 240px;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 10;
    transition: width 0.2s ease;
}

.nav-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.nav-icon svg {
    width: 20px;
    height: 20px;
}

.sidebar-bottom {
    margin-top: auto;
    border-top: 1px solid rgba(255,255,255,0.1);
}

.sidebar-toggle,
.sidebar-logout-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    border: none;
    background: transparent;
    color: var(--sidebar-text);
    font-family: inherit;
    font-size: 14px;
    cursor: pointer;
    text-align: left;
    transition: background 0.15s, color 0.15s;
}

.sidebar-toggle {
    padding: 12px 20px;
}

.sidebar-logout-btn {
    padding: 6px 0;
}

.sidebar-toggle:hover,
.sidebar-logout-btn:hover {
    background: rgba(255,255,255,0.08);
    color: var(--sidebar-active);
}

html.nav-collapsed .sidebar {
    width: 56px;
}

html.nav-collapsed .content {
    margin-left: 56px;
}

html.nav-collapsed .sidebar-header {
    padding: 16px 10px;
}

html.nav-collapsed .workspace-switch-button {
    justify-content: center;
    padding: 8px;
}

html.nav-collapsed .workspace-title,
html.nav-collapsed .workspace-caret,
html.nav-collapsed .nav-label,
html.nav-collapsed .footer-label {
    display: none;
}

html.nav-collapsed .nav-links li a,
html.nav-collapsed .sidebar-toggle,
html.nav-collapsed .sidebar-logout-btn {
    justify-content: center;
    padding-left: 0;
    padding-right: 0;
}

html.nav-collapsed .sidebar-footer {
    justify-content: center;
    padding: 12px 8px;
}

html.nav-collapsed .sidebar-toggle-icon {
    transform: scaleX(-1);
}

html.nav-collapsed .workspace-menu {
    left: calc(100% + 4px);
    right: auto;
    top: 0;
    width: 180px;
}

.sidebar-header {
    padding: 24px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-header h2 {
    color: white;
    font-size: 18px;
    font-weight: 600;
}

/* Workspace switcher (CRMDemo <-> ParishData) */
.workspace-switch {
    position: relative;
}

.workspace-switch-button {
    display: flex;
    width: 100%;
    align-items: center;
    gap: 10px;
    justify-content: space-between;
    background: transparent;
    border: 1px solid rgba(255,255,255,0.08);
    color: white;
    font-size: 18px;
    font-weight: 600;
    padding: 6px 10px;
    border-radius: 6px;
    cursor: pointer;
    font-family: inherit;
}

.workspace-title {
    flex: 1;
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.workspace-switch-button:hover {
    background: rgba(255,255,255,0.06);
}

.workspace-caret {
    display: inline-block;
    margin-left: 8px;
    font-size: 12px;
    opacity: 0.75;
    transition: transform 0.15s ease;
}

.workspace-caret.open {
    transform: rotate(180deg);
}

.workspace-menu {
    position: absolute;
    top: calc(100% + 4px);
    left: 20px;
    right: 20px;
    background: #0f172a;
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 6px;
    list-style: none;
    padding: 4px 0;
    margin: 0;
    z-index: 20;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.workspace-menu li a {
    display: block;
    padding: 8px 12px;
    color: var(--sidebar-active);
    text-decoration: none;
    font-size: 14px;
}

.workspace-menu li a:hover {
    background: rgba(255,255,255,0.08);
}

.nav-links {
    list-style: none;
    padding: 12px 0;
    flex: 1;
}

.nav-links li a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 20px;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 14px;
    transition: background 0.15s, color 0.15s;
}

.nav-links li a:hover,
.nav-links li a.active {
    background: rgba(255,255,255,0.1);
    color: var(--sidebar-active);
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid rgba(255,255,255,0.1);
    font-size: 13px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Main content */
.content {
    margin-left: 240px;
    padding: 32px;
    flex: 1;
    transition: margin-left 0.2s ease;
}

/* Global keyring missing-secret banner (all authenticated pages) */
.keyring-banner {
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-left: 4px solid var(--danger);
    border-radius: var(--radius);
    color: #991b1b;
    padding: 14px 16px;
    margin-bottom: 20px;
}

.keyring-banner-title {
    font-weight: 600;
    font-size: 15px;
    margin-bottom: 6px;
}

.keyring-banner-account {
    margin: 0 0 10px;
    font-size: 13px;
}

.keyring-banner-list {
    margin: 0 0 10px 18px;
    padding: 0;
    font-size: 13px;
    line-height: 1.45;
}

.keyring-banner-list li {
    margin-bottom: 6px;
}

.keyring-banner-hint {
    margin: 0 0 10px;
    font-size: 13px;
    color: #7f1d1d;
}

.keyring-banner code {
    font-size: 12px;
    background: #fee2e2;
    padding: 1px 5px;
    border-radius: 3px;
}

.keyring-banner-refresh {
    margin-top: 2px;
}

h1 {
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 24px;
}

/* Cards */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
    gap: 20px;
}

.card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 20px;
}

.card h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--text);
}

.card-collapse-header {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    user-select: none;
    margin-bottom: 12px;
}

.card-collapse-header-collapsed {
    margin-bottom: 0;
}

.card-collapse-header h3 {
    margin-bottom: 0;
}

.system-heading {
    margin-bottom: 10px;
}

.metrics-card .system-heading h3 {
    margin: 0;
    line-height: 1.2;
}

.metrics-card .system-repo-name {
    margin: 0;
    padding: 0;
    line-height: 1.2;
}

/* Tables */
.table-wrapper {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.data-table.resizable-table {
    table-layout: fixed;
    width: auto;
    min-width: 0;
    max-width: none;
}

.data-table th {
    text-align: left;
    padding: 10px 12px;
    border-bottom: 2px solid var(--border);
    color: var(--text-muted);
    font-weight: 500;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.resizable-table th {
    position: relative;
    overflow: hidden;
}

.resizable-table th:not(:last-child),
.resizable-table td:not(:last-child) {
    border-right: 1px solid #dce3ed;
}

.resizable-table th.sortable-header {
    cursor: pointer;
}

.col-resize-grip {
    position: absolute;
    top: 0;
    right: 0;
    width: 9px;
    height: 100%;
    transform: translateX(50%);
    cursor: col-resize;
    user-select: none;
    z-index: 2;
}

.col-resize-grip::before {
    content: '';
    position: absolute;
    top: 4px;
    bottom: 4px;
    left: 50%;
    width: 1px;
    transform: translateX(-50%);
    background: #cbd5e1;
    pointer-events: none;
}

.col-resize-grip:hover::before {
    background: var(--primary);
}

body.col-resizing {
    cursor: col-resize;
    user-select: none;
}

.data-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.resizable-table th,
.resizable-table td {
    padding: 6px 8px;
}

.data-table tbody tr:nth-child(even) {
    background: #f8fafc;
}

.data-table a {
    color: var(--primary);
    text-decoration: none;
}

.data-table a:hover {
    text-decoration: underline;
}

/* Badges */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.badge-pending { background: #e2e8f0; color: #475569; }
.badge-waiting { background: #fef3c7; color: #92400e; }
.badge-running { background: #dbeafe; color: #1d4ed8; }
.badge-completed { background: #dcfce7; color: #166534; }
.badge-failed { background: #fee2e2; color: #991b1b; }
.badge-cancelled { background: #fef3c7; color: #92400e; }
.badge-on { background: var(--success); color: white; }
.badge-off { background: #94a3b8; color: white; }

/* Activity indicator */
.activity-indicator {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 0;
}

.activity-indicator.small {
    gap: 8px;
    padding: 4px 0;
}

@keyframes activity-spin {
    to { transform: rotate(360deg); }
}

.activity-pulse {
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 3px solid #e2e8f0;
    border-top-color: var(--primary);
    border-radius: 50%;
    flex-shrink: 0;
    animation: activity-spin 0.8s linear infinite;
}

.activity-indicator.small .activity-pulse {
    width: 14px;
    height: 14px;
    border-width: 2px;
}

.activity-label {
    font-size: 14px;
    font-family: "Cascadia Code", "Fira Code", "Consolas", monospace;
    color: var(--text);
}

.activity-indicator.small .activity-label {
    font-size: 12px;
    color: var(--text-muted);
}

/* Buttons */
.btn-primary {
    background: var(--primary);
    color: white;
    border: none;
    padding: 8px 20px;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 14px;
    transition: background 0.15s;
}

.btn-primary:hover { background: var(--primary-hover); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-small {
    padding: 4px 12px;
    font-size: 12px;
    border: 1px solid var(--border);
    background: white;
    color: var(--text);
    border-radius: var(--radius);
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}

.btn-small:hover {
    background: var(--bg);
    border-color: var(--text-muted);
}

.btn-small:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}

.btn-danger { color: var(--danger); border-color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: white; }

.btn-icon {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.85em;
    padding: 0 4px;
    margin-left: 4px;
    opacity: 0.5;
    transition: opacity 0.15s, color 0.15s;
}

.btn-icon:hover {
    opacity: 1;
    color: var(--text);
}

.actions-cell {
    display: flex;
    gap: 4px;
    white-space: nowrap;
}
.btn-on { background: var(--success); color: white; border-color: var(--success); }
.btn-off { background: #94a3b8; color: white; border-color: #94a3b8; }

.btn-toggle {
    padding: 4px 14px;
    font-size: 12px;
    font-weight: 600;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    letter-spacing: 0.5px;
    transition: background 0.15s;
}

.text-muted { color: var(--text-muted); }

/* Forms */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 4px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
}

.form-group input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
}

.text-input, .select-input {
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
}

.inline-form {
    display: flex;
    gap: 8px;
    align-items: center;
}

.inline-form-bar {
    justify-content: space-between;
    flex-wrap: wrap;
    width: 100%;
}

/* Page header */
.page-header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

/* Tool subpages: back link above; title + Settings on next row, left-aligned */
.page-header.tool-page-header {
    flex-direction: column;
    align-items: flex-start;
    justify-content: flex-start;
    gap: 8px;
}

.tool-page-header-top {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.tool-page-back {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 14px;
    white-space: nowrap;
}

.tool-page-back:hover {
    color: var(--text);
}

.section-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 20px;
    padding: 12px 16px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.section-nav a {
    display: inline-block;
    padding: 6px 14px;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
    text-decoration: none;
    border: 1px solid var(--border);
    background: var(--bg);
}

.section-nav a:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.wiki-toc {
    margin-bottom: 24px;
}

.wiki-toc-links {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.wiki-toc-links a {
    display: inline-block;
    padding: 5px 12px;
    border-radius: var(--radius);
    font-size: 13px;
    color: var(--primary);
    text-decoration: none;
    border: 1px solid var(--border);
    background: var(--bg);
}

.wiki-toc-links a:hover {
    background: var(--card-bg);
    border-color: var(--primary);
}

.wiki-section [id] {
    scroll-margin-top: 16px;
}

.tool-section {
    scroll-margin-top: 16px;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.page-header h1 { margin-bottom: 0; }

.actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

/* Log viewer */
.log-viewer {
    max-height: 500px;
    overflow-y: auto;
    font-family: "Cascadia Code", "Fira Code", "Consolas", monospace;
    font-size: 13px;
    background: #1e293b;
    color: #e2e8f0;
    border-radius: var(--radius);
    padding: 16px;
}

.log-line {
    padding: 2px 0;
    display: flex;
    gap: 12px;
}

.log-time {
    color: #64748b;
    flex-shrink: 0;
}

.log-level {
    text-transform: uppercase;
    font-size: 11px;
    font-weight: 600;
    flex-shrink: 0;
    width: 50px;
}

.log-info .log-level { color: #60a5fa; }
.log-warning .log-level { color: #fbbf24; }
.log-error .log-level { color: #f87171; }

.log-msg {
    word-break: break-all;
}

.error-block {
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: var(--radius);
    padding: 16px;
    font-family: monospace;
    font-size: 13px;
    color: #991b1b;
    white-space: pre-wrap;
    max-height: 300px;
    overflow-y: auto;
}

.error-text {
    color: var(--danger);
    font-size: 14px;
    margin-bottom: 12px;
}

.error-snippet {
    font-size: 12px;
    color: var(--text-muted);
    display: block;
    margin-top: 2px;
}

.empty-state {
    color: var(--text-muted);
    font-size: 14px;
    padding: 12px 0;
}

/* Job list (inside cards) */
.job-list, .schedule-list {
    list-style: none;
}

.job-list li, .schedule-list li {
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
}

.job-list li:last-child, .schedule-list li:last-child {
    border-bottom: none;
}

.job-list li a, .schedule-list li a {
    color: var(--primary);
    text-decoration: none;
}

.schedule-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.next-run {
    font-size: 12px;
    color: var(--text-muted);
}

.chain-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
}

.chain-link:hover {
    text-decoration: underline;
}

.chain-tag {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 2px 6px;
    border-radius: 10px;
    background: var(--sidebar-bg, #eef2ff);
    color: var(--primary);
}

.failure {
    border-left: 3px solid var(--danger);
    padding-left: 8px;
}

/* Login page */
.login-body {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: var(--sidebar-bg);
}

.login-card {
    background: var(--card-bg);
    padding: 40px;
    border-radius: 12px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.login-card h1 {
    text-align: center;
    margin-bottom: 4px;
}

.login-subtitle {
    text-align: center;
    color: var(--text-muted);
    margin-bottom: 32px;
    font-size: 14px;
}

.login-btn {
    width: 100%;
    padding: 10px 20px;
}

.login-links {
    display: flex;
    justify-content: center;
    gap: 16px;
    margin-top: 16px;
}

.link-btn {
    background: none;
    border: none;
    outline: none;
    color: var(--text-muted);
    font-family: inherit;
    font-size: 13px;
    cursor: pointer;
    padding: 0;
    transition: color 0.15s;
}

.link-btn:hover,
.link-btn:focus-visible {
    color: var(--primary);
}

.login-divider {
    border: none;
    border-top: 1px solid var(--border);
    margin: 16px 0;
}

.success-text {
    color: var(--success);
    font-size: 14px;
    margin-bottom: 12px;
}

.login-hint {
    display: block;
    color: var(--text-muted);
    font-size: 12px;
    margin-top: 4px;
}

/* Users page */
.users-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
}

.users-toolbar input[type="text"] {
    min-width: 220px;
}

.users-actions {
    display: flex;
    gap: 6px;
}

.temp-password {
    display: block;
    font-family: "Consolas", "Courier New", monospace;
    font-size: 22px;
    letter-spacing: 2px;
    padding: 12px 16px;
    margin: 12px 0;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    text-align: center;
    user-select: all;
}

/* Settings page */
.settings-list {
    display: flex;
    flex-direction: column;
}

.setting-row {
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 16px;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}

.setting-row:last-child { border-bottom: none; }

.setting-label {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.setting-label strong { font-size: 14px; }

.setting-desc {
    font-size: 12px;
    color: var(--text-muted);
}

.setting-value { min-width: 880px; }

.setting-value .text-input { width: 100%; }

.setting-input-sm { width: 120px; }

.setting-meta {
    color: var(--text-muted);
    font-size: 12px;
    white-space: nowrap;
}

.weekday-picker {
    display: flex;
    gap: 4px;
}

.monthday-picker {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    max-width: 420px;
}

.stp-freq-toggle {
    display: inline-flex;
    border: 1px solid var(--border);
    border-radius: 6px;
    overflow: hidden;
}

.stp-hint {
    margin: 6px 0 0;
    font-size: 12px;
    color: var(--text-muted);
}

.day-btn {
    width: 40px;
    height: 32px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: white;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    color: var(--text-muted);
    transition: all 0.15s;
}

.day-btn:hover { border-color: var(--primary); color: var(--primary); }

.day-active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

.day-active:hover {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
    color: white;
}

.day-btn-sm {
    width: 34px;
    height: 26px;
    font-size: 11px;
}

/* Inline schedule editor (reschedule row) */
.inline-edit-schedule {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 4px 0;
}

.inline-edit-schedule .select-input {
    font-size: 13px;
    padding: 4px 8px;
}

.inline-edit-schedule .select-narrow {
    width: 90px;
}

.btn-save {
    background: var(--success);
    color: white;
    border-color: var(--success);
}

.btn-save:hover {
    background: #16a34a;
    border-color: #16a34a;
}

/* Run group header */
.group-header-compact {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 12px;
}

.group-header-main {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.group-header-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-left: auto;
}

.group-header-metrics {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
    font-size: 12px;
    color: var(--text-muted);
    padding-left: 36px;
}

.group-metric {
    display: inline-flex;
    align-items: baseline;
    gap: 6px;
    white-space: nowrap;
}

.group-metric-label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
}

.group-metric-value {
    color: var(--text);
}

.group-reschedule-row {
    padding-left: 36px;
}

.btn-compact {
    padding: 4px 10px;
    font-size: 12px;
}

.group-title { margin-bottom: 0; flex: 1; min-width: 140px; }

.group-title-clickable {
    cursor: pointer;
}

.group-title-clickable:hover {
    text-decoration: underline;
}

.group-name-edit {
    display: flex;
    align-items: center;
    gap: 8px;
}

.group-name-input {
    min-width: 200px;
}

.group-collapse-btn {
    width: 28px;
    min-width: 28px;
    height: 28px;
    padding: 0;
    font-size: 16px;
    font-weight: 600;
    line-height: 1;
}

.group-card-collapsed .group-header-compact {
    margin-bottom: 0;
}

.group-card-collapsed .group-body {
    display: none;
}

.nested-add-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}

.nested-add-select {
    flex: 1;
    min-width: 200px;
}

.group-chain-label {
    font-size: 11px;
    font-weight: 500;
    color: var(--primary);
    background: #eff6ff;
    padding: 2px 8px;
    border-radius: 10px;
}

/* Order column */
.th-order, .td-order { width: 52px; text-align: center; }

.member-order-cell {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.member-drag-handle {
    color: var(--text-muted);
    cursor: grab;
    font-size: 13px;
    line-height: 1;
}

tr.row-dragging { opacity: 0.5; }

.data-table tbody tr[draggable="true"] {
    cursor: grab;
}

.order-controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1px;
}

.order-num {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    line-height: 1;
}

.order-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 10px;
    color: var(--text-muted);
    padding: 0 4px;
    line-height: 1;
    transition: color 0.15s;
}

.order-btn:hover:not(:disabled) { color: var(--primary); }
.order-btn:disabled { opacity: 0.2; cursor: default; }

/* Chain label for non-first group members */
.chain-after {
    font-size: 13px;
    color: var(--text-muted);
}

/* Badge marking a row that is a nested run group rather than a job */
.nested-group-badge {
    margin-left: 8px;
    font-size: 11px;
    font-weight: 500;
    color: var(--primary);
    background: #eff6ff;
    padding: 2px 8px;
    border-radius: 10px;
}

/* Nested run group panel */
.modal-panel-wide {
    max-width: 920px;
    width: 90%;
}

.nested-crumb {
    color: var(--primary);
    text-decoration: none;
}
.nested-crumb:hover { text-decoration: underline; }
.nested-crumb-sep { color: var(--text-muted); }

.nested-add-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
}
.nested-add-row label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
}

/* Run group builder */
.builder-card h3 {
    margin-bottom: 12px;
}

.builder-name-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

.builder-name-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    white-space: nowrap;
    flex-shrink: 0;
}

.builder-name-input {
    flex: 1;
    max-width: 420px;
}

.builder-name-field {
    flex: 1;
    max-width: 420px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.builder-name-field .builder-name-input {
    max-width: none;
    width: 100%;
}

.builder-field-msg {
    margin: 0;
    font-size: 12px;
    font-weight: 600;
    color: #dc2626 !important;
}

.input-error,
select.input-error,
.text-input.input-error {
    border-color: #dc2626 !important;
    box-shadow: 0 0 0 1px #dc2626 !important;
}

.builder-schedule-col.builder-field-error,
.builder-selected.builder-selected-error {
    border-color: #dc2626 !important;
    box-shadow: 0 0 0 1px #dc2626 !important;
}

.builder-field-error .stp-label,
.builder-field-error .builder-name-label {
    color: #dc2626 !important;
}

.builder-body {
    display: grid;
    grid-template-columns: minmax(320px, 460px) minmax(0, 1fr);
    gap: 20px;
    align-items: start;
}

.builder-schedule-col {
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 14px;
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 8px;
}

.builder-schedule-block {
    min-width: 0;
}

.builder-week-overview {
    margin-top: 2px;
}

.stp-week-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 8px;
}

.stp-week-col {
    min-width: 0;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 6px;
    overflow: hidden;
}

.stp-week-col-head {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--text-muted);
    text-align: center;
    padding: 6px 4px;
    background: #f1f5f9;
    border-bottom: 1px solid var(--border);
}

.stp-week-col-body {
    padding: 8px 6px;
    min-height: 36px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.stp-week-col-body .stp-time-badges {
    justify-content: center;
}

.stp-week-col-body .stp-not-set {
    text-align: center;
}

.builder-card .stp-day-btn-sm {
    width: 38px;
    height: 30px;
    font-size: 11px;
}

.builder-card .stp-checkbox-row {
    margin-top: 8px;
}

.stp-week-grid-compact {
    gap: 6px;
    grid-template-columns: repeat(7, minmax(52px, 1fr));
}

.stp-week-grid-compact .stp-week-col-head {
    font-size: 10px;
    padding: 5px 4px;
}

.stp-week-grid-compact .stp-week-col-body {
    padding: 6px 4px;
    min-height: 32px;
}

.stp-week-grid-compact .stp-not-set {
    font-size: 11px;
}

.stp-time-badge-sm {
    font-size: 10px;
    padding: 2px 5px;
}

.builder-items-col {
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-width: 0;
}

.builder-add-select {
    width: 100%;
}

.builder-palette-head {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-bottom: 8px;
}

.builder-selected {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px;
    background: #fff;
    display: flex;
    flex-direction: column;
    min-height: 80px;
}

.builder-selected-list {
    flex: 1;
}

.builder-empty {
    font-size: 13px;
    color: var(--text-muted);
    margin: 0;
    text-align: center;
    padding: 20px 8px;
}

.builder-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #fff;
    margin-bottom: 6px;
    cursor: grab;
}
.builder-row.dragging { opacity: 0.5; }
.builder-row-handle { color: var(--text-muted); cursor: grab; }
.builder-row-num {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    width: 18px;
    text-align: center;
}
.builder-row-name { flex: 1; font-size: 14px; min-width: 0; }
.builder-row-remove {
    border: none;
    background: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 12px;
    padding: 2px 6px;
    flex-shrink: 0;
}
.builder-row-remove:hover { color: var(--danger); }

.builder-actions {
    display: flex;
    justify-content: flex-end;
    padding-top: 4px;
}

@media (max-width: 768px) {
    .builder-body {
        grid-template-columns: 1fr;
    }

    .builder-name-input {
        max-width: none;
    }

    .stp-week-grid-compact {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

@media (max-width: 480px) {
    .builder-name-row {
        flex-direction: column;
        align-items: stretch;
    }

    .stp-week-grid-compact {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

/* Run group card header / meta */
.group-header-right {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}
.group-schedule-text {
    font-size: 13px;
    color: var(--text-muted);
}
.group-meta {
    font-size: 12px;
    color: var(--text-muted);
    margin: -4px 0 12px;
}
.row-skipped { opacity: 0.55; }

/* Inline group assignment */
.inline-assign-group {
    display: flex;
    align-items: center;
    gap: 4px;
}

.text-input-sm {
    width: 130px;
    padding: 4px 8px;
    font-size: 12px;
}

/* Cron editor (settings page) */
.cron-editor {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.cron-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.cron-at {
    font-size: 13px;
    color: var(--text-muted);
    padding: 0 2px;
}

/* Schedule form (legacy narrow forms; builder uses .builder-layout) */
.schedule-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.schedule-form .form-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.schedule-form .form-row > label {
    width: 80px;
    flex-shrink: 0;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
}

.schedule-form .select-input:not(.select-narrow) {
    min-width: 200px;
}

.time-picker {
    display: flex;
    align-items: center;
    gap: 6px;
}

.time-sep {
    font-weight: 600;
    font-size: 16px;
    color: var(--text-muted);
}

.select-narrow { width: 100px; }

/* Toast notification */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: var(--success);
    color: white;
    padding: 10px 24px;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 100;
}

/* Wiki prose (rendered markdown in wiki cards) */
.wiki-prose { font-size: 14px; line-height: 1.7; margin-top: 12px; }
.wiki-prose h1, .wiki-prose h2, .wiki-prose h3 { margin: 16px 0 8px; font-weight: 600; }
.wiki-prose h1 { font-size: 20px; }
.wiki-prose h2 { font-size: 16px; }
.wiki-prose h3 { font-size: 14px; }
.wiki-prose p { margin: 8px 0; }
.wiki-prose ul, .wiki-prose ol { margin: 8px 0; padding-left: 24px; }
.wiki-prose li { margin: 4px 0; }
.wiki-prose code {
    background: #f1f5f9;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 13px;
    font-family: "Cascadia Code", "Fira Code", "Consolas", monospace;
}
.wiki-prose pre {
    background: #1e293b;
    color: #e2e8f0;
    padding: 16px;
    border-radius: var(--radius);
    overflow-x: auto;
    font-size: 13px;
    margin: 12px 0;
}
.wiki-prose pre code {
    background: none;
    padding: 0;
    color: inherit;
}
.wiki-prose hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 16px 0;
}

/* Wiki guide section */
.wiki-guide-code {
    background: #1e293b;
    color: #e2e8f0;
    padding: 16px;
    border-radius: var(--radius);
    overflow-x: auto;
    max-width: 100%;
    min-width: 0;
    font-size: 13px;
    font-family: "Cascadia Code", "Fira Code", "Consolas", monospace;
    margin: 12px 0;
    white-space: pre;
    line-height: 1.5;
}

/* Wiki tab navigation */
.wiki-tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--border);
    margin-bottom: 24px;
}

.wiki-tab {
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-muted);
    text-decoration: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: color 0.15s, border-color 0.15s;
}

.wiki-tab:hover {
    color: var(--text);
}

.wiki-tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.wiki-section {
    margin-top: 4px;
    min-width: 0;
}

.wiki-section .card {
    min-width: 0;
}

/* Wiki tables: wrap prose cells instead of stretching the page */
.wiki-section .data-table {
    table-layout: fixed;
    width: 100%;
}

.wiki-section .data-table th,
.wiki-section .data-table td {
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
    vertical-align: top;
    overflow-wrap: break-word;
    word-wrap: break-word;
}

.wiki-section .data-table td code {
    word-break: break-word;
}

/* Repository Structure: give the description column most of the width */
.wiki-section .data-table.repo-structure-table th:nth-child(1),
.wiki-section .data-table.repo-structure-table td:nth-child(1) {
    width: 14%;
}

.wiki-section .data-table.repo-structure-table th:nth-child(2),
.wiki-section .data-table.repo-structure-table td:nth-child(2) {
    width: 46%;
}

.wiki-section .data-table.repo-structure-table th:nth-child(3),
.wiki-section .data-table.repo-structure-table td:nth-child(3) {
    width: 40%;
}

/* Schema tables (wiki database page) */
.schema-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    margin: 8px 0 0;
}

.schema-table th {
    text-align: left;
    padding: 6px 10px;
    border-bottom: 2px solid var(--border);
    color: var(--text-muted);
    font-weight: 500;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.schema-table td {
    padding: 5px 10px;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}

.schema-table code {
    background: #f1f5f9;
    padding: 1px 5px;
    border-radius: 3px;
    font-size: 12px;
    font-family: "Cascadia Code", "Fira Code", "Consolas", monospace;
}

.schema-table .pk { font-weight: 600; }

.schema-table .fk { color: var(--primary); }

/* Wiki info callout */
.wiki-callout {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: var(--radius);
    padding: 16px 20px;
    margin: 16px 0;
    font-size: 14px;
    line-height: 1.6;
}

.wiki-callout p { margin: 4px 0; }

.wiki-callout code {
    background: #dbeafe;
    padding: 1px 5px;
    border-radius: 3px;
    font-size: 13px;
    font-family: "Cascadia Code", "Fira Code", "Consolas", monospace;
}

/* Job detail info card */
.job-info-card {
    margin-bottom: 20px;
}

.job-info-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
}

.job-info-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.job-info-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.job-info-value {
    font-size: 14px;
    font-weight: 500;
    color: var(--text);
}

/* Settings snapshot on job detail */
.settings-snapshot {
    margin-top: 8px;
}

.snapshot-group {
    margin-bottom: 16px;
    border: 1px solid var(--border);
    border-radius: 6px;
    overflow: hidden;
}

.snapshot-group:last-child {
    margin-bottom: 0;
}

.snapshot-group-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    background: #f8fafc;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    user-select: none;
}

.snapshot-group-header:hover {
    background: #f1f5f9;
}

.snapshot-group-header-collapsed {
    border-bottom: none;
}

.snapshot-group-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    margin: 0;
    flex: 1;
    min-width: 0;
    border-bottom: none;
    padding-bottom: 0;
}

.snapshot-group-metrics {
    display: flex;
    align-items: center;
    gap: 20px;
    flex-shrink: 0;
    font-size: 13px;
}

.snapshot-metric {
    display: flex;
    align-items: baseline;
    gap: 6px;
    white-space: nowrap;
}

.snapshot-metric-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--text-muted);
}

.snapshot-group > div:last-child {
    padding: 0 12px 12px;
}

.snapshot-table {
    table-layout: fixed;
    width: 100%;
}

.snapshot-table th:first-child,
.snapshot-table td:first-child { width: 55%; }

.snapshot-table th:last-child,
.snapshot-table td:last-child { width: 45%; }

.snapshot-table td {
    white-space: normal;
    overflow: visible;
    vertical-align: top;
}

.snapshot-label {
    font-size: 13px;
    font-weight: 500;
    display: block;
}

.snapshot-key {
    font-size: 11px;
    color: var(--text-muted);
    font-family: "Cascadia Code", "Fira Code", "Consolas", monospace;
    display: block;
    margin-top: 2px;
}

.snapshot-value {
    background: #f1f5f9;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 13px;
    font-family: "Cascadia Code", "Fira Code", "Consolas", monospace;
    word-break: break-all;
}

.path-link {
    color: var(--primary, #2563eb);
    text-decoration: underline;
    cursor: pointer;
}

.path-link:hover {
    background: #e0e7ff;
}

.snapshot-meta {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.snapshot-meta-row {
    font-size: 11px;
    color: var(--text-muted);
    display: block;
    margin-top: 4px;
}

.snapshot-table .setting-desc {
    display: block;
    margin-top: 2px;
}

.snapshot-table td:last-child .text-input {
    width: 100%;
    box-sizing: border-box;
}

.snapshot-table td:last-child .cron-row {
    flex-wrap: wrap;
}

.snapshot-scope-note {
    font-size: 12px;
    color: var(--text-muted);
    background: #f8fafc;
    border-left: 3px solid var(--border);
    padding: 6px 10px;
    margin: 0 0 12px 0;
    border-radius: 4px;
}

.snapshot-group-tag {
    font-size: 13px;
    font-weight: 400;
    color: var(--text-muted);
    margin-left: 6px;
}

/* Settings page */
.settings-toolbar-card {
    padding-bottom: 12px;
}

.settings-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.settings-job-select {
    flex: 1;
    min-width: 280px;
    max-width: 480px;
}

.settings-server-compact {
    margin-top: 4px;
    padding-top: 12px;
}

.settings-server-row {
    margin-bottom: 10px;
}

.settings-server-branch {
    font-size: 13px;
    color: var(--text-muted);
}

.settings-server-test-note {
    color: var(--danger);
    margin-left: 6px;
}

.settings-server-actions {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}

.settings-server-action {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    flex: 1;
    min-width: 260px;
}

.settings-server-action-label {
    font-weight: 600;
    font-size: 13px;
    white-space: nowrap;
}

.settings-server-action-desc {
    font-size: 12px;
    color: var(--text-muted);
    flex: 1;
    min-width: 120px;
}

.settings-server-status {
    display: block;
    margin-top: 8px;
    color: var(--text-muted);
    font-size: 12px;
}

.settings-update-log {
    margin-top: 8px;
}

.settings-update-log-title {
    font-weight: 600;
    font-size: 12px;
    margin-bottom: 4px;
}

.settings-update-log-pre {
    max-height: 160px;
    overflow: auto;
    background: var(--bg-muted, #f4f4f5);
    padding: 8px;
    border-radius: 6px;
    font-size: 11px;
    white-space: pre-wrap;
    margin: 0;
}

.settings-console-card {
    margin-top: 16px;
}

.settings-console-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.settings-console-header h3 {
    margin: 0;
}

.settings-console-hint {
    color: var(--text-muted);
    font-size: 12px;
    flex: 1;
}

.settings-console-viewer {
    max-height: 360px;
    min-height: 160px;
}

.settings-console-line {
    display: block;
    white-space: pre-wrap;
    word-break: break-all;
    padding: 1px 0;
}

.settings-general-block {
    margin-top: 20px;
    padding-top: 12px;
    border-top: 1px solid var(--border, #e4e4e7);
}

.settings-restart-modal h3 {
    margin: 0 0 8px;
}

.settings-restart-help {
    margin: 0 0 16px;
    color: var(--text-muted);
    font-size: 13px;
}

.settings-restart-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.settings-default-card {
    margin-top: 0;
}

.settings-default-title {
    text-align: center;
    margin-bottom: 12px;
}

.settings-default-group {
    margin-bottom: 8px;
    border-bottom: none;
    padding-bottom: 0;
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    z-index: 1000;
    overflow-y: auto;
    padding: 40px 16px;
}

.modal-panel {
    background: #ffffff;
    border-radius: 8px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
    width: 100%;
    max-width: 720px;
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 80px);
}

.modal-header,
.modal-footer {
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.modal-footer {
    border-bottom: none;
    border-top: 1px solid var(--border);
    justify-content: flex-end;
}

.modal-footer-spread {
    justify-content: space-between;
}

.modal-footer-left {
    display: flex;
    gap: 8px;
    align-items: center;
}

.modal-header h3 {
    margin: 0;
    font-size: 16px;
}

.modal-body {
    padding: 16px 18px;
    overflow-y: auto;
    flex: 1;
}

/* Schedule Time Picker v2 */

.stp-section { margin-bottom: 16px; }

.stp-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

.stp-days { display: flex; gap: 4px; flex-wrap: wrap; }

.stp-day-btn {
    width: 44px;
    height: 34px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: white;
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    position: relative;
    transition: all 0.12s;
}

.stp-day-btn:hover { border-color: var(--primary); color: var(--primary); }

.stp-day-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

.stp-day-btn.active:hover {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
}

.stp-day-dot {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--success);
}

.stp-checkbox-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
    cursor: pointer;
    user-select: none;
}

.stp-checkbox {
    width: 16px;
    height: 16px;
    border-radius: 4px;
    border: 2px solid var(--border);
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.12s;
    flex-shrink: 0;
}

.stp-checkbox.checked {
    background: var(--primary);
    border-color: var(--primary);
}

.stp-checkbox-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
}

.stp-checkbox.checked + .stp-checkbox-label { color: var(--text); }

.stp-time-row {
    display: flex;
    gap: 6px;
    align-items: center;
}

.stp-colon {
    font-weight: 700;
    font-size: 18px;
    color: var(--text-muted);
}

.stp-combo {
    position: relative;
    flex-shrink: 0;
}

.stp-combo-field {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 7px 10px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: white;
    cursor: text;
    min-height: 36px;
    width: 80px;
    transition: border-color 0.12s;
}

.stp-combo-field.open { border-color: var(--primary); }

.stp-combo-display {
    font-size: 14px;
    color: var(--text);
    width: 100%;
    text-align: center;
    cursor: text;
    user-select: none;
}

.stp-combo-display.placeholder { color: var(--text-muted); }

.stp-combo-input {
    border: none;
    outline: none;
    background: transparent;
    color: var(--text);
    font-family: inherit;
    font-size: 14px;
    width: 100%;
    text-align: center;
    padding: 0;
}

.stp-combo-arrow {
    flex-shrink: 0;
    margin-left: 4px;
    cursor: pointer;
    opacity: 0.4;
}

.stp-combo-dropdown {
    position: absolute;
    top: calc(100% + 2px);
    left: 0;
    right: 0;
    max-height: 180px;
    overflow-y: auto;
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 4px 16px rgba(0,0,0,0.1);
    z-index: 20;
}

.stp-combo-option {
    padding: 7px 10px;
    cursor: pointer;
    font-size: 14px;
    text-align: center;
    color: var(--text);
}

.stp-combo-option:hover { background: #f8fafc; }
.stp-combo-option.selected { color: var(--primary); background: #eff6ff; }

.stp-period-toggle {
    display: flex;
    border-radius: 6px;
    border: 1px solid var(--border);
    overflow: hidden;
}

.stp-period-btn {
    padding: 7px 14px;
    border: none;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    background: white;
    color: var(--text-muted);
    transition: all 0.12s;
}

.stp-period-btn.active {
    background: var(--primary);
    color: white;
}

.stp-add-btn {
    width: 34px;
    height: 34px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: white;
    color: var(--text-muted);
    font-size: 20px;
    cursor: not-allowed;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.12s;
    opacity: 0.4;
}

.stp-add-btn.ready {
    border-color: var(--primary);
    background: #eff6ff;
    color: var(--primary);
    cursor: pointer;
    opacity: 1;
}

.stp-add-btn.ready:hover {
    background: var(--primary);
    color: white;
}

.stp-week-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 0;
    border-bottom: 1px solid var(--border);
}

.stp-week-row:last-child { border-bottom: none; }

.stp-week-day-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    width: 36px;
    flex-shrink: 0;
}

.stp-not-set {
    font-size: 12px;
    color: #cbd5e1;
    font-style: italic;
}

.stp-time-badges { display: flex; gap: 6px; flex-wrap: wrap; }

.stp-time-badge {
    padding: 3px 10px;
    border-radius: 6px;
    background: #dcfce7;
    border: 1px solid #bbf7d0;
    font-size: 12px;
    font-weight: 500;
    color: #166534;
    cursor: default;
    transition: all 0.15s;
    user-select: none;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.stp-time-badge .stp-badge-x {
    display: none;
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
}

.stp-time-badge:hover {
    background: #fee2e2;
    border-color: #fca5a5;
    color: #991b1b;
    cursor: pointer;
}

.stp-time-badge:hover .stp-badge-x { display: inline; }

/* System metrics tiles */
.metrics-card {
    margin-bottom: 20px;
}

.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 16px;
}

.metric-tile {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 12px;
    background: #f8fafc;
    border-radius: 6px;
    border: 1px solid var(--border);
}

.metric-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.metric-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--text);
    line-height: 1.1;
    font-variant-numeric: tabular-nums;
}

.metric-value-sm {
    font-size: 14px;
    font-weight: 600;
}

.metric-sub {
    font-size: 12px;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

.metric-bar {
    height: 6px;
    background: #e2e8f0;
    border-radius: 3px;
    overflow: hidden;
    margin: 4px 0 2px;
}

.metric-bar-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.4s ease;
}

.bar-ok { background: var(--success); }
.bar-warning { background: var(--warning); }
.bar-danger { background: var(--danger); }

/* Blackbaud webhook tile */
.webhook-card {
    margin-bottom: 20px;
}

.webhook-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.webhook-header-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.webhook-alert {
    margin-top: 12px;
    padding: 10px 12px;
    border-radius: var(--radius);
    background: #fef3c7;
    color: #92400e;
    font-size: 13px;
    border: 1px solid #fcd34d;
}

.webhook-alert-action {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.webhook-alert-warn {
    display: flex;
    flex-direction: column;
    gap: 4px;
    background: #fee2e2;
    border-color: #fca5a5;
    color: #991b1b;
}

.webhook-health .health-bad {
    color: #b91c1c;
    font-weight: 600;
}

.webhook-alert code {
    background: rgba(0,0,0,0.06);
    padding: 1px 5px;
    border-radius: 4px;
}

.btn-inline {
    display: inline-block;
    background: var(--primary);
    color: #fff;
    text-decoration: none;
    padding: 6px 12px;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
}

.btn-inline:hover { background: var(--primary-hover); }

.webhook-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 18px;
    margin-top: 14px;
    font-size: 13px;
    color: var(--text-muted);
}

.webhook-meta code {
    background: var(--bg);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 12px;
    color: var(--text);
}

.webhook-subs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 14px;
}

.sub-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    border: 1px solid var(--border);
}

.sub-ok { background: #dcfce7; color: #166534; border-color: #86efac; }
.sub-bad { background: #fee2e2; color: #991b1b; border-color: #fca5a5; }

.sub-status {
    font-weight: 400;
    opacity: 0.8;
}

.webhook-feed-title {
    margin-top: 20px;
    margin-bottom: 8px;
    font-size: 14px;
    color: var(--text-muted);
}

.webhook-feed {
    max-height: 320px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.webhook-feed-empty {
    margin: 0;
    padding: 16px 12px;
}

.webhook-events-table {
    font-size: 13px;
}

.webhook-events-table th {
    position: sticky;
    top: 0;
    background: var(--card-bg);
    z-index: 1;
}

.webhook-event-type {
    font-weight: 600;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.webhook-event-rejected .webhook-event-type {
    color: var(--danger, #c0392b);
}

.webhook-record-type {
    color: var(--text-muted);
    text-transform: capitalize;
}

.webhook-record-id {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.webhook-received-at {
    color: var(--text-muted);
    font-size: 12px;
    white-space: nowrap;
}

/* All Gifts Check tool */

.agc-intro {
    color: var(--text-muted);
    font-size: 14px;
    margin: 0 0 16px;
    max-width: 820px;
}

.agc-meta {
    color: var(--text-muted);
    font-size: 14px;
    margin: 0 0 12px;
}

.agc-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.agc-blocked {
    color: var(--danger, #991b1b);
    font-size: 14px;
    margin: 12px 0 0;
}

.agc-alert {
    margin-bottom: 16px;
}

.agc-alert p {
    margin: 0;
}

.agc-alert-error {
    border-color: var(--danger, #991b1b);
}

.agc-alert-error p {
    color: var(--danger, #991b1b);
}

.agc-alert-info {
    background: var(--primary-light, #eff6ff);
}

.agc-alert-warn {
    border-color: var(--warning, #b8860b);
}

.agc-date-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px 16px;
    align-items: flex-end;
    margin-bottom: 16px;
}

.agc-date-row .form-group {
    margin-bottom: 0;
    min-width: 180px;
}

.agc-date-row input[type="date"] {
    width: 100%;
    padding: 8px 10px;
    font-size: 14px;
}

.agc-settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px 16px;
    margin-bottom: 16px;
}

.agc-combo-toolbar {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.agc-workbook-toolbar {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    margin-bottom: 12px;
}

.agc-sort-indicator {
    font-size: 11px;
    opacity: 0.9;
}

.workbook-shell {
    padding: 0;
    overflow: hidden;
}

.workbook-scroll {
    overflow: auto;
    max-height: calc(100vh - 260px);
}

.workbook-grid {
    width: max-content;
    min-width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 13px;
}

.workbook-grid.resizable-table {
    table-layout: fixed;
    width: auto;
    min-width: 100%;
}

.workbook-grid th,
.workbook-grid td {
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    padding: 0;
    white-space: nowrap;
    vertical-align: middle;
    overflow: visible;
    text-overflow: clip;
    max-width: none;
}

.workbook-grid thead th {
    position: sticky;
    top: 0;
    z-index: 3;
    background: #4472c4;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    text-transform: none;
    letter-spacing: 0;
    padding: 8px 10px;
    cursor: grab;
}

.workbook-grid thead th:active {
    cursor: grabbing;
}

.workbook-grid thead th.sortable-header {
    user-select: none;
}

.workbook-grid thead th.workbook-header-error {
    background: #5b7fbd;
}

.workbook-grid tbody tr:nth-child(even) td {
    background: #f8fafc;
}

.workbook-grid tbody tr.workbook-row-error td {
    background: #fff5f5;
}

.workbook-grid tbody tr.workbook-row-error td.workbook-error-cell {
    background: #ffc7c7;
}

.workbook-grid tbody tr.workbook-row-error td.workbook-error-cell .workbook-cell-input {
    font-weight: 600;
}

.workbook-col-action {
    position: sticky;
    right: 0;
    background: var(--surface);
    padding: 8px 10px;
    text-align: center;
    z-index: 2;
}

.workbook-cell-input {
    display: block;
    width: 100%;
    min-width: 88px;
    border: none;
    background: transparent;
    padding: 8px 10px;
    font: inherit;
    color: inherit;
    box-sizing: border-box;
}

.workbook-cell-editable {
    background: #fff;
    cursor: text;
}

.workbook-cell-readonly {
    cursor: default;
}

.workbook-cell-readonly[readonly] {
    pointer-events: auto;
}

.workbook-grid td.workbook-cell:has(.workbook-cell-editable) {
    background: #fff;
}

.workbook-cell-input:focus {
    outline: 2px solid var(--primary);
    outline-offset: -2px;
    background: #fff;
}

.workbook-cell-editable:focus {
    background: #fff;
}

.workbook-grid a {
    color: #2f72ed;
    text-decoration: underline;
    padding: 8px 10px;
    display: inline-block;
}

.table-inline-input {
    width: 100%;
    min-width: 72px;
    padding: 6px 8px;
    font-size: 13px;
    font-family: inherit;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface, #fff);
}

.table-inline-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary-light, #eff6ff);
}

/* ------------------------------------------------------------------
   Collapsible sections in tool settings modals (Letters, OCA Export)
   ------------------------------------------------------------------ */

.tool-sec {
    border: 1px solid var(--border, #e5e7eb);
    border-radius: 8px;
    margin-bottom: 12px;
    overflow: hidden;
}

.tool-sec-head {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    color: inherit;
    text-align: left;
}

.tool-sec-head:hover {
    background: rgba(0, 0, 0, 0.03);
}

.tool-sec-hint {
    margin-left: auto;
    font-weight: 400;
    font-size: 12px;
    color: var(--muted, #6b7280);
    white-space: nowrap;
}

.tool-sec-body {
    padding: 2px 14px 14px;
}

/* Grouped, scrollable mail-code picker */

.mc-picker {
    border: 1px solid var(--border, #d1d5db);
    border-radius: 6px;
    max-height: 240px;
    overflow-y: auto;
    background: var(--surface, #fff);
}

.mc-group + .mc-group {
    border-top: 1px solid var(--border, #e5e7eb);
}

.mc-group-head {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 12px;
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    color: inherit;
    text-align: left;
}

.mc-group-head:hover {
    background: rgba(0, 0, 0, 0.03);
}

.mc-count {
    font-weight: 400;
    font-size: 12px;
    color: var(--muted, #6b7280);
    white-space: nowrap;
}

.mc-group-body {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 6px 16px;
    padding: 2px 12px 10px;
}

.mc-check {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    font-weight: normal;
    font-size: 13px;
    line-height: 1.3;
    min-width: 0;
}

.mc-check input[type="checkbox"] {
    width: auto;
    min-width: 16px;
    max-width: 16px;
    height: 16px;
    margin: 0;
    flex: 0 0 auto;
    align-self: center;
}

.mc-check span {
    flex: 1 1 auto;
    min-width: 0;
    white-space: normal;
}

.mc-empty {
    margin: 0;
    padding: 8px 12px;
    font-size: 12px;
    color: var(--muted, #6b7280);
}

.appeal-id-picker {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 280px;
    max-width: 520px;
}

.appeal-id-picker-hint {
    margin: 0;
    font-size: 12px;
    color: var(--muted, #6b7280);
}

.appeal-id-picker-grid {
    border: 1px solid var(--border, #e5e7eb);
    border-radius: 6px;
    max-height: 180px;
    overflow-y: auto;
    padding: 6px 10px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 4px 12px;
}

/* Configure Columns modal (export_columns settings) */
.ec-modal {
    max-width: 1280px;
    width: 95%;
    max-height: 92vh;
}

.ec-launcher {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.ec-summary {
    font-size: 13px;
    color: var(--muted, #6b7280);
    max-width: 460px;
}

.ec-body {
    display: grid;
    grid-template-columns: minmax(300px, 2fr) minmax(420px, 3fr);
    gap: 20px;
    align-items: start;
}

.ec-panel-title {
    font-weight: 600;
    margin-bottom: 8px;
}

.ec-search {
    width: 100%;
    margin-bottom: 8px;
}

.ec-groups {
    border: 1px solid var(--border, #e5e7eb);
    border-radius: 6px;
    max-height: calc(92vh - 280px);
    overflow-y: auto;
    padding: 8px 10px;
}

.ec-group-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 2px 10px;
    margin-bottom: 8px;
}

.ec-hint {
    margin: 0 0 8px 0;
    font-size: 12px;
    color: var(--muted, #6b7280);
}

.ec-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-height: calc(92vh - 240px);
    overflow-y: auto;
}

.ec-row {
    display: flex;
    align-items: center;
    gap: 8px;
    border: 1px solid var(--border, #e5e7eb);
    border-radius: 6px;
    padding: 4px 8px;
    background: #ffffff;
}

.ec-row-dragging {
    opacity: 0.4;
}

.ec-drag-handle {
    cursor: grab;
    color: var(--muted, #9ca3af);
    font-weight: 700;
    letter-spacing: 1px;
    user-select: none;
    flex: 0 0 auto;
}

.ec-row-main {
    flex: 1 1 auto;
    min-width: 0;
}

.ec-row-name {
    font-size: 13px;
    word-break: normal;
    overflow-wrap: break-word;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
}

.ec-row-source {
    color: var(--muted, #9ca3af);
    font-size: 12px;
    margin-left: 6px;
}

.ec-row-actions {
    display: flex;
    gap: 4px;
    flex: 0 0 auto;
}

.ec-heading-input {
    width: 100%;
}

.ec-footer {
    display: flex;
    align-items: center;
    gap: 8px;
}

.ec-footer-spacer {
    flex: 1 1 auto;
}

.mcr-editor {
    min-width: 280px;
    max-width: 520px;
}

.mcr-add {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
}

.mcr-add select {
    flex: 1 1 auto;
    min-width: 0;
    font-size: 13px;
}

.mcr-list {
    border: 1px solid var(--border, #d1d5db);
    border-radius: 6px;
    max-height: 320px;
    overflow-y: auto;
}

.mcr-rule + .mcr-rule {
    border-top: 1px solid var(--border, #e5e7eb);
}

.mcr-rule-head {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 10px;
}

.mcr-code {
    flex: 1 1 auto;
    min-width: 0;
    font-size: 13px;
    font-weight: 500;
}

.mcr-scope {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 12px;
    color: var(--muted);
    white-space: nowrap;
    padding: 2px 4px;
}

.mcr-scope:hover {
    text-decoration: underline;
}

.mcr-scope-editor {
    padding: 0 10px 10px;
}

.mcr-hint {
    margin: 0 0 6px;
    font-size: 11px;
    color: var(--muted);
}

.mcr-appeals {
    border: 1px solid var(--border, #e5e7eb);
    border-radius: 6px;
    max-height: 150px;
    overflow-y: auto;
    padding: 6px 10px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 4px 12px;
}

.mcr-clear {
    margin-top: 6px;
}

.mcr-empty {
    margin: 0;
    padding: 8px 0;
    font-size: 12px;
    color: var(--muted);
}

/* Data-check correction grid (_data_check_dialog.html / data_check_grid.js) */
.dcd-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}
.dcd-dialog {
    background: #1e1e1e;
    color: #e0e0e0;
    width: 96vw;
    height: 90vh;
    border-radius: 6px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    font-size: 13px;
}
.dcd-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
}
.dcd-title {
    font-size: 16px;
    font-weight: bold;
    color: #ffffff;
}
.dcd-row-count {
    font-size: 12px;
    color: #a0a0a0;
}
.dcd-group {
    border: 1px solid #404040;
    border-radius: 4px;
    padding: 8px 12px;
}
.dcd-group-title {
    font-weight: bold;
    margin-bottom: 8px;
}
.dcd-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 6px;
}
.dcd-toolbar label { color: #e0e0e0; }
.dcd-toolbar select,
.dcd-toolbar input[type="text"] {
    background: #2d2d2d;
    color: #e0e0e0;
    border: 1px solid #5a5a5a;
    border-radius: 3px;
    padding: 6px;
    min-width: 200px;
}
.dcd-toolbar input.dcd-fill-input { min-width: 160px; }
.dcd-toolbar input[type="text"]:disabled { opacity: 0.5; }
.dcd-sel-count {
    min-width: 80px;
    color: #a0a0a0;
}
.dcd-check {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-weight: normal;
}
.dcd-hint {
    font-size: 11px;
    color: #a0a0a0;
    margin: 0;
}
.dcd-table-wrap {
    flex: 1;
    overflow: auto;
    border: 1px solid #404040;
}
.dcd-table-wrap:focus {
    outline: none;
    border-color: #0078d4;
}
.dcd-table {
    border-collapse: collapse;
    width: 100%;
    user-select: none;
}
.dcd-table th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: #3c3c3c;
    color: #ffffff;
    border: 1px solid #555555;
    padding: 6px;
    font-weight: bold;
    cursor: pointer;
    white-space: nowrap;
    user-select: none;
}
.dcd-table td {
    background: #2d2d2d;
    color: #e0e0e0;
    border: 1px solid #404040;
    padding: 4px 6px;
    min-width: 90px;
    height: 20px;
    white-space: nowrap;
    cursor: cell;
}
.dcd-table td.dcd-error-cell {
    background: #f8d7da;
    color: #842029;
}
.dcd-table td.dcd-selected {
    background: #264f78;
    color: #ffffff;
}
.dcd-table td.dcd-error-cell.dcd-selected {
    background: #8a3b44;
    color: #ffffff;
}
.dcd-table td.dcd-active {
    outline: 2px solid #0078d4;
    outline-offset: -2px;
}
.dcd-table td.dcd-editing {
    background: #ffffff;
    color: #000000;
    padding: 0;
}
.dcd-cell-input {
    width: 100%;
    height: 100%;
    min-height: 28px;
    box-sizing: border-box;
    border: none;
    outline: none;
    padding: 4px 6px;
    margin: 0;
    background: #ffffff;
    color: #000000;
    font: inherit;
}
.dcd-table tr.dcd-dropped td {
    text-decoration: line-through;
    opacity: 0.55;
}
.dcd-check-cell {
    text-align: center;
    cursor: default;
}
.dcd-footer {
    display: flex;
    align-items: center;
    gap: 8px;
}
.dcd-spacer { flex: 1; }
.dcd-pager {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-left: 16px;
    color: #a0a0a0;
}
.dcd-btn {
    background: #3c3c3c;
    color: #ffffff;
    border: 1px solid #555555;
    padding: 8px 16px;
    border-radius: 4px;
    font-weight: 500;
    cursor: pointer;
}
.dcd-btn:hover { background: #4a4a4a; }
.dcd-btn:disabled { opacity: 0.6; cursor: default; }
.dcd-btn-primary {
    background: #0078d4;
    border-color: #0078d4;
    min-width: 180px;
}
.dcd-btn-primary:hover { background: #1084d8; }
.dcd-btn-danger {
    background: #c42b1c;
    border-color: #c42b1c;
    min-width: 100px;
}
.dcd-btn-danger:hover { background: #d83b2d; }

/* Mobile top bar + drawer nav */
.mobile-topbar {
    display: none;
}

.mobile-menu-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--card-bg);
    color: var(--text);
    cursor: pointer;
}

.mobile-menu-btn svg {
    width: 20px;
    height: 20px;
}

.mobile-topbar-title {
    font-size: 16px;
    font-weight: 600;
}

.nav-backdrop {
    display: none;
}

@media (max-width: 900px) {
    body {
        flex-direction: column;
        overflow-x: hidden;
    }

    .mobile-topbar {
        display: flex;
        align-items: center;
        gap: 12px;
        position: sticky;
        top: 0;
        z-index: 20;
        padding: 10px 12px;
        background: var(--card-bg);
        border-bottom: 1px solid var(--border);
        margin-left: 0;
        width: 100%;
        flex-shrink: 0;
    }

    .sidebar {
        width: min(280px, 86vw);
        transform: translateX(-105%);
        transition: transform 0.2s ease, width 0.2s ease;
        z-index: 40;
        box-shadow: none;
    }

    html.nav-collapsed .sidebar {
        width: min(280px, 86vw);
    }

    html.nav-collapsed .workspace-title,
    html.nav-collapsed .workspace-caret,
    html.nav-collapsed .nav-label,
    html.nav-collapsed .footer-label {
        display: inline;
    }

    html.nav-collapsed .workspace-switch-button {
        justify-content: space-between;
        padding: 8px 10px;
    }

    html.nav-collapsed .sidebar-header {
        padding: 16px 12px;
    }

    html.nav-collapsed .sidebar-toggle,
    html.nav-collapsed .sidebar-logout-btn {
        justify-content: flex-start;
        padding-left: 20px;
        padding-right: 20px;
    }

    html.nav-open .sidebar {
        transform: translateX(0);
        box-shadow: 8px 0 24px rgba(0, 0, 0, 0.25);
    }

    .nav-backdrop {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(15, 23, 42, 0.45);
        z-index: 30;
        border: none;
        padding: 0;
        margin: 0;
        cursor: pointer;
    }

    html.nav-open .nav-backdrop {
        display: block;
    }

    .content,
    html.nav-collapsed .content {
        margin-left: 0;
        padding: 16px 12px;
        width: 100%;
        max-width: 100%;
        min-width: 0;
    }

    .sidebar-toggle {
        display: none;
    }

    h1 {
        font-size: 20px;
        margin-bottom: 16px;
    }

    .card-grid {
        grid-template-columns: 1fr;
    }

    .card {
        padding: 14px;
        margin-bottom: 14px;
    }

    .metrics-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .job-info-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 12px;
    }

    .setting-row {
        grid-template-columns: 1fr;
        align-items: stretch;
        gap: 8px;
    }

    .setting-value {
        min-width: 0;
        width: 100%;
    }

    .setting-meta {
        white-space: normal;
    }

    .login-card {
        margin: 16px;
        padding: 28px 20px;
        max-width: calc(100% - 32px);
    }

    .wiki-tabs {
        flex-wrap: wrap;
        gap: 8px;
    }

    .builder-body,
    .ec-body {
        grid-template-columns: 1fr;
    }

    .table-wrap,
    .data-table-wrap {
        overflow-x: auto;
        max-width: 100%;
    }

    .tools-page {
        max-width: 100%;
    }

    .tool-row {
        flex-direction: column;
        align-items: stretch;
    }

    .tool-row .btn-primary,
    .tool-row a.btn-primary,
    .tool-row a.btn-small {
        width: 100%;
        text-align: center;
    }

    .section-body {
        padding-left: 0;
    }

    table {
        display: block;
        max-width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .group-header,
    .group-header-right,
    .cron-row,
    .form-row {
        flex-wrap: wrap;
    }

    .form-row label {
        width: 100%;
    }

    .form-row input[type="text"],
    .form-row select {
        max-width: 100%;
    }

    .modal-panel {
        width: calc(100vw - 16px);
        max-width: calc(100vw - 16px);
        margin: 8px;
    }

    .ltr-wide,
    .ltr-full {
        min-width: 0;
        max-width: 100%;
    }

    .setting-input-sm {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .metrics-grid {
        grid-template-columns: 1fr;
    }

    .job-info-grid {
        grid-template-columns: 1fr;
    }
}
