/* ============================================================
   Multi-Language Pharmacy Label System — Apple HIG UI Design
   Standard Human Interface Guidelines (HIG) · SF Pro & Sarabun
   ============================================================ */

/* ============================================================
   Authentication Gate — Store Passcode Login
/* ============================================================
   Authentication Gate — Apple-Style Sign In Sheet
   Standard Apple HIG · Frosted Glass Acrylic & Clean Typography
   ============================================================ */
.auth-gate {
  position: fixed;
  inset: 0;
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.42);
  backdrop-filter: saturate(180%) blur(24px);
  -webkit-backdrop-filter: saturate(180%) blur(24px);
  padding: 20px;
  box-sizing: border-box;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Helvetica Neue", "Sarabun", sans-serif;
  transition: opacity 0.25s ease, visibility 0.25s ease;
  animation: authFadeIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}
.auth-gate.hidden {
  display: none !important;
  visibility: hidden !important;
  pointer-events: none !important;
}
@keyframes authFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Apple Floating Sheet Card */
.auth-card {
  position: relative;
  width: min(390px, 94vw);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: saturate(190%) blur(40px);
  -webkit-backdrop-filter: saturate(190%) blur(40px);
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 26px;
  padding: 36px 30px 24px;
  text-align: center;
  box-shadow:
    0 24px 60px -10px rgba(0, 0, 0, 0.25),
    0 0 0 1px rgba(255, 255, 255, 0.9) inset;
  animation: appleSheetPop 0.32s cubic-bezier(0.16, 1, 0.3, 1);
  box-sizing: border-box;
  color: #1d1d1f;
}
@keyframes appleSheetPop {
  from { opacity: 0; transform: scale(0.95) translateY(14px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

/* Apple Circular Close Button */
.auth-close-btn {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, 0.05);
  color: #86868b;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 20;
}
.auth-close-btn:hover {
  background: rgba(0, 0, 0, 0.1);
  color: #1d1d1f;
  transform: scale(1.06);
}
.auth-close-btn:active {
  transform: scale(0.94);
}

/* Centerpiece Emblem */
.auth-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  margin-bottom: 16px;
  box-shadow: 0 8px 24px rgba(123, 166, 208, 0.4);
  position: relative;
}
.auth-logo-img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

.auth-title {
  color: #1d1d1f;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 6px;
  line-height: 1.2;
}
.auth-subtitle {
  color: #86868b;
  font-size: 13.5px;
  font-weight: 400;
  line-height: 1.45;
  margin: 0 0 24px;
}

/* Store Subdomain Branding Badge */
.auth-store-header {
  margin-bottom: 12px;
}
.auth-store-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.03em;
  padding: 3px 11px;
  border-radius: 980px;
  background: rgba(0, 113, 227, 0.1);
  color: #0071e3;
  margin-bottom: 6px;
}
.auth-store-name {
  font-size: 18px;
  font-weight: 700;
  color: #1d1d1f;
  letter-spacing: -0.015em;
}

/* Apple Input Fields Stack */
.auth-inputs-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
}

.auth-input-wrap {
  position: relative;
  width: 100%;
}

.auth-input {
  width: 100%;
  height: 48px;
  padding: 0 42px 0 16px;
  font-size: 15px;
  font-family: inherit;
  color: #1d1d1f;
  background: #f5f5f7;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 13px;
  outline: none;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  box-sizing: border-box;
}
.auth-input::placeholder {
  color: #86868b;
  font-size: 14px;
}
.auth-input:focus {
  background: #ffffff;
  border-color: #0071e3;
  box-shadow: 0 0 0 3.5px rgba(0, 113, 227, 0.18);
}
.auth-input[readonly] {
  background: #e5e5ea;
  color: #6e6e73;
  border-color: rgba(0, 0, 0, 0.05);
  cursor: default;
}
.auth-input.auth-shake,
.auth-card.auth-shake {
  animation: authShake 0.4s ease;
}
@keyframes authShake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-5px); }
  80% { transform: translateX(5px); }
}

.auth-toggle-vis {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  color: #86868b;
  cursor: pointer;
  padding: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s ease;
  z-index: 10;
}
.auth-toggle-vis:hover {
  color: #1d1d1f;
}

/* Apple Warning / Error Box */
.auth-error {
  font-size: 12.5px;
  color: #ff3b30;
  background: rgba(255, 59, 48, 0.08);
  border: 1px solid rgba(255, 59, 48, 0.18);
  border-radius: 10px;
  padding: 9px 14px;
  margin-bottom: 14px;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-weight: 500;
}
.auth-error[hidden],
.auth-error:empty {
  display: none !important;
}

/* Apple Primary Action Pill Button */
.auth-submit {
  width: 100%;
  height: 46px;
  font-size: 15px;
  font-weight: 500;
  font-family: inherit;
  color: #ffffff;
  background: #0071e3;
  border: none;
  border-radius: 980px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  box-shadow: 0 4px 14px rgba(0, 113, 227, 0.28);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}
.auth-submit:hover {
  background: #0077ed;
  box-shadow: 0 6px 18px rgba(0, 113, 227, 0.38);
  transform: translateY(-1px);
}
.auth-submit:active {
  background: #006edb;
  transform: scale(0.98);
}
.auth-submit:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

/* Subdomain Back Link */
.auth-back-wrap {
  text-align: center;
  margin-top: 14px;
}
.auth-back-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12.5px;
  color: #0071e3;
  text-decoration: none;
  transition: opacity 0.15s ease;
}
.auth-back-link:hover {
  opacity: 0.8;
  text-decoration: underline;
}

/* Footer Bar */
.auth-footer-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 22px;
  padding-top: 14px;
  border-top: 1px solid rgba(0, 0, 0, 0.06);
}
.auth-footer-copy {
  font-size: 11.5px;
  color: #86868b;
}
.auth-footer-admin {
  font-size: 11.5px;
  color: #86868b;
  text-decoration: none;
  transition: color 0.15s ease;
}
.auth-footer-admin:hover {
  color: #0071e3;
}

/* ============================================================
   Promotional Landing Page — Apple Event & Product Showcase
   Matches https://www.apple.com Keynote & Product Aesthetic
   ============================================================ */
.landing-page {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Helvetica Neue", "Sarabun", sans-serif;
  background: #f5f5f7;
  color: #1d1d1f;
  min-height: 100vh;
  line-height: 1.47059;
  letter-spacing: -0.022em;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.landing-page.hidden {
  display: none !important;
}

.landing-container {
  max-width: 1020px;
  margin: 0 auto;
  padding: 0 24px;
  box-sizing: border-box;
}

/* --- Apple Global Navigation (Light Frosted) --- */
.landing-header {
  position: sticky;
  top: 0;
  z-index: 9999;
  height: 44px;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
  transition: background 0.3s ease;
}

.landing-header-inner {
  max-width: 1020px;
  height: 100%;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.landing-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: #1d1d1f;
  transition: opacity 0.2s ease;
}

.landing-brand:hover {
  opacity: 0.7;
}

.landing-brand-icon {
  display: flex;
  align-items: center;
  color: #1d1d1f;
}

.landing-brand-title {
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: #1d1d1f;
}

.landing-nav-links {
  display: flex;
  align-items: center;
  gap: 28px;
}

.landing-nav-link {
  font-size: 12px;
  font-weight: 400;
  color: rgba(29, 29, 31, 0.8);
  text-decoration: none;
  transition: color 0.2s ease, opacity 0.2s ease;
}

.landing-nav-link:hover {
  color: #000000;
  opacity: 1;
}

.landing-nav-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.landing-nav-admin {
  font-size: 12px;
  font-weight: 400;
  color: rgba(29, 29, 31, 0.65);
  text-decoration: none;
  transition: color 0.2s ease;
}

.landing-nav-admin:hover {
  color: #000000;
}

.landing-btn-login {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 14px;
  font-size: 12px;
  font-weight: 500;
  font-family: inherit;
  color: #ffffff;
  background: #0071e3;
  border: none;
  border-radius: 980px;
  cursor: pointer;
  transition: background 0.2s cubic-bezier(0.16, 1, 0.3, 1), transform 0.15s ease;
}

.landing-btn-login:hover {
  background: #0077ed;
}

.landing-btn-login:active {
  background: #006edb;
  transform: scale(0.98);
}

/* --- Apple Special Event Keynote Hero --- */
.landing-hero {
  position: relative;
  padding: 48px 0 76px;
  text-align: center;
  background: radial-gradient(circle at 50% 32%, #7ba6d0 0%, #5c87b1 32%, #3d6891 68%, #264a6e 100%);
  color: #ffffff;
  overflow: hidden;
  box-shadow: inset 0 -20px 40px rgba(0, 0, 0, 0.15);
}

.apple-event-visual {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
  width: min(320px, 72vw);
  height: min(320px, 72vw);
  will-change: transform;
  animation: appleFloat 6s ease-in-out infinite;
  transform: translate3d(0, 0, 0);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.apple-event-aura {
  position: absolute;
  inset: -10%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.45) 0%, rgba(126, 170, 212, 0.3) 48%, transparent 72%);
  filter: blur(24px);
  pointer-events: none;
}

.apple-event-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
  -webkit-mask-image: radial-gradient(circle, black 58%, transparent 71%);
  mask-image: radial-gradient(circle, black 58%, transparent 71%);
  filter: drop-shadow(0 15px 35px rgba(0, 0, 0, 0.25));
  transform: translateZ(0);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

@keyframes appleFloat {
  0%, 100% { transform: translate3d(0, 0, 0); }
  50% { transform: translate3d(0, -10px, 0); }
}

.apple-event-content {
  position: relative;
  z-index: 2;
}

.landing-hero-title {
  font-size: clamp(38px, 6vw, 64px);
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.08;
  color: #ffffff;
  margin: 0 auto 14px;
  max-width: 880px;
  text-shadow: 0 2px 14px rgba(0, 0, 0, 0.18);
}

.landing-hero-desc {
  font-size: clamp(16px, 2.2vw, 21px);
  font-weight: 400;
  line-height: 1.48;
  letter-spacing: -0.012em;
  color: rgba(255, 255, 255, 0.92);
  max-width: 660px;
  margin: 0 auto 32px;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.15);
}

.landing-hero-cta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-bottom: 48px;
}

/* Apple White Pill Button (Matches 'Add to calendar' on Apple.com) */
.btn-apple-white {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 28px;
  font-size: 15px;
  font-weight: 500;
  font-family: inherit;
  color: #1d1d1f;
  background: #ffffff;
  border: none;
  border-radius: 980px;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.16);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  text-decoration: none;
}

.btn-apple-white:hover {
  background: rgba(255, 255, 255, 0.94);
  transform: scale(1.02);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.22);
}

.btn-apple-white:active {
  transform: scale(0.98);
}

/* Apple Frosted Glass Button */
.btn-apple-glass {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 12px 24px;
  font-size: 15px;
  font-weight: 500;
  font-family: inherit;
  color: #ffffff;
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 980px;
  cursor: pointer;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  transition: all 0.2s ease;
  text-decoration: none;
}

.btn-apple-glass:hover {
  background: rgba(255, 255, 255, 0.28);
  transform: scale(1.02);
}

.landing-spec-bar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  max-width: 880px;
  margin: 0 auto;
  padding: 24px 0 0;
  border-top: 1px solid rgba(255, 255, 255, 0.22);
  text-align: left;
  gap: 24px;
}

.spec-bar-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.spec-bar-k {
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: rgba(255, 255, 255, 0.75);
}

.spec-bar-v {
  font-size: 13.5px;
  font-weight: 600;
  color: #ffffff;
}

/* --- Promo Film (Keynote-style dark stage) --- */
.landing-film {
  position: relative;
  padding: 88px 0 80px;
  background: radial-gradient(ellipse at 50% 0%, #1f3550 0%, #0d1117 55%, #000 100%);
  color: #f5f5f7;
  overflow: hidden;
}

.landing-film-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 24px;
  box-sizing: border-box;
}

.landing-film .landing-section-eyebrow { color: #64b5ff; }
.landing-film .landing-section-title { color: #f5f5f7; }
.landing-film .landing-section-sub { color: #a1a1a6; }

.film-frame {
  position: relative;
  aspect-ratio: 16 / 9;
  border-radius: 22px;
  overflow: hidden;
  /* poster stays underneath so Safari never shows a black box while buffering */
  background: #1c3d66 url(assets/promo/chalakya-promo-poster.jpg) center / cover no-repeat;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.08),
    0 40px 120px rgba(0, 113, 227, 0.22),
    0 24px 60px rgba(0, 0, 0, 0.6);
}

.film-video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: transparent;
}

.film-frame::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 46px;
  height: 46px;
  margin: -23px 0 0 -23px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.25);
  border-top-color: #fff;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.film-frame.is-loading::after {
  opacity: 1;
  animation: film-spin 0.8s linear infinite;
}

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

.film-play {
  display: flex;
  margin: 28px auto 0;
  align-items: center;
  gap: 12px;
  padding: 10px 26px 10px 10px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 980px;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  font: inherit;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.25s ease, background 0.25s ease, opacity 0.3s ease;
}

