:root {
    --sys-navy-950: #061326;
    --sys-navy-900: #081c38;
    --sys-navy-850: #0b2447;
    --sys-navy-800: #0f315e;
    --sys-blue-700: #0050C0;
    --sys-blue-600: #0B66D8;
    --sys-blue-500: #2478E8;
    --sys-gold-500: #F4B400;
    --sys-gold-400: #FFD45C;

    --sys-bg: #f4f7fb;
    --sys-surface: #ffffff;
    --sys-surface-soft: #f8fbff;
    --sys-border: #e1e9f4;
    --sys-border-strong: #cad8ea;
    --sys-text: #152033;
    --sys-muted: #68758a;
    --sys-danger: #b42318;
    --sys-success: #137333;
    --sys-warning: #9a6700;

    --sys-radius-sm: 10px;
    --sys-radius: 16px;
    --sys-radius-lg: 22px;
    --sys-radius-xl: 28px;

    --sys-shadow-xs: 0 1px 2px rgba(8, 28, 56, .05);
    --sys-shadow-sm: 0 10px 24px rgba(8, 28, 56, .055);
    --sys-shadow-md: 0 18px 42px rgba(8, 28, 56, .085);

    --sys-font: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
}

* { box-sizing: border-box; }

html { min-height: 100%; background: var(--sys-bg); }

body {
    margin: 0;
    min-height: 100vh;
    font-family: var(--sys-font);
    color: var(--sys-text);
    background:
        radial-gradient(circle at 10% 0%, rgba(244, 180, 0, .08), transparent 20rem),
        radial-gradient(circle at 96% 0%, rgba(36, 120, 232, .08), transparent 28rem),
        linear-gradient(180deg, #f9fbff 0%, var(--sys-bg) 52%, #eef4fb 100%);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

a { color: inherit; text-decoration: none; }

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

.admin-shell {
    display: grid;
    grid-template-columns: 312px minmax(0, 1fr);
    min-height: 100vh;
}

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    padding: 24px 20px;
    overflow-y: auto;
    background:
        radial-gradient(circle at 12% 0%, rgba(244, 180, 0, .18), transparent 15rem),
        linear-gradient(180deg, var(--sys-navy-900) 0%, var(--sys-navy-950) 100%);
    color: #fff;
    box-shadow: 18px 0 55px rgba(8, 28, 56, .18);
}

.brand {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 104px;
    padding: 18px;
    border-radius: 26px;
    background: #ffffff;
    border: 1px solid rgba(255, 255, 255, .86);
    box-shadow: 0 18px 42px rgba(0, 0, 0, .16);
}

.brand-logo {
    display: block;
    width: 246px;
    max-width: 100%;
    height: auto;
    object-fit: contain;
}

.sidebar-section-title {
    margin: 34px 12px 12px;
    color: rgba(255, 255, 255, .62);
    font-size: 11px;
    font-weight: 900;
    letter-spacing: .13em;
    text-transform: uppercase;
}

.nav-list { display: grid; gap: 8px; }

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 52px;
    padding: 12px 14px;
    border-radius: 16px;
    color: rgba(255, 255, 255, .82);
    font-size: 14px;
    font-weight: 800;
    border: 1px solid transparent;
    transition: background .16s ease, color .16s ease, transform .16s ease, border-color .16s ease;
}

.nav-link:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, .10);
    border-color: rgba(255, 255, 255, .10);
    transform: translateX(2px);
}

.nav-link.active {
    color: #ffffff;
    background: rgba(255, 255, 255, .13);
    border-color: rgba(255, 255, 255, .20);
    box-shadow: inset 4px 0 0 var(--sys-gold-500);
}

.nav-icon {
    width: 34px;
    height: 34px;
    flex: 0 0 34px;
    border-radius: 13px;
    display: grid;
    place-items: center;
    background: rgba(255, 255, 255, .10);
    color: var(--sys-gold-400);
    font-weight: 900;
}

.content { min-width: 0; }

.topbar {
    min-height: 90px;
    padding: 20px 42px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    background: rgba(249, 251, 255, .86);
    border-bottom: 1px solid rgba(202, 216, 234, .72);
    backdrop-filter: blur(18px);
}

