/**
 * Cacciatore SmartHouse OS - Industrial Building Automation Design System
 * Farby: Cacciatore Red (#CC0000), Dark Slate (#0A0D14), Surface (#121620), Border (#1F2633)
 */

:root {
  --cacciatore-red: #CC0000;
  --cacciatore-red-dark: #990000;
  --cacciatore-red-hover: #E60000;
  --cacciatore-red-glow: rgba(204, 0, 0, 0.28);
  
  --bg-main: #0A0D14;
  --bg-surface: #121620;
  --bg-card: #151B27;
  --bg-card-hover: #1A2232;
  --bg-input: #0E131D;
  
  --border-subtle: #1F2633;
  --border-strong: #2F3B4E;
  --border-active: #CC0000;
  
  --text-primary: #FFFFFF;
  --text-secondary: #8E9AA8;
  --text-muted: #5A6675;
  
  --status-ok: #10B981;
  --status-warn: #F59E0B;
  --status-crit: #CC0000;
  --status-info: #0284C7;
  
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'Consolas', monospace;
  
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg-main);
  color: var(--text-primary);
  font-family: var(--font-sans);
  line-height: 1.5;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ─── SYSTEM TOPBAR ──────────────────────────────────────────────────────── */
.top-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(10, 13, 20, 0.94);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-subtle);
  padding: 0.65rem 1.5rem;
}

.header-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.brand-wrap {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.brand-badge {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: linear-gradient(145deg, #CC0000 0%, #880000 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-size: 1.15rem;
  letter-spacing: -0.04em;
  color: #FFFFFF;
  box-shadow: 0 0 20px var(--cacciatore-red-glow);
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.brand-title {
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: #FFFFFF;
  flex-wrap: wrap;
}

.brand-sub {
  font-size: 0.72rem;
  color: var(--text-secondary);
  font-family: var(--font-mono);
  line-height: 1.35;
}

.system-status-pills {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.35rem 0.7rem;
  border-radius: var(--radius-sm);
  font-size: 0.74rem;
  font-weight: 600;
  font-family: var(--font-mono);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  white-space: nowrap;
}

.status-pill .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: inline-block;
}

.pill-active {
  color: #FFFFFF;
  border-color: rgba(204, 0, 0, 0.4);
}

/* ─── NAVIGATION TABS ────────────────────────────────────────────────────── */
.nav-tabs {
  display: flex;
  gap: 0.38rem;
  margin-top: 0.6rem;
  padding-top: 0.55rem;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  flex-wrap: wrap;
}

.nav-tab {
  background: rgba(255, 255, 255, 0.02);
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
  padding: 0.42rem 0.78rem;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.16s ease;
}

.nav-tab:hover {
  color: #FFFFFF;
  background: rgba(255, 255, 255, 0.06);
  border-color: var(--border-strong);
}

.nav-tab.active {
  color: #FFFFFF;
  background: linear-gradient(135deg, rgba(204, 0, 0, 0.28), rgba(204, 0, 0, 0.12));
  border-color: var(--cacciatore-red);
  box-shadow: 0 0 14px rgba(204, 0, 0, 0.22);
}

/* ─── MAIN CONTAINER & CARDS ─────────────────────────────────────────────── */
.main-container {
  max-width: 1680px;
  margin: 0 auto;
  padding: 1.25rem 1.5rem 3rem;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
  animation: fadeIn 0.18s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(3px); }
  to { opacity: 1; transform: translateY(0); }
}

.grid-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.9rem;
  margin-bottom: 1.2rem;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1.05rem 1.2rem;
  box-shadow: 0 10px 25px -8px rgba(0, 0, 0, 0.6);
  transition: border-color 0.16s ease;
  min-width: 0;
  overflow: hidden;
}

.card:hover {
  border-color: var(--border-strong);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.85rem;
  gap: 0.65rem;
  flex-wrap: wrap;
}

.card-title {
  font-size: 0.92rem;
  font-weight: 700;
  color: #FFFFFF;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  letter-spacing: -0.01em;
}

.kpi-label {
  font-size: 0.74rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}

.kpi-value {
  font-size: 1.85rem;
  font-weight: 800;
  font-family: var(--font-mono);
  margin: 0.2rem 0;
  letter-spacing: -0.03em;
}

