:root {
    color-scheme: light;
    --bg: #f4f6fb;
    --panel: #ffffff;
    --border: #d9dfeb;
    --text: #1f2937;
    --muted: #6b7280;
    --primary: #2563eb;
    --success: #198754;
    --warning: #b7791f;
    --danger: #dc3545;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    background: #111827;
    color: #fff;
}

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

.topbar__nav {
    display: flex;
    gap: 16px;
}

.topbar__nav a {
    color: #fff;
    text-decoration: none;
}

.page-shell {
    padding: 24px;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 24px;
}

.page-header h1 {
    margin: 0 0 8px;
}

.page-header p,
.text-muted {
    color: var(--muted);
}

.header-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card,
.panel,
.timeline-step,
.timeline-item {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 14px;
}

.stat-card {
    padding: 18px;
}

.stat-card__label {
    display: block;
    color: var(--muted);
    margin-bottom: 6px;
}

.stat-card__value {
    font-size: 28px;
}

.stat-card__value--sm {
    font-size: 18px;
    line-height: 1.4;
}

.portal-layout {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 24px;
    align-items: start;
}

.portal-grid {
    display: grid;
    gap: 24px;
    align-items: start;
    margin-bottom: 24px;
}

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

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

.panel {
    padding: 18px;
}

.panel--timeline {
    min-width: 0;
}

.action-card {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.cycle-card {
    min-height: 100%;
}

.cycle-card__actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

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

.panel__header h2,
.timeline-step__header h3 {
    margin: 0;
}

.panel__meta,
.timeline-step__header p,
.os-list__subtitle,
.os-list__meta {
    color: var(--muted);
}

.os-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.os-list__item {
    display: block;
    text-decoration: none;
    color: inherit;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #fbfcff;
}

.os-list__item.is-active {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.12);
}

.os-list__title,
.os-list__meta,
.timeline-step__header,
.timeline-item__meta {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.os-list__subtitle {
    margin: 8px 0;
}

.timeline-step {
    padding: 18px;
    margin-bottom: 16px;
}

.detail-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 18px;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: #f8fafc;
}

.detail-toolbar__summary,
.detail-toolbar__actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.tabs {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.tabs__nav {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    padding-bottom: 4px;
    border-bottom: 1px solid var(--border);
}

.tabs__button {
    border: 1px solid var(--border);
    background: #fff;
    color: var(--muted);
    padding: 10px 14px;
    border-radius: 10px;
    font-weight: 700;
    cursor: pointer;
}

.tabs__button.is-active {
    background: #111827;
    color: #fff;
    border-color: #111827;
}

.tabs__panel {
    display: none;
}

.tabs__panel.is-active {
    display: block;
}

.chat-thread {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.chat-message {
    display: flex;
}

.chat-message--bot {
    justify-content: flex-end;
}

.chat-message--cliente {
    justify-content: flex-start;
}

.chat-message__bubble {
    width: min(100%, 760px);
    padding: 14px 16px;
    border-radius: 16px;
    border: 1px solid var(--border);
    background: #eef2f7;
}

.chat-message--bot .chat-message__bubble {
    background: #1f3b73;
    color: #fff;
    border-color: #1f3b73;
}

.chat-message__meta,
.chat-message__badges,
.timeline-group__header,
.timeline-item__footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.chat-message__author {
    font-weight: 700;
}

.chat-message__time {
    font-size: 12px;
    opacity: 0.8;
}

.chat-message__media {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
    padding: 6px 10px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.2);
    font-size: 13px;
}

.chat-message--cliente .chat-message__media {
    background: #e5e7eb;
}

.media-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 34px;
    min-height: 24px;
    padding: 0 8px;
    border-radius: 999px;
    background: rgba(17, 24, 39, 0.16);
    font-size: 11px;
    font-weight: 700;
}

.chat-message__text {
    margin-top: 10px;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-word;
}

