/* NefroSystem global visual layer: neutral clinical palette and readable UI. */
:root {
    --nefro-primary: #0f7f95;
    --nefro-primary-dark: #0b5f70;
    --nefro-primary-soft: #e7f5f7;
    --nefro-accent: #2f7d6d;
    --nefro-bg: #f4f8fb;
    --nefro-surface: rgba(255, 255, 255, 0.96);
    --nefro-surface-soft: rgba(248, 251, 252, 0.98);
    --nefro-text: #172033;
    --nefro-muted: #64748b;
    --nefro-border: #d8e3ea;
    --nefro-shadow: 0 10px 28px -20px rgba(15, 23, 42, 0.20);
    --nefro-shadow-sm: 0 6px 18px -14px rgba(15, 23, 42, 0.16);
    --nefro-success: #16835f;
    --nefro-warning: #b7791f;
    --nefro-danger: #c24141;
    --nefro-radius: 14px;
    --nefro-radius-lg: 18px;
    --nefro-radius-xl: 24px;
    --nefro-radius-pill: 999px;
    --nefro-shell-width: 1680px;

    --primary: var(--nefro-primary);
    --primary-dark: var(--nefro-primary-dark);
    --nefro-blue: var(--nefro-primary);
    --nefro-blue-dark: var(--nefro-primary-dark);
    --nefro-green: var(--nefro-success);
    --nefro-yellow: var(--nefro-warning);
    --success: var(--nefro-success);
    --warning: var(--nefro-warning);
    --danger: var(--nefro-danger);
    --bg: var(--nefro-bg);
    --bg-body: var(--nefro-bg);
    --bg-main: var(--nefro-bg);
    --surface: var(--nefro-surface);
    --white: var(--nefro-surface);
    --text: var(--nefro-text);
    --text-main: var(--nefro-text);
    --text-dark: var(--nefro-text);
    --text-muted: var(--nefro-muted);
    --text-sub: var(--nefro-muted);
    --border: var(--nefro-border);
}

html {
    color-scheme: light;
    background: var(--nefro-bg);
}