.userbox {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-left: auto;
}

.user-pill {
    max-width: 280px;
    padding: 10px 14px;
    border-radius: 999px;
    background: #ffffff;
    border: 1px solid var(--sys-border);
    color: var(--sys-navy-800);
    box-shadow: var(--sys-shadow-xs);
    font-size: 13px;
    font-weight: 850;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.page-body { padding: 30px 42px 56px; }

.page-hero,
.admin-page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 24px;
    padding: 28px;
    border: 1px solid var(--sys-border);
    border-radius: var(--sys-radius-xl);
    background:
        radial-gradient(circle at 8% 0%, rgba(244, 180, 0, .18), transparent 22rem),
        radial-gradient(circle at 92% 0%, rgba(36, 120, 232, .12), transparent 26rem),
        linear-gradient(135deg, #ffffff, #f7faff);
    box-shadow: var(--sys-shadow-sm);
    position: relative;
    overflow: hidden;
}

.page-hero::after,
.admin-page-header::after {
    content: "";
    position: absolute;
    right: -90px;
    bottom: -120px;
    width: 280px;
    height: 280px;
    border-radius: 999px;
    border: 46px solid rgba(0, 80, 192, .055);
    pointer-events: none;
}

.page-hero > *,
.admin-page-header > * {
    position: relative;
    z-index: 1;
}

.page-eyebrow,
.admin-eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 12px;
    color: var(--sys-blue-700);
    font-size: 12px;
    font-weight: 950;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.page-eyebrow::before,
.admin-eyebrow::before {
    content: "";
    width: 10px;
    height: 10px;
    border-radius: 999px;
    background: var(--sys-gold-500);
    box-shadow: 0 0 0 5px rgba(244, 180, 0, .16);
}

.page-hero h1,
.admin-page-header h1 {
    margin: 0;
    color: var(--sys-navy-900);
    font-size: clamp(30px, 4vw, 44px);
    line-height: 1.04;
    letter-spacing: -.04em;
    font-weight: 950;
}

.page-description,
.admin-page-description {
    max-width: 860px;
    margin: 15px 0 0;
    color: var(--sys-muted);
    font-size: 16px;
    line-height: 1.7;
}

.admin-actions,
.action-row,
.form-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 18px;
    margin-bottom: 22px;
}

.card,
.panel,
.admin-card {
    background: rgba(255, 255, 255, .94);
    border: 1px solid rgba(225, 233, 244, .96);
    border-radius: var(--sys-radius-xl);
    box-shadow: var(--sys-shadow-sm);
    overflow: hidden;
}

.panel,
.admin-card {
    padding: 28px;
    margin-bottom: 22px;
}

.card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin: -28px -28px 24px;
    padding: 24px 28px 20px;
    border-bottom: 1px solid rgba(0, 32, 80, .08);
    background: linear-gradient(180deg, #ffffff, #fbfdff);
}

.panel-title,
.admin-card h2,
.card-title {
    margin: 0;
    color: var(--sys-navy-900);
    font-size: 21px;
    line-height: 1.2;
    font-weight: 950;
    letter-spacing: -.02em;
}

.panel-text {
    margin: 10px 0 0;
    color: var(--sys-muted);
    line-height: 1.65;
}

/* Buttons */
.btn,
.button,
button.btn,
a.btn,
button.button,
a.button {
    appearance: none;
    border: 1px solid transparent;
    cursor: pointer;
    min-height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 0 16px;
    border-radius: 14px;
    font-size: 14px;
    font-weight: 900;
    text-decoration: none;
    box-shadow: none !important;
    background-image: none !important;
    transition: background .16s ease, border-color .16s ease, color .16s ease, transform .16s ease;
}

.btn:hover,
.button:hover {
    transform: translateY(-1px);
}

.btn-primary,
.button-primary {
    color: #ffffff !important;
    background: var(--sys-blue-700) !important;
    border-color: var(--sys-blue-700) !important;
}

.btn-primary:hover,
.button-primary:hover {
    background: var(--sys-blue-600) !important;
    border-color: var(--sys-blue-600) !important;
}

