/* ============================================================ */
/*  AquaGestor — design system v3 (GitHub Primer-inspired)        */
/*  Paleta neutra sofisticada, dark mode nativo, system fonts.    */
/* ============================================================ */

/* ===== TOKENS — light theme (default) ===== */
:root {
  /* Canvas (backgrounds) */
  --bg-canvas:        #ffffff;
  --bg-default:       #f6f8fa;
  --bg-subtle:        #eaeef2;
  --bg-emphasis:      #25292e;
  --bg-overlay:       #ffffff;

  /* Foreground (text) */
  --fg-default:       #1f2328;
  --fg-muted:         #59636e;
  --fg-subtle:        #818b98;
  --fg-on-emphasis:   #ffffff;

  /* Borders */
  --border-default:   #d0d7de;
  --border-muted:     #d8dee4;
  --border-subtle:    rgba(31, 35, 40, 0.08);

  /* Accent (link/primary) */
  --accent-fg:        #0969da;
  --accent-emphasis:  #0969da;
  --accent-subtle:    #ddf4ff;
  --accent-muted:     rgba(9, 105, 218, 0.4);

  /* Success (green) */
  --success-fg:       #1a7f37;
  --success-emphasis: #1f883d;
  --success-subtle:   #dafbe1;
  --success-muted:    rgba(31, 136, 61, 0.4);

  /* Attention (yellow) */
  --attention-fg:     #9a6700;
  --attention-emphasis:#bf8700;
  --attention-subtle: #fff8c5;
  --attention-muted:  rgba(212, 167, 44, 0.4);

  /* Danger (red) */
  --danger-fg:        #cf222e;
  --danger-emphasis:  #cf222e;
  --danger-subtle:    #ffebe9;
  --danger-muted:     rgba(207, 34, 46, 0.4);

  /* Done (purple) */
  --done-fg:          #8250df;
  --done-subtle:      #fbefff;

  /* Charts (grid/ticks/labels) */
  --chart-grid:       #d8dee4;
  --chart-tick:       #59636e;
  --chart-axis:       #818b98;

  /* Shadows */
  --shadow-resting:   0 1px 0 rgba(31, 35, 40, 0.04);
  --shadow-medium:    0 3px 6px rgba(140, 149, 159, 0.15);
  --shadow-large:     0 8px 24px rgba(140, 149, 159, 0.2);

  /* Forma */
  --radius:           6px;
  --radius-sm:        4px;
  --radius-lg:        12px;

  /* Tipografia — system stack (GitHub-style) */
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans",
               Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
               "Liberation Mono", monospace;
}

/* ===== TOKENS — dark theme ===== */
[data-theme="dark"] {
  --bg-canvas:        #0d1117;
  --bg-default:       #161b22;
  --bg-subtle:        #21262d;
  --bg-emphasis:      #6e7681;
  --bg-overlay:       #161b22;

  --fg-default:       #e6edf3;
  --fg-muted:         #9198a1;
  --fg-subtle:        #6e7681;
  --fg-on-emphasis:   #ffffff;

  --border-default:   #30363d;
  --border-muted:     #21262d;
  --border-subtle:    rgba(110, 118, 129, 0.4);

  --accent-fg:        #2f81f7;
  --accent-emphasis:  #1f6feb;
  --accent-subtle:    rgba(56, 139, 253, 0.15);
  --accent-muted:     rgba(56, 139, 253, 0.4);

  --success-fg:       #3fb950;
  --success-emphasis: #238636;
  --success-subtle:   rgba(46, 160, 67, 0.15);
  --success-muted:    rgba(46, 160, 67, 0.4);

  --attention-fg:     #d29922;
  --attention-emphasis:#9e6a03;
  --attention-subtle: rgba(187, 128, 9, 0.15);
  --attention-muted:  rgba(187, 128, 9, 0.4);

  --danger-fg:        #f85149;
  --danger-emphasis:  #da3633;
  --danger-subtle:    rgba(248, 81, 73, 0.15);
  --danger-muted:     rgba(248, 81, 73, 0.4);

  --done-fg:          #a371f7;
  --done-subtle:      rgba(163, 113, 247, 0.15);

  --chart-grid:       #21262d;
  --chart-tick:       #8b949e;
  --chart-axis:       #6e7681;

  --shadow-resting:   0 0 transparent;
  --shadow-medium:    0 3px 6px rgba(1, 4, 9, 0.85);
  --shadow-large:     0 8px 24px rgba(1, 4, 9, 0.5);
}