body {
    background:
        linear-gradient(180deg, #f7fafc 0%, var(--nefro-bg) 62%, #eef4f8 100%) !important;
    color: var(--nefro-text) !important;
    font-family: "Plus Jakarta Sans", "Inter", "Segoe UI", Arial, sans-serif !important;
    line-height: 1.45;
    letter-spacing: 0;
    min-width: 0;
    overflow-x: hidden;
}

body::selection {
    background: rgba(15, 127, 149, 0.22);
}

h1, h2, h3, h4, h5, h6 {
    color: var(--nefro-text);
    letter-spacing: 0 !important;
}

p, small, span, label, td, th, input, select, textarea, button, a {
    letter-spacing: 0 !important;
}

button,
input,
select,
textarea {
    font: inherit;
    color: inherit;
}

input,
select,
textarea {
    min-width: 0;
}

button {
    cursor: pointer;
}

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

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

:focus-visible {
    outline: 3px solid rgba(15, 127, 149, 0.22) !important;
    outline-offset: 2px;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

img,
video,
canvas,
svg,
iframe {
    max-width: 100%;
}

main,
section,
article,
aside,
header,
footer,
nav,
.content,
.main-container,
.hub-container,
.portal-shell,
.container,
.container-fluid {
    min-width: 0;
}

:where(.wrap, .hub-container, .portal-shell, .page-shell) {
    width: min(100%, var(--nefro-shell-width));
    margin-inline: auto;
    padding: clamp(18px, 2vw, 32px);
}

:where(.wrap, .hub-container, .portal-shell, .page-shell, .container, .container-fluid) {
    width: min(100%, var(--nefro-shell-width));
    margin-inline: auto;
    padding-inline: clamp(18px, 2vw, 32px);
}
body.nefro-master-operacional {
    --nefro-operational-master-top-offset: clamp(56px, 7vw, 84px);
    --nefro-portal-sticky-top: calc(var(--nefro-operational-master-top-offset) + 10px);
    --nefro-portal-sticky-top-mobile: calc(var(--nefro-operational-master-top-offset) + 6px);
}
body.nefro-master-operacional :where(.dashboard-container > .main-header:first-child,
       .page > .header:first-child,
       .page > .main-header:first-child,
       .page-shell > .page-topbar:first-child,
       .portal-shell > .portal-topbar:first-child,
       .portal-shell > .main-header:first-child,
       .portal-shell > .header:first-child,
       .hub-container > .main-header:first-child,
       .wrap > .main-header:first-child,
       .container > .main-header:first-child,
       .container-fluid > .main-header:first-child) {
    margin-top: var(--nefro-operational-master-top-offset) !important;
}

:where(.table-container, .table-responsive, .table-wrap, .scroll-x, .scrollable, .overflow-x-auto) {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
}

:where(.topbar, .navbar, .header, .page-header, .form-header, .action-bar, .status-bar, .sidebar, .portal-topbar) {
    border: 1px solid rgba(216, 227, 234, 0.92) !important;
    background: rgba(255, 255, 255, 0.96) !important;
    box-shadow: var(--nefro-shadow-sm) !important;
    backdrop-filter: none;
}

:where(.actions, .page-actions, .card-actions, .toolbar, .controls, .btn-group, .btn-group-right, .hero .actions) {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}

:where(.portal-topbar) {
    border-radius: var(--nefro-radius-xl) !important;
}

:where(.topbar, .navbar, .header, .page-header, .form-header, .action-bar, .status-bar) {
    border-radius: var(--nefro-radius-lg) !important;
}

:where(.card, .section-card, .metric-card, .kpi-card, .category-card, .table-container, .box, .modal, .modal-content, .document, .history-card, .info-box, .notif-card, .doc-card, .item-card, .client-card, .login-card, .glass-card, .portal-card, .portal-panel, .portal-entry-card, .portal-modern-panel, .portal-modern-entry, .portal-modern-row, .portal-modern-feature, .portal-modern-flow) {
    overflow: hidden;
}

:where(.nav-item, .btn, .btn-premium, .btn-action, .btn-new, .btn-add, .btn-save, .btn-primary, .btn-secondary, .btn-outline, .tab, .chip, .filter-chip) {
    min-height: 38px;
}

:where(.nav-item, .btn, .btn-premium, .btn-action, .btn-new, .btn-add, .btn-save, .btn-primary, .btn-secondary, .btn-outline) {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

:where(.lead, .page-description, .section-description, .hero .lead, .hero p, .page-hero p, .welcome-text p) {
    color: var(--nefro-muted);
    font-weight: 650;
    line-height: 1.5;
}

:where(.steps) {
    display: grid;
    gap: 12px;
}

:where(.step) {
    border: 1px solid var(--nefro-border);
    border-radius: 18px;
    padding: 14px;
    background: rgba(255,255,255,.86);
    box-shadow: none;
}

:where(.table-container, .table-responsive, .table-wrap, .scroll-x, .overflow-x-auto) table {
    min-width: 100%;
}

table {
    table-layout: auto;
}

th,
td {
    word-break: break-word;
    overflow-wrap: anywhere;
    vertical-align: top;
}

/* Densidade enterprise mais produtiva para listas e tabelas */
:where(table) th {
    padding: 10px 12px !important;
    font-size: 0.76rem !important;
    letter-spacing: 0.06em !important;
}

:where(table) td {
    padding: 10px 12px !important;
    font-size: 0.88rem !important;
}

:where([style*="width: 520px"], [style*="width:520px"], [style*="min-width: 520px"], [style*="min-width:520px"],
       [style*="width: 560px"], [style*="width:560px"], [style*="min-width: 560px"], [style*="min-width:560px"],
       [style*="width: 600px"], [style*="width:600px"], [style*="min-width: 600px"], [style*="min-width:600px"],
       [style*="width: 620px"], [style*="width:620px"], [style*="min-width: 620px"], [style*="min-width:620px"],
       [style*="width: 640px"], [style*="width:640px"], [style*="min-width: 640px"], [style*="min-width:640px"],
       [style*="width: 650px"], [style*="width:650px"], [style*="min-width: 650px"], [style*="min-width:650px"],
       [style*="width: 680px"], [style*="width:680px"], [style*="min-width: 680px"], [style*="min-width:680px"],
       [style*="width: 700px"], [style*="width:700px"], [style*="min-width: 700px"], [style*="min-width:700px"],
       [style*="width: 720px"], [style*="width:720px"], [style*="min-width: 720px"], [style*="min-width:720px"],
       [style*="width: 760px"], [style*="width:760px"], [style*="min-width: 760px"], [style*="min-width:760px"],
       [style*="width: 768px"], [style*="width:768px"], [style*="min-width: 768px"], [style*="min-width:768px"],
       [style*="width: 780px"], [style*="width:780px"], [style*="min-width: 780px"], [style*="min-width:780px"],
       [style*="width: 800px"], [style*="width:800px"], [style*="min-width: 800px"], [style*="min-width:800px"],
       [style*="width: 820px"], [style*="width:820px"], [style*="min-width: 820px"], [style*="min-width:820px"],
       [style*="width: 840px"], [style*="width:840px"], [style*="min-width: 840px"], [style*="min-width:840px"],
       [style*="width: 850px"], [style*="width:850px"], [style*="min-width: 850px"], [style*="min-width:850px"],
       [style*="width: 860px"], [style*="width:860px"], [style*="min-width: 860px"], [style*="min-width:860px"],
       [style*="width: 880px"], [style*="width:880px"], [style*="min-width: 880px"], [style*="min-width:880px"],
       [style*="width: 900px"], [style*="width:900px"], [style*="min-width: 900px"], [style*="min-width:900px"],
       [style*="width: 920px"], [style*="width:920px"], [style*="min-width: 920px"], [style*="min-width:920px"],
       [style*="width: 960px"], [style*="width:960px"], [style*="min-width: 960px"], [style*="min-width:960px"],
       [style*="width: 1080px"], [style*="width:1080px"], [style*="min-width: 1080px"], [style*="min-width:1080px"],
       [style*="width: 1100px"], [style*="width:1100px"], [style*="min-width: 1100px"], [style*="min-width:1100px"],
       [style*="width: 1120px"], [style*="width:1120px"], [style*="min-width: 1120px"], [style*="min-width:1120px"],
       [style*="width: 1180px"], [style*="width:1180px"], [style*="min-width: 1180px"], [style*="min-width:1180px"],
       [style*="width: 1200px"], [style*="width:1200px"], [style*="min-width: 1200px"], [style*="min-width:1200px"],
       [style*="width: 1280px"], [style*="width:1280px"], [style*="min-width: 1280px"], [style*="min-width:1280px"],
       [style*="width: 1320px"], [style*="width:1320px"], [style*="min-width: 1320px"], [style*="min-width:1320px"]) {
    width: min(100%, calc(100vw - 32px)) !important;
    max-width: calc(100vw - 32px) !important;
}

input,
select,
textarea {
    background: rgba(255, 255, 255, 0.92) !important;
    color: var(--nefro-text) !important;
    border: 1px solid var(--nefro-border) !important;
    border-radius: var(--nefro-radius) !important;
    box-shadow: none !important;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--nefro-primary) !important;
    box-shadow: 0 0 0 4px rgba(15, 127, 149, 0.12) !important;
}

button,
.btn,
.btn-action,
.btn-new,
.btn-add,
.btn-save,
.btn-primary,
.btn-secondary,
.btn-outline,
.tab,
.chip,
.filter-chip,
.nav-item,
.modulo-card,
.card,
.section-card,
.metric-card,
.kpi-card,
.category-card,
.table-container,
.box,
.modal,
.modal-content,
.action-bar,
.controls,
.card-shadow,
.rounded-lg,
.rounded-xl,
.rounded-2xl {
    border-radius: var(--nefro-radius) !important;
}

button,
.btn,
.btn-action,
.btn-new,
.btn-add,
.btn-save,
.btn-primary {
    transition: background-color 0.18s ease, border-color 0.18s ease, color 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease !important;
}

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

.lab-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 40px;
    padding: 10px 16px;
    border: 1px solid var(--nefro-border);
    border-radius: var(--nefro-radius);
    background: #ffffff;
    color: var(--nefro-text);
    font-weight: 800;
    text-decoration: none;
    cursor: pointer;
}

.lab-btn:hover {
    border-color: rgba(15, 127, 149, 0.45);
    color: var(--nefro-primary-dark);
}

.lab-btn-muted {
    background: var(--nefro-surface-soft);
    color: var(--nefro-muted);
}

.lab-btn-success {
    background: var(--nefro-success);
    border-color: var(--nefro-success);
    color: #ffffff;
}

.lab-table {
    width: 100%;
    border-collapse: collapse;
    background: #ffffff;
}

.lab-table th,
.lab-table td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--nefro-border);
    vertical-align: top;
}

