:root {
    --bg: #10131a;
    --panel: #171b24;
    --panel-2: #202635;
    --text: #e7eaf0;
    --muted: #9aa4b5;
    --line: #2b3345;
    --primary: #4d8dff;
    --primary-hover: #397cf0;
    --danger: #d94f4f;
    --danger-hover: #c94444;
    --warning: #d9a441;
    --warning-hover: #c8912f;
    --secondary: #394255;
    --secondary-hover: #465169;
    --success: #3ca66b;
    --error-bg: #3a1e24;
    --error-border: #9b3e4c;
    --success-bg: #193326;
    --success-border: #3ca66b;
}

html.theme-light {
    --bg: #f4f6fa;
    --panel: #ffffff;
    --panel-2: #eef2f8;
    --text: #1f2937;
    --muted: #5f6b7a;
    --line: #d8dee8;
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --danger: #dc2626;
    --danger-hover: #b91c1c;
    --warning: #c17f1a;
    --warning-hover: #a76513;
    --secondary: #d9e1ee;
    --secondary-hover: #c9d3e3;
    --success: #15803d;
    --error-bg: #fee2e2;
    --error-border: #f87171;
    --success-bg: #dcfce7;
    --success-border: #22c55e;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    font-family: Arial, Helvetica, sans-serif;
    font-size: 15px;
}

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

a:hover {
    color: white;
}

/* Layout */

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 16px 24px;
    border-bottom: 1px solid var(--line);
    background: var(--panel);
}

.brand {
    min-width: 240px;
}

.brand-title {
    font-size: 20px;
    font-weight: 700;
}

.brand-subtitle {
    color: var(--muted);
    font-size: 13px;
    margin-top: 2px;
}

.container {
    width: min(1680px, calc(100% - 32px));
    margin: 24px auto;
}

.page-header {
    margin-bottom: 18px;
}

h1,
h2 {
    margin: 0 0 10px 0;
}

h1 {
    font-size: 28px;
}

h2 {
    font-size: 20px;
}

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

.card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 18px;
    margin-bottom: 18px;
}

.grid {
    display: grid;
    gap: 18px;
}

.grid.two {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid.three {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

/* Navigation */

.nav-toggle {
    display: none;
    min-height: 36px;
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: var(--panel-2);
    color: var(--text);
    font-weight: 700;
    cursor: pointer;
}

.nav-toggle:hover {
    background: var(--secondary-hover);
}

.nav {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    flex-wrap: nowrap;
}

.nav-link,
.nav-group-button,
.nav-dropdown a,
.nav-theme-button {
    padding: 8px 12px;
    background: var(--panel-2);
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--text);
    font: inherit;
    font-weight: 700;
    line-height: 1.2;
    cursor: pointer;
}

.nav-link:hover,
.nav-group-button:hover,
.nav-dropdown a:hover,
.nav-theme-button:hover {
    background: var(--secondary-hover);
    color: white;
}

.nav-group {
    position: relative;
}

.nav-group-button {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.nav-theme-button {
    min-height: 36px;
    white-space: nowrap;
}

.nav-caret {
    color: var(--muted);
    font-size: 12px;
}

.nav-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 50;
    min-width: 180px;
    padding: 8px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--panel);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
}

.nav-dropdown-right {
    left: auto;
    right: 0;
}

.nav-dropdown a {
    display: block;
    margin-bottom: 6px;
    white-space: nowrap;
}

.nav-dropdown a:last-child {
    margin-bottom: 0;
}

.nav-group:hover .nav-dropdown,
.nav-group.nav-group-open .nav-dropdown {
    display: block;
}

/* Login */

.login-shell {
    display: flex;
    justify-content: center;
    margin-top: 60px;
}

.login-card {
    width: min(420px, 100%);
}

/* Forms */

.form-row {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 14px;
}

label {
    color: var(--muted);
    font-size: 13px;
}

input,
select {
    width: 100%;
    padding: 10px 12px;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: #0d1017;
    color: var(--text);
    outline: none;
}

input:focus,
select:focus {
    border-color: var(--primary);
}

.checkbox-row label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--text);
}

.checkbox-row input {
    width: auto;
}

.inline-form {
    max-width: 500px;
}

.mini-form {
    display: inline-block;
    margin: 0 4px 6px 0;
}