.steps-timeline {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.timeline-items {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 12px;
}

.timeline-group {
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: #fbfcff;
}

.timeline-group__items {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 12px;
}

.timeline-item {
    padding: 14px;
}

.timeline-item.is-invalid {
    border-color: var(--danger);
    background: #fff6f7;
}

.timeline-item.is-valid {
    border-color: #b8e0c7;
}

.timeline-item.is-pending {
    border-color: #ead7a1;
    background: #fffdf6;
}

.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 4px 10px;
    border-radius: 999px;
    color: #fff;
    font-size: 12px;
    line-height: 1.2;
}

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

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

.badge--pending {
    background: var(--warning);
}

.badge--neutral {
    background: #6b7280;
}

.badge--flow {
    color: #fff;
}

.badge--manual {
    background: #111827;
    color: #fff;
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    z-index: 1000;
}

.modal-backdrop.is-hidden {
    display: none;
}

.modal-card {
    width: min(100%, 520px);
    border-radius: 16px;
    background: #ffffff;
    border: 1px solid var(--border);
    box-shadow: 0 20px 60px rgba(15, 23, 42, 0.22);
}

.modal-card--media {
    width: min(100%, 960px);
}

.modal-card__header,
.modal-card__body,
.modal-card__actions {
    padding: 18px 20px;
}

.modal-card__header {
    border-bottom: 1px solid var(--border);
}

.modal-card__body {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.modal-card__body--media {
    align-items: center;
    justify-content: center;
    max-height: calc(100vh - 180px);
    overflow: auto;
    background: #0f172a;
}

.modal-card__actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    border-top: 1px solid var(--border);
}

.modal-card__error {
    padding: 12px 14px;
    border-radius: 10px;
    border: 1px solid #fecaca;
    background: #fef2f2;
    color: #991b1b;
}

.modal-card__error.is-hidden {
    display: none;
}

.media-thumb {
    display: inline-block;
    margin-top: 10px;
}

.media-thumb--button {
    padding: 0;
    background: transparent;
    border: 0;
    cursor: zoom-in;
}

.media-thumb--sm img {
    width: 120px;
    height: 120px;
    object-fit: cover;
}

.media-thumb img,
.media-player {
    width: min(100%, 360px);
    border-radius: 12px;
    border: 1px solid var(--border);
}

.media-preview__image {
    width: auto;
    max-width: 100%;
    max-height: calc(100vh - 240px);
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    background: #020617;
    object-fit: contain;
}

.audio-player {
    width: min(100%, 360px);
    margin-top: 10px;
}

.doc-link {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    margin-top: 10px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 12px;
    text-decoration: none;
    color: var(--text);
    background: #f8fafc;
}

.doc-link__icon {
    font-weight: 700;
    color: var(--primary);
}

.chat-bubble {
    margin-top: 10px;
    max-width: 720px;
    padding: 12px 14px;
    border-radius: 14px;
    background: #eef4ff;
    border: 1px solid #cfe0ff;
    line-height: 1.5;
}

.timeline-quote {
    margin: 10px 0 0;
    padding: 12px 14px;
    border-left: 4px solid #cbd5e1;
    background: #f8fafc;
    border-radius: 10px;
    color: var(--text);
    white-space: pre-wrap;
}

.timeline-item__reason {
    margin-top: 10px;
    padding: 10px 12px;
    border-radius: 10px;
    background: #fff1f2;
    color: #8a1c1c;
}

.empty-state {
    padding: 24px;
    text-align: center;
    color: var(--muted);
    border: 1px dashed var(--border);
    border-radius: 12px;
    background: #fafbff;
}

.empty-state--inline {
    padding: 16px;
}

.filter-bar {
    display: flex;
    gap: 12px;
    align-items: end;
    flex-wrap: wrap;
}

.filter-bar--inline {
    margin-bottom: 16px;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 220px;
}

.field--search {
    min-width: min(100%, 360px);
    flex: 1 1 320px;
}

