:root {
    --color-primary: #2563eb;
    --color-primary-dark: #1d4ed8;
    --color-success: #16a34a;
    --color-danger: #dc2626;
    --color-warning: #f59e0b;
    --color-text: #111827;
    --color-muted: #6b7280;
    --color-border: #e5e7eb;
    --color-surface: #f3f4f6;
    --color-surface-muted: #f9fafb;
    --color-card: #ffffff;
    --radius-lg: 16px;
    --radius-md: 12px;
    --shadow-lg: 0 20px 45px rgba(15, 23, 42, 0.08);
    --shadow-md: 0 12px 35px rgba(15, 23, 42, 0.08);
}

body {
    background: var(--color-surface);
    color: var(--color-text);
}

a {
    color: var(--color-primary);
}

a:hover {
    color: var(--color-primary-dark);
}

main.app-container {
    padding-top: 32px;
    padding-bottom: 48px;
}

.app-card {
    background: var(--color-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
}

.app-card .card-header,
.app-card .card-footer {
    background: transparent;
    border-color: var(--color-border);
}

.auth-card {
    padding: 32px;
}

.auth-card .form-text {
    color: var(--color-muted);
}

.chat-search {
    max-width: 240px;
}

.cadastros-col-name {
    width: 25%;
}

.cadastros-col-created {
    width: 200px;
}

.cadastros-col-actions {
    width: 220px;
}

.admin-col-actions {
    width: 220px;
}

.password-hints-list {
    list-style: none;
    padding-left: 0;
    margin-bottom: 0;
}

.password-hints-list li {
    color: var(--color-muted);
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.password-hints-list li::before {
    content: '-';
}

.password-hints-list li.is-valid {
    color: #16a34a;
}

.password-hints-list li.is-invalid {
    color: #dc2626;
}

.password-toggle-icon {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

.password-toggle .password-toggle-icon.is-hidden {
    display: none;
}

.password-toggle.is-revealed .password-toggle-icon.is-hidden {
    display: inline-block;
}

.password-toggle.is-revealed .password-toggle-icon.is-visible {
    display: none;
}

.dashboard {
    background: var(--color-card);
    border-radius: var(--radius-lg);
    padding: 32px;
    box-shadow: var(--shadow-lg);
    margin-top: 40px;
}

.dashboard-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

.dashboard-title {
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: 6px;
}

.dashboard-subtitle {
    margin: 0;
    color: var(--color-muted);
    font-size: 0.95rem;
}

.dashboard-actions {
    display: flex;
    align-items: flex-end;
    flex-wrap: wrap;
    gap: 20px;
}

.status-toggle {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 18px;
    border: 1px solid var(--color-border);
    border-radius: 999px;
    background: var(--color-surface-muted);
}

.status-toggle .toggle-label {
    font-weight: 600;
    color: #374151;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.toggle-btn {
    width: 64px;
    height: 32px;
    background-color: #d1d5db;
    border-radius: 32px;
    position: relative;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.toggle-btn .toggle-circle {
    width: 28px;
    height: 28px;
    background-color: #ffffff;
    border-radius: 50%;
    position: absolute;
    top: 2px;
    left: 2px;
    transition: 0.3s ease;
    box-shadow: 0 4px 10px rgba(15, 23, 42, 0.18);
}

.toggle-btn.active {
    background-color: var(--color-success);
}

.toggle-btn.active .toggle-circle {
    left: 34px;
}

.toggle-state {
    font-weight: 600;
    color: #4b5563;
    min-width: 64px;
    text-align: right;
}

.date-filter {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.date-filter-control {
    display: flex;
    align-items: center;
    gap: 12px;
}

.date-filter input[type="date"] {
    padding: 10px 14px;
    border: 1px solid #d1d5db;
    border-radius: 10px;
    font-size: 0.95rem;
    color: var(--color-text);
}

.date-filter input[type="date"]:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.loading-indicator {
    font-size: 0.85rem;
    color: var(--color-muted);
}

.dashboard-alert {
    margin-top: 20px;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    background: #fee2e2;
    border: 1px solid #fecaca;
    color: #b91c1c;
}

.status-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-top: 28px;
}

.status-card {
    border-radius: 18px;
    padding: 22px;
    background: linear-gradient(135deg, #ffffff 0%, #f3f4f6 100%);
    cursor: pointer;
    text-align: left;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    display: flex;
    flex-direction: column;
    gap: 8px;
    border: none;
}

.status-card:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

.status-card.active {
    box-shadow: 0 12px 35px rgba(37, 99, 235, 0.15);
    transform: translateY(-2px);
}

.status-label {
    display: block;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--color-muted);
}

.status-value {
    display: block;
    font-size: 2.1rem;
    font-weight: 600;
    color: var(--color-text);
}

.status-value.text-danger {
    color: var(--color-danger) !important;
}

.status-hint {
    font-size: 0.8rem;
    color: var(--color-muted);
}

.reports-wrapper {
    margin-top: 32px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 20px;
}

.report-panel {
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 20px;
    background: var(--color-surface-muted);
    box-shadow: var(--shadow-md);
    display: none;
}

.report-panel.is-visible {
    display: block;
}

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

.panel-header h5 {
    margin: 0;
    font-weight: 600;
    color: var(--color-text);
}

.panel-header p {
    margin: 4px 0 0;
    font-size: 0.85rem;
    color: var(--color-muted);
}

.report-badge {
    background: #e0e7ff;
    color: #3730a3;
    padding: 6px 12px;
    border-radius: 999px;
    font-weight: 600;
    font-size: 0.9rem;
}

.report-badge--danger {
    background: #fee2e2;
    color: #b91c1c;
}

.report-empty {
    font-size: 0.9rem;
    color: var(--color-muted);
    margin-bottom: 12px;
}

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

.report-item {
    background: var(--color-card);
    border-radius: 14px;
    border: 1px solid var(--color-border);
    padding: 16px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    box-shadow: 0 5px 15px rgba(15, 23, 42, 0.05);
}

.report-meta {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.report-waid {
    font-weight: 600;
    color: var(--color-text);
}

.report-time {
    font-size: 0.85rem;
    color: var(--color-muted);
}

.report-status {
    font-size: 0.85rem;
    color: #10b981;
}

.report-status.text-danger {
    color: var(--color-danger);
}

.details-btn {
    border: 1px solid var(--color-primary);
    background: transparent;
    color: var(--color-primary);
    border-radius: 999px;
    padding: 8px 16px;
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease;
}

.details-btn:hover {
    background: var(--color-primary);
    color: #fff;
}

.report-modal {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px;
    z-index: 1050;
    overflow-y: auto;
}

.report-modal::before {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    pointer-events: none;
}

.report-modal.open {
    display: flex;
}

.report-modal .modal-dialog {
    width: min(640px, calc(100vw - 32px));
    margin: 16px auto;
    max-height: 90vh;
    display: flex;
    pointer-events: none;
    z-index: 1;
}

.report-modal .modal-content {
    background: var(--color-card);
    border-radius: 18px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    padding: 24px;
    position: relative;
    box-shadow: 0 25px 70px rgba(15, 23, 42, 0.25);
    pointer-events: auto;
}

.report-modal .modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    border: none;
    background: transparent;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--color-muted);
}

.report-modal .modal-section {
    margin-bottom: 20px;
}

.report-modal .modal-section h6 {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: 8px;
}

.report-modal .modal-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    font-size: 0.9rem;
    padding: 6px 0;
    border-bottom: 1px solid #f3f4f6;
}

.report-modal .modal-row span {
    color: var(--color-muted);
}

.report-modal .modal-pre {
    background: #1f2937;
    color: #f9fafb;
    border-radius: 12px;
    padding: 16px;
    font-size: 0.85rem;
    max-height: 320px;
    overflow-y: auto;
    overflow-x: auto;
    white-space: pre;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

.instance-card {
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 24px;
    background: var(--color-card);
    box-shadow: 0 20px 45px rgba(15, 23, 42, 0.05);
}

.qr-preview {
    max-width: 240px;
    border-radius: var(--radius-md);
    border: 1px solid var(--color-border);
    background: var(--color-card);
    padding: 12px;
}

.action-card {
    border: 1px solid var(--color-border);
    border-radius: 14px;
    padding: 20px;
    height: 100%;
    background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.action-card h5 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.action-card p {
    flex-grow: 1;
    color: var(--color-muted);
    font-size: 0.9rem;
}

@media (max-width: 575.98px) {
    .dashboard {
        padding: 24px 20px;
    }

    .status-toggle {
        width: 100%;
        justify-content: space-between;
    }

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

    .report-item {
        flex-direction: column;
        align-items: flex-start;
    }
}