/* ===== reset ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  color: var(--fg-default);
  background: var(--bg-canvas);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background 0.15s, color 0.15s;
}
a { color: var(--accent-fg); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, select, textarea { font: inherit; color: inherit; }
ul, ol { list-style: none; }
table { border-collapse: collapse; width: 100%; }
img, svg { display: block; max-width: 100%; }

/* Scrollbar discreta com tema */
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: var(--border-default);
  border-radius: 6px;
  border: 2px solid var(--bg-canvas);
}
*::-webkit-scrollbar-thumb:hover { background: var(--fg-subtle); }

/* ============================================================ */
/*  SHELL                                                         */
/* ============================================================ */
.app-shell {
  display: grid;
  grid-template-columns: 232px 1fr;
  min-height: 100vh;
}

/* ---------- Sidebar ---------- */
.sidebar {
  background: var(--bg-canvas);
  border-right: 1px solid var(--border-default);
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px 20px;
  border-bottom: 1px solid var(--border-muted);
  margin-bottom: 12px;
}
.brand-mark {
  width: 44px;
  height: 26px;
  border-radius: 5px;
  overflow: visible;
  background: transparent;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.brand-mark img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
.brand-text { line-height: 1.2; }
.brand-name {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--fg-default);
}
.brand-tag {
  font-size: 11px;
  color: var(--fg-muted);
  margin-top: 1px;
}

/* Sections */
.menu-section { margin-bottom: 12px; }
.menu-section-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--fg-muted);
  padding: 4px 10px 6px;
}
.menu { display: flex; flex-direction: column; gap: 1px; }
.menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 13.5px;
  font-weight: 400;
  color: var(--fg-default);
  text-decoration: none;
  transition: background 0.12s, color 0.12s;
  position: relative;
}
.menu-item:hover {
  background: var(--bg-default);
  text-decoration: none;
}
.menu-item.is-active {
  background: var(--bg-default);
  font-weight: 600;
}
.menu-item.is-active::before {
  content: '';
  position: absolute;
  left: -12px; top: 6px; bottom: 6px;
  width: 2px;
  background: var(--accent-emphasis);
  border-radius: 0 4px 4px 0;
}
.menu-icon {
  width: 18px; height: 18px;
  display: grid; place-items: center;
  font-size: 14px;
  color: var(--fg-muted);
}
.menu-item.is-active .menu-icon { color: var(--accent-fg); }

/* Footer da sidebar */
.sidebar-footer {
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--border-muted);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* Theme toggle */
.theme-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: 6px;
  font-size: 13px;
  color: var(--fg-default);
  background: transparent;
  cursor: pointer;
  text-align: left;
  width: 100%;
  transition: background 0.12s;
}
.theme-toggle:hover { background: var(--bg-default); }
.theme-toggle-icon {
  width: 18px; height: 18px;
  display: grid; place-items: center;
  color: var(--fg-muted);
}
[data-theme="dark"] .theme-toggle-icon-light  { display: none; }
[data-theme="light"] .theme-toggle-icon-dark,
:root:not([data-theme="dark"]) .theme-toggle-icon-dark { display: none; }
[data-theme="dark"] .theme-toggle-icon-dark    { display: grid; }

.user-chip {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px;
  border-radius: 6px;
  cursor: default;
}
.user-chip:hover { background: var(--bg-default); }
.user-avatar {
  width: 26px; height: 26px;
  background: var(--accent-emphasis);
  color: #fff;
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: 11.5px;
  font-weight: 600;
  flex-shrink: 0;
}
.user-meta { flex: 1; line-height: 1.2; min-width: 0; }
.user-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--fg-default);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.user-logout {
  font-size: 11px;
  color: var(--fg-muted);
  display: block;
  margin-top: 1px;
  text-decoration: none;
}
.user-logout:hover { color: var(--accent-fg); text-decoration: underline; }

