/* Design system do Brava Hub: tokens da marca, tema claro e escuro, mobile first (360 px) e ampliado depois. */

@font-face {
  font-family: "Google Sans Flex";
  src: url("fonts/google-sans-flex-latin-400-normal.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}

/* Tokens: brand (azul-marinho), action (azul das ações), accent (laranja da Brava) e cores de estado. */
:root {
  --brand-700: #0a1f40;
  --brand-900: #061328;
  --action: #0137f0;
  --action-hover: #0124c0;
  --accent: #ff6506;
  --accent-hover: #e75b06;
  --accent-tint: rgba(255, 101, 6, 0.1);
  --accent-shadow: 0 8px 20px -10px rgba(255, 101, 6, 0.6);
  /* Texto e detalhes sobre as superfícies azul-marinho (cabeçalho e barra do celular), iguais nos dois temas. */
  --on-dark: #ffffff;
  --on-dark-muted: rgba(255, 255, 255, 0.6);
  --on-dark-soft: #aebbd1;
  --on-dark-line: rgba(255, 255, 255, 0.08);
  --on-dark-fill: rgba(255, 255, 255, 0.1);
  --on-dark-fill-strong: rgba(255, 255, 255, 0.16);
  --qr-bg: #ffffff;
  --mesh:
    radial-gradient(at 0% 0%, hsla(26, 100%, 94%, 1) 0, transparent 50%),
    radial-gradient(at 100% 0%, hsla(218, 63%, 95%, 1) 0, transparent 50%);

  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-2: #f5f7fb;
  --text: #133467;
  --muted: #5a6a86;
  --subtle: #8794ae;
  --border: rgba(203, 213, 230, 0.6);
  --field-border: #cbd5e6;
  --focus: #0137f0;
  --ring: rgba(1, 55, 240, 0.1);
  --strong-bg: #133467;
  --strong-text: #ffffff;
  --strong-hover: #233a66;
  --hover: #f5f7fb;
  --badge-bg: #ebeff6;
  --shadow: 0 1px 2px rgba(10, 31, 64, 0.06);
  --shadow-lg: 0 20px 40px -20px rgba(10, 31, 64, 0.25);

  --success-bg: #ecfdf5; --success-border: #d1fae5; --success-text: #047857;
  --error-bg: #fef2f2; --error-border: #fee2e2; --error-text: #dc2626;
  --info-bg: #eff6ff; --info-border: #dbeafe; --info-text: #2563eb;
  --warning-bg: #fffbeb; --warning-border: #fef3c7; --warning-text: #b45309;

  --radius: 16px;
  --radius-sm: 12px;
  --font-display: "Google Sans Flex", ui-sans-serif, system-ui, sans-serif;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}

/* Tema escuro: ligado pela classe dark no html (botão de tema), com a preferência do sistema como padrão. */
html.dark {
  --bg: #061328;
  --surface: #0a1f40;
  --surface-2: rgba(255, 255, 255, 0.05);
  --text: #ffffff;
  --muted: #aebbd1;
  --subtle: #8794ae;
  --border: rgba(255, 255, 255, 0.1);
  --field-border: rgba(255, 255, 255, 0.1);
  --focus: #5f86c4;
  --ring: rgba(95, 134, 196, 0.2);
  --strong-bg: #ffffff;
  --strong-text: #0a1f40;
  --strong-hover: #ebeff6;
  --hover: rgba(255, 255, 255, 0.05);
  --badge-bg: rgba(255, 255, 255, 0.05);
  --shadow: none;
  --shadow-lg: 0 20px 40px -20px rgba(0, 0, 0, 0.6);

  --success-bg: rgba(16, 185, 129, 0.1); --success-border: rgba(16, 185, 129, 0.2); --success-text: #34d399;
  --error-bg: rgba(239, 68, 68, 0.1); --error-border: rgba(239, 68, 68, 0.2); --error-text: #f87171;
  --info-bg: rgba(59, 130, 246, 0.1); --info-border: rgba(59, 130, 246, 0.2); --info-text: #60a5fa;
  --warning-bg: rgba(245, 158, 11, 0.1); --warning-border: rgba(245, 158, 11, 0.2); --warning-text: #fbbf24;
  color-scheme: dark;
}

/* Base */
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font); font-size: 15px; line-height: 1.5; color: var(--text); background-color: var(--bg);
  -webkit-font-smoothing: antialiased;
  padding-bottom: calc(88px + env(safe-area-inset-bottom));
}
/* Fundo em malha do design system, só no tema claro. */
html:not(.dark) body { background-image: var(--mesh); background-attachment: fixed; }
a { color: var(--accent); }
h1 { font-family: var(--font-display); font-weight: 400; font-size: 30px; line-height: 1.15; letter-spacing: -0.02em; margin: 8px 0 16px; }
h2 { font-size: 17px; font-weight: 600; letter-spacing: -0.01em; margin: 24px 0 10px; }
h3 { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.12em; color: var(--subtle); margin: 16px 0 8px; }
.muted { color: var(--muted); }
.icon { width: 18px; height: 18px; flex: 0 0 auto; }
.small { font-size: 13px; }
strong { font-weight: 600; }

