/* ===== Tokens ===== */
:root {
  --teal: #0f6b5c;
  --teal-dark: #0a4f44;
  --teal-pale: #e8f2ef;
  --bg: #f6f7f6;
  --card: #ffffff;
  --ink: #1c2522;
  --ink-soft: #5b6b66;
  --border: #e1e6e3;
  --amber: #b6772b;
  --amber-bg: #fbf1e4;
  --red: #ad2b22;
  --red-bg: #fbe9e7;
  --radius: 14px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  --font-mono: "SF Mono", "Menlo", "Consolas", monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;
}
button, input { font-family: inherit; }

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

.hidden { display: none !important; }

/* ===== Centered auth/lock screens ===== */
.screen-center {
  flex: 1; display: flex; flex-direction: column; justify-content: center;
  padding: 1.75rem; gap: 1.25rem;
}
.brand { text-align: center; margin-bottom: .5rem; }
.brand-mark {
  width: 56px; height: 56px; border-radius: 14px; background: var(--teal);
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 1.3rem; margin: 0 auto .75rem;
}
.brand h1 { font-size: 1.05rem; margin: 0; color: var(--teal-dark); }
.brand p { font-size: .8rem; color: var(--ink-soft); margin: .2rem 0 0; }

.field { display: flex; flex-direction: column; gap: .4rem; }
.field label { font-size: .8rem; color: var(--ink-soft); }
.field input {
  padding: .75rem .85rem; border: 1px solid var(--border); border-radius: 10px;
  font-size: 1rem; background: var(--card);
}
.field input:focus { outline: 2px solid var(--teal); outline-offset: 1px; }

.btn-primary {
  background: var(--teal); color: #fff; border: none; padding: .8rem;
  border-radius: 10px; font-size: 1rem; font-weight: 600; cursor: pointer;
}
.btn-primary:active { background: var(--teal-dark); }
.btn-secondary {
  background: transparent; color: var(--teal-dark); border: none;
  padding: .5rem; font-size: .85rem; cursor: pointer; text-decoration: underline;
}
.btn-text { background: none; border: none; color: var(--teal-dark); font-size: .85rem; cursor: pointer; padding: .4rem; }

.form-error { background: var(--red-bg); color: var(--red); padding: .6rem .8rem; border-radius: 8px; font-size: .85rem; margin: 0; }
.form-info { background: var(--teal-pale); color: var(--teal-dark); padding: .6rem .8rem; border-radius: 8px; font-size: .85rem; margin: 0; }

/* ===== PIN pad ===== */
.pin-dots { display: flex; justify-content: center; gap: .6rem; margin: .5rem 0; }
.pin-dot { width: 14px; height: 14px; border-radius: 50%; border: 1.5px solid var(--teal); background: transparent; }
.pin-dot.filled { background: var(--teal); }
.pin-pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: .6rem; max-width: 280px; margin: 0 auto; }
.pin-key {
  aspect-ratio: 1; border-radius: 50%; border: 1px solid var(--border); background: var(--card);
  font-size: 1.3rem; font-weight: 500; cursor: pointer; color: var(--ink);
}
.pin-key:active { background: var(--teal-pale); }
.pin-key.pin-action { border: none; background: none; font-size: .85rem; color: var(--ink-soft); }

/* ===== App shell: top bar + tab bar ===== */
.top-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: .85rem 1rem; background: var(--card); border-bottom: 1px solid var(--border);
}
.top-bar h1 { font-size: 1rem; margin: 0; color: var(--teal-dark); }
.top-bar .top-bar-sub { font-size: .7rem; color: var(--ink-soft); }

.view { flex: 1; overflow-y: auto; padding: 1rem; padding-bottom: 5.5rem; }

.tab-bar {
  position: fixed; bottom: 0; left: 0; right: 0; max-width: 480px; margin: 0 auto;
  display: flex; background: var(--card); border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
.tab-btn {
  flex: 1; border: none; background: none; padding: .6rem 0 .5rem; display: flex;
  flex-direction: column; align-items: center; gap: .15rem; color: var(--ink-soft); font-size: .68rem;
  cursor: pointer;
}
.tab-btn .tab-icon { font-size: 1.1rem; }
.tab-btn.active { color: var(--teal-dark); font-weight: 600; }

/* ===== Search / drug list ===== */
.search-box {
  padding: .75rem .9rem; border: 1px solid var(--border); border-radius: 12px;
  background: var(--card); width: 100%; font-size: 1rem; margin-bottom: .9rem;
}
.obat-card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: .9rem 1rem; margin-bottom: .65rem; cursor: pointer;
}
.obat-card h3 { margin: 0 0 .2rem; font-size: .95rem; }
.obat-card .obat-sub { font-size: .78rem; color: var(--ink-soft); }
.kategori-pill {
  display: inline-block; font-size: .65rem; padding: .1rem .5rem; border-radius: 999px;
  background: var(--teal-pale); color: var(--teal-dark); margin-top: .35rem;
}

/* ===== Calculator forms ===== */
.calc-section { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; margin-bottom: 1rem; }
.calc-section h2 { font-size: .85rem; color: var(--teal-dark); margin: 0 0 .8rem; text-transform: uppercase; letter-spacing: .04em; }
.calc-row { display: flex; flex-direction: column; gap: .35rem; margin-bottom: .8rem; }
.calc-row label { font-size: .82rem; color: var(--ink-soft); }
.calc-row input, .calc-row select {
  padding: .65rem .75rem; border: 1px solid var(--border); border-radius: 9px; font-size: 1rem;
}

.result-box { background: var(--teal-pale); border-radius: 12px; padding: 1rem; margin-top: .5rem; }
.result-headline { font-size: 1.4rem; font-weight: 700; color: var(--teal-dark); font-family: var(--font-mono); }
.result-sub { font-size: .8rem; color: var(--ink-soft); margin-top: .2rem; }
.formula-steps { margin-top: .7rem; font-size: .8rem; color: var(--ink-soft); font-family: var(--font-mono); line-height: 1.55; }

.alert { border-radius: 10px; padding: .65rem .8rem; font-size: .82rem; margin-top: .6rem; }
.alert-amber { background: var(--amber-bg); color: var(--amber); }
.alert-red { background: var(--red-bg); color: var(--red); font-weight: 600; }

/* ===== Racikan cart ===== */
.racikan-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: .6rem 0; border-bottom: 1px solid var(--border); font-size: .85rem;
}
.racikan-item button { border: none; background: none; color: var(--red); font-size: .85rem; cursor: pointer; }

/* ===== Signature element: resep card (prescription pad look) ===== */
.resep-card {
  background: #fffdf8;
  border: 1px dashed #c8b89a;
  border-radius: 4px;
  padding: 1.1rem 1.1rem 1.3rem;
  font-family: var(--font-mono);
  font-size: .82rem;
  line-height: 1.7;
  position: relative;
  margin-top: .75rem;
}
.resep-card::before {
  content: "Rx";
  position: absolute; top: -14px; left: 14px; background: var(--bg);
  padding: 0 .4rem; font-weight: 700; color: var(--teal-dark); font-size: 1rem;
}
.resep-card .resep-line { white-space: pre-wrap; }
.resep-card .resep-divider { border-top: 1px dashed #c8b89a; margin: .6rem 0; }

@media (prefers-reduced-motion: no-preference) {
  .view { scroll-behavior: smooth; }
}
