/* ============================================================
   ওষুধ সাথী — Design tokens & base
   ============================================================ */
:root {
  --teal-50: #f0fdfa; --teal-100: #ccfbf1; --teal-200: #99f6e4;
  --teal-500: #14b8a6; --teal-600: #0d9488; --teal-700: #0f766e;
  --teal-800: #115e59; --teal-900: #134e4a;
  --red-50: #fef2f2; --red-500: #ef4444; --red-600: #dc2626;
  --amber-50: #fffbeb; --amber-400: #fbbf24; --amber-500: #f59e0b; --amber-600: #d97706;
  --orange-50: #fff7ed; --orange-500: #f97316;
  --green-50: #f0fdf4; --green-500: #22c55e; --green-600: #16a34a;
  --slate-50: #f8fafc; --slate-100: #f1f5f9; --slate-200: #e2e8f0;
  --slate-300: #cbd5e1; --slate-400: #94a3b8; --slate-500: #64748b;
  --slate-600: #475569; --slate-700: #334155; --slate-800: #1e293b;
  --slate-900: #0f172a;

  --bg: #f8faf9; --surface: #fff; --text: var(--slate-800); --text-muted: var(--slate-500);
  --border: var(--slate-200); --primary: var(--teal-600); --primary-dark: var(--teal-700);
  --primary-light: var(--teal-100); --danger: var(--red-600); --danger-light: var(--red-50);
  --warn: var(--amber-500); --warn-light: var(--amber-50);
  --radius: 14px; --radius-sm: 10px; --shadow-sm: 0 1px 3px rgba(15,23,42,.06);
  --shadow: 0 4px 12px rgba(15,23,42,.08); --shadow-lg: 0 8px 24px rgba(15,23,42,.12);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --font: 'Noto Sans Bengali', system-ui, -apple-system, sans-serif;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-family: var(--font); font-size: 15px; line-height: 1.55; color: var(--text);
  background: var(--bg); -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent;
  scroll-behavior: smooth; }

body { min-height: 100dvh; padding-bottom: calc(72px + var(--safe-b)); overscroll-behavior-y: contain; }

img, svg { display: block; max-width: 100%; }

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

button, input, textarea, select { font: inherit; color: inherit; border: none; background: none; }

h1 { font-size: 1.45rem; font-weight: 700; }
h2 { font-size: 1.15rem; font-weight: 700; }
h3 { font-size: 1rem; font-weight: 600; }

.icon { width: 20px; height: 20px; flex-shrink: 0; vertical-align: middle; }

/* ============================================================
   Utilities
   ============================================================ */
.muted { color: var(--text-muted); }
.small { font-size: .82rem; }
.center { text-align: center; }
.opacity { opacity: .7; }
.mt { margin-top: 1rem; }
.grow { flex: 1; }
.ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row { display: flex; align-items: center; }
.between { justify-content: space-between; }
.gap { gap: .5rem; }
.stack { display: flex; flex-direction: column; gap: .5rem; }
.block { width: 100%; }

.enter { animation: fadeUp .25s ease-out; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } }

/* ============================================================
   Layout
   ============================================================ */
.app { max-width: 520px; margin: 0 auto; padding: 16px 16px 24px; }

.splash { display: flex; flex-direction: column; align-items: center; justify-content: center;
  height: 60dvh; gap: 1.5rem; }

.center-screen { display: flex; flex-direction: column; align-items: center;
  justify-content: center; min-height: 75dvh; gap: 1rem; width: 100%; }

.brand { display: flex; flex-direction: column; align-items: center; gap: .5rem; margin-bottom: .5rem; }
.brand.compact { gap: .25rem; margin-bottom: 0; }
.brand h1 { color: var(--primary-dark); letter-spacing: -.5px; }

/* ============================================================
   Top bar
   ============================================================ */
.top-bar { display: flex; align-items: center; gap: .5rem; margin-bottom: 1rem; padding: 4px 0; }
.top-bar h1 { flex: 1; min-width: 0; }
.icon-btn { display: flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: 50%; cursor: pointer; }
.icon-btn:hover { background: var(--slate-100); text-decoration: none; }
.icon-btn.placeholder { visibility: hidden; }