.film-play:hover {
  background: rgba(255, 255, 255, 0.16);
  transform: scale(1.04);
}

.film-play:focus-visible {
  outline: 3px solid #64b5ff;
  outline-offset: 3px;
}

.film-play-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #fff;
  color: #0071e3;
  padding-left: 3px;
  box-sizing: border-box;
}

.film-play-icon svg { width: 20px; height: 20px; }

.film-frame.is-playing + .film-play {
  opacity: 0.35;
  pointer-events: none;
}

.film-meta {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
  font-size: 13px;
  color: #86868b;
  letter-spacing: 0.02em;
}

@media (max-width: 640px) {
  .landing-film { padding: 56px 0 48px; }
  .landing-film-inner { padding: 0 16px; }
  .film-frame { border-radius: 14px; }
  .film-play { margin-top: 20px; font-size: 14px; padding: 6px 18px 6px 6px; }
  .film-play-icon { width: 34px; height: 34px; }
  .film-play-icon svg { width: 16px; height: 16px; }
}

/* --- Interactive Label Showcase (Apple Product Canvas) --- */
.landing-showcase {
  padding: 84px 0;
  background: #f5f5f7;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.landing-section-head {
  text-align: center;
  max-width: 680px;
  margin: 0 auto 44px;
}

.landing-section-eyebrow {
  display: block;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #0071e3;
  margin-bottom: 10px;
}

.landing-section-title {
  font-size: clamp(28px, 4vw, 44px);
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #1d1d1f;
  margin: 0 0 14px;
  line-height: 1.15;
}

.landing-section-sub {
  font-size: 16px;
  font-weight: 400;
  line-height: 1.5;
  color: #6e6e73;
  margin: 0;
}

.apple-showcase-box {
  max-width: 760px;
  margin: 0 auto;
}

.apple-segmented-group {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 32px;
}

.apple-segmented-control {
  display: inline-flex;
  align-items: center;
  background: rgba(0, 0, 0, 0.06);
  padding: 3px;
  border-radius: 980px;
  border: 1px solid rgba(0, 0, 0, 0.04);
}

.demo-pill, .demo-pill-sm {
  background: transparent;
  border: none;
  color: #6e6e73;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  padding: 6px 16px;
  border-radius: 980px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  white-space: nowrap;
}

.demo-pill-sm {
  font-size: 12px;
  padding: 5px 13px;
}

.demo-pill:hover, .demo-pill-sm:hover {
  color: #1d1d1f;
}

.demo-pill.active, .demo-pill-sm.active {
  background: #ffffff;
  color: #1d1d1f;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

.apple-sticker-stage {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 44px 24px;
  background: #ffffff;
  border-radius: 28px;
  border: 1px solid rgba(0, 0, 0, 0.06);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.04);
}

.demo-label-sheet {
  background: #ffffff;
  color: #000000;
  border-radius: 6px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.16), 0 0 0 1px rgba(0, 0, 0, 0.06);
  width: 100%;
  max-width: 540px;
  transition: all 0.2s ease;
}

.demo-sub-text {
  font-size: .92em;
  color: #0071e3;
  font-weight: 600;
  margin-top: calc(0.3 * var(--u));
}

.apple-showcase-caption {
  text-align: center;
  font-size: 13px;
  color: #6e6e73;
  margin-top: 22px;
}

/* --- Apple Bento Grid (Light Canvas) --- */
.landing-bento {
  padding: 96px 0;
  background: #ffffff;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.apple-bento-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
}

.bento-card {
  background: #f5f5f7;
  border: 1px solid rgba(0, 0, 0, 0.04);
  border-radius: 24px;
  padding: 38px 34px;
  transition: border-color 0.25s ease, transform 0.25s ease, box-shadow 0.25s ease;
}

.bento-card:hover {
  border-color: rgba(0, 0, 0, 0.1);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.04);
}

.bento-card-wide {
  grid-column: span 2;
}

.bento-eyebrow {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #0071e3;
  margin-bottom: 12px;
}

.bento-headline {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.015em;
  color: #1d1d1f;
  margin: 0 0 12px;
  line-height: 1.3;
}

.bento-body {
  font-size: 15px;
  font-weight: 400;
  line-height: 1.55;
  color: #6e6e73;
  margin: 0;
}

.bento-chips {
  display: flex;
  gap: 8px;
  margin-top: 22px;
}

.bento-chip {
  font-size: 12px;
  font-weight: 500;
  color: #1d1d1f;
  background: #ffffff;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 980px;
  padding: 4px 14px;
}

/* --- Apple Workflow Steps --- */
.landing-workflow {
  padding: 84px 0 96px;
  background: #f5f5f7;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.workflow-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
}

.workflow-col {
  background: #ffffff;
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: 24px;
  padding: 34px 28px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.02);
}

.workflow-num {
  font-size: 32px;
  font-weight: 700;
  color: #0071e3;
  letter-spacing: -0.03em;
  margin-bottom: 12px;
}

.workflow-step-title {
  font-size: 18px;
  font-weight: 700;
  color: #1d1d1f;
  margin: 0 0 8px;
  letter-spacing: -0.01em;
}

.workflow-step-desc {
  font-size: 14px;
  font-weight: 400;
  line-height: 1.55;
  color: #6e6e73;
  margin: 0;
}

/* --- Hardware Specs (Apple Style) --- */
.landing-hardware {
  padding: 84px 0;
  background: #ffffff;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.hardware-panel {
  background: #f5f5f7;
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: 28px;
  padding: 48px;
}

.hardware-head {
  margin-bottom: 34px;
}

.hardware-title {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.015em;
  color: #1d1d1f;
  margin: 8px 0 10px;
}

.hardware-desc {
  font-size: 15px;
  color: #6e6e73;
  margin: 0;
  line-height: 1.5;
}

.hardware-specs-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.spec-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

.spec-row:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.spec-label {
  font-size: 14px;
  font-weight: 500;
  color: #6e6e73;
  flex-shrink: 0;
  width: 240px;
}

.spec-value {
  font-size: 14.5px;
  font-weight: 500;
  color: #1d1d1f;
  text-align: right;
}

/* --- Apple Bottom Call-to-Action --- */
.landing-cta {
  padding: 96px 0;
  background: #f5f5f7;
  text-align: center;
}

.apple-cta-box {
  max-width: 640px;
  margin: 0 auto;
}

.apple-cta-title {
  font-size: clamp(28px, 4vw, 42px);
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #1d1d1f;
  margin: 0 0 14px;
}

.apple-cta-sub {
  font-size: 17px;
  color: #6e6e73;
  margin: 0 0 32px;
}

.apple-cta-action {
  display: flex;
  justify-content: center;
}

.btn-apple-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 28px;
  font-size: 15px;
  font-weight: 500;
  font-family: inherit;
  color: #ffffff;
  background: #0071e3;
  border: none;
  border-radius: 980px;
  cursor: pointer;
  transition: background 0.2s cubic-bezier(0.16, 1, 0.3, 1), transform 0.15s ease;
  text-decoration: none;
}

.btn-apple-primary:hover {
  background: #0077ed;
  transform: translateY(-1px);
}

.btn-apple-primary:active {
  background: #006edb;
  transform: scale(0.98);
}

/* --- Apple Signature Footer (5-Column Directory & Legal Bar) --- */
.landing-footer {
  background: #f5f5f7;
  color: #6e6e73;
  font-size: 12px;
  line-height: 1.33337;
  font-weight: 400;
  letter-spacing: -0.01em;
  padding: 0 0 28px;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
}

.apple-footer-disclaimer {
  padding: 17px 0 11px;
  color: #86868b;
  font-size: 11px;
  line-height: 1.55;
}
.apple-footer-disclaimer p {
  margin: 0 0 8px;
}
.apple-footer-disclaimer p:last-child {
  margin-bottom: 0;
}

.apple-footer-divider {
  border-top: 1px solid rgba(0, 0, 0, 0.14);
  margin: 0;
}

/* 5-Column Grid */
.apple-footer-directory {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 20px;
  padding: 20px 0 24px;
}

.apple-footer-col {
  display: flex;
  flex-direction: column;
}

.apple-footer-section {
  margin-bottom: 24px;
}
.apple-footer-section:last-child {
  margin-bottom: 0;
}

.apple-footer-heading {
  font-size: 12px;
  font-weight: 600;
  color: #1d1d1f;
  letter-spacing: -0.01em;
  margin: 0 0 9px;
}

.apple-footer-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.apple-footer-list a {
  font-size: 12px;
  color: #424245;
  text-decoration: none;
  transition: color 0.15s ease;
}
.apple-footer-list a:hover {
  color: #000000;
  text-decoration: underline;
}

/* Apple Hotline More Info */
.apple-footer-more {
  padding: 12px 0 16px;
  font-size: 12px;
  color: #86868b;
  line-height: 1.45;
}
.apple-footer-more-link {
  color: #0071e3;
  text-decoration: none;
}
.apple-footer-more-link:hover {
  text-decoration: underline;
}

/* Apple Legal & Locale Row */
.apple-footer-legal-wrap {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px 0 16px;
  font-size: 12px;
}

.apple-footer-legal-row1 {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.apple-footer-legal-row2 {
  display: flex;
  align-items: center;
}

.apple-footer-copy {
  color: #86868b;
  white-space: nowrap;
}

.apple-footer-legal-links {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0;
}

.apple-footer-legal-links li {
  display: inline-flex;
  align-items: center;
}

.apple-footer-legal-links li:not(:last-child)::after {
  content: '|';
  margin: 0 8px;
  color: #d2d2d7;
}

.apple-footer-legal-links a {
  color: #424245;
  text-decoration: none;
  transition: color 0.15s ease;
}
.apple-footer-legal-links a:hover {
  color: #000000;
  text-decoration: underline;
}

.apple-footer-legal-right {
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.apple-footer-locale {
  color: #1d1d1f;
  font-weight: 500;
}
.apple-footer-locale-sep {
  color: #d2d2d7;
}
.apple-footer-locale-link {
  color: #424245;
  text-decoration: none;
}
.apple-footer-locale-link:hover {
  color: #000000;
  text-decoration: underline;
}

/* --- Responsive Layout --- */
@media (max-width: 840px) {
  .landing-nav-links { display: none; }
  .landing-spec-bar { grid-template-columns: repeat(2, 1fr); }
  .apple-bento-grid { grid-template-columns: 1fr; }
  .bento-card-wide { grid-column: span 1; }
  .workflow-grid { grid-template-columns: 1fr; gap: 20px; }
  .spec-row { flex-direction: column; align-items: flex-start; gap: 4px; }
  .spec-value { text-align: left; }
  .apple-footer-directory { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 640px) {
  .landing-hero { padding: 40px 0 44px; }
  .landing-hero-cta { flex-direction: column; width: 100%; }
  .btn-apple-white, .btn-apple-glass { width: 100%; }
  .apple-segmented-group { flex-direction: column; }
  .apple-sticker-stage { padding: 20px 10px; }
  .hardware-panel { padding: 28px 20px; }
  .apple-footer-directory { grid-template-columns: 1fr; }
  .apple-footer-legal-row1 { flex-direction: column; align-items: flex-start; gap: 8px; }
  .apple-footer-legal-links { flex-wrap: wrap; gap: 4px; }
}

:root {
  /* Apple System Palette */
  --bg: #f5f5f7;
  --surface: #ffffff;
  --surface-secondary: #fbfbfd;
  --surface-tertiary: #f2f2f7;

  --line: rgba(0, 0, 0, 0.08);
  --line-strong: rgba(0, 0, 0, 0.15);
  --line-soft: rgba(0, 0, 0, 0.04);

  /* Apple Accent Colors */
  --blue: #0071e3;
  --blue-hover: #0077ed;
  --blue-active: #0068d6;
  --blue-dark: #0056b3;
  --blue-deep: #003e80;
  --blue-soft: #f0f6ff;
  --blue-ring: rgba(0, 113, 227, 0.20);

  --green: #34c759;
  --green-dark: #28a745;
  --green-soft: #eafaf1;

  --red: #ff3b30;
  --red-hover: #d70015;
  --red-soft: #fff1f0;

  --amber: #ff9500;
  --amber-soft: #fff8eb;

  /* Apple Typography Colors */
  --ink: #1d1d1f;
  /* Apple Primary Label */
  --ink-2: #424245;
  /* Apple Secondary Label */
  --ink-3: #86868b;
  /* Apple Tertiary Label */
  --ink-4: #a1a1a6;
  /* Apple Quaternary Label */

  /* Apple Elevation Shadows */
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.04), 0 1px 2px rgba(0, 0, 0, 0.02);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.06), 0 1px 4px rgba(0, 0, 0, 0.03);
  --shadow-lg: 0 12px 36px rgba(0, 0, 0, 0.10), 0 4px 12px rgba(0, 0, 0, 0.05);

  /* Apple Corner Radiuses (Squircle feel) */
  --r-xs: 6px;
  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 18px;
  --r-pill: 980px;

  /* Typography Stack */
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Sarabun", "Noto Sans SC", "Helvetica Neue", system-ui, sans-serif;
  --font-label: "Sarabun", "Noto Sans SC", -apple-system, BlinkMacSystemFont, "Inter", sans-serif;

  /* label sheet dimensions (print) */
  --ls-w: 80mm;
  --ls-h: 60mm;
}

/* 80×50mm (8×5 cm) standard label mode */
html.size-80x50 {
  --ls-w: 80mm;
  --ls-h: 50mm;
}

/* 80×60mm (8×6 cm) standard label mode */
html.size-80x60 {
  --ls-w: 80mm;
  --ls-h: 60mm;
}

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

html,
body {
  height: 100%;
}

body {
  font-family: var(--font);
  background-color: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  letter-spacing: -0.011em;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  font-size: 13px;
  -webkit-tap-highlight-color: transparent;
}

input,
textarea,
select {
  font-family: inherit;
  -webkit-appearance: none;
}

kbd {
  font-family: var(--font);
  font-size: 11px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.04);
  color: var(--ink-2);
}

