:root {
  --bg: #f8fafc; --card: #ffffff; --card-soft: #f1f5f9; --line: #e2e8f0; --text: #0f172a;
  --muted: #64748b; --accent: #2563eb; --accent-hover: #1d4ed8; 
  --good: #10b981; --bad: #ef4444; --warn: #f59e0b; --info: #0ea5e9;
  --sidebar-w: 280px; --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1); --radius: 12px;
}
[data-bs-theme="dark"] {
  --bg: #0f172a; --card: #1e293b; --card-soft: #334155; --line: #334155;
  --text: #f8fafc; --muted: #94a3b8; --accent: #3b82f6; --accent-hover: #60a5fa;
}

html, body { background: var(--bg); color: var(--text); margin: 0; font-family: 'Inter', sans-serif; overflow-x: hidden; }
.arc-shell { display: flex; height: 100vh; overflow: hidden; transition: all 0.3s; }
.arc-sidebar { width: var(--sidebar-w); background: var(--card); border-right: 1px solid var(--line); display: flex; flex-direction: column; transition: 0.3s; z-index: 50; }
.arc-sidebar.collapsed { margin-left: calc(var(--sidebar-w) * -1); }
.arc-main { flex: 1; display: flex; flex-direction: column; height: 100vh; background: var(--bg); min-width: 0; transition: 0.3s; position: relative; }
.arc-topbar { height: 64px; background: var(--card); border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; padding: 0 24px; flex-shrink: 0; transition: 0.3s; }
.arc-sidebar-brand { height: 64px; padding: 0 24px; display: flex; align-items: center; gap: 12px; border-bottom: 1px solid var(--line); font-weight: 700; font-size: 18px; color: var(--accent); }
.arc-sidebar-body { flex: 1; overflow-y: auto; padding: 24px 16px; }
.arc-nav-item { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-radius: var(--radius); color: var(--muted); text-decoration: none; font-weight: 500; margin-bottom: 4px; cursor: pointer; transition: 0.2s; }
.arc-nav-item:hover { background: var(--card-soft); color: var(--text); }
.arc-nav-item.active { background: var(--accent); color: #fff; }
.arc-nav-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); margin: 24px 0 8px 16px; font-weight: 600; }
.arc-page-content { flex: 1; overflow-y: auto; padding: 32px 24px; }

/* Grid e Componentes base */
.arc-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 24px; margin-bottom: 24px; }
.arc-card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; }
.arc-card-title { margin: 0; font-size: 18px; font-weight: 600; }
.arc-grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 24px; }
.arc-grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(400px, 1fr)); gap: 24px; }
.arc-stat { padding: 20px; border-radius: var(--radius); background: var(--card-soft); border: 1px solid var(--line); display: flex; align-items: center; gap: 16px; }
.arc-stat-icon { width: 48px; height: 48px; border-radius: 12px; background: var(--accent); color: #fff; display: grid; place-items: center; font-size: 24px; }
.arc-stat-info b { display: block; font-size: 24px; font-weight: 700; }
.arc-stat-info span { color: var(--muted); font-size: 13px; }

/* ======== WIDGETS NOC DASHBOARD ======== */
.widget-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.widget-tile { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; display: flex; flex-direction: column; gap: 12px; position: relative; overflow: hidden; box-shadow: var(--shadow-sm); transition: 0.2s; }
.widget-tile:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.widget-header { display: flex; justify-content: space-between; align-items: center; font-size: 14px; font-weight: 600; color: var(--muted); }
.widget-value-row { display: flex; align-items: baseline; gap: 8px; margin-top: 4px; }
.widget-value { font-size: 38px; font-weight: 800; color: var(--text); line-height: 1; letter-spacing: -0.03em; }
.widget-unit { font-size: 18px; font-weight: 600; color: var(--muted); }
.widget-icon { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; font-size: 24px; }

/* Cores de Alerta */
.bg-danger-soft { background: rgba(239, 68, 68, 0.1); color: var(--bad); }
.bg-success-soft { background: rgba(16, 185, 129, 0.1); color: var(--good); }
.bg-info-soft { background: rgba(14, 165, 233, 0.1); color: var(--info); }
.bg-warn-soft { background: rgba(245, 158, 11, 0.1); color: var(--warn); }
.bg-offline { background: rgba(100, 116, 139, 0.1); color: var(--muted); border-style: dashed; }

/* Tanque de Água CSS */
.tank-wrap { width: 100%; display: flex; align-items: center; gap: 12px; margin-top: 8px; }
.tank-container { flex: 1; height: 18px; background: var(--card-soft); border-radius: 99px; overflow: hidden; position: relative; border: 1px solid var(--line); }
.tank-fill { height: 100%; background: var(--info); transition: width 0.5s ease; }
.tank-fill.critical { background: var(--bad); }

@keyframes pulseRed { 0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); } 70% { box-shadow: 0 0 0 10px rgba(239, 68, 68, 0); } 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); } }
.alert-pulse { border-color: var(--bad) !important; animation: pulseRed 2s infinite; }