.btn-secondary,
.button-secondary,
.btn-light,
.button-light {
    color: var(--sys-navy-900) !important;
    background: #ffffff !important;
    border-color: var(--sys-border-strong) !important;
}

.btn-secondary:hover,
.button-secondary:hover,
.btn-light:hover,
.button-light:hover {
    color: var(--sys-navy-900) !important;
    background: #f3f7fc !important;
    border-color: #b7cbe3 !important;
}

.btn-danger,
.button-danger {
    color: #ffffff !important;
    background: var(--sys-danger) !important;
    border-color: var(--sys-danger) !important;
}

/* Icon action buttons with label on hover/focus */
.icon-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.icon-btn {
    position: relative;
    width: 42px;
    height: 42px;
    min-height: 42px;
    padding: 0;
    border-radius: 14px;
    display: inline-grid;
    place-items: center;
    border: 1px solid var(--sys-border-strong);
    color: var(--sys-navy-900);
    background: #ffffff;
    box-shadow: none !important;
    cursor: pointer;
    transition: background .16s ease, border-color .16s ease, color .16s ease, transform .16s ease;
}

.icon-btn svg {
    width: 19px;
    height: 19px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.icon-btn:hover,
.icon-btn:focus-visible {
    color: #ffffff;
    background: var(--sys-blue-700);
    border-color: var(--sys-blue-700);
    transform: translateY(-1px);
}

.icon-btn .icon-label {
    position: absolute;
    left: 50%;
    bottom: calc(100% + 10px);
    transform: translateX(-50%) translateY(4px);
    opacity: 0;
    pointer-events: none;
    white-space: nowrap;
    min-height: 30px;
    padding: 0 10px;
    display: inline-flex;
    align-items: center;
    border-radius: 10px;
    color: #ffffff;
    background: var(--sys-navy-900);
    font-size: 12px;
    font-weight: 850;
    z-index: 50;
    transition: opacity .14s ease, transform .14s ease;
}

.icon-btn .icon-label::after {
    content: "";
    position: absolute;
    left: 50%;
    top: 100%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: var(--sys-navy-900);
}

.icon-btn:hover .icon-label,
.icon-btn:focus-visible .icon-label {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* Back buttons must keep arrow + text */
.back-button {
    min-width: auto;
}

/* Alerts below page hero */
.system-alert {
    position: relative;
    display: flex;
    gap: 14px;
    margin: 0 0 20px;
    padding: 16px 54px 16px 18px;
    border-radius: 20px;
    border: 1px solid;
    box-shadow: var(--sys-shadow-xs);
}

.system-alert-icon {
    flex: 0 0 auto;
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    border-radius: 999px;
    font-weight: 950;
}

.system-alert-content strong {
    display: block;
    margin-bottom: 4px;
}

.system-alert-content p {
    margin: 0;
}

.system-alert-content ul {
    margin: 8px 0 0;
    padding-left: 19px;
}

.system-alert-close {
    position: absolute;
    top: 13px;
    right: 14px;
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 999px;
    display: grid;
    place-items: center;
    cursor: pointer;
    color: inherit;
    background: rgba(255, 255, 255, .65);
    font-size: 22px;
    line-height: 1;
}

.system-alert-danger {
    color: var(--sys-danger);
    background: #fff3f1;
    border-color: #ffd4ce;
}

.system-alert-danger .system-alert-icon {
    background: #ffd8d2;
}

.system-alert-success {
    color: var(--sys-success);
    background: #f3fff6;
    border-color: #cdebd4;
}

.system-alert-success .system-alert-icon {
    background: #d8f5df;
}

.system-alert-warning {
    color: var(--sys-warning);
    background: #fff8e6;
    border-color: #f3dd95;
}

.system-alert-warning .system-alert-icon {
    background: #ffedb3;
}

.alert {
    display: none;
}

.metric-card {
    position: relative;
    overflow: hidden;
    padding: 24px;
    min-height: 142px;
}

.metric-card::after { display: none; }

.metric-label {
    color: var(--sys-muted);
    font-size: 12px;
    font-weight: 950;
    letter-spacing: .09em;
    text-transform: uppercase;
}

.metric-value {
    margin-top: 14px;
    color: var(--sys-navy-900);
    font-size: 40px;
    line-height: 1;
    font-weight: 950;
    letter-spacing: -.04em;
}

.metric-note {
    margin-top: 12px;
    color: var(--sys-muted);
    font-size: 13px;
}

.table-wrap {
    margin-top: 20px;
    overflow: auto;
    border: 1px solid var(--sys-border);
    border-radius: 22px;
    background: #fff;
}

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

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

th {
    background: #f5f8fc;
    color: var(--sys-navy-800);
    font-size: 12px;
    font-weight: 950;
    letter-spacing: .08em;
    text-transform: uppercase;
}

tr:last-child td { border-bottom: 0; }

small,
.help-text,
td small {
    color: var(--sys-muted);
}

code {
    color: var(--sys-blue-700);
    background: #eef6ff;
    border: 1px solid #d8eaff;
    border-radius: 8px;
    padding: 2px 6px;
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    min-height: 30px;
    padding: 0 11px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 900;
    border: 1px solid transparent;
}

.badge-success { color: #11693f; background: #e7f8ee; border-color: #bcebd0; }
.badge-warning { color: #815200; background: #fff8e6; border-color: #f3dd95; }
.badge-danger { color: #9d241c; background: #fff3f1; border-color: #ffd4ce; }
.badge-info { color: #075ea8; background: #eaf4ff; border-color: #cae2ff; }
.badge-muted { color: #64748b; background: #f3f6fa; border-color: #e2e8f0; }

.empty-state {
    margin-top: 20px;
    padding: 34px;
    border-radius: 22px;
    background: #f8fbff;
    border: 1px dashed var(--sys-border-strong);
    color: var(--sys-muted);
    text-align: center;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
}

.form-grid-full { grid-column: 1 / -1; }

.field label,
.form-group label,
.flow-field label {
    display: block;
    margin-bottom: 8px;
    color: var(--sys-navy-900);
    font-size: 13px;
    font-weight: 900;
}

input,
select,
textarea {
    width: 100%;
    min-height: 46px;
    border: 1px solid var(--sys-border);
    background: #ffffff;
    border-radius: 14px;
    padding: 11px 13px;
    color: var(--sys-text);
    font: inherit;
    outline: none;
    box-shadow: var(--sys-shadow-xs);
}

textarea {
    min-height: 126px;
    resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--sys-blue-500);
    box-shadow: 0 0 0 4px rgba(36, 120, 232, .12);
}

.error-text {
    display: block;
    margin-top: 7px;
    color: var(--sys-danger);
    font-size: 12px;
    font-weight: 800;
}

.client-variable-list {
    display: grid;
    gap: 10px;
    margin-top: 18px;
}

.client-variable {
    padding: 14px 16px;
    border-radius: 16px;
    background: #f8fbff;
    border: 1px solid var(--sys-border);
}

/* Flow import layout */
.flow-import-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.55fr) minmax(360px, .85fr);
    gap: 22px;
    align-items: start;
}

.flow-side {
    display: grid;
    gap: 22px;
}

.flow-upload {
    display: flex;
    align-items: center;
    gap: 16px;
    min-height: 98px;
    padding: 18px;
    border: 1.5px dashed rgba(0, 80, 192, .26);
    border-radius: 22px;
    background: #f8fbff;
    cursor: pointer;
    transition: border-color .18s ease, transform .18s ease, box-shadow .18s ease;
}

.flow-upload:hover {
    border-color: rgba(0, 80, 192, .55);
    transform: translateY(-1px);
    box-shadow: var(--sys-shadow-sm);
}

.flow-upload input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

.flow-upload__icon {
    flex: 0 0 auto;
    width: 54px;
    height: 54px;
    display: grid;
    place-items: center;
    border-radius: 18px;
    color: var(--sys-navy-900);
    background: var(--sys-gold-500);
}

.flow-upload__icon svg {
    width: 27px;
    height: 27px;
    fill: currentColor;
}

.flow-upload strong {
    display: block;
    color: var(--sys-navy-900);
    font-size: 16px;
    font-weight: 950;
}

.flow-upload span {
    display: block;
    margin-top: 5px;
    color: var(--sys-muted);
    font-size: 13px;
}

.flow-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 22px 0;
    color: var(--sys-muted);
    font-size: 12px;
    font-weight: 900;
    letter-spacing: .06em;
    text-transform: uppercase;
}

.flow-divider::before,
.flow-divider::after {
    content: "";
    height: 1px;
    flex: 1;
    background: rgba(0, 32, 80, .10);
}

.flow-field__label-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 9px;
}

.flow-field__label-row span {
    color: var(--sys-muted);
    font-size: 12px;
    font-weight: 800;
}

.flow-field textarea {
    min-height: 430px;
    background: #fbfdff;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
    font-size: 13px;
    line-height: 1.65;
}

.flow-form__footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-top: 18px;
}

.flow-safe-note {
    color: var(--sys-muted);
    font-size: 13px;
    line-height: 1.5;
}

.flow-safe-note strong {
    color: var(--sys-navy-900);
}

.flow-check-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 12px;
}