/* ============================================================
   Page header (dashboard)
   ============================================================ */
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.avatar { display: flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; border-radius: 50%; font-weight: 700; font-size: 1.1rem;
  color: #fff; background: var(--primary); cursor: pointer; text-decoration: none; }

/* ============================================================
   Patient card
   ============================================================ */
.patient-card { background: linear-gradient(135deg, var(--teal-700) 0%, var(--teal-600) 100%);
  border-radius: var(--radius); padding: 1.2rem 1.1rem; color: #fff; margin-bottom: 1rem; }
.patient-card h2 { font-size: 1.25rem; }
.patient-card .stats { display: flex; gap: 1.5rem; margin-top: .8rem; }
.patient-card .stats div { display: flex; flex-direction: column; }
.patient-card .stats strong { font-size: 1.35rem; }
.patient-card .stats span { font-size: .72rem; opacity: .85; }

/* ============================================================
   Banners
   ============================================================ */
.banner { display: flex; align-items: flex-start; gap: .75rem; padding: .9rem 1rem;
  border-radius: var(--radius-sm); margin-bottom: .75rem; font-size: .88rem; }
.banner > .icon { flex-shrink: 0; margin-top: 2px; }
.banner strong { display: block; }
.banner p { margin-top: 2px; opacity: .85; }
.banner.danger { background: var(--danger-light); color: var(--red-600); }
.banner.warn { background: var(--warn-light); color: var(--amber-600); }
.banner.info { background: var(--primary-light); color: var(--teal-800); cursor: pointer; }
.banner.info:hover { text-decoration: none; filter: brightness(.97); }
.banner .icon:last-child { margin-left: auto; margin-top: 6px; opacity: .5; }

/* ============================================================
   Cards
   ============================================================ */
.card { background: var(--surface); border-radius: var(--radius); padding: 1rem 1.1rem;
  box-shadow: var(--shadow-sm); margin-bottom: .75rem; border: 1px solid var(--border); }
.card-title { display: flex; align-items: center; gap: .4rem; margin-bottom: .75rem; }

.section-head { margin: 1.25rem 0 .5rem; }
.section-label { color: var(--text-muted); font-size: .82rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: .3px; margin: .75rem 0 .3rem; }
.section-label .tag { text-transform: none; }

/* ============================================================
   Medicine cards (list)
   ============================================================ */
.med-list { display: flex; flex-direction: column; gap: .5rem; }

.med-card { display: flex; gap: .75rem; padding: .9rem 1rem; background: var(--surface);
  border-radius: var(--radius-sm); border: 1px solid var(--border); box-shadow: var(--shadow-sm);
  text-decoration: none; color: inherit; transition: box-shadow .15s, border-color .15s; }
.med-card:hover { box-shadow: var(--shadow); border-color: var(--slate-300); text-decoration: none; }
.med-icon { display: flex; align-items: center; justify-content: center; width: 44px; height: 44px;
  border-radius: 12px; flex-shrink: 0; background: var(--teal-50); color: var(--primary); }
.med-body { flex: 1; min-width: 0; }
.med-name { font-size: .95rem; margin-right: .5rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.med-meta { font-size: .82rem; color: var(--text-muted); margin: 2px 0 6px; }
.med-meta strong { color: var(--text); }

.status-urgent .med-icon { background: var(--danger-light); color: var(--red-600); }
.status-reminder .med-icon { background: var(--orange-50); color: var(--orange-500); }
.status-low .med-icon { background: var(--amber-50); color: var(--amber-600); }
.status-paused .med-icon { background: var(--slate-100); color: var(--slate-400); }

/* ============================================================
   Pills / chips / tags
   ============================================================ */
.pill { display: inline-flex; align-items: center; padding: 2px 10px; border-radius: 99px;
  font-size: .72rem; font-weight: 600; white-space: nowrap; }
.pill.ok { background: var(--green-50); color: var(--green-600); }
.pill.low { background: var(--amber-50); color: var(--amber-600); }
.pill.reminder { background: var(--orange-50); color: var(--orange-500); }
.pill.urgent { background: var(--danger-light); color: var(--red-500); }
.pill.paused { background: var(--slate-100); color: var(--slate-500); }
.pill.sm { font-size: .68rem; padding: 1px 7px; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; padding: 4px 10px; border-radius: 8px;
  font-size: .78rem; background: var(--slate-100); color: var(--slate-600); white-space: nowrap; }
.btn-chip { cursor: pointer; border: 1px solid var(--border); background: var(--surface); }
.btn-chip:hover { background: var(--slate-100); }

.tag { display: inline-block; font-size: .7rem; padding: 1px 6px; border-radius: 4px;
  background: var(--slate-100); color: var(--slate-500); vertical-align: middle; font-weight: 500; }
.tag.ok { background: var(--green-50); color: var(--green-600); }

/* ============================================================
   Supply bar
   ============================================================ */
.bar { height: 6px; border-radius: 99px; background: var(--slate-100); overflow: hidden; }
.bar > span { display: block; height: 100%; border-radius: 99px; background: var(--green-500); transition: width .6s ease; }
.bar.lg { height: 10px; }
.status-low .bar > span { background: var(--amber-400); }
.status-reminder .bar > span { background: var(--orange-500); }
.status-urgent .bar > span { background: var(--red-500); }

/* ============================================================
   Hero (medicine detail)
   ============================================================ */
.hero { text-align: center; padding: 1.5rem 1rem; }
.hero .pill { margin-bottom: .5rem; }
.hero-qty { margin: .5rem 0 .25rem; }
.hero-qty strong { font-size: 2.5rem; line-height: 1; }
.hero-qty span { display: block; font-size: .82rem; color: var(--text-muted); }
.hero-days { font-size: .9rem; color: var(--text-muted); margin-bottom: .75rem; }

/* ============================================================
   Adjust row
   ============================================================ */
.adjust-row { display: flex; gap: .5rem; margin-bottom: .75rem; }
.adjust-btn { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: .75rem .5rem; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); font-size: .78rem; cursor: pointer; box-shadow: var(--shadow-sm); }
.adjust-btn .icon { width: 22px; height: 22px; }
.adjust-btn:hover { background: var(--slate-50); }
.adjust-btn.primary { background: var(--primary-light); color: var(--teal-800); border-color: var(--teal-200); }
.adjust-btn.primary:hover { background: var(--teal-200); }

/* ============================================================
   Schedule / threshold lists
   ============================================================ */
.schedule-list { list-style: none; }
.schedule-list li { display: flex; align-items: center; justify-content: space-between; gap: .5rem;
  padding: .5rem 0; border-bottom: 1px solid var(--slate-100); }
.schedule-list li:last-child { border: none; }
.total { margin-top: .5rem; padding-top: .5rem; border-top: 1px solid var(--border); }

.thresholds { display: flex; gap: .5rem; text-align: center; }
.thresholds .t { flex: 1; padding: .7rem .5rem; border-radius: var(--radius-sm); font-size: .78rem; }
.thresholds .t strong { display: block; font-size: 1.5rem; }
.t.low { background: var(--amber-50); color: var(--amber-600); }
.t.reminder { background: var(--orange-50); color: var(--orange-500); }
.t.urgent { background: var(--danger-light); color: var(--red-600); }

.notes { white-space: pre-wrap; word-break: break-word; font-size: .9rem; color: var(--slate-600); }

/* ============================================================
   Logs
   ============================================================ */
.log-list { list-style: none; }
.log-list li { display: flex; gap: .6rem; align-items: flex-start; padding: .55rem 0;
  border-bottom: 1px solid var(--slate-100); font-size: .85rem; }
.log-list li:last-child { border: none; }
.log-list.compact li { padding: .4rem 0; font-size: .8rem; }
.delta { display: inline-flex; align-items: center; justify-content: center; min-width: 54px;
  padding: 3px 8px; border-radius: 6px; font-weight: 600; font-size: .82rem; font-variant-numeric: tabular-nums; }
.delta.up { background: var(--green-50); color: var(--green-600); }
.delta.down { background: var(--danger-light); color: var(--red-500); }

/* ============================================================
   Forms
   ============================================================ */
.form { display: flex; flex-direction: column; gap: .6rem; }

.field { display: flex; flex-direction: column; gap: 3px; }
.field > span { font-size: .82rem; font-weight: 600; color: var(--slate-700); }
.field input, .field textarea, .field select {
  width: 100%; padding: .6rem .75rem; border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); font-size: .95rem; transition: border-color .15s; }
.field input:focus, .field textarea:focus, .field select:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(20,184,166,.12); }
.field textarea { resize: vertical; }
.hint { font-size: .76rem; color: var(--text-muted); }

