:root {
  font-family: "Segoe UI", system-ui, sans-serif;
  color: #152f33;
  background: #f3f8f7;
  --teal: #006b63;
  --mint: #e1f5ee;
  --line: #d9e8e5;
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; }
.topbar { background: white; border-bottom: 1px solid var(--line); }
.topbar-row, #menu, .breadcrumb { max-width: 1440px; margin: auto; padding-inline: 34px; }
.topbar-row { min-height: 65px; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding-block: 8px; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 4px; font-size: 21px; letter-spacing: -.055em; font-weight: 700; white-space: nowrap; }
.brand strong { color: var(--teal); }
.brand img { object-fit: contain; display: block; }
small { display: block; font-size: 12px; letter-spacing: 0; color: #4d6768; font-weight: 550; }
#menu { display: flex; overflow-x: auto; gap: 6px; padding-block: 3px 0; }
nav button, #switch { background: transparent; color: #36585b; text-align: left; padding: 11px 10px; border-radius: 8px; text-decoration: none; font-size: 14px; }
nav button { flex: none; white-space: nowrap; border-radius: 8px 8px 0 0; }
nav button:focus-visible { outline-offset: -3px; }
nav button:hover, #switch:hover, nav .active { background: var(--mint); color: #005a53; }
nav .active { box-shadow: inset 0 -3px var(--teal); }
nav i { display: inline-block; width: 27px; font-style: normal; color: var(--teal); }
#switch { display: block; background: var(--mint); }
main { min-width: 0; }
.breadcrumb { padding-top: 17px; color: #476366; font-size: 14px; }
#content { max-width: 1440px; margin: auto; padding: 26px 34px 40px; }
.dashboard-title { margin-bottom: 21px; }
.dashboard-title time { font-size: 14px; color: #49696a; }
.dashboard-lead { display: grid; grid-template-columns: minmax(0, 2fr) minmax(230px, 1fr); gap: 16px; }
.hero { position: relative; isolation: isolate; overflow: hidden; display: flex; align-items: center; min-height: 216px; background: linear-gradient(116deg,#e8faf2,#c8efe5); border: 1px solid #bde5d8; padding: 30px; border-radius: 20px; }
.hero > div { flex: 1; }
.hero h1, .hero h2 { font-size: clamp(26px, 4vw, 43px); letter-spacing: -.055em; line-height: 1.04; margin-bottom: 11px; }
.hero p { color: #345b5c; max-width: 39ch; line-height: 1.45; margin-bottom: 19px; }
.hero-mark { display: block; width: clamp(92px, 16vw, 220px); max-height: 190px; object-fit: contain; transform: rotate(-8deg); }
.owner .hero { background: linear-gradient(116deg,#e6f6f4,#cfe7ed); border-color: #bfdee4; }
h1, h2, h3, p { margin-top: 0; }
h1 { font-size: clamp(25px, 4vw, 35px); letter-spacing: -.055em; }
h2 { font-size: 19px; letter-spacing: -.026em; }
.cards { display: grid; grid-template-columns: repeat(auto-fit,minmax(135px,1fr)); gap: 12px; margin: 18px 0; }
.card, .panel { background: #fff; border: 1px solid var(--line); border-radius: 15px; padding: 17px; }
.card { border-top: 3px solid #8fd9c8; }
.card span { font-size: 13px; color: #4a6466; }
.card strong { display: block; font-size: clamp(21px, 2.5vw, 28px); margin-top: 4px; letter-spacing: -.05em; }
.card button { margin-top: 10px; }
.panel { margin-top: 16px; }
.quick { margin-top: 0; display: flex; flex-direction: column; align-items: stretch; gap: 7px; }
.quick h2 { margin-bottom: 3px; }
.quick button, .card button, .ghost { background: #e9f5f1; color: #005a53; }
.quick button { text-align: left; }
.bar { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; margin-bottom: 13px; }
.bar h1, .bar h2 { margin: 0; }
.scroll { overflow: auto; }
table { width: 100%; border-collapse: collapse; text-align: left; white-space: nowrap; }
td, th { padding: 11px; border-bottom: 1px solid var(--line); font-size: 14px; }
th { background: #f0f7f5; color: #405e60; font-size: 12px; }
button { font: inherit; font-size: 14px; font-weight: 650; border: 0; border-radius: 8px; background: var(--teal); color: white; padding: 10px 13px; cursor: pointer; }
button:hover { filter: brightness(.95); }
:focus-visible { outline: 3px solid #118a84; outline-offset: 3px; }
.pill { display: inline-block; border-radius: 30px; padding: 4px 9px; background: #fff1d2; color: #67470d; font-size: 12px; }
.alert { background: #fce5e4; color: #7e2826; }
.muted, .empty { color: #4b686a; }
.empty { padding: 14px; background: #f4f8f7; border-radius: 8px; }
label { display: grid; gap: 5px; margin: 9px 0; font-size: 14px; font-weight: 600; }
input, select { width: 100%; padding: 10px; border: 1px solid #aecbc5; border-radius: 8px; background: #fff; color: inherit; font: inherit; }
dialog { border: 1px solid var(--line); border-radius: 18px; width: min(94vw, 510px); max-height: 88vh; padding: 23px; color: inherit; }
dialog::backdrop { background: #12343699; }
footer { display: flex; justify-content: flex-end; gap: 8px; margin-top: 17px; }
#error { color: #9b3230; }
#toast { position: fixed; right: 18px; bottom: 20px; padding: 14px; background: #054c46; color: white; border-radius: 12px; z-index: 2; }
@media(max-width: 950px) { #content, #menu, .topbar-row, .breadcrumb { padding-inline: 20px; } .dashboard-lead { grid-template-columns: 1fr; } }
@media(max-width: 690px) { #content, #menu, .topbar-row, .breadcrumb { padding-inline: 12px; } .topbar-row { flex-wrap: wrap; } .local { display: none; } .hero { padding: 20px; } .hero-mark { width: 75px; } }

/* Navigation, dashboard and shared surfaces */
:root {
  background: #eef5f4;
  --surface-shadow: 0 7px 24px #103b3d0b;
}
.topbar { box-shadow: 0 4px 18px #163a3a0b; }
.topbar-row { min-height: 72px; }
#menu { gap: 7px; }
nav button { padding: 13px 13px 14px; }
nav i { width: auto; margin-right: 7px; }
.breadcrumb { padding-top: 20px; }
.dashboard-title { margin-bottom: 20px; }
.dashboard-title time { padding: 7px 11px; border: 1px solid var(--line); border-radius: 8px; background: white; }
.dashboard-lead { grid-template-columns: minmax(0, 2fr) minmax(230px, 1fr); gap: 18px; }
.hero {
  min-height: 238px;
  background: radial-gradient(ellipse at 93% 80%, #067a70, transparent 65%), #083c3d;
  color: white;
  box-shadow: var(--surface-shadow);
}
.hero p { color: #d3efea; }
.hero button { background: #aaf3da; color: #063e38; padding: 12px 17px; }
.hero-mark {
  padding: 14px;
  border-radius: 30%;
  background: #edfdfa;
  border: 1px solid #ccefe5;
  box-shadow: 0 12px 32px #002b2a45;
}
.owner .hero { background: radial-gradient(ellipse at 94% 80%, #236674, transparent 63%), #163948; border-color: #275363; }
.card, .panel { box-shadow: var(--surface-shadow); }
.cards { gap: 14px; }
.card { border-top: 1px solid var(--line); border-left: 4px solid #57b8a5; min-width: 0; }
.stats .card:nth-child(3) { border-left-color: #508fb2; }
.stats .card:nth-child(4) { border-left-color: #df9c53; }
.card strong { overflow-wrap: anywhere; }
.quick { justify-content: center; gap: 9px; }
.quick button { background: #f4faf8; border: 1px solid #dcece7; padding: 11px; }
.expiry-summary { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 13px; }
tbody tr:hover { background: #f6fbfa; }
.empty { margin-bottom: 0; }
@media (max-width: 760px) {
  .dashboard-lead { grid-template-columns: 1fr; }
  .hero { min-height: 190px; }
  .hero-mark { padding: 7px; }
}

/* Pharmacy workspace */
:root {
  background: #ebf2f2;
  --line: #d6e4e4;
  --surface-shadow: 0 12px 28px #123b4510;
}
.topbar { background: #0c333a; border-bottom: 0; color: white; }
.topbar-row { min-height: 78px; }
.brand strong { color: #9af0d7; }
.brand small, .topbar-actions small { color: #bedbdc; }
.brand img { background: #eefefa; border-radius: 12px; padding: 4px; }
#switch { background: #174950; color: #e5fff7; border: 1px solid #417277; }
#switch:hover { background: #236069; color: white; }
#menu { gap: 4px; }
#menu button, #menu .ribbon-link { color: #d2e9e9; border-radius: 10px 10px 0 0; }
#menu button i { color: #91e7d1; }
#menu button:hover, #menu .ribbon-link:hover { background: #194b53; }
#menu button.active { color: #0c3b42; background: #ebf2f2; box-shadow: none; }
#menu button.active i { color: #007969; }
#menu button:focus-visible { outline-color: #9af0d7; }
.breadcrumb { font-size: 12px; }
#content { padding-top: 18px; }
.dashboard-title h1 { font-size: clamp(29px, 4vw, 42px); }
.dashboard-lead { grid-template-columns: minmax(0, 2.25fr) minmax(235px, 1fr); }
.hero, .owner .hero {
  min-height: 306px;
  padding: clamp(22px, 4vw, 48px);
  border-radius: 24px;
  border: 0;
  background:
    linear-gradient(90deg, #092e36 4%, #092e36f2 31%, #092e3688 64%, #092e362b),
    url("farmacia-painel.jpg") center 48% / cover no-repeat,
    #092e36;
}
.hero > div { max-width: 430px; }
.hero h1, .hero h2 { font-size: clamp(36px, 5vw, 58px); }
.hero p { color: #e1f4f3; }
.hero button { border-radius: 10px; padding: 13px 20px; box-shadow: 0 5px 18px #062a3366; }
.hero-mark { display: none; }
.quick {
  padding: 22px;
  border-radius: 24px;
  background: linear-gradient(160deg, #fff, #eef8f5);
}
.quick h2 { font-size: 23px; margin-bottom: 7px; }
.quick button {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 54px;
  border-radius: 11px;
  background: white;
  box-shadow: 0 3px 9px #0d514b08;
}
.quick button::after { content: "→"; margin-left: auto; color: #107f71; font-size: 17px; }
.cards { margin: 20px 0; gap: 14px; }
.card { position: relative; border: 1px solid var(--line); padding: 17px; border-radius: 17px; }
.stats { grid-template-columns: repeat(4, minmax(0,1fr)); }
.stats .card { display: grid; align-content: center; min-height: 110px; }
.stats .card:nth-child(1) { background: linear-gradient(135deg,#fff,#def5ef); }
.stats .card:nth-child(2) { background: linear-gradient(135deg,#fff,#e3f3f9); }
.stats .card:nth-child(3) { background: linear-gradient(135deg,#fff,#e9edf9); }
.stats .card:nth-child(4) { background: linear-gradient(135deg,#fff,#fcf0df); }
.card strong { font-size: clamp(20px,3vw,34px); }
.panel:not(.quick) { padding: 20px; border-radius: 18px; }
.panel .bar { margin-bottom: 15px; }
.scroll { border: 1px solid var(--line); border-radius: 11px; }
.scroll tbody tr:last-child td { border-bottom: 0; }
@media (max-width: 810px) {
  .dashboard-lead { grid-template-columns: 1fr; }
  .quick { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); }
  .quick h2 { grid-column: 1 / -1; }
}
@media (max-width: 580px) {
  .hero, .owner .hero { min-height: 246px; background-position: center, 62% center; }
  .hero h1, .hero h2 { font-size: 37px; }
  .stats { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .stats .card { min-height: 90px; }
  .quick { grid-template-columns: 1fr; }
}
.topbar { background: #102c37; }
.topbar-row { min-height: 65px; }
#menu { padding-block: 10px 14px; gap: 9px; scrollbar-color: #74949b #102c37; }
#menu button, #menu .ribbon-link {
  flex: 1 0 126px;
  max-width: 175px;
  min-height: 90px;
  padding: 8px 10px 10px;
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 6px;
  font-size: 13px;
  border: 1px solid #35545d;
  border-radius: 13px;
  background: #183944;
  color: #f5fbfd;
}
#menu button:hover, #menu .ribbon-link:hover { background: #28505c; }
#menu button.active { background: #f4fffc; color: #133c41; border-color: #98e8d6; box-shadow: inset 0 -3px #47b6a0; }
.ribbon-icon {
  display: grid;
  place-items: center;
  width: 43px;
  height: 43px;
  flex: none;
  border-radius: 12px;
  color: var(--icon-ink, #08796c);
  background: linear-gradient(145deg, white, var(--icon-bg, #bceee2) 83%);
  box-shadow: 0 3px 8px #0b252825;
}
.ribbon-icon svg { width: 26px; height: 26px; }
.ribbon-icon[data-icon="cart"] { --icon-ink: #197453; --icon-bg: #b6f0cd; }
.ribbon-icon[data-icon="box"] { --icon-ink: #945200; --icon-bg: #ffdb9d; }
.ribbon-icon[data-icon="people"] { --icon-ink: #2856a2; --icon-bg: #c5dcff; }
.ribbon-icon[data-icon="wallet"] { --icon-ink: #67429d; --icon-bg: #e5d5ff; }
.ribbon-icon[data-icon="reports"] { --icon-ink: #1e647e; --icon-bg: #b9e8f6; }
.ribbon-icon[data-icon="fiscal"] { --icon-ink: #994072; --icon-bg: #f8cde6; }
.dashboard-title { margin-bottom: 8px; }
.dashboard-title time { display: inline-block; margin-top: 4px; padding: 0; border: 0; background: none; }
.stats .card { display: flex; gap: 10px; align-items: flex-start; justify-content: space-between; }
.dashboard-reports { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 14px; }
.dashboard-reports .panel { margin-top: 0; min-width: 0; }
.method { display: grid; grid-template-columns: 1fr auto; gap: 5px; margin-bottom: 14px; font-size: 14px; }
.method progress { grid-column: 1 / -1; width: 100%; height: 8px; accent-color: var(--method); }
@media (max-width: 940px) { .stats { grid-template-columns: repeat(2, minmax(0,1fr)); } }
@media (max-width: 720px) { .dashboard-reports { grid-template-columns: 1fr; } }
@media (max-width: 450px) { .stats .card .ribbon-icon { display: none; } }

.owner-login { width: min(100% - 32px, 435px); margin: clamp(28px, 10vh, 100px) auto; }
.owner-login .panel { padding: 28px; margin: 0; }
.owner-login .brand { margin-bottom: 18px; padding: 0; }
.owner-login .brand strong { color: var(--teal); }
.owner-login h1 { font-size: 30px; }
.owner-login form, .profile-form { display: grid; gap: 12px; max-width: 440px; }
.owner-login form { margin-bottom: 18px; }
.owner-login a { color: var(--teal); }
.profile-form button { justify-self: start; }
.profile-logout { margin-top: 20px; }
.profile-feedback { padding: 10px 12px; border-radius: 8px; background: #e4f3ef; color: #174841; }

#menu .ribbon-link { text-decoration: none; text-align: center; font-weight: 600; }
#menu .ribbon-link:focus-visible { outline: 2px solid #9af0d7; outline-offset: -3px; }
.farmacia-layout { display: flex; flex-direction: column; }
.farmacia-layout > main { flex: 1 0 auto; }
.farmacia-marcas { display: flex; align-items: center; gap: 12px; min-width: 0; }
.farmacia-logo {
  display: block; width: auto; height: 48px; max-width: 94px; object-fit: contain;
  padding: 4px; background: #fff; border-radius: 8px;
}
.farmacia-cabecalho { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1.45fr) minmax(0,1fr); }
.farmacia-cabecalho .topbar-actions { grid-column: 3; grid-row: 1; justify-self: end; }
.farmacia-nome {
  grid-column: 2; grid-row: 1; margin: 0; text-align: center; overflow-wrap: anywhere;
  font-weight: 750; font-size: clamp(24px, 3.2vw, 44px); line-height: 1.12; color: #f4fffb;
}
.suporte-rodape {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 16px; border-top: 1px solid var(--line); background: #fff;
}
.suporte-rodape img { max-width: 100%; height: auto; max-height: 60px; object-fit: contain; }
.suporte-rodape a {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 5px 8px;
  color: #126245; font-weight: 650; text-decoration: none;
}
.suporte-rodape a:hover { text-decoration: underline; }
.profile-form .remover-logo { display: flex; gap: 7px; align-items: center; }
.remover-logo input { width: auto; margin: 0; }
#identidade-erro { color: #982c29; }
#identidade-erro:empty { display: none; }
@media (max-width: 900px) {
  .farmacia-cabecalho { grid-template-columns: minmax(0,1fr) auto; }
  .farmacia-cabecalho .topbar-actions { grid-column: 2; }
  .farmacia-nome { grid-column: 1 / -1; grid-row: 2; padding: 5px 0; }
}
@media (max-width: 460px) {
  .farmacia-marcas { gap: 5px; }
  .farmacia-logo { max-width: 54px; height: 36px; }
}
.tema-form { gap: 10px; }
.tema-form input[type="color"] { width: 80px; height: 42px; padding: 4px; cursor: pointer; }
.tema-acoes { display: flex; flex-wrap: wrap; gap: 8px; }
.farmacia-layout[data-tema="personalizado"] {
  --teal: color-mix(in srgb, var(--cor-farmacia) 46%, #15232c);
  --mint: color-mix(in srgb, var(--cor-farmacia) 12%, white);
  --line: color-mix(in srgb, var(--cor-farmacia) 18%, #e4e9ed);
  background: color-mix(in srgb, var(--cor-farmacia) 7%, #f5f7fa);
}
[data-tema="personalizado"] .topbar { background: color-mix(in srgb, var(--cor-farmacia) 38%, #10202e); }
[data-tema="personalizado"] .topbar .brand strong,
[data-tema="personalizado"] #menu button,
[data-tema="personalizado"] #menu .ribbon-link { color: #fff; }
[data-tema="personalizado"] #menu button,
[data-tema="personalizado"] #menu .ribbon-link,
[data-tema="personalizado"] .topbar #switch {
  background: color-mix(in srgb, var(--teal) 90%, white);
  border-color: color-mix(in srgb, var(--teal) 65%, white);
}
[data-tema="personalizado"] #menu button:hover,
[data-tema="personalizado"] #menu .ribbon-link:hover,
[data-tema="personalizado"] #menu button.active {
  background: var(--mint); color: var(--teal); box-shadow: inset 0 -3px var(--cor-farmacia);
}
[data-tema="personalizado"] button:not(.ghost):not(#menu button) { background: var(--teal); color: white; }
[data-tema="personalizado"] .ghost,
[data-tema="personalizado"] .profile-feedback { background: var(--mint); color: var(--teal); }
[data-tema="personalizado"] .brand img { background: var(--mint); }
[data-tema="personalizado"] .stats .card { border-color: var(--line); }
[data-tema="personalizado"] a:not(.suporte-rodape a):not(#menu a):not(#switch) { color: var(--teal); }