.flow-check-list li {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    color: var(--sys-muted);
    font-size: 14px;
    line-height: 1.5;
}

.flow-check-list li span {
    flex: 0 0 auto;
    width: 22px;
    height: 22px;
    display: grid;
    place-items: center;
    border-radius: 999px;
    color: var(--sys-navy-900);
    background: rgba(244, 180, 0, .25);
    font-size: 12px;
    font-weight: 950;
}

.flow-code-card {
    position: relative;
    margin: -28px;
    margin-top: 18px;
    padding: 18px;
    background: #0b1628;
}

.flow-code-card pre {
    max-height: 520px;
    margin: 0;
    overflow: auto;
    color: #dce8ff;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
    font-size: 12px;
    line-height: 1.7;
    white-space: pre-wrap;
    tab-size: 2;
}

.flow-copy-btn {
    position: absolute;
    right: 14px;
    top: 14px;
    min-height: 34px;
    padding: 0 12px;
    border: 1px solid rgba(255, 255, 255, .16);
    border-radius: 12px;
    color: #fff;
    background: var(--sys-navy-800);
    cursor: pointer;
    font: inherit;
    font-size: 12px;
    font-weight: 850;
    box-shadow: none;
}

/* Preview */
.preview-shell {
    overflow: hidden;
    border: 1px solid rgba(0, 32, 80, .12);
    border-radius: 24px;
    background: #fff;
    min-height: 680px;
    display: grid;
    grid-template-rows: auto 1fr auto;
}

