/* ============================================
   AquaSense Home — style.css
   Mobile-first, premium water monitoring UI
   ============================================ */

/* ---- CSS VARIABLES ---- */
:root {
  --blue-50:  #EFF8FF;
  --blue-100: #DBEAFE;
  --blue-200: #BFDBFE;
  --blue-400: #60A5FA;
  --blue-500: #3B82F6;
  --blue-600: #2563EB;
  --sky-400:  #38BDF8;
  --sky-500:  #0EA5E9;
  --sky-600:  #0284C7;
  --green-400:#4ADE80;
  --green-500:#22C55E;
  --green-600:#16A34A;
  --teal-400: #2DD4BF;
  --teal-500: #14B8A6;
  --orange-400:#FB923C;
  --orange-500:#F59E0B;
  --red-400:  #F87171;
  --red-500:  #EF4444;
  --purple-500:#8B5CF6;

  --bg:       #F0F6FF;
  --surface:  #FFFFFF;
  --surface2: #F7FAFF;
  --border:   #E2EEF9;
  --text-primary: #0F172A;
  --text-secondary: #64748B;
  --text-muted: #94A3B8;

  --shadow-sm: 0 1px 3px rgba(14,35,60,0.06), 0 1px 2px rgba(14,35,60,0.04);
  --shadow-md: 0 4px 16px rgba(14,35,60,0.08), 0 2px 6px rgba(14,35,60,0.05);
  --shadow-lg: 0 8px 32px rgba(14,35,60,0.10), 0 4px 12px rgba(14,35,60,0.06);

  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 22px;
  --radius-xl: 28px;

  --nav-height: 70px;
  --header-height: 64px;
  --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ---- RESET & BASE ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; font-size: 16px; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  min-height: 100vh;
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
}

button { cursor: pointer; font-family: inherit; border: none; outline: none; }
input, select { font-family: inherit; outline: none; }
svg { display: block; flex-shrink: 0; }

/* ---- APP WRAPPER ---- */
#app {
  max-width: 520px;
  margin: 0 auto;
  position: relative;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---- TOP HEADER ---- */
.top-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-height);
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  gap: 10px;
}

.header-left { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }

.app-logo {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-shrink: 0;
}

.app-name {
  font-size: 1.05rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--sky-500), var(--green-500));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.5px;
}

.house-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.house-name {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.connection-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.62rem;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 999px;
  margin-top: 2px;
  width: fit-content;
}

.connection-badge.online { background: #DCFCE7; color: #16A34A; }
.connection-badge.offline { background: #FEE2E2; color: #DC2626; }

.connection-badge .dot {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: currentColor;
  animation: pulse-dot 1.8s ease-in-out infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.header-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

.auto-mode-pill {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 5px 10px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--sky-400), var(--sky-600));
  cursor: pointer;
  transition: var(--transition);
  user-select: none;
}

.auto-mode-pill.off { background: linear-gradient(135deg, #94A3B8, #64748B); }

.auto-label { font-size: 0.65rem; font-weight: 600; color: rgba(255,255,255,0.85); }
.auto-state { font-size: 0.72rem; font-weight: 800; color: #fff; }

.notif-btn {
  position: relative;
  background: var(--surface);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: 999px;
  width: 38px; height: 38px;
  display: flex; align-items: center; justify-content: center;
  transition: var(--transition);
}

.notif-btn:hover { background: var(--blue-50); color: var(--sky-500); }

.notif-count {
  position: absolute;
  top: -3px; right: -3px;
  background: var(--red-500);
  color: #fff;
  font-size: 0.55rem;
  font-weight: 700;
  width: 16px; height: 16px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid white;
}

/* ---- MAIN CONTENT ---- */
.main-content {
  flex: 1;
  padding: 16px 14px;
  padding-bottom: calc(var(--nav-height) + 12px);
  overflow-y: auto;
}

/* ---- PAGE SECTIONS ---- */
.page-section { display: none; animation: fadeInUp 0.3s ease; }
.page-section.active { display: block; }

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---- CARD BASE ---- */
.card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 18px;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border);
  margin-bottom: 14px;
}

/* ---- SECTION HEADING ---- */
.section-heading { margin-bottom: 14px; }
.section-title { font-size: 1.2rem; font-weight: 800; color: var(--text-primary); }
.section-sub { font-size: 0.75rem; color: var(--text-secondary); margin-top: 2px; display: block; }

/* ======================================================
   HERO CARD (HOME)
   ====================================================== */
.hero-card { padding: 20px; }

.hero-card-inner {
  display: flex;
  gap: 18px;
  align-items: center;
  margin-bottom: 18px;
}

/* Tank Visual */
.tank-visual-wrap {
  position: relative;
  flex-shrink: 0;
  width: 140px; height: 140px;
}

.tank-ring {
  width: 140px; height: 140px;
  position: relative;
  z-index: 2;
}

.tank-svg {
  width: 140px; height: 140px;
  position: absolute;
  top: 0; left: 0;
  filter: drop-shadow(0 4px 16px rgba(56,189,248,0.2));
}

#tankCircle {
  transition: stroke-dashoffset 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.tank-inner-info {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%,-50%);
  text-align: center;
  z-index: 3;
}

.tank-percent {
  font-size: 1.85rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--sky-500), var(--green-500));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1;
}

