
/* Layout: ferramenta de fila — faixa de status (resumo e abas) no topo, lista densa abaixo, detalhe em painel lateral */
:root {
  --bg: #F3F5F4;
  --surface: #FFFFFF;
  --surface-2: #EAEEEC;
  --fg: #16201D;
  --muted: #5C6B66;
  --line: #D5DCD9;
  --accent: #0E5B4C;
  --accent-fg: #FFFFFF;
  --accent-soft: #DCEBE6;
  --wait: #9A5B00;   --wait-bg: #FBEBD2;
  --ok: #1D5FA8;     --ok-bg: #DCE8F7;
  --paid: #1E7A3C;   --paid-bg: #DAF0E0;
  --bad: #B3261E;    --bad-bg: #F8DEDB;
  --shadow: 0 1px 2px rgba(16,32,28,.06), 0 8px 24px rgba(16,32,28,.08);
  --f-display: "Archivo", "Arial Narrow", system-ui, sans-serif;
  --f-body: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --f-mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0F1513; --surface: #171F1C; --surface-2: #1F2926; --fg: #E6EDEA; --muted: #9AABA5; --line: #2C3834;
    --accent: #5BC2A6; --accent-fg: #06221B; --accent-soft: #1B3A32;
    --wait: #F2B65A; --wait-bg: #3A2A10; --ok: #8DB8F0; --ok-bg: #172B45; --paid: #7DD69A; --paid-bg: #15331F; --bad: #F2948C; --bad-bg: #401A17;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.35);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0F1513; --surface: #171F1C; --surface-2: #1F2926; --fg: #E6EDEA; --muted: #9AABA5; --line: #2C3834;
  --accent: #5BC2A6; --accent-fg: #06221B; --accent-soft: #1B3A32;
  --wait: #F2B65A; --wait-bg: #3A2A10; --ok: #8DB8F0; --ok-bg: #172B45; --paid: #7DD69A; --paid-bg: #15331F; --bad: #F2948C; --bad-bg: #401A17;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.35);
  color-scheme: dark;
}
* { box-sizing: border-box; }
body { background: var(--bg); color: var(--fg); font-family: var(--f-body); font-size: 14px; line-height: 1.45; }
.app { max-width: 1180px; margin: 0 auto; padding-block: 20px 48px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); display: flex; flex-direction: column; gap: 16px; }
h1, h2, h3 { font-family: var(--f-display); margin: 0; text-wrap: balance; letter-spacing: -.01em; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.num { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--f-mono); font-size: 12.5px; }
.muted { color: var(--muted); }