.preview-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 18px 20px;
    border-bottom: 1px solid rgba(0, 32, 80, .10);
    background: linear-gradient(180deg, #ffffff, #f6f9ff);
}

.preview-header strong {
    display: block;
    color: #002050;
    font-weight: 900;
}

.preview-header span {
    display: block;
    margin-top: 4px;
    color: #6b7890;
    font-size: 13px;
}

.preview-body {
    height: 520px;
    overflow-y: auto;
    padding: 22px;
    background: #f8fbff;
}

.preview-message-list {
    display: grid;
    gap: 13px;
}

.preview-msg {
    max-width: 78%;
    padding: 13px 15px;
    border-radius: 18px;
    font-size: 15px;
    line-height: 1.5;
    white-space: pre-wrap;
}

.preview-msg.bot {
    justify-self: start;
    color: #172033;
    background: #ffffff;
    border: 1px solid rgba(0, 32, 80, .10);
    box-shadow: 0 8px 22px rgba(8, 28, 56, .06);
}

.preview-msg.user {
    justify-self: end;
    color: #fff;
    background: var(--sys-blue-700);
}

.preview-typing {
    justify-self: start;
    color: #6b7890;
    font-size: 13px;
    padding: 8px 12px;
}

.preview-options {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 4px;
}

.preview-option-btn {
    border: 1px solid #d8eaff;
    cursor: pointer;
    min-height: 40px;
    border-radius: 14px;
    padding: 0 14px;
    font: inherit;
    font-weight: 850;
    color: #002050;
    background: #eef6ff;
}

.preview-footer {
    padding: 16px;
    border-top: 1px solid rgba(0, 32, 80, .10);
    background: #fff;
}

.preview-input-row {
    display: flex;
    gap: 10px;
}

.preview-answer-input {
    flex: 1;
}