.tank-label {
  font-size: 0.6rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: 3px 0;
}

.tank-liters {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--sky-600);
}

.tank-wave-wrap {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 140px;
  border-radius: 50%;
  overflow: hidden;
  z-index: 1;
  pointer-events: none;
}

.wave-anim {
  position: absolute;
  bottom: 0;
  left: -50%;
  width: 200%;
  background: linear-gradient(180deg, rgba(56,189,248,0.12) 0%, rgba(14,165,233,0.06) 100%);
  border-radius: 40% 60% 55% 45% / 35% 45% 55% 65%;
  animation: wave-morph 3s ease-in-out infinite alternate;
  transition: height 0.8s ease;
}

@keyframes wave-morph {
  0%   { border-radius: 40% 60% 55% 45% / 35% 45% 55% 65%; }
  50%  { border-radius: 60% 40% 45% 55% / 55% 35% 65% 45%; }
  100% { border-radius: 45% 55% 60% 40% / 45% 60% 35% 55%; }
}

/* Hero Info */
.hero-info { flex: 1; min-width: 0; }

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(56,189,248,0.12), rgba(34,197,94,0.12));
  border: 1px solid rgba(56,189,248,0.25);
  margin-bottom: 12px;
}

.status-badge.idle-badge {
  background: rgba(100,116,139,0.1);
  border-color: rgba(100,116,139,0.2);
}

.status-icon {
  font-size: 0.85rem;
  animation: spin 2s linear infinite;
}

.status-badge.idle-badge .status-icon { animation: none; }

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.status-badge span:last-child {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--sky-600);
}

.status-badge.idle-badge span:last-child { color: var(--text-secondary); }

.info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 5px 0;
  border-bottom: 1px solid var(--border);
}

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

.info-key {
  font-size: 0.7rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.info-val {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-primary);
}

/* Action Buttons */
.action-buttons {
  display: flex;
  gap: 8px;
}

.btn {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 11px 8px;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 700;
  transition: var(--transition);
  letter-spacing: 0.2px;
  user-select: none;
}

.btn:active { transform: scale(0.96); }

.btn-primary {
  background: linear-gradient(135deg, var(--sky-500), var(--sky-600));
  color: #fff;
  box-shadow: 0 4px 14px rgba(14,165,233,0.3);
}

.btn-primary:hover { box-shadow: 0 6px 20px rgba(14,165,233,0.4); transform: translateY(-1px); }

.btn-danger {
  background: linear-gradient(135deg, var(--red-400), var(--red-500));
  color: #fff;
  box-shadow: 0 4px 14px rgba(239,68,68,0.25);
}

