:root{
  --green:#245b35; --green2:#3f7a45; --light:#f4f8ef; --cream:#fff9ed;
  --card:#fff; --text:#1d2b1f; --muted:#697566; --border:#dce8d5; --orange:#d9822b;
  --shadow:0 10px 26px rgba(0,0,0,.12);
}
*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0; font-family:"Segoe UI",Arial,sans-serif; color:var(--text);
  background:linear-gradient(135deg,#eef7e9,#fff9ed);
  -webkit-font-smoothing:antialiased;
}

/* ===== Responsive frame: phone-first, device frame on desktop ===== */
.device{ min-height:100dvh; display:flex; justify-content:center; align-items:stretch; }
.app{
  width:100%; max-width:480px; background:var(--light);
  display:flex; flex-direction:column; position:relative;
  min-height:100dvh; overflow:hidden;
}
@media(min-width:820px){
  .device{ align-items:center; padding:24px; }
  .app{
    height:840px; min-height:0; border-radius:32px;
    box-shadow:var(--shadow); border:10px solid #111;
  }
}

/* ===== Header ===== */
.app-header{ background:var(--green); color:#fff; padding:14px 16px 14px; }
.header-top{ display:flex; align-items:center; gap:10px; }
.logo{ width:34px; height:34px; background:#fff; border-radius:8px; padding:3px; }
.header-titles{ flex:1; min-width:0; }
.clinic{ font-size:14px; font-weight:700; line-height:1.2; }
.doctor{ font-size:11px; opacity:.9; margin-top:2px; }
.icon-btn{ background:rgba(255,255,255,.15); border:0; color:#fff; font-size:18px;
  width:36px; height:36px; border-radius:10px; cursor:pointer; }
.title{ font-size:20px; font-weight:700; margin-top:10px; }
.header-controls{ display:flex; justify-content:space-between; gap:8px; margin-top:10px; flex-wrap:wrap; }
.lang-switch,.role-switch{ display:flex; gap:6px; align-items:center; }
.role-label{ font-size:10px; opacity:.85; margin-right:2px; }
.lang-switch button,.role-switch button{
  border:1px solid rgba(255,255,255,.6); background:rgba(255,255,255,.12);
  color:#fff; border-radius:999px; padding:5px 10px; font-size:11px; cursor:pointer;
}
.lang-switch button.active,.role-switch button.active{ background:#fff; color:var(--green); font-weight:700; }

/* ===== Content ===== */
.content{ flex:1; overflow-y:auto; padding:14px; -webkit-overflow-scrolling:touch; }

/* ===== Cards ===== */
.card{ background:var(--card); border:1px solid var(--border); border-radius:16px;
  padding:14px; margin-bottom:12px; box-shadow:0 3px 10px rgba(0,0,0,.04); }
.op-card{ background:#fff8e8; border:1px solid #e9c97f; }
.op-number{ font-size:24px; color:var(--green); font-weight:800; letter-spacing:.5px; margin-top:4px; }
.card-title{ font-weight:700; color:var(--green); margin-bottom:8px; font-size:15px; }
.row{ display:flex; justify-content:space-between; gap:10px; margin:6px 0; font-size:13px; }
.label{ color:var(--muted); }
.value{ font-weight:700; text-align:right; }
.muted-note{ color:var(--muted); font-size:13px; }
.med-note,.med-item .med-note{ font-size:12px; color:var(--muted); margin:6px 0 0; }

/* progress bar */
.progress{ height:8px; background:#e8f3e4; border-radius:99px; margin-top:8px; overflow:hidden; }
.progress-bar{ height:100%; background:var(--green); border-radius:99px; }

/* pills */
.pill{ display:inline-block; padding:5px 9px; border-radius:20px; background:#e8f3e4;
  color:var(--green); font-size:12px; margin:3px 3px 3px 0; }
.pill.orange{ background:#fff0df; color:#a95716; }
.pill.red{ background:#ffe9e7; color:#a4342a; }

/* chips (multi select) */
.chips{ display:flex; flex-wrap:wrap; gap:8px; }
.chip{ border:1px solid var(--border); background:#fff; color:var(--text);
  border-radius:999px; padding:7px 12px; font-size:13px; cursor:pointer; }
.chip.on{ background:var(--green); color:#fff; border-color:var(--green); }

/* buttons */
.btn{ display:block; width:100%; border:0; background:var(--green); color:#fff;
  border-radius:12px; padding:12px; font-size:14px; margin-top:10px; cursor:pointer; }
.btn.light{ background:#e7f2e2; color:var(--green); }
.btn.orange{ background:var(--orange); }
.btn.small{ width:auto; padding:7px 12px; font-size:12px; margin:0; }

/* forms */
.field{ margin-bottom:10px; }
.field label{ display:block; font-size:12px; color:var(--muted); margin-bottom:4px; font-weight:700; }
input,select,textarea{ width:100%; border:1px solid var(--border); border-radius:10px;
  padding:10px; font-size:13px; font-family:inherit; background:#fff; color:var(--text); }
textarea{ min-height:64px; resize:vertical; }
.switch-row{ display:flex; align-items:center; gap:8px; font-size:13px; margin:8px 0; }
.switch-row input{ width:auto; }

/* doctor-only banner */
.doctor-only{ background:#fff4f4; border-left:4px solid #b14136; padding:10px;
  border-radius:10px; font-size:12px; margin-bottom:10px; color:#7a241e; }

/* medicine items */
.med-item{ border:1px solid var(--border); border-radius:12px; padding:10px; margin-bottom:10px; }
.med-head{ display:flex; justify-content:space-between; align-items:center; }
.refill-row{ display:flex; justify-content:space-between; align-items:center; gap:8px;
  margin-top:8px; font-size:12px; color:var(--muted); flex-wrap:wrap; }

/* install button */
.install-btn{ position:absolute; right:14px; bottom:72px; background:var(--orange);
  color:#fff; border:0; border-radius:999px; padding:10px 16px; font-size:13px;
  box-shadow:var(--shadow); cursor:pointer; z-index:20; }

/* bottom nav */
.bottom-nav{ height:60px; background:#fff; border-top:1px solid var(--border);
  display:grid; grid-template-columns:repeat(4,1fr); }
.nav-item{ background:none; border:0; display:flex; flex-direction:column;
  align-items:center; justify-content:center; gap:2px; font-size:11px; color:var(--muted); cursor:pointer; }
.nav-item .ic{ font-size:18px; }
.nav-item.active{ color:var(--green); font-weight:700; }

/* menu drawer */
.menu-overlay{ position:absolute; inset:0; background:rgba(0,0,0,.4); opacity:0;
  pointer-events:none; transition:.2s; z-index:30; }
.menu-overlay.show{ opacity:1; pointer-events:auto; }
.menu{ position:absolute; top:0; right:0; height:100%; width:74%; max-width:300px;
  background:#fff; box-shadow:var(--shadow); transform:translateX(100%);
  transition:.25s; z-index:40; display:flex; flex-direction:column; padding:12px; overflow-y:auto; }
.menu.open{ transform:translateX(0); }
.menu-head{ font-weight:800; color:var(--green); font-size:18px; padding:8px 6px 12px; border-bottom:1px solid var(--border); margin-bottom:8px; }
.menu button{ text-align:left; background:none; border:0; padding:12px 8px; font-size:14px;
  color:var(--text); border-radius:10px; cursor:pointer; display:flex; justify-content:space-between; }
.menu button:hover{ background:var(--light); }
.menu button.active{ background:#e7f2e2; color:var(--green); font-weight:700; }
.lock.hidden{ display:none; }
.hidden{ display:none !important; }

/* toast */
#toast{ position:fixed; left:50%; bottom:90px; transform:translateX(-50%) translateY(20px);
  background:#1d2b1f; color:#fff; padding:10px 16px; border-radius:999px; font-size:13px;
  opacity:0; pointer-events:none; transition:.25s; z-index:9999; max-width:90%; text-align:center; }
#toast.show{ opacity:1; transform:translateX(-50%) translateY(0); }