.field span {
    font-size: 14px;
    font-weight: 600;
}

.field input,
.field select {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 15px;
    background: #fff;
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 44px;
    padding: 10px 16px;
    border: 1px solid transparent;
    border-radius: 10px;
    text-decoration: none;
    font-weight: 700;
    cursor: pointer;
}

.button:disabled {
    cursor: wait;
    opacity: 0.75;
}

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

.button--secondary {
    background: #fff;
    color: var(--text);
    border-color: var(--border);
}

.button--success {
    background: var(--success);
    color: #fff;
}

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

.button--sm {
    min-height: 36px;
    padding: 8px 12px;
    font-size: 14px;
}

.data-table-wrap {
    overflow-x: auto;
}

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

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

.data-table th {
    font-size: 13px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.json-preview {
    margin: 0;
    padding: 10px 12px;
    border-radius: 10px;
    background: #0f172a;
    color: #e2e8f0;
    font-size: 12px;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
}

.detail-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    margin: 0;
}

.detail-list dt {
    margin-bottom: 6px;
    color: var(--muted);
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.detail-list dd {
    margin: 0;
    font-weight: 600;
}

.stack-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.stack-card {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #fbfcff;
}

.chip-list {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.chip {
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: #fff;
    color: var(--text);
    cursor: pointer;
}

.task-feedback {
    min-height: 44px;
    padding: 12px 14px;
    border-radius: 10px;
    background: #f8fafc;
    color: var(--muted);
    border: 1px solid var(--border);
}

.task-feedback.is-hidden {
    display: none;
}

.is-hidden {
    display: none !important;
}

.is-filter-hidden {
    display: none !important;
}

.task-feedback--pending {
    background: #fffdf6;
    color: #8a6700;
    border-color: #ead7a1;
}

.task-feedback--success {
    background: #f0fdf4;
    color: #166534;
    border-color: #bbf7d0;
}

.task-feedback--error {
    background: #fff1f2;
    color: #9f1239;
    border-color: #fecdd3;
}

@media (max-width: 1080px) {
    .portal-layout {
        grid-template-columns: 1fr;
    }

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

    .detail-toolbar,
    .chat-message__meta,
    .timeline-group__header,
    .timeline-item__footer {
        align-items: flex-start;
    }
}

.login-shell {
    min-height: calc(100vh - 110px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
}

.login-card {
    width: min(100%, 420px);
    padding: 28px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: 0 20px 50px rgba(15, 23, 42, 0.08);
}

.login-card__header h1 {
    margin: 0 0 8px;
}

.login-card__header p {
    margin: 0 0 20px;
    color: var(--muted);
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.login-form__field {
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-weight: 600;
}

.login-form__field span {
    font-size: 14px;
}

.login-form__field input {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 15px;
    background: #fff;
}

.login-form__field input:focus {
    outline: 2px solid rgba(37, 99, 235, 0.2);
    border-color: var(--primary);
}

.login-form__submit {
    margin-top: 4px;
    border: 0;
    border-radius: 10px;
    padding: 12px 14px;
    background: var(--primary);
    color: #fff;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
}

.login-alert {
    margin-bottom: 16px;
    padding: 12px 14px;
    border-radius: 10px;
    background: #fff1f2;
    color: #8a1c1c;
    border: 1px solid #fecdd3;
}

.pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.pagination__info {
    color: var(--muted);
    font-size: 14px;
}

.pagination__controls {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.pagination__btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 38px;
    min-height: 38px;
    padding: 0 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #fff;
    color: var(--text);
    font-weight: 600;
    font-size: 14px;
    text-decoration: none;
    cursor: pointer;
}

.pagination__btn:hover:not(.pagination__btn--disabled):not(.pagination__btn--active) {
    border-color: var(--primary);
    color: var(--primary);
}

.pagination__btn--active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
    cursor: default;
}

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

.pagination__ellipsis {
    color: var(--muted);
    padding: 0 6px;
    font-weight: 600;
}