.preview-error {
    display: none;
    margin-top: 10px;
    color: #9d241c;
    background: #fff3f1;
    border: 1px solid #ffd4ce;
    padding: 10px 12px;
    border-radius: 14px;
    font-size: 13px;
}

@media (max-width: 1180px) {
    .admin-shell { grid-template-columns: 104px minmax(0, 1fr); }
    .sidebar { padding: 18px 12px; }
    .brand { min-height: 76px; padding: 10px; }
    .brand-logo { width: 66px; }
    .sidebar-section-title,
    .nav-link span:not(.nav-icon) { display: none; }
    .nav-link { justify-content: center; padding: 10px; }
    .card-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .page-hero,
    .admin-page-header { align-items: flex-start; flex-direction: column; }
    .flow-import-grid { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
    .admin-shell { grid-template-columns: 1fr; }
    .sidebar { position: relative; height: auto; border-radius: 0 0 28px 28px; }
    .brand-logo { width: 220px; }
    .nav-link span:not(.nav-icon),
    .sidebar-section-title { display: initial; }
    .nav-link { justify-content: flex-start; }
    .topbar { align-items: flex-start; flex-direction: column; padding: 24px; }
    .page-body { padding: 22px; }
    .page-hero,
    .admin-page-header { padding: 22px; flex-direction: column; align-items: stretch; }
    .card-grid,
    .form-grid { grid-template-columns: 1fr; }
    .flow-form__footer { flex-direction: column; align-items: stretch; }
    .flow-field textarea { min-height: 360px; }
}


/* HOTFIX PREVIEW DEBUG — sobrescreve/adiciona layout lateral de variáveis */
.preview-debug-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 360px;
    gap: 20px;
    align-items: stretch;
}

.debug-panel {
    border: 1px solid var(--sys-border);
    border-radius: 24px;
    background: #ffffff;
    box-shadow: var(--sys-shadow-sm);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 680px;
}

.debug-panel-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding: 18px 18px 16px;
    border-bottom: 1px solid rgba(0, 32, 80, .08);
    background: linear-gradient(180deg, #ffffff, #fbfdff);
}

.debug-panel-header h3 {
    margin: 0;
    color: var(--sys-navy-900);
    font-size: 20px;
    font-weight: 950;
    letter-spacing: -.02em;
}

.debug-session {
    display: grid;
    gap: 6px;
    padding: 14px 18px;
    border-bottom: 1px solid rgba(0, 32, 80, .08);
}

