:root {
    --azul-institucional: #3E6FDB;
    --azul-profundo: #2F56B3;
    --azul-suave: #6F93F2;
    --verde-menta: #49C2A1;
    --verde-medico: #2E9E83;
    --verde-suave: #7FE0C7;
    --azul-background: #EAF1FF;
    --verde-background: #E6F7F3;
    --cinza-light: #F4F6F9;
    --cinza-medio-claro: #D9DEE7;
    --texto-secundario: #4A5568;
    --texto-principal: #2D3748;
    --alto-contraste: #1A202C;
    --azul-cta: #2D8CFF;
    --verde-cta: #1BC58D;
    --ciano-destaque: #00B5D8;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, var(--azul-background) 0%, var(--verde-background) 100%);
    min-height: 100vh;
    color: var(--texto-principal);
    margin: 0;
    padding: 0;
}

.app-container {
    display: flex;
    min-height: 100vh;
}

/* ---- Sidebar ---- */
.sidebar {
    width: 280px;
    background: linear-gradient(180deg, var(--azul-institucional) 0%, var(--azul-profundo) 100%);
    color: white;
    display: flex;
    flex-direction: column;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
    position: fixed;
    height: 100vh;
    z-index: 1000;
}

.sidebar-header {
    padding: 2rem 1.5rem;
    text-align: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-logo {
    max-width: 120px;
    height: auto;
    filter: brightness(0) invert(1);
    margin-bottom: 0.5rem;
}

.sidebar-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin: 0;
}

.sidebar-nav {
    flex: 1;
    padding: 1rem 0;
    overflow-y: auto;
}

.sidebar-nav .nav-link {
    color: rgba(255, 255, 255, 0.8);
    padding: 0.75rem 1.5rem;
    border-radius: 0;
    transition: all 0.2s;
    text-decoration: none;
    border-left: 3px solid transparent;
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.sidebar-nav .nav-link:hover {
    color: white;
    background: rgba(255, 255, 255, 0.1);
    border-left-color: var(--verde-menta);
}

.sidebar-nav .nav-link.active {
    color: white;
    background: rgba(255, 255, 255, 0.15);
    border-left-color: var(--verde-menta);
}

.sidebar-footer {
    padding: 1.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-footer .tenant-info {
    background: rgba(255, 255, 255, 0.1);
    padding: 0.5rem 1rem;
    border-radius: 8px;
    color: white;
    font-weight: 500;
    font-size: 0.9rem;
    margin-bottom: 1rem;
    text-align: center;
}

/* ---- Main content ---- */
.main-content {
    flex: 1;
    margin-left: 280px;
    background: linear-gradient(135deg, var(--azul-background) 0%, var(--verde-background) 100%);
    min-height: 100vh;
    padding: 2rem;
}

/* ---- Cards ---- */
.card {
    border: none;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.07);
    background: white;
}

.card-hover {
    transition: transform 0.2s, box-shadow 0.2s;
}

.card-hover:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 15px rgba(0, 0, 0, 0.1);
}

.filter-card {
    background: white;
    border-left: 4px solid var(--azul-institucional);
}

.filter-card .card-title {
    color: var(--azul-institucional);
    font-weight: 600;
}

/* ---- Forms ---- */
.form-label {
    font-weight: 500;
    color: var(--texto-secundario);
    font-size: 0.9rem;
}

.form-control, .form-select {
    border: 1px solid var(--cinza-medio-claro);
    border-radius: 8px;
    padding: 0.6rem 0.9rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-control:focus, .form-select:focus {
    border-color: var(--azul-institucional);
    box-shadow: 0 0 0 0.2rem rgba(62, 111, 219, 0.15);
}

/* ---- Buttons ---- */
.btn-primary {
    background: linear-gradient(90deg, var(--azul-cta) 0%, var(--ciano-destaque) 100%);
    border: none;
    border-radius: 8px;
    padding: 0.6rem 1.5rem;
    font-weight: 500;
    transition: transform 0.2s, box-shadow 0.2s;
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(45, 140, 255, 0.3);
    background: linear-gradient(90deg, var(--azul-institucional) 0%, var(--azul-cta) 100%);
}

.btn-outline-light:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: white;
}

