  :root {
    --bg: #f3f5f9;
    --surface: #ffffff;
    --surface-2: #f8f9fc;
    --text: #172033;
    --muted: #64708a;
    --border: #e3e7ef;
    --accent: #2f5bea;
    --accent-strong: #2149cf;
    --accent-soft: #e8eefe;
    --ok: #12945b;
    --ok-soft: #e3f6ec;
    --warn: #b86e00;
    --warn-soft: #fff3dc;
    --danger: #d1343e;
    --danger-soft: #fde8ea;
    --neutral-soft: #eef0f4;
    --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06);
    --shadow-lg: 0 12px 32px rgba(16, 24, 40, .18);
    --radius: 14px;
    --tabbar-h: 64px;
    --safe-b: env(safe-area-inset-bottom, 0px);
  }
  @media (prefers-color-scheme: dark) {
    :root {
      --bg: #0f1420;
      --surface: #171d2b;
      --surface-2: #1d2434;
      --text: #e8ecf4;
      --muted: #94a0b8;
      --border: #2a3245;
      --accent: #6b8cff;
      --accent-strong: #8aa4ff;
      --accent-soft: #1f2a4a;
      --ok: #3ccf8e;
      --ok-soft: #15322a;
      --warn: #f2b14c;
      --warn-soft: #3a2c13;
      --danger: #ff6b74;
      --danger-soft: #3d1b20;
      --neutral-soft: #232b3c;
      --shadow: 0 1px 2px rgba(0, 0, 0, .3);
      --shadow-lg: 0 12px 32px rgba(0, 0, 0, .5);
    }
  }

  * { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
  html, body { margin: 0; padding: 0; }
  body {
    font-family: system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 15px;
    line-height: 1.45;
    -webkit-font-smoothing: antialiased;
  }
  .hidden { display: none !important; }
  svg.i { width: 20px; height: 20px; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
  svg.i.sm { width: 16px; height: 16px; }

  h1 { font-size: 22px; margin: 0; letter-spacing: -.01em; }
  h2 { font-size: 17px; margin: 0 0 12px; }
  h3 { font-size: 13px; margin: 0 0 8px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 650; }
  .muted { color: var(--muted); }
  .small { font-size: 13px; }
  .num { font-variant-numeric: tabular-nums; }

  /* ---------- Formulários ---------- */
  label.campo { display: block; margin-bottom: 14px; }
  label.campo > span { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
  input, select, textarea {
    width: 100%;
    font: inherit;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 11px 12px;
    outline: none;
    transition: border-color .15s, box-shadow .15s;
  }
  input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
  textarea { resize: vertical; min-height: 70px; }

  .btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    font: inherit; font-weight: 600; font-size: 14px;
    border: 1px solid transparent; border-radius: 10px;
    padding: 10px 16px; cursor: pointer;
    background: var(--accent); color: #fff;
    transition: background .15s, transform .05s;
    white-space: nowrap;
  }
  .btn:hover { background: var(--accent-strong); }
  .btn:active { transform: scale(.98); }
  .btn:disabled { opacity: .55; cursor: default; }
  .btn.sec { background: var(--surface); color: var(--text); border-color: var(--border); }
  .btn.sec:hover { background: var(--surface-2); }
  .btn.ghost { background: transparent; color: var(--accent); }
  .btn.ghost:hover { background: var(--accent-soft); }
  .btn.perigo { background: var(--danger); }
  .btn.ok { background: var(--ok); }
  .btn.bloco { width: 100%; }
  .btn.mini { padding: 6px 10px; font-size: 13px; border-radius: 8px; }
  .btn.icone { padding: 8px; border-radius: 10px; }

  .msg { padding: 10px 12px; border-radius: 10px; font-size: 14px; margin-bottom: 14px; }
  .msg.erro { background: var(--danger-soft); color: var(--danger); }
  .msg.ok { background: var(--ok-soft); color: var(--ok); }

  /* ---------- Login ---------- */
  #telaLogin { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
  .login-box { width: 100%; max-width: 380px; }
  .login-logo {
    width: 56px; height: 56px; border-radius: 16px; background: var(--accent); color: #fff;
    display: flex; align-items: center; justify-content: center; margin-bottom: 18px;
  }
  .login-logo svg.i { width: 28px; height: 28px; }
  .login-box p { margin: 6px 0 24px; }

  /* ---------- Estrutura do app ---------- */
  .layout { min-height: 100vh; }
  .sidebar { display: none; }
  .topbar {
    position: sticky; top: 0; z-index: 30;
    display: flex; align-items: center; gap: 10px;
    padding: 12px 16px;
    background: color-mix(in srgb, var(--bg) 88%, transparent);
    backdrop-filter: saturate(1.4) blur(10px);
    -webkit-backdrop-filter: saturate(1.4) blur(10px);
    border-bottom: 1px solid var(--border);
  }
  .topbar h1 { font-size: 19px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  main { padding: 16px 16px calc(var(--tabbar-h) + var(--safe-b) + 90px); max-width: 980px; margin: 0 auto; }
  #btnNovaTopo { display: none; }
  @media (min-width: 900px) { #btnNovaTopo:not(.hidden) { display: inline-flex; } }

  .tabbar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
    height: calc(var(--tabbar-h) + var(--safe-b)); padding-bottom: var(--safe-b);
    display: flex; background: var(--surface); border-top: 1px solid var(--border);
  }
  .tabbar button {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    background: none; border: 0; font: inherit; font-size: 11px; font-weight: 600; color: var(--muted); cursor: pointer;
  }
  .tabbar button.ativo { color: var(--accent); }
  .tabbar svg.i { width: 22px; height: 22px; }

  .fab {
    position: fixed; right: 18px; bottom: calc(var(--tabbar-h) + var(--safe-b) + 16px); z-index: 35;
    width: 56px; height: 56px; border-radius: 18px; border: 0; cursor: pointer;
    background: var(--accent); color: #fff; box-shadow: var(--shadow-lg);
    display: flex; align-items: center; justify-content: center;
  }
  .fab svg.i { width: 26px; height: 26px; }

  @media (min-width: 900px) {
    .layout { display: grid; grid-template-columns: 240px 1fr; }
    .sidebar {
      display: flex; flex-direction: column; gap: 4px;
      position: sticky; top: 0; height: 100vh; padding: 20px 14px;
      background: var(--surface); border-right: 1px solid var(--border);
    }
    .sidebar .marca { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; padding: 4px 8px 20px; }
    .sidebar .marca span.logo { width: 34px; height: 34px; border-radius: 10px; background: var(--accent); color: #fff; display: flex; align-items: center; justify-content: center; }
    .sidebar nav button {
      width: 100%; display: flex; align-items: center; gap: 12px; padding: 10px 12px;
      border: 0; border-radius: 10px; background: none; font: inherit; font-weight: 600; color: var(--muted); cursor: pointer; text-align: left;
    }
    .sidebar nav button:hover { background: var(--surface-2); color: var(--text); }
    .sidebar nav button.ativo { background: var(--accent-soft); color: var(--accent); }
    .sidebar .rodape { margin-top: auto; padding: 12px 8px 0; border-top: 1px solid var(--border); font-size: 13px; }
    .tabbar, .fab { display: none; }
    main { padding: 24px 32px 60px; }
    .topbar { padding: 16px 32px; }
  }

  /* ---------- Filtros ---------- */
  .busca { position: relative; margin-bottom: 12px; }
  .busca svg.i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); }
  .busca input { padding-left: 40px; }
  .segmentado { display: flex; background: var(--neutral-soft); border-radius: 11px; padding: 3px; margin-bottom: 12px; }
  .segmentado button {
    flex: 1; border: 0; background: none; font: inherit; font-size: 13px; font-weight: 600; color: var(--muted);
    padding: 8px 4px; border-radius: 9px; cursor: pointer; white-space: nowrap;
  }
  .segmentado button.ativo { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
  .chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; margin: 0 -16px 14px; padding-left: 16px; padding-right: 16px; scrollbar-width: none; }
  .chips::-webkit-scrollbar { display: none; }
  @media (min-width: 900px) { .chips { margin-left: 0; margin-right: 0; padding-left: 0; padding-right: 0; flex-wrap: wrap; } }
  .chip {
    display: inline-flex; align-items: center; gap: 6px; flex: none;
    border: 1px solid var(--border); background: var(--surface); color: var(--text);
    font: inherit; font-size: 13px; font-weight: 600; padding: 6px 12px; border-radius: 999px; cursor: pointer;
  }
  .chip .n { background: var(--neutral-soft); color: var(--muted); border-radius: 999px; padding: 0 7px; font-size: 12px; }
  .chip.ativo { background: var(--accent); border-color: var(--accent); color: #fff; }
  .chip.ativo .n { background: rgba(255, 255, 255, .25); color: #fff; }
  .linha-ferramentas { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 10px; }
  .linha-ferramentas select { width: auto; padding: 6px 10px; font-size: 13px; border-radius: 8px; }

  /* ---------- Cartão de requisição ---------- */
  .lista { display: grid; gap: 12px; }
  @media (min-width: 1200px) { .lista { grid-template-columns: 1fr 1fr; } }
  .req {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: var(--shadow); padding: 14px 16px; cursor: pointer; transition: border-color .15s;
  }
  .req:hover { border-color: color-mix(in srgb, var(--accent) 40%, var(--border)); }
  .req-topo { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
  .req-id { font-weight: 750; font-size: 16px; }
  .req-quando { margin-left: auto; font-size: 12px; color: var(--muted); }
  .req-itens { margin: 6px 0 2px; font-weight: 550; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
  .req-quem { font-size: 13px; color: var(--muted); }
  .req-acao { margin-top: 12px; display: flex; gap: 8px; }
  .req-acao .btn { flex: 1; }

  .tag { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; font-weight: 700; padding: 2px 8px; border-radius: 999px; text-transform: uppercase; letter-spacing: .02em; }
  .tag.urgente { background: var(--danger-soft); color: var(--danger); }
  .tag.atrasada { background: var(--warn-soft); color: var(--warn); }
  .tag.concluida { background: var(--ok-soft); color: var(--ok); }
  .tag.cancelada { background: var(--neutral-soft); color: var(--muted); }

  .progresso { margin-top: 12px; }
  .progresso .barra { display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; }
  .progresso .barra span { height: 6px; border-radius: 99px; background: var(--neutral-soft); }
  .progresso .barra span.feita { background: var(--ok); }
  .progresso .barra span.atual { background: var(--accent); }
  .progresso.cancelada .barra span.feita { background: var(--muted); }
  .progresso .rotulo { display: flex; justify-content: space-between; margin-top: 6px; font-size: 13px; }
  .progresso .rotulo b { font-weight: 650; }

  .vazio { text-align: center; padding: 48px 16px; color: var(--muted); }
  .vazio svg.i { width: 40px; height: 40px; margin-bottom: 8px; opacity: .6; }

  .esqueleto { height: 128px; border-radius: var(--radius); background: linear-gradient(90deg, var(--surface) 0%, var(--surface-2) 50%, var(--surface) 100%); background-size: 200% 100%; animation: brilho 1.2s infinite; border: 1px solid var(--border); }
  @keyframes brilho { from { background-position: 200% 0; } to { background-position: -200% 0; } }

  /* ---------- Painéis / cartões genéricos ---------- */
  .cartao { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 14px; }
  .kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 14px; }
  @media (min-width: 700px) { .kpis { grid-template-columns: repeat(4, 1fr); } }
  .kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; cursor: pointer; box-shadow: var(--shadow); }
  .kpi .v { font-size: 28px; font-weight: 750; letter-spacing: -.02em; }
  .kpi .l { font-size: 12.5px; color: var(--muted); font-weight: 600; }
  .kpi.alerta .v { color: var(--danger); }
  .kpi.aviso .v { color: var(--warn); }

  .funil-linha { display: grid; grid-template-columns: 150px 1fr 36px; gap: 10px; align-items: center; padding: 6px 0; cursor: pointer; font-size: 14px; }
  .funil-linha .trilho { height: 10px; background: var(--neutral-soft); border-radius: 99px; overflow: hidden; }
  .funil-linha .trilho i { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
  .funil-linha .n { text-align: right; font-weight: 700; }
  @media (max-width: 420px) { .funil-linha { grid-template-columns: 120px 1fr 30px; font-size: 13px; } }

  table.tabela { width: 100%; border-collapse: collapse; font-size: 14px; }
  table.tabela th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 650; padding: 6px 8px; border-bottom: 1px solid var(--border); }
  table.tabela td { padding: 8px; border-bottom: 1px solid var(--border); }
  table.tabela td.n, table.tabela th.n { text-align: right; }

  /* ---------- Nova requisição ---------- */
  .item-form { border: 1px solid var(--border); border-radius: 12px; padding: 12px; margin-bottom: 10px; background: var(--surface-2); }
  .item-form .grade { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
  .item-form label.campo { margin-bottom: 8px; }
  .item-form .cab { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; font-size: 13px; font-weight: 650; color: var(--muted); }
  .alternar { display: flex; gap: 8px; }
  .alternar button { flex: 1; }
  .alternar button.ativo.urgente { background: var(--danger); border-color: var(--danger); color: #fff; }
  .alternar button.ativo.normal { background: var(--accent); border-color: var(--accent); color: #fff; }

  /* ---------- Detalhe (painel lateral / tela cheia) ---------- */
  .fundo { position: fixed; inset: 0; background: rgba(10, 15, 30, .45); z-index: 50; opacity: 0; transition: opacity .2s; }
  .fundo.aberto { opacity: 1; }
  .detalhe {
    position: fixed; z-index: 60; background: var(--bg);
    inset: 0; display: flex; flex-direction: column;
    transform: translateX(100%); transition: transform .25s ease;
  }
  .detalhe.aberto { transform: none; }
  @media (min-width: 900px) {
    .detalhe { left: auto; width: 560px; box-shadow: var(--shadow-lg); border-left: 1px solid var(--border); }
  }
  .detalhe-topo { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--border); background: var(--surface); }
  .detalhe-topo h2 { margin: 0; flex: 1; font-size: 18px; }
  .detalhe-corpo { flex: 1; overflow-y: auto; padding: 16px 16px calc(24px + var(--safe-b)); }

  .info-grade { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; }
  .info-grade div > span { display: block; font-size: 12px; color: var(--muted); font-weight: 600; }
  .info-grade div > b { font-weight: 600; }

  .etapas { list-style: none; margin: 0; padding: 0; }
  .etapas li { position: relative; display: grid; grid-template-columns: 32px 1fr; gap: 12px; padding-bottom: 18px; }
  .etapas li:last-child { padding-bottom: 0; }
  .etapas li::before { content: ''; position: absolute; left: 15px; top: 32px; bottom: 2px; width: 2px; background: var(--border); }
  .etapas li:last-child::before { display: none; }
  .etapas li.feita::before { background: var(--ok); }
  .etapas .bola {
    width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
    font-size: 13px; font-weight: 700; background: var(--neutral-soft); color: var(--muted); border: 2px solid var(--surface);
    position: relative; z-index: 1;
  }
  .etapas li.feita .bola { background: var(--ok); color: #fff; }
  .etapas li.atual .bola { background: var(--accent); color: #fff; box-shadow: 0 0 0 4px var(--accent-soft); }
  .etapas .nome { font-weight: 650; padding-top: 5px; }
  .etapas li.pendente .nome { color: var(--muted); }
  .etapas .quem { font-size: 13px; color: var(--muted); }
  .etapas .obs { font-size: 13.5px; margin-top: 4px; padding: 6px 10px; background: var(--surface-2); border-radius: 8px; border: 1px solid var(--border); white-space: pre-wrap; }
  .etapas .acoes { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }

  .itens-lista { list-style: none; margin: 0; padding: 0; }
  .itens-lista li { display: flex; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--border); }
  .itens-lista li:last-child { border-bottom: 0; }
  .itens-lista .qtd { min-width: 64px; font-weight: 700; font-variant-numeric: tabular-nums; }
  .itens-lista .estoque { font-size: 12.5px; color: var(--muted); }

  .linha-tempo { list-style: none; margin: 0 0 12px; padding: 0; }
  .linha-tempo li { padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
  .linha-tempo li:last-child { border-bottom: 0; }
  .linha-tempo .cab { font-size: 12.5px; color: var(--muted); }
  .linha-tempo .txt { white-space: pre-wrap; margin-top: 2px; }
  .linha-tempo li.comentario .txt { background: var(--accent-soft); padding: 6px 10px; border-radius: 10px; display: inline-block; max-width: 100%; }

  .acoes-rodape { display: flex; gap: 8px; flex-wrap: wrap; }

  /* ---------- Folha inferior (modal) ---------- */
  .folha {
    position: fixed; z-index: 80; left: 0; right: 0; bottom: 0;
    background: var(--surface); border-radius: 20px 20px 0 0; box-shadow: var(--shadow-lg);
    max-height: 90vh; overflow-y: auto; padding: 8px 16px calc(16px + var(--safe-b));
    transform: translateY(100%); transition: transform .22s ease;
  }
  .folha.aberto { transform: none; }
  .folha .puxador { width: 40px; height: 4px; border-radius: 4px; background: var(--border); margin: 4px auto 14px; }
  .folha h2 { margin-bottom: 4px; }
  .folha .sub { margin: 0 0 16px; color: var(--muted); font-size: 14px; }
  .folha .botoes { display: flex; gap: 8px; margin-top: 6px; }
  .folha .botoes .btn { flex: 1; }
  .fundo.folha-fundo { z-index: 70; }
  @media (min-width: 700px) {
    .folha { left: 50%; bottom: auto; top: 50%; width: 480px; border-radius: 18px; transform: translate(-50%, -45%); opacity: 0; pointer-events: none; transition: opacity .18s, transform .18s; }
    .folha.aberto { transform: translate(-50%, -50%); opacity: 1; pointer-events: auto; }
    .folha .puxador { display: none; }
  }

  /* ---------- Usuários ---------- */
  .usuario-linha { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); cursor: pointer; }
  .usuario-linha:last-child { border-bottom: 0; }
  .avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: flex; align-items: center; justify-content: center; font-weight: 700; flex: none; }
  .usuario-linha .nome { font-weight: 600; }
  .usuario-linha.inativo { opacity: .5; }

  /* ---------- Toast ---------- */
  #toast {
    position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + var(--safe-b) + 84px); transform: translate(-50%, 20px);
    background: #172033; color: #fff; padding: 11px 18px; border-radius: 12px; font-size: 14px; font-weight: 550;
    opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 100; max-width: calc(100% - 32px); text-align: center;
  }
  #toast.on { opacity: 1; transform: translate(-50%, 0); }
  #toast.erro { background: var(--danger); }
  @media (min-width: 900px) { #toast { bottom: 28px; } }

  .carregando-topo { position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 200; overflow: hidden; }
  .carregando-topo i { display: block; height: 100%; width: 40%; background: var(--accent); animation: corre 1s infinite ease-in-out; }
  @keyframes corre { from { transform: translateX(-100%); } to { transform: translateX(250%); } }