.iot-card {
    background: var(--nefro-surface) !important;
    border: 1px solid var(--nefro-border) !important;
    border-radius: var(--nefro-radius) !important;
    box-shadow: var(--nefro-shadow-sm) !important;
}

.iot-card:has(.lab-table) {
    overflow-x: auto;
}

.iot-card .lab-table {
    min-width: 560px;
}

.btn-primary,
.bg-nefro,
.btn-nav,
button[type="submit"]:not(.btn-close) {
    background-color: var(--nefro-primary) !important;
    border-color: var(--nefro-primary) !important;
    color: #ffffff !important;
}

.btn-primary:hover,
.bg-nefro:hover,
.btn-nav:hover,
button[type="submit"]:not(.btn-close):hover {
    background-color: var(--nefro-primary-dark) !important;
    border-color: var(--nefro-primary-dark) !important;
}

.btn-outline,
.btn-back,
.btn-status,
.btn-del,
.btn-action[style*="background:none"],
.btn-action[style*="background: none"] {
    box-shadow: none !important;
}

.card,
.section-card,
.metric-card,
.kpi-card,
.category-card,
.table-container,
.box,
.modal,
.modal-content,
.document,
.history-card,
.info-box,
.notif-card,
.doc-card,
.item-card,
.client-card,
.login-card,
.card-shadow {
    background: var(--nefro-surface) !important;
    border-color: var(--nefro-border) !important;
    box-shadow: var(--nefro-shadow-sm) !important;
    backdrop-filter: blur(14px);
}

.card:hover,
.section-card:hover,
.metric-card:hover,
.kpi-card:hover,
.doc-card:hover,
.notif-card:hover,
.modulo-card:hover {
    border-color: rgba(15, 127, 149, 0.45) !important;
    box-shadow: var(--nefro-shadow) !important;
}

/* --- Padrões de Grid e Cards (Centralizado para unificar telas) --- */
.info-grid, .metrics-grid, .detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

.metric-card, .stat-card {
    background: var(--nefro-surface);
    padding: 24px;
    border-radius: var(--nefro-radius);
    border: 1px solid var(--nefro-border);
    border-left: 0;
    position: relative;
    overflow: hidden;
    transition: transform 0.2s ease;
}

.metric-card::before,
.stat-card::before,
.kpi-card::before {
    content: "";
    position: absolute;
    inset: 0 0 auto 0;
    height: 4px;
    background: linear-gradient(90deg, var(--nefro-primary), rgba(15, 127, 149, 0.08));
}

.metric-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--nefro-shadow);
}