/* Cabeçalho: a pílula azul-marinho do design system, com o símbolo branco da Brava. */
.topbar {
  display: flex; align-items: center; gap: 12px; margin: 12px; margin-top: calc(12px + env(safe-area-inset-top));
  padding: 6px 6px 6px 12px; min-height: 52px; background: var(--brand-700); color: var(--on-dark); border-radius: 999px;
  box-shadow: var(--shadow-lg); border: 1px solid var(--on-dark-line);
}
.brand { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; font-size: 16px; letter-spacing: -0.01em; white-space: nowrap; }
.brand img { width: 28px; height: 28px; object-fit: contain; }
.brand strong { font-weight: 700; }
.brand span { color: var(--accent); }
.client { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: flex-end; color: var(--on-dark-muted); font-size: 12px; line-height: 1.3; text-align: right; }
.client > span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.client-user { color: var(--on-dark); font-size: 13px; font-weight: 600; }
.theme-toggle {
  flex: 0 0 auto; width: 40px; height: 40px; display: inline-flex; align-items: center; justify-content: center;
  border: 0; border-radius: 999px; background: var(--on-dark-line); color: var(--on-dark); cursor: pointer;
}
.theme-toggle:hover { background: var(--on-dark-fill-strong); }
.theme-toggle svg { width: 18px; height: 18px; }
.theme-toggle .icon-sun, html.dark .theme-toggle .icon-moon { display: none; }
html.dark .theme-toggle .icon-sun { display: block; }

.content { padding: 8px 16px 16px; max-width: 720px; margin: 0 auto; overflow-wrap: anywhere; }

/* Navegação do celular: pílula escura presa embaixo. */
.bottom-nav {
  position: fixed; left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); z-index: 50;
  display: flex; gap: 2px; padding: 4px; background: var(--brand-700); border: 1px solid var(--on-dark-fill);
  border-radius: 999px; box-shadow: var(--shadow-lg);
}
.bottom-nav a {
  flex: 1; min-width: 0; min-height: 44px; display: flex; align-items: center; justify-content: center; padding: 0 4px;
  border-radius: 999px; color: var(--on-dark-soft); text-decoration: none; font-size: 12px; white-space: nowrap; transition: background-color 0.2s, color 0.2s;
}
.bottom-nav a:hover { color: var(--on-dark); }
.bottom-nav a[aria-current="page"] { background: var(--on-dark-fill); color: var(--on-dark); font-weight: 600; }
.bottom-nav .nav-extra { display: none; }
/* No celular, a pílula mostra só o texto; os ícones aparecem na barra lateral do computador. */
.bottom-nav .icon { display: none; }

