/* Off Farma - design system do painel. Tokens primeiro, componentes depois. */
:root {
  --brand: #0f7b4f;            /* cor da farmácia (editável no painel) */
  --on-brand: #ffffff;
  --font: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --r-sm: 10px; --r-md: 14px; --r-lg: 20px; --r-xl: 28px;
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px;
  --ease: cubic-bezier(.2, .7, .2, 1);
  --nav-w: 264px; --bottom-h: 68px;
}
:root[data-theme="light"] {
  --bg: #f4f5f6; --surface: #ffffff; --surface-2: #f8f9fa; --surface-3: #eef0f2;
  --border: #e4e7ea; --border-strong: #cfd5da;
  --text: #14191c; --muted: #5f6b73; --faint: #8d979e;
  --primary: var(--brand); --primary-soft: color-mix(in srgb, var(--brand) 9%, white);
  --accent: #22a06b;
  --hero-1: #ffffff; --hero-2: color-mix(in srgb, var(--brand) 7%, white); --on-hero: var(--text); --on-hero-muted: var(--muted);
  --ok: #0f7b4f; --ok-soft: #e1f5ea; --warn: #9a5b00; --warn-soft: #fdf1d8; --err: #b42318; --err-soft: #fde8e6; --info: #0c5c8a; --info-soft: #e0f0fa;
  --shadow: 0 1px 2px rgba(17, 38, 46, .05), 0 6px 18px rgba(17, 38, 46, .05);
  --shadow-pop: 0 10px 40px rgba(17, 38, 46, .18);
  --logo-tile: transparent;
}
.lg { display: inline-flex; } .lg img { height: 100%; width: auto; display: block; }
.lg .logo-d { display: none; } :root[data-theme="dark"] .lg .logo-d { display: block; } :root[data-theme="dark"] .lg .logo-l { display: none; }
:root[data-theme="dark"] {
  --bg: #0f1213; --surface: #171b1d; --surface-2: #1d2225; --surface-3: #262c2f;
  --border: #2a3135; --border-strong: #3a4348;
  --text: #eceff1; --muted: #9aa5ab; --faint: #727d84;
  --primary: color-mix(in srgb, var(--brand) 62%, #6ee7b7); --primary-soft: color-mix(in srgb, var(--brand) 20%, #171b1d);
  --accent: #4ade80;
  --hero-1: #1b2124; --hero-2: color-mix(in srgb, var(--brand) 16%, #171b1d); --on-hero: var(--text); --on-hero-muted: var(--muted);
  --ok: #4ade80; --ok-soft: #12362a; --warn: #fbbf24; --warn-soft: #3a2d0c; --err: #fb7185; --err-soft: #3d1a20; --info: #7dd3fc; --info-soft: #0f2b3b;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .3);
  --shadow-pop: 0 14px 50px rgba(0, 0, 0, .6);
  --logo-tile: transparent;
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 var(--font); -webkit-font-smoothing: antialiased; transition: background .2s, color .2s; }
button, input, select { font: inherit; color: inherit; }
h1, h2, h3, p { margin: 0; }
.i { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.i.sm { width: 16px; height: 16px; } .i.lg { width: 24px; height: 24px; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--primary) 55%, transparent); outline-offset: 2px; border-radius: 8px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- estrutura ---------- */
.app { display: grid; grid-template-columns: var(--nav-w) minmax(0, 1fr); min-height: 100vh; min-height: 100dvh; }
.side { position: sticky; top: 0; height: 100vh; height: 100dvh; padding: var(--s5) var(--s4); display: flex; flex-direction: column; gap: var(--s4); background: var(--surface); border-right: 1px solid var(--border); }
.brand { display: flex; align-items: center; gap: var(--s3); padding: 0 var(--s2); }
.brand .lg { height: 46px; }
.brand .pharm { font-size: 12px; color: var(--muted); line-height: 1.25; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.brand .pharm b { display: block; color: var(--text); font-size: 13.5px; }
.nav { display: flex; flex-direction: column; gap: 2px; margin-top: var(--s2); }
.nav a { display: flex; align-items: center; gap: var(--s3); padding: 11px 14px; border-radius: var(--r-md); color: var(--muted); text-decoration: none; font-weight: 550; transition: background .15s, color .15s; }
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a[aria-current="page"] { background: var(--primary-soft); color: var(--primary); }
.side .foot { margin-top: auto; font-size: 12px; color: var(--faint); padding: 0 var(--s2); }
.main { min-width: 0; display: flex; flex-direction: column; }
.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: var(--s3); padding: 14px var(--s5); background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--border); }
.top h1 { font-size: 20px; letter-spacing: -.01em; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top .mobile-logo { display: none; height: 32px; width: auto; }
.page { padding: var(--s5); max-width: 1180px; width: 100%; margin: 0 auto; display: flex; flex-direction: column; gap: var(--s5); animation: rise .35s var(--ease); }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* barra inferior (celular) */
.bottom { display: none; position: fixed; inset: auto 0 0 0; z-index: 30; height: calc(var(--bottom-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); background: var(--surface); border-top: 1px solid var(--border); grid-template-columns: repeat(5, 1fr); }
.bottom a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 11.5px; font-weight: 600; color: var(--muted); text-decoration: none; }
.bottom a[aria-current="page"] { color: var(--primary); }
.bottom a[aria-current="page"] .i { transform: translateY(-1px); }

/* ---------- componentes ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: var(--s5); box-shadow: var(--shadow); min-width: 0; }
.card h2 { font-size: 15px; font-weight: 650; display: flex; align-items: center; gap: var(--s2); }
.card .sub { color: var(--muted); font-size: 13.5px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); margin-bottom: var(--s4); }
.bento { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: var(--s4); }
.span-12 { grid-column: span 12; } .span-8 { grid-column: span 8; } .span-6 { grid-column: span 6; } .span-4 { grid-column: span 4; }
.hero { position: relative; overflow: hidden; color: var(--on-hero); background: linear-gradient(135deg, var(--hero-1) 35%, var(--hero-2)); }
.hero::before { content: ""; position: absolute; left: 0; top: 18px; bottom: 18px; width: 4px; border-radius: 0 4px 4px 0; background: var(--primary); }
.hero .sub, .hero .lab { color: var(--on-hero-muted); }
.hero .lab { font-size: 13px; font-weight: 600; display: flex; align-items: center; gap: var(--s2); }
.hero .big { font-size: clamp(38px, 6vw, 56px); font-weight: 750; letter-spacing: -.03em; line-height: 1.05; margin: var(--s3) 0 var(--s2); font-variant-numeric: tabular-nums; }
.hero .row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s3); margin-top: var(--s4); }
.stat-n { font-size: clamp(22px, 2.3vw, 30px); overflow-wrap: anywhere; font-weight: 720; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.ring { --p: 0; width: 84px; height: 84px; border-radius: 50%; display: grid; place-items: center; background: conic-gradient(var(--primary) calc(var(--p) * 1%), var(--surface-3) 0); flex: none; }
.ring > span { width: 64px; height: 64px; border-radius: 50%; background: var(--surface); display: grid; place-items: center; font-weight: 750; font-size: 18px; }
.flex { display: flex; align-items: center; gap: var(--s4); }
.stack { display: flex; flex-direction: column; gap: var(--s3); }
.between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.muted { color: var(--muted); } .faint { color: var(--faint); } .small { font-size: 13px; } .mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--s2); min-height: 44px; padding: 0 var(--s4); border-radius: var(--r-md); border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font-weight: 600; cursor: pointer; transition: transform .12s var(--ease), background .15s, border-color .15s, opacity .15s; text-decoration: none; white-space: nowrap; }
.btn:hover { background: var(--surface-2); } .btn:active { transform: scale(.98); }
.btn.primary { background: var(--primary); border-color: transparent; color: var(--on-brand); }
:root[data-theme="dark"] .btn.primary { color: #052e1f; }
.btn.primary:hover { filter: brightness(1.06); background: var(--primary); }
.btn.ghost { background: transparent; border-color: transparent; } .btn.ghost:hover { background: var(--surface-2); }
.btn.danger { color: var(--err); border-color: color-mix(in srgb, var(--err) 40%, transparent); } .btn.danger:hover { background: var(--err-soft); }
.btn[disabled], .btn[aria-busy="true"] { opacity: .55; pointer-events: none; }
.btn.sm { min-height: 36px; padding: 0 var(--s3); font-size: 13.5px; border-radius: var(--r-sm); }
.btn.icon { width: 44px; padding: 0; } .btn.icon.sm { width: 36px; }
.spin { animation: spin .8s linear infinite; } @keyframes spin { to { transform: rotate(360deg); } }

.pill { display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px; border-radius: 99px; font-size: 12.5px; font-weight: 650; background: var(--surface-3); color: var(--muted); white-space: nowrap; }
.pill .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.pill.ok { background: var(--ok-soft); color: var(--ok); } .pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.err { background: var(--err-soft); color: var(--err); } .pill.info { background: var(--info-soft); color: var(--info); }
.pill.pulse .dot { animation: pulse 1.6s ease-in-out infinite; } @keyframes pulse { 50% { opacity: .35; } }

.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13.5px; font-weight: 600; }
.field .hint { font-size: 12.5px; color: var(--muted); }
.inp { width: 100%; min-height: 48px; padding: 0 14px; border-radius: var(--r-md); border: 1px solid var(--border-strong); background: var(--surface); transition: border-color .15s, box-shadow .15s; }
.inp:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary) 20%, transparent); }
.inp[aria-invalid="true"] { border-color: var(--err); }
.pw { position: relative; } .pw .inp { padding-right: 54px; } .pw button { position: absolute; right: 4px; top: 4px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s4); }
.err-msg { color: var(--err); font-size: 13.5px; font-weight: 550; min-height: 20px; }
.switch { display: flex; align-items: center; justify-content: space-between; gap: var(--s4); }
.switch input { appearance: none; width: 50px; height: 30px; border-radius: 99px; background: var(--border-strong); position: relative; cursor: pointer; transition: background .2s; flex: none; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.3); transition: transform .2s var(--ease); }
.switch input:checked { background: var(--primary); } .switch input:checked::after { transform: translateX(20px); }

.list { display: flex; flex-direction: column; }
.row-item { display: flex; align-items: center; gap: var(--s3); padding: 13px 0; border-top: 1px solid var(--border); min-width: 0; }
.row-item:first-child { border-top: 0; padding-top: 0; }
.avatar { width: 42px; height: 42px; border-radius: 13px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); flex: none; }
.row-item .grow { flex: 1; min-width: 0; } .row-item .t { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-item .d { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty { text-align: center; padding: var(--s6) var(--s4); color: var(--muted); }
.empty .avatar { margin: 0 auto var(--s3); width: 56px; height: 56px; border-radius: 18px; }
.empty b { display: block; color: var(--text); margin-bottom: 4px; }
.sk { border-radius: 10px; background: linear-gradient(90deg, var(--surface-3), var(--surface-2), var(--surface-3)); background-size: 200% 100%; animation: sh 1.2s linear infinite; } @keyframes sh { to { background-position: -200% 0; } }

.code-box { display: flex; align-items: center; justify-content: center; gap: var(--s3); padding: var(--s5); border-radius: var(--r-lg); background: var(--primary-soft); border: 1px dashed color-mix(in srgb, var(--primary) 45%, transparent); }
.code-box .code { font-size: clamp(30px, 8vw, 44px); font-weight: 780; letter-spacing: .12em; color: var(--primary); font-variant-numeric: tabular-nums; }
.steps { counter-reset: s; display: flex; flex-direction: column; gap: var(--s3); padding: 0; margin: 0; list-style: none; }
.steps li { counter-increment: s; display: flex; gap: var(--s3); align-items: flex-start; }
.steps li::before { content: counter(s); flex: none; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-size: 13px; font-weight: 700; background: var(--primary-soft); color: var(--primary); }
.swatches { display: flex; flex-wrap: wrap; gap: 10px; }
.swatch { width: 40px; height: 40px; border-radius: 12px; border: 3px solid transparent; cursor: pointer; box-shadow: inset 0 0 0 1px rgba(0,0,0,.15); }
.swatch[aria-pressed="true"] { border-color: var(--text); }
.preview { border-radius: var(--r-lg); overflow: hidden; border: 1px solid var(--border); background: var(--surface-2); }
.preview .bar { display: flex; align-items: center; gap: var(--s3); padding: 14px var(--s4); background: var(--pv, var(--brand)); color: #fff; font-weight: 700; }
.preview .bar img { height: 30px; background: rgba(255,255,255,.92); border-radius: 8px; padding: 2px 6px; }
.preview .body { padding: var(--s4); display: flex; flex-direction: column; gap: 8px; }
.preview .fake { height: 44px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border); }
.alert { display: flex; gap: var(--s3); padding: var(--s3) var(--s4); border-radius: var(--r-md); font-size: 13.5px; background: var(--info-soft); color: var(--info); }
.alert.warn { background: var(--warn-soft); color: var(--warn); } .alert.err { background: var(--err-soft); color: var(--err); }
.alert > div { color: var(--text); } .alert .i { margin-top: 1px; }

/* ---------- entrada (login / primeiro acesso) ---------- */
.gate { min-height: 100vh; min-height: 100dvh; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); }
.gate-art { position: relative; overflow: hidden; color: var(--text); padding: 48px; display: flex; flex-direction: column; justify-content: space-between; background: radial-gradient(70% 50% at 0% 100%, color-mix(in srgb, var(--brand) 12%, transparent), transparent 70%), var(--surface); border-right: 1px solid var(--border); }
.gate-art .logo-wrap { align-self: flex-start; }
.gate-art .logo-wrap .lg { height: 84px; }
.gate-art h2 { font-size: clamp(26px, 3vw, 38px); line-height: 1.12; letter-spacing: -.02em; max-width: 14ch; }
.gate-art ul { list-style: none; margin: var(--s5) 0 0; padding: 0; display: flex; flex-direction: column; gap: 12px; color: var(--on-hero-muted); }
.gate-art li { display: flex; gap: 10px; align-items: center; } .gate-art li .i { color: var(--accent); }
.gate-form { display: grid; place-items: center; padding: var(--s5); position: relative; }
.gate-form .theme-slot { position: absolute; top: 16px; right: 16px; }
.gate-card { width: min(100%, 420px); display: flex; flex-direction: column; gap: var(--s4); }
.gate-card h1 { font-size: 26px; letter-spacing: -.02em; }
.gate-logo-m { display: none; }