/* ================= App Bar (Apple Translucent Header) ================= */

.app-bar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-bottom: 1px solid var(--line);
  transition: background 0.2s ease, border-color 0.2s ease;
}

.app-bar-inner {
  max-width: 1240px;
  margin: 0 auto;
  padding: 11px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-icon {
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  display: grid;
  place-items: center;
  font-size: 20px;
  border-radius: 10px;
  background: linear-gradient(145deg, #0071e3, #0056b3);
  box-shadow: 0 3px 10px rgba(0, 113, 227, 0.35);
}

.brand-text h1 {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.015em;
  color: var(--ink);
  white-space: nowrap;
}

.brand-sub {
  font-size: 12px;
  color: var(--ink-3);
  display: flex;
  align-items: center;
  gap: 6px;
}

.brand-sub .ver {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--blue);
  background: var(--blue-soft);
  padding: 1px 7px;
  border-radius: var(--r-pill);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn-settings {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
  background: var(--surface-tertiary);
  border: 1px solid transparent;
  border-radius: var(--r-pill);
  cursor: pointer;
  transition: all .15s cubic-bezier(0.25, 0.1, 0.25, 1);
  white-space: nowrap;
  flex-shrink: 0;
}

.btn-settings svg {
  width: 16px;
  height: 16px;
  color: var(--ink-3);
  transition: color .15s;
}

.btn-settings:hover {
  background: var(--blue-soft);
  color: var(--blue);
  border-color: rgba(0, 113, 227, 0.15);
}

.btn-settings:hover svg {
  color: var(--blue);
}

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

.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 14px 4px 5px;
  border-radius: var(--r-pill);
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow-xs);
  flex: 0 0 auto;
  cursor: pointer;
  transition: all .15s cubic-bezier(0.25, 0.1, 0.25, 1);
}

.user-chip:hover {
  border-color: rgba(0, 113, 227, 0.3);
  box-shadow: 0 2px 10px rgba(0, 113, 227, 0.08);
}

.user-chip:active {
  transform: scale(0.98);
}

.avatar {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: linear-gradient(145deg, #0071e3, #0056b3);
  color: #fff;
  font-weight: 600;
  font-size: 15px;
}

.user-name {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.15;
  color: var(--ink);
}

.user-role {
  font-size: 11px;
  color: var(--ink-3);
}

/* ================= Cards / Workspace ================= */

.workspace {
  max-width: 1240px;
  margin: 0 auto;
  padding: 24px 24px 48px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s ease;
}

/* ----- Patient strip (Clean Apple Form Card) ----- */

.strip {
  padding: 16px 20px 18px;
}

.strip-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  gap: 12px;
  flex-wrap: wrap;
}

.strip-title {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -0.012em;
  color: var(--ink);
  display: flex;
  align-items: baseline;
}

.strip-title .hint {
  font-size: 11.5px;
  font-weight: 400;
  color: var(--ink-3);
  margin-left: 6px;
}

.strip-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-strip-action {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-2);
  background: var(--surface-tertiary);
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  cursor: pointer;
  transition: all .15s ease;
  white-space: nowrap;
  flex-shrink: 0;
}

.btn-strip-action:hover {
  background: var(--blue-soft);
  color: var(--blue);
  border-color: rgba(0, 113, 227, 0.25);
}

.btn-strip-action.danger:hover {
  background: var(--red-soft);
  color: var(--red);
  border-color: rgba(255, 59, 48, 0.25);
}

.btn-strip-action:active {
  transform: scale(0.96);
}

.strip-grid {
  display: grid;
  grid-template-columns: 2fr 0.9fr 1.1fr 1.1fr 2fr;
  gap: 16px;
  align-items: end;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.field.grow2 {
  grid-column: span 1;
}

.field>span {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--ink-2);
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.field>span i {
  font-style: normal;
  font-size: 10.5px;
  font-weight: 400;
  color: var(--ink-3);
}

.field input,
.field select {
  width: 100%;
  font-size: 14px;
  font-weight: 500;
  color: var(--ink);
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface-tertiary);
  outline: none;
  transition: all .15s ease;
}

.field input:hover,
.field select:hover {
  border-color: rgba(0, 0, 0, 0.18);
  background: #ffffff;
}

.field input:focus,
.field select:focus {
  background: #ffffff;
  border-color: var(--blue);
  box-shadow: 0 0 0 3.5px var(--blue-ring);
}

/* ----- Toolbar (Apple Pro Command Bar) ----- */

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 18px;
  position: relative;
  z-index: 30;
  flex-wrap: wrap;
}

.toolbar-left {
  flex: 1 1 220px;
}

.toolbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1 1 auto;
  flex-wrap: wrap;
  justify-content: flex-end;
}

@media (max-width: 680px) {
  .toolbar-right .btn-print {
    width: 100%;
    justify-content: center;
    margin-left: 0;
  }
}

/* ---- Print guide modal ---- */
.guide-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 150;
  display: grid;
  place-items: center;
  padding: 16px;
  animation: fadeIn .18s ease;
}

.guide-card {
  background: #ffffff;
  border-radius: var(--r-lg);
  max-width: 540px;
  width: 100%;
  max-height: 86vh;
  overflow-y: auto;
  padding: 24px 26px;
  box-shadow: var(--shadow-lg);
  animation: popIn .2s cubic-bezier(.16, 1, .3, 1);
}

.guide-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 16px;
}

.guide-close {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: var(--surface-tertiary);
  color: var(--ink-3);
  font-size: 14px;
  cursor: pointer;
  transition: all .15s ease;
}

.guide-close:hover {
  background: var(--red-soft);
  color: var(--red);
}

.guide-step {
  display: flex;
  gap: 12px;
  margin-bottom: 12px;
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--ink-2);
}

.guide-step b {
  color: var(--ink);
  font-weight: 600;
}

.guide-num {
  flex: 0 0 22px;
  height: 22px;
  display: grid;
  place-items: center;
  background: var(--blue-soft);
  color: var(--blue);
  font-weight: 700;
  border-radius: 50%;
  font-size: 12px;
  margin-top: 1px;
}

.guide-note {
  background: var(--amber-soft);
  border: 1px solid rgba(255, 149, 0, 0.25);
  border-radius: var(--r-sm);
  padding: 12px 14px;
  font-size: 12.5px;
  color: #944b00;
  line-height: 1.5;
  margin-top: 6px;
}

/* Search input (Apple Spotlight Style) */
.search-wrap {
  position: relative;
  flex: 1;
  display: flex;
  align-items: center;
  min-width: 260px;
}

.search-icon {
  width: 17px;
  height: 17px;
  color: var(--ink-3);
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
}

#drugSearch {
  width: 100%;
  font-size: 14px;
  padding: 10px 46px 10px 42px;
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  background: var(--surface-tertiary);
  outline: none;
  color: var(--ink);
  transition: all .15s ease;
}

#drugSearch:hover {
  border-color: rgba(0, 0, 0, 0.18);
  background: #ffffff;
}

#drugSearch:focus {
  background: #ffffff;
  border-color: var(--blue);
  box-shadow: 0 0 0 3.5px var(--blue-ring);
}

.search-wrap .kbd {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  background: rgba(0, 0, 0, 0.05);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 20px;
  min-width: 20px;
  padding: 0 4px;
  box-sizing: border-box;
  line-height: 1;
}

.search-drop {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  z-index: 60;
  animation: popIn .16s ease;
}

.search-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 16px;
  border: 0;
  background: transparent;
  text-align: left;
  border-bottom: 1px solid var(--line-soft);
  cursor: pointer;
  transition: background .12s;
}

.search-item:last-child {
  border-bottom: 0;
}

.search-item:hover,
.search-item.sel {
  background: var(--blue-soft);
}

.search-item .si-main {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 8px;
}

.search-item .si-sub {
  font-size: 12px;
  color: var(--ink-3);
}

.search-item .si-bc {
  margin-left: auto;
  font-size: 11px;
  font-weight: 500;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
  letter-spacing: .3px;
  background: rgba(0, 0, 0, 0.04);
  padding: 2px 8px;
  border-radius: 6px;
  white-space: nowrap;
}

.search-item .si-match {
  font-size: 10px;
  font-weight: 600;
  color: var(--green);
  background: var(--green-soft);
  padding: 1px 7px;
  border-radius: var(--r-pill);
}

.search-empty {
  padding: 18px;
  font-size: 13px;
  color: var(--ink-3);
  text-align: center;
}

/* Primary Print Button (Apple Call to Action) */
.btn-print {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
  font-size: 13.5px;
  font-weight: 600;
  color: #ffffff;
  background: #34c759;
  border: 0;
  border-radius: var(--r-pill);
  padding: 10px 20px;
  min-height: 40px;
  box-shadow: 0 3px 12px rgba(52, 199, 89, 0.35);
  cursor: pointer;
  transition: all .15s cubic-bezier(0.25, 0.1, 0.25, 1);
}

.btn-print svg {
  width: 16px;
  height: 16px;
}

.btn-print:hover {
  background: #28a745;
  box-shadow: 0 4px 16px rgba(52, 199, 89, 0.45);
}

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

.btn-print:disabled,
.btn-print.disabled {
  opacity: 0.45;
  cursor: not-allowed;
  filter: grayscale(0.6);
  box-shadow: none;
  transform: none !important;
  pointer-events: none;
}

.badge {
  background: rgba(0, 0, 0, 0.15);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  border-radius: 999px;
  padding: 1px 7px;
  transition: transform .2s;
}

/* ================= Toolbar Segmented Controls (High-Contrast Apple Style) ================= */

.view-size-wrap {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-tertiary);
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  padding: 4px 10px;
  flex: 0 0 auto;
}

.vsw-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-2);
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.vsw-label .tb-icon {
  color: var(--ink-3);
  display: block;
}

.global-lang-wrap {
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-2);
  margin-right: 8px;
}

.gl-label {
  display: none;
}

/* Floats under the menu so showing it never shifts the buttons beside it. */
.gl-status {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 20;
  padding: 5px 10px;
  border-radius: 8px;
  background: #f0f9ff;
  border: 1px solid #bae6fd;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.08);
  font-size: 11.5px;
  font-weight: 600;
  color: var(--blue-deep, #0369a1);
  white-space: nowrap;
  pointer-events: none;
}

.s-lang-checks { display: flex; flex-wrap: wrap; gap: 8px 16px; }
.s-lang-check { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; cursor: pointer; min-height: 32px; }
.s-lang-check .native { font-weight: 500; color: var(--ink-3); }

@media (min-width: 900px) {
  .gl-label {
    display: inline;
  }
}

.s-select {
  font-size: 12px;
  font-weight: 600;
  padding: 4px 24px 4px 10px;
  border-radius: var(--r-pill);
  border: 1px solid var(--line);
  background-color: var(--surface-tertiary);
  color: var(--ink);
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' stroke='%23737373' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' viewBox='0 0 24 24'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 12px;
  cursor: pointer;
  outline: none;
  transition: all 0.15s ease;
}

.s-select:hover {
  background-color: #fff;
  border-color: rgba(0, 0, 0, 0.15);
}

.vsw-select {
  font-size: 12.5px;
  font-weight: 600;
  padding: 6px 28px 6px 14px;
  border-radius: var(--r-pill);
  border: 1px solid var(--line);
  background-color: var(--surface-tertiary);
  color: var(--ink);
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' stroke='%23737373' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' viewBox='0 0 24 24'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 14px;
  cursor: pointer;
  outline: none;
  transition: all 0.15s ease;
}

.vsw-select:hover {
  background-color: #fff;
  border-color: rgba(0, 0, 0, 0.15);
}

.vsw-select.highlight-blue {
  background-color: var(--blue-soft);
  color: var(--blue);
  border-color: rgba(0, 113, 227, 0.25);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' stroke='%230071e3' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' viewBox='0 0 24 24'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
}

.batch-select-wrap {
  display: inline-flex;
  align-items: center;
  background: var(--surface-tertiary);
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  padding: 6px 14px;
  min-height: 38px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-2);
  white-space: nowrap;
}