/* Superfícies */
.card, form.stack {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; box-shadow: var(--shadow);
}
.card form.stack, details.card form.stack { background: none; border: 0; padding: 0; margin: 12px 0 0; box-shadow: none; }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; flex-wrap: wrap; margin-bottom: 4px; }
.list { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.list li + li { border-top: 1px solid var(--border); }
.list > li.muted { padding: 12px 16px; }
.row {
  display: flex; align-items: center; min-height: 48px; padding: 0 16px; color: var(--text); text-decoration: none;
  width: 100%; background: none; border: 0; font: inherit; text-align: left; cursor: pointer; transition: background-color 0.2s;
}
.row-text { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; min-height: 48px; padding: 8px 16px; color: var(--text); text-decoration: none; }
a.row-text, .row { transition: background-color 0.2s; }
a.row-text:hover, .row:hover { background: var(--hover); }
.row-actions { display: flex; flex-wrap: wrap; }
.row-actions form, .secondary-actions form { display: inline; }
.inactive { opacity: 0.55; }
.list-block { margin-bottom: 16px; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.stack > p { margin: 0; }
.message-text { white-space: pre-wrap; background: var(--surface-2); border-radius: var(--radius-sm); padding: 12px; margin: 8px 0 12px; font-size: 14px; line-height: 1.6; }
.steps { padding-left: 20px; color: var(--muted); }
.steps li { margin-bottom: 6px; }

/* Botões: principal em laranja, escuro para a segunda ação, contorno para a secundária e link. */
button[type="submit"], .button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 18px;
  border-radius: var(--radius-sm); border: 0; background: var(--accent); color: var(--on-dark); font: inherit; font-size: 14px;
  font-weight: 600; text-decoration: none; cursor: pointer; box-shadow: var(--accent-shadow); transition: background-color 0.2s;
}
button[type="submit"]:hover, .button:hover { background: var(--accent-hover); }
.button.dark { background: var(--strong-bg); color: var(--strong-text); box-shadow: none; }
.button.dark:hover { background: var(--strong-hover); }
button.secondary[type="submit"], .button.secondary {
  background: var(--surface); color: var(--text); border: 2px solid var(--field-border); box-shadow: none; width: 100%;
}
button.secondary[type="submit"]:hover { border-color: var(--subtle); background: var(--surface); }
.button svg, button svg { width: 16px; height: 16px; flex: 0 0 auto; }
.link, button.link[type="submit"] {
  display: inline-flex; align-items: center; min-height: 44px; padding: 0 6px; background: none; border: 0; box-shadow: none;
  color: var(--accent); font: inherit; font-size: 13px; font-weight: 700; text-decoration: none; cursor: pointer;
}
.link:hover, button.link[type="submit"]:hover { background: none; text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 4px; }
.link.quiet, button.link.quiet[type="submit"] { color: var(--muted); }
.list button[type="submit"]:not(.link) { background: none; color: var(--text); border: 0; box-shadow: none; border-radius: 0; font-weight: 400; font-size: 15px; justify-content: flex-start; }
.list button[type="submit"]:not(.link):hover { background: var(--hover); }
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.actions .button { padding: 0 10px; font-size: 13px; white-space: nowrap; }
.secondary-actions { display: flex; flex-wrap: wrap; gap: 0 12px; margin-top: 4px; margin-left: -6px; }

/* Campos: borda dupla, foco azul com anel e rótulo flutuante sobre a borda. */
label { display: block; margin-bottom: 6px; font-size: 13px; font-weight: 600; }
input, select, textarea {
  font: inherit; font-size: 14px; font-weight: 600; width: 100%; min-height: 48px; padding: 12px 16px; color: var(--text);
  background: var(--surface); border: 2px solid var(--field-border); border-radius: var(--radius-sm); transition: border-color 0.2s, box-shadow 0.2s;
}
textarea { min-height: 96px; line-height: 1.5; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 4px var(--ring); }
input:disabled, select:disabled, textarea:disabled { color: var(--subtle); background: var(--surface-2); cursor: not-allowed; }
input[type="checkbox"], input[type="radio"] { width: 18px; height: 18px; min-height: 0; padding: 0; accent-color: var(--action); }
input[type="file"] { padding: 10px 12px; font-weight: 400; }
:is(.stack > p, .field):has(> :is(input:not([type="checkbox"]):not([type="radio"]), select, textarea)) { position: relative; }
:is(.stack > p, .field):has(> :is(input:not([type="checkbox"]):not([type="radio"]), select, textarea)) > label {
  position: absolute; top: -8px; left: 12px; z-index: 1; margin: 0; padding: 0 4px; background: var(--surface);
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.12em; color: var(--subtle); transition: color 0.2s;
}
:is(.stack > p, .field):focus-within > label { color: var(--focus); }
.field > label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.12em; color: var(--subtle); }
.field > div label, .field ul label, form label:has(> input[type="checkbox"]) {
  display: flex; align-items: center; gap: 10px; min-height: 44px; margin: 0; font-size: 14px; font-weight: 500; text-transform: none; letter-spacing: 0; color: var(--text);
}
.field ul { list-style: none; padding: 0; margin: 0; }
.error { display: block; margin-top: 4px; font-size: 12px; font-weight: 500; color: var(--error-text); }
:is(.stack > p, .field):has(.error) > :is(input, select, textarea) { border-color: var(--error-text); box-shadow: 0 0 0 4px var(--error-bg); }
:is(.stack > p, .field):has(.error) > label { color: var(--error-text); }
.inline-form { display: flex; gap: 8px; margin-top: 8px; }
.inline-form input, .inline-form select { flex: 1; min-width: 0; }
.inline-form button { white-space: nowrap; }

