:root {
  --teal: #009640;
  --teal-dark: #007533;
  --teal-deep: #005c27;
  --gold: #e30613;
  --gold-soft: #fde8ea;
  --ink: #111111;
  --muted: #5a635e;
  --bg: #f3f6f4;
  --card: #ffffff;
  --danger: #e30613;
  --ok: #009640;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body.app-body {
  margin: 0;
  font-family: "Plus Jakarta Sans", system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
}
.brand-serif { font-family: "Playfair Display", Georgia, serif; }
.app-header {
  position: sticky; top: 0; z-index: 1040;
  background: linear-gradient(180deg, #007533 0%, #005c27 100%);
  color: #e8f6ee;
  box-shadow: 0 8px 24px rgba(0, 92, 39, .22);
}
.app-header-bar {
  display: flex; align-items: center; gap: .75rem;
  padding: .55rem 1.15rem .45rem;
}
.app-brand {
  display: flex; align-items: center; gap: .65rem;
  color: #fff; text-decoration: none; flex-shrink: 0;
}
.app-brand:hover { color: #fff; }
.app-logo {
  height: 48px; width: auto; max-width: min(280px, 58vw);
  object-fit: contain; display: block;
  background: #fff; border-radius: 10px; padding: 4px 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,.12);
}
.app-header-tools {
  margin-left: auto; display: flex; align-items: center; gap: .75rem;
}
.app-header-tools .search-pill { width: 220px; background: #fff; color: var(--ink); }
.app-tool {
  color: #e8f6ee; font-size: 1.2rem; line-height: 1; position: relative;
  padding: .25rem;
}
.app-tool:hover { color: #fff; }
.app-user {
  background: rgba(255,255,255,.1); color: #fff; border: 1px solid rgba(255,255,255,.14);
}
.app-user:hover, .app-user:focus { background: rgba(255,255,255,.16); color: #fff; }
.app-nav-toggle {
  background: transparent; border: 1px solid rgba(255,255,255,.2);
  color: #fff; border-radius: 10px; width: 38px; height: 38px;
}
.app-nav {
  display: flex; align-items: stretch; flex-wrap: wrap; gap: .15rem;
  padding: 0 .7rem .5rem;
  border-top: 1px solid rgba(255,255,255,.07);
}
.app-nav-link {
  display: inline-flex; align-items: center; gap: .4rem;
  color: #d7efe0; text-decoration: none;
  padding: .45rem .7rem; border-radius: 9px;
  font-size: .86rem; font-weight: 600; white-space: nowrap;
}
.app-nav-link:hover { background: rgba(255,255,255,.08); color: #fff; }
.app-nav .dropdown-toggle { cursor: pointer; }
.app-nav .dropdown-toggle.show { background: rgba(255,255,255,.08); color: #fff; }
.app-nav-link.active {
  background: linear-gradient(180deg, rgba(227,6,19,.28), rgba(255,255,255,.04));
  color: #fff; box-shadow: inset 0 -2px 0 var(--gold);
}
.app-nav .dropdown-menu {
  border: 1px solid #dce8e4; border-radius: 12px;
  box-shadow: 0 12px 32px rgba(0,92,39,.14);
  padding: .4rem;
}
.app-nav .dropdown-item {
  border-radius: 8px; font-size: .88rem; display: flex; align-items: center; gap: .5rem;
  padding: .45rem .7rem;
}
.app-nav .dropdown-item.active,
.app-nav .dropdown-item:active {
  background: #e6f6ec; color: var(--teal-dark);
}
.app-main { min-height: 100vh; }
.app-top {
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid #dce8e4;
  padding: .7rem 1.25rem;
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 1020;
}
.page-wrap { padding: 1.25rem 1.35rem 2.5rem; }
.stat-card {
  background: var(--card);
  border: 0;
  border-radius: 16px;
  box-shadow: 0 8px 24px rgba(0, 92, 39, .06);
  padding: 1.05rem 1.1rem;
  height: 100%;
  position: relative; overflow: hidden;
}
.stat-card::after {
  content: ""; position: absolute; right: -18px; top: -18px;
  width: 86px; height: 86px; border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, rgba(0,150,64,.14), transparent 70%);
}
.stat-card .label { color: var(--muted); font-size: .78rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.stat-card .value { font-size: 1.7rem; font-weight: 700; color: var(--teal-dark); line-height: 1.15; }
.panel {
  background: #fff; border-radius: 16px;
  box-shadow: 0 8px 24px rgba(0, 92, 39, .06);
  border: 1px solid #e6efec;
}
.panel .panel-h {
  padding: .9rem 1.15rem; border-bottom: 1px solid #edf3f1;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
}
.panel .panel-b { padding: 1.15rem; }
.btn-teal { background: var(--teal); color: #fff; border: 0; }
.btn-teal:hover { background: var(--teal-dark); color: #fff; }
.btn-gold { background: var(--gold); color: #fff; border: 0; font-weight: 600; }
.btn-gold:hover { background: #c10510; color: #fff; }
.table thead th {
  font-size: .75rem; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted); font-weight: 700; background: #f6faf8;
}
.table td, .table th { vertical-align: middle; }
.search-pill { background: #f3f8f6; border: 1px solid #d7e6e1; border-radius: 999px; padding: .35rem .8rem; }
.avatar-sm { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; background: #dceae6; }
.login-page { margin: 0; }
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background:
    radial-gradient(900px 500px at 10% -10%, rgba(0,179,77,.45), transparent 50%),
    radial-gradient(700px 420px at 100% 110%, rgba(227,6,19,.28), transparent 46%),
    linear-gradient(160deg, #005c27, #009640 55%, #007533);
}
.login-card {
  width: min(440px, 100%);
  background: #fff;
  border-radius: 22px;
  padding: 2rem 1.85rem 1.6rem;
  box-shadow: 0 24px 60px rgba(0, 40, 20, .28);
  text-align: center;
}
.login-title {
  color: var(--teal);
  font-size: 1.55rem;
  margin: .85rem 0 .25rem;
}
.login-logo {
  height: 64px; width: auto; max-width: 280px; object-fit: contain;
  background: #fff; border-radius: 12px; padding: 6px 10px;
  margin: 0 auto;
  display: block;
}
.login-meta {
  margin-top: 1.35rem; padding-top: 1rem;
  border-top: 1px solid #e6efec;
  font-size: .78rem; color: var(--muted); line-height: 1.45;
}
.login-form {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  background:
    radial-gradient(900px 500px at 10% -10%, rgba(0,179,77,.45), transparent 50%),
    linear-gradient(160deg, #005c27, #009640 55%, #007533);
}
.form-control, .form-select { border-radius: 10px; border-color: #cddfd9; }
.form-control:focus, .form-select:focus { border-color: var(--teal); box-shadow: 0 0 0 .2rem rgba(0,150,64,.18); }
.alert-gold { background: #fde8ea; color: #8a0610; border: 1px solid #f5b4b8; }
.print-only { display: none; }
@media print {
  .app-header, .app-sidebar, .app-top, .no-print { display: none !important; }
  .app-main { margin: 0 !important; }
  .print-only { display: block; }
  .panel { box-shadow: none; border: 0; }
}
@media (max-width: 992px) {
  .login-wrap { padding: 1.1rem; }
  .login-card { padding: 1.5rem 1.2rem 1.3rem; }
}
.notif-count {
  position: absolute; top: -5px; right: -8px;
  min-width: 18px; height: 18px; padding: 0 5px;
  background: #e30613; color: #fff;
  font-size: .68rem; font-weight: 800;
  border-radius: 999px; display: inline-flex; align-items: center; justify-content: center;
  line-height: 1; border: 2px solid #007533;
}
.badge-soft { background: #e6f6ec; color: var(--teal-dark); }
.hero-mini {
  background: linear-gradient(100deg, #007533, #009640 55%, #e30613);
  color: #fff; border-radius: 18px; padding: 1.4rem 1.5rem;
}
.timeline { border-left: 2px solid #d5e6e1; margin-left: .6rem; }
.timeline .item { position: relative; padding: 0 0 1rem 1.1rem; }
.timeline .item::before {
  content: ""; width: 10px; height: 10px; background: var(--teal);
  border-radius: 50%; position: absolute; left: -6px; top: 4px;
}

/* Dashboard */
.dash-hero {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 1.5rem;
  background:
    radial-gradient(circle at 92% 12%, rgba(227,6,19,.38), transparent 32%),
    linear-gradient(118deg, #005c27 0%, #009640 52%, #00b34d 78%, #c10510 160%);
  color: #fff; border-radius: 22px; padding: 1.55rem 1.65rem 1.5rem;
  box-shadow: 0 16px 40px rgba(0, 92, 39, .18);
  position: relative; overflow: hidden;
}
.dash-hero::after {
  content: ""; position: absolute; inset: auto -40px -50px auto;
  width: 180px; height: 180px; border-radius: 50%;
  border: 18px solid rgba(255,255,255,.06);
}
.dash-hero-copy { position: relative; z-index: 1; max-width: 640px; }
.dash-hero h1 { font-size: clamp(1.45rem, 2.4vw, 2rem); margin: .2rem 0 .45rem; }
.dash-hero-meta { font-size: .82rem; opacity: .82; letter-spacing: .02em; }
.dash-hero-aside {
  position: relative; z-index: 1; min-width: 220px;
  background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.16);
  border-radius: 16px; padding: 1rem 1.15rem; backdrop-filter: blur(8px);
}
.dash-hero-chip {
  font-size: .72rem; text-transform: uppercase; letter-spacing: .08em;
  opacity: .8; font-weight: 700;
}
.dash-hero-money { font-size: 1.65rem; font-weight: 800; line-height: 1.2; }
.dash-hero-sub { font-size: .82rem; opacity: .85; }
.dash-qa { display: flex; flex-wrap: wrap; gap: .5rem; }
.dash-qa-btn {
  display: inline-flex; align-items: center; gap: .4rem;
  background: rgba(255,255,255,.12); color: #fff; text-decoration: none;
  border: 1px solid rgba(255,255,255,.18); border-radius: 999px;
  padding: .42rem .9rem; font-size: .84rem; font-weight: 600;
}
.dash-qa-btn:hover { background: rgba(255,255,255,.2); color: #fff; }
.dash-qa-btn.is-gold { background: var(--gold); color: #fff; border-color: transparent; }
.dash-qa-btn.is-gold:hover { filter: brightness(1.05); color: #fff; }
.dash-live { display: inline-flex; align-items: center; gap: .35rem; font-weight: 600; }
.dash-live span {
  width: 8px; height: 8px; border-radius: 50%; background: #7dffb3;
  box-shadow: 0 0 0 0 rgba(125,255,179,.7); animation: dash-pulse 1.6s infinite;
}
@keyframes dash-pulse {
  70% { box-shadow: 0 0 0 8px rgba(125,255,179,0); }
  100% { box-shadow: 0 0 0 0 rgba(125,255,179,0); }
}
.dash-progress .dash-bar, .dash-bar {
  height: 7px; background: rgba(255,255,255,.22); border-radius: 99px; overflow: hidden;
}
.dash-bar span {
  display: block; height: 100%; border-radius: 99px;
  background: linear-gradient(90deg, #f5b4b8, #e30613);
}
.dash-bar.slim { height: 5px; background: #e6efec; margin-top: .35rem; }
.dash-bar span.is-warn { background: linear-gradient(90deg, #f6c77a, #d97706); }
.dash-bar span.is-danger { background: #b42318; }

.dash-kpi {
  display: flex; align-items: flex-start; gap: .9rem;
  background: #fff; border-radius: 18px; padding: 1.05rem 1.1rem;
  text-decoration: none; color: inherit; height: 100%;
  border: 1px solid #e6efec;
  box-shadow: 0 8px 24px rgba(0, 92, 39, .06);
  transition: transform .18s ease, box-shadow .18s ease;
}
.dash-kpi:hover { transform: translateY(-3px); box-shadow: 0 14px 32px rgba(12, 61, 54, .12); color: inherit; }
.kpi-ico {
  width: 46px; height: 46px; border-radius: 14px; flex-shrink: 0;
  display: grid; place-items: center; font-size: 1.2rem;
}
.dash-kpi.tone-teal .kpi-ico { background: #e6f6ec; color: var(--teal); }
.dash-kpi.tone-gold .kpi-ico { background: #fde8ea; color: var(--gold); }
.dash-kpi.tone-warn .kpi-ico { background: #fff1e6; color: #c05621; }
.kpi-body { display: flex; flex-direction: column; min-width: 0; }
.kpi-label { font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.kpi-value { font-size: 1.45rem; font-weight: 800; color: var(--teal-dark); line-height: 1.2; }
.kpi-hint { font-size: .78rem; color: var(--muted); }

.dash-mini {
  display: flex; align-items: center; gap: .7rem;
  background: #fff; border: 1px solid #e6efec; border-radius: 14px;
  padding: .75rem .9rem; text-decoration: none; color: inherit; height: 100%;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.dash-mini:hover { border-color: #bcd4cd; box-shadow: 0 8px 18px rgba(12,61,54,.07); color: inherit; }
.dash-mini i { font-size: 1.15rem; color: var(--teal); }
.dash-mini strong { display: block; font-size: 1.05rem; color: var(--teal-dark); }
.dash-mini small { color: var(--muted); font-weight: 600; }
.dash-mini.is-warn { background: #fff8f8; border-color: #f5b4b8; }
.dash-mini.is-warn i, .dash-mini.is-warn strong { color: var(--gold); }
.dash-mini.is-danger { background: #fff6f5; border-color: #f0c7c3; }
.dash-mini.is-danger i, .dash-mini.is-danger strong { color: var(--danger); }

.dash-empty {
  text-align: center; color: var(--muted);
}
.dash-empty i { font-size: 1.7rem; color: #9bb8b1; display: block; margin-bottom: .4rem; }
.dash-table tbody tr.dash-row { cursor: pointer; }
.dash-table tbody tr.dash-row:hover { background: #f4faf8; }
.dash-person { display: flex; align-items: center; gap: .55rem; }
.dash-av {
  width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0;
  display: grid; place-items: center; font-size: .68rem; font-weight: 800;
  background: #e6f6ec; color: var(--teal-dark);
}
.dash-legend { list-style: none; padding: 0; display: grid; gap: .35rem; font-size: .82rem; }
.dash-legend li { display: flex; align-items: center; gap: .45rem; color: var(--muted); }
.dash-legend strong { margin-left: auto; color: var(--ink); }
.lg { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.lg-agendada { background: #7ecf9a; }
.lg-confirmada { background: #e30613; }
.lg-em_atendimento { background: #d97706; }
.lg-concluida { background: #009640; }
.lg-cancelada { background: #8a0610; }
.lg-nao_compareceu { background: #4b5563; }

.dash-feed { display: flex; flex-direction: column; }
.dash-feed-item {
  display: flex; gap: .7rem; padding: .7rem 0;
  border-bottom: 1px solid #edf3f1; text-decoration: none; color: inherit;
}
.dash-feed-item:last-child { border-bottom: 0; }
.dash-feed-item:hover { color: inherit; }
.dash-feed-item:hover .fw-semibold { color: var(--teal); }
.feed-ico {
  width: 34px; height: 34px; border-radius: 10px; flex-shrink: 0;
  display: grid; place-items: center;
}
.feed-ico.tone-teal { background: #e6f6ec; color: var(--teal); }
.feed-ico.tone-gold { background: #fde8ea; color: var(--gold); }
.feed-ico.tone-warn { background: #fff1e6; color: #c05621; }
.feed-ico.tone-muted { background: #eef2f1; color: var(--muted); }
.feed-time { font-size: .72rem; color: #8aa09b; }

.dash-stock li { margin-bottom: .85rem; font-size: .88rem; }
.dash-expiry li, .dash-online li { display: flex; gap: .6rem; padding: .45rem 0; border-bottom: 1px solid #edf3f1; }
.dash-expiry li:last-child, .dash-online li:last-child { border-bottom: 0; }
.dash-expiry i { color: var(--gold); margin-top: .15rem; }
.dash-online a {
  display: grid; grid-template-columns: auto 1fr auto; gap: .55rem; align-items: center;
  width: 100%; text-decoration: none; color: inherit; font-size: .88rem;
}
.dash-online a:hover .on-sum { color: var(--teal); }
.on-type {
  font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  background: #e6f6ec; color: var(--teal-dark); border-radius: 999px; padding: .15rem .5rem;
}
.on-time { font-size: .72rem; color: var(--muted); white-space: nowrap; }

@media (max-width: 768px) {
  .dash-hero { padding: 1.2rem; border-radius: 16px; }
  .dash-hero-aside { width: 100%; min-width: 0; }
  .kpi-value { font-size: 1.15rem; }
  .kpi-hint { display: none; }
  .kpi-ico { width: 38px; height: 38px; font-size: 1rem; }
  .dash-kpi { padding: .85rem .75rem; gap: .55rem; }
}
@media (prefers-reduced-motion: reduce) {
  .dash-kpi, .dash-live span { animation: none; transition: none; }
}

/* Responsividade */
html { overflow-x: hidden; }
img, svg, video { max-width: 100%; height: auto; }
canvas { max-width: 100% !important; }
.app-header { padding-top: env(safe-area-inset-top); }
.app-header-tools .search-pill { width: min(220px, 28vw); }
.page-wrap {
  padding: clamp(.8rem, 2.4vw, 1.35rem);
  padding-bottom: 2.5rem;
  max-width: 100%;
}
.panel .panel-h { flex-wrap: wrap; }
.table-responsive { -webkit-overflow-scrolling: touch; max-width: 100%; }
.table { --bs-table-bg: transparent; }
body.nav-open { overflow: hidden; }
.app-nav-search { padding: .15rem .15rem .55rem; }
.app-nav-search .search-pill { width: 100%; background: #fff; color: var(--ink); }

@media (max-width: 1199px) {
  .app-nav-link { font-size: .82rem; padding: .4rem .55rem; }
}
@media (max-width: 991.98px) {
  .app-header-bar { padding: .5rem .75rem; gap: .5rem; }
  .app-logo { height: 40px; max-width: min(200px, 48vw); padding: 3px 6px; }
  .app-nav {
    display: none;
    flex-direction: column;
    align-items: stretch;
    padding: .45rem .75rem calc(.9rem + env(safe-area-inset-bottom));
    max-height: calc(100dvh - 58px);
    overflow-y: auto;
    background: #005c27;
  }
  .app-nav.open { display: flex; }
  .app-nav .dropdown { width: 100%; }
  .app-nav-link { width: 100%; padding: .7rem .8rem; font-size: .95rem; }
  .app-nav .dropdown-menu {
    position: static !important;
    transform: none !important;
    width: 100%;
    box-shadow: none;
    background: rgba(255,255,255,.08);
    border: 0;
    margin: 0 0 .35rem;
  }
  .app-nav .dropdown-item { color: #e8f6ee; }
  .app-nav .dropdown-item.active, .app-nav .dropdown-item:active { background: rgba(227,6,19,.28); color: #fff; }
  .stat-card .value { font-size: 1.35rem; }
  .hero-mini { padding: 1.1rem 1.15rem; border-radius: 14px; }
}
@media (max-width: 575.98px) {
  .page-wrap { padding: .75rem .7rem 5.5rem; }
  .dash-online a { grid-template-columns: 1fr; gap: .2rem; }
  .on-time { white-space: normal; }
  .login-wrap, .login-form { padding: .9rem; padding-bottom: calc(.9rem + env(safe-area-inset-bottom)); }
  .login-card { padding: 1.35rem 1rem 1.15rem; border-radius: 16px; }
  .login-title { font-size: 1.28rem; }
  .login-logo { height: 52px; max-width: 92%; }
  .btn, .btn-teal, .btn-gold { min-height: 42px; }
  .form-control, .form-select { min-height: 42px; font-size: 16px; }
  .panel { border-radius: 12px; }
  .panel .panel-h, .panel .panel-b { padding: .8rem .9rem; }
  .dash-hero h1 { font-size: 1.35rem; }
  .col-6 .dash-mini small { font-size: .68rem; }
}
@media (min-width: 1400px) {
  .page-wrap { max-width: 1320px; margin-left: auto; margin-right: auto; }
}
.portal-nav { background: #007533; }
.portal-nav .navbar-toggler { border-color: rgba(255,255,255,.45); }
.portal-nav .navbar-toggler-icon { filter: invert(1) grayscale(1); }
.portal-nav .nav-link { color: #fff !important; }
.page-wrap form.d-flex, .page-wrap .d-flex.gap-2, .page-wrap .mb-3.d-flex { flex-wrap: wrap; }