.password-form {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

.password-form input {
    max-width: 220px;
}

.search-form {
    margin: 0;
}

.search-buttons {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

/* Buttons */

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 36px;
    padding: 8px 12px;
    border-radius: 8px;
    border: 0;
    cursor: pointer;
    color: white;
    font-weight: 600;
}

.button-primary {
    background: var(--primary);
}

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

.button-secondary {
    background: var(--secondary);
}

.button-secondary:hover {
    background: var(--secondary-hover);
}

.button-danger {
    background: var(--danger);
}

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

.button-warning {
    background: var(--warning);
}

.button-warning:hover {
    background: var(--warning-hover);
}

.button-small {
    min-height: 28px;
    padding: 5px 9px;
    font-size: 12px;
}

.disabled-button {
    opacity: 0.45;
    cursor: not-allowed;
    pointer-events: none;
}

.button-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 14px;
}

.button-align-bottom {
    display: flex;
    align-items: flex-end;
}

.bulk-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 14px;
}

/* Tables */

table {
    width: 100%;
    border-collapse: collapse;
    overflow: hidden;
}

th,
td {
    padding: 10px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: top;
}

th {
    color: var(--muted);
    font-size: 13px;
    font-weight: 600;
}

.right {
    text-align: right;
}

.actions {
    width: 420px;
}

.actions-small {
    width: 110px;
    white-space: nowrap;
}

.actions-template {
    width: 260px;
    white-space: nowrap;
}

.actions-left {
    width: 150px;
    white-space: nowrap;
}

.table-wrap {
    width: 100%;
    overflow-x: auto;
}

.wide-table {
    min-width: 1300px;
}

.compact-table {
    width: 100%;
    min-width: 900px;
    border-collapse: collapse;
}

.clip {
    max-width: 260px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.table-link {
    color: var(--primary);
    font-weight: 700;
}

.table-link:hover {
    color: white;
    text-decoration: underline;
}

.select-col {
    width: 38px;
    text-align: center;
}

.select-col input {
    width: auto;
}

.no-action-scroll {
    overflow-x: auto;
}

.no-action-scroll .actions-left,
.no-action-scroll .select-col {
    position: sticky;
    left: 0;
    z-index: 2;
    background: var(--panel);
}

.no-action-scroll .actions-left {
    left: 38px;
}

.no-action-scroll tbody .actions-left,
.no-action-scroll tbody .select-col {
    background: var(--panel);
}

.no-action-scroll thead .actions-left,
.no-action-scroll thead .select-col {
    background: var(--panel-2);
}

.detail-row td {
    border-bottom: 1px solid var(--line);
    background: #121720;
    font-size: 13px;
}

.detail-spacer {
    display: inline-block;
    width: 18px;
}

/* Badges */

.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 72px;
    padding: 4px 8px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    background: var(--secondary);
    color: var(--text);
}

.badge-pending {
    background: #5b6275;
}

.badge-rendered {
    background: #4d6f9f;
}

.badge-sent {
    background: #2f8a57;
}

.badge-retry {
    background: #9b7328;
}

.badge-failed,
.badge-render_failed,
.badge-smtp_failed,
.badge-api_error {
    background: #9b3e4c;
}

.badge-cancelled,
.badge-skipped_duplicate {
    background: #5f5368;
}

.badge-log-debug {
    background: #2f3542;
    color: #d0d7de;
    border: 1px solid #57606a;
}

.badge-log-info {
    background: #102a43;
    color: #79c0ff;
    border: 1px solid #1f6feb;
}

.badge-log-warning {
    background: #3d2f00;
    color: #f2cc60;
    border: 1px solid #d29922;
}

.badge-log-error {
    background: #3b1016;
    color: #ffb3bd;
    border: 1px solid #f85149;
}

/* Flash Messages */

.flash-wrap {
    margin-bottom: 18px;
}

.flash {
    padding: 12px 14px;
    border-radius: 10px;
    margin-bottom: 8px;
    border: 1px solid var(--line);
}

.flash-error {
    background: var(--error-bg);
    border-color: var(--error-border);
}

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

.flash-warning {
    background: #332a16;
    border-color: var(--warning);
}

/* Dashboard */

.stat-card {
    margin-bottom: 18px;
}

.stat-label {
    color: var(--muted);
    font-size: 13px;
    margin-bottom: 8px;
}

.stat-value {
    font-size: 32px;
    font-weight: 700;
}

/* Toolbars / Filters / Pagination */

.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-bottom: 16px;
}

