/* ===================================================================
   CHS DIRECTORATE REPORTING SYSTEM
   Design tokens + base styles
   Palette: warm clinical orange, paired with a deep teal accent and
   a warm paper background (kept off pure-white to reduce phone glare).
   =================================================================== */

:root {
  /* --- Color tokens --- */
  --color-bg: #FBF4EC;
  --color-surface: #FFFFFF;
  --color-surface-alt: #FFF6EC;
  --color-primary: #E2672B;
  --color-primary-dark: #B94E1E;
  --color-primary-darker: #8F3B16;
  --color-primary-light: #F7D9BD;
  --color-primary-tint: #FCEADC;
  --color-teal: #2F6F62;
  --color-teal-tint: #E3EFEC;
  --color-danger: #C23B22;
  --color-danger-tint: #FBE7E1;
  --color-ink: #20242B;
  --color-ink-soft: #5C6470;
  --color-ink-faint: #8C93A0;
  --color-border: #ECE0D2;
  --color-border-strong: #DFCBAE;

  /* --- Type --- */
  --font-base: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;

  /* --- Radius / shadow --- */
  --radius-lg: 22px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --shadow-card: 0 10px 28px -8px rgba(143, 59, 22, 0.18);
  --shadow-soft: 0 2px 10px rgba(32, 36, 43, 0.06);

  /* --- Layout --- */
  --max-width: 480px;
  --topbar-height: 58px;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-base);
  background: var(--color-bg);
  color: var(--color-ink);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

button, input, select, textarea {
  font-family: inherit;
}

a {
  color: var(--color-primary-dark);
}

/* ===================== App shell ===================== */

#app {
  max-width: var(--max-width);
  margin: 0 auto;
  min-height: 100vh;
  background: var(--color-bg);
  position: relative;
  display: flex;
  flex-direction: column;
}

.screen {
  display: none;
  flex-direction: column;
  flex: 1;
  min-height: 100vh;
  animation: screen-in 0.22s ease;
}

.screen.active {
  display: flex;
}

@keyframes screen-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  .screen { animation: none; }
}

/* ===================== Top bar (native-app style) ===================== */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 8px 0 4px;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
}

.topbar-back {
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: var(--color-primary-dark);
  border-radius: 50%;
  flex: none;
  transition: background 0.15s ease;
}

.topbar-back:active {
  background: var(--color-primary-tint);
}

.topbar-back svg {
  width: 22px;
  height: 22px;
}

.topbar-title {
  font-size: 16.5px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--color-ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar-title small {
  display: block;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--color-ink-faint);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ===================== Scrollable content area ===================== */

.content {
  flex: 1;
  padding: 18px 18px 110px;
}

.content--narrow {
  padding-left: 16px;
  padding-right: 16px;
}

/* ===================== HOME screen ===================== */

.home-screen {
  justify-content: space-between;
  background: linear-gradient(180deg, #FFFDFA 0%, var(--color-bg) 55%);
}

.home-hero {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 32px 28px 8px;
}

.home-logo-ring {
  position: relative;
  width: 168px;
  height: 168px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 26px;
}

.home-logo-ring::before,
.home-logo-ring::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  border: 1.5px solid var(--color-primary-light);
}

.home-logo-ring::before {
  width: 168px;
  height: 168px;
}

.home-logo-ring::after {
  width: 138px;
  height: 138px;
  border-style: dashed;
  border-color: var(--color-primary-light);
  animation: spin-slow 50s linear infinite;
}

@media (prefers-reduced-motion: reduce) {
  .home-logo-ring::after { animation: none; }
}

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

.home-logo-badge {
  width: 112px;
  height: 112px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--color-surface);
  box-shadow: var(--shadow-card);
  display: flex;
  align-items: center;
  justify-content: center;
}

.home-logo-badge svg {
  width: 64px;
  height: 64px;
}

.home-logo-badge img {
  width: 132%;
  height: 132%;
  object-fit: cover;
}

.home-title {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.01em;
  line-height: 1.25;
  margin: 0 0 8px;
  color: var(--color-ink);
}

.home-title span {
  color: var(--color-primary-dark);
}

.home-subtitle {
  font-size: 14.5px;
  color: var(--color-ink-soft);
  margin: 0;
  max-width: 280px;
}

.home-credit {
  font-size: 13px;
  color: var(--color-ink-faint);
  margin-top: 18px;
  letter-spacing: 0.01em;
}

.home-credit strong {
  color: var(--color-ink-soft);
  font-weight: 600;
}