.debug-session small {
    color: var(--sys-muted);
    font-size: 11px;
    font-weight: 950;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.debug-session code {
    display: block;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.debug-variable-list {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: grid;
    align-content: start;
    gap: 12px;
    background: #f8fbff;
}

.debug-empty {
    padding: 18px;
    border-radius: 18px;
    border: 1px dashed var(--sys-border-strong);
    color: var(--sys-muted);
    background: #ffffff;
    text-align: center;
    font-size: 14px;
    line-height: 1.5;
}

.debug-variable-item {
    padding: 14px;
    border-radius: 18px;
    background: #ffffff;
    border: 1px solid rgba(0, 32, 80, .10);
    box-shadow: var(--sys-shadow-xs);
}

.debug-variable-code {
    color: var(--sys-blue-700);
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
    font-size: 12px;
    font-weight: 950;
    word-break: break-all;
}

.debug-variable-value {
    margin-top: 8px;
    color: var(--sys-navy-900);
    font-size: 15px;
    font-weight: 850;
    line-height: 1.45;
    word-break: break-word;
}

.debug-variable-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
}

.debug-variable-meta span {
    display: inline-flex;
    min-height: 24px;
    align-items: center;
    padding: 0 8px;
    border-radius: 999px;
    color: var(--sys-muted);
    background: #f3f6fa;
    border: 1px solid var(--sys-border);
    font-size: 11px;
    font-weight: 850;
}

@media (max-width: 1180px) {
    .preview-debug-layout {
        grid-template-columns: 1fr;
    }

    .debug-panel {
        min-height: 360px;
    }
}



/* HOTFIX — Indicador animado de digitação no preview */
.preview-typing-animated {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    justify-self: start;
    width: fit-content;
    min-height: 38px;
    padding: 9px 13px;
    border-radius: 999px;
    color: var(--sys-navy-900);
    background: #ffffff;
    border: 1px solid rgba(0, 32, 80, .10);
    box-shadow: 0 8px 22px rgba(8, 28, 56, .06);
    font-size: 13px;
    font-weight: 850;
}

.typing-pulse-icon {
    position: relative;
    width: 34px;
    height: 22px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    border-radius: 999px;
    color: var(--sys-blue-700);
    background: #eef6ff;
    overflow: hidden;
}

.typing-pulse-icon::before {
    content: "";
    position: absolute;
    inset: 2px;
    border-radius: 999px;
    background: rgba(0, 80, 192, .08);
    animation: typingGlow 1.25s ease-in-out infinite;
}

.typing-pulse-icon span {
    position: relative;
    z-index: 1;
    width: 5px;
    height: 5px;
    border-radius: 999px;
    background: currentColor;
    animation: typingDot 1.05s ease-in-out infinite;
}

.typing-pulse-icon span:nth-child(2) {
    animation-delay: .16s;
}

.typing-pulse-icon span:nth-child(3) {
    animation-delay: .32s;
}

.typing-label {
    white-space: nowrap;
}

@keyframes typingDot {
    0%, 80%, 100% {
        opacity: .35;
        transform: translateY(0) scale(.85);
    }

    40% {
        opacity: 1;
        transform: translateY(-3px) scale(1.08);
    }
}

@keyframes typingGlow {
    0%, 100% {
        transform: scale(.86);
        opacity: .55;
    }

    50% {
        transform: scale(1.08);
        opacity: 1;
    }
}




/* HOTFIX — Corrige camada/recorte dos tooltips dos botões de ação */
.card,
.panel,
.admin-card {
    overflow: visible;
}

.card-header,
.admin-actions,
.action-row,
.icon-actions {
    overflow: visible;
}

.icon-actions {
    position: relative;
    z-index: 20;
}

.icon-btn {
    position: relative;
    z-index: 21;
}

.icon-btn:hover,
.icon-btn:focus-visible {
    z-index: 10000;
}

/*
 * Os tooltips ficavam cortados quando apareciam acima do botão,
 * principalmente dentro de headers/cards com bordas arredondadas.
 * Agora aparecem abaixo do ícone, com z-index alto e sem recorte.
 */
.icon-btn .icon-label {
    top: calc(100% + 10px);
    bottom: auto;
    z-index: 10001;
    transform: translateX(-50%) translateY(-4px);
}

.icon-btn .icon-label::after {
    top: auto;
    bottom: 100%;
    border-top-color: transparent;
    border-bottom-color: var(--sys-navy-900);
}

.icon-btn:hover .icon-label,
.icon-btn:focus-visible .icon-label {
    transform: translateX(-50%) translateY(0);
}

/* Em áreas muito próximas da borda direita, mantém o tooltip legível */
.icon-actions .icon-btn:last-child .icon-label {
    left: auto;
    right: 0;
    transform: translateX(0) translateY(-4px);
}

.icon-actions .icon-btn:last-child:hover .icon-label,
.icon-actions .icon-btn:last-child:focus-visible .icon-label {
    transform: translateX(0) translateY(0);
}

.icon-actions .icon-btn:last-child .icon-label::after {
    left: auto;
    right: 14px;
    transform: none;
}

/* Evita que tabelas ou painéis cubram tooltip vizinho */
.table-wrap {
    position: relative;
    z-index: 1;
}

.card-header {
    position: relative;
    z-index: 5;
}




/* HOTFIX — Ícones em telas de blocos sem quebrar o CSS global */
button.icon-btn {
    font: inherit;
}

button.icon-btn[type="submit"] {
    color: #ffffff;
    background: var(--sys-blue-700);
    border-color: var(--sys-blue-700);
}

button.icon-btn[type="submit"]:hover,
button.icon-btn[type="submit"]:focus-visible {
    color: #ffffff;
    background: var(--sys-blue-600);
    border-color: var(--sys-blue-600);
}

.table-wrap .icon-actions {
    justify-content: flex-start;
}