.second-toolbar {
    margin-top: 10px;
}

.filter-links {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.filter-links a {
    padding: 7px 10px;
    background: var(--panel-2);
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--muted);
    font-size: 13px;
}

.filter-links a:hover,
.filter-links a.active {
    background: var(--secondary-hover);
    color: var(--text);
}

.pagination-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: 16px 0;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel-2);
}

.pagination-bottom {
    margin-top: 16px;
}

.pagination-summary {
    color: var(--muted);
    font-size: 13px;
}

.pagination-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.per-page-form {
    display: flex;
    align-items: center;
    gap: 8px;
}

.per-page-form label {
    color: var(--muted);
    font-size: 13px;
    margin: 0;
}

.per-page-form select {
    min-width: 90px;
}

.search-chip {
    display: inline-flex;
    margin-left: 8px;
    padding: 3px 8px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: var(--panel);
    color: var(--text);
    font-size: 12px;
}

/* Help / Code / Editors */

.helper-note {
    color: var(--muted);
    font-size: 12px;
    margin: 0 0 8px 0;
}

.help-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
}

.help-grid > div {
    min-width: 0;
}

.help-grid h3 {
    margin: 0 0 8px 0;
    font-size: 15px;
}

.help-code {
    margin: 0;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #0d1017;
    color: var(--text);
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-word;
    font-family: Consolas, Monaco, "Courier New", monospace;
    font-size: 13px;
    line-height: 1.45;
}

.help-code.variable-list {
    overflow-x: hidden;
    white-space: pre-wrap;
    word-break: normal;
}

.variable-list-box {
    margin: 0;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #0d1017;
    color: var(--text);
    font-family: Consolas, Monaco, "Courier New", monospace;
    font-size: 13px;
    line-height: 1.45;
    overflow-x: auto;
}

.variable-list-box code {
    display: block;
    white-space: nowrap;
    margin-bottom: 3px;
}

.variable-list-box code:last-child {
    margin-bottom: 0;
}

code {
    font-family: Consolas, Monaco, "Courier New", monospace;
    color: var(--text);
}

.detail-row code {
    color: var(--muted);
    white-space: pre-wrap;
}

.detail-code {
    margin: 0;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #0d1017;
    color: var(--text);
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-word;
    font-family: Consolas, Monaco, "Courier New", monospace;
    font-size: 13px;
    line-height: 1.45;
}

.large-code {
    max-height: 520px;
    overflow: auto;
}

.code-area,
.endpoint-code-area {
    width: 100%;
    min-height: 180px;
    padding: 12px;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: #0d1017;
    color: var(--text);
    font-family: Consolas, Monaco, "Courier New", monospace;
    font-size: 13px;
    line-height: 1.45;
    resize: vertical;
    outline: none;
}

.code-area:focus,
.endpoint-code-area:focus {
    border-color: var(--primary);
}

.code-area.short,
.endpoint-code-area.short {
    min-height: 220px;
}

.code-area.tall {
    min-height: 520px;
}

.CodeMirror {
    border: 1px solid var(--line);
    border-radius: 8px;
    font-family: Consolas, Monaco, "Courier New", monospace;
    font-size: 13px;
    line-height: 1.45;
}

.CodeMirror-focused {
    border-color: var(--primary);
}

.cm-jinja-dynamic-tag {
    color: #7ee787 !important;
    font-weight: 700;
}

.cm-jinja-queue-tag {
    color: #79c0ff !important;
    font-weight: 700;
}

.cm-jinja-chunk-tag {
    color: #d2a8ff !important;
    font-weight: 700;
}

.cm-jinja-section-tag {
    color: #ffa657 !important;
    font-weight: 700;
}

.cm-jinja-control-tag {
    color: #ff7b72 !important;
    font-weight: 700;
}

.cm-jinja-comment-tag {
    color: #8b949e !important;
    font-style: italic;
}

.cm-jinja-generic-tag {
    color: #f2cc60 !important;
    font-weight: 700;
}

.editor-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 8px 0 12px 0;
}

.editor-legend > span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 8px;
    border-radius: 999px;
    background: var(--panel-2);
    border: 1px solid var(--line);
    color: var(--muted);
    font-size: 12px;
}

.editor-legend .legend-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    min-width: 10px;
    border-radius: 50%;
    border: 0;
    padding: 0;
}

.editor-legend .legend-dynamic {
    background: #7ee787 !important;
}

