:root {
    --bg: #f1f2ea;
    --page: #f7f4df;
    --card: #fffdf2;
    --card-soft: #f9f6e8;
    --text: #111827;
    --muted: #6b7280;
    --border: #e8e1c8;
    --solar: #facc15;
    --solar-dark: #ca8a04;
    --green: #16a34a;
    --red: #dc2626;
    --orange: #d97706;
    --blue: #2563eb;
    --shadow: 0 18px 45px rgba(17, 24, 39, 0.08);
}

* {
    box-sizing: border-box;
}

body {
    font-family: Arial, sans-serif;
    background: linear-gradient(180deg, #e7e9ef 0%, var(--bg) 100%);
    margin: 0;
    padding: 0;
    color: var(--text);
}

.container {
    width: 100%;
    max-width: 1280px;
    margin: 32px auto;
    padding: 20px;
}

.card {
    background: rgba(255, 253, 242, 0.92);
    border: 1px solid var(--border);
    border-radius: 24px;
    padding: 26px;
    box-shadow: var(--shadow);
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-bottom: 22px;
    background: rgba(255, 253, 242, 0.9);
    border: 1px solid var(--border);
    border-radius: 22px;
    padding: 16px 20px;
    box-shadow: 0 10px 28px rgba(17, 24, 39, 0.06);
}

h1, h2, h3 {
    color: var(--text);
}

h1 {
    margin-top: 0;
    font-size: 30px;
    letter-spacing: -0.5px;
}

a {
    color: var(--text);
    font-weight: 700;
    text-decoration: none;
}

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

label {
    display: block;
    margin-top: 12px;
    margin-bottom: 6px;
    font-weight: 700;
}

input,
select {
    width: 100%;
    padding: 11px 13px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: #fffef8;
    color: var(--text);
}

button,
.btn-link-reset {
    display: inline-block;
    margin-top: 10px;
    padding: 10px 16px;
    border: none;
    border-radius: 14px;
    background: var(--solar);
    color: #111827;
    cursor: pointer;
    font-weight: 800;
    text-decoration: none;
    box-shadow: 0 8px 18px rgba(250, 204, 21, 0.25);
}

button:hover,
.btn-link-reset:hover {
    opacity: 0.92;
    text-decoration: none;
}

button.btn-success {
    background: var(--green);
    color: white;
}

button.btn-danger {
    background: var(--red);
    color: white;
}

button.btn-warning {
    background: var(--orange);
    color: white;
}

button.btn-secondary {
    background: #374151;
    color: white;
}

.alert,
.alert.success,
.alert-success {
    background: #dcfce7;
    color: #166534;
    border: 1px solid #bbf7d0;
    padding: 12px 14px;
    border-radius: 16px;
    margin-bottom: 14px;
    font-weight: 700;
}

.alert.error,
.alert-error {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fecaca;
    padding: 12px 14px;
    border-radius: 16px;
    margin-bottom: 14px;
    font-weight: 700;
}

.stats-grid,
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-top: 20px;
}

.stats-grid-3 {
    grid-template-columns: repeat(3, 1fr);
}

.metrics-grid-4 {
    grid-template-columns: repeat(4, 1fr);
}

.stat-box,
.metric-card {
    background: var(--card-soft);
    border: 1px solid var(--border);
    border-radius: 22px;
    padding: 18px;
    box-shadow: 0 10px 24px rgba(17, 24, 39, 0.04);
}

.stat-box h3,
.metric-card h3 {
    margin: 0 0 10px 0;
    font-size: 15px;
    color: var(--muted);
}

.stat-box p {
    margin: 0;
    font-size: 28px;
    font-weight: 900;
    color: var(--text);
}

.metric-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
}

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

.metric-label {
    color: var(--muted);
    font-weight: 700;
}

.metric-value {
    color: var(--text);
    font-weight: 900;
    text-align: right;
}

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0 10px;
    margin-top: 16px;
}

th {
    background: transparent;
    color: var(--muted);
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    padding: 10px 12px;
    text-align: left;
}

td {
    background: #fffef8;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    padding: 14px 12px;
    vertical-align: middle;
}

td:first-child {
    border-left: 1px solid var(--border);
    border-radius: 18px 0 0 18px;
}

td:last-child {
    border-right: 1px solid var(--border);
    border-radius: 0 18px 18px 0;
}

tr:hover td {
    background: #fff8cf;
}

.badge {
    display: inline-block;
    padding: 6px 12px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 900;
    letter-spacing: 0.3px;
}

.badge-online,
.badge-resolved {
    background: #dcfce7;
    color: #166534;
}

.badge-offline,
.badge-critical,
.badge-open {
    background: #fee2e2;
    color: #991b1b;
}

.badge-warning,
.badge-alert-warning {
    background: #fef3c7;
    color: #92400e;
}

.badge-info {
    background: #dbeafe;
    color: #1d4ed8;
}

.badge-unknown {
    background: #e5e7eb;
    color: #374151;
}