.btn-danger:hover { box-shadow: 0 6px 20px rgba(239,68,68,0.35); transform: translateY(-1px); }

.btn-secondary {
  background: var(--surface2);
  color: var(--text-primary);
  border: 1.5px solid var(--border);
}

.btn-secondary:hover { background: var(--blue-50); border-color: var(--sky-400); }

.btn:disabled {
  opacity: 0.5;
  pointer-events: none;
  transform: none !important;
  box-shadow: none !important;
}

/* ---- QUICK CARDS ---- */
.quick-cards-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 14px;
}

.quick-card {
  background: var(--surface);
  border-radius: var(--radius-md);
  padding: 14px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.quick-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--sky-400), var(--green-400));
  opacity: 0;
  transition: var(--transition);
}

.quick-card:hover::before { opacity: 1; }
.quick-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }

.qc-icon {
  width: 38px; height: 38px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.pump-icon { background: linear-gradient(135deg, rgba(56,189,248,0.15), rgba(14,165,233,0.1)); color: var(--sky-500); }
.time-icon  { background: linear-gradient(135deg, rgba(34,197,94,0.15), rgba(34,197,94,0.1)); color: var(--green-500); }
.usage-icon { background: linear-gradient(135deg, rgba(251,146,60,0.15), rgba(245,158,11,0.1)); color: var(--orange-400); }
.cycle-icon { background: linear-gradient(135deg, rgba(139,92,246,0.15), rgba(139,92,246,0.1)); color: var(--purple-500); }

.qc-info { flex: 1; min-width: 0; }

.qc-val {
  font-size: 0.92rem;
  font-weight: 800;
  color: var(--text-primary);
  white-space: nowrap;
}

.qc-label {
  font-size: 0.65rem;
  color: var(--text-secondary);
  font-weight: 500;
  margin-top: 1px;
}

.qc-indicator {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.qc-indicator.running {
  background: var(--green-500);
  box-shadow: 0 0 0 3px rgba(34,197,94,0.2);
  animation: pulse-green 1.5s ease-in-out infinite;
}

.qc-indicator.idle { background: var(--text-muted); }

@keyframes pulse-green {
  0%, 100% { box-shadow: 0 0 0 3px rgba(34,197,94,0.2); }
  50%       { box-shadow: 0 0 0 6px rgba(34,197,94,0.1); }
}

/* ---- INSIGHT CARD ---- */
.insight-card { padding: 18px; }

.insight-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.insight-title { font-size: 0.85rem; font-weight: 700; color: var(--text-primary); }
.insight-time { font-size: 0.68rem; color: var(--text-muted); font-weight: 500; }

.insight-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.insight-item {
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 12px;
  border: 1px solid var(--border);
}

.insight-val {
  font-size: 1.1rem;
  font-weight: 800;
  margin-bottom: 3px;
}

.insight-val.green { color: var(--green-600); }
.insight-val.blue  { color: var(--sky-600); }
.insight-val.orange{ color: var(--orange-400); }
.insight-val.teal  { color: var(--teal-500); }

.insight-desc { font-size: 0.62rem; color: var(--text-secondary); line-height: 1.4; }

/* ======================================================
   LIVE LEVEL SECTION
   ====================================================== */
.live-card { padding: 18px; }

.live-meta {
  display: flex;
  justify-content: space-between;
  margin-bottom: 16px;
  gap: 8px;
}

.live-meta-item { text-align: center; flex: 1; }

.lm-label {
  display: block;
  font-size: 0.6rem;
  color: var(--text-muted);
  font-weight: 500;
  margin-bottom: 3px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.lm-val {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-primary);
}

.active-inflow { color: var(--green-600) !important; }

/* Chart */
.chart-wrap {
  display: flex;
  gap: 8px;
  margin-bottom: 6px;
}

.chart-y-labels {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 0 4px;
  width: 34px;
  flex-shrink: 0;
}

.chart-y-labels span {
  font-size: 0.6rem;
  color: var(--text-muted);
  font-weight: 500;
  text-align: right;
}

.chart-area {
  flex: 1;
  position: relative;
  border-radius: 8px;
  overflow: visible;
}

#levelChart { width: 100%; height: 180px; }

.chart-tooltip {
  position: absolute;
  background: var(--text-primary);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 6px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
  white-space: nowrap;
  z-index: 10;
}

.chart-x-labels {
  display: flex;
  justify-content: space-around;
  padding-left: 42px;
  margin-bottom: 10px;
}

.chart-x-labels span {
  font-size: 0.62rem;
  color: var(--text-muted);
  font-weight: 500;
  text-align: center;
}

.pump-period-legend {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}

.legend-box {
  width: 24px; height: 10px;
  border-radius: 3px;
  flex-shrink: 0;
}

.pump-active-legend { background: rgba(56,189,248,0.2); border: 1px solid rgba(56,189,248,0.4); }
.legend-text { font-size: 0.65rem; color: var(--text-secondary); font-weight: 500; }

/* Current Level Card */
.current-level-card {
  display: flex;
  gap: 16px;
  align-items: center;
}

.cl-left { flex: 1; }
.cl-percent {
  font-size: 2.8rem;
  font-weight: 900;
  background: linear-gradient(135deg, var(--sky-500), var(--green-500));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1;
  margin-bottom: 12px;
}

.cl-detail { display: flex; flex-direction: column; gap: 6px; }
.cl-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
}
.cl-row span:first-child { color: var(--text-secondary); font-weight: 500; }
.cl-row span:last-child { font-weight: 700; color: var(--text-primary); }

.cl-right { flex-shrink: 0; }

/* Tank Tube Visual */
.tank-tube {
  width: 54px;
  height: 120px;
  border: 3px solid var(--border);
  border-radius: 10px;
  position: relative;
  overflow: hidden;
  background: var(--bg);
}

.tank-fill {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  background: linear-gradient(180deg, rgba(56,189,248,0.7), rgba(14,165,233,0.9));
  transition: height 1s ease;
  border-radius: 0 0 7px 7px;
}

.tank-bubbles {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  top: 0;
  pointer-events: none;
  overflow: hidden;
}

.bubble {
  position: absolute;
  border-radius: 50%;
  background: rgba(255,255,255,0.45);
  animation: rise-bubble linear infinite;
}

@keyframes rise-bubble {
  0%   { transform: translateY(0) scale(1); opacity: 0.7; }
  100% { transform: translateY(-140px) scale(0.6); opacity: 0; }
}

/* ======================================================
   ANALYTICS SECTION
   ====================================================== */
.analytics-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 14px;
}