.text-cacciatore-red {
  color: var(--cacciatore-red);
}

.kpi-sub {
  font-size: 0.76rem;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.22rem 0.6rem;
  border-radius: var(--radius-sm);
  font-size: 0.7rem;
  font-weight: 700;
  font-family: var(--font-mono);
  white-space: nowrap;
  flex-shrink: 0;
  line-height: 1.2;
}

.badge-ok { background: rgba(16, 185, 129, 0.14); color: #34d399; border: 1px solid rgba(16, 185, 129, 0.35); }
.badge-warn { background: rgba(245, 158, 11, 0.14); color: #fbbf24; border: 1px solid rgba(245, 158, 11, 0.35); }
.badge-crit { background: rgba(204, 0, 0, 0.22); color: #ff9999; border: 1px solid rgba(204, 0, 0, 0.55); }
.badge-info { background: rgba(2, 132, 199, 0.15); color: #38bdf8; border: 1px solid rgba(2, 132, 199, 0.35); }

.grid-2col {
  display: grid;
  grid-template-columns: 1.68fr 1fr;
  gap: 1.25rem;
  margin-bottom: 1.25rem;
}

.grid-equal {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 400px), 1fr));
  gap: 1.25rem;
  margin-bottom: 1.25rem;
}

.grid-3col {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr));
  gap: 1.25rem;
  margin-bottom: 1.25rem;
}

@media (max-width: 1100px) {
  .grid-2col {
    grid-template-columns: 1fr;
  }
}

/* ─── NATIVE MOBILE & TABLET MOCKUP FRAME ────────────────────────────────── */
.phone-mockup {
  width: 340px;
  margin: 0 auto;
  background: #0d111a;
  border: 5px solid #202836;
  border-radius: 34px;
  padding: 1.1rem;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.7);
}

.phone-notch {
  width: 105px;
  height: 16px;
  background: #19212d;
  border-radius: 999px;
  margin: 0 auto 0.85rem;
}

.phone-ring {
  width: 165px;
  height: 165px;
  border-radius: 50%;
  margin: 0.75rem auto;
  background: conic-gradient(var(--cacciatore-red) 0% 65%, #1f2735 65% 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 28px rgba(204, 0, 0, 0.22);
}

.phone-ring-inner {
  width: 136px;
  height: 136px;
  border-radius: 50%;
  background: #0d121c;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

/* ─── BUTTONS & INDUSTRIAL CONTROLS ──────────────────────────────────────── */
.btn {
  background: #1a2232;
  color: #FFFFFF;
  border: 1px solid var(--border-subtle);
  padding: 0.5rem 0.9rem;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
}

.btn:hover {
  background: #242f44;
  border-color: var(--border-strong);
}

.btn-primary {
  background: var(--cacciatore-red);
  border-color: #e60000;
  color: #FFFFFF;
}

.btn-primary:hover {
  background: var(--cacciatore-red-hover);
  box-shadow: 0 0 16px var(--cacciatore-red-glow);
}

.btn-emerald {
  background: rgba(16, 185, 129, 0.16);
  border-color: rgba(16, 185, 129, 0.4);
  color: #34d399;
}

.btn-emerald:hover {
  background: rgba(16, 185, 129, 0.28);
}

.actuator-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.65rem 0.85rem;
  background: rgba(14, 19, 29, 0.7);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  margin-bottom: 0.55rem;
  gap: 0.75rem;
}

.switch-btn {
  min-width: 78px;
  padding: 0.35rem 0.65rem;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 0.74rem;
  font-weight: 700;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s ease;
}

.switch-btn.on {
  background: rgba(16, 185, 129, 0.18);
  color: #34d399;
  border-color: rgba(16, 185, 129, 0.45);
}

.switch-btn.off {
  background: rgba(90, 102, 117, 0.18);
  color: #8e9aa8;
  border-color: rgba(90, 102, 117, 0.35);
}

input[type="range"] {
  width: 100%;
  accent-color: var(--cacciatore-red);
  cursor: pointer;
}

.form-group {
  margin-bottom: 0.85rem;
}

.form-group label {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 0.35rem;
}

.form-control {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  color: #FFFFFF;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 0.84rem;
  outline: none;
  transition: border-color 0.15s ease;
}

.form-control:focus {
  border-color: var(--cacciatore-red);
}

/* ─── DATA TABLES & LOG TERMINAL ─────────────────────────────────────────── */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.79rem;
}