/* ---------- Main ---------- */
.main {
  background: var(--bg-canvas);
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* ============================================================ */
/*  Topbar                                                        */
/* ============================================================ */
.topbar {
  padding: 24px 28px 18px;
  border-bottom: 1px solid var(--border-default);
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 24px;
  background: var(--bg-canvas);
}
.topbar-back { display: flex; align-items: center; gap: 14px; }
.btn-back {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 500;
  color: var(--fg-muted);
  border: 1px solid var(--border-default);
  border-radius: 6px;
  background: var(--bg-canvas);
  text-decoration: none;
  transition: all 0.12s;
}
.btn-back:hover {
  color: var(--fg-default);
  border-color: var(--fg-muted);
  background: var(--bg-default);
  text-decoration: none;
}
.btn-back svg { opacity: 0.7; }

.page-title {
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.011em;
  line-height: 1.2;
  color: var(--fg-default);
}
.page-sub {
  font-size: 13px;
  color: var(--fg-muted);
  margin-top: 4px;
}

.topbar-actions { display: flex; gap: 8px; align-items: center; }

.select {
  background: var(--bg-canvas);
  border: 1px solid var(--border-default);
  border-radius: 6px;
  padding: 5px 24px 5px 10px;
  font-size: 12.5px;
  color: var(--fg-default);
  cursor: pointer;
  min-width: 200px;
  transition: border 0.12s;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 16 16'><path fill='%2359636e' d='M4.427 7.427l3.396 3.396a.25.25 0 0 0 .354 0l3.396-3.396A.25.25 0 0 0 11.396 7H4.604a.25.25 0 0 0-.177.427z'/></svg>");
  background-repeat: no-repeat;
  background-position: right 8px center;
}
.select:hover { border-color: var(--fg-muted); }
.select:focus {
  outline: none;
  border-color: var(--accent-emphasis);
  box-shadow: 0 0 0 3px var(--accent-subtle);
}

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 12px;
  font-size: 12.5px;
  font-weight: 500;
  border-radius: 6px;
  border: 1px solid var(--border-default);
  background: var(--bg-canvas);
  color: var(--fg-default);
  text-decoration: none;
  transition: all 0.12s;
  box-shadow: var(--shadow-resting);
}
.btn:hover {
  background: var(--bg-default);
  border-color: var(--fg-muted);
  text-decoration: none;
}
.btn-primary {
  background: var(--success-emphasis);
  color: #fff;
  border-color: rgba(27, 31, 36, 0.15);
}
.btn-primary:hover { background: #1a7f37; color: #fff; }

/* Quick links no topbar */
.quick-links { display: flex; gap: 6px; }
.quick-link {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 11px;
  border: 1px solid var(--border-default);
  border-radius: 6px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--fg-default);
  background: var(--bg-canvas);
  text-decoration: none;
  transition: all 0.12s;
  box-shadow: var(--shadow-resting);
}
.quick-link:hover {
  background: var(--bg-default);
  border-color: var(--fg-muted);
  text-decoration: none;
}
.quick-link svg { width: 14px; height: 14px; opacity: 0.7; }

.content {
  padding: 20px 28px 56px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ============================================================ */
/*  Section heads                                                 */
/* ============================================================ */
.section-head {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-bottom: 2px;
  margin-top: 6px;
}
.section-head:first-child { margin-top: 0; }
.section-head h2 {
  font-size: 14px;
  font-weight: 600;
  color: var(--fg-default);
  letter-spacing: -0.005em;
}
.section-head .section-action {
  font-size: 12.5px;
  color: var(--fg-muted);
}
.section-head .section-action a { color: var(--accent-fg); }

/* ============================================================ */
/*  KPI                                                           */
/* ============================================================ */
.kpi-grid { display: grid; gap: 12px; }
.kpi-grid-4 { grid-template-columns: repeat(4, 1fr); }
.kpi-grid-3 { grid-template-columns: repeat(3, 1fr); }
.kpi-grid-2 { grid-template-columns: repeat(2, 1fr); }

.kpi {
  background: var(--bg-canvas);
  border: 1px solid var(--border-default);
  border-radius: var(--radius);
  padding: 14px 16px;
  position: relative;
  box-shadow: var(--shadow-resting);
  transition: border-color 0.15s;
}
.kpi:hover { border-color: var(--fg-muted); }

.kpi-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 6px;
}
.kpi-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--fg-muted);
}
.kpi-icon {
  width: 24px; height: 24px;
  border-radius: 6px;
  background: var(--bg-default);
  color: var(--fg-muted);
  display: grid; place-items: center;
  font-size: 13px;
}
.kpi-value {
  font-family: var(--font-sans);
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.022em;
  line-height: 1.15;
  color: var(--fg-default);
  font-variant-numeric: tabular-nums;
}
.kpi-unit {
  font-size: 13px;
  font-weight: 500;
  color: var(--fg-muted);
  margin-left: 3px;
}
.kpi-foot {
  font-size: 12px;
  color: var(--fg-muted);
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border-muted);
  display: flex; align-items: center; gap: 6px;
  flex-wrap: wrap;
}
.kpi-delta {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 10px;
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  background: var(--bg-default);
  color: var(--fg-default);
  border: 1px solid var(--border-muted);
}
.kpi-delta-up    { background: var(--success-subtle); color: var(--success-fg); border-color: transparent; }
.kpi-delta-down  { background: var(--danger-subtle);  color: var(--danger-fg);  border-color: transparent; }