.section-title,
.search-row,
.actions-inline {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.section-title {
    justify-content: space-between;
    margin-bottom: 14px;
}

.search-row input[type="text"] {
    flex: 1;
    min-width: 260px;
}

.muted {
    color: var(--muted);
}

.online-flag {
    color: var(--green);
    font-weight: 900;
}

.offline-flag {
    color: var(--red);
    font-weight: 900;
}

.warning-flag {
    color: var(--orange);
    font-weight: 900;
}

.alerts-column,
.last-reading-cell {
    min-width: 260px;
    line-height: 1.55;
}

.main-alert-cell {
    min-width: 260px;
    max-width: 340px;
}

.main-alert-box {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.main-alert-title {
    font-size: 13px;
    line-height: 1.45;
    color: var(--text);
    font-weight: 800;
}

.context-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 220px;
}

.context-item {
    font-size: 13px;
    line-height: 1.4;
    background: var(--card-soft);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 8px 10px;
}

.context-item strong {
    display: inline-block;
    margin-right: 6px;
}

pre,
.compact-pre {
    background: var(--card-soft);
    padding: 14px;
    border-radius: 14px;
    overflow-x: auto;
    white-space: pre-wrap;
    word-wrap: break-word;
    border: 1px solid var(--border);
}

.compact-pre {
    margin: 0;
    font-size: 12px;
    line-height: 1.35;
    max-height: 180px;
    overflow: auto;
}

.col-code {
    width: 120px;
    max-width: 120px;
    white-space: nowrap;
    font-size: 12px;
}

.col-recommended-action {
    min-width: 340px;
    max-width: 520px;
    white-space: normal;
    line-height: 1.45;
}

@media (max-width: 1200px) {
    .stats-grid,
    .metrics-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .container {
        max-width: 100%;
        margin: 16px auto;
    }
}

@media (max-width: 700px) {
    .stats-grid,
    .metrics-grid {
        grid-template-columns: 1fr;
    }

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

    td,
    th {
        font-size: 13px;
    }
}
/* Força todos os blocos a respeitar o container */
.container {
    max-width: 1280px;
    margin: 32px auto;
}

/* Garante que os cards não crescem mais que o container */
.card {
    width: 100%;
    overflow: visible;
}

/* Resolve o problema da tabela a sair fora */
table {
    width: 100%;

    word-wrap: break-word;
}

/* Evita que colunas gigantes expandam tudo */
td, th {
    overflow: visible;
    text-overflow: ellipsis;
}

/* Permite scroll horizontal se necessário (melhor UX) */
.table-wrapper {
    width: 100%;
    overflow-x: auto;
}
.container {
    max-width: 1280px;
    margin: 32px auto;
}

.card {
    width: 100%;
    overflow: visible;
}

.table-wrapper {
    width: 100%;
    overflow-x: auto;
}

.table-wrapper table {
    width: 100%;
    min-width: 1120px;
    table-layout: fixed;
}

.table-wrapper th,
.table-wrapper td {
    overflow: visible;
    word-wrap: break-word;
}
/* Separadores verticais entre colunas */
.table-wrapper td:not(:last-child),
.table-wrapper th:not(:last-child) {
    border-right: 1px solid #e5e7eb;
}

/* Ajuste para manter estilo arredondado */
.table-wrapper td {
    background: #fffef8;
}
/* Linhas verticais para TODAS as tabelas */
table th:not(:last-child),
table td:not(:last-child) {
    border-right: 1px solid rgba(0, 0, 0, 0.06);
}
/* Header das tabelas (todas as páginas) */
table thead th {
    background: #f5efd2; /* tom creme/amarelo suave */
    color: #2f3238;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 14px 12px;
    border-bottom: 1px solid #e5e7eb;
}
.login-logo {
    text-align: center;
    margin-bottom: 20px;
}

.login-logo img {
    max-width: 160px;
    height: auto;
}
/* Context column: quebra texto sem invadir outras colunas */
.context-cell {
    max-width: 420px;
    width: 420px;
    overflow: hidden;
}

.context-list {
    width: 100%;
    max-width: 100%;
    overflow: hidden;
}

.context-item {
    max-width: 100%;
    white-space: normal;
    word-break: break-word;
    overflow-wrap: anywhere;
    overflow: hidden;
}

/* Se o contexto vier em pre/json */
.context-cell pre,
.context-cell .compact-pre {
    white-space: pre-wrap;
    word-break: break-word;
    overflow-wrap: anywhere;
    max-height: none;
    overflow: auto;
}

/* Mantém a coluna de data protegida */
td {
    white-space: normal;
    vertical-align: top;
}
/* NÃO cortar texto e deixar expandir */
.col-code {
    white-space: nowrap;
    word-break: normal;
    overflow-wrap: normal;
    max-width: none;
}
@media (max-width: 900px) {
    .table-wrapper {
        overflow-x: auto;
    }

    .table-wrapper table {
        width: max-content;
        min-width: 900px;
    }

    table th,
    table td {
        white-space: nowrap;
    }

    .context-cell,
    .last-reading-cell,
    .main-alert-cell,
    .col-recommended-action {
        white-space: normal;
        min-width: 260px;
    }
}

/* =========================================================
   SAFE FIX: Context column must not invade Detected At column
   Applies to Project Alert History and Inverter Alerts tables
   ========================================================= */
.context-cell {
    width: 320px !important;
    min-width: 260px !important;
    max-width: 320px !important;
    overflow: hidden !important;
    vertical-align: top !important;
}

.context-cell .context-list,
.context-list {
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    overflow: hidden !important;
}

.context-cell .context-item,
.context-item {
    display: block !important;
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    white-space: normal !important;
    word-break: break-word !important;
    overflow-wrap: anywhere !important;
    overflow: hidden !important;
}

.context-cell .context-item strong,
.context-item strong {
    white-space: nowrap;
}

.context-cell pre,
.context-cell .compact-pre {
    width: 100% !important;
    max-width: 100% !important;
    white-space: pre-wrap !important;
    word-break: break-word !important;
    overflow-wrap: anywhere !important;
    overflow-x: auto !important;
}

/* Prevent only context cells from overflowing into the next table column */
table td.context-cell {
    overflow: hidden !important;
}

/* Keep date/status columns readable and protected */
table th:nth-last-child(3),
table td:nth-last-child(3),
table th:nth-last-child(2),
table td:nth-last-child(2),
table th:last-child,
table td:last-child {
    white-space: normal;
}
img {
  border-radius: 20px; /* Ajuste o valor em px conforme necessário */
}
.project-dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 22px;
    align-items: start;
}