.batch-cb-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
}

.batch-cb-label input {
  display: none;
}

.batch-cb-box {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  border: 2px solid var(--line);
  position: relative;
  transition: all 0.2s;
  background: #fff;
}

.batch-cb-label input:checked+.batch-cb-box {
  background: var(--blue);
  border-color: var(--blue);
}

.batch-cb-label input:checked+.batch-cb-box::after {
  content: '';
  position: absolute;
  left: 4px;
  top: 1px;
  width: 4px;
  height: 8px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.btn-guide {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface-tertiary);
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  padding: 6px 14px;
  min-height: 38px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-2);
  cursor: pointer;
  transition: all .15s ease;
  white-space: nowrap;
}

.btn-guide svg {
  color: var(--ink-3);
}

.btn-guide:hover {
  background: #ffffff;
  color: var(--blue);
  border-color: rgba(0, 113, 227, 0.3);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
}

.btn-guide:hover svg {
  color: var(--blue);
}

/* ================= Label Gallery (Apple Clean Responsive Grid) ================= */

.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 540px), 1fr));
  gap: 24px;
  width: 100%;
  max-width: 1300px;
  margin: 0 auto;
  align-items: start;
  padding: 8px 0 24px;
  transition: all .2s ease;
}

/* Full Width View (Extra Large Single Column) */
.gallery.view-full {
  grid-template-columns: 1fr;
  max-width: 860px;
}

/* Compact Grid View */
.gallery.view-compact {
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  max-width: 100%;
}

.label-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 16px 16px 18px;
  box-shadow: var(--shadow-sm);
  transition: transform .18s cubic-bezier(0.25, 0.1, 0.25, 1), box-shadow .18s cubic-bezier(0.25, 0.1, 0.25, 1);
  animation: cardIn .25s ease both;
  width: 100%;
  box-sizing: border-box;
}

.label-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

@keyframes cardIn {
  from {
    opacity: 0;
    transform: translateY(8px) scale(.98);
  }

  to {
    opacity: 1;
    transform: none;
  }
}

.card-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
}

.card-bar-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-select-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  user-select: none;
  background: var(--surface-tertiary);
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  padding: 9px;
  min-height: 34px;
  min-width: 34px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-2);
  transition: all .15s ease;
}

.card-select-toggle input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.card-cb-box {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  border: 1.5px solid var(--ink-4);
  background: #ffffff;
  display: grid;
  place-items: center;
  transition: all .15s ease;
  flex: 0 0 16px;
  position: relative;
}

.card-select-toggle input:checked+.card-cb-box {
  background: var(--blue);
  border-color: var(--blue);
  box-shadow: 0 2px 6px rgba(0, 113, 227, 0.35);
}

.card-select-toggle input:checked+.card-cb-box::after {
  content: '';
  width: 4px;
  height: 8px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg) translate(-0.5px, -0.5px);
}

.card-select-toggle:hover {
  background: var(--blue-soft);
  border-color: rgba(0, 113, 227, 0.25);
  color: var(--blue);
}

.card-select-toggle:hover .card-cb-box {
  border-color: var(--blue);
}

.label-card.selected {
  border-color: rgba(0, 113, 227, 0.35);
  box-shadow: 0 0 0 1.5px var(--blue), var(--shadow-sm);
}

/* segmented language switcher (Apple iOS Segmented Control) */
.seg {
  display: inline-flex;
  background: rgba(118, 118, 128, 0.12);
  border-radius: 9px;
  padding: 3px;
  gap: 2px;
}

.seg-btn {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-2);
  background: transparent;
  border: 0;
  border-radius: 7px;
  padding: 5px 12px;
  min-height: 28px;
  transition: all .15s ease;
  letter-spacing: -0.01em;
  cursor: pointer;
  white-space: nowrap;
}

.seg-btn:hover {
  color: var(--ink);
}

.seg-btn.active {
  background: #ffffff;
  color: var(--blue);
  font-weight: 700;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.06);
}

.card-bar-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.icon-btn {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface-tertiary);
  color: var(--ink-2);
  transition: all .15s cubic-bezier(0.25, 0.1, 0.25, 1);
  cursor: pointer;
}

.icon-btn svg {
  width: 16px;
  height: 16px;
  display: block;
}

.icon-btn:hover {
  background: #ffffff;
  color: var(--blue);
  border-color: rgba(0, 113, 227, 0.3);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
  transform: translateY(-1px);
}

.icon-btn.danger:hover {
  background: var(--red-soft);
  color: var(--red);
  border-color: rgba(255, 59, 48, 0.3);
  box-shadow: 0 2px 6px rgba(255, 59, 48, 0.15);
}

.icon-btn:active {
  transform: scale(0.95);
}

.icon-btn:hover {
  background: var(--blue-soft);
  color: var(--blue);
}

.icon-btn.danger:hover {
  background: var(--red-soft);
  color: var(--red);
}

.icon-btn:active {
  transform: scale(0.92);
}

/* ================= Label sheet: one layout for screen and paper =================
   Every size inside the sheet is a multiple of --u, one point of the printed
   sticker: the sheet is a size container and 100cqw is its width, which on
   paper is 78mm = 221.1pt. So the preview is the sticker scaled up, not a
   separate layout — what fits (or overflows) on screen fits (or overflows)
   the same way on paper, and checkLabelOverflow() can be trusted. Sizes are
   for the 8×6 sticker; the 8×5 one scales the whole label by 0.82 (48mm / 58mm). */

.label-sheet {
  position: relative;
  width: 100%;
  max-width: 100%;
  aspect-ratio: 78 / 58;
  margin: 0 auto;
  padding: 0;
  container-type: inline-size;
  background: #ffffff;
  border: 1.5px solid #cbd5e1;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(15, 23, 42, .08), 0 10px 24px -6px rgba(15, 23, 42, .14);
  font-family: var(--font-label);
  color: #111827;
  box-sizing: border-box;
  overflow: hidden;
}

.label-sheet.size-80x50 { aspect-ratio: 78 / 48; }

.ls-in {
  --u: calc(100cqw / 221.1);
  height: 100%;
  box-sizing: border-box;
  padding: calc(2 * var(--u)) calc(4.4 * var(--u)) calc(1.6 * var(--u));
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  font-size: calc(7 * var(--u));
  line-height: 1.25;
}

.size-80x50 .ls-in { --u: calc(100cqw / 221.1 * 0.82); }

/* --- header --- */
.ls-head {
  border-bottom: calc(1 * var(--u)) solid #111827;
  padding-bottom: calc(1 * var(--u));
  margin-bottom: calc(1.2 * var(--u));
}

.ls-pharmacy {
  font-size: calc(9.8 * var(--u));
  font-weight: 800;
  line-height: 1.2;
  display: flex;
  align-items: baseline;
  gap: calc(3 * var(--u));
  white-space: nowrap;
  overflow: hidden;
  color: #000000;
}

.ls-pharmacy .sub {
  font-size: calc(6.2 * var(--u));
  font-weight: 600;
  color: #475569;
}

