/* ==========================================================================
   VBD Surveillance — Government of Nepal reporting system
   Design tokens carried over verbatim from the approved prototype:
   crimson #dc143c / #c8102e (dengue, notices), Nepal blue #003893 (chrome,
   scrub typhus), paper #eef1f6. Type: Source Sans 3 + Noto Sans Devanagari
   + IBM Plex Mono for all figures.
   ========================================================================== */

:root {
  --blue:        #003893;
  --blue-dark:   #002a6e;
  --blue-darker: #002d75;
  --blue-tint:   #e6ecf7;
  --blue-soft:   #b8c5e2;
  --crimson:     #dc143c;
  --dengue:      #c8102e;
  --dengue-soft: #f2b6c1;
  --maroon:      #8f1a2b;
  --paper:       #eef1f6;
  --card:        #ffffff;
  --line:        #dfe3ea;
  --line-soft:   #eef0f5;
  --line-mid:    #e5e9f0;
  --ink:         #1b1f2a;
  --ink-2:       #22283a;
  --ink-3:       #333c4d;
  --ink-4:       #4d5768;
  --muted:       #5a6478;
  --muted-2:     #6f7889;
  --muted-3:     #7d879b;
  --muted-4:     #8e97a9;
  --field:       #fbfcfe;
  --field-line:  #d3d9e3;
  --ok:          #1c5e42;
  --ok-bg:       #eef5f0;
  --ok-line:     #cfe3d7;
  --warn:        #8a5b0f;
  --warn-bg:     #fdf7ea;
  --warn-line:   #f0e0bd;
  --err:         #b3261e;
  --err-bg:      #fdf0f1;
  --err-line:    #f6d5d8;
  --err-ink:     #99202e;
  --mono:        'IBM Plex Mono', ui-monospace, monospace;
  --ne:          'Noto Sans Devanagari', sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--paper);
  color: var(--ink);
  font-family: 'Source Sans 3', system-ui, -apple-system, sans-serif;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--blue); text-decoration: none; }
a:hover { color: var(--blue-dark); text-decoration: underline; }
.ne { font-family: var(--ne); }
.mono { font-family: var(--mono); }

input, select, textarea, button { font-family: inherit; font-size: inherit; color: inherit; }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible {
  outline: 2px solid var(--blue); outline-offset: 1px;
}
/* 44px minimum touch target throughout — this is used one-handed on a phone
   at a health post, often outdoors. */
input, select, textarea { min-height: 44px; padding: 10px 11px; border: 1px solid var(--field-line);
  border-radius: 2px; background: var(--field); font-size: 14px; width: 100%; }
textarea { resize: vertical; min-height: 62px; }
input.num { font-family: var(--mono); font-size: 15px; }
input.err, select.err { border-color: var(--err); }
/* Checkboxes must escape the full-width field styling above. */
input[type="checkbox"] {
  width: 20px; height: 20px; min-height: 0; padding: 0;
  flex: 0 0 auto; accent-color: var(--blue); cursor: pointer;
}
input:disabled, select:disabled, textarea:disabled {
  background: #f1f3f7; color: var(--muted-3); cursor: not-allowed;
}
.nilbox {
  display: flex; align-items: flex-start; gap: 11px; padding: 13px 15px;
  border: 1px solid var(--warn-line); background: var(--warn-bg); border-radius: 2px; cursor: pointer;
}
.nilbox.on { border-color: var(--blue); background: var(--blue-tint); }

/* Tick-box group for a disease whose combo test can be positive on more than
   one marker at once (see DISEASES.*.multiTestType). */
.checkrow {
  display: flex; flex-wrap: wrap; gap: 8px 18px; padding: 11px 12px;
  border: 1px solid var(--field-line); border-radius: 2px; background: var(--field);
}
.checkrow.err { border-color: var(--err); }
.chk { display: flex; align-items: center; gap: 7px; font-size: 14px; cursor: pointer; min-height: 32px; }

/* ------------------------------------------------------------- chrome -- */
.flagbar { height: 5px; background: var(--crimson); }