/* Avisos: informação por padrão, com variações de sucesso, erro e atenção. */
.message {
  display: flex; gap: 10px; align-items: flex-start; margin: 0 0 12px; padding: 12px 16px; font-size: 14px; font-weight: 500;
  border: 1px solid var(--info-border); border-radius: var(--radius-sm); background: var(--info-bg); color: var(--info-text);
}
.message::before { content: ""; flex: 0 0 6px; height: 6px; margin-top: 8px; border-radius: 999px; background: currentColor; }
.message p { margin: 0; }
.message a { color: inherit; font-weight: 700; }
.message.success { background: var(--success-bg); border-color: var(--success-border); color: var(--success-text); }
.message.error { background: var(--error-bg); border-color: var(--error-border); color: var(--error-text); }
.message.warning { background: var(--warning-bg); border-color: var(--warning-border); color: var(--warning-text); }
.form-notice { flex-direction: column; color: var(--text); }
.form-notice::before { display: none; }

/* Etiquetas de status */
.badge {
  display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap;
  background: var(--badge-bg); color: var(--muted);
}
.badge.accent { background: var(--accent-tint); color: var(--accent); }
.badge.success { background: var(--success-bg); color: var(--success-text); }
.badge.error { background: var(--error-bg); color: var(--error-text); }
.badge.warning { background: var(--warning-bg); color: var(--warning-text); }
.badge.info { background: var(--info-bg); color: var(--info-text); }

/* Filtros em pílulas, com o ativo em laranja claro. */
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 12px; scrollbar-width: none; }
.chips a {
  flex: 0 0 auto; min-height: 36px; display: inline-flex; align-items: center; padding: 0 14px; border: 1px solid var(--border);
  border-radius: 999px; background: var(--surface); color: var(--muted); text-decoration: none; font-size: 13px; font-weight: 500; transition: color 0.2s, background-color 0.2s;
}
.chips a:hover { color: var(--text); }
.chips a[aria-current="true"] { background: var(--accent-tint); border-color: transparent; color: var(--accent); font-weight: 700; }

/* Estado vazio */
.empty {
  margin: 0 0 12px; padding: 32px 24px; text-align: center; color: var(--muted); font-size: 14px;
  background: var(--surface-2); border: 1px dashed var(--field-border); border-radius: 24px;
}
.empty strong { display: block; margin-bottom: 4px; font-family: var(--font-display); font-weight: 400; font-size: 22px; letter-spacing: -0.02em; color: var(--text); }