.editor-legend .legend-queue {
    background: #79c0ff !important;
}

.editor-legend .legend-chunk {
    background: #d2a8ff !important;
}

.editor-legend .legend-section {
    background: #ffa657 !important;
}

.editor-legend .legend-control {
    background: #ff7b72 !important;
}

/* Detail / Preview */

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

.error-text {
    color: #ffb3bd;
}

.error-block {
    color: #ffb3bd;
    border-color: var(--error-border);
    background: var(--error-bg);
}

.email-preview-frame {
    width: 100%;
    height: 700px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: white;
}

.mono-wrap {
    font-family: Consolas, Monaco, "Courier New", monospace;
    word-break: break-all;
}

.qr-wrap {
    background: white;
    display: inline-block;
    padding: 14px;
    border-radius: 12px;
    margin: 12px 0 20px 0;
}

.qr-wrap img {
    display: block;
    width: 240px;
    height: 240px;
}

.soft-line {
    border: 0;
    border-top: 1px solid var(--line);
    margin: 24px 0;
}

/* Source / Endpoint Pages */

.four-source-create {
    grid-template-columns: 1fr 1fr 1fr auto;
    align-items: end;
}

.source-section {
    margin-bottom: 18px;
}

.endpoint-run-button-row {
    margin-top: 14px;
}

.endpoint-inbound-fields,
.endpoint-run-fields,
.endpoint-test-payload-section {
    margin-bottom: 14px;
}

/* Workflow Pages */

.workflow-summary {
    display: grid;
    gap: 14px;
    margin-top: 14px;
}

.workflow-summary-item {
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--panel-2);
}

.workflow-summary-item strong {
    display: block;
    margin-bottom: 6px;
}

.action-config-preview {
    max-width: 420px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Light Theme Overrides */

html.theme-light input,
html.theme-light select,
html.theme-light .code-area,
html.theme-light .endpoint-code-area,
html.theme-light .help-code,
html.theme-light .variable-list-box,
html.theme-light .detail-code {
    background: #ffffff;
    color: var(--text);
}

html.theme-light .detail-row td,
html.theme-light .nav-dropdown {
    background: #ffffff;
}

html.theme-light .nav-dropdown {
    box-shadow: 0 12px 30px rgba(15, 23, 42, 0.18);
}

html.theme-light .badge-log-debug {
    background: #e5e7eb;
    color: #374151;
    border-color: #cbd5e1;
}

html.theme-light .badge-log-info {
    background: #dbeafe;
    color: #1d4ed8;
    border-color: #93c5fd;
}

html.theme-light .badge-log-warning {
    background: #fef3c7;
    color: #92400e;
    border-color: #f59e0b;
}

html.theme-light .badge-log-error {
    background: #fee2e2;
    color: #991b1b;
    border-color: #f87171;
}

html.theme-light .error-text {
    color: #b91c1c;
}

html.theme-light .error-block {
    color: #991b1b;
}

/* Responsive */

@media (max-width: 1100px) {
    .help-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 1000px) {
    .topbar {
        align-items: flex-start;
        flex-wrap: wrap;
    }

    .brand {
        flex: 1 1 auto;
    }

    .nav {
        flex-wrap: wrap;
        justify-content: flex-start;
        width: 100%;
    }
}

@media (max-width: 900px) {
    .compact-table {
        min-width: 950px;
    }

    .actions-left {
        width: 130px;
    }

    .actions-template {
        width: auto;
    }

    .four-source-create {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 800px) {
    .topbar {
        flex-direction: row;
        align-items: center;
        flex-wrap: wrap;
        gap: 12px;
    }

    .brand {
        flex: 1 1 auto;
        min-width: 220px;
    }

    .nav-toggle {
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .nav {
        display: none;
        width: 100%;
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }

    .nav.nav-open {
        display: flex;
    }

    .nav-link,
    .nav-group-button,
    .nav-theme-button {
        width: 100%;
        justify-content: space-between;
        text-align: left;
    }

    .nav-group {
        width: 100%;
    }

    .nav-dropdown {
        position: static;
        display: none;
        width: 100%;
        min-width: 0;
        margin-top: 6px;
        padding: 8px;
        box-shadow: none;
        background: var(--panel);
    }

    .nav-group:hover .nav-dropdown {
        display: none;
    }

    .nav-group.nav-group-open .nav-dropdown {
        display: block;
    }

    .nav-dropdown a {
        width: 100%;
        white-space: normal;
    }

    .grid.two,
    .grid.three {
        grid-template-columns: 1fr;
    }

    .actions {
        width: auto;
    }

    .password-form {
        flex-direction: column;
    }

    table {
        font-size: 13px;
    }
}

/* Multi-select filters and log cleanup */

.checkbox-chip-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.checkbox-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 10px;
    background: var(--panel-2);
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--muted);
    font-size: 13px;
    cursor: pointer;
}

.checkbox-chip:hover {
    background: var(--secondary-hover);
    color: var(--text);
}

.checkbox-chip input {
    width: auto;
    margin: 0;
}

.inline-pagination-form {
    display: inline-flex;
    margin: 0;
}

.retention-inline-form {
    margin: 0 0 14px 0;
}

.log-cleanup-actions {
    align-items: center;
}

.inline-label {
    color: var(--muted);
    font-size: 13px;
    margin: 0;
}

.small-select {
    width: auto;
    min-width: 150px;
    padding: 7px 10px;
}

/* Scheduled Job Run History Polish */

.log-cleanup-actions {
    align-items: center;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel-2);
}