.metric-label {
    font-size: 0.75rem;
    color: var(--nefro-muted);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.metric-value {
    font-size: 2rem;
    font-weight: 800;
    color: var(--nefro-text);
}

/* --- Padrões de Engenharia e Operação --- */
.checklist-item-display {
    display: flex;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px dashed var(--nefro-border);
}
.checklist-item-display:last-child { border-bottom: none; }
.checklist-item-display .question { font-weight: 600; font-size: 0.9rem; color: var(--nefro-muted); }
.checklist-item-display .answer { font-weight: 700; font-size: 0.9rem; color: var(--nefro-primary); }
.checklist-item-display .answer.false { color: var(--nefro-danger); }

.timeline-container { padding: 10px 0; }
.timeline-item-event {
    padding-left: 24px;
    border-left: 2px solid var(--nefro-border);
    position: relative;
    margin-bottom: 20px;
    padding-bottom: 5px;
}
.timeline-item-event::before {
    content: '';
    position: absolute;
    left: -7px;
    top: 0;
    width: 12px;
    height: 12px;
    background: var(--nefro-primary);
    border-radius: 50%;
    border: 2px solid var(--nefro-surface);
}

.signature-box {
    border: 1px solid var(--nefro-border);
    border-radius: var(--nefro-radius);
    padding: 20px;
    text-align: center;
    background: var(--nefro-surface-soft);
}

/* --- Padrões de Engenharia e Operação (Unificado) --- */
.checklist-item-display {
    display: flex;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px dashed var(--nefro-border);
}
.checklist-item-display:last-child { border-bottom: none; }
.checklist-item-display .question { font-weight: 600; font-size: 0.9rem; color: var(--nefro-muted); }
.checklist-item-display .answer { font-weight: 700; font-size: 0.9rem; color: var(--nefro-primary); }
.checklist-item-display .answer.false { color: var(--nefro-danger); }

.timeline-container { padding: 10px 0; }
.timeline-item-event {
    padding-left: 24px;
    border-left: 2px solid var(--nefro-border);
    position: relative;
    margin-bottom: 20px;
    padding-bottom: 5px;
}
.timeline-item-event::before {
    content: '';
    position: absolute;
    left: -7px;
    top: 0;
    width: 12px;
    height: 12px;
    background: var(--nefro-primary);
    border-radius: 50%;
    border: 2px solid var(--nefro-surface);
}

.signature-box {
    border: 1px solid var(--nefro-border);
    border-radius: var(--nefro-radius);
    padding: 20px;
    text-align: center;
    background: var(--nefro-surface-soft);
}

.tech-report {
    background: var(--nefro-bg);
    border-radius: var(--nefro-radius);
    padding: 20px;
    border-left: 4px solid var(--nefro-primary);
}

.navbar,
header,
.top-bar,
.action-bar,
.status-bar {
    background: rgba(255, 255, 255, 0.92) !important;
    border-color: var(--nefro-border) !important;
    box-shadow: 0 1px 0 rgba(15, 23, 42, 0.04) !important;
}

/* --- Finance-style shared page frame --- */
.page-shell {
    width: min(1520px, calc(100% - 30px));
    margin: 0 auto;
    padding: 24px 0 48px;
}

.page-topbar,
.page-hero,
.page-card,
.page-panel,
.page-chip,
.page-quicklink {
    border: 1px solid rgba(216, 227, 234, 0.92);
    background: rgba(255, 255, 255, 0.92);
    box-shadow: var(--nefro-shadow-sm);
    backdrop-filter: blur(16px);
}

.page-topbar {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 18px;
    padding: 18px 22px;
    border-radius: var(--nefro-radius-xl);
}

.page-hero {
    position: relative;
    overflow: hidden;
    margin-bottom: 24px;
    padding: 24px;
    border-radius: 28px;
    color: #fff;
    background: linear-gradient(135deg, var(--nefro-primary-dark), var(--nefro-primary) 52%, #0099ff);
}

.page-hero::after {
    content: "";
    position: absolute;
    right: -60px;
    top: -60px;
    width: 300px;
    height: 300px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.16) 0%, transparent 70%);
    pointer-events: none;
}

.page-hero h1,
.page-hero h2 {
    margin: 12px 0 8px;
    color: #fff;
    font-weight: 1000;
    letter-spacing: -0.06em;
    line-height: 0.96;
}

.page-hero p {
    margin: 0;
    max-width: 920px;
    color: rgba(255, 255, 255, 0.84);
}

.page-kicker,
.page-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 7px 14px;
    border-radius: var(--nefro-radius-pill);
    font-size: 0.7rem;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.page-kicker {
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: rgba(255, 255, 255, 0.9);
}

.page-chip {
    color: var(--nefro-text);
    background: rgba(0, 123, 255, 0.06);
    border: 1px solid rgba(0, 123, 255, 0.12);
}