/* Métricas e tabela do resumo */
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 8px; }
.tile { display: flex; flex-direction: column; gap: 2px; padding: 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
a.tile { color: inherit; text-decoration: none; transition: border-color 0.2s; }
a.tile:hover { border-color: var(--accent); }
.tile-value { font-family: var(--font-display); font-weight: 400; font-size: 36px; line-height: 1.1; letter-spacing: -0.02em; }
.tile-label { color: var(--muted); font-size: 13px; }
.bands { margin-top: 8px; box-shadow: none; }
.bands a.row-text { color: var(--accent); }
.trend { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; font-size: 14px; box-shadow: var(--shadow); }
.trend th { padding: 10px 12px; text-align: right; background: var(--surface-2); color: var(--subtle); font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.12em; }
.trend td { padding: 10px 12px; text-align: right; border-top: 1px solid var(--border); }
.trend th:first-child, .trend td:first-child { text-align: left; }
.trend tbody tr:hover { background: var(--hover); }

/* Leitura da planilha e QR */
.sheet-wrap { overflow-x: auto; margin: 12px 0 4px; background: var(--surface); border: 1px solid var(--field-border); border-radius: var(--radius-sm); box-shadow: var(--shadow); }
.sheet { border-collapse: collapse; font-size: 13px; white-space: nowrap; }
.sheet th, .sheet td { padding: 6px 10px; border: 1px solid var(--field-border); text-align: left; }
.sheet thead th { background: var(--surface-2); color: var(--muted); font-weight: 700; }
.sheet .sheet-line { position: sticky; left: 0; min-width: 36px; background: var(--surface-2); color: var(--subtle); font-weight: 400; text-align: center; }
.sheet .sheet-note { border-left: 3px solid var(--field-border); color: var(--muted); }
.sheet-attention { list-style: none; padding: 12px 16px; font-size: 14px; }
.sheet-attention li { margin: 4px 0; padding-left: 12px; border-left: 3px solid var(--warning-text); }
.sheet-attention li.is-error { border-left-color: var(--error-text); }
.sheet tr.is-error td { background: var(--error-bg); }
.sheet tr.is-warning td { background: var(--warning-bg); }
.sheet td.marked { color: var(--error-text); font-weight: 700; outline: 2px solid var(--error-text); outline-offset: -2px; }
.qr { display: flex; justify-content: center; padding: 12px; background: var(--qr-bg); border-radius: var(--radius-sm); }
.qr svg { max-width: 100%; }
details summary { display: flex; align-items: center; min-height: 44px; cursor: pointer; }

/* Telas maiores: mesma ordem do celular, aproveitando a largura com colunas. */
@media (min-width: 768px) {
  .content { max-width: 1200px; padding: 8px 24px 24px; }
  h1 { font-size: 40px; margin: 16px 0 20px; }
  .cards, .columns { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 16px; align-items: start; }
  .cards > .card, .cards > p { margin: 0; }
  .cards > .empty { grid-column: 1 / -1; }
  .tiles { grid-template-columns: repeat(4, 1fr); }
  .content > form.stack, .content > form.card { max-width: 640px; }
  .topbar { max-width: 1152px; margin-left: auto; margin-right: auto; }
}

/* Computador: a navegação vira barra lateral clara, com o item ativo em laranja claro e as opções de "Mais" à vista. */
@media (min-width: 1024px) {
  body { padding-bottom: 0; padding-left: 256px; }
  .topbar { margin: 16px 24px 0; max-width: none; }
  .bottom-nav {
    top: 16px; bottom: 16px; left: 16px; right: auto; width: 224px; flex-direction: column; justify-content: flex-start; gap: 4px;
    padding: 12px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
  }
  html.dark .bottom-nav { background: var(--brand-700); }
  .bottom-nav .icon { display: block; }
  .bottom-nav a, .bottom-nav .nav-extra button {
    flex: 0 0 auto; min-height: 42px; justify-content: flex-start; gap: 12px; padding: 0 12px; border-radius: var(--radius-sm); color: var(--muted); font-size: 14px;
  }
  .bottom-nav a:hover, .bottom-nav .nav-extra button:hover { background: var(--hover); color: var(--text); }
  .bottom-nav a[aria-current="page"] { background: var(--accent-tint); color: var(--accent); }
  .bottom-nav .nav-more { display: none; }
  .bottom-nav .nav-extra { display: flex; }
  .bottom-nav form.nav-extra { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--border); }
  .bottom-nav form.nav-extra button {
    width: 100%; min-height: 42px; background: none; border: 0; box-shadow: none; font: inherit; font-size: 14px; font-weight: 400; cursor: pointer; text-align: left;
  }
}