.ls-pharmacy-sub {
  font-size: calc(5.6 * var(--u));
  color: #475569;
  margin-top: calc(0.3 * var(--u));
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* --- patient --- */
.ls-patient {
  display: flex;
  justify-content: space-between;
  gap: calc(5 * var(--u));
  font-size: calc(6.8 * var(--u));
  padding-bottom: calc(1 * var(--u));
  margin-bottom: calc(1 * var(--u));
  border-bottom: calc(0.8 * var(--u)) dotted #94a3b8;
  flex-shrink: 0;
}

.ls-patient b {
  font-weight: 800;
  color: #000000;
  font-size: calc(7 * var(--u));
}

/* Age, sex, allergies and conditions: filled from the patient strip (or the
   LINE profile); a blank one keeps a line to write on by hand. */
.ls-patient-info {
  display: grid;
  grid-template-columns: 1fr 1fr;
  column-gap: calc(5 * var(--u));
  row-gap: calc(0.6 * var(--u));
  font-size: calc(6 * var(--u));
  line-height: 1.25;
  padding-bottom: calc(1 * var(--u));
  margin-bottom: calc(1 * var(--u));
  border-bottom: calc(0.6 * var(--u)) dashed #94a3b8;
  flex-shrink: 0;
}
.ls-pi { display: flex; align-items: baseline; gap: calc(2 * var(--u)); min-width: 0; }
.ls-pi-lab { flex-shrink: 0; color: #334155; }
.ls-pi-val {
  font-weight: 800;
  color: #000;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ls-pi-line { flex: 1; height: 1em; border-bottom: calc(0.6 * var(--u)) dotted #333; }

/* --- drug --- */
.ls-drug {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: calc(3 * var(--u));
  margin-bottom: calc(1 * var(--u));
}

.ls-drug-left { flex: 1; min-width: 0; }

.ls-trade {
  font-size: calc(11.4 * var(--u));
  font-weight: 800;
  line-height: 1.15;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #000000;
}

.ls-generic {
  font-size: calc(6.4 * var(--u));
  font-weight: 600;
  color: #334155;
  margin-top: calc(0.3 * var(--u));
  line-height: 1.2;
}

.ls-drug-right {
  flex: 0 0 calc(82 * var(--u));
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.ls-qty {
  display: flex;
  justify-content: space-between;
  gap: calc(2 * var(--u));
  width: 100%;
  font-size: calc(6.2 * var(--u));
  line-height: 1.25;
}

.ls-qty .lab { color: #475569; font-weight: 600; }
.ls-qty b { font-weight: 800; color: #000; font-variant-numeric: tabular-nums; white-space: nowrap; }

.ls-bc {
  margin-top: calc(0.6 * var(--u));
  width: 100%;
  display: flex;
  justify-content: flex-end;
}

.ls-bc svg {
  display: block;
  width: 100%;
  max-width: calc(80 * var(--u));
  height: calc(10 * var(--u));
}

.ls-bc-digits {
  font-size: calc(5.2 * var(--u));
  font-family: 'Courier New', Courier, monospace;
  font-weight: 700;
  letter-spacing: .5px;
  text-align: center;
  width: 100%;
  margin-top: calc(0.3 * var(--u));
  font-variant-numeric: tabular-nums;
  color: #000000;
}

/* --- indication / dosage / warning: plain text, no boxes (a printed box
   came out uneven on the thermal sticker) --- */
.ls-ind {
  font-size: calc(6.8 * var(--u));
  line-height: 1.2;
  margin-bottom: calc(1 * var(--u));
  color: #1e293b;
  font-weight: 600;
}

.ls-lab { font-weight: 800; color: #000000; }

.ls-dosage {
  font-size: calc(7.6 * var(--u));
  font-weight: 700;
  line-height: 1.22;
  margin-bottom: calc(1.2 * var(--u));
  color: #000000;
}

.ls-warn {
  font-size: calc(6.4 * var(--u));
  font-weight: 600;
  line-height: 1.2;
  margin-bottom: calc(1 * var(--u));
  color: #111827;
}

/* --- footer --- */
.ls-foot {
  margin-top: auto;
  border-top: calc(0.8 * var(--u)) dotted #94a3b8;
  padding-top: calc(1 * var(--u));
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: calc(5 * var(--u));
  font-size: calc(5.4 * var(--u));
  font-weight: 600;
  color: #475569;
  overflow: hidden;
}

.ls-foot b { color: #000000; }

/* A long footer (the Russian expiry line) wraps under itself instead of
   losing its last words to overflow:hidden. */
.ls-foot > span:first-child { white-space: nowrap; }
.ls-foot > span:last-child { text-align: right; }

/* sub-language text on labels. The translated line is usually the longer
   one, so it is set a little smaller than the Thai it follows. */
.label-sheet .sub { font-weight: 500; }
.ls-ind .sub, .ls-dosage .sub, .ls-warn .sub { font-size: .92em; }

/* editable hover highlights (screen only) */
.ls-editable {
  cursor: pointer;
  border-radius: 4px;
  transition: background-color .14s ease, outline-color .14s ease;
}

.ls-editable:hover {
  outline: 2px dashed var(--blue);
  outline-offset: 1px;
}

.ls-dosage.ls-editable:hover { background: #f0f9ff; }
.ls-warn.ls-editable:hover { background: #fef2f2; }

/* ============================================================
   Keeping the dose and the warning on the printed sticker.
   The sticker is a fixed height and clips the rest, so the variable-length
   fields give up space first, and the dose, warning and footer never shrink.
   ============================================================ */

.ls-generic {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.ls-ind {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Allowed to give up space */
.ls-drug,
.ls-ind {
  min-height: 0;
  flex-shrink: 1;
}

/* Never give up space — these carry the instruction and the warning */
.ls-dosage,
.ls-warn,
.ls-foot,
.ls-head {
  flex-shrink: 0;
}

/* Shown by checkLabelOverflow() when content still cannot fit the sticker */
.label-overflow-warn {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  padding: 7px 10px;
  border: 1.5px solid #f59e0b;
  background: #fffbeb;
  border-radius: 7px;
  font-size: 11.5px;
  font-weight: 700;
  color: #92400e;
  line-height: 1.35;
}

/* Up to eight language buttons: on a narrow (compact or phone) card the
   actions wrap to their own row instead of hanging off the card's edge. */
.label-card .seg-lang .seg-btn { padding: 5px 9px; min-height: 32px; }
.label-card .seg-lang { flex-wrap: wrap; }
.label-card .card-bar { flex-wrap: wrap; row-gap: 8px; }
.label-card .card-bar-actions { margin-left: auto; }

/* Second-language fonts. Sarabun has no Cyrillic or Hangul, and Noto Sans SC
   would draw Traditional characters in their mainland shapes, so each mode
   puts its own font right after Sarabun. */
.label-sheet.lang-thtw { font-family: "Sarabun", "Noto Sans TC", "Noto Sans SC", sans-serif; }
.label-sheet.lang-thru { font-family: "Sarabun", "Inter", "Noto Sans SC", sans-serif; }
.label-sheet.lang-thmy { font-family: "Sarabun", "Noto Sans Myanmar", "Myanmar Text", "Myanmar Sangam MN", sans-serif; }
.label-sheet.lang-thko { font-family: "Sarabun", "Noto Sans KR", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif; }

/* ================= Empty state ================= */

.empty-state {
  grid-column: 1 / -1;
  border: 2px dashed #cbd5e1;
  border-radius: var(--r-lg);
  background: rgba(255, 255, 255, .7);
  padding: 56px 24px;
  text-align: center;
  color: var(--ink-3);
}

.empty-state .es-icon {
  font-size: 40px;
  margin-bottom: 10px;
}

.empty-state h3 {
  font-size: 17px;
  font-weight: 700;
  color: var(--ink-2);
  margin-bottom: 6px;
}

.empty-state p {
  font-size: 13.5px;
  margin-bottom: 18px;
}

.btn-ghost-blue {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--blue);
  background: var(--blue-soft);
  border: 1px solid #bae6fd;
  border-radius: var(--r-sm);
  padding: 9px 16px;
  transition: background .12s, transform .12s;
}

.btn-ghost-blue:hover {
  background: #d3edfd;
  transform: translateY(-1px);
}

/* ================= Status bar ================= */

.status-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-2);
  background: var(--surface-secondary);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 10px 16px;
  flex-wrap: wrap;
  margin-top: auto;
}

.status-bar .shortcuts {
  white-space: nowrap;
  font-weight: 600;
  color: var(--ink);
}

/* ================= Popover editors ================= */

.popover {
  position: fixed;
  z-index: 100;
  width: 440px;
  max-width: calc(100vw - 24px);
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  animation: popIn .18s cubic-bezier(.16, 1, .3, 1);
  padding: 16px 18px 14px;
}

.pop-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 12px;
}

.pop-title .pop-emoji {
  margin-right: 6px;
}

.pop-close {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: var(--surface-tertiary);
  color: var(--ink-3);
  font-size: 14px;
  cursor: pointer;
  transition: all .12s ease;
}

.pop-close:hover {
  background: var(--red-soft);
  color: var(--red);
}

.ed-field {
  margin-bottom: 9px;
}

.ed-field>label,
.ed-field-label {
  display: block;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--ink-2);
  margin-bottom: 5px;
}

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

.ed-row .grow {
  flex: 1;
  min-width: 0;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-2);
  background: var(--surface-tertiary);
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  padding: 5px 11px;
  cursor: pointer;
  transition: all .12s ease;
}

.chip:hover {
  background: #ffffff;
  border-color: rgba(0, 0, 0, 0.18);
}

.chip.active {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
  box-shadow: 0 2px 8px rgba(0, 113, 227, 0.35);
}

.ed-input {
  width: 100%;
  font-size: 13.5px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface-tertiary);
  outline: none;
  transition: all .15s ease;
}

.ed-input:focus {
  background: #ffffff;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px var(--blue-ring);
}

.ed-textarea {
  min-height: 64px;
  resize: vertical;
  line-height: 1.45;
}

.ed-hint {
  font-size: 11px;
  color: var(--ink-3);
  margin: 6px 0 10px;
}

.ed-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 6px;
}

.btn {
  font-size: 13.5px;
  font-weight: 600;
  border-radius: var(--r-pill);
  padding: 8px 18px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all .15s cubic-bezier(0.25, 0.1, 0.25, 1);
}

.btn.primary {
  background: var(--blue);
  color: #fff;
  box-shadow: 0 2px 8px rgba(0, 113, 227, 0.3);
}

.btn.primary:hover {
  background: var(--blue-hover);
  box-shadow: 0 4px 12px rgba(0, 113, 227, 0.4);
}

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

.btn.ghost {
  background: var(--surface-tertiary);
  color: var(--ink-2);
  border-color: var(--line);
}

.btn.ghost:hover {
  background: #ffffff;
  border-color: rgba(0, 0, 0, 0.2);
}

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

/* drug swap list */
.ed-list {
  margin-top: 8px;
  max-height: 216px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: #ffffff;
}

.ed-list .search-item {
  padding: 9px 14px;
}

.ed-list .search-item.sel {
  background: var(--blue-soft);
}

/* ================= Settings & Master Data Modal (Apple macOS Window Style) ================= */
.settings-overlay {
  position: fixed;
  inset: 0;
  z-index: 150;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn .18s ease;
}

.settings-modal {
  position: relative;
  width: min(1220px, 95vw);
  max-width: 100%;
  height: 88vh;
  max-height: 860px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg), 0 25px 50px -12px rgba(0, 0, 0, .25);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: popIn .2s cubic-bezier(.16, 1, .3, 1);
}

.settings-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 22px;
  background: rgba(255, 255, 255, 0.9);
  border-bottom: 1px solid var(--line);
  flex: 0 0 auto;
}

.settings-head-title {
  display: flex;
  align-items: center;
  gap: 12px;
}

.settings-head-title .icon {
  font-size: 22px;
}

.settings-head-title h2 {
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.015em;
}

.settings-head-title p {
  font-size: 12px;
  color: var(--ink-3);
}

.settings-close {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: var(--surface-tertiary);
  color: var(--ink-3);
  font-size: 14px;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: all .15s ease;
}

.settings-close:hover {
  background: var(--red-soft);
  color: var(--red);
}

.settings-close:active {
  transform: scale(0.92);
}

.settings-nav {
  display: flex;
  gap: 4px;
  padding: 8px 18px 0;
  background: var(--surface-secondary);
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
  flex: 0 0 auto;
}

.s-nav-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-3);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: all .15s ease;
}

.s-nav-btn:hover {
  color: var(--ink);
}

.s-nav-btn.active {
  color: var(--blue);
  border-bottom-color: var(--blue);
  background: rgba(0, 113, 227, 0.04);
}

.settings-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
  background: #ffffff;
}

.s-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.s-search {
  position: relative;
  flex: 1;
  max-width: 420px;
}

.s-btn-add {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  border-radius: 8px;
  background: var(--blue);
  color: white;
  border: none;
  cursor: pointer;
  transition: background .15s ease, transform .1s ease;
  white-space: nowrap;
}

.s-btn-add:hover {
  background: var(--blue-deep);
  transform: translateY(-1px);
}

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

.s-search input {
  width: 100%;
  padding: 8px 12px 8px 34px;
  font-size: 13px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: #f8fafc;
  outline: none;
}

.s-search input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px var(--blue-ring);
  background: #fff;
}

.s-search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 15px;
  height: 15px;
  color: var(--ink-4);
  pointer-events: none;
}

/* Table styling */
.s-table-wrap {
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  overflow-x: auto;
  box-shadow: var(--shadow-sm);
  background: #fff;
}

.s-table {
  width: 100%;
  min-width: 860px;
  border-collapse: collapse;
  font-size: 12.5px;
  text-align: left;
}

.s-table th {
  background: #f8fafc;
  padding: 11px 16px;
  font-weight: 700;
  color: var(--ink-2);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

.s-table td {
  padding: 12px 16px;
  border-bottom: 1px solid #f1f5f9;
  color: var(--ink);
  vertical-align: middle;
}

.s-table th:last-child,
.s-table td:last-child {
  text-align: right;
  width: 140px;
  min-width: 140px;
  padding-right: 18px;
}

.s-table tr:last-child td {
  border-bottom: none;
}

.s-table tr:hover td {
  background: #f8fafc;
}

.s-table code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 11px;
  background: #f1f5f9;
  color: #334155;
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid #e2e8f0;
  letter-spacing: 0.3px;
  display: inline-block;
}

.s-table .t-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  justify-content: flex-end;
  white-space: nowrap;
}

.s-act-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 9px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink-2);
  cursor: pointer;
  transition: all .15s ease;
}

.s-act-btn svg {
  flex-shrink: 0;
}

.s-act-btn:hover {
  background: var(--blue-soft);
  color: var(--blue);
  border-color: #bae6fd;
}

.s-act-btn.danger:hover {
  background: var(--red-soft);
  color: var(--red);
  border-color: #fecaca;
}

.s-btn-add {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  border-radius: 8px;
  background: var(--blue);
  color: white;
  border: none;
  cursor: pointer;
  transition: background .15s ease, transform .1s ease;
  white-space: nowrap;
}

.s-btn-add:hover {
  background: var(--blue-deep);
}

.s-btn-add:active {
  transform: scale(0.98);
}

.s-btn-add svg {
  flex-shrink: 0;
}

.s-tag {
  display: inline-block;
  padding: 2px 7px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 999px;
  background: #f1f5f9;
  color: var(--ink-2);
  border: 1px solid var(--line);
}

.s-tag.blue {
  background: var(--blue-soft);
  color: var(--blue-deep);
  border-color: #bae6fd;
}

.s-tag.red {
  background: var(--red-soft);
  color: #991b1b;
  border-color: #fecaca;
}

/* Sub editor dialog inside settings */
.s-submodal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .7);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 300;
  animation: fadeIn .15s ease;
}

.s-submodal {
  width: 720px;
  max-width: 100%;
  max-height: 85vh;
  background: #fff;
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.s-submodal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 18px;
  background: #f8fafc;
  border-bottom: 1px solid var(--line);
}

.s-submodal-head h3 {
  font-size: 14.5px;
  font-weight: 800;
}

.s-submodal-body {
  padding: 16px 20px;
  overflow-y: auto;
  flex: 1;
}

.s-submodal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 18px;
  background: #f8fafc;
  border-top: 1px solid var(--line);
}

.s-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.s-form-grid .full {
  grid-column: 1 / -1;
}

.s-form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.s-form-group label {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--ink-2);
}

.s-form-group label small {
  font-weight: 500;
  color: var(--ink-4);
}

.s-input {
  width: 100%;
  padding: 8px 11px;
  font-size: 13px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: #f8fafc;
  outline: none;
  transition: all .12s;
}

.s-input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px var(--blue-ring);
  background: #fff;
}

.s-textarea {
  min-height: 58px;
  resize: vertical;
  line-height: 1.4;
}

/* Lang input group */
.s-lang-group {
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 12px;
  background: #fafbfc;
  margin-bottom: 12px;
}

