/* ══════ GLOBAL STYLES ══════ */
* { box-sizing: border-box; }
body { font-family: -apple-system, "Segoe UI", Roboto, sans-serif; margin: 0; background: #f4f6f8; color: #1f2937; }

/* ══════ HEADER ══════ */
header { background: #111827; color: #fff; padding: 12px 24px; display: flex; align-items: center; gap: 24px; flex-wrap: wrap; }
header h1 { font-size: 16px; margin: 0; white-space: nowrap; }
nav a { color: #d1d5db; text-decoration: none; margin-right: 18px; font-size: 14px; padding-bottom: 4px; }
nav a:hover, nav a.active { color: #fff; border-bottom: 2px solid #60a5fa; }
.user-info { margin-left: auto; display: flex; align-items: center; gap: 12px; font-size: 13px; flex-shrink: 0; }
.username { color: #9ca3af; }
.role-badge { padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: 600; }
.role-admin { background: #7c3aed; color: #fff; }
.role-operador { background: #2563eb; color: #fff; }
.role-viewer { background: #6b7280; color: #fff; }
.logout { color: #f87171; text-decoration: none; font-size: 13px; }

/* ══════ MAIN ══════ */
main { max-width: 1320px; margin: 24px auto; padding: 0 24px; }

/* ══════ SBGR STATUS ══════ */
.sbgr-status { display: flex; align-items: center; gap: 12px; padding: 12px 18px; border-radius: 8px; margin-bottom: 16px; font-size: 14px; }
.sbgr-status.status-green { background: #d1fae5; color: #065f46; }
.sbgr-status.status-yellow { background: #fef3c7; color: #92400e; }
.sbgr-status.status-red { background: #fee2e2; color: #991b1b; }
.status-icon { font-size: 18px; }
.status-text { font-weight: 600; }
.status-detail { margin-left: auto; font-size: 12px; opacity: 0.8; }

/* ══════ CARDS ══════ */
.card { background: #fff; border-radius: 8px; padding: 20px; box-shadow: 0 1px 3px rgba(0,0,0,.06); margin-bottom: 20px; }
.card h2 { margin-top: 0; font-size: 18px; margin-bottom: 16px; }

/* ══════ KPIs ══════ */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 16px; margin-bottom: 20px; }
.kpis-sm { margin-bottom: 0; }
.kpi { background: #fff; border-radius: 8px; padding: 16px; box-shadow: 0 1px 3px rgba(0,0,0,.06); }
.kpi .label { font-size: 12px; color: #6b7280; }
.kpi .value { font-size: 24px; font-weight: 700; color: #111827; margin-top: 4px; }
.kpi-up .value { color: #059669; }
.kpi-down .value { color: #dc2626; }
.kpis-sm .kpi { padding: 12px; }
.kpis-sm .kpi .value { font-size: 20px; }

/* ══════ WEEK CARD ══════ */
.week-card { border-left: 4px solid #f59e0b; }
.week-info { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.pax-badge { padding: 4px 12px; border-radius: 12px; font-size: 13px; font-weight: 600; }
.pax-muito-alto { background: #fee2e2; color: #991b1b; }
.pax-alto { background: #fef3c7; color: #92400e; }
.pax-normal { background: #e5e7eb; color: #374151; }
.pax-baixo { background: #dbeafe; color: #1e40af; }
.pax-muito-baixo { background: #e0e7ff; color: #3730a3; }
.focus-label { font-size: 13px; color: #6b7280; }

/* ══════ TOOLBAR ══════ */
.toolbar { display: flex; gap: 12px; align-items: end; flex-wrap: wrap; }
label { display: flex; flex-direction: column; font-size: 12px; color: #4b5563; gap: 4px; }
input, select, textarea { padding: 6px 10px; border: 1px solid #d1d5db; border-radius: 6px; font-size: 14px; background: #fff; }
textarea { font-family: "Cascadia Code", "Consolas", monospace; font-size: 12px; min-height: 200px; width: 100%; }
button { background: #2563eb; color: #fff; border: none; padding: 8px 16px; border-radius: 6px; font-weight: 600; cursor: pointer; font-size: 14px; transition: background .2s; }
button:hover { background: #1d4ed8; }
button.secondary { background: #6b7280; }
button.secondary:hover { background: #4b5563; }
button.danger { background: #dc2626; }
button.danger:hover { background: #b91c1c; }

/* ══════ TABLE ══════ */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 8px 10px; text-align: left; border-bottom: 1px solid #e5e7eb; }
th { background: #f9fafb; font-weight: 600; color: #374151; position: sticky; top: 0; z-index: 1; }
tr:hover { background: #f9fafb; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.delta-pos { color: #059669; font-weight: 600; }
.delta-neg { color: #dc2626; font-weight: 600; }
.delta-zero { color: #6b7280; }
.scroll-table { max-height: 600px; overflow-y: auto; border: 1px solid #e5e7eb; border-radius: 6px; }

/* ══════ BADGES ══════ */
.badge { display: inline-block; padding: 2px 8px; border-radius: 12px; font-size: 11px; font-weight: 600; }
.badge-baixo { background: #d1fae5; color: #065f46; }
.badge-medio { background: #fef3c7; color: #92400e; }
.badge-alto { background: #fee2e2; color: #991b1b; }
.badge-regulado { background: #e0e7ff; color: #3730a3; }
.badge-foco { background: #fef3c7; color: #92400e; }
.badge-ativo { background: #d1fae5; color: #065f46; }
.badge-inativo { background: #f3f4f6; color: #6b7280; }

/* ══════ TABLE CONTROLS ══════ */
.table-controls { display: flex; gap: 12px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.table-controls input { flex: 0 0 260px; }
.category-tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.cat-tab { padding: 4px 12px; border-radius: 14px; font-size: 12px; cursor: pointer; border: 1px solid #d1d5db; background: #fff; transition: all .2s; }
.cat-tab:hover, .cat-tab.active { background: #2563eb; color: #fff; border-color: #2563eb; }

/* ══════ MOTIVOS ══════ */
.motivos-gerais { margin-top: 14px; padding: 12px 16px; background: #f9fafb; border-radius: 6px; font-size: 12px; color: #4b5563; }
.motivos-gerais strong { color: #1f2937; }
.motivos-list { list-style: none; padding: 0; margin: 8px 0 0; }
.motivos-list li { padding: 3px 0; }
.motivos-list li::before { content: "• "; color: #2563eb; }

/* ══════ INFO CHIP ══════ */
.info-chip { cursor: pointer; background: #eff6ff; color: #2563eb; border: 1px solid #bfdbfe; border-radius: 50%; width: 22px; height: 22px; display: inline-flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; }
.info-chip:hover { background: #2563eb; color: #fff; }

/* ══════ MODAL ══════ */
.modal-overlay { display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,.4); z-index: 1000; align-items: center; justify-content: center; }
.modal-overlay.show { display: flex; }
.modal { background: #fff; border-radius: 12px; padding: 24px; max-width: 500px; width: 90%; max-height: 80vh; overflow-y: auto; }
.modal h3 { margin-top: 0; }
.modal-close { float: right; cursor: pointer; font-size: 18px; background: none; border: none; color: #6b7280; padding: 0; }

/* ══════ GRID LAYOUTS ══════ */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }

/* ══════ CONTEXT PAGE ══════ */
.ctx-card { background: #fff; border-radius: 8px; padding: 18px; box-shadow: 0 1px 3px rgba(0,0,0,.06); }
.ctx-card h3 { margin-top: 0; font-size: 15px; margin-bottom: 12px; }
.ctx-item { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px solid #f3f4f6; font-size: 13px; }
.ctx-item:last-child { border-bottom: none; }

/* ══════ CONFIG PAGE ══════ */
.config-section { margin-bottom: 24px; }
.config-section h3 { font-size: 15px; margin-bottom: 12px; padding-bottom: 6px; border-bottom: 2px solid #e5e7eb; }
.field-row { display: grid; grid-template-columns: 260px 120px; gap: 12px; align-items: center; margin-bottom: 8px; font-size: 13px; }
.field-row label { flex-direction: row; font-size: 13px; }

/* ══════ LOGIN PAGE ══════ */
.login-container { display: flex; align-items: center; justify-content: center; min-height: 80vh; }
.login-card { background: #fff; border-radius: 12px; padding: 40px; box-shadow: 0 4px 24px rgba(0,0,0,.1); width: 360px; text-align: center; }
.login-card h2 { margin-bottom: 24px; }
.login-card input { width: 100%; margin-bottom: 14px; padding: 10px; }
.login-card button { width: 100%; padding: 12px; font-size: 16px; }

/* ══════ CHARTS PLACEHOLDER ══════ */
.chart-placeholder { background: #f9fafb; border: 2px dashed #d1d5db; border-radius: 8px; padding: 40px; text-align: center; color: #9ca3af; font-size: 14px; margin: 12px 0; }

/* ══════ DETAILS ══════ */
details summary { cursor: pointer; font-weight: 600; padding: 8px 0; font-size: 14px; }
details[open] summary { margin-bottom: 8px; }

/* ══════ ALERTS ══════ */
.alert-ok { background: #d1fae5; color: #065f46; padding: 10px 14px; border-radius: 6px; margin-bottom: 16px; font-size: 13px; }
.alert-warn { background: #fef3c7; color: #92400e; padding: 10px 14px; border-radius: 6px; margin-bottom: 16px; font-size: 13px; }
.alert-err { background: #fee2e2; color: #991b1b; padding: 10px 14px; border-radius: 6px; margin-bottom: 16px; font-size: 13px; }

/* ══════ RESPONSIVE ══════ */
@media (max-width: 768px) {
  header { flex-direction: column; align-items: flex-start; }
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .table-controls { flex-direction: column; }
  .table-controls input { flex: 1 1 auto; width: 100%; }
}
