/* WCSH Monitoring System — Stylesheet v2.0 */
:root {
  --orange:      #E8650A;
  --orange-dark: #C2440A;
  --orange-deep: #7C2D12;
  --orange-lite: #FFF3EB;
  --green:       #16A34A;
  --green-lite:  #DCFCE7;
  --green-dark:  #166534;
  --red:         #DC2626;
  --red-lite:    #FEE2E2;
  --red-dark:    #991B1B;
  --yellow:      #CA8A04;
  --yellow-lite: #FEF9C3;
  --yellow-dark: #92400E;
  --g1: #F9FAFB; --g2: #F3F4F6; --g3: #E5E7EB;
  --g4: #9CA3AF; --g5: #6B7280; --g6: #374151; --g7: #111827;
  --white: #FFFFFF;
  --topbar-h: 60px;   /* exact topbar height — used for padding */
  --nav-h: 60px;
  --radius: 12px; --radius-sm: 8px;
  --shadow: 0 2px 10px rgba(0,0,0,0.08);
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; font-size: 15px; -webkit-font-smoothing: antialiased; }
body { font-family: 'Segoe UI', system-ui, -apple-system, sans-serif; background: var(--g1); color: var(--g7); }

/* ── APP SHELL ── */
#app { max-width: 430px; margin: 0 auto; min-height: 100vh; display: flex; flex-direction: column; }

/* ── TOP BAR ── */
.topbar {
  position: fixed;                          /* fixed so it never moves */
  top: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 430px;
  height: var(--topbar-h);
  z-index: 300;
  background: linear-gradient(135deg, var(--orange-deep) 0%, var(--orange-dark) 60%, var(--orange) 100%);
  display: flex; align-items: center; gap: 10px; padding: 0 14px;
  box-shadow: 0 2px 10px rgba(194,68,10,0.3);
}
.logo {
  width: 40px; height: 40px; border-radius: 50%; flex-shrink: 0;
  background: rgba(255,255,255,0.2); border: 2px solid rgba(255,255,255,0.4);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 800; color: #fff; letter-spacing: -0.5px;
}
.topbar-mid { flex: 1; min-width: 0; }
.topbar-title { color: #fff; font-size: 12px; font-weight: 700; line-height: 1.2; }
.topbar-sub   { color: rgba(255,255,255,0.75); font-size: 9px; margin-top: 1px; }
.topbar-right { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.week-tag { background: rgba(255,255,255,0.22); border-radius: 20px; padding: 2px 9px; color: #fff; font-size: 10px; font-weight: 600; }
.conn-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--g4); }
.conn-dot.ok  { background: #4ADE80; }
.conn-dot.err { background: var(--red); }

/* ── MAIN — pushed down by topbar height, up by nav height ── */
.main {
  flex: 1;
  margin-top: var(--topbar-h);     /* ← KEY FIX: content starts below fixed topbar */
  padding-bottom: var(--nav-h);
  overflow-y: auto;
}

/* ── PAGES ── */
.page { display: none; }
.page.active { display: block; }

/* ── HERO ── */
.hero {
  background: linear-gradient(135deg, var(--orange-deep), var(--orange-dark));
  padding: 18px 16px 20px; color: #fff;
}
.hero-greeting { font-size: 12px; opacity: .85; }
.hero-week     { font-size: 16px; font-weight: 700; margin-top: 3px; }

/* ── KPI ROW — lives AFTER hero, no overlap ── */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  padding: 12px 12px 0;
}
.kpi-card {
  background: var(--white);
  border-radius: var(--radius-sm);
  padding: 12px 6px 10px;
  box-shadow: var(--shadow);
  text-align: center;
}
.kpi-num { font-size: 26px; font-weight: 800; line-height: 1; }
.kpi-lbl { font-size: 9px; font-weight: 600; color: var(--g5); margin-top: 4px; text-transform: uppercase; letter-spacing: .3px; }

/* ── ALERT BAR ── */
.alert-bar {
  margin: 10px 12px 0;
  background: var(--red-lite); border: 1px solid rgba(220,38,38,.3);
  border-radius: var(--radius-sm); padding: 9px 12px;
  font-size: 11px; color: var(--red-dark); font-weight: 500; line-height: 1.5;
  display: flex; gap: 6px; align-items: flex-start;
}

/* ── SECTION HEADERS ── */
.sec-hd {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 12px 6px; font-size: 13px; font-weight: 700; color: var(--g6);
}
.link-btn { font-size: 11px; color: var(--orange); background: none; border: none; cursor: pointer; font-weight: 600; }

/* ── CARD STACK ── */
.card-stack { padding: 0 12px; display: flex; flex-direction: column; gap: 8px; }

/* Equipment card */
.eq-card {
  background: var(--white); border-radius: var(--radius); padding: 11px 13px;
  box-shadow: var(--shadow); display: flex; align-items: center; gap: 11px;
  border-left: 3px solid var(--g3);
}
.eq-card.ok   { border-left-color: var(--green); }
.eq-card.warn { border-left-color: var(--yellow); }
.eq-card.crit { border-left-color: var(--red); }
.eq-ico { width: 36px; height: 36px; border-radius: 9px; display: flex; align-items: center; justify-content: center; font-size: 17px; flex-shrink: 0; background: var(--g2); }
.eq-ico.ok   { background: var(--green-lite); }
.eq-ico.warn { background: var(--yellow-lite); }
.eq-ico.crit { background: var(--red-lite); }
.eq-info { flex: 1; min-width: 0; }
.eq-name   { font-size: 12px; font-weight: 600; }
.eq-detail { font-size: 10px; color: var(--g5); margin-top: 1px; }
.badge { font-size: 9px; padding: 3px 7px; border-radius: 20px; font-weight: 700; white-space: nowrap; }
.b-ok   { background: var(--green-lite); color: var(--green-dark); }
.b-warn { background: var(--yellow-lite); color: var(--yellow-dark); }
.b-crit { background: var(--red-lite); color: var(--red-dark); }

/* Backlog card */
.bl-card { background: var(--white); border-radius: var(--radius); padding: 11px 13px; box-shadow: var(--shadow); }
.bl-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 7px; }
.bl-name  { font-size: 12px; font-weight: 600; }
.bl-num   { font-size: 22px; font-weight: 800; color: var(--orange); }
.prog     { background: var(--g2); border-radius: 4px; height: 5px; overflow: hidden; }
.prog-fill{ height: 100%; border-radius: 4px; background: linear-gradient(90deg,var(--orange-dark),var(--orange)); transition: width .5s; }
.bl-meta  { display: flex; justify-content: space-between; margin-top: 4px; font-size: 10px; color: var(--g5); }