/* Variantes de KPI */
.kpi-success .kpi-value { color: var(--success-fg); }
.kpi-success .kpi-icon  { background: var(--success-subtle); color: var(--success-fg); }
.kpi-info    .kpi-value { color: var(--accent-fg); }
.kpi-info    .kpi-icon  { background: var(--accent-subtle); color: var(--accent-fg); }
.kpi-warn    .kpi-value { color: var(--attention-fg); }
.kpi-warn    .kpi-icon  { background: var(--attention-subtle); color: var(--attention-fg); }
.kpi-danger  .kpi-value { color: var(--danger-fg); }
.kpi-danger  .kpi-icon  { background: var(--danger-subtle); color: var(--danger-fg); }

/* ============================================================ */
/*  Cards                                                         */
/* ============================================================ */
.card {
  background: var(--bg-canvas);
  border: 1px solid var(--border-default);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-resting);
}
.card-head {
  padding: 14px 18px 12px;
  border-bottom: 1px solid var(--border-default);
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 16px;
  background: var(--bg-canvas);
}
.card-head h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--fg-default);
}
.card-head p {
  font-size: 12.5px;
  color: var(--fg-muted);
  margin-top: 2px;
}
.card-head .card-tools {
  display: flex; gap: 6px;
  flex-shrink: 0;
}
.card-body { padding: 18px; }
.card-body--tight { padding: 0; }
.card-body--chart { padding: 12px 16px; }

/* Linha 2 colunas */
.row-2 {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 12px;
}
.row-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

/* ============================================================ */
/*  Chart wraps (alturas padronizadas)                            */
/* ============================================================ */
.chart-wrap { position: relative; width: 100%; }
.chart-wrap canvas { max-width: 100%; }
.chart-wrap-sm { height: 180px; }
.chart-wrap-md { height: 220px; }
.chart-wrap-lg { height: 320px; }

/* ============================================================ */
/*  Pie/donut com legenda                                         */
/* ============================================================ */
.card-pie {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 18px;
}
.pie-canvas-wrap {
  position: relative;
  display: grid; place-items: center;
  width: 180px;
  flex-shrink: 0;
}
.pie-legend {
  display: flex; flex-direction: column; gap: 6px;
}
.pie-legend-item {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 11px;
  border: 1px solid var(--border-muted);
  border-radius: 6px;
  font-size: 13px;
  background: var(--bg-canvas);
}
.pie-legend-item .dot { flex-shrink: 0; }
.pie-legend-item .pie-label { flex: 1; color: var(--fg-default); }
.pie-legend-item .pie-val {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--fg-default);
  font-variant-numeric: tabular-nums;
}
.dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  display: inline-block;
}
.dot-success { background: var(--success-emphasis); }
.dot-info    { background: var(--accent-emphasis); }
.dot-warn    { background: var(--attention-emphasis); }
.dot-danger  { background: var(--danger-emphasis); }

/* ============================================================ */
/*  Tabelas                                                       */
/* ============================================================ */
.table-wrap { overflow-x: auto; }
.table-scroll { max-height: 600px; overflow: auto; }
.table { width: 100%; font-size: 13px; }
.table thead th {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--fg-muted);
  text-align: left;
  padding: 9px 14px;
  background: var(--bg-default);
  position: sticky; top: 0;
  border-bottom: 1px solid var(--border-default);
  white-space: nowrap;
}
.table thead th small {
  display: block;
  margin-top: 1px;
  font-size: 10.5px;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  color: var(--fg-subtle);
}
.table tbody td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-muted);
  vertical-align: middle;
  color: var(--fg-default);
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: var(--bg-default); }
.table tbody td.is-num,
.table thead th.is-num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.table .row-strong { color: var(--fg-default); font-weight: 600; }
.table .row-muted  { color: var(--fg-muted); }
.table-foot {
  padding: 10px 14px;
  font-size: 12px;
  color: var(--fg-muted);
  background: var(--bg-default);
  border-top: 1px solid var(--border-default);
  text-align: center;
}