/* ---- Login ---- */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, var(--azul-institucional) 0%, var(--verde-menta) 100%);
}

.login-container {
    width: 100%;
    max-width: 450px;
    padding: 2rem;
}

.login-card {
    background: white;
    border-radius: 16px;
    padding: 3rem 2.5rem;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
}

.login-logo {
    max-width: 200px;
    height: auto;
}

.login-title {
    color: var(--azul-institucional);
    font-weight: 700;
    font-size: 1.75rem;
}

.password-input-group {
    position: relative;
}

.password-input-group .form-control {
    padding-right: 3rem;
}

.password-toggle {
    position: absolute;
    right: 0;
    top: 0;
    height: 100%;
    background: transparent;
    border: none;
    padding: 0 1rem;
    color: var(--texto-secundario);
    cursor: pointer;
    transition: color 0.2s;
}

.password-toggle:hover {
    color: var(--azul-institucional);
}

.login-footer {
    border-top: 1px solid var(--cinza-medio-claro);
}

.login-info {
    color: rgba(255, 255, 255, 0.9);
}

/* ---- Typography ---- */
.text-muted {
    color: var(--texto-secundario) !important;
}

small {
    font-size: 0.85rem;
}

/* ---- Animations ---- */
.fade-in {
    animation: fadeIn 0.4s ease-in;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}

.pulse {
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.6; }
}

/* ---- Page header ---- */
.page-header {
    margin-bottom: 1.5rem;
}

.page-header h1 {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--texto-principal);
}

.page-header p {
    color: var(--texto-secundario);
    margin: 0;
}

/* ---- Tables ---- */
.table-container {
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.07);
    overflow: hidden;
}

.table {
    margin: 0;
}

.table thead th {
    background: var(--cinza-light);
    color: var(--texto-secundario);
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid var(--cinza-medio-claro);
    padding: 0.875rem 1rem;
}

.table tbody td {
    padding: 0.875rem 1rem;
    vertical-align: middle;
    border-bottom: 1px solid var(--cinza-light);
}

.table tbody tr:last-child td {
    border-bottom: none;
}

.table tbody tr:hover {
    background: var(--azul-background);
}

/* ---- Badges ---- */
.badge-status-active, .badge-status-ativo {
    background: var(--verde-background);
    color: var(--verde-medico);
    border: 1px solid var(--verde-suave);
    font-weight: 500;
}

.badge-status-inactive, .badge-status-inativo {
    background: #FFF5F5;
    color: #C53030;
    border: 1px solid #FEB2B2;
    font-weight: 500;
}

.badge-type-admin {
    background: var(--azul-background);
    color: var(--azul-institucional);
    border: 1px solid var(--azul-suave);
    font-weight: 500;
}

.badge-type-regular {
    background: var(--verde-background);
    color: var(--verde-medico);
    border: 1px solid var(--verde-suave);
    font-weight: 500;
}

/* ---- Case cards ---- */
.case-file-card {
    border-radius: 10px;
    border: 1px solid var(--cinza-medio-claro);
    transition: box-shadow 0.2s;
}

.case-file-card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.case-file-card.state-empty {
    border-color: var(--cinza-medio-claro);
    background: var(--cinza-light);
}

.case-file-card.state-pending,
.case-file-card.state-processing {
    border-color: #F6AD55;
    background: #FFFAF0;
}

.case-file-card.state-processed {
    border-color: var(--verde-menta);
    background: var(--verde-background);
}

.case-file-card.state-failed {
    border-color: #FC8181;
    background: #FFF5F5;
}

.criteria-result-row {
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    padding: 0.5rem 0.6rem;
    border-radius: 6px;
    border-left: 3px solid transparent;
    margin-bottom: 0.3rem;
    font-size: 0.875rem;
}

.criteria-result-row:last-child {
    margin-bottom: 0;
}

.criteria-result-row.criteria-match {
    background: rgba(73, 194, 161, 0.1);
    border-left-color: var(--verde-menta);
}