.s-lang-title {
  font-size: 12px;
  font-weight: 800;
  color: var(--ink-2);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.s-card-section {
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 16px;
  background: #ffffff;
  margin-bottom: 14px;
}

.s-card-title {
  font-size: 13.5px;
  font-weight: 800;
  color: var(--ink);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Backup card */
.backup-box {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.backup-card {
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 18px;
  background: #f8fafc;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.backup-card h4 {
  font-size: 14px;
  font-weight: 800;
}

.backup-card p {
  font-size: 12px;
  color: var(--ink-3);
  line-height: 1.45;
  flex: 1;
}

/* ================= Toasts ================= */

#toastRoot {
  position: fixed;
  bottom: 22px;
  right: 22px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #0f172a;
  color: #f8fafc;
  font-size: 13px;
  font-weight: 600;
  padding: 11px 15px;
  border-radius: 12px;
  box-shadow: 0 12px 30px -8px rgba(15, 23, 42, .5);
  animation: toastIn .2s ease;
  max-width: 340px;
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: none;
  }
}

.toast .t-undo {
  margin-left: 4px;
  font-weight: 800;
  color: #7dd3fc;
  background: none;
  border: 0;
  font-size: 12.5px;
  padding: 2px 6px;
  border-radius: 6px;
}

.toast .t-undo:hover {
  background: rgba(255, 255, 255, .12);
}

.toast.out {
  animation: toastOut .2s ease forwards;
}

@keyframes toastOut {
  to {
    opacity: 0;
    transform: translateY(8px);
  }
}

/* ================= Print-only staging ================= */

.print-area {
  display: none;
}

/* ================= Print fidelity: thermal roll (80×60 or 60×80) =================
   NOTE: @page size is injected by JS (applyPageSize) as a single rule so browsers
   don't drop it — Safari ignores @page with custom-property values. */

@media print {

  /* "+ เพิ่มคำเตือน" is an editor prompt, not label content: a label with no
     warning must not print an empty warning box with that hint in it. */
  .ls-warn-empty {
    display: none !important;
  }

  *,
  *::before,
  *::after {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
    box-sizing: border-box !important;
  }

  html,
  body {
    margin: 0 !important;
    padding: 0 !important;
    background: #fff !important;
  }

  body>.app,
  .landing-page,
  .auth-gate {
    display: none !important;
  }

  #popoverRoot,
  #settingsRoot,
  #toastRoot,
  .guide-overlay,
  .settings-overlay,
  .s-submodal-overlay {
    display: none !important;
  }

  .print-area {
    display: block !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  .print-area .label-sheet {
    width: 78mm !important;
    max-width: 78mm !important;
    height: 58mm !important;
    max-height: 58mm !important;
    min-height: unset !important;
    aspect-ratio: unset !important;
    margin: 0 auto !important;
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    overflow: hidden !important;
    page-break-before: auto !important;
    break-before: auto !important;
    page-break-inside: avoid !important;
    break-inside: avoid !important;
    page-break-after: always !important;
    break-after: page !important;
    background: #ffffff !important;
  }

  .print-area .label-sheet.size-80x50 {
    height: 48mm !important;
    max-height: 48mm !important;
  }

  /* The same layout as the preview, at sticker size: one --u is one point
     (what 100cqw / 221.1 also works out to on the 78mm sheet). */
  .print-area .ls-in { --u: 1pt !important; }
  .print-area .size-80x50 .ls-in { --u: 0.82pt !important; }

  .print-area .label-sheet:last-child {
    page-break-after: avoid !important;
    break-after: avoid !important;
  }

  .print-area .ls-editable {
    outline: none !important;
    cursor: default !important;
  }
}

/* ================= Responsive ================= */

@media (max-width: 900px) {
  .strip-grid {
    grid-template-columns: 1fr 1fr;
  }

  .strip-grid .grow2 {
    grid-column: span 1;
  }
}

/* ==========================================================
   Chronic Disease Refill Reminder Styles (Phase 2)
   ========================================================== */
.strip-refill-bar {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px dashed var(--line, #e2e8f0);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.refill-toggle-wrap {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
  width: fit-content;
}

/* Native checkboxes are blanked out by the global `-webkit-appearance: none`
   reset on WebKit, so every checkbox in this app draws its own box. */
.refill-toggle-wrap input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.refill-toggle-wrap input:checked + .card-cb-box,
.refill-toggle-wrap input:indeterminate + .card-cb-box {
  background: var(--blue);
  border-color: var(--blue);
  box-shadow: 0 2px 6px rgba(0, 113, 227, 0.35);
}

.refill-toggle-wrap input:checked + .card-cb-box::after {
  content: '';
  width: 4px;
  height: 8px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg) translate(-0.5px, -0.5px);
}

/* Mixed basket: some medicines tracked, some not. */
.refill-toggle-wrap input:indeterminate + .card-cb-box::after {
  content: '';
  width: 8px;
  height: 2px;
  background: #ffffff;
  border-radius: 1px;
}

.refill-summary-text {
  font-size: 11px;
  font-weight: 600;
  color: var(--blue);
  background: var(--blue-soft, #eff6ff);
  padding: 2px 8px;
  border-radius: 10px;
}

.refill-summary-text:empty {
  display: none;
}

/* --- Per-medicine tracking toggle on each label card --- */
.card-refill-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  padding: 7px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-tertiary);
  font-size: 12px;
}

.card-refill-bar.tracked {
  background: #f0f9ff;
  border-bottom-color: rgba(2, 132, 199, 0.25);
}

.card-refill-toggle {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  user-select: none;
}

.card-refill-toggle input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.card-refill-toggle input:checked + .card-cb-box {
  background: #0284c7;
  border-color: #0284c7;
}

.card-refill-toggle input:checked + .card-cb-box::after {
  content: '';
  width: 4px;
  height: 8px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg) translate(-0.5px, -0.5px);
}

.card-refill-text {
  font-weight: 600;
  color: var(--ink-2);
}

.card-refill-bar.tracked .card-refill-text {
  color: #0369a1;
}

.card-refill-days {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--ink-2);
}

.card-refill-input {
  width: 58px;
  padding: 3px 7px;
  border: 1px solid rgba(2, 132, 199, 0.35);
  border-radius: 7px;
  background: #ffffff;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink);
  text-align: center;
}

.card-refill-due {
  font-weight: 700;
  color: #0369a1;
}