.home-bottom {
  padding: 0 24px 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.home-footer {
  text-align: center;
  font-size: 11.5px;
  color: var(--color-ink-faint);
  padding: 14px 0 22px;
  letter-spacing: 0.02em;
}

/* ===================== Buttons ===================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  border: none;
  border-radius: var(--radius-md);
  padding: 16px 20px;
  font-size: 15.5px;
  font-weight: 700;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease, opacity 0.12s ease;
  -webkit-tap-highlight-color: transparent;
}

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

.btn-primary {
  background: linear-gradient(180deg, var(--color-primary) 0%, var(--color-primary-dark) 100%);
  color: #fff;
  box-shadow: 0 10px 22px -8px rgba(185, 78, 30, 0.55);
}

.btn-primary svg {
  width: 18px;
  height: 18px;
}

.btn-secondary {
  background: var(--color-surface);
  color: var(--color-primary-dark);
  border: 1.5px solid var(--color-border-strong);
}

.btn-block {
  margin-top: 10px;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

/* Sticky bottom action bar used on forms */
.action-bar {
  position: sticky;
  bottom: 0;
  z-index: 15;
  padding: 12px 18px calc(14px + env(safe-area-inset-bottom));
  background: linear-gradient(180deg, rgba(251,244,236,0) 0%, var(--color-bg) 38%);
}

.action-bar-inner {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 10px;
  box-shadow: 0 -4px 24px rgba(32,36,43,0.08);
}

/* ===================== Desk / menu cards ===================== */

.menu-eyebrow {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-primary-dark);
  margin: 4px 0 4px;
}

.menu-heading {
  font-size: 21px;
  font-weight: 800;
  letter-spacing: -0.01em;
  margin: 0 0 4px;
}

.menu-sub {
  font-size: 14px;
  color: var(--color-ink-soft);
  margin: 0 0 20px;
}

.card-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.desk-card {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  text-align: left;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-left: 4px solid var(--color-primary);
  border-radius: var(--radius-md);
  padding: 16px 14px;
  box-shadow: var(--shadow-soft);
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.desk-card:active {
  transform: scale(0.98);
}

.desk-card--teal { border-left-color: var(--color-teal); }
.desk-card--disabled {
  border-left-color: var(--color-border-strong);
  opacity: 0.62;
  cursor: default;
}

.desk-card--disabled:active { transform: none; }

.desk-icon {
  width: 46px;
  height: 46px;
  flex: none;
  border-radius: 13px;
  background: var(--color-primary-tint);
  display: flex;
  align-items: center;
  justify-content: center;
}

.desk-icon svg {
  width: 24px;
  height: 24px;
  color: var(--color-primary-dark);
}

.desk-card--teal .desk-icon {
  background: var(--color-teal-tint);
}
.desk-card--teal .desk-icon svg {
  color: var(--color-teal);
}

.desk-icon--muted {
  background: #EFEAE1;
}
.desk-icon--muted svg {
  color: var(--color-ink-faint);
}

.desk-text {
  flex: 1;
  min-width: 0;
}

.desk-name {
  font-size: 15.5px;
  font-weight: 700;
  color: var(--color-ink);
  margin: 0 0 2px;
}

.desk-desc {
  font-size: 12.5px;
  color: var(--color-ink-soft);
  margin: 0;
  line-height: 1.35;
}

.desk-chevron {
  width: 20px;
  height: 20px;
  flex: none;
  color: var(--color-ink-faint);
}

.badge-soon {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-ink-faint);
  background: #EFEAE1;
  border-radius: 6px;
  padding: 2px 6px;
  margin-top: 4px;
}

/* Grid of small icon buttons (HAI surveillance submenu) */
.icon-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.icon-tile {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 18px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  text-align: center;
  cursor: pointer;
  box-shadow: var(--shadow-soft);
  transition: transform 0.12s ease;
}

.icon-tile:active { transform: scale(0.97); }

.icon-tile--disabled {
  opacity: 0.55;
  cursor: default;
}
.icon-tile--disabled:active { transform: none; }

.icon-tile-badge {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: var(--color-primary-tint);
  display: flex;
  align-items: center;
  justify-content: center;
}

.icon-tile-badge svg {
  width: 26px;
  height: 26px;
  color: var(--color-primary-dark);
}

.icon-tile-name {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--color-ink);
}

.icon-tile-full {
  font-size: 10.5px;
  color: var(--color-ink-soft);
  line-height: 1.3;
}

/* ===================== Forms ===================== */

.field-group {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 14px;
  margin-bottom: 14px;
}

.field-group-title {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-primary-dark);
  margin: 0 0 12px;
}

.field {
  margin-bottom: 12px;
}

.field:last-child { margin-bottom: 0; }

.field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--color-ink-soft);
  margin-bottom: 6px;
}

.field-row {
  display: flex;
  gap: 10px;
}

.field-row > .field {
  flex: 1;
  min-width: 0;
}