.project-details-form {
    max-width: 420px;
    margin-top: 14px;
}

.project-details-form input {
    margin-bottom: 8px;
}

.alert-notification-panel {
    background: var(--card-soft);
    border: 1px solid var(--border);
    border-radius: 22px;
    padding: 22px;
}

.alert-notification-panel h2 {
    margin-top: 0;
}

.alert-notification-panel form {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.alert-notification-panel input {
    width: 100%;
    max-width: 100%;
}

.alert-notification-panel button {
    width: fit-content;
}

.alert-notification-panel hr {
    margin: 18px 0;
    border: none;
    border-top: 1px solid var(--border);
}

.project-standby-box {
    margin-top: 18px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}

.project-standby-box h3 {
    margin-bottom: 10px;
}

/* Corrige o Reason dentro da coluna Alerts Standby */
.alert-standby-cell {
    min-width: 220px;
    max-width: 260px;
}

.alert-standby-cell form {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.alert-standby-cell input[type="text"] {
    width: 100%;
    max-width: 100%;
    min-width: 0;
}

.alert-standby-cell button {
    width: fit-content;
}

@media (max-width: 900px) {
    .project-dashboard-grid {
        grid-template-columns: 1fr;
    }
}
.project-dashboard-grid {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) minmax(360px, 0.9fr);
    gap: 24px;
    align-items: start;
}

.project-dashboard-left {
    min-width: 0;
}

.project-details-form {
    max-width: 520px;
}

.alert-notification-panel {
    align-self: start;
}

.alert-standby-cell {
    width: 240px;
    min-width: 220px;
    max-width: 260px;
}

.alert-standby-cell form {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.alert-standby-cell input[type="text"] {
    width: 100%;
    max-width: 100%;
    min-width: 0 !important;
}

.alert-standby-cell button {
    width: fit-content;
}

@media (max-width: 900px) {
    .project-dashboard-grid {
        grid-template-columns: 1fr;
    }
}
/* Fix only inverter alerts table code column */
.inverter-alerts-table th.col-code,
.inverter-alerts-table td.col-code {
    width: 180px !important;
    min-width: 180px !important;
    max-width: 180px !important;

    white-space: normal !important;
    word-break: break-word !important;
    overflow-wrap: anywhere !important;

    font-size: 12px;
    line-height: 1.35;
}
.alert-rule-box {
    display: flex !important;
    align-items: center !important;
    justify-content: flex-start !important;
    gap: 6px !important;

    margin: 0 !important;
    padding: 5px 8px !important;

    border: 1px solid #ddd;
    border-radius: 6px;
    background: #fff;

    font-size: 12px;
    font-weight: 500;
    line-height: 1.15;
}

.alert-rule-box input[type="checkbox"] {
    width: auto !important;
    min-width: 14px !important;
    margin: 0 !important;
    padding: 0 !important;
    transform: scale(0.85);
    flex: 0 0 auto;
}

.alert-rule-box span {
    display: block;
    margin: 0;
    text-align: left;
}
.alert-email-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
    margin-top: 18px;
}

.alert-email-card {
    background: var(--card-soft);
    border: 1px solid var(--border);
    border-radius: 22px;
    padding: 18px;
    box-shadow: none;
}

.alert-email-card form {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.alert-email-card button {
    width: fit-content;
}

@media (max-width: 900px) {
    .alert-email-grid {
        grid-template-columns: 1fr;
    }
}