.util {
  background: var(--blue-dark); color: #c3cfe6; padding: 6px 28px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; font-size: 12px; flex-wrap: wrap;
}
.util .sep { color: #7f93bd; }

.masthead {
  background: var(--card); padding: 14px 28px; border-bottom: 3px solid var(--blue);
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
}
.masthead img { width: 56px; height: 56px; flex: 0 0 auto; object-fit: contain; }
.masthead .ministry { font-family: var(--ne); font-size: 12.5px; color: var(--maroon); font-weight: 600; }
.masthead .title { font-size: 19px; font-weight: 700; color: var(--blue); line-height: 1.25; margin-top: 2px; }
.masthead .office { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.masthead .right { margin-left: auto; text-align: right; font-size: 12.5px; color: var(--muted); line-height: 1.6; }
.pill {
  display: inline-block; padding: 4px 10px; border-radius: 2px; background: var(--blue-tint);
  color: var(--blue-dark); font-weight: 600; font-size: 11.5px; letter-spacing: .06em; text-transform: uppercase;
}

.notice {
  background: var(--err-bg); border-bottom: 1px solid var(--err-line); padding: 9px 28px;
  font-size: 13px; color: var(--maroon); display: flex; align-items: center; gap: 10px;
}
.notice .tag {
  flex: 0 0 auto; padding: 2px 8px; background: var(--crimson); color: #fff;
  font-size: 10.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; border-radius: 2px;
}

.shell { display: flex; align-items: flex-start; background: var(--paper); }

/* -------------------------------------------------------------- side -- */
.side {
  width: 246px; flex: 0 0 auto; position: sticky; top: 0; min-height: 100vh;
  background: var(--card); border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
}
.side-head {
  padding: 13px 20px 11px; background: var(--blue); color: #fff;
  font-size: 11px; letter-spacing: .14em; text-transform: uppercase; font-weight: 600;
}
.side-head span { font-family: var(--ne); letter-spacing: 0; text-transform: none; color: var(--blue-soft); font-weight: 400; }
.nav { display: flex; flex-direction: column; gap: 2px; padding: 14px 12px; }
.nav button {
  display: flex; align-items: center; gap: 10px; text-align: left; width: 100%;
  min-height: 44px; padding: 10px 12px; border: none; border-radius: 2px;
  cursor: pointer; background: transparent; color: var(--ink-3);
}
.nav button:hover { background: var(--line-soft); }
.nav button.on { background: var(--blue-tint); color: var(--blue-dark); }
.nav .dot { width: 6px; height: 6px; border-radius: 50%; flex: 0 0 auto; background: var(--muted-4); }
.nav .labels { display: flex; flex-direction: column; gap: 1px; min-width: 0; flex: 1; }
.nav .en { font-size: 14px; font-weight: 600; white-space: nowrap; }
.nav .np { font-family: var(--ne); font-size: 11px; opacity: .7; white-space: nowrap; }
.nav .chev { font-size: 11px; color: var(--muted-2); transition: transform .16s ease; }
.nav .chev.open { transform: rotate(180deg); }
.subnav {
  display: flex; flex-direction: column; gap: 2px;
  margin: 2px 0 4px 21px; padding-left: 11px; border-left: 1px solid var(--line);
}
.subnav .en { font-size: 13.5px; }
.side-foot { margin-top: auto; padding: 16px 20px 22px; border-top: 1px solid var(--line-soft); }

.lbl {
  display: block; font-size: 11px; letter-spacing: .1em; text-transform: uppercase;
  color: var(--muted-2); font-weight: 600; margin-bottom: 6px;
}
.lbl span { font-family: var(--ne); letter-spacing: 0; text-transform: none; font-weight: 400; color: var(--muted-4); }

/* -------------------------------------------------------------- main -- */
.main { flex: 1; min-width: 0; padding: 34px 40px 90px; }
h1.page { margin: 0; font-size: 27px; font-weight: 700; letter-spacing: -.01em; }
.page-sub { font-family: var(--ne); font-size: 14px; color: var(--muted); margin-top: 5px; }

.scopebar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding: 11px 16px;
  margin-bottom: 22px; background: var(--card); border: 1px solid var(--line);
  border-left: 4px solid var(--blue); border-radius: 3px;
}
.scopebar .k { font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted-2); }
.scopebar .v { font-size: 15px; font-weight: 700; color: var(--blue); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 3px; }
.card-head { padding: 12px 20px; background: var(--blue); color: #fff; }
.card-head .t { font-size: 15px; font-weight: 700; }
.card-head .n { font-family: var(--ne); font-size: 12px; opacity: .85; margin-top: 2px; }
.card-body { padding: 20px 22px 24px; display: flex; flex-direction: column; gap: 18px; }

.section-title { font-size: 13px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-3); }
.hint { font-size: 12.5px; color: var(--muted); line-height: 1.55; }