input[type="text"],
input[type="number"],
input[type="date"],
select,
textarea {
  width: 100%;
  border: 1.5px solid var(--color-border-strong);
  background: var(--color-surface-alt);
  border-radius: var(--radius-sm);
  padding: 11px 12px;
  font-size: 15px;
  color: var(--color-ink);
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}

textarea {
  resize: vertical;
  min-height: 64px;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-tint);
}

.hint {
  font-size: 11.5px;
  color: var(--color-ink-faint);
  margin-top: 5px;
  line-height: 1.35;
}

/* Yes/No segmented control */
.seg {
  display: flex;
  border: 1.5px solid var(--color-border-strong);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.seg button {
  flex: 1;
  border: none;
  background: var(--color-surface-alt);
  padding: 10px 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--color-ink-soft);
  cursor: pointer;
}

.seg button + button {
  border-left: 1.5px solid var(--color-border-strong);
}

.seg button.active {
  background: var(--color-primary);
  color: #fff;
}

/* ===================== Indicator accordion (weekly form) ===================== */

.week-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.week-meta .field--full {
  grid-column: 1 / -1;
}

.indicator-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  margin-bottom: 10px;
  overflow: hidden;
}

.indicator-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 14px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.indicator-sn {
  flex: none;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--color-primary-tint);
  color: var(--color-primary-dark);
  font-size: 12.5px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
}

.indicator-titles {
  flex: 1;
  min-width: 0;
}

.indicator-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--color-ink);
  line-height: 1.3;
}

.indicator-hint {
  font-size: 11px;
  color: var(--color-ink-faint);
  margin-top: 2px;
  line-height: 1.3;
}

.indicator-total {
  flex: none;
  font-size: 12px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--color-teal);
  background: var(--color-teal-tint);
  border-radius: 8px;
  padding: 4px 8px;
  white-space: nowrap;
}

.indicator-total.is-zero {
  color: var(--color-ink-faint);
  background: #F1ECE3;
}

.indicator-chevron {
  flex: none;
  width: 18px;
  height: 18px;
  color: var(--color-ink-faint);
  transition: transform 0.15s ease;
}

.indicator-card.open .indicator-chevron {
  transform: rotate(180deg);
}

.indicator-body {
  display: none;
  padding: 0 14px 16px;
  border-top: 1px solid var(--color-border);
}

.indicator-card.open .indicator-body {
  display: block;
  padding-top: 12px;
}

.day-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  margin-bottom: 10px;
}

.day-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.day-cell span {
  font-size: 10px;
  font-weight: 700;
  color: var(--color-ink-faint);
  text-transform: uppercase;
}

.day-cell input {
  width: 100%;
  padding: 8px 2px;
  text-align: center;
  font-size: 13.5px;
  font-variant-numeric: tabular-nums;
  border-radius: 8px;
}

/* ===================== Misc ===================== */

.section-note {
  background: var(--color-primary-tint);
  border: 1px solid var(--color-primary-light);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 12.5px;
  color: var(--color-primary-darker);
  line-height: 1.45;
  margin-bottom: 16px;
}

.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px 30px;
  gap: 14px;
}

.empty-state svg {
  width: 56px;
  height: 56px;
  color: var(--color-primary-light);
}

.empty-state h3 {
  font-size: 17px;
  margin: 0;
}

.empty-state p {
  font-size: 13.5px;
  color: var(--color-ink-soft);
  margin: 0;
  max-width: 260px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%) translateY(20px);
  background: var(--color-ink);
  color: #fff;
  padding: 13px 20px;
  border-radius: 14px;
  font-size: 13.5px;
  font-weight: 600;
  box-shadow: 0 14px 30px rgba(0,0,0,0.25);
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 86%;
}

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

.toast svg { width: 18px; height: 18px; flex: none; }
.toast--error { background: var(--color-danger); }
.toast--success { background: var(--color-teal); }

.success-screen {
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px 30px;
  gap: 16px;
  flex: 1;
}

.success-icon {
  width: 84px;
  height: 84px;
  border-radius: 50%;
  background: var(--color-teal-tint);
  display: flex;
  align-items: center;
  justify-content: center;
}

.success-icon svg {
  width: 42px;
  height: 42px;
  color: var(--color-teal);
}

.spinner {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.4);
  border-top-color: #fff;
  animation: spin 0.7s linear infinite;
}

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

/* Scrollbar tidy-up (desktop testing) */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-thumb { background: var(--color-border-strong); border-radius: 4px; }

/* Hand Hygiene Compliance — overall summary banner */
.hh-overall {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 12px;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  background: var(--color-teal-tint);
  border: 1px solid var(--color-teal);
}

.hh-overall-label {
  font-size: 14px;
  font-weight: 700;
  color: var(--color-teal);
}

.hh-overall-value {
  font-size: 20px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--color-teal);
}

.hh-overall-value.is-zero {
  color: var(--color-ink-faint);
}