.page-topbar-meta,
.page-actions,
.page-quicklinks {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.page-quicklinks {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 24px;
}

.page-quicklink {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    min-height: 74px;
    padding: 14px 16px;
    border-radius: 18px;
    color: var(--nefro-text);
    text-decoration: none;
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.page-quicklink:hover {
    transform: translateY(-2px);
    border-color: rgba(15, 127, 149, 0.35);
    box-shadow: var(--nefro-shadow);
}

.page-quicklink i {
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    border-radius: 12px;
    background: rgba(15, 127, 149, 0.08);
    color: var(--nefro-primary);
    flex: 0 0 auto;
}

.page-quicklink strong {
    display: block;
    font-size: 0.92rem;
    font-weight: 950;
    line-height: 1.2;
}

.page-quicklink span {
    display: block;
    margin-top: 3px;
    color: var(--nefro-muted);
    font-size: 0.76rem;
    line-height: 1.35;
}

.page-section-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 18px;
}

.page-section-title h2 {
    margin: 0;
    font-size: 1.18rem;
    font-weight: 1000;
    letter-spacing: -0.04em;
}

.page-section-note {
    color: var(--nefro-muted);
    font-size: 0.78rem;
    font-weight: 800;
    white-space: nowrap;
}

.page-btn,
.btn-soft,
.btn-ghost {
    min-height: 44px;
    padding: 10px 16px;
    border-radius: 14px;
    border: 1px solid var(--nefro-border);
    font-weight: 900;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-decoration: none;
}

.btn-soft,
.btn-ghost {
    background: rgba(255, 255, 255, 0.9);
    color: var(--nefro-text);
}

.btn-soft:hover,
.btn-ghost:hover {
    border-color: rgba(15, 127, 149, 0.35);
    box-shadow: var(--nefro-shadow-sm);
}

.page-btn.primary,
.btn-primary,
.btn-nav,
button[type="submit"]:not(.btn-close) {
    background: var(--nefro-primary) !important;
    border-color: var(--nefro-primary) !important;
    color: #ffffff !important;
}

.page-btn.primary:hover,
.btn-primary:hover,
.btn-nav:hover,
button[type="submit"]:not(.btn-close):hover {
    background: var(--nefro-primary-dark) !important;
    border-color: var(--nefro-primary-dark) !important;
}

@media (max-width: 1200px) {
    .page-quicklinks {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .page-topbar {
        flex-direction: column;
    }
}

@media (max-width: 600px) {
    .page-quicklinks {
        grid-template-columns: 1fr;
    }

    .page-topbar,
    .page-hero {
        padding: 18px;
        border-radius: 20px;
    }

    .page-hero h1,
    .page-hero h2 {
        font-size: clamp(1.6rem, 10vw, 2.2rem);
    }
}

aside,
.sidebar,
#main-sidebar {
    background:
        linear-gradient(180deg, rgba(255,255,255,0.96), rgba(248,251,252,0.88)),
        radial-gradient(circle at 50% 0%, rgba(15,127,149,0.12), transparent 44%) !important;
    color: var(--nefro-text) !important;
    border-color: var(--nefro-border) !important;
    backdrop-filter: blur(16px);
}

.sidebar a,
.sidebar .nav-item,
#main-sidebar a,
#main-sidebar button {
    color: var(--nefro-muted) !important;
}

.sidebar .active,
.sidebar-item-active,
.nav-item.active,
.tab.active,
.chip.active,
.filter-chip.active {
    background: var(--nefro-primary-soft) !important;
    color: var(--nefro-primary-dark) !important;
    border-color: rgba(15, 127, 149, 0.3) !important;
}

table {
    background: rgba(255, 255, 255, 0.88);
    border-radius: var(--nefro-radius);
    overflow: hidden;
}

th {
    background: linear-gradient(180deg, rgba(248,251,252,0.98), rgba(231,245,247,0.70)) !important;
    color: #475569 !important;
    font-weight: 700 !important;
}

td,
th {
    border-color: var(--nefro-border) !important;
}

tbody tr:hover {
    background: rgba(15, 127, 149, 0.045) !important;
}

.badge,
.badge-config,
.status-badge,
.type-pill {
    border-radius: 6px !important;
    font-weight: 800 !important;
}