/* header */
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.mark { font-family: var(--f-display); font-weight: 700; font-size: 13px; letter-spacing: .08em; background: var(--accent); color: var(--accent-fg); padding: 8px 9px; border-radius: 6px; }
.brand h1 { font-size: 22px; font-weight: 700; }
.brand p { margin: 0; color: var(--muted); font-size: 13px; }
.top-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.chip-me { display: inline-flex; align-items: center; gap: 8px; padding: 4px 10px 4px 4px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); font-size: 13px; }
.chip-me img { width: 24px; height: 24px; border-radius: 50%; }
.chip-me .roles { color: var(--muted); font-size: 12px; }
.btn { border: 1px solid var(--line); background: var(--surface); padding: 8px 14px; border-radius: 8px; font-weight: 500; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, var(--line)); }
.btn.good { background: var(--paid); color: var(--surface); border-color: var(--paid); font-weight: 600; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.banner { padding: 12px 14px; border-radius: 8px; background: var(--wait-bg); color: var(--fg); border: 1px solid color-mix(in srgb, var(--wait) 35%, transparent); }

/* status tiles = abas */
.tiles { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; }
.tile { text-align: left; border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: 12px 14px; display: flex; flex-direction: column; gap: 2px; position: relative; min-width: 0; }
.tile .lbl { font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; display: flex; align-items: center; gap: 6px; }
.tile .lbl i { width: 8px; height: 8px; border-radius: 50%; background: var(--c, var(--muted)); display: inline-block; }
.tile .count { font-family: var(--f-display); font-size: 26px; font-weight: 700; line-height: 1.1; }
.tile .sum { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile .alert { font-size: 12px; color: var(--bad); font-weight: 600; min-height: 1em; }
.tile[aria-selected="true"] { border-color: var(--c, var(--accent)); box-shadow: inset 0 0 0 1px var(--c, var(--accent)); }
.tile:hover { background: var(--surface-2); }

.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.toolbar input[type="search"] { flex: 1 1 260px; min-width: 0; }
.field, .toolbar input, .toolbar select { border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 8px 10px; }

/* lista */
.list { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.row { display: grid; grid-template-columns: 112px minmax(0, 1.1fr) minmax(0, 1.6fr) minmax(0, 1fr) 132px 172px; gap: 12px; align-items: center; padding: 12px 14px; border-top: 1px solid var(--line); cursor: pointer; width: 100%; text-align: left; background: none; border-left: 0; border-right: 0; border-bottom: 0; }
.row:first-child { border-top: 0; }
.row:hover { background: var(--surface-2); }
.row.head { cursor: default; font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; padding-block: 9px; background: var(--surface-2); }
.row .cell { min-width: 0; }
.row .t1 { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .t2 { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .valor { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.venc { display: inline-flex; flex-direction: column; gap: 1px; }
.venc b { font-variant-numeric: tabular-nums; font-weight: 600; }
.venc small { font-size: 11.5px; font-weight: 600; }
.venc.late small { color: var(--bad); } .venc.today small { color: var(--wait); } .venc.soon small { color: var(--wait); } .venc.fine small { color: var(--muted); }
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 999px; white-space: nowrap; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.s-aguardando { color: var(--wait); background: var(--wait-bg); }
.s-aprovado { color: var(--ok); background: var(--ok-bg); }
.s-pago { color: var(--paid); background: var(--paid-bg); }
.s-reprovado, .s-cancelada { color: var(--bad); background: var(--bad-bg); }
.empty { padding: 40px 20px; text-align: center; color: var(--muted); display: flex; flex-direction: column; gap: 6px; align-items: center; }
.empty strong { color: var(--fg); font-family: var(--f-display); font-size: 16px; }

/* dialogs */
dialog { border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--fg); padding: 0; box-shadow: var(--shadow); width: min(640px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); }
dialog::backdrop { background: rgba(10,20,17,.45); }
dialog.side { margin: 0 0 0 auto; height: 100dvh; max-height: 100dvh; border-radius: 0; width: min(560px, 100vw); border-width: 0 0 0 1px; }
.dlg { display: flex; flex-direction: column; max-height: inherit; height: 100%; }
.dlg-h { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); padding-top: max(16px, env(safe-area-inset-top, 0px)); }
.dlg-h h2 { font-size: 18px; }
.dlg-b { padding: 18px 20px; overflow-y: auto; display: flex; flex-direction: column; gap: 16px; flex: 1; }
.dlg-f { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; padding-bottom: max(14px, env(safe-area-inset-bottom, 0px)); }
.x { border: 0; background: none; font-size: 22px; line-height: 1; padding: 2px 6px; color: var(--muted); border-radius: 6px; }
.x:hover { background: var(--surface-2); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; }
.f { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.f.full { grid-column: 1 / -1; }
.f label { font-size: 12.5px; font-weight: 600; }
.f label .req { color: var(--bad); }
.f .hint { font-size: 12px; color: var(--muted); }
.f .err { font-size: 12px; color: var(--bad); font-weight: 500; }
.field { width: 100%; }
textarea.field { resize: vertical; min-height: 64px; }
.drop { border: 1.5px dashed var(--line); border-radius: 8px; padding: 12px; display: flex; flex-direction: column; gap: 6px; background: var(--bg); }
.drop.over { border-color: var(--accent); background: var(--accent-soft); }
.drop input { font-size: 13px; max-width: 100%; }
.formerr { background: var(--bad-bg); color: var(--bad); padding: 10px 12px; border-radius: 8px; font-weight: 500; }

/* detalhe */
.d-top { display: flex; flex-direction: column; gap: 8px; }
.d-valor { font-family: var(--f-display); font-size: 30px; font-weight: 700; font-variant-numeric: tabular-nums; }
.kv { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; margin: 0; }
.kv div { min-width: 0; }
.kv dt { font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }
.kv dd { margin: 2px 0 0; overflow-wrap: anywhere; }
.files { display: flex; flex-direction: column; gap: 6px; }
.file { display: flex; align-items: center; gap: 10px; padding: 8px 8px 8px 12px; border: 1px solid var(--line); border-radius: 8px; color: var(--fg); background: var(--bg); min-width: 0; flex-wrap: wrap; }
.fbtn { border: 1px solid var(--line); background: var(--surface); color: var(--fg); padding: 5px 10px; border-radius: 6px; font-size: 12.5px; font-weight: 500; text-decoration: none; flex: none; }
.fbtn:hover { border-color: var(--accent); color: var(--accent); }
.fbtn:disabled { opacity: .6; }
.file .ext { font-family: var(--f-mono); font-size: 11px; font-weight: 500; background: var(--surface-2); padding: 2px 6px; border-radius: 4px; text-transform: uppercase; flex: none; }
.file .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0; }
.file .tag { font-size: 11.5px; color: var(--muted); flex: none; }
.file.comp { border-color: color-mix(in srgb, var(--paid) 50%, var(--line)); background: var(--paid-bg); }
.sec-t { font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; margin-bottom: 6px; }
.timeline { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.timeline li { display: grid; grid-template-columns: 10px 1fr; gap: 10px; }
.timeline li::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); margin-top: 6px; }
.timeline .when { font-size: 12px; color: var(--muted); }
.timeline .obs { font-size: 13px; background: var(--surface-2); padding: 6px 9px; border-radius: 6px; margin-top: 4px; overflow-wrap: anywhere; }
.action-box { border: 1px solid var(--line); border-radius: 10px; padding: 14px; display: flex; flex-direction: column; gap: 12px; background: var(--bg); }
.action-box h3 { font-size: 15px; }
.btns { display: flex; gap: 8px; flex-wrap: wrap; }
.motivo { background: var(--bad-bg); color: var(--fg); padding: 10px 12px; border-radius: 8px; border-left: 3px solid var(--bad); }

/* equipe */
.people { display: flex; flex-direction: column; }
.person { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); }
.person:first-child { border-top: 0; }
.person .who { display: flex; align-items: center; gap: 10px; min-width: 0; }
.person img { width: 28px; height: 28px; border-radius: 50%; flex: none; }
.person .roles { display: flex; gap: 10px; flex-wrap: wrap; font-size: 13px; }
.person .roles label { display: inline-flex; gap: 5px; align-items: center; }

.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(20px + env(safe-area-inset-bottom, 0px)); background: var(--fg); color: var(--bg); padding: 10px 16px; border-radius: 8px; font-weight: 500; z-index: 50; box-shadow: var(--shadow); max-width: calc(100vw - 32px); }

@media (max-width: 900px) {
  .tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .row.head { display: none; }
  .row { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "forn valor" "oc status" "venc cc"; gap: 6px 12px; }
  .row .c-venc { grid-area: venc; } .row .c-oc { grid-area: oc; } .row .c-forn { grid-area: forn; } .row .c-cc { grid-area: cc; text-align: right; }
  .row .c-valor { grid-area: valor; } .row .c-status { grid-area: status; text-align: right; }
  .venc { flex-direction: row; gap: 8px; align-items: baseline; }
}
@media (max-width: 560px) {
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid2, .kv { grid-template-columns: 1fr; }
  .brand h1 { font-size: 19px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ---- adicionais da versão Cloudflare ---- */
html, body { margin: 0; }
[hidden] { display: none !important; }
a { color: var(--accent); }
.chip-me { cursor: default; }
.chip-me .setor { color: var(--muted); font-size: 12px; }
.linkbtn { background: none; border: 0; color: var(--accent); font-weight: 600; padding: 4px 6px; border-radius: 6px; }
.linkbtn:hover { background: var(--accent-soft); }
.utable { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.utable th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 8px 6px; border-bottom: 1px solid var(--line); }
.utable td { padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.utable select, .utable input { border: 1px solid var(--line); background: var(--surface); border-radius: 6px; padding: 5px 6px; }
.utable .off td { opacity: .55; }
.scrollx { overflow-x: auto; }
.okbox { background: var(--paid-bg); color: var(--fg); padding: 10px 12px; border-radius: 8px; border-left: 3px solid var(--paid); overflow-wrap: anywhere; }
.newuser { border: 1px solid var(--line); border-radius: 10px; padding: 14px; display: flex; flex-direction: column; gap: 12px; background: var(--bg); }
.check { display: inline-flex; gap: 6px; align-items: center; font-size: 13px; }

/* login */
.auth { min-height: 100vh; display: grid; place-items: center; padding-block: 32px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.auth-card { width: min(420px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); padding: 28px; display: flex; flex-direction: column; gap: 16px; }
.auth-card .brand { margin-bottom: 4px; }
.auth-card .btn { width: 100%; padding: 11px; }

/* urgência e condição */
.s-prazo { color: var(--accent); background: var(--accent-soft); }
.pill.u-atraso { color: var(--surface); background: var(--bad); }
.pill.u-urgente { color: var(--surface); background: var(--wait); }
.row .c-status { display: flex; flex-direction: column; gap: 4px; align-items: flex-start; }
.row.urg-atraso { box-shadow: inset 4px 0 0 var(--bad); }
.row.urg-urgente { box-shadow: inset 4px 0 0 var(--wait); }
@media (max-width: 900px) { .row .c-status { align-items: flex-end; } }

/* card Atualizar */
.refresh { position: relative; display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--fg); padding: 5px 12px 5px 10px; border-radius: 10px; text-align: left; }
.refresh:hover { border-color: var(--accent); }
.refresh svg { color: var(--accent); flex: none; }
.refresh .rf-txt { display: flex; flex-direction: column; line-height: 1.15; }
.refresh .rf-txt b { font-size: 13px; font-weight: 600; }
.refresh .rf-txt small { font-size: 11.5px; color: var(--muted); }
.rf-flag { font-size: 11.5px; font-weight: 700; color: var(--surface); background: var(--bad); padding: 2px 8px; border-radius: 999px; }
.refresh.tem-novidade { border-color: var(--bad); box-shadow: 0 0 0 3px color-mix(in srgb, var(--bad) 18%, transparent); }
.refresh.girando svg { animation: girar .8s linear infinite; }
@keyframes girar { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .refresh.girando svg { animation: none; } }

/* campos lidos do PDF da OC */
.field.travado { background: var(--surface-2); color: var(--fg); cursor: not-allowed; border-style: dashed; }
.field.travado:focus-visible { outline-color: var(--muted); }