/* MODO TV */
body.tv-mode .arc-sidebar { display: none !important; }
body.tv-mode .arc-topbar { display: none !important; }
body.tv-mode .arc-page-content { padding: 12px; }
body.tv-mode .widget-value { font-size: 52px; }

/* Botão Flutuante TV */
.exit-tv-btn { display: none; position: absolute; top: 16px; right: 16px; background: rgba(0,0,0,0.6); color: #fff; border: none; padding: 10px 16px; border-radius: 8px; font-size: 14px; font-weight: 600; cursor: pointer; z-index: 1000; backdrop-filter: blur(4px); transition: 0.2s; }
.exit-tv-btn:hover { background: rgba(0,0,0,0.8); }
body.tv-mode .exit-tv-btn { display: flex; align-items: center; gap: 8px; }

/* Botões e Inputs */
.arc-btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 18px; border-radius: 8px; font-weight: 500; font-size: 14px; cursor: pointer; transition: 0.2s; border: 1px solid var(--line); background: var(--card); color: var(--text); }
.arc-btn:hover { background: var(--card-soft); }
.arc-btn-icon { background: transparent; border: none; color: var(--muted); cursor: pointer; padding: 8px; border-radius: 8px; display: grid; place-items: center; transition: 0.2s; }
.arc-btn-icon:hover { background: var(--card-soft); color: var(--text); }
.arc-btn-primary { background: var(--accent); color: #fff; border: none; }
.arc-btn-danger { background: #fef2f2; color: var(--bad); border-color: #fecaca; }

.arc-form-group { margin-bottom: 16px; }
.arc-form-group label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 6px; color: var(--text); }
.arc-input, .arc-select, .arc-textarea { width: 100%; padding: 12px 14px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); color: var(--text); outline: none; font-family: inherit; font-size: 14px; }
.arc-input:focus { border-color: var(--accent); }

.arc-table { width: 100%; border-collapse: collapse; text-align: left; }
.arc-table th { padding: 12px 16px; color: var(--muted); font-size: 12px; text-transform: uppercase; font-weight: 600; border-bottom: 1px solid var(--line); }
.arc-table td { padding: 16px; font-size: 14px; border-bottom: 1px solid var(--line); }
.arc-badge { display: inline-flex; padding: 4px 10px; border-radius: 99px; font-size: 12px; font-weight: 500; }
.arc-badge-online { background: rgba(16, 185, 129, 0.1); color: var(--good); }
.arc-badge-offline { background: rgba(239, 68, 68, 0.1); color: var(--bad); }

/* Login Custom */
.arc-login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: var(--bg); }
.arc-login-box { width: 100%; max-width: 420px; padding: 40px; border-radius: 24px; background: var(--card); box-shadow: var(--shadow-md); border: 1px solid var(--line); text-align: center; }
.nav-pills .nav-link { color: var(--text); background: var(--card-soft); border-radius: 8px; margin: 0 4px; padding: 10px; font-weight: 600; cursor: pointer; border: 1px solid transparent; transition: 0.2s; }
.nav-pills .nav-link:hover { background: var(--line); }
.nav-pills .nav-link.active { background: var(--accent); color: #fff; }