.placeholder { text-align: center; color: var(--g4); font-size: 12px; padding: 20px; }

/* ── REPORT TABS ── */
.tab-bar {
  display: flex; background: var(--white); border-bottom: 1px solid var(--g3);
  position: sticky; top: 0; z-index: 100;
}
.tab {
  flex: 1; padding: 12px 6px; font-size: 12px; font-weight: 600;
  color: var(--g5); border: none; background: none;
  border-bottom: 2.5px solid transparent; cursor: pointer;
}
.tab.active { color: var(--orange); border-bottom-color: var(--orange); }

/* ── FORM ── */
.form-wrap { padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.fcard { background: var(--white); border-radius: var(--radius); padding: 13px; box-shadow: var(--shadow); }
.fcard-hd {
  font-size: 10px; font-weight: 700; color: var(--orange-deep);
  text-transform: uppercase; letter-spacing: .5px;
  border-bottom: 1px solid var(--orange-lite); padding-bottom: 7px; margin-bottom: 11px;
}
.field { margin-bottom: 9px; }
.field:last-child { margin-bottom: 0; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.lbl { display: block; font-size: 11px; font-weight: 600; color: var(--g6); margin-bottom: 4px; }
.req { color: var(--red); }
.inp {
  width: 100%; border: 1.5px solid var(--g3); border-radius: var(--radius-sm);
  padding: 8px 10px; font-size: 13px; color: var(--g7); background: var(--white);
  outline: none; -webkit-appearance: none; appearance: none;
  transition: border-color .2s; font-family: inherit;
}
.inp:focus { border-color: var(--orange); }
textarea.inp { min-height: 68px; resize: vertical; }

/* Chips (radio buttons) */
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  padding: 6px 12px; border-radius: 20px; border: 1.5px solid var(--g3);
  font-size: 11px; font-weight: 600; color: var(--g5);
  background: var(--white); cursor: pointer; transition: all .18s;
}
.chip.on {
  border-color: var(--orange); background: var(--orange-lite); color: var(--orange-deep);
}

/* Equipment selector grid */
.eq-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.eq-opt {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 11px 6px; border-radius: var(--radius-sm);
  border: 1.5px solid var(--g3); background: var(--white);
  cursor: pointer; transition: all .18s;
}
.eq-opt.on { border-color: var(--orange); background: var(--orange-lite); }
.eq-opt .eo-icon { font-size: 20px; }
.eq-opt .eo-name { font-size: 10px; font-weight: 600; color: var(--g6); text-align: center; line-height: 1.3; }
.eq-opt.on .eo-name { color: var(--orange-deep); }

/* Submit button */
.submit-btn {
  width: 100%; background: linear-gradient(135deg, var(--orange-deep), var(--orange-dark));
  color: var(--white); border: none; border-radius: var(--radius);
  padding: 14px; font-size: 14px; font-weight: 700;
  cursor: pointer; box-shadow: 0 4px 14px rgba(194,68,10,.3);
  transition: transform .15s, opacity .15s; font-family: inherit;
}
.submit-btn:active   { transform: scale(.98); }
.submit-btn:disabled { opacity: .6; cursor: not-allowed; }

/* ── ANALYTICS ── */
.an-card { background: var(--white); border-radius: var(--radius); padding: 13px; box-shadow: var(--shadow); }
.an-title { font-size: 13px; font-weight: 700; color: var(--g7); margin-bottom: 12px; }
.stat-row3 { display: grid; grid-template-columns: repeat(3,1fr); gap: 8px; }
.stat-cell { background: var(--g1); border-radius: var(--radius-sm); padding: 10px 6px; text-align: center; }
.stat-val { font-size: 24px; font-weight: 800; }
.stat-lbl { font-size: 9px; color: var(--g5); margin-top: 2px; }
.prog-row { margin-bottom: 9px; }
.prog-row:last-child { margin-bottom: 0; }
.prog-lbl { display: flex; justify-content: space-between; font-size: 11px; margin-bottom: 3px; color: var(--g6); }

/* ── BOTTOM NAV ── */
.bottom-nav {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 430px; height: var(--nav-h);
  background: var(--white); border-top: .5px solid var(--g3);
  display: flex; z-index: 300;
  box-shadow: 0 -2px 10px rgba(0,0,0,.06);
}
.nav-btn {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; border: none; background: none; cursor: pointer; color: var(--g4);
}
.nav-btn.active { color: var(--orange); }
.ni { font-size: 20px; line-height: 1; }
.nl { font-size: 9px; font-weight: 600; }

/* ── TOAST ── */
.toast {
  position: fixed; bottom: 72px; left: 50%; transform: translateX(-50%) translateY(16px);
  background: var(--g7); color: #fff; padding: 10px 18px;
  border-radius: 30px; font-size: 13px; font-weight: 500;
  opacity: 0; pointer-events: none; z-index: 9999;
  white-space: nowrap; transition: all .25s ease;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.ok  { background: var(--green); }
.toast.err { background: var(--red); }
.toast.wrn { background: var(--yellow-dark); }

/* Safe area (iPhone notch) */
@supports (padding: env(safe-area-inset-bottom)) {
  .bottom-nav { padding-bottom: env(safe-area-inset-bottom); height: calc(var(--nav-h) + env(safe-area-inset-bottom)); }
}

/* Scrollbar */
.main::-webkit-scrollbar { width: 3px; }
.main::-webkit-scrollbar-thumb { background: var(--g3); border-radius: 3px; }