/* Avante Hub – identidade Avante (Montserrat, azuis da marca) com materiais e movimento no estilo Apple */
@font-face { font-family: 'Montserrat'; font-weight: 400; font-display: swap; src: url('../assets/fonts/montserrat-latin-400-normal.woff2') format('woff2'); }
@font-face { font-family: 'Montserrat'; font-weight: 500; font-display: swap; src: url('../assets/fonts/montserrat-latin-500-normal.woff2') format('woff2'); }
@font-face { font-family: 'Montserrat'; font-weight: 600; font-display: swap; src: url('../assets/fonts/montserrat-latin-600-normal.woff2') format('woff2'); }
@font-face { font-family: 'Montserrat'; font-weight: 700; font-display: swap; src: url('../assets/fonts/montserrat-latin-700-normal.woff2') format('woff2'); }

:root {
  --navy: #05326b; --navy-deep: #071d35; --blue: #5299d3; --ice: #baf4ff; --white: #fff;
  --bg: #f2f5f9; --surface: #ffffff; --surface-2: #eef4fa; --line: rgba(7, 29, 53, .09);
  --ink: #0f1d2e; --ink-2: #4a5a6e; --ink-3: #7c8a9c;
  --red: #c93b3b; --red-bg: #fde8e8; --orange: #c2410c; --orange-bg: #fdebdc; --yellow: #8a6200; --yellow-bg: #fdf3cf;
  --green: #217a3c; --green-bg: #dff3e4; --blue-bg: #e1eefa;
  --radius: 16px; --radius-s: 10px;
  --shadow: 0 1px 2px rgba(7, 29, 53, .05), 0 8px 24px rgba(7, 29, 53, .06);
  --shadow-l: 0 2px 6px rgba(7, 29, 53, .08), 0 24px 64px rgba(7, 29, 53, .18);
  --ease-out: cubic-bezier(.22, 1, .36, 1); --ease-in: cubic-bezier(.64, 0, .78, 0);
  --font: 'Montserrat', system-ui, -apple-system, 'Segoe UI', sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 400 0.9375rem/1.5 var(--font); color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; }
h1, h2, h3 { margin: 0; font-weight: 600; color: var(--navy-deep); }
h1 { font-size: 1.75rem; line-height: 1.15; letter-spacing: -0.02em; }
h2 { font-size: 1.125rem; line-height: 1.3; letter-spacing: -0.01em; }
h3 { font-size: 0.9375rem; line-height: 1.35; }
p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
.muted { color: var(--ink-2); }
.small { font-size: 0.8125rem; letter-spacing: 0.005em; }
.num { font-variant-numeric: tabular-nums; }
[hidden] { display: none !important; }

/* ---------- Login */
.login { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.login-art { position: relative; overflow: hidden; background: var(--navy); color: var(--white); padding: 56px; display: flex; flex-direction: column; justify-content: space-between; }
.login-art img.logo { width: 220px; height: auto; }
.login-art h1 { color: var(--white); font-size: clamp(2rem, 3.6vw, 3rem); line-height: 1.05; letter-spacing: -0.025em; max-width: 12ch; position: relative; z-index: 1; }
.login-art p { color: var(--ice); max-width: 38ch; margin-top: 16px; position: relative; z-index: 1; }
.login-art .foot { color: rgba(255,255,255,.7); font-size: .8125rem; position: relative; z-index: 1; }
.tri { position: absolute; width: 0; height: 0; border-style: solid; opacity: .9; }
.tri-a { right: -40px; top: 18%; border-width: 170px 0 170px 290px; border-color: transparent transparent transparent rgba(82,153,211,.55); }
.tri-b { right: 60px; bottom: 6%; border-width: 100px 170px 100px 0; border-color: transparent rgba(186,244,255,.55) transparent transparent; }
.login-form { display: grid; place-items: center; padding: 32px; }
.login-card { width: min(400px, 100%); }
.login-card h2 { font-size: 1.5rem; letter-spacing: -0.02em; }
.login-card .sub { color: var(--ink-2); margin: 6px 0 28px; }
.demo-hint { margin-top: 20px; padding: 12px 14px; border-radius: var(--radius-s); background: var(--surface-2); font-size: .8125rem; color: var(--ink-2); }
.demo-hint b { color: var(--navy); }
@media (max-width: 860px) { .login { grid-template-columns: 1fr; } .login-art { min-height: 300px; padding: 32px; } }

/* ---------- Campos */
.field { display: grid; gap: 6px; margin-bottom: 16px; }
.field label { font-size: .8125rem; font-weight: 600; color: var(--ink-2); letter-spacing: .01em; }
.input, select.input, textarea.input { width: 100%; padding: 11px 14px; border-radius: var(--radius-s); border: 1px solid var(--line); background: var(--surface); outline: none; transition: border-color .15s, box-shadow .15s; }
.input:focus { border-color: var(--blue); box-shadow: 0 0 0 4px rgba(82,153,211,.18); }
.input.invalid { border-color: var(--red); box-shadow: 0 0 0 4px rgba(201,59,59,.12); }
.err { color: var(--red); font-size: .8125rem; min-height: 1.2em; }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 0 16px; }