.refill-toggle-label {
  font-size: 13px;
  color: var(--ink, #1e293b);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.refill-toggle-label .refill-hint {
  font-size: 11px;
  color: var(--ink-3, #94a3b8);
  font-weight: 400;
}

.refill-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  background: #f0f9ff;
  border: 1px solid #bae6fd;
  border-radius: 12px;
  padding: 10px 14px;
  animation: fadeIn 0.2s ease;
}

.refill-quick-days {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.refill-sub-label {
  font-size: 12px;
  font-weight: 600;
  color: #0369a1;
}

.btn-day-pill {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  color: #334155;
  font-size: 12px;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-day-pill:hover {
  border-color: #0284c7;
  color: #0284c7;
}

.btn-day-pill.active {
  background: #0284c7;
  border-color: #0284c7;
  color: #ffffff;
  box-shadow: 0 2px 6px rgba(2, 132, 199, 0.3);
}

.refill-custom-days {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #fff;
  border: 1px solid #cbd5e1;
  border-radius: 20px;
  padding: 2px 8px 2px 10px;
}

.refill-custom-days input {
  width: 48px;
  border: none;
  background: transparent;
  font-size: 12px;
  font-weight: 600;
  text-align: center;
  color: #0f172a;
}
.refill-custom-days input:focus { outline: none; }
.refill-custom-days span { font-size: 11px; color: #64748b; }

.refill-calculated-badge {
  font-size: 12px;
  color: #0369a1;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.refill-calculated-badge strong {
  color: #0c4a6e;
}

/* Header Refill Tracker Badge */
.refill-badge-count {
  position: absolute;
  top: -4px;
  right: -4px;
  background: #ea580c;
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  min-width: 18px;
  height: 18px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  box-shadow: 0 2px 6px rgba(234, 88, 12, 0.4);
}

/* Refill Modal Drawer / Popup */
.refill-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(4px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.refill-modal {
  background: #ffffff;
  border-radius: 20px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.25);
  width: 100%;
  max-width: 900px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: modalScaleIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalScaleIn {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}

.refill-modal-header {
  padding: 18px 24px;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #f8fafc;
}

.refill-modal-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 17px;
  font-weight: 700;
  color: #0f172a;
}

.refill-modal-close {
  background: transparent;
  border: none;
  cursor: pointer;
  color: #64748b;
  font-size: 20px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}
.refill-modal-close:hover {
  background: #e2e8f0;
  color: #0f172a;
}

.refill-modal-toolbar {
  padding: 12px 24px;
  border-bottom: 1px solid #f1f5f9;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.refill-filter-btns {
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-filter-pill {
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  color: #475569;
  font-size: 12px;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.btn-filter-pill.active {
  background: #0284c7;
  border-color: #0284c7;
  color: #ffffff;
}

.refill-modal-body {
  padding: 16px 24px;
  overflow-y: auto;
  flex: 1;
}

/* Chat Inbox Modal */
.chat-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(4px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.chat-modal {
  max-width: 960px;
  height: 80vh;
}

.chat-modal-body {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.chat-list-pane {
  width: 280px;
  flex-shrink: 0;
  border-right: 1px solid #e2e8f0;
  overflow-y: auto;
  background: #f8fafc;
}

.chat-list-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  cursor: pointer;
  border-bottom: 1px solid #f1f5f9;
  transition: background 0.12s;
}
.chat-list-item:hover { background: #eef2f7; }
.chat-list-item.active { background: #e0f2fe; }

.chat-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  background: #cbd5e1;
}

.chat-list-meta { min-width: 0; flex: 1; }
.chat-list-name {
  font-size: 13px;
  font-weight: 700;
  color: #0f172a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-list-preview {
  font-size: 11.5px;
  color: #64748b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-unread-dot {
  background: #06c755;
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  min-width: 18px;
  height: 18px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  flex-shrink: 0;
}

.chat-thread-pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.chat-thread-empty {
  margin: auto;
  color: #94a3b8;
  font-size: 13px;
  text-align: center;
  padding: 20px;
}

.chat-bubble-list {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.chat-bubble {
  max-width: 70%;
  padding: 8px 12px;
  border-radius: 14px;
  font-size: 13px;
  line-height: 1.4;
}
.chat-bubble.in {
  align-self: flex-start;
  background: #f1f5f9;
  color: #0f172a;
  border-bottom-left-radius: 4px;
}
.chat-bubble.out {
  align-self: flex-end;
  background: #06c755;
  color: #fff;
  border-bottom-right-radius: 4px;
}
.chat-bubble-text { white-space: pre-wrap; word-break: break-word; }
.chat-bubble.out.pending { opacity: 0.7; }
.chat-bubble.out.failed { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }

/* Thread header — who the pharmacist is talking to */
.chat-thread-header {
  padding: 10px 16px;
  border-bottom: 1px solid #e2e8f0;
  background: #f8fafc;
  flex-shrink: 0;
}
.chat-thread-header-main {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 13px;
  color: #0f172a;
}
.chat-thread-header-meta { font-size: 11.5px; color: #64748b; }
.chat-thread-header-note { font-size: 11.5px; color: #94a3b8; }
.chat-allergy-warn {
  margin-top: 6px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #b91c1c;
  font-size: 11.5px;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 6px;
}

/* AI draft review panel — nothing here is sent until the pharmacist approves */
.chat-ai-draft {
  border-top: 2px solid #f59e0b;
  background: #fffbeb;
  padding: 10px 14px;
  flex-shrink: 0;
}
.chat-ai-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11.5px;
  font-weight: 700;
  color: #b45309;
  margin-bottom: 6px;
}
.chat-ai-x {
  background: transparent;
  border: none;
  color: #b45309;
  font-size: 18px;
  cursor: pointer;
  line-height: 1;
}
.chat-ai-textarea {
  width: 100%;
  border: 1px solid #fcd34d;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 13px;
  font-family: inherit;
  line-height: 1.5;
  resize: vertical;
  outline: none;
  background: #fff;
}
.chat-ai-textarea:focus { border-color: #f59e0b; }
.chat-ai-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 8px;
  flex-wrap: wrap;
}
.chat-ai-warn { font-size: 10.5px; color: #92400e; flex: 1; min-width: 160px; }
.chat-ai-actions { display: flex; gap: 6px; }
.chat-ai-primary {
  background: #f59e0b;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 7px 14px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}
.chat-ai-primary:disabled { opacity: 0.6; cursor: default; }
.chat-ai-secondary {
  background: transparent;
  color: #92400e;
  border: 1px solid #fcd34d;
  border-radius: 8px;
  padding: 7px 12px;
  font-size: 12px;
  cursor: pointer;
}
.chat-ai-loading { font-size: 12px; color: #b45309; padding: 4px 0; }
.chat-ai-btn {
  background: #fff7ed;
  border: 1px solid #fdba74;
  color: #c2410c;
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}
.chat-ai-btn:hover { background: #ffedd5; }
.chat-ai-btn:disabled { opacity: 0.55; cursor: default; }

/* Full-size image viewer */
.chat-lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.88);
  z-index: 10050;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
}
.chat-lightbox img {
  max-width: 92vw;
  max-height: 88vh;
  border-radius: 8px;
  object-fit: contain;
}
.chat-lightbox-close {
  position: absolute;
  top: 18px;
  right: 24px;
  background: rgba(255, 255, 255, 0.15);
  border: none;
  color: #fff;
  font-size: 26px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  line-height: 1;
}
.chat-lightbox-download {
  position: absolute;
  bottom: 24px;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  text-decoration: none;
  font-size: 12px;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: 100px;
}

.chat-bubble.chat-bubble-media {
  padding: 6px;
  background: transparent;
}
.chat-bubble-img { cursor: zoom-in; }
.chat-bubble-img {
  display: block;
  max-width: 220px;
  max-height: 220px;
  border-radius: 10px;
  object-fit: cover;
  background: #e2e8f0;
  min-height: 60px;
  min-width: 120px;
}
.chat-bubble-time {
  font-size: 10px;
  opacity: 0.65;
  margin-top: 3px;
  text-align: right;
}

.chat-input-bar {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid #e2e8f0;
  background: #fafafa;
}
.chat-input-bar input {
  flex: 1;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 13px;
  outline: none;
}
.chat-input-bar input:focus { border-color: #06c755; }

@media (max-width: 720px) {
  .chat-modal-body { flex-direction: column; }
  .chat-list-pane { width: 100%; max-height: 160px; border-right: none; border-bottom: 1px solid #e2e8f0; }
}

/* One card per patient — the person the pharmacist calls — listing that
   patient's own medicines underneath. */
.refill-patient-card {
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  margin-bottom: 12px;
  overflow: hidden;
  background: #ffffff;
}

.refill-patient-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px 14px;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
}

.refill-patient-name {
  font-size: 14px;
  color: #0f172a;
}

.refill-patient-meta {
  font-size: 11px;
  color: #64748b;
  margin-top: 3px;
}

.refill-item-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 10px 14px;
  border-bottom: 1px solid #f1f5f9;
  font-size: 13px;
}

/* Selecting which medicines go into this send — independent of which filter
   tab happens to be showing the row. */
.refill-select-toggle {
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  flex: 0 0 auto;
}

.refill-select-toggle input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.refill-select-toggle input:checked + .card-cb-box {
  background: #06c755;
  border-color: #06c755;
}

.refill-select-toggle input:checked + .card-cb-box::after {
  content: '';
  width: 4px;
  height: 8px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg) translate(-0.5px, -0.5px);
}

.refill-item-row:last-child {
  border-bottom: none;
}

.refill-item-row:hover {
  background: #f8fafc;
}

.refill-item-main {
  flex: 1 1 200px;
  min-width: 0;
  color: #1e293b;
}

.refill-item-meta {
  display: block;
  font-size: 11px;
  color: #94a3b8;
  margin-top: 2px;
}

/* Both dates sit on the row: the pharmacist checks the due date against when
   the medicine was actually handed over before trusting it. */
.refill-item-dates {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 16px;
  color: #1e293b;
}

.refill-date-block {
  display: flex;
  flex-direction: column;
  line-height: 1.35;
}

.refill-date-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .02em;
  color: #94a3b8;
}

.refill-date-value {
  font-size: 12.5px;
  color: #475569;
}

.refill-date-value.strong {
  font-size: 13px;
  font-weight: 700;
  color: #0f172a;
}

.refill-line-yes { color: #06c755; font-weight: 600; }
.refill-line-no { color: #94a3b8; }

.refill-no-line-note {
  font-size: 11px;
  color: #94a3b8;
}

/* A request in flight, so the row cannot be acted on twice. */
.refill-item-row.is-busy {
  opacity: .5;
  pointer-events: none;
}

.refill-item-row.is-editing {
  background: #f0f9ff;
  box-shadow: inset 2px 0 0 var(--blue);
}

/* Confirming or editing happens in the row itself rather than in a browser
   dialog, so the answer appears where the question was asked. */
.refill-inline-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  width: 100%;
}

.refill-inline-text {
  font-size: 13px;
  color: #0f172a;
}

.refill-inline-sub {
  display: block;
  font-size: 11px;
  color: #64748b;
  margin-top: 2px;
}

.refill-inline-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}

.refill-date-input {
  padding: 4px 8px;
  border: 1px solid rgba(2, 132, 199, 0.4);
  border-radius: 7px;
  font-family: inherit;
  font-size: 12px;
  color: var(--ink);
  background: #ffffff;
}

.refill-row-error {
  flex: 1 0 100%;
  margin-top: 6px;
  font-size: 11.5px;
  font-weight: 600;
  color: #b91c1c;
}

/* Marks the row that just changed, so the new value reads as the result of
   what was done rather than as something that was always there. */
@keyframes refillJustUpdated {
  from { background: #dcfce7; }
  to { background: transparent; }
}

.refill-item-row.just-updated {
  animation: refillJustUpdated 1.8s ease-out;
}

.refill-empty {
  text-align: center;
  padding: 36px 20px;
}

.refill-empty-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
}

.refill-empty-sub {
  font-size: 12px;
  color: var(--ink-3);
  margin-top: 4px;
}

.refill-item-actions {
  flex: 0 0 auto;
  display: flex;
  gap: 6px;
  margin-left: auto;
}

.refill-mini-btn {
  border: 1px solid #e2e8f0;
  background: #ffffff;
  color: #475569;
  padding: 4px 9px;
  border-radius: 7px;
  font-family: inherit;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s ease;
}

.refill-mini-btn:hover {
  background: #f1f5f9;
  color: #0f172a;
}

.refill-mini-btn.danger:hover {
  background: #fee2e2;
  border-color: #fecaca;
  color: #b91c1c;
}

.refill-mini-btn.solid {
  background: var(--blue);
  border-color: var(--blue);
  color: #ffffff;
}

.refill-mini-btn.solid:hover {
  background: #0062c4;
  color: #ffffff;
}

.refill-mini-btn.danger.solid {
  background: #dc2626;
  border-color: #dc2626;
  color: #ffffff;
}

.refill-mini-btn.danger.solid:hover {
  background: #b91c1c;
  color: #ffffff;
}

.refill-mini-btn:disabled {
  opacity: .5;
  cursor: not-allowed;
}

.refill-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 100px;
  font-size: 11px;
  font-weight: 700;
}
.refill-status-due { background: #fef3c7; color: #b45309; }
.refill-status-overdue { background: #fee2e2; color: #b91c1c; }
.refill-status-notified { background: #dcfce7; color: #15803d; }
.refill-status-future { background: #e0f2fe; color: #0369a1; }
.refill-status-far { background: #f1f5f9; color: #64748b; }
.refill-status-stopped { background: #f1f5f9; color: #94a3b8; }

/* Stopped medicines read as set-aside, not as something needing attention. */
.refill-patient-card.is-stopped-view {
  opacity: .85;
}

.refill-patient-card.is-stopped-view .refill-item-main strong {
  color: #64748b;
}

.refill-patient-card.is-stopped-view .refill-date-value.strong {
  color: #64748b;
}

.btn-send-refill-sm {
  background: #06c755;
  color: #fff;
  border: none;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s;
}
.btn-send-refill-sm:hover {
  background: #05b04c;
}
.btn-send-refill-sm:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

@media (max-width: 640px) {
  .workspace {
    padding: 14px;
  }

  .gallery {
    grid-template-columns: 1fr;
    justify-content: center;
  }

  .label-sheet {
    margin: 0 auto;
  }

  .app-bar-inner {
    padding: 10px 14px;
  }

  .brand-text h1 {
    font-size: 15px;
  }

  .status-bar {
    justify-content: center;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}
/* ==========================================================
   MOBILE / TABLET OPTIMIZATION  — Pharmacy Label System v4.0
   Target: iPad pharmacist workflow + mobile LINE notifications
   Added: 2026-09-15
   ========================================================== */

/* ── Touch targets: all touch-screen devices ─────────────── */
@media (pointer: coarse) {
  .btn-settings,
  .btn-strip-action,
  .btn-print,
  .btn-guide,
  .field input,
  .field select,
  .s-select,
  .vsw-select,
  .btn-day-pill,
  #drugSearch {
    min-height: 44px;
  }
  .batch-cb-label { min-height: 36px; }
}

/* ── iPad / Tablet / Zoomed Viewport (≤1024px) ───────────── */
@media (max-width: 1024px) {
  .app-bar-inner { padding: 8px 14px; gap: 8px; }
  .brand-sub { display: none !important; }
  .brand-text h1 { font-size: 14px; line-height: 1.2; }

  /* Header: icon-only for secondary actions to prevent squeezing */
  #viewLandingBtn span,
  #btnLockApp span,
  #openSettingsBtn .btn-text,
  #btnOpenRefillTracker > span:not(.refill-badge-count) { display: none !important; }
  
  #viewLandingBtn,
  #btnLockApp,
  #openSettingsBtn,
  #btnOpenRefillTracker {
    padding: 8px 10px !important;
    gap: 0 !important;
    white-space: nowrap !important;
    flex-shrink: 0;
  }
  .user-role { display: none !important; }
  .user-chip { padding: 4px 8px 4px 4px; flex-shrink: 0; }

  /* Strip head stack to avoid button crushing */
  .strip-head { flex-direction: column; align-items: stretch; gap: 8px; }
  .strip-actions { flex-wrap: wrap; gap: 6px; }
  .btn-strip-action { white-space: nowrap !important; flex-shrink: 0; }

  /* Strip grid → 3 col */
  .strip-grid {
    grid-template-columns: 2fr 1fr 1fr;
  }
  .strip-grid .grow2 { grid-column: span 2; }

  /* Toolbar: wrap to 2 rows */
  .toolbar { flex-wrap: wrap; gap: 8px; }
  .toolbar-left { flex: 1 1 100%; }
  .toolbar-right { flex: 1 1 100%; }

  /* Gallery: 2 col on tablet */
  .gallery:not(.view-compact):not(.view-full) {
    grid-template-columns: repeat(2, 1fr) !important;
  }
}

/* ── Mobile & Small Screens (≤ 768px) ────────────────────── */
@media (max-width: 768px) {
  /* Header compact — prevent ALL overflow */
  .app-bar-inner {
    padding: 8px 12px;
    gap: 6px;
    overflow: hidden;
  }

  /* Brand: icon only — hide text on all phones */
  .brand-text { display: none !important; }
  .brand { gap: 0; flex: 0 0 auto; }
  .brand-icon { width: 34px; height: 34px; flex: 0 0 34px; }

  /* Header-actions: flex row, icon-only, no wrap */
  .header-actions {
    gap: 4px;
    flex: 1;
    justify-content: flex-end;
    overflow: hidden;
    flex-wrap: nowrap;
  }

  /* All header buttons: icon-only, square */
  .btn-settings {
    padding: 8px !important;
    gap: 0 !important;
    flex-shrink: 0;
    white-space: nowrap !important;
  }

  /* Hide ALL text inside header buttons */
  #viewLandingBtn > span,
  #btnLockApp > span,
  #openSettingsBtn .btn-text { display: none !important; }
  #btnOpenRefillTracker > span:not(.refill-badge-count) { display: none !important; }

  /* Uniform icon size in header */
  .header-actions svg { width: 18px; height: 18px; flex-shrink: 0; }

  /* Hide home button — brand icon acts as home */
  #viewLandingBtn { display: none !important; }

  /* User chip: avatar only */
  .user-meta { display: none !important; }
  .user-chip { padding: 5px; flex-shrink: 0; }
  .user-chip .avatar { width: 28px; height: 28px; }

  /* ── Strip head: stack vertically ─── */
  .strip-head { flex-direction: column; align-items: stretch; gap: 8px; }

  /* Strip actions: 2-col grid — no more overflow */
  .strip-actions {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    flex-wrap: unset;
  }

  /* Language selector spans full width */
  .global-lang-wrap {
    grid-column: 1 / -1;
    width: 100%;
    flex: unset;
  }
  .global-lang-wrap .s-select {
    width: 100%;
    flex: 1;
  }

  /* LINE button: full width, at the bottom */
  #sendLineBtn {
    grid-column: 1 / -1;
    justify-content: center;
    order: 10;
    flex: unset;
  }

  /* Strip action buttons: compact, no overflow */
  .btn-strip-action {
    min-height: 36px !important; /* override coarse device rule */
    font-size: 11.5px;
    padding: 6px 10px;
    justify-content: center;
    white-space: nowrap !important;
    flex-shrink: 0;
  }

  /* Hide icons in strip buttons to save row space */
  .strip-actions .btn-strip-action > svg { display: none; }

  /* Strip grid: 2-col on mobile */
  .strip-grid {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }
  .strip-grid .grow2 { grid-column: span 2; }

  /* Refill section: compact */
  .refill-quick-days { flex-wrap: wrap; }

  /* Toolbar: hide less-used controls */
  .view-size-wrap { display: none; }
  .btn-guide { display: none; }
  .toolbar-left { width: 100%; }
  .toolbar-right { width: 100%; justify-content: space-between; flex-wrap: wrap; gap: 8px; }
  .batch-select-wrap { order: -1; }
  .btn-print { flex: 1 1 auto; justify-content: center; white-space: nowrap; }

  /* Gallery: single column */
  .gallery,
  .gallery.view-full,
  .gallery.view-compact,
  .gallery.view-large {
    grid-template-columns: 1fr !important;
  }
  .label-sheet { margin: 0 auto; max-width: 420px; }

  /* Footer shortcuts: hide */
  .shortcuts { display: none; }

  /* Padding for sticky bottom bar */
  .workspace { padding-bottom: 80px; }
}

/* ── Sticky Mobile Bottom Action Bar ────────────────────── */
.mobile-bar {
  display: none;
}

@media (max-width: 768px) {
  .mobile-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 60;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(24px) saturate(180%);
    -webkit-backdrop-filter: blur(24px) saturate(180%);
    border-top: 1px solid rgba(0,0,0,0.1);
    padding: 8px 14px;
    padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
    box-shadow: 0 -4px 24px rgba(0,0,0,0.08);
  }

  .mobile-bar-search {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
  }

  .mobile-bar-search svg {
    position: absolute;
    left: 10px;
    color: #94a3b8;
    pointer-events: none;
    width: 16px;
    height: 16px;
  }

  .mobile-bar-input {
    width: 100%;
    height: 40px;
    padding: 0 12px 0 34px;
    background: #f1f5f9;
    border: 1.5px solid transparent;
    border-radius: 20px;
    font-size: 14px;
    font-family: inherit;
    color: #1e293b;
    outline: none;
    transition: border-color 0.15s;
  }
  .mobile-bar-input:focus {
    border-color: #0071e3;
    background: #fff;
  }
  .mobile-bar-input::placeholder { color: #94a3b8; }

  .mobile-bar-btn {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    min-width: 54px;
    height: 52px;
    padding: 6px 10px;
    border: none;
    border-radius: 14px;
    font-size: 10px;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    transition: transform 0.12s ease, opacity 0.12s ease;
    flex-shrink: 0;
  }
  .mobile-bar-btn:active { transform: scale(0.93); opacity: 0.85; }

  .mobile-bar-btn svg { width: 20px; height: 20px; flex-shrink: 0; }

  .mobile-bar-btn-line {
    background: #06C755;
    color: #fff;
  }
  .mobile-bar-btn-print {
    background: #0071e3;
    color: #fff;
  }

  /* Hide the toolbar print button on mobile (use bottom bar instead) */
  .btn-print { display: none; }

  .workspace { padding-bottom: 80px; }
}

/* ── Very small phones ≤ 400px ──────────────────────────── */
@media (max-width: 400px) {
  .brand-text { display: none; }
  .brand { gap: 0; }
}

/* ── iPad-specific tweaks (landscape) ───────────────────── */
@media (min-width: 641px) and (max-width: 1024px) {
  /* Keep print button visible on iPad toolbar */
  .btn-print { display: inline-flex; }

  /* Bottom bar: show only on portrait */
  @media (orientation: portrait) {
    .mobile-bar { display: flex; }
    .workspace { padding-bottom: 80px; }
  }
  @media (orientation: landscape) {
    .mobile-bar { display: none; }
    .workspace { padding-bottom: 16px; }
  }
}

/* ================= LINE chat: new-message popup + sound toggle ================= */

.chat-avatar.chat-avatar-fallback,
.chat-notify-avatar.chat-avatar-fallback {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #dcfce7;
  color: #15803d;
  font-weight: 700;
  font-size: 15px;
}

.chat-modal-head-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.chat-sound-toggle {
  border: 1px solid #bbf7d0;
  background: #f0fdf4;
  color: #15803d;
  font-size: 12px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 999px;
  cursor: pointer;
}
.chat-sound-toggle:hover { background: #dcfce7; }
.chat-sound-toggle.off {
  border-color: #e2e8f0;
  background: #f8fafc;
  color: #64748b;
}

/* Sits above the chat modal (z-index 9999) so it shows even while chatting with someone else. */
#chatNotifyRoot {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 10050;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: min(360px, calc(100vw - 32px));
  pointer-events: none;
}

.chat-notify {
  pointer-events: auto;
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 40px 14px 14px;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-left: 4px solid #06c755;
  border-radius: 14px;
  box-shadow: 0 14px 36px -10px rgba(15, 23, 42, .28), 0 4px 10px rgba(15, 23, 42, .06);
  cursor: pointer;
  animation: chatNotifyIn .28s cubic-bezier(.2, .8, .2, 1);
}
.chat-notify:hover { border-color: #cbd5e1; border-left-color: #06c755; }
.chat-notify:focus-visible { outline: 2px solid #06c755; outline-offset: 2px; }
.chat-notify.out { animation: chatNotifyOut .22s ease forwards; }

.chat-notify-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  background: #cbd5e1;
}

.chat-notify-body { min-width: 0; flex: 1; }
.chat-notify-top {
  display: flex;
  align-items: center;
  gap: 8px;
}
.chat-notify-name {
  font-size: 14px;
  font-weight: 700;
  color: #0f172a;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chat-notify-count {
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 700;
  color: #15803d;
  background: #dcfce7;
  padding: 1px 7px;
  border-radius: 999px;
}
.chat-notify-text {
  margin-top: 3px;
  font-size: 13px;
  line-height: 1.45;
  color: #334155;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}
.chat-notify-hint {
  margin-top: 6px;
  font-size: 11.5px;
  font-weight: 600;
  color: #06a347;
}

.chat-notify-close {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 26px;
  height: 26px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: #94a3b8;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}
.chat-notify-close:hover { background: #f1f5f9; color: #475569; }

@keyframes chatNotifyIn {
  from { opacity: 0; transform: translateX(24px); }
  to { opacity: 1; transform: none; }
}
@keyframes chatNotifyOut {
  to { opacity: 0; transform: translateX(24px); }
}

@media (prefers-reduced-motion: reduce) {
  .chat-notify, .chat-notify.out { animation: none; }
}

@media (max-width: 640px) {
  #chatNotifyRoot { top: 12px; right: 16px; left: 16px; width: auto; }
}

/* ================= In-place feedback ================= */

/* Result of an action, placed right after the control that was used */
.inline-status {
  display: inline-flex;
  align-items: center;
  margin-left: 8px;
  max-width: 320px;
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1.3;
  white-space: normal;
  color: var(--ink-3);
}
.inline-status[data-kind="ok"] { color: #15803d; }
.inline-status[data-kind="err"] { color: #b91c1c; }
/* Phone layout turns the strip actions into a grid with the LINE button last
   (order: 10); keep its status as a full row right under it. */
.strip-actions > .inline-status { grid-column: 1 / -1; order: 11; }
@media (max-width: 768px) {
  .strip-actions > .inline-status { margin-left: 0; max-width: none; }
}

/* Two-step confirm: the button itself becomes the question for a few seconds */
.is-confirming {
  background: #dc2626 !important;
  border-color: #dc2626 !important;
  color: #ffffff !important;
}

/* Allergy / chronic disease of the patient being served — stays up while
   the labels are prepared, cleared when the patient changes */
.pt-alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-top: 12px;
  padding: 10px 14px;
  border: 1.5px solid #f59e0b;
  border-left-width: 6px;
  border-radius: 10px;
  background: #fffbeb;
  color: #92400e;
}
.pt-alert[hidden] { display: none; }
.pt-alert.has-allergy {
  border-color: #dc2626;
  background: #fef2f2;
  color: #b91c1c;
}
.pt-alert-icon { flex-shrink: 0; margin-top: 1px; }
.pt-alert-body {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
  font-size: 13.5px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}
.pt-alert-row strong { font-weight: 800; margin-right: 2px; }
.pt-alert-row.allergy { color: #b91c1c; }
.pt-alert-row.condition { color: #92400e; }

/* Screen-only note on a label card (never printed) */
.card-note {
  margin: 0 0 8px;
  padding: 5px 9px;
  font-size: 11.5px;
  font-weight: 600;
  color: #92400e;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 7px;
}

/* Popover editor: outside click held back because of unsaved text */
.pop-hint {
  margin: 8px 0 2px;
  font-size: 12px;
  font-weight: 700;
  color: #b45309;
}
.pop-hint.nudge { animation: popHintNudge .3s ease; }
@keyframes popHintNudge {
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

/* Chat: background refresh failed (thread kept), and why a send failed */
.chat-conn-status {
  padding: 6px 16px;
  font-size: 11.5px;
  font-weight: 600;
  color: #92400e;
  background: #fffbeb;
  border-top: 1px solid #fde68a;
}
.chat-compose-error {
  padding: 0 16px 10px;
  font-size: 12px;
  font-weight: 600;
  color: #b91c1c;
  background: #fafafa;
}
.chat-bubble-video {
  display: block;
  max-width: 260px;
  max-height: 320px;
  border-radius: 10px;
  background: #0f172a;
}
.chat-bubble-audio { display: block; width: 240px; max-width: 100%; }
.chat-media-failed { font-size: 12px; color: #b91c1c; }

/* Above the mobile bottom bar, where the thumb is */
.mobile-bar-hint {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  transform: translateX(-50%);
  width: max-content;
  max-width: calc(100vw - 32px);
  padding: 8px 14px;
  border-radius: 10px;
  background: #0f172a;
  color: #f8fafc;
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  box-shadow: 0 8px 24px -8px rgba(15, 23, 42, .45);
  pointer-events: none;
}
.mobile-bar-hint[data-kind="err"] { background: #b91c1c; }
.mobile-bar-hint[data-kind="ok"] { background: #15803d; }

/* Refill rows: keep the destructive action apart from the everyday one */
.refill-item-actions .refill-mini-btn.danger { margin-left: 8px; }

@media (pointer: coarse) {
  .refill-mini-btn {
    min-height: 40px;
    padding: 8px 14px;
    font-size: 12.5px;
  }
  .refill-item-actions { gap: 10px; }
  .refill-item-actions .refill-mini-btn.danger { margin-left: 18px; }
}

/* Sex / allergy / conditions row of the patient strip */
.strip-grid-info {
  grid-template-columns: 0.9fr 2fr 2fr;
  margin-top: 12px;
}
.field select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2.5'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}
@media (max-width: 900px) {
  .strip-grid-info { grid-template-columns: 1fr 1fr; }
  .strip-grid-info .field:last-child { grid-column: span 2; }
}

/* ================= Dosage builder popover ================= */
.popover.pop-wide {
  width: 640px;
  max-height: calc(100vh - 16px);
  display: flex;
  flex-direction: column;
}
.popover.pop-wide .pop-body { overflow-y: auto; min-height: 0; }
/* Each part of the dosage (quick picks, action, amount, frequency, meal and
   time of day) sits in its own box, so the chip groups don't run together
   into one wall of options. */
.dz-section {
  margin-bottom: 8px;
  padding: 10px 12px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-secondary);
}
.dz-section.dz-quick {
  background: var(--blue-soft);
  border-color: var(--blue-ring);
}
.dz-section .ed-field-label {
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--line-soft);
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-2);
}
.dz-grid { counter-reset: dz-step; }
.dz-grid > .dz-section > .ed-field-label::before {
  counter-increment: dz-step;
  content: counter(dz-step);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  margin-right: 6px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  font-size: 11px;
  color: var(--ink-3);
  vertical-align: 1px;
}
.dz-opt { font-weight: 500; color: var(--ink-4); font-size: 11px; margin-left: 4px; }
.dz-amount { display: flex; gap: 6px; margin-top: 6px; max-width: 280px; }
.dz-amount #edDoseQty { flex: 0 0 90px; }
.dz-second {
  margin-top: 6px;
  padding: 6px 10px;
  border-radius: var(--r-sm);
  background: var(--surface-tertiary);
  color: var(--ink-2);
  font-size: 12.5px;
  line-height: 1.4;
}
.dz-second:empty { display: none; }

/* ================= Settings > Dosage: one category per sub-tab ================= */
.s-subnav {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 14px;
}
.s-subnav-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
  background: var(--surface-tertiary);
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  cursor: pointer;
  transition: all .12s ease;
}
.s-subnav-btn:hover { background: #ffffff; border-color: rgba(0, 0, 0, 0.18); }
.s-subnav-btn.active { background: var(--blue); border-color: var(--blue); color: #fff; }
.s-subnav-count {
  font-size: 11px;
  font-weight: 700;
  padding: 0 6px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.06);
}
.s-subnav-btn.active .s-subnav-count { background: rgba(255, 255, 255, 0.25); }
.s-tag.gray { color: var(--ink-4); background: transparent; border-style: dashed; }

/* --- Landing: supported label languages strip --- */
.landing-langs {
  padding: 56px 0 60px;
  background: #ffffff;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}
.lp-langs-head {
  text-align: center;
  max-width: 640px;
  margin: 0 auto 28px;
}
.lp-langs-title {
  font-size: clamp(24px, 3.2vw, 34px);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
  color: #1d1d1f;
  margin: 0 0 10px;
}
.lp-langs-sub {
  font-size: 15px;
  line-height: 1.55;
  color: #6e6e73;
  margin: 0;
}
.lp-lang-list {
  list-style: none;
  margin: 0 auto;
  padding: 0;
  max-width: 860px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}
.lp-lang-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 104px;
  padding: 12px 18px;
  background: #f5f5f7;
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: 16px;
  box-sizing: border-box;
}
.lp-lang-chip-base {
  background: #e8f1fc;
  border-color: rgba(0, 113, 227, 0.22);
}
.lp-lang-native {
  font-size: 18px;
  font-weight: 600;
  line-height: 1.5;
  color: #1d1d1f;
  white-space: nowrap;
}
.lp-lang-native:lang(zh-Hant) { font-family: "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif; }
.lp-lang-native:lang(my) { font-family: "Noto Sans Myanmar", "Myanmar Sangam MN", "Myanmar Text", sans-serif; }
.lp-lang-native:lang(ko) { font-family: "Noto Sans KR", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif; }
.lp-lang-th {
  font-size: 12px;
  font-weight: 500;
  color: #6e6e73;
}
.lp-lang-chip-base .lp-lang-th { color: #0071e3; }
.bento-chips { flex-wrap: wrap; }
@media (max-width: 640px) {
  .landing-langs { padding: 40px 0 44px; }
  .landing-langs .landing-container { padding: 0 16px; }
  .lp-lang-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .lp-lang-chip { min-width: 0; padding: 10px 12px; }
  .lp-lang-chip-base { grid-column: 1 / -1; }
  .lp-lang-native { font-size: 17px; }
}