.data-table th,
.data-table td {
  padding: 0.58rem 0.68rem;
  text-align: left;
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: middle;
  word-break: break-word;
}

.data-table th {
  color: var(--text-secondary);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.7rem;
  letter-spacing: 0.04em;
}

.data-table code {
  background: rgba(14, 19, 29, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 0.14rem 0.4rem;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: #e2e8f0;
}

.terminal-box {
  background: #080b11;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 0.85rem;
  font-family: var(--font-mono);
  font-size: 0.76rem;
  max-height: 330px;
  overflow-y: auto;
}

.terminal-line {
  padding: 0.32rem 0;
  border-bottom: 1px dashed rgba(255, 255, 255, 0.05);
}

canvas {
  width: 100%;
  display: block;
  border-radius: var(--radius-sm);
  background: #090c13;
}

.schematic-svg {
  width: 100%;
  height: auto;
  background: #090c13;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
}


/* ─── TOP HEADER & MULTI-AGENT BAR ───────────────────────────────────────── */
.top-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(9, 13, 20, 0.92);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border-subtle);
  padding: 0.75rem 1.5rem;
}

.header-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.brand-wrap {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.brand-badge {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: linear-gradient(135deg, #e11d48 0%, #9f1239 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1.15rem;
  letter-spacing: -0.03em;
  box-shadow: 0 0 20px rgba(225, 29, 72, 0.45);
}

.brand-title {
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.brand-sub {
  font-size: 0.76rem;
  color: var(--text-secondary);
  font-family: var(--font-mono);
}

.agent-pills {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.agent-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 600;
  font-family: var(--font-mono);
  background: rgba(30, 41, 59, 0.75);
  border: 1px solid var(--border-subtle);
}

.agent-pill .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  box-shadow: 0 0 8px currentColor;
}

.agent-sha { color: #38bdf8; border-color: rgba(56, 189, 248, 0.35); }
.agent-eoa { color: #34d399; border-color: rgba(52, 211, 153, 0.35); }
.agent-ssa { color: #fb7185; border-color: rgba(251, 113, 133, 0.35); }

/* ─── NAVIGATION TABS ────────────────────────────────────────────────────── */
.nav-tabs {
  display: flex;
  gap: 0.4rem;
  margin-top: 0.75rem;
  padding-top: 0.65rem;
  border-top: 1px solid rgba(148, 163, 184, 0.08);
  overflow-x: auto;
}

.nav-tab {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid transparent;
  padding: 0.48rem 0.9rem;
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.18s ease;
}

.nav-tab:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.04);
}

.nav-tab.active {
  color: #fff;
  background: linear-gradient(135deg, rgba(225, 29, 72, 0.28), rgba(225, 29, 72, 0.1));
  border-color: var(--border-strong);
}

/* ─── MAIN LAYOUT & CARDS ────────────────────────────────────────────────── */
.main-container {
  max-width: 1640px;
  margin: 0 auto;
  padding: 1.25rem 1.5rem 3rem;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
  animation: fadeIn 0.22s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.grid-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 1.1rem 1.25rem;
  box-shadow: 0 10px 25px -10px rgba(0, 0, 0, 0.5);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.85rem;
  gap: 0.5rem;
}

.card-title {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.kpi-label {
  font-size: 0.76rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
}

.kpi-value {
  font-size: 1.75rem;
  font-weight: 800;
  font-family: var(--font-mono);
  margin: 0.25rem 0;
}

.kpi-sub {
  font-size: 0.76rem;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.18rem 0.55rem;
  border-radius: 6px;
  font-size: 0.7rem;
  font-weight: 700;
  font-family: var(--font-mono);
}

.badge-ok { background: rgba(16, 185, 129, 0.16); color: #34d399; border: 1px solid rgba(16, 185, 129, 0.35); }
.badge-warn { background: rgba(245, 158, 11, 0.16); color: #fbbf24; border: 1px solid rgba(245, 158, 11, 0.35); }
.badge-crit { background: rgba(225, 29, 72, 0.22); color: #fda4af; border: 1px solid rgba(225, 29, 72, 0.55); }
.badge-info { background: rgba(56, 189, 248, 0.16); color: #38bdf8; border: 1px solid rgba(56, 189, 248, 0.35); }

.grid-2col {
  display: grid;
  grid-template-columns: 1.65fr 1fr;
  gap: 1.25rem;
  margin-bottom: 1.25rem;
}

.grid-equal {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(420px, 1fr));
  gap: 1.25rem;
  margin-bottom: 1.25rem;
}

.grid-3col {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1.25rem;
  margin-bottom: 1.25rem;
}

@media (max-width: 1100px) {
  .grid-2col {
    grid-template-columns: 1fr;
  }
}

/* ─── MOBILE APP PHONE MOCKUP ────────────────────────────────────────────── */
.phone-mockup {
  width: 340px;
  margin: 0 auto;
  background: #0b101b;
  border: 6px solid #263248;
  border-radius: 36px;
  padding: 1rem;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.65);
}

.phone-notch {
  width: 110px;
  height: 18px;
  background: #1e293b;
  border-radius: 999px;
  margin: 0 auto 0.85rem;
}

.phone-ring {
  width: 165px;
  height: 165px;
  border-radius: 50%;
  margin: 0.75rem auto;
  background: conic-gradient(var(--accent-red) 0% 68%, #1e293b 68% 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 30px rgba(225, 29, 72, 0.25);
}

.phone-ring-inner {
  width: 136px;
  height: 136px;
  border-radius: 50%;
  background: #0f172a;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

/* ─── BUTTONS, CONTROLS & SLIDERS ────────────────────────────────────────── */
.btn {
  background: #1e293b;
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
  padding: 0.5rem 0.9rem;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn:hover {
  background: #334155;
}

.btn-primary {
  background: linear-gradient(135deg, #e11d48, #be123c);
  border-color: #f43f5e;
  color: #fff;
}

.btn-primary:hover {
  filter: brightness(1.1);
}

.btn-emerald {
  background: rgba(16, 185, 129, 0.18);
  border-color: rgba(16, 185, 129, 0.45);
  color: #34d399;
}

.actuator-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.65rem 0.8rem;
  background: rgba(15, 23, 42, 0.65);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  margin-bottom: 0.55rem;
  gap: 0.75rem;
}

.switch-btn {
  min-width: 76px;
  padding: 0.35rem 0.65rem;
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: 0.74rem;
  font-weight: 700;
  cursor: pointer;
  border: 1px solid transparent;
}

.switch-btn.on {
  background: rgba(16, 185, 129, 0.2);
  color: #34d399;
  border-color: rgba(16, 185, 129, 0.5);
}

.switch-btn.off {
  background: rgba(100, 116, 139, 0.18);
  color: #94a3b8;
  border-color: rgba(100, 116, 139, 0.35);
}

input[type="range"] {
  width: 100%;
  accent-color: var(--accent-red);
  cursor: pointer;
}

.form-group {
  margin-bottom: 0.85rem;
}

.form-group label {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 0.3rem;
}

.form-control {
  width: 100%;
  background: #0f172a;
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  font-family: var(--font-mono);
  font-size: 0.84rem;
}

/* ─── TABLES & LOGS ──────────────────────────────────────────────────────── */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}

.data-table th,
.data-table td {
  padding: 0.6rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--border-subtle);
}

.data-table th {
  color: var(--text-secondary);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.72rem;
}

.terminal-box {
  background: #070a10;
  border: 1px solid rgba(56, 189, 248, 0.22);
  border-radius: 10px;
  padding: 0.85rem;
  font-family: var(--font-mono);
  font-size: 0.76rem;
  max-height: 330px;
  overflow-y: auto;
}

.terminal-line {
  padding: 0.32rem 0;
  border-bottom: 1px dashed rgba(148, 163, 184, 0.1);
}

canvas {
  width: 100%;
  display: block;
  border-radius: 8px;
  background: #0b111c;
}

.schematic-svg {
  width: 100%;
  height: auto;
  background: #0b101b;
  border-radius: 10px;
  border: 1px solid var(--border-subtle);
}