/* ------------------------------------------------------------ buttons -- */
.btn {
  min-height: 44px; padding: 10px 16px; border-radius: 2px; font-size: 14px;
  font-weight: 600; cursor: pointer; border: 1px solid var(--field-line);
  background: var(--card); color: var(--ink-3);
}
.btn:hover { background: var(--line-soft); }
.btn.primary { background: var(--blue); color: #fff; border-color: var(--blue); min-height: 48px; padding: 13px 24px; font-size: 15px; }
.btn.primary:hover { background: var(--blue-darker); }
.btn.ghost { border-color: var(--blue); color: var(--blue); }
.btn.ghost:hover { background: var(--blue); color: #fff; }
.btn.sm { min-height: 34px; padding: 6px 12px; font-size: 12.5px; }
.btn.on { background: var(--blue); color: #fff; border-color: var(--blue); }
.btn[disabled] { background: #9aa6bd; color: #fff; border-color: #9aa6bd; cursor: not-allowed; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* ------------------------------------------------------------- tables -- */
.tablewrap { overflow-x: auto; border: 1px solid var(--line-mid); border-radius: 3px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead tr { background: var(--blue); }
th { text-align: left; padding: 10px 12px; font-weight: 600; color: #fff; white-space: nowrap; }
th.r, td.r { text-align: right; }
th small { font-weight: 400; color: var(--blue-soft); font-size: 11px; display: block; }
tbody tr { border-bottom: 1px solid #f0f3f8; }
td { padding: 9px 12px; color: var(--ink-2); }
td.num { font-family: var(--mono); color: var(--ink-4); text-align: right; }
tr.total { background: var(--blue-tint); font-weight: 600; }
tr.total td { padding: 11px 12px; }

.chip { padding: 6px 11px; border-radius: 2px; font-size: 12.5px; display: inline-block; }
.chip.ok { background: var(--ok-bg); border: 1px solid var(--ok-line); color: var(--ok); }
.chip.no { background: var(--err-bg); border: 1px solid var(--err-line); color: var(--err-ink); }

.msg { padding: 9px 12px; border-radius: 2px; font-size: 12.5px; line-height: 1.5; }
.msg.ok   { background: var(--ok-bg);   border: 1px solid var(--ok-line);   color: var(--ok); }
.msg.warn { background: var(--warn-bg); border: 1px solid var(--warn-line); color: var(--warn); }
.msg.err  { background: var(--err-bg);  border: 1px solid var(--err-line);  color: var(--err); }

code {
  font-family: var(--mono); font-size: 11.5px; background: var(--line-soft);
  padding: 2px 5px; border-radius: 2px; word-break: break-word;
}
details summary::marker { color: var(--muted-3); }

/* --------------------------------------------------------- stat cards -- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(118px, 1fr)); gap: 1px; background: var(--line-soft); }
.stat { background: var(--card); padding: 16px 18px; }
.stat .v { font-family: var(--mono); font-size: 26px; font-weight: 600; letter-spacing: -.02em; }
.stat .l { font-size: 12px; font-weight: 600; color: var(--ink-3); margin-top: 6px; line-height: 1.35; }
.stat .n { font-family: var(--ne); font-size: 11px; color: var(--muted-3); line-height: 1.5; }

/* -------------------------------------------------------- epi curve --- */
.curve { display: flex; gap: 8px; }
.curve .yaxis {
  width: 26px; height: 132px; display: flex; flex-direction: column;
  justify-content: space-between; align-items: flex-end;
  font-family: var(--mono); font-size: 10px; color: var(--muted-4);
}
.curve .plot {
  flex: 1; min-width: 0; position: relative; height: 132px; display: flex;
  align-items: flex-end; gap: 3px; padding-bottom: 1px;
  border-bottom: 1px solid var(--line); border-left: 1px solid var(--line);
}
.curve .bar { flex: 1; min-width: 0; display: flex; align-items: flex-end; justify-content: center; height: 100%; }
.curve .bar i { display: block; width: 100%; }
.curve svg { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.ticks { display: flex; justify-content: space-between; margin: 7px 0 0 34px; font-size: 10.5px; color: var(--muted-4); font-family: var(--ne); }
.legend { display: flex; align-items: center; gap: 14px; margin-top: 10px; font-size: 11.5px; color: var(--muted-2); }
.legend span { display: flex; align-items: center; gap: 6px; }

.bar-track { height: 7px; border-radius: 2px; background: var(--line-soft); overflow: hidden; }
.bar-fill { height: 100%; background: var(--blue); }

/* ---------------------------------------------------------- form grid -- */
.grid { display: grid; gap: 12px; }
.g2 { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.g3 { grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); }
.g-wide { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.g-board { display: grid; grid-template-columns: repeat(auto-fit, minmax(520px, 1fr)); gap: 26px; align-items: start; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > .cap { font-size: 12.5px; font-weight: 600; color: var(--ink-3); }
.field > .cap span { font-family: var(--ne); font-weight: 400; color: var(--muted-3); }
.field .sub { font-size: 12.5px; color: var(--muted-3); }
.field .bs { font-family: var(--ne); font-size: 12.5px; color: var(--blue); }
.field .fe { font-size: 12px; color: var(--err); }

.totrow {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 12px; border-radius: 2px; background: #f2f5fa; border: 1px solid var(--line-soft);
}
.totrow .v { font-family: var(--mono); font-size: 19px; font-weight: 600; }

/* ---------------------------------------------------------- overlays --- */
.gate {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 24px; background: var(--paper);
}
.gate .box { width: 100%; max-width: 420px; background: var(--card); border: 1px solid var(--line); border-radius: 3px; overflow: hidden; }
.gate .box .top { height: 5px; background: var(--crimson); }
.gate .inner { padding: 26px 26px 30px; display: flex; flex-direction: column; gap: 16px; }
.gate img { width: 62px; height: 62px; object-fit: contain; align-self: center; }

.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%);
  z-index: 60; max-width: min(560px, 92vw); padding: 12px 18px; border-radius: 3px;
  font-size: 13.5px; line-height: 1.5; box-shadow: 0 6px 22px rgba(15, 25, 55, .22);
}
.toast.ok  { background: #14512f; color: #fff; }
.toast.err { background: #8f1a2b; color: #fff; }

.busy {
  position: fixed; inset: 0; z-index: 70; background: rgba(238, 241, 246, .72);
  display: flex; align-items: center; justify-content: center;
}
.busy .spin {
  width: 34px; height: 34px; border: 3px solid var(--blue-soft); border-top-color: var(--blue);
  border-radius: 50%; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Fallback shown when the browser blocks a file download (some embedded
   Apps Script frames do). The reporter can still copy the data out. */
.modal {
  position: fixed; inset: 0; z-index: 80; background: rgba(15, 25, 55, .5);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal .panel {
  background: var(--card); border-radius: 3px; width: 100%; max-width: 720px;
  max-height: 86vh; display: flex; flex-direction: column; overflow: hidden;
}
.modal .panel textarea { flex: 1; min-height: 260px; font-family: var(--mono); font-size: 12px; }

/* ------------------------------------------------------------ responsive */
@media (max-width: 900px) {
  .shell { flex-direction: column; }
  .side { width: auto; min-height: 0; position: static; border-right: none; border-bottom: 1px solid var(--line); }
  .nav { flex-direction: row; overflow-x: auto; padding: 8px; }
  .nav > * { flex: 0 0 auto; }
  .subnav { flex-direction: row; margin: 0; padding-left: 0; border-left: none; }
  .side-foot { padding: 12px 16px; }
  .main { padding: 18px 14px 60px; }
  .masthead { padding: 12px 14px; gap: 12px; }
  .masthead img { width: 44px; height: 44px; }
  .masthead .right { margin-left: 0; text-align: left; }
  .util, .notice { padding-left: 14px; padding-right: 14px; }
  .util { flex-direction: column; align-items: flex-start; gap: 3px; }
  .g-board { grid-template-columns: 1fr; gap: 18px; }
  /* iOS zooms the page if a focused field is under 16px. */
  input, select, textarea { font-size: 16px; }
}

@media print {
  .util, .side, .notice, .noprint, .toast { display: none !important; }
  .main { padding: 0 !important; }
  body { background: #fff; }
  .card, section, .stat { break-inside: avoid; }
}