/* ============================================================ */
/*  Tags / badges (estilo Primer)                                 */
/* ============================================================ */
.tag {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  background: var(--bg-default);
  color: var(--fg-muted);
  border: 1px solid var(--border-default);
  white-space: nowrap;
  line-height: 18px;
}
.tag-success { background: var(--success-subtle); color: var(--success-fg); border-color: transparent; }
.tag-info    { background: var(--accent-subtle);  color: var(--accent-fg);  border-color: transparent; }
.tag-warn    { background: var(--attention-subtle); color: var(--attention-fg); border-color: transparent; }
.tag-danger  { background: var(--danger-subtle);  color: var(--danger-fg);  border-color: transparent; }
.tag-ghost   { background: transparent; }

.status-icon {
  display: inline-grid; place-items: center;
  width: 18px; height: 18px;
  border-radius: 50%;
  font-size: 11px;
}
.status-icon-success { background: var(--success-subtle); color: var(--success-fg); }
.status-icon-warn    { background: var(--attention-subtle); color: var(--attention-fg); }
.status-icon-danger  { background: var(--danger-subtle); color: var(--danger-fg); }

/* Cor inline em texto */
.t-success { color: var(--success-fg); font-weight: 500; }
.t-info    { color: var(--accent-fg);  font-weight: 500; }
.t-warn    { color: var(--attention-fg); font-weight: 500; }
.t-danger  { color: var(--danger-fg);  font-weight: 500; }
.muted     { color: var(--fg-muted); }

/* ============================================================ */
/*  Alert items                                                   */
/* ============================================================ */
.alert-list { display: flex; flex-direction: column; gap: 6px; padding: 12px 18px; }
.alert-item {
  display: grid;
  grid-template-columns: auto 1fr auto auto auto;
  gap: 14px;
  align-items: center;
  padding: 10px 14px;
  border: 1px solid var(--border-default);
  border-radius: 6px;
  background: var(--bg-canvas);
  transition: border-color 0.12s, background 0.12s;
}
.alert-item:hover { border-color: var(--fg-muted); background: var(--bg-default); }
.alert-item--danger { border-left: 3px solid var(--danger-emphasis); }
.alert-item--warn   { border-left: 3px solid var(--attention-emphasis); }

.alert-tank-info { line-height: 1.3; min-width: 160px; }
.alert-tank-info strong {
  display: block;
  font-size: 13.5px;
  color: var(--fg-default);
  font-weight: 600;
}
.alert-tank-info span { font-size: 12px; color: var(--fg-muted); }

.alert-metric {
  display: flex; flex-direction: column;
  font-size: 11px;
  color: var(--fg-muted);
  font-weight: 500;
  text-align: right;
}
.alert-metric strong {
  font-family: var(--font-mono);
  font-size: 13.5px;
  font-weight: 600;
  color: var(--fg-default);
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
}
.alert-metric.alert-metric--danger strong { color: var(--danger-fg); }
.alert-metric.alert-metric--warn strong   { color: var(--attention-fg); }

/* ============================================================ */
/*  Insights                                                      */
/* ============================================================ */
.insights { display: flex; flex-direction: column; padding: 0; }
.insight {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-muted);
}
.insight:last-child { border-bottom: none; }
.insight-icon {
  width: 30px; height: 30px;
  display: grid; place-items: center;
  border-radius: 6px;
  background: var(--bg-default);
  font-size: 15px;
  flex-shrink: 0;
}
.insight-success .insight-icon { background: var(--success-subtle); }
.insight-warn    .insight-icon { background: var(--attention-subtle); }
.insight-info    .insight-icon { background: var(--accent-subtle); }
.insight-body strong {
  display: block;
  font-size: 13.5px;
  color: var(--fg-default);
  font-weight: 600;
  margin-bottom: 1px;
}
.insight-body p { font-size: 13px; color: var(--fg-muted); line-height: 1.5; }

/* ============================================================ */
/*  Map                                                           */
/* ============================================================ */
.map-canvas {
  height: 460px;
  width: 100%;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-default);
  overflow: hidden;
  background: var(--bg-default);
}
.map-legend {
  display: flex; gap: 18px; flex-wrap: wrap;
  padding: 10px 16px;
  border-top: 1px solid var(--border-muted);
  background: var(--bg-default);
  font-size: 12.5px;
  color: var(--fg-default);
}
.map-legend span { display: flex; align-items: center; gap: 6px; }

/* ============================================================ */
/*  Banner status DB                                              */
/* ============================================================ */
.db-banner {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 28px;
  font-size: 13px;
  border-bottom: 1px solid;
}
.db-banner code {
  background: var(--bg-default);
  padding: 1px 5px;
  border-radius: 3px;
  font-family: var(--font-mono);
  font-size: 11.5px;
}
.db-banner a { font-weight: 600; }
.db-banner-warn { background: var(--attention-subtle); border-color: var(--attention-muted); color: var(--attention-fg); }
.db-banner-info { background: var(--accent-subtle);   border-color: var(--accent-muted);    color: var(--accent-fg); }

/* ============================================================ */
/*  Diagnóstico                                                   */
/* ============================================================ */
.diag-status {
  display: flex; gap: 12px;
  padding: 14px 16px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  background: var(--bg-canvas);
}
.diag-icon { font-size: 20px; line-height: 1; }
.diag-status pre.diag-err {
  background: var(--bg-default);
  padding: 8px 12px;
  border-radius: 5px;
  margin-top: 6px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--fg-default);
  border: 1px solid var(--border-muted);
}
.diag-hint { margin-top: 8px; font-size: 12.5px; color: var(--fg-default); }
.diag-ok    { background: var(--success-subtle); border-color: var(--success-muted); color: var(--success-fg); }
.diag-info  { background: var(--accent-subtle);  border-color: var(--accent-muted);  color: var(--accent-fg); }
.diag-error { background: var(--danger-subtle);  border-color: var(--danger-muted);  color: var(--danger-fg); }

.diag-h4 {
  font-size: 12.5px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--fg-muted);
  margin-top: 14px; margin-bottom: 6px;
}
.diag-config { width: 100%; border-collapse: collapse; font-size: 13px; }
.diag-config th {
  text-align: left; font-weight: 500;
  color: var(--fg-muted);
  padding: 7px 12px 7px 0;
  width: 130px;
  border-bottom: 1px solid var(--border-muted);
}
.diag-config td {
  padding: 7px 0;
  border-bottom: 1px solid var(--border-muted);
}
.diag-config code {
  background: var(--bg-default);
  padding: 2px 6px;
  border-radius: 3px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--fg-default);
  border: 1px solid var(--border-muted);
}
.diag-steps { padding-left: 18px; line-height: 1.7; }
.diag-steps li { margin-bottom: 10px; }
.diag-code {
  background: #161b22;
  color: #f0f6fc;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 12px;
  margin-top: 6px;
  overflow-x: auto;
  line-height: 1.5;
  border: 1px solid #30363d;
}

/* ============================================================ */
/*  Flash                                                         */
/* ============================================================ */
.flash {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 12px;
  border: 1px solid;
}
.flash-error { background: var(--danger-subtle); border-color: var(--danger-muted); color: var(--danger-fg); }

/* ============================================================ */
/*  LOGIN                                                         */
/* ============================================================ */
.login-body { background: var(--bg-canvas); min-height: 100vh; }
.login-shell {
  display: grid;
  grid-template-columns: 1fr 1fr;
  min-height: 100vh;
}
.login-aside {
  background: #0d1117;          /* sempre dark, independente do tema */
  color: #f0f6fc;
  padding: 48px 52px;
  position: relative;
  display: flex; flex-direction: column; justify-content: space-between;
  overflow: hidden;
}
.login-aside::before {
  content: '';
  position: absolute; inset: 0;
  background:
    radial-gradient(circle at 25% 80%, rgba(56, 139, 253, 0.10), transparent 40%),
    radial-gradient(circle at 80% 20%, rgba(99, 110, 123, 0.12), transparent 50%);
  pointer-events: none;
}
.login-aside .brand { padding: 0; border-bottom: none; margin-bottom: 0; }
.brand-mark-lg {
  width: 60px !important;
  height: 35px !important;
  border-radius: 6px !important;
}
.login-aside .brand-name { color: #f0f6fc; font-size: 16px; }
.login-aside .brand-tag { color: #8b949e; font-size: 12px; }

.login-headline { position: relative; z-index: 1; max-width: 460px; }
.login-headline h1 {
  font-size: 32px;
  font-weight: 600;
  letter-spacing: -0.022em;
  line-height: 1.2;
  color: #f0f6fc;
}
.login-headline p {
  margin-top: 10px;
  font-size: 14px;
  color: #8b949e;
  line-height: 1.6;
}
.login-bullets { display: flex; gap: 28px; position: relative; z-index: 1; }
.login-bullets li {
  font-size: 11px;
  color: #6e7681;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 500;
}
.login-bullets li span {
  display: block;
  font-size: 22px;
  font-weight: 600;
  color: #f0f6fc;
  margin-bottom: 2px;
  text-transform: none;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
}

.login-main {
  display: grid; place-items: center;
  padding: 40px;
  background: var(--bg-canvas);
}
.login-form-wrap { width: 100%; max-width: 340px; }
.login-title {
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.018em;
  color: var(--fg-default);
}
.login-sub {
  font-size: 13px; color: var(--fg-muted);
  margin-top: 4px; margin-bottom: 24px;
}
.login-form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field span {
  font-size: 12px;
  font-weight: 500;
  color: var(--fg-default);
}
.field input {
  background: var(--bg-canvas);
  border: 1px solid var(--border-default);
  border-radius: 6px;
  padding: 7px 11px;
  font-size: 14px;
  color: var(--fg-default);
  outline: none;
  transition: all 0.12s;
}
.field input:hover { border-color: var(--fg-muted); }
.field input:focus {
  border-color: var(--accent-emphasis);
  box-shadow: 0 0 0 3px var(--accent-subtle);
}
.btn-submit {
  margin-top: 6px;
  background: var(--success-emphasis);
  color: #fff;
  padding: 7px 16px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  display: inline-flex; justify-content: center; align-items: center; gap: 6px;
  transition: 0.12s;
  border: 1px solid rgba(27, 31, 36, 0.15);
  box-shadow: var(--shadow-resting);
}
.btn-submit:hover { background: #1a7f37; }
.btn-submit svg { transition: transform 0.12s; }
.btn-submit:hover svg { transform: translateX(2px); }
.login-foot {
  margin-top: 22px;
  font-size: 12px;
  color: var(--fg-muted);
  line-height: 1.5;
}

/* ============================================================ */
/*  Water quality stats                                           */
/* ============================================================ */
.water-stats {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 18px 32px;
}
.water-stat {
  padding: 4px 0;
  border-left: 2px solid var(--border-default);
  padding-left: 14px;
}
.water-stat-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--fg-muted);
}
.water-stat-val {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.018em;
  color: var(--fg-default);
  margin-top: 4px;
  font-variant-numeric: tabular-nums;
}
.water-stat-unit {
  font-size: 12px;
  font-weight: 500;
  color: var(--fg-muted);
  margin-left: 3px;
}

/* ============================================================ */
/*  Ração — cards                                                 */
/* ============================================================ */
.racao-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.racao-card { position: relative; overflow: hidden; }
.racao-card::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 3px;
}
.racao-inicial::before     { background: var(--accent-emphasis); }
.racao-crescimento::before { background: var(--success-emphasis); }
.racao-terminacao::before  { background: var(--attention-emphasis); }
.racao-stats {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 14px 24px;
  margin-top: 4px;
}
.racao-stat .label {
  font-size: 11px;
  font-weight: 500;
  color: var(--fg-muted);
}
.racao-stat .val {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--fg-default);
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.bar-cell { width: 200px; }
.hbar {
  background: var(--bg-default);
  border-radius: 999px;
  height: 4px;
  overflow: hidden;
}
.hbar span {
  display: block; height: 100%;
  background: var(--accent-emphasis);
  border-radius: 999px;
}

/* ============================================================ */
/*  Responsivo                                                    */
/* ============================================================ */
@media (max-width: 1180px) {
  .kpi-grid-4 { grid-template-columns: repeat(2, 1fr); }
  .kpi-grid-3 { grid-template-columns: repeat(2, 1fr); }
  .row-2, .row-3, .racao-grid { grid-template-columns: 1fr; }
}
@media (max-width: 800px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: relative; height: auto; }
  .topbar, .content { padding-left: 18px; padding-right: 18px; }
  .kpi-grid-4, .kpi-grid-3 { grid-template-columns: 1fr; }
  .login-shell { grid-template-columns: 1fr; }
  .login-aside { display: none; }
}