/* ---------- Botões: resposta no pressionar, não no soltar */
a.btn { text-decoration: none; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 18px; border: 0; border-radius: 999px; font-weight: 600; font-size: .875rem; letter-spacing: .005em; cursor: pointer; background: var(--surface-2); color: var(--navy); transition: transform .1s var(--ease-out), background-color .15s, box-shadow .15s; -webkit-tap-highlight-color: transparent; user-select: none; white-space: nowrap; }
.btn:active { transform: scale(.97); }
.btn:focus-visible, .nav a:focus-visible, .chip:focus-visible { outline: 3px solid rgba(82,153,211,.6); outline-offset: 2px; }
.btn-primary { background: var(--navy); color: var(--white); box-shadow: 0 1px 2px rgba(5,50,107,.25); }
.btn-primary:hover { background: #0a3f82; }
.btn-ghost { background: transparent; }
.btn-ghost:hover, .btn:not(.btn-primary):hover { background: #e2ecf6; }
.btn-danger { background: var(--red-bg); color: var(--red); }
.btn-block { width: 100%; padding: 13px 18px; font-size: .9375rem; }
.btn-s { padding: 7px 12px; font-size: .8125rem; }
.btn svg { width: 18px; height: 18px; }

/* ---------- Estrutura */
.app { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; background: var(--navy-deep); color: #c9d6e6; display: flex; flex-direction: column; padding: 22px 14px; }
.sidebar .brand { display: flex; align-items: center; padding: 4px 10px 22px; }
.sidebar .brand img { width: 150px; height: auto; }
.nav { display: grid; gap: 2px; }
.nav-label { font-size: .6875rem; text-transform: uppercase; letter-spacing: .08em; color: #7f95b1; padding: 16px 12px 6px; font-weight: 600; }
.nav a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; color: #c9d6e6; text-decoration: none; font-weight: 500; font-size: .875rem; transition: background-color .15s, color .15s, transform .1s var(--ease-out); }
.nav a:active { transform: scale(.98); }
.nav a:hover { background: rgba(255,255,255,.06); color: var(--white); }
.nav a.active { background: rgba(82,153,211,.22); color: var(--white); }
.nav a svg { width: 19px; height: 19px; flex: none; opacity: .9; }
.nav .badge { margin-left: auto; background: var(--orange); color: #fff; font-size: .6875rem; font-weight: 700; border-radius: 999px; padding: 1px 7px; }
.sidebar .user { margin-top: auto; padding: 14px 12px 4px; border-top: 1px solid rgba(255,255,255,.08); display: flex; align-items: center; gap: 10px; font-size: .8125rem; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--blue); color: var(--white); display: grid; place-items: center; font-weight: 700; flex: none; }
.sidebar .user .btn { margin-left: auto; background: rgba(255,255,255,.08); color: #c9d6e6; padding: 7px; }

.main { min-width: 0; }
/* barra superior translúcida: o conteúdo rola por baixo */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 16px; padding: 18px 32px; background: rgba(242,245,249,.72); backdrop-filter: blur(20px) saturate(180%); -webkit-backdrop-filter: blur(20px) saturate(180%); }
.topbar::after { content: ''; position: absolute; left: 0; right: 0; bottom: -16px; height: 16px; background: linear-gradient(rgba(242,245,249,.7), rgba(242,245,249,0)); pointer-events: none; }
.topbar .title { min-width: 0; }
.topbar .title p { color: var(--ink-2); font-size: .8125rem; margin-top: 2px; }
.topbar .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.menu-btn { display: none; }
.content { padding: 8px 32px 48px; display: grid; gap: 20px; }
.view-enter { animation: viewIn .32s var(--ease-out) both; }
@keyframes viewIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- Cartões e grades */
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px 22px; min-width: 0; }
.card-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.card-head .right { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.grid { display: grid; gap: 20px; }
.g-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g-21 { grid-template-columns: 2fr 1fr; }
@media (max-width: 1180px) { .g-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g-21, .g-3 { grid-template-columns: 1fr; } }
@media (max-width: 720px) { .g-4, .g-2 { grid-template-columns: 1fr; } }

.kpi { position: relative; }
.kpi .label { font-size: .8125rem; color: var(--ink-2); font-weight: 500; }
.kpi .value { font-size: 2rem; font-weight: 700; letter-spacing: -0.03em; line-height: 1.1; margin-top: 8px; color: var(--navy-deep); font-variant-numeric: tabular-nums; }
.kpi .hint { font-size: .8125rem; color: var(--ink-2); margin-top: 6px; }
.kpi.dark { background: var(--navy); }
.kpi.dark .label, .kpi.dark .hint { color: var(--ice); }
.kpi.dark .value { color: var(--white); }
.bar { height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; margin-top: 12px; }
.bar > i { display: block; height: 100%; border-radius: 99px; background: var(--blue); transform-origin: left; animation: grow .7s var(--ease-out) both; }
.kpi.dark .bar { background: rgba(255,255,255,.14); }
.kpi.dark .bar > i { background: var(--ice); }
@keyframes grow { from { transform: scaleX(0); } }

/* ---------- Etiquetas de validade (as mesmas cores do quadro da despensa) */
.tag { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: .75rem; font-weight: 600; white-space: nowrap; letter-spacing: .005em; }
.tag::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.tag-red { background: var(--red-bg); color: var(--red); }
.tag-orange { background: var(--orange-bg); color: var(--orange); }
.tag-blue { background: var(--blue-bg); color: var(--navy); }
.tag-yellow { background: var(--yellow-bg); color: var(--yellow); }
.tag-green { background: var(--green-bg); color: var(--green); }
.tag-plain { background: var(--surface-2); color: var(--ink-2); }
.tag-plain::before { display: none; }

/* ---------- Tabelas */
.table-wrap { overflow-x: auto; margin: 0 -22px; padding: 0 22px; }
table { width: 100%; border-collapse: collapse; font-size: .875rem; }
th { text-align: left; font-size: .75rem; font-weight: 600; color: var(--ink-2); letter-spacing: .02em; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr { transition: background-color .12s; }
tbody tr:hover { background: #f7fafd; }
td.r, th.r { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ordem { width: 28px; height: 28px; border-radius: 50%; display: inline-grid; place-items: center; background: var(--navy); color: var(--white); font-weight: 700; font-size: .8125rem; }
.ordem.off { background: var(--surface-2); color: var(--ink-3); }

/* ---------- Filtros (chips) */
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { padding: 7px 14px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); font-size: .8125rem; font-weight: 600; color: var(--ink-2); cursor: pointer; transition: transform .1s var(--ease-out), background-color .15s, color .15s; }
.chip:active { transform: scale(.96); }
.chip.on { background: var(--navy); color: var(--white); border-color: var(--navy); }

/* ---------- Listas de alerta */
.list { display: grid; gap: 4px; }
.li { display: flex; align-items: center; gap: 12px; padding: 10px 4px; border-bottom: 1px solid var(--line); }
.li:last-child { border-bottom: 0; }
.li .grow { flex: 1; min-width: 0; }
.li .ico { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; flex: none; }
.li .ico svg { width: 18px; height: 18px; }
.ico.red { background: var(--red-bg); color: var(--red); } .ico.orange { background: var(--orange-bg); color: var(--orange); } .ico.blue { background: var(--blue-bg); color: var(--navy); } .ico.green { background: var(--green-bg); color: var(--green); }
.empty { text-align: center; color: var(--ink-3); padding: 24px 8px; font-size: .875rem; }

/* ---------- Painel lateral (sheet): entra e sai pela direita */
.scrim { position: fixed; inset: 0; background: rgba(7,29,53,.32); z-index: 60; opacity: 0; transition: opacity .28s var(--ease-out); }
.scrim.on { opacity: 1; }
.sheet { position: fixed; top: 12px; right: 12px; bottom: 12px; width: min(480px, calc(100vw - 24px)); background: rgba(255,255,255,.94); backdrop-filter: blur(30px) saturate(180%); -webkit-backdrop-filter: blur(30px) saturate(180%); border-radius: 22px; box-shadow: var(--shadow-l); z-index: 61; display: flex; flex-direction: column; transform: translateX(calc(100% + 24px)); transition: transform .42s var(--ease-out); }
.sheet.on { transform: none; }
.sheet.closing { transition: transform .26s var(--ease-in); }
.sheet-head { display: flex; align-items: center; gap: 12px; padding: 20px 22px 12px; }
.sheet-head .btn { margin-left: auto; padding: 8px; }
.sheet-body { padding: 4px 22px 22px; overflow-y: auto; flex: 1; }
.sheet-foot { padding: 14px 22px 20px; display: flex; gap: 10px; justify-content: flex-end; border-top: 1px solid var(--line); }

.callout { border-radius: var(--radius-s); padding: 12px 14px; font-size: .875rem; background: var(--surface-2); }
.callout.ok { background: var(--green-bg); color: #164f28; }
.callout.warn { background: var(--yellow-bg); color: #5c4100; }
.callout.bad { background: var(--red-bg); color: #7a1f1f; }
.callout b { font-weight: 700; }
.stat-row { display: flex; gap: 22px; flex-wrap: wrap; margin: 12px 0; }
.stat-row div { display: grid; }
.stat-row b { font-size: 1.25rem; letter-spacing: -0.02em; color: var(--navy-deep); font-variant-numeric: tabular-nums; }

/* ---------- Toast */
.toasts { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); display: grid; gap: 8px; z-index: 80; }
.toast { background: rgba(7,29,53,.92); backdrop-filter: blur(20px); color: var(--white); padding: 12px 18px; border-radius: 14px; font-size: .875rem; font-weight: 500; box-shadow: var(--shadow-l); display: flex; gap: 10px; align-items: center; animation: toastIn .36s var(--ease-out) both; }
.toast.out { animation: toastOut .22s var(--ease-in) both; }
.toast svg { width: 18px; height: 18px; color: var(--ice); }
@keyframes toastIn { from { opacity: 0; transform: translateY(14px) scale(.98); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(10px) scale(.98); } }

/* ---------- Gráficos simples */
.chart svg { width: 100%; height: auto; display: block; }
.chart text { font-family: var(--font); fill: var(--ink-2); font-size: 11px; }
.legend { display: flex; gap: 16px; font-size: .8125rem; color: var(--ink-2); margin-top: 8px; flex-wrap: wrap; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }

/* ---------- Responsivo: barra lateral vira gaveta */
@media (max-width: 960px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 70; left: 0; width: 264px; transform: translateX(-100%); transition: transform .38s var(--ease-out); }
  .sidebar.on { transform: none; box-shadow: var(--shadow-l); }
  .menu-btn { display: inline-flex; }
  .topbar, .content { padding-left: 16px; padding-right: 16px; }
}

/* ---------- Acessibilidade */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
  .sheet, .sidebar { transition: opacity .2s ease !important; }
  .sheet { transform: none; opacity: 0; pointer-events: none; }
  .sheet.on { opacity: 1; pointer-events: auto; }
  .btn:active, .chip:active, .nav a:active { transform: none; }
}
@media (prefers-reduced-transparency: reduce) {
  .topbar { background: var(--bg); backdrop-filter: none; }
  .sheet, .toast { background: var(--surface); backdrop-filter: none; }
  .toast { background: var(--navy-deep); }
}
@media (prefers-contrast: more) {
  .card, .input, .chip { border: 1px solid var(--ink-2); }
  .muted, .kpi .label, th { color: var(--ink); }
}
@media print {
  .sidebar, .topbar .actions, .menu-btn { display: none !important; }
  .app { grid-template-columns: 1fr; }
  .card { box-shadow: none; border: 1px solid #ccc; }
}