.inline-label {
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.small-select {
    width: auto;
    min-width: 130px;
    padding: 7px 10px;
}

.inline-pagination-form {
    display: inline-flex;
    margin: 0;
}

.workflow-summary.grid.three {
    align-items: stretch;
}

.workflow-summary.grid.three .workflow-summary-item {
    min-width: 0;
    overflow-wrap: anywhere;
}

.compact-table td,
.compact-table th {
    white-space: nowrap;
}

.compact-table td:last-child {
    white-space: normal;
    min-width: 260px;
}

.compact-table .error-text,
.compact-table .muted {
    overflow-wrap: anywhere;
}

@media (max-width: 900px) {
    .log-cleanup-actions {
        align-items: flex-start;
    }

    .log-cleanup-actions .inline-label,
    .log-cleanup-actions .small-select,
    .log-cleanup-actions .button {
        width: 100%;
    }
}

/* Wider admin layout and less cramped tables */

.table-wrap {
    width: 100%;
    overflow-x: auto;
}

.compact-table th,
.compact-table td {
    padding: 8px;
    vertical-align: top;
}

.compact-table td,
.compact-table th {
    white-space: normal;
}

.compact-table .actions-left,
.compact-table .actions-small,
.compact-table .actions-template {
    white-space: nowrap;
}

.actions-left {
    width: 120px;
}

.actions-small {
    width: 90px;
}

.actions-template {
    width: 220px;
}

.clip {
    max-width: 220px;
}

.no-action-scroll .actions-left,
.no-action-scroll .select-col {
    position: sticky;
    left: 0;
    z-index: 2;
    background: var(--panel);
}

.no-action-scroll .actions-left {
    left: 38px;
}

@media (min-width: 1400px) {
    .container {
        width: min(1760px, calc(100% - 48px));
    }

    .clip {
        max-width: 320px;
    }
}

@media (max-width: 1000px) {
    .compact-table {
        min-width: 900px;
    }
}

/* Final Admin Table Layout */

.container {
    width: min(1760px, calc(100% - 48px));
    margin: 24px auto;
}

.table-wrap {
    width: 100%;
    overflow-x: auto;
}

.compact-table {
    width: 100%;
    min-width: 900px;
    border-collapse: collapse;
}

.compact-table th,
.compact-table td {
    padding: 8px;
    vertical-align: top;
    white-space: normal;
}

.compact-table code,
.compact-table .mono-wrap,
.compact-table .badge {
    white-space: nowrap;
}

.compact-table .clip {
    max-width: 340px;
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.compact-table .muted,
.compact-table .error-text {
    overflow-wrap: anywhere;
    word-break: break-word;
}

.actions,
.actions-small,
.actions-template,
.actions-left {
    min-width: 180px;
    white-space: normal;
}

.actions .button,
.actions-small .button,
.actions-template .button,
.actions-left .button,
.actions .mini-form,
.actions-small .mini-form,
.actions-template .mini-form,
.actions-left .mini-form {
    margin: 0 4px 6px 0;
}

.no-action-scroll .select-col {
    position: sticky;
    left: 0;
    z-index: 4;
    background: var(--panel);
}

.no-action-scroll .actions-left,
.no-action-scroll .actions-small,
.no-action-scroll .actions-template,
.no-action-scroll .actions {
    position: sticky;
    left: 38px;
    z-index: 4;
    background: var(--panel);
}

.no-action-scroll thead .select-col,
.no-action-scroll thead .actions-left,
.no-action-scroll thead .actions-small,
.no-action-scroll thead .actions-template,
.no-action-scroll thead .actions {
    background: var(--panel-2);
}

.no-action-scroll tbody .select-col,
.no-action-scroll tbody .actions-left,
.no-action-scroll tbody .actions-small,
.no-action-scroll tbody .actions-template,
.no-action-scroll tbody .actions {
    background: var(--panel);
}

.detail-row td {
    white-space: normal;
}

.detail-row code,
.muted-detail code {
    display: block;
    max-width: 100%;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.log-cleanup-actions {
    align-items: center;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel-2);
}

.inline-label {
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
    margin: 0;
}

.small-select {
    width: auto;
    min-width: 130px;
    padding: 7px 10px;
}

.inline-pagination-form {
    display: inline-flex;
    margin: 0;
}

.workflow-summary.grid.three {
    align-items: stretch;
}

.workflow-summary.grid.three .workflow-summary-item {
    min-width: 0;
    overflow-wrap: anywhere;
}

@media (max-width: 1000px) {
    .container {
        width: min(100%, calc(100% - 24px));
    }

    .compact-table {
        min-width: 900px;
    }

    .actions,
    .actions-small,
    .actions-template,
    .actions-left {
        min-width: 160px;
    }
}

@media (max-width: 900px) {
    .log-cleanup-actions {
        align-items: flex-start;
    }

    .log-cleanup-actions .inline-label,
    .log-cleanup-actions .small-select,
    .log-cleanup-actions .button {
        width: 100%;
    }
}

/* Final Action Column Width Override */

.actions,
.actions-small,
.actions-template,
.actions-left {
    width: 260px;
    min-width: 260px;
    max-width: 260px;
    white-space: normal;
}

.actions .button,
.actions-small .button,
.actions-template .button,
.actions-left .button {
    margin: 0 6px 6px 0;
}

.actions .mini-form,
.actions-small .mini-form,
.actions-template .mini-form,
.actions-left .mini-form {
    display: inline-block;
    margin: 0 6px 6px 0;
}

.no-action-scroll .actions-left,
.no-action-scroll .actions-small,
.no-action-scroll .actions-template,
.no-action-scroll .actions {
    left: 38px;
    width: 260px;
    min-width: 260px;
    max-width: 260px;
}

@media (max-width: 1000px) {
    .actions,
    .actions-small,
    .actions-template,
    .actions-left {
        width: 220px;
        min-width: 220px;
        max-width: 220px;
    }

    .no-action-scroll .actions-left,
    .no-action-scroll .actions-small,
    .no-action-scroll .actions-template,
    .no-action-scroll .actions {
        width: 220px;
        min-width: 220px;
        max-width: 220px;
    }
}

/* Users Table Cleanup */

.users-table .users-actions-col {
    width: 260px;
    min-width: 260px;
    max-width: 260px;
}

.user-action-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 6px;
}

.user-action-buttons .mini-form {
    margin: 0;
}

.user-reset-details {
    margin-top: 4px;
}

.user-reset-details summary {
    cursor: pointer;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    user-select: none;
}

.user-reset-details summary:hover {
    color: var(--text);
}

.user-password-reset-form {
    display: flex;
    gap: 6px;
    align-items: center;
    margin-top: 8px;
}

.user-password-reset-form input[type="password"] {
    width: 160px;
    min-width: 160px;
}

.user-password-reset-form .button {
    margin: 0;
}
/* 4ENZIC-inspired AlertFlow shell */
:root {
    --bg: #081018;
    --panel: #101b26;
    --panel-2: #142332;
    --line: #263c4d;
    --text: #edf6fa;
    --muted: #91a5b2;
    --primary: #56b6e9;
    --primary-hover: #6dc4ef;
    --accent: #56b6e9;
    --accent-2: #9bd8f7;
    --success: #45ca82;
}
body { background: radial-gradient(circle at top left, #132637 0, #081018 38%, #050a0f 100%); color: var(--text); }
a { color: #d9edf8; }
.app-shell { min-height: 100vh; display: grid; grid-template-columns: 282px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; overflow-y: auto; background: linear-gradient(180deg,#071018 0%,#0a141d 100%); border-right: 1px solid var(--line); padding: 18px 15px; }
.brand-sidebar { min-width: 0; display: flex; align-items: center; gap: 12px; padding: 0 4px 20px; }
.brand-sidebar strong { display: block; font-size: 20px; letter-spacing: .01em; }
.brand-sidebar small { display: block; color: var(--muted); margin-top: 2px; font-size: 12px; }
.brand-mark { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 12px; background: linear-gradient(145deg,#102a3a,#0b1a25); border: 1px solid #244255; box-shadow: inset 0 0 18px rgba(86,182,233,.08); color: var(--accent-2); font-weight: 900; }
.nav-section { margin: 0 0 18px; }
.nav-label { color: #69bde8; font-size: 10px; font-weight: 800; letter-spacing: .17em; text-transform: uppercase; margin: 0 0 7px 5px; }
.nav-link { display: block; padding: 8px 10px; border-radius: 7px; color: #cbd8df; transition: background .16s ease,color .16s ease,transform .16s ease; }
.nav-link:hover { background: #142638; color: white; text-decoration: none; transform: translateX(2px); }
.sidebar-footer { border-top: 1px solid var(--line); padding-top: 14px; margin-top: 18px; }
.user-chip { display: grid; gap: 2px; background: #0b1620; border: 1px solid var(--line); border-radius: 8px; padding: 10px; margin-bottom: 10px; }
.user-chip span { color: var(--muted); font-size: 12px; }
.main { min-width: 0; }
.topbar { position: sticky; top: 0; z-index: 10; min-height: 58px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 24px; background: rgba(8,16,24,.9); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.status { font-size: 13px; color: #cbd8df; }
.pulse-dot { width: 8px; height: 8px; border-radius: 50%; background: #48cf85; display: inline-block; margin-right: 6px; box-shadow: 0 0 0 3px rgba(72,207,133,.1); }
.content { max-width: 1700px; margin: 0 auto; padding: 24px; }
.container { width: auto; margin: 0; }
.card { background: linear-gradient(180deg,rgba(20,33,45,.98),rgba(14,25,35,.98)); border: 1px solid var(--line); border-radius: 12px; padding: 18px; box-shadow: 0 16px 40px rgba(0,0,0,.18); }
.page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; margin: 0 0 18px; }
.page-header h1 { font-size: 28px; letter-spacing: -.02em; }
table { background: #0b1620; border-color: var(--line); }
th { background: #172738; color: #d9edf8; border-color: var(--line); font-size: 12px; letter-spacing: .02em; }
td { border-color: var(--line); }
.table-wrap { border: 1px solid var(--line); border-radius: 9px; overflow: auto; background: #0b1620; }
.button, button.button { border-radius: 7px; font-weight: 700; }
.button-primary, .button.primary { background: var(--accent); color: #07131a; }
.button-secondary, .button.secondary { background: #223746; border-color: #416071; color: var(--text); }
.button-warning, .button.warning { background: #8a6427; color: white; }
.button-danger, .button.danger { background: #7e3939; color: white; }
.button.ghost { background: transparent; border-color: var(--line); color: var(--text); }
.button.small, .button-small { min-height: 29px; padding: 4px 8px; font-size: 12px; }
.badge, .pill { display: inline-flex; align-items: center; justify-content: center; min-height: 22px; padding: 3px 9px; border-radius: 999px; border: 1px solid #3d5363; background: #162330; color: #dceaf0; font-size: 11px; font-weight: 800; text-transform: uppercase; }
.badge-sent, .badge.success, .badge.written, .badge.generated { border-color: #2d7750; background: #173b29; color: #a9f0c8; }
.badge-failed, .badge-error, .badge.failed { border-color: #893e3e; background: #3b1b1b; color: #f1a5a5; }
.badge-cancelled, .badge.skipped_duplicate { border-color: #5b526b; background: #302941; color: #d9cee9; }
input, select, textarea { border-color: #425766; background: #0d1820; color: var(--text); }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(75, 163, 211, .35); border-color: var(--accent); }
.flash-wrap { max-width: 1700px; margin: 14px auto 0; padding: 0 24px; }
.flash { padding: 11px 14px; border-radius: 7px; border: 1px solid var(--line); margin-bottom: 8px; }
.flash.success, .flash-success { background: #173b29; border-color: #2d7750; }
.flash.error, .flash-error { background: #3b1b1b; border-color: #893e3e; }
.flash.warning, .flash-warning { background: #392b14; border-color: #8d692b; }
pre.json, .detail-code { max-height: 420px; overflow: auto; background: #091119; border: 1px solid var(--line); border-radius: 7px; padding: 12px; color: #dceaf0; }
@media (max-width: 920px) { .app-shell { grid-template-columns: 1fr; } .sidebar { position: static; height: auto; } .topbar { position: static; } .content { padding: 16px; } }


/* Compact configuration form action rows */
.config-form-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-top: 4px;
    padding-top: 12px;
    border-top: 1px solid var(--line);
}
.config-enabled {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--text);
    font-weight: 700;
    cursor: pointer;
    margin: 0;
}
.config-enabled input[type="checkbox"] {
    width: 16px;
    height: 16px;
    margin: 0;
    accent-color: var(--primary);
}
.config-action-buttons {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
}
.config-action-buttons .button { margin: 0; }
@media (max-width: 700px) {
    .config-form-actions { align-items: stretch; flex-direction: column; }
    .config-action-buttons { justify-content: flex-start; flex-wrap: wrap; }
}

/* Portable action-template packages */
.compact-header { align-items: center; margin-bottom: 10px; }
.compact-header h2 { margin-bottom: 4px; }
.template-package-import {
    display: grid;
    grid-template-columns: minmax(280px, 1fr) auto auto;
    align-items: end;
    gap: 14px;
}
.template-package-import .template-package-file { margin: 0; }
.template-package-import .config-enabled { min-height: 40px; }
.template-package-import .button { margin: 0; }
@media (max-width: 900px) {
    .template-package-import { grid-template-columns: 1fr; align-items: stretch; }
}

/* Build 5 live operations + tab workspaces */
.live-indicator { display:inline-flex; align-items:center; gap:6px; color:var(--muted); font-size:12px; white-space:nowrap; }
.filter-pills, .workspace-tabs { display:flex; flex-wrap:wrap; gap:7px; margin:0 0 14px; }
.filter-pills a, .workspace-tab { border:1px solid var(--line); background:#10202d; color:#bed2dd; padding:7px 11px; border-radius:7px; font-weight:700; text-decoration:none; cursor:pointer; }
.filter-pills a.active, .workspace-tab.active { background:var(--accent); color:#07131a; border-color:var(--accent); }
[data-tab-panel][hidden] { display:none !important; }
.compact-actions { flex-wrap:wrap; margin:0 0 12px; }
.badge-dead_letter { border-color:#9a4b4b; background:#421d1d; color:#ffb9b9; }
.badge-running { border-color:#2f6e91; background:#153147; color:#a8dcff; }
.badge-pending, .badge-retry { border-color:#7c6b33; background:#352f18; color:#f2dc8e; }
.badge-paused { border-color:#685c80; background:#302942; color:#d9cbed; }
.badge-succeeded { border-color:#2d7750; background:#173b29; color:#a9f0c8; }
.backup-grid { align-items:start; }
.callout { margin-top:16px; padding:12px; border:1px solid var(--line); border-radius:8px; background:#0c1821; color:var(--muted); }
.grid.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1200px) { .grid.four { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 700px) { .grid.four { grid-template-columns: 1fr; } }

/* Build 5.1 type-aware configuration workspaces */
.type-aware-note { padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: #0b1720; color: var(--muted); margin: 0 0 14px; }
.form-section-heading { display:flex; align-items:center; justify-content:space-between; gap:12px; margin:0 0 12px; }
.form-section-heading h2, .form-section-heading h3 { margin:0; }
.workspace-tabs.sticky-workspace-tabs { position:sticky; top:70px; z-index:7; padding:8px; background:rgba(8,16,24,.94); border:1px solid var(--line); border-radius:9px; backdrop-filter:blur(8px); }
.compact-card { padding:14px 16px; }
.type-summary { display:flex; flex-wrap:wrap; gap:8px; align-items:center; margin-top:8px; }
[data-show-controller][hidden] { display:none !important; }
.tab-footer-actions { display:flex; align-items:center; justify-content:space-between; gap:12px; margin-top:14px; padding-top:12px; border-top:1px solid var(--line); }
@media (max-width:700px) { .tab-footer-actions { flex-direction:column; align-items:stretch; } .workspace-tabs.sticky-workspace-tabs { position:static; } }