/* ---------- tema, toasts, modal ---------- */
.theme-btn { position: relative; }
.pop { position: absolute; right: 0; top: calc(100% + 8px); min-width: 190px; padding: 6px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); box-shadow: var(--shadow-pop); z-index: 50; animation: rise .15s var(--ease); }
.pop button { display: flex; align-items: center; gap: var(--s3); width: 100%; min-height: 42px; padding: 0 12px; border: 0; border-radius: 10px; background: transparent; cursor: pointer; text-align: left; }
.pop button:hover { background: var(--surface-2); } .pop button[aria-checked="true"] { color: var(--primary); font-weight: 650; background: var(--primary-soft); }
.rel { position: relative; }
.toasts { position: fixed; z-index: 100; right: var(--s4); bottom: var(--s4); display: flex; flex-direction: column; gap: 8px; max-width: min(92vw, 380px); }
.toast { display: flex; gap: 10px; align-items: flex-start; padding: 12px 16px; border-radius: var(--r-md); background: var(--text); color: var(--bg); box-shadow: var(--shadow-pop); animation: rise .25s var(--ease); font-weight: 550; }
.toast.ok .i { color: #4ade80; } .toast.err .i { color: #fb7185; }
:root[data-theme="dark"] .toast.ok .i { color: #15803d; } :root[data-theme="dark"] .toast.err .i { color: #be123c; }
.modal { border: 0; padding: 0; border-radius: var(--r-xl); background: var(--surface); color: var(--text); width: min(92vw, 460px); box-shadow: var(--shadow-pop); }
.modal::backdrop { background: rgba(3, 12, 8, .6); backdrop-filter: blur(3px); }
.modal .in { padding: var(--s5); display: flex; flex-direction: column; gap: var(--s4); }
.modal h3 { font-size: 20px; letter-spacing: -.01em; }
.modal .actions { display: flex; gap: var(--s3); justify-content: flex-end; flex-wrap: wrap; }
.check { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; }
.check input { width: 22px; height: 22px; accent-color: var(--primary); flex: none; margin-top: 1px; }

/* ---------- responsivo ---------- */
@media (max-width: 960px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .side { display: none; }
  .bottom { display: grid; }
  .main { padding-bottom: calc(var(--bottom-h) + env(safe-area-inset-bottom) + 12px); }
  .top { padding: 12px var(--s4); } .top .mobile-logo { display: block; } .top h1 { font-size: 18px; }
  .page { padding: var(--s4); gap: var(--s4); }
  .span-8, .span-6, .span-4 { grid-column: span 12; }
  .card { padding: var(--s4); border-radius: 18px; }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .toasts { bottom: calc(var(--bottom-h) + 12px + env(safe-area-inset-bottom)); left: var(--s4); right: var(--s4); max-width: none; }
  .gate { grid-template-columns: minmax(0, 1fr); } .gate-art { display: none; }
  .gate-logo-m { display: inline-flex; height: 56px; margin-bottom: var(--s2); align-self: flex-start; }
  .top .mobile-logo { display: inline-flex; }
}
@media (max-width: 420px) { .hero .row .btn { width: 100%; } .hide-sm { display: none; } #connPill { padding: 8px; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; } }

/* ---- painel de licencas ---- */
.bottom.n3 { grid-template-columns: repeat(3, 1fr); }
.lic { display: flex; flex-direction: column; gap: var(--s4); }
.lic .key { font-weight: 700; letter-spacing: .04em; font-size: 15px; overflow-wrap: anywhere; }
.keyrow { padding: 10px 12px; border-radius: var(--r-md); background: var(--surface-2); border: 1px solid var(--border); gap: var(--s3); flex-wrap: wrap; }
.lic-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--s4); }
@media (max-width: 700px) { .lic-grid { grid-template-columns: minmax(0, 1fr); gap: var(--s3); } }
.chip { min-height: 38px; padding: 0 14px; border-radius: 99px; border: 1px solid var(--border-strong); background: var(--surface); cursor: pointer; font-weight: 600; color: var(--muted); }
.chip[aria-pressed="true"] { background: var(--primary-soft); color: var(--primary); border-color: transparent; }

.bottom.n4 { grid-template-columns: repeat(4, 1fr); }
.qr-wrap { display: grid; place-items: center; }
.qr-wrap svg { width: min(250px, 72vw); height: auto; background: #fff; border-radius: 18px; border: 1px solid var(--border); box-shadow: var(--shadow); }

.bottom.n5 { grid-template-columns: repeat(5, 1fr); }
.bottom.n5 a { font-size: 10.5px; }
.offer { padding: var(--s3) var(--s4); border-radius: var(--r-md); border: 1px solid var(--border); background: var(--surface-2); display: flex; flex-direction: column; gap: var(--s3); }
.offer-top { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); }
.sales-tot { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--s4); }
@media (max-width: 700px) { .sales-tot { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
