:root {
    --bg: #067f7d;
    --bg-dark: #046462;
    --panel: #ffffff;
    --muted: #6b7280;
    --text: #0f172a;
    --line: #e5e7eb;
    --accent-soft: #7ac5c0;
    --ok: #0f8b57;
    --bad: #c0392b;
    --warn: #a16b00;
}

* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: 'Inter', Arial, sans-serif;
    color: var(--text);
    background: #f3f6f9;
}

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

.login-page {
    min-height: 100vh;
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.login-wrap { width: min(1200px, 100%); }

.login-card {
    background: #f7f7f7;
    border-radius: 22px;
    min-height: 640px;
    display: flex;
    overflow: hidden;
    box-shadow: 0 25px 60px rgba(0,0,0,.18);
}

.login-brand-side,
.login-form-side {
    padding: 56px;
}

.login-brand-side {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 16px;
}

.login-brand-side img {
    width: min(360px, 90%);
    height: auto;
}

.login-brand-side p {
    color: #4b5563;
    max-width: 360px;
    text-align: center;
    margin: 0;
}

.login-form-side {
    width: 520px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.login-form-side h1 {
    margin: 0 0 22px;
    color: var(--bg);
    font-size: 44px;
    font-weight: 800;
}

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

.login-form-side label {
    font-weight: 700;
    color: var(--bg);
    margin-top: 4px;
}

.login-form-side input[type="text"],
.login-form-side input[type="password"],
.login-form-side input[type="email"],
.login-form-side input[type="date"],
.login-form-side select,
.stack-form input,
.stack-form select,
.filters input,
.filters select,
.filters textarea,
.stack-form textarea,
.inline-form input[type="password"] {
    width: 100%;
    border: 1px solid #d1d5db;
    background: #eef3fb;
    border-radius: 10px;
    padding: 12px 14px;
    font-size: 14px;
    outline: none;
}

.check-inline {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin: 4px 0 10px;
    color: var(--bg) !important;
}

.check-inline input { width: 16px; height: 16px; }

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

.btn {
    border: 1px solid transparent;
    border-radius: 999px;
    padding: 10px 14px;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-size: 14px;
}

.btn-sm { padding: 6px 10px; font-size: 12px; }
.btn-block { width: 100%; }
.btn-primary {
    background: var(--accent-soft);
    color: #fff;
}
.btn-primary:hover { filter: brightness(.95); }
.btn-outline {
    background: #fff;
    color: var(--bg-dark);
    border-color: #cfd8dc;
}
.btn-ghost {
    background: transparent;
    color: #fff;
    border-color: rgba(255,255,255,.25);
}

.alert {
    border-radius: 12px;
    padding: 10px 12px;
    margin-bottom: 12px;
    font-size: 14px;
}
.alert-success { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }
.alert-danger { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.alert-warning { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }

.app-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 260px 1fr;
}

.sidebar {
    background: linear-gradient(180deg, var(--bg), var(--bg-dark));
    color: #fff;
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 18px;
}
.brand {
    background: rgba(255,255,255,.08);
    border: 1px solid rgba(255,255,255,.15);
    border-radius: 16px;
    padding: 10px;
}
.brand img { width: 100%; max-height: 64px; object-fit: contain; background: #fff; border-radius: 10px; padding: 6px; }
.brand small { opacity: .9; display: block; margin-top: 8px; }

.menu { display: grid; gap: 6px; }
.menu a {
    padding: 10px 12px;
    border-radius: 12px;
    color: rgba(255,255,255,.92);
    border: 1px solid transparent;
}
.menu a:hover, .menu a.active {
    background: rgba(255,255,255,.12);
    border-color: rgba(255,255,255,.18);
}

.sidebar-foot { margin-top: auto; display: grid; gap: 10px; }
.user-box {
    background: rgba(255,255,255,.08);
    border-radius: 12px;
    padding: 10px 12px;
    display: grid;
}
.user-box span { opacity: .8; font-size: 12px; }

.content { padding: 18px; }
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}
.topbar h1 { margin: 0; font-size: 26px; }

.grid { display: grid; gap: 14px; margin-bottom: 14px; }
.kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.kpis-compact { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.two-cols { grid-template-columns: 1.2fr 0.8fr; }

.card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 14px;
    box-shadow: 0 10px 24px rgba(15,23,42,.04);
}
.card h2, .card h3 { margin: 0; }
.card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 12px;
}

.kpi h3 {
    color: #334155;
    font-size: 13px;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: .04em;
}
.metric-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    border-bottom: 1px dashed #e5e7eb;
    font-size: 13px;
}
.metric-row:last-child { border-bottom: 0; }
.metric-row strong { font-size: 15px; }
.highlight {
    background: linear-gradient(145deg, #f7fffe, #ecffff);
    border-color: #bae6fd;
}
.big-number {
    font-size: 32px;
    font-weight: 800;
    margin-top: 8px;
}
.ok { color: var(--ok); }
.bad { color: var(--bad); }

.table-wrap {
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: 12px;
}
.table-wrap table {
    width: 100%;
    border-collapse: collapse;
    min-width: 860px;
}
.table-wrap th, .table-wrap td {
    padding: 10px 10px;
    border-bottom: 1px solid #edf2f7;
    vertical-align: top;
    font-size: 13px;
    text-align: left;
}
.table-wrap thead th {
    background: #f8fafc;
    position: sticky;
    top: 0;
    z-index: 1;
}
.small-cell { max-width: 260px; white-space: normal; }

.badge {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 4px 9px;
    font-size: 11px;
    font-weight: 700;
    border: 1px solid;
}
.badge-ok { background: #ecfdf5; color: #065f46; border-color: #a7f3d0; }
.badge-bad { background: #fef2f2; color: #991b1b; border-color: #fecaca; }
.badge-warn { background: #fffbeb; color: #92400e; border-color: #fde68a; }

.filters {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 10px;
    align-items: end;
}
.filters label { display: block; font-size: 12px; color: #334155; margin-bottom: 4px; font-weight: 700; }
.filter-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.stack-form { display: grid; gap: 6px; }
.stack-form label { font-size: 12px; font-weight: 700; color: #334155; }
.inline-form { display: inline-flex; gap: 6px; align-items: center; margin: 3px 0; flex-wrap: wrap; }

.list-stack { display: grid; gap: 8px; }
.list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 10px;
}
.list-item small { display: block; color: var(--muted); margin-top: 3px; }

canvas { max-width: 100%; }

.chart-box {
    position: relative;
    width: 100%;
    height: 340px;
    min-height: 260px;
}

.chart-box canvas {
    display: block;
    width: 100% !important;
    height: 100% !important;
    min-height: 0 !important;
}

@media (max-width: 1100px) {
    .app-shell { grid-template-columns: 1fr; }
    .sidebar { position: sticky; top: 0; z-index: 5; }
    .kpis, .kpis-compact, .two-cols { grid-template-columns: 1fr; }
    .filters { grid-template-columns: 1fr 1fr; }
}


@media (max-width: 900px) {
    .chart-box { height: 280px; }
}

@media (max-width: 900px) {
    .login-card { flex-direction: column; min-height: unset; }
    .login-form-side { width: 100%; }
    .login-brand-side, .login-form-side { padding: 28px; }
    .login-form-side h1 { font-size: 32px; }
    .filters { grid-template-columns: 1fr; }
}

@media print {
    .sidebar, .topbar, .filters .filter-actions, .btn { display: none !important; }
    .app-shell { grid-template-columns: 1fr; }
    .content { padding: 0; }
    .card { box-shadow: none; border: 1px solid #ddd; }
    body { background: #fff; }
}


/* ===== Catálogo de procedimentos/preparos ===== */
.section-title {
    margin: 0 0 6px;
    font-size: 16px;
    font-weight: 800;
    color: #0f172a;
}
.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px 10px;
}
.form-grid .full { grid-column: 1 / -1; }
.toolbar-inline {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}
.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 999px;
    border: 1px solid #dbeafe;
    background: #eff6ff;
    color: #1d4ed8;
    font-size: 11px;
    font-weight: 700;
}
.chip-muted {
    border-color: #e5e7eb;
    background: #f8fafc;
    color: #475569;
}
.chip-ok {
    border-color: #bbf7d0;
    background: #ecfdf5;
    color: #166534;
}
.chip-bad {
    border-color: #fecaca;
    background: #fef2f2;
    color: #991b1b;
}
.table-actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}
.file-link {
    color: var(--bg-dark);
    text-decoration: underline;
    font-weight: 600;
}
.kpi-mini {
    display: grid;
    grid-template-columns: repeat(4, minmax(0,1fr));
    gap: 8px;
}
.kpi-mini .mini-box {
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 10px;
    background: #fff;
}
.kpi-mini .mini-box strong { display:block; font-size: 18px; margin-top: 4px; }
.note-box {
    background: #f8fafc;
    border: 1px dashed #cbd5e1;
    border-radius: 12px;
    padding: 10px;
    color: #334155;
    font-size: 13px;
}
@media (max-width: 900px) {
    .form-grid { grid-template-columns: 1fr; }
    .kpi-mini { grid-template-columns: 1fr 1fr; }
}