.criteria-result-row.criteria-fail {
    background: rgba(252, 129, 129, 0.1);
    border-left-color: #FC8181;
}

.criteria-result-row.criteria-pending {
    background: rgba(0, 0, 0, 0.02);
    border-left-color: var(--cinza-medio-claro);
}

.criteria-icon {
    font-size: 1rem;
    margin-top: 0.1rem;
    flex-shrink: 0;
}

.criteria-match .criteria-icon { color: var(--verde-medico); }
.criteria-fail .criteria-icon   { color: #E53E3E; }
.criteria-pending .criteria-icon { color: #A0AEC0; }

.criteria-content {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.criteria-name {
    font-weight: 500;
    line-height: 1.3;
}

.criteria-match .criteria-name  { color: var(--verde-medico); }
.criteria-fail .criteria-name   { color: #C53030; }
.criteria-pending .criteria-name { color: var(--texto-secundario); }

.criteria-note {
    font-size: 0.78rem;
    color: var(--texto-secundario);
    margin-top: 0.15rem;
    line-height: 1.35;
}

/* Score badge (X/Y) on processed card header */
.criteria-score {
    font-size: 0.78rem;
    font-weight: 700;
    padding: 0.15rem 0.55rem;
    border-radius: 20px;
    letter-spacing: 0.3px;
}

.criteria-score.score-all {
    background: var(--verde-background);
    color: var(--verde-medico);
    border: 1px solid var(--verde-suave);
}

.criteria-score.score-partial {
    background: #FFFAF0;
    color: #C05621;
    border: 1px solid #F6AD55;
}

.criteria-score.score-none {
    background: #FFF5F5;
    color: #C53030;
    border: 1px solid #FC8181;
}

.criteria-score.score-neutral {
    background: var(--cinza-light);
    color: var(--texto-secundario);
    border: 1px solid var(--cinza-medio-claro);
}

/* ---- Workflow builder ---- */
.workflow-file-row {
    background: white;
    border: 1px solid var(--cinza-medio-claro);
    border-radius: 8px;
    margin-bottom: 0.5rem;
}

.workflow-file-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    cursor: pointer;
}

.workflow-file-body {
    padding: 1rem;
    border-top: 1px solid var(--cinza-light);
}

.criteria-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--cinza-light);
}

.criteria-row:last-child {
    border-bottom: none;
}

/* ---- Home hero ---- */
.hero-block {
    background: linear-gradient(135deg, var(--azul-institucional) 0%, var(--verde-menta) 100%);
    border-radius: 16px;
    padding: 3rem 2rem;
    color: white;
    text-align: center;
    box-shadow: 0 8px 30px rgba(62, 111, 219, 0.3);
}

.hero-block h1 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.hero-block p {
    opacity: 0.9;
    font-size: 1.1rem;
}

/* ---- Pagination ---- */
.pagination .page-link {
    color: var(--azul-institucional);
    border-color: var(--cinza-medio-claro);
}

.pagination .page-item.active .page-link {
    background: var(--azul-institucional);
    border-color: var(--azul-institucional);
    color: white;
}

.pagination .page-link:hover {
    background: var(--azul-background);
    color: var(--azul-profundo);
}

/* ---- Toast ---- */
.toast-container {
    position: fixed;
    top: 1.5rem;
    right: 1.5rem;
    z-index: 9999;
}

/* ---- Responsive ---- */
@media (max-width: 992px) {
    .sidebar { width: 250px; }
    .main-content { margin-left: 250px; }
}

@media (max-width: 768px) {
    .sidebar { width: 100%; position: relative; height: auto; }
    .main-content { margin-left: 0; padding: 1rem; }
    .app-container { flex-direction: column; }
    .sidebar-nav { padding: 0.5rem 0; }
    .sidebar-nav .nav-link { padding: 0.5rem 1rem; }
    .sidebar-footer { padding: 1rem; }
    .sidebar-footer .tenant-info { display: none; }
    .login-card { padding: 2rem 1.5rem; }
    .login-container { padding: 1rem; }
}