.input-wrap { position: relative; display: flex; }
.input-wrap input { flex: 1; padding-right: 40px; }
.eye { position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  padding: 6px; cursor: pointer; font-size: 1.1rem; opacity: .5; }
.eye:hover { opacity: .8; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
.grid-2.wide-first { grid-template-columns: 2fr 1fr; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: .5rem; }

.error { color: var(--danger); background: var(--danger-light); padding: .6rem .75rem;
  border-radius: var(--radius-sm); font-size: .85rem; }

/* ============================================================
   Segmented tabs
   ============================================================ */
.segmented { display: flex; background: var(--slate-100); border-radius: var(--radius-sm);
  padding: 3px; margin-bottom: .75rem; width: 100%; max-width: 340px; }
.segmented button { flex: 1; padding: .5rem 1rem; border-radius: 8px; font-weight: 600;
  font-size: .9rem; cursor: pointer; transition: background .15s; }
.segmented button.active { background: var(--surface); box-shadow: var(--shadow-sm); color: var(--primary); }

/* ============================================================
   Lock badge (gate page)
   ============================================================ */
.lock-badge { display: flex; align-items: center; justify-content: center;
  width: 56px; height: 56px; border-radius: 16px; background: var(--primary-light);
  color: var(--primary); margin: 0 auto .5rem; }
.lock-badge .icon { width: 28px; height: 28px; }

/* ============================================================
   Toggle / switch
   ============================================================ */
.toggle-label { display: flex; align-items: center; gap: .6rem; padding: .5rem 0; cursor: pointer; font-size: .9rem; }
.toggle-label.highlight { background: var(--slate-50); padding: .7rem .75rem; border-radius: var(--radius-sm); margin-top: .25rem; }
.toggle-label input[type=checkbox] { display: none; }
.switch { position: relative; display: inline-block; width: 44px; height: 26px; flex-shrink: 0;
  background: var(--slate-300); border-radius: 99px; transition: background .2s; }
.switch::after { content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px;
  border-radius: 50%; background: #fff; box-shadow: var(--shadow-sm); transition: transform .2s; }
input:checked + .switch, input:checked ~ .switch { background: var(--primary); }
input:checked + .switch::after, input:checked ~ .switch::after { transform: translateX(18px); }

/* ============================================================
   Slots (form)
   ============================================================ */
.slots { display: flex; flex-direction: column; gap: .5rem; }
.slot { border: 1.5px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; transition: border-color .15s; }
.slot.on { border-color: var(--teal-200); }
.slot-toggle { display: flex; align-items: center; gap: .5rem; padding: .65rem .75rem; cursor: pointer; }
.slot-toggle input[type=checkbox] { display: none; }
.slot-emoji { font-size: 1.2rem; }
.slot-label { flex: 1; font-weight: 600; font-size: .9rem; }
.slot-detail { display: none; padding: 0 .75rem .75rem; }
.slot.on .slot-detail { display: flex; gap: .75rem; align-items: flex-end; }
.mini { display: flex; flex-direction: column; gap: 3px; font-size: .78rem; font-weight: 600; color: var(--slate-600); }
.mini input { padding: .4rem .5rem; border: 1.5px solid var(--border); border-radius: 8px; font-size: .88rem; width: 90px; }
.mini input:focus { outline: none; border-color: var(--primary); }

.stepper { display: flex; align-items: center; gap: 0; }
.stepper button { display: flex; align-items: center; justify-content: center; width: 34px; height: 34px;
  border: 1.5px solid var(--border); cursor: pointer; background: var(--slate-50); }
.stepper button:first-child { border-radius: 8px 0 0 8px; }
.stepper button:last-child { border-radius: 0 8px 8px 0; }
.stepper button:hover { background: var(--slate-200); }
.stepper button .icon { width: 16px; height: 16px; }
.stepper input { width: 52px; height: 34px; border: 1.5px solid var(--border); border-left: none; border-right: none;
  text-align: center; font-weight: 600; font-size: .9rem; padding: 0; }

.summary { padding: .6rem .75rem; background: var(--teal-50); border-radius: 8px; font-size: .85rem; margin-top: .5rem; }
.summary strong { color: var(--teal-800); }

.advanced { margin-top: .25rem; }
.advanced summary { cursor: pointer; font-size: .85rem; color: var(--text-muted); padding: .5rem 0; }

/* ============================================================
   Buttons
   ============================================================ */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  padding: .6rem 1.2rem; border-radius: var(--radius-sm); font-weight: 600; font-size: .9rem;
  cursor: pointer; transition: background .15s, box-shadow .15s; white-space: nowrap;
  -webkit-user-select: none; user-select: none; text-decoration: none; }
.btn:hover { text-decoration: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn .icon { width: 18px; height: 18px; }

.btn.primary { background: var(--primary); color: #fff; box-shadow: var(--shadow-sm); }
.btn.primary:hover:not(:disabled) { background: var(--primary-dark); box-shadow: var(--shadow); }
.btn.ghost { background: transparent; color: var(--slate-600); }
.btn.ghost:hover:not(:disabled) { background: var(--slate-100); }
.btn.danger { background: var(--danger); color: #fff; }
.btn.danger:hover:not(:disabled) { background: #b91c1c; }
.btn.danger-ghost { color: var(--danger); }
.btn.danger-ghost:hover:not(:disabled) { background: var(--danger-light); }
.btn.lg { padding: .75rem 1.5rem; font-size: .95rem; }
.btn.sm { padding: .4rem .8rem; font-size: .82rem; }

.sticky-actions { position: sticky; bottom: calc(72px + var(--safe-b) + 8px); z-index: 10;
  padding: .5rem 0; background: linear-gradient(to top, var(--bg) 60%, transparent); }

/* ============================================================
   Empty state
   ============================================================ */
.empty { display: flex; flex-direction: column; align-items: center; text-align: center;
  padding: 2rem 1rem; gap: .75rem; }
.empty .icon { width: 48px; height: 48px; color: var(--slate-300); }

/* ============================================================
   Tab bar
   ============================================================ */
.tabbar { position: fixed; bottom: 0; left: 0; right: 0; z-index: 100;
  display: flex; justify-content: center; align-items: flex-end;
  background: var(--surface); border-top: 1px solid var(--border); box-shadow: 0 -2px 8px rgba(15,23,42,.05);
  padding: 0 16px calc(var(--safe-b) + 2px); }
.tab { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  flex: 1; max-width: 120px; padding: 8px 0 4px; color: var(--slate-400); font-size: .68rem; font-weight: 600;
  text-decoration: none; transition: color .15s; }
.tab .icon { width: 22px; height: 22px; }
.tab.active { color: var(--primary); }
.tab:hover { color: var(--primary); text-decoration: none; }

.tab-add { position: relative; }
.tab-fab { display: flex; align-items: center; justify-content: center;
  width: 48px; height: 48px; border-radius: 50%; background: var(--primary); color: #fff;
  box-shadow: 0 4px 12px rgba(13,148,136,.35); margin-top: -22px; }
.tab-fab .icon { width: 24px; height: 24px; }
.tab-add.active .tab-fab { background: var(--primary-dark); }

/* ============================================================
   Toast
   ============================================================ */
.toast { position: fixed; bottom: calc(80px + var(--safe-b)); left: 50%; transform: translateX(-50%) translateY(20px);
  z-index: 200; padding: .6rem 1.2rem; border-radius: var(--radius-sm); font-size: .88rem; font-weight: 500;
  background: var(--slate-800); color: #fff; opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s; max-width: calc(100vw - 32px); text-align: center;
  box-shadow: var(--shadow-lg); }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); pointer-events: auto; }
.toast.success { background: var(--green-600); }
.toast.error { background: var(--red-600); }

/* ============================================================
   Sheet / bottom dialog
   ============================================================ */
.sheet-backdrop { position: fixed; inset: 0; z-index: 150; background: rgba(15,23,42,.35);
  display: flex; align-items: flex-end; justify-content: center;
  opacity: 0; transition: opacity .2s; }
.sheet-backdrop.open { opacity: 1; }
.sheet { width: 100%; max-width: 520px; max-height: 85dvh; overflow-y: auto;
  background: var(--surface); border-radius: var(--radius) var(--radius) 0 0;
  padding: 1rem 1.25rem calc(1rem + var(--safe-b));
  transform: translateY(100%); transition: transform .25s ease-out; }
.sheet-backdrop.open .sheet { transform: translateY(0); }
.sheet-handle { width: 36px; height: 4px; border-radius: 99px; background: var(--slate-300); margin: 0 auto .75rem; }
.sheet-title { margin-bottom: .75rem; }

/* ============================================================
   Spinner
   ============================================================ */
.spinner { width: 20px; height: 20px; border: 2.5px solid rgba(255,255,255,.3);
  border-top-color: #fff; border-radius: 50%; animation: spin .6s linear infinite; display: inline-block; }
.spinner.dark { border-color: var(--slate-200); border-top-color: var(--primary); width: 28px; height: 28px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   Offline bar
   ============================================================ */
.offline-bar { position: fixed; top: 0; left: 0; right: 0; z-index: 999;
  padding: 6px 16px; text-align: center; font-size: .78rem; font-weight: 600;
  background: var(--amber-400); color: var(--slate-900); }
.offline-bar:not([hidden]) ~ .app { padding-top: 40px; }

/* ============================================================
   Responsive
   ============================================================ */
@media (min-width: 600px) {
  html { font-size: 16px; }
  .app { padding: 24px 20px 32px; }
  .med-card { padding: 1rem 1.2rem; }
}

/* Reduce motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* Print */
@media print {
  .tabbar, .toast, .sheet-backdrop, .offline-bar, .adjust-row, .sticky-actions, button { display: none !important; }
  body { padding: 0; }
}

