/* Visual refresh + new components. Loads after app.css */

@import url("https://fonts.googleapis.com/css2?family=Nunito:wght@500;600;700;800&family=Noto+Sans+Devanagari:wght@500;700&display=swap");

:root {
  font-family: Nunito, "Noto Sans Devanagari", "Segoe UI", sans-serif;
}

body {
  background:
    radial-gradient(900px 500px at 10% -10%, #d7ece6 0%, transparent 55%),
    radial-gradient(700px 400px at 100% 100%, #e8dcc4 0%, transparent 50%),
    #dfe8e3;
}

.phone {
  border: 11px solid #142428;
  box-shadow:
    0 8px 0 #0c1c20,
    0 30px 70px rgba(12, 48, 56, 0.28);
}

.status-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #cfe4df;
  padding: 4px 6px 6px;
}
.status-bar .bat {
  width: 22px;
  height: 10px;
  border: 1.5px solid #cfe4df;
  border-radius: 3px;
  position: relative;
}
.status-bar .bat::after {
  content: "";
  position: absolute;
  inset: 1px 6px 1px 1px;
  background: #7dcea0;
  border-radius: 1px;
}

.top {
  background:
    linear-gradient(180deg, #0e3a40 0%, var(--navy) 100%);
  padding: 22px 16px 12px;
}

.logo {
  background: linear-gradient(145deg, #2aa89a, #14645e);
}

.hero-dose {
  position: relative;
  overflow: hidden;
  padding: 16px 16px 18px;
  background:
    radial-gradient(120px 80px at 92% -10%, rgba(196, 154, 74, 0.35), transparent 70%),
    linear-gradient(160deg, #12383f 0%, #0c3038 55%, #145c58 140%);
}
.hero-dose h2 { font-size: 26px; font-weight: 800; }
.kicker {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255,255,255,0.1);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 700;
  color: #e4f3ee;
  margin-bottom: 8px;
}
.hero-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 10px;
}
.hero-actions .btn { min-height: 46px; font-size: 13px; }
.hero-dose .btn.ghost {
  border-color: rgba(255,255,255,0.32);
  color: #f4faf8;
  background: rgba(255,255,255,0.08);
}
.hero-dose .btn.soft {
  background: #e8f3f0;
  color: #145c58;
}
.app.elder .hero-actions .btn { min-height: 52px; font-size: 15px; }

.quick {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}
.quick button {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 10px 6px;
  min-height: 72px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
  color: var(--teal-deep);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.quick button svg { width: 22px; height: 22px; }
.quick button.on { background: var(--soft); border-color: var(--teal); }

.slot-h {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--teal-deep);
  margin: 4px 2px 8px;
}
.slot-h::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

.dose-item {
  grid-template-columns: 36px 1fr auto;
  padding: 10px 0;
}
.dose-ico {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 800;
  color: #fff;
}

.card {
  box-shadow: 0 1px 0 rgba(12, 48, 56, 0.04);
}

.btn {
  transition: transform 0.12s ease, filter 0.12s ease;
}
.btn:active { transform: scale(0.98); }
.btn.primary { background: linear-gradient(180deg, #21958c, #1b7d76); }
.btn.gold { background: linear-gradient(180deg, #d4b05c, #c49a4a); }

.nav {
  background: rgba(255, 252, 246, 0.92);
  backdrop-filter: blur(8px);
}
.nav button.on {
  color: var(--teal-deep);
}
.nav button.on svg {
  stroke-width: 2.2;
}
.nav button.on span {
  position: relative;
}
.nav button.on::before {
  content: "";
  width: 18px;
  height: 3px;
  border-radius: 99px;
  background: var(--gold);
  position: absolute;
  top: 4px;
}

.viewfinder {
  height: 236px;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.08);
}
.frame {
  border: 0;
  box-shadow:
    inset 18px 18px 0 -14px #a8d5ce,
    inset -18px 18px 0 -14px #a8d5ce,
    inset 18px -18px 0 -14px #a8d5ce,
    inset -18px -18px 0 -14px #a8d5ce;
  animation: pulse 1.8s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 0.7; }
  50% { opacity: 1; }
}

.scan-dock {
  position: sticky;
  bottom: 0;
  padding-top: 8px;
  background: linear-gradient(180deg, transparent, var(--cream) 30%);
}

.search {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 14px;
  padding: 11px 12px;
  margin-bottom: 10px;
  min-height: 46px;
}

.week {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  margin-top: 10px;
}
.week i {
  display: block;
  height: 46px;
  border-radius: 8px;
  background: #e4f6ea;
  position: relative;
}
.week i::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: var(--h, 70%);
  background: var(--teal);
  border-radius: 8px;
  opacity: 0.85;
}
.week b { display: block; text-align: center; font-size: 10px; color: var(--muted); margin-top: 4px; }

.overlay {
  animation: fade 0.2s ease;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.sheet {
  animation: up 0.24s ease;
}
@keyframes up { from { transform: translateY(24px); } to { transform: translateY(0); } }
.grab {
  width: 40px;
  height: 4px;
  border-radius: 99px;
  background: #d5dfdb;
  margin: 0 auto 12px;
}

.choice-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 8px;
}
.choice {
  text-align: left;
  border: 1.5px solid var(--line);
  background: #fff;
  border-radius: 14px;
  padding: 12px 10px;
  min-height: 52px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  color: var(--ink);
}
.choice.on {
  background: var(--soft);
  border-color: var(--teal);
  color: var(--teal-deep);
}
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  font-weight: 700;
  color: var(--teal-deep);
  margin: 10px 0;
}
.field input, .field select {
  font: inherit;
  font-weight: 600;
  color: var(--ink);
  border: 1.5px solid var(--line);
  background: #fff;
  border-radius: 14px;
  padding: 12px 12px;
  min-height: 52px;
}
.field input:focus {
  outline: 2px solid var(--teal);
  border-color: var(--teal);
}
.setup {
  position: relative;
  inset: auto;
  flex: 1;
  min-height: 0;
  height: 100%;
  z-index: 1;
  background: var(--cream);
  color: var(--ink);
  display: flex;
  flex-direction: column;
  padding: 28px 16px 14px;
}
.login-app { background: var(--cream); }
.login-toast { bottom: 84px; }
.setup h2 { font-size: 24px; line-height: 1.2; margin: 4px 0 8px; letter-spacing: -0.02em; }
.setup .kicker {
  background: var(--soft);
  color: var(--teal-deep);
}
.setup-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  font-weight: 800;
  color: var(--teal-deep);
}
.text-btn {
  border: 0;
  background: none;
  color: var(--teal);
  font-weight: 800;
  cursor: pointer;
  font-size: 12px;
}
.setup-scroll { flex: 1; min-height: 0; overflow: auto; padding-bottom: 24px; }
.setup-foot {
  flex: 0 0 auto;
  padding-top: 10px;
  background: var(--cream);
  z-index: 1;
}
.dots { display: flex; gap: 6px; margin: 16px 0; }
.dots i { width: 8px; height: 8px; border-radius: 50%; background: #3d5c62; }
.dots i.on { background: var(--gold); width: 18px; border-radius: 99px; }

.success {
  text-align: center;
  padding: 12px 8px 8px;
}
.check-burst {
  width: 84px;
  height: 84px;
  margin: 8px auto 12px;
  border-radius: 50%;
  background: #e4f6ea;
  color: var(--ok);
  display: grid;
  place-items: center;
  animation: pop 0.35s ease;
}
@keyframes pop { from { transform: scale(0.7); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.pin-row { display: flex; justify-content: center; gap: 10px; margin: 16px 0; }
.pin-row i {
  width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid var(--teal);
}
.pin-row i.on { background: var(--teal); }
.pad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.pad button {
  min-height: 52px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: #fff;
  font-weight: 800;
  cursor: pointer;
}

.call-card { text-align: center; }
.call-avatar {
  width: 72px; height: 72px; border-radius: 24px;
  margin: 8px auto 10px;
  display: grid; place-items: center;
  color: #fff; font-weight: 800; font-size: 22px;
  background: #1b7d76;
}
.ring { animation: ring 1.2s ease-in-out infinite; }
@keyframes ring { 50% { transform: scale(1.04); } }

.tip {
  background: #fff;
  border-left: 4px solid var(--gold);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 13px;
  margin-bottom: 12px;
  color: var(--ink);
}

.app.night {
  --cream: #12262a;
  --ivory: #183035;
  --card: #1b3338;
  --ink: #eef6f3;
  --muted: #b7c9c4;
  --line: #2c4a50;
  background: #12262a;
  color: var(--ink);
}
.app.night .nav { background: #183035; border-top-color: #2c4a50; }
.app.night .btn.ghost { color: #eef6f3; border-color: #3a5a60; }
.app.night .sample, .app.night .quick button, .app.night .search, .app.night .tabs button, .app.night .cell, .app.night .chip {
  background: #1b3338;
  color: #eef6f3;
  border-color: #2c4a50;
}
.app.night .tabs button.on { background: #a8d5ce; color: #0c3038; }

.switch { transition: background 0.15s ease; }
.switch i { transition: left 0.15s ease; }

.toast {
  animation: up 0.2s ease;
}

.judge {
  padding-right: 8px;
}
.judge h1 { font-family: Nunito, sans-serif; }

.content { scroll-behavior: smooth; }

.back {
  width: 40px;
  min-height: 40px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #fff;
  margin-bottom: 10px;
  cursor: pointer;
  font-weight: 800;
}

.prog-mini {
  height: 6px;
  background: #e4ece9;
  border-radius: 99px;
  overflow: hidden;
  width: 64px;
}
.prog-mini > i { display: block; height: 100%; background: var(--teal); }

.family-card span:nth-child(2),
.med-row span,
.dose-item div {
  min-width: 0;
}
.who, .med-row strong, .family-card strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.content, .setup-scroll, .sheet {
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}
.app { overscroll-behavior: none; }

@media (max-width: 1100px) and (min-width: 861px) {
  .stage { gap: 16px; padding: 12px 14px; }
  .judge { width: 280px; flex-basis: 280px; }
}

@media (max-width: 860px) {
  html, body, .stage {
    height: 100%;
    height: 100dvh;
    height: 100svh;
    max-height: 100dvh;
  }
  body {
    background: var(--cream);
  }
  .stage {
    display: block;
    padding: 0;
    gap: 0;
  }
  .judge { display: none !important; }
  .phone-wrap {
    width: 100%;
    height: 100%;
    display: block;
  }
  .phone {
    width: 100% !important;
    max-width: 100%;
    height: 100% !important;
    border: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
  }
  .notch,
  .status-bar { display: none !important; }
  .app, .login-app {
    width: 100%;
    height: 100%;
    min-height: 100%;
  }
  .top {
    padding-top: calc(12px + env(safe-area-inset-top, 0px));
    padding-left: calc(16px + env(safe-area-inset-left, 0px));
    padding-right: calc(16px + env(safe-area-inset-right, 0px));
  }
  .content {
    padding-left: calc(14px + env(safe-area-inset-left, 0px));
    padding-right: calc(14px + env(safe-area-inset-right, 0px));
    padding-bottom: calc(18px + env(safe-area-inset-bottom, 0px));
  }
  .nav {
    padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
    min-height: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px));
  }
  .setup {
    padding-top: calc(16px + env(safe-area-inset-top, 0px));
    padding-left: calc(16px + env(safe-area-inset-left, 0px));
    padding-right: calc(16px + env(safe-area-inset-right, 0px));
  }
  .setup-foot {
    padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
  }
  .sheet {
    padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  }
  .toast {
    left: calc(16px + env(safe-area-inset-left, 0px));
    right: calc(16px + env(safe-area-inset-right, 0px));
    bottom: calc(var(--nav-h) + 12px + env(safe-area-inset-bottom, 0px));
  }
  .login-toast {
    bottom: calc(84px + env(safe-area-inset-bottom, 0px));
  }
  .scan-dock {
    padding-bottom: 4px;
  }
  .hero-dose h2 { font-size: clamp(22px, 6.4vw, 26px); }
  .setup h2 { font-size: clamp(22px, 6vw, 24px); }
  .overlay { position: fixed; }
}

@media (max-width: 400px) {
  .quick { gap: 6px; }
  .quick button {
    min-height: 64px;
    font-size: 11px;
    padding: 8px 4px;
  }
  .hero-actions .btn { font-size: 12px; padding: 10px 8px; }
  .content { padding-left: 12px; padding-right: 12px; }
  .tabs button { font-size: 11px; padding: 8px 4px; }
  .choice { font-size: 12px; padding: 10px 8px; }
  .box-grid { grid-template-columns: 44px repeat(3, 1fr); font-size: 10px; }
}

@media (max-width: 340px) {
  .grid2, .choice-grid, .quick, .hero-actions {
    grid-template-columns: 1fr;
  }
  .quick button { min-height: 52px; flex-direction: row; justify-content: flex-start; padding: 10px 12px; }
}

@media (max-width: 860px) and (max-height: 520px) and (orientation: landscape) {
  .viewfinder { height: 132px; }
  .hero-dose { padding: 12px; }
  .hero-dose h2 { font-size: 20px; margin: 4px 0 8px; }
  .quick button { min-height: 48px; }
  .setup h2 { font-size: 20px; }
  .nav button { min-height: 44px; padding: 6px 2px; }
}

@media (min-width: 861px) and (min-height: 920px) {
  .phone {
    width: min(430px, 42vw);
    height: min(900px, calc(100dvh - 32px));
  }
}