.analytics-card {
  border-radius: var(--radius-md);
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  border: 1px solid transparent;
  transition: var(--transition);
}

.analytics-card:hover { transform: translateY(-2px); }

.blue-card   { background: linear-gradient(135deg, #EFF8FF, #DBEAFE); border-color: #BFDBFE; }
.green-card  { background: linear-gradient(135deg, #F0FDF4, #DCFCE7); border-color: #BBF7D0; }
.teal-card   { background: linear-gradient(135deg, #F0FDFA, #CCFBF1); border-color: #99F6E4; }
.orange-card { background: linear-gradient(135deg, #FFFBEB, #FEF3C7); border-color: #FDE68A; }

.ac-icon { font-size: 1.4rem; margin-bottom: 2px; }
.ac-val { font-size: 1.35rem; font-weight: 800; color: var(--text-primary); }
.ac-label { font-size: 0.65rem; color: var(--text-secondary); font-weight: 600; }

/* Bar Chart */
.chart-card { padding: 18px; }

.chart-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.chart-title { font-size: 0.82rem; font-weight: 700; color: var(--text-primary); }
.chart-unit { font-size: 0.65rem; color: var(--text-muted); font-weight: 500; }

.bar-chart-wrap {
  display: flex;
  align-items: flex-end;
  gap: 7px;
  height: 110px;
  margin-bottom: 8px;
}

.bar-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  height: 100%;
  position: relative;
}

.bar-rect-wrap {
  width: 100%;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  height: 100%;
}

.bar-rect {
  width: 100%;
  border-radius: 5px 5px 0 0;
  background: linear-gradient(180deg, var(--sky-400), var(--sky-600));
  transition: opacity 0.2s;
  cursor: pointer;
  position: relative;
}

.bar-rect:hover { opacity: 0.85; }

.bar-rect.today { background: linear-gradient(180deg, var(--green-400), var(--green-600)); }

.bar-val {
  font-size: 0.58rem;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: 3px;
  text-align: center;
}

.bar-chart-labels {
  display: flex;
  gap: 7px;
}

.bar-day {
  flex: 1;
  text-align: center;
  font-size: 0.62rem;
  color: var(--text-muted);
  font-weight: 600;
}

/* Usage Breakdown */
.usage-breakdown { padding: 18px; }

.ub-title { font-size: 0.85rem; font-weight: 700; color: var(--text-primary); margin-bottom: 14px; }

.ub-item {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 11px;
}

.ub-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.ub-name { font-size: 0.65rem; color: var(--text-secondary); font-weight: 500; width: 100px; flex-shrink: 0; }
.ub-bar-wrap { flex: 1; height: 6px; background: var(--border); border-radius: 999px; overflow: hidden; }
.ub-bar { height: 100%; border-radius: 999px; transition: width 0.8s ease; }
.ub-pct { font-size: 0.65rem; font-weight: 700; color: var(--text-primary); width: 36px; text-align: right; flex-shrink: 0; }

/* ---- HEALTH CARD ---- */
.health-card { padding: 18px; }

.health-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 18px;
}

.health-stat { text-align: center; }

.hs-val {
  font-size: 1rem;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 3px;
}

.hs-val.warn { color: var(--orange-400); }
.hs-val.good { color: var(--green-600); }

.hs-label {
  font-size: 0.58rem;
  color: var(--text-secondary);
  font-weight: 500;
  line-height: 1.3;
}

.health-score-wrap { margin-bottom: 18px; }

.hs-score-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.72rem;
  margin-bottom: 6px;
}

.hs-score-label span:first-child { color: var(--text-secondary); font-weight: 500; }
.hs-score-val { font-weight: 800; color: var(--sky-600); }

.hs-bar-bg {
  height: 8px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
}

.hs-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--sky-400), var(--green-500));
  border-radius: 999px;
  transition: width 1s ease;
}

/* Event Log */
.event-log-title {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 10px;
}

.event-log { display: flex; flex-direction: column; gap: 8px; }

.log-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border-left: 3px solid transparent;
}

.warn-log { background: #FFFBEB; border-left-color: var(--orange-400); }
.ok-log   { background: #F0FDF4; border-left-color: var(--green-500); }
.info-log { background: var(--blue-50); border-left-color: var(--sky-400); }

.log-icon { font-size: 1rem; flex-shrink: 0; }
.log-msg { font-size: 0.75rem; font-weight: 600; color: var(--text-primary); }
.log-time { font-size: 0.62rem; color: var(--text-muted); margin-top: 2px; font-weight: 500; }

/* ======================================================
   ALERTS SECTION
   ====================================================== */
.alerts-list { display: flex; flex-direction: column; gap: 10px; }

.alert-card {
  background: var(--surface);
  border-radius: var(--radius-md);
  padding: 15px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  transition: var(--transition);
  border-left: 4px solid transparent;
}

.alert-card:hover { transform: translateX(4px); box-shadow: var(--shadow-md); }

.alert-card.alert-success { border-left-color: var(--green-500); }
.alert-card.alert-warning { border-left-color: var(--orange-400); }
.alert-card.alert-danger  { border-left-color: var(--red-500); }
.alert-card.alert-info    { border-left-color: var(--sky-400); }

.alert-icon {
  width: 40px; height: 40px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
}

.alert-success .alert-icon { background: #DCFCE7; }
.alert-warning .alert-icon { background: #FEF3C7; }
.alert-danger  .alert-icon { background: #FEE2E2; }
.alert-info    .alert-icon { background: #E0F2FE; }

.alert-content { flex: 1; min-width: 0; }

.alert-title { font-size: 0.82rem; font-weight: 700; color: var(--text-primary); margin-bottom: 2px; }
.alert-desc  { font-size: 0.68rem; color: var(--text-secondary); font-weight: 400; }
.alert-time  { font-size: 0.6rem; color: var(--text-muted); font-weight: 500; margin-top: 4px; }

.alert-arrow {
  color: var(--text-muted);
  flex-shrink: 0;
  font-size: 1rem;
}

/* ======================================================
   SETTINGS SECTION
   ====================================================== */
.settings-card { padding: 18px; }
.settings-group-title { font-size: 0.85rem; font-weight: 700; color: var(--text-primary); margin-bottom: 16px; }

.settings-item { margin-bottom: 16px; }
.settings-item:last-child { margin-bottom: 0; }

.si-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.si-label { font-size: 0.78rem; font-weight: 600; color: var(--text-primary); }
.si-val   { font-size: 0.78rem; font-weight: 800; color: var(--sky-600); }
.si-desc  { font-size: 0.65rem; color: var(--text-secondary); margin-top: 2px; }

.toggle-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.ti-info { flex: 1; }

/* Range input */
.range-input {
  width: 100%;
  -webkit-appearance: none;
  height: 5px;
  border-radius: 999px;
  background: var(--border);
  outline: none;
  cursor: pointer;
}

.range-input::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--sky-500);
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(14,165,233,0.35);
  transition: box-shadow 0.2s;
}

.range-input::-webkit-slider-thumb:hover {
  box-shadow: 0 3px 12px rgba(14,165,233,0.5);
}

/* Toggle */
.toggle-wrap { cursor: pointer; flex-shrink: 0; }

.toggle-track {
  width: 46px; height: 26px;
  border-radius: 999px;
  background: var(--border);
  position: relative;
  transition: background 0.25s;
}

.toggle-track.active { background: linear-gradient(135deg, var(--sky-400), var(--sky-600)); }

.toggle-thumb {
  position: absolute;
  top: 3px; left: 3px;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.toggle-track.active .toggle-thumb { transform: translateX(20px); }

/* Select */
.select-input {
  width: 100%;
  padding: 9px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-primary);
  cursor: pointer;
  transition: var(--transition);
}

.select-input:focus { border-color: var(--sky-400); box-shadow: 0 0 0 3px rgba(56,189,248,0.15); }

/* Battery bar */
.battery-bar-bg {
  height: 6px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
  margin-top: 6px;
}

.battery-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--sky-400), var(--green-500));
  border-radius: 999px;
}

.green-val { color: var(--green-600) !important; }

/* Hardware rows */
.hw-row {
  display: flex;
  justify-content: space-between;
  padding: 10px 0;
  border-top: 1px solid var(--border);
}

.hw-key { font-size: 0.72rem; color: var(--text-secondary); font-weight: 500; }
.hw-val { font-size: 0.73rem; font-weight: 700; color: var(--text-primary); }

/* Remote Control Card */
.remote-card { padding: 18px; }

.remote-info {
  display: flex;
  gap: 16px;
  margin-bottom: 16px;
}

.safety-checks { flex: 1; }
.sc-title { font-size: 0.7rem; font-weight: 700; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 10px; }

.sc-item {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.sc-icon {
  width: 20px; height: 20px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.65rem;
  font-weight: 800;
  flex-shrink: 0;
}

.sc-icon.ok { background: #DCFCE7; color: var(--green-600); }
.sc-icon.fail { background: #FEE2E2; color: var(--red-500); }

.sc-text { font-size: 0.7rem; color: var(--text-primary); font-weight: 500; }

.remote-level-wrap { flex-shrink: 0; text-align: center; width: 80px; }
.remote-level-label { font-size: 0.6rem; color: var(--text-muted); font-weight: 500; margin-bottom: 4px; }
.remote-level-val { font-size: 1.5rem; font-weight: 900; color: var(--sky-600); }

.remote-mini-bar-bg {
  height: 6px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
  margin-top: 6px;
}

.remote-mini-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--sky-400), var(--green-400));
  border-radius: 999px;
  transition: width 0.5s ease;
}

.remote-actions { display: flex; gap: 10px; }

/* ======================================================
   BOTTOM NAV
   ====================================================== */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 520px;
  height: var(--nav-height);
  background: rgba(255,255,255,0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: 0 4px;
  z-index: 200;
  box-shadow: 0 -4px 24px rgba(14,35,60,0.08);
}

.nav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 8px 4px;
  background: none;
  color: var(--text-muted);
  transition: var(--transition);
  border-radius: var(--radius-sm);
  position: relative;
}

.nav-btn span {
  font-size: 0.6rem;
  font-weight: 600;
  letter-spacing: 0.2px;
}

.nav-btn:hover { color: var(--sky-500); }

.nav-btn.active { color: var(--sky-600); }

.nav-btn.active svg { stroke: var(--sky-600); }

.nav-btn.active::before {
  content: '';
  position: absolute;
  top: 0; left: 50%;
  transform: translateX(-50%);
  width: 24px; height: 3px;
  background: var(--sky-500);
  border-radius: 0 0 3px 3px;
}

/* ======================================================
   MODAL
   ====================================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,0.45);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.modal-box {
  background: var(--surface);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  padding: 24px 20px 32px;
  width: 100%;
  max-width: 520px;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
}

.modal-overlay.open .modal-box { transform: translateY(0); }

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.modal-icon { font-size: 2rem; }

.modal-close {
  background: var(--bg);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.8rem;
  cursor: pointer;
  transition: var(--transition);
}

.modal-close:hover { background: var(--border); }

.modal-title { font-size: 1.15rem; font-weight: 800; color: var(--text-primary); margin-bottom: 8px; }

.modal-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 700;
  margin-bottom: 14px;
}

.modal-body { font-size: 0.82rem; color: var(--text-secondary); line-height: 1.6; margin-bottom: 12px; }
.modal-time { font-size: 0.7rem; color: var(--text-muted); font-weight: 500; margin-bottom: 18px; }

.modal-dismiss {
  width: 100%;
  padding: 14px;
  font-size: 0.88rem;
}

/* ======================================================
   TOAST
   ====================================================== */
.toast {
  position: fixed;
  bottom: calc(var(--nav-height) + 14px);
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--text-primary);
  color: #fff;
  padding: 10px 20px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  z-index: 998;
  opacity: 0;
  transition: opacity 0.25s, transform 0.25s;
  white-space: nowrap;
  pointer-events: none;
  box-shadow: var(--shadow-lg);
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ======================================================
   DESKTOP RESPONSIVE
   ====================================================== */
@media (min-width: 540px) {
  .main-content { padding: 20px 20px calc(var(--nav-height) + 16px); }
}

@media (min-width: 768px) {
  #app { max-width: 720px; box-shadow: var(--shadow-lg); min-height: 100vh; }

  .hero-card-inner { gap: 28px; }
  .tank-visual-wrap { width: 160px; height: 160px; }
  .tank-ring, .tank-svg { width: 160px; height: 160px; }
  .tank-percent { font-size: 2.2rem; }

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

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

  .bar-chart-wrap { height: 140px; }
}

@media (min-width: 1024px) {
  body { background: linear-gradient(135deg, #E0F2FE 0%, #F0F6FF 50%, #ECFDF5 100%); }
  #app { max-width: 480px; }
}