.badge.area-clinica { background: var(--nefro-primary-soft); color: var(--nefro-primary-dark); }
.badge.status-operacional { background: var(--nefro-green); color: #fff; }
.badge.status-manutencao { background: var(--nefro-yellow); color: #fff; }
.badge.status-fora_de_servico, .badge.status-parado { background: var(--nefro-danger); color: #fff; }
.badge.status-conciliado { background: var(--nefro-success); color: white; }
.badge.status-pendente { background: var(--nefro-warning); color: white; }
.badge.status-ok { background: var(--nefro-success); color: white; }
.badge.status-baixo, .badge.status-critico { background: var(--nefro-danger); color: white; }

/* Status Pills para CRM e Financeiro */
.status-pill {
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
}

/* Tabela Profissional */
table { width: 100%; border-collapse: separate; border-spacing: 0; }
th { padding: 16px; font-size: 11px; color: #64748b; text-transform: uppercase; background: #f8fafc; border-bottom: 1px solid var(--nefro-border); font-weight: 700; }
td { padding: 16px; border-bottom: 1px solid var(--nefro-border); font-size: 14px; }
tr:hover { background-color: var(--nefro-surface-soft); }

/* Input/Select styles */
.filter-group select, .filter-group input,
input, select, textarea {
    width: 100%; padding: 12px; border: 1px solid var(--nefro-border); border-radius: var(--nefro-radius); outline: none; font-size: 14px; transition: 0.2s;
    background-color: var(--nefro-surface); /* Ensure background is light */
    color: var(--nefro-text); /* Ensure text is dark */
}
.text-nefro,
.border-nefro,
h1 i,
h2 i,
h3 i {
    color: var(--nefro-primary) !important;
}

.border-nefro {
    border-color: var(--nefro-primary) !important;
}

.text-slate-900,
.text-slate-800,
.text-slate-700 {
    color: var(--nefro-text) !important;
}

.text-slate-600,
.text-slate-500,
.text-slate-400 {
    color: var(--nefro-muted) !important;
}

.bg-slate-50,
.bg-[#f8fafc],
.bg-light {
    background-color: var(--nefro-bg) !important;
}

.bg-white {
    background-color: var(--nefro-surface) !important;
}

.border-slate-100,
.border-slate-200,
.border-light {
    border-color: var(--nefro-border) !important;
}

.shadow-lg,
.shadow-xl,
.shadow-md,
.shadow-sm {
    box-shadow: var(--nefro-shadow-sm) !important;
}

.hero-bg {
    background: #eef6f7 !important;
    opacity: 0.5 !important;
    filter: none !important;
}

.welcome-hero {
    margin-bottom: 2rem !important;
    border-left-color: var(--nefro-primary) !important;
}

.welcome-text h1 {
    font-size: clamp(2rem, 5vw, 3.4rem) !important;
    line-height: 1 !important;
    letter-spacing: 0 !important;
}

.grid-modulos {
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)) !important;
    gap: 1rem !important;
}

.modulo-card {
    padding: 1.5rem !important;
    min-height: 180px;
}

.modulo-card .title {
    font-size: 1.25rem !important;
    letter-spacing: 0 !important;
}

.badge,
.badge-config,
.status-badge,
.type-pill,
.status-pill {
    border-radius: 999px !important;
}

.modal-content {
    border: 1px solid rgba(216, 227, 234, 0.88) !important;
    box-shadow: 0 34px 90px -44px rgba(15, 23, 42, 0.55) !important;
}

@media (max-width: 768px) {
    body {
        background: linear-gradient(180deg, #f8fbfc 0%, var(--nefro-bg) 100%) !important;
    }

    .info-grid, .metrics-grid, .detail-grid {
        grid-template-columns: 1fr !important;
        gap: 14px !important;
    }

    .card,
    .section-card,
    .metric-card,
    .kpi-card,
    .table-container,
    .box {
        padding: 16px !important;
    }
}

/* --- Cockpit interno dos módulos do sistema --- */
.container,
.container-fluid {
    max-width: 1360px;
    margin-left: auto;
    margin-right: auto;
    padding: clamp(18px, 3vw, 38px) !important;
}

.py-4 {
    padding-top: clamp(18px, 3vw, 38px) !important;
    padding-bottom: clamp(18px, 3vw, 38px) !important;
}

.d-flex {
    display: flex !important;
}

.justify-content-between {
    justify-content: space-between !important;
}

.align-items-center {
    align-items: center !important;
}

.gap-2 {
    gap: .75rem !important;
}

.mb-4 {
    margin-bottom: 1.5rem !important;
}

.mt-4 {
    margin-top: 1.5rem !important;
}

.p-3 {
    padding: 1rem !important;
}

.p-4 {
    padding: 1.35rem !important;
}

.header,
.page-header,
.form-header,
.container > .d-flex.justify-content-between:first-child,
.container-fluid > .d-flex.justify-content-between:first-child {
    padding: clamp(18px, 2.5vw, 28px);
    border-radius: 28px;
    border: 1px solid rgba(216, 227, 234, 0.9);
    background: linear-gradient(135deg, rgba(255,255,255,.94), rgba(231,245,247,.64));
    box-shadow: var(--nefro-shadow-sm);
    margin-bottom: 24px !important;
}

.header h1,
.page-header h1,
.form-header h1,
.container > .d-flex.justify-content-between:first-child h1,
.container-fluid > .d-flex.justify-content-between:first-child h1 {
    font-size: clamp(1.55rem, 3vw, 2.35rem) !important;
    font-weight: 950 !important;
    line-height: 1.05;
}

.header p,
.page-header p,
.form-header p {
    color: var(--nefro-muted) !important;
    font-weight: 600;
}

.btn,
.btn-premium,
.btn-primary,
.btn-secondary,
.btn-outline,
.btn-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 42px;
    padding: 10px 16px !important;
    border-radius: 14px !important;
    font-weight: 850 !important;
    text-decoration: none !important;
    cursor: pointer;
}

.btn-outline,
.btn-secondary,
.btn-premium.btn-secondary {
    background: rgba(255,255,255,.78) !important;
    border: 1px solid var(--nefro-border) !important;
    color: var(--nefro-text) !important;
}

.form-control,
.form-control-sm,
.w-25 {
    width: auto;
}

.table-container,
.card,
.glass-card {
    border-radius: 24px !important;
    overflow: hidden;
}

.row {
    display: grid !important;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 18px !important;
}

.row > .card {
    min-width: 0 !important;
}

@media (max-width: 900px) {
    .d-flex.justify-content-between,
    .header,
    .page-header,
    .form-header {
        flex-direction: column;
        align-items: flex-start !important;
    }

    .container > .d-flex.justify-content-between:first-child,
    .container-fluid > .d-flex.justify-content-between:first-child {
        flex-direction: column;
        align-items: flex-start !important;
    }

    .form-control,
    .form-control-sm,
    .w-25 {
        width: 100% !important;
    }
}

.hub-container {
    margin-top: 2.25rem !important;
}

.box {
    max-width: 420px !important;
    padding: 32px !important;
}

.logo,
.logo-text,
.header-title {
    color: var(--nefro-text) !important;
}

.danger,
.text-danger,
.btn-danger,
.btn-reject {
    color: #ffffff !important;
    background-color: var(--nefro-danger) !important;
    border-color: var(--nefro-danger) !important;
}

.success,
.text-success,
.btn-success,
.btn-approve {
    color: #ffffff !important;
    background-color: var(--nefro-success) !important;
    border-color: var(--nefro-success) !important;
}

@media (max-width: 900px) {
    body {
        font-size: 15px;
    }

    .main-container,
    .container,
    .hub-container {
        padding-left: 16px !important;
        padding-right: 16px !important;
    }

    .sidebar {
        position: static !important;
        width: 100% !important;
        height: auto !important;
    }

    .main-container {
        margin-left: 0 !important;
        width: 100% !important;
    }

    .welcome-hero,
    .header,
    .page-header,
    .controls,
    .action-bar {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 14px !important;
    }

    .grid-config,
    .info-grid,
    .detail-grid,
    .system-stats {
        grid-template-columns: 1fr !important;
        display: grid !important;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
    }
}


/* Shared page headers: prevent title/actions overlap across operational screens */
:where(.dashboard-container) {
    width: min(100%, var(--nefro-shell-width));
    margin-inline: auto;
    padding: clamp(18px, 2vw, 32px);
}

:where(.main-header) {
    display: flex !important;
    align-items: flex-start !important;
    justify-content: space-between !important;
    gap: 16px 18px !important;
    flex-wrap: wrap !important;
    min-width: 0;
    width: 100%;
    margin-bottom: 24px;
}

:where(.main-header > h1, .main-header > h2, .main-header > .title-block, .main-header > div:first-child) {
    flex: 1 1 320px;
    min-width: 0;
    margin: 0;
}

:where(.main-header h1, .main-header h2, .main-header p) {
    overflow-wrap: anywhere;
}

:where(.main-header .header-actions, .main-header .actions, .main-header .page-actions, .main-header .toolbar) {
    display: flex !important;
    flex-wrap: wrap !important;
    justify-content: flex-end !important;
    align-items: center !important;
    gap: 10px !important;
    flex: 1 1 360px;
    min-width: min(100%, 320px);
    max-width: 100%;
    margin-left: auto;
}

:where(.main-header .header-actions > *, .main-header .actions > *, .main-header .page-actions > *, .main-header .toolbar > *) {
    flex: 0 1 auto;
    min-width: 0;
    max-width: 100%;
}

:where(.main-header .header-actions .btn, .main-header .header-actions button, .main-header .header-actions a,
       .main-header .actions .btn, .main-header .actions button, .main-header .actions a) {
    white-space: normal;
    text-align: center;
}

@media (max-width: 920px) {
    :where(.main-header) {
        align-items: stretch !important;
    }

    :where(.main-header > h1, .main-header > h2, .main-header > .title-block, .main-header > div:first-child,
           .main-header .header-actions, .main-header .actions, .main-header .page-actions, .main-header .toolbar) {
        flex-basis: 100%;
    }

    :where(.main-header .header-actions, .main-header .actions, .main-header .page-actions, .main-header .toolbar) {
        justify-content: flex-start !important;
        margin-left: 0;
    }
}

@media (max-width: 640px) {
    :where(.main-header .header-actions > *, .main-header .actions > *, .main-header .page-actions > *, .main-header .toolbar > *) {
        width: 100%;
    }
}

/* Project-wide operational hardening */
:where(.main,
       .page,
       .dashboard-container,
       .shell,
       .rh-shell,
       .cfg-shell,
       .ai-shell,
       .lab-shell,
       .report-shell,
       .content-shell,
       .workspace-shell) {
    width: min(100%, var(--nefro-shell-width));
    max-width: 100%;
    min-width: 0;
    margin-inline: auto;
}

:where(.filter-bar,
       .toolbar,
       .filters,
       .controls,
       .page-actions,
       .header-actions,
       .report-header,
       .section-head,
       .actions-row,
       .top-actions) {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    min-width: 0;
}

:where(.filter-group,
       .toolbar .field,
       .filters .field,
       .controls .field) {
    flex: 1 1 180px;
    min-width: min(100%, 180px);
}

:where(.stats-grid,
       .dashboard-grid,
       .report-grid,
       .cards-grid,
       .grid-bloqueios,
       .intelligence-alerts,
       .module-kpi-grid,
       .module-grid-3,
       .module-grid-main,
       .module-grid-2) {
    min-width: 0;
}

:where(.btn,
       .btn-premium,
       .btn-primary,
       .btn-secondary,
       .btn-outline,
       .btn-action,
       .btn-save,
       .btn-add,
       .btn-new,
       .btn-back,
       .chip,
       .badge,
       button,
       a.btn) {
    max-width: 100%;
    white-space: normal;
    overflow-wrap: anywhere;
    text-wrap: pretty;
}

:where(.sidebar + .main,
       aside.sidebar + .main) {
    width: min(calc(100vw - 260px), var(--nefro-shell-width));
    max-width: calc(100vw - 260px);
    margin-right: auto;
    padding-inline: clamp(18px, 2vw, 32px);
    box-sizing: border-box;
}

:where(.nefro-auto-table-wrap) {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    width: 100%;
    max-width: 100%;
    border-radius: inherit;
}

:where(.nefro-auto-table-wrap) > table {
    min-width: min(100%, 960px);
}

:where(.nefro-fluid-shell) {
    width: min(100%, calc(100vw - 32px)) !important;
    max-width: min(var(--nefro-shell-width), calc(100vw - 32px)) !important;
    min-width: 0 !important;
    margin-inline: auto !important;
}

@media (max-width: 1180px) {
    :where(.stats-grid,
           .dashboard-grid,
           .report-grid,
           .cards-grid,
           .intelligence-alerts,
           .module-kpi-grid,
           .module-grid-3) {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    }
}

@media (max-width: 1080px) {
    :where(.sidebar,
           body > .sidebar,
           aside.sidebar) {
        position: static !important;
        width: 100% !important;
        max-width: 100% !important;
        height: auto !important;
    }

    :where(.sidebar + .main,
           aside.sidebar + .main) {
        width: 100% !important;
        max-width: 100% !important;
        margin-left: 0 !important;
        padding-inline: 16px !important;
    }
}

@media (max-width: 900px) {
    :where(.stats-grid,
           .dashboard-grid,
           .report-grid,
           .cards-grid,
           .grid-bloqueios,
           .intelligence-alerts,
           .module-kpi-grid,
           .module-grid-3,
           .module-grid-main,
           .module-grid-2) {
        grid-template-columns: 1fr !important;
    }

    :where(.report-header,
           .filter-bar,
           .toolbar,
           .filters,
           .controls,
           .actions-row,
           .top-actions) {
        align-items: stretch;
    }
}

/* Go-live visual refinement: clearer light UI across operational modules */
:root {
    --nefro-viz-surface: #ffffff;
    --nefro-viz-surface-soft: #f7fafc;
    --nefro-viz-line: rgba(15, 23, 42, 0.1);
    --nefro-viz-line-strong: rgba(15, 23, 42, 0.16);
    --nefro-viz-accent: #0d8aa0;
    --nefro-viz-accent-soft: rgba(13, 138, 160, 0.12);
    --nefro-viz-shadow: 0 12px 28px rgba(15, 23, 42, 0.08);
}

body {
    background:
        radial-gradient(circle at 8% 2%, rgba(13, 138, 160, 0.08), transparent 22rem),
        radial-gradient(circle at 92% 0%, rgba(34, 197, 94, 0.08), transparent 18rem),
        var(--nefro-viz-surface-soft) !important;
}

:where(.header, .page-header, .form-header, .main-header) {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(255, 255, 255, 0.88));
    border: 1px solid var(--nefro-viz-line);
    border-radius: 18px;
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.05);
}

:where(.card, .section-card, .metric-card, .kpi-card, .table-container, .portal-card, .portal-panel, .box, .panel, .widget) {
    background: var(--nefro-viz-surface) !important;
    border: 1px solid var(--nefro-viz-line) !important;
    box-shadow: var(--nefro-viz-shadow) !important;
}

:where(.card:hover, .portal-card:hover, .kpi-card:hover) {
    transform: translateY(-1px);
    box-shadow: 0 16px 34px rgba(15, 23, 42, 0.11) !important;
}

:where(.form-control, .form-control-sm, input:not([type="checkbox"]):not([type="radio"]), select, textarea) {
    background: #fff !important;
    border: 1px solid var(--nefro-viz-line-strong) !important;
    border-radius: 12px !important;
    min-height: 42px;
}

:where(.form-control:focus, .form-control-sm:focus, input:focus, select:focus, textarea:focus) {
    border-color: var(--nefro-viz-accent) !important;
    box-shadow: 0 0 0 4px var(--nefro-viz-accent-soft) !important;
    outline: none !important;
}

:where([data-auto="true"], .field-auto, .is-auto, .auto-field) {
    background: linear-gradient(180deg, #f0fdfa, #ecfeff) !important;
    border-color: rgba(13, 138, 160, 0.3) !important;
}

:where(.btn, .btn-action, .btn-primary, .btn-secondary, .btn-outline, .btn-save, .btn-add, .btn-new) {
    border-radius: 12px !important;
    font-weight: 800 !important;
    letter-spacing: 0.01em;
}

:where(.btn-primary, button[type="submit"]:not(.btn-close), .btn-save, .btn-add, .btn-new) {
    background: linear-gradient(135deg, #0d8aa0, #116fb1) !important;
    border-color: transparent !important;
}

:where(.btn-outline, .btn-secondary) {
    background: #fff !important;
    border-color: var(--nefro-viz-line-strong) !important;
    color: #0f172a !important;
}

:where(table thead th, .table thead th) {
    background: #f1f5f9 !important;
    color: #334155 !important;
    border-bottom: 1px solid var(--nefro-viz-line-strong) !important;
}

:where(table tbody tr:hover, .table tbody tr:hover) {
    background: #f8fafc !important;
}

