:root {
  --bg: #f5f6f8; --surface: #ffffff; --surface-2: #f0f2f5; --border: #e2e5ea;
  --text: #16191f; --muted: #667085; --accent: #1f6feb; --accent-soft: #e6efff;
  --ok: #15803d; --ok-soft: #dcfce7; --warn: #b45309; --warn-soft: #fef3c7;
  --info: #1d4ed8; --info-soft: #dbeafe; --bad: #b91c1c; --bad-soft: #fee2e2;
  --radius: 10px; --shadow: 0 1px 2px rgba(16,24,40,.06);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115; --surface: #171a21; --surface-2: #1f232c; --border: #2a2f3a;
    --text: #e6e8ec; --muted: #8b93a3; --accent: #4c8dff; --accent-soft: #1b2a45;
    --ok: #4ade80; --ok-soft: #12301f; --warn: #fbbf24; --warn-soft: #3a2a0c;
    --info: #7aa7ff; --info-soft: #172846; --bad: #f87171; --bad-soft: #3b1515;
    --shadow: none;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
button, input, select { font: inherit; color: inherit; }
input, select {
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  padding: 7px 10px; min-width: 0; width: 100%;
}
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
input:disabled { opacity: .45; }
button { cursor: pointer; border: 1px solid var(--border); background: var(--surface); border-radius: 8px; padding: 7px 12px; }
button:hover { background: var(--surface-2); }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
button.primary:hover { filter: brightness(1.08); }
button.ghost { border-color: transparent; background: transparent; color: var(--muted); padding: 6px 8px; }
button.ghost:hover { background: var(--surface-2); color: var(--text); }
button.danger:hover { color: var(--bad); }
.icon { padding: 6px 8px; line-height: 1; }

/* login */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.auth form { width: 100%; max-width: 360px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 28px; box-shadow: var(--shadow); display: grid; gap: 12px; }
.auth h1 { margin: 0 0 4px; font-size: 20px; }
.auth p { margin: 0 0 6px; color: var(--muted); }
.auth label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.err { color: var(--bad); font-size: 13px; min-height: 18px; }

/* shell */
header.top { position: sticky; top: 0; z-index: 5; background: var(--surface); border-bottom: 1px solid var(--border); }
.top-in { max-width: 1180px; margin: 0 auto; padding: 0 16px; display: flex; align-items: center; gap: 16px; height: 56px; }
.brand { font-weight: 700; white-space: nowrap; }
nav.tabs { display: flex; gap: 4px; overflow-x: auto; flex: 1; }
nav.tabs button { border: 0; background: transparent; color: var(--muted); padding: 8px 12px; border-radius: 8px; white-space: nowrap; font-weight: 500; }
nav.tabs button.on { background: var(--accent-soft); color: var(--accent); }
.save { font-size: 12px; color: var(--muted); white-space: nowrap; }
.save.erro { color: var(--bad); }
main { max-width: 1180px; margin: 0 auto; padding: 20px 16px 60px; }
h2 { font-size: 18px; margin: 0 0 4px; }
.sub { color: var(--muted); margin: 0 0 16px; }

.bar { display: flex; gap: 8px; margin-bottom: 18px; flex-wrap: wrap; }
.bar input { flex: 1; min-width: 200px; }
.bar.big input { font-size: 16px; padding: 12px 14px; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 12px; }
.empty { text-align: center; color: var(--muted); padding: 40px 16px; border: 1px dashed var(--border); border-radius: var(--radius); }

/* aba 1 */
.bm-head { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.bm-head .name { font-weight: 600; font-size: 15px; flex: 1; min-width: 0; overflow-wrap: anywhere; }
.prog { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; white-space: nowrap; }
.prog .track { width: 90px; height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.prog .fill { height: 100%; background: var(--accent); }
.steps { list-style: none; margin: 0; padding: 6px 0; }
.steps li label { display: flex; align-items: center; gap: 12px; padding: 9px 16px; cursor: pointer; }
.steps li label:hover { background: var(--surface-2); }
.steps input[type=checkbox] { width: 18px; height: 18px; flex: none; accent-color: var(--accent); }
.steps .n { color: var(--muted); width: 18px; text-align: right; font-variant-numeric: tabular-nums; }
.steps .t { flex: 1; }
.steps li.done .t { color: var(--muted); text-decoration: line-through; }
.steps .when { font-size: 12px; color: var(--muted); white-space: nowrap; }

/* aba 2 */
.org-head { display: flex; align-items: center; gap: 10px; padding: 12px 14px; cursor: pointer; user-select: none; }
.org-head .caret { width: 18px; color: var(--muted); transition: transform .15s; }
.org-head.open .caret { transform: rotate(90deg); }
.org-head .name { font-weight: 600; flex: 1; min-width: 0; overflow-wrap: anywhere; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.pill { font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.pill.ativa { background: var(--ok-soft); color: var(--ok); }
.pill.pedir { background: var(--warn-soft); color: var(--warn); }
.pill.analise { background: var(--info-soft); color: var(--info); }
.pill.bloqueada { background: var(--bad-soft); color: var(--bad); }
.org-body { border-top: 1px solid var(--border); padding: 12px 14px 14px; }
.bm-meta { display: flex; gap: 10px; align-items: end; margin-bottom: 12px; flex-wrap: wrap; }
.bm-meta label { display: grid; gap: 3px; font-size: 12px; color: var(--muted); }
.acc-grid { display: grid; grid-template-columns: minmax(150px,1.3fr) 150px 190px 230px minmax(170px,1.3fr) 104px 34px; gap: 8px; align-items: start; }
.acc-grid.h { font-size: 12px; color: var(--muted); padding: 0 2px 6px; }
.acc { padding: 8px 0; border-top: 1px solid var(--border); }
.acc:first-of-type { border-top: 0; }
.row2 { display: flex; gap: 6px; }
.row2 select { width: 74px; flex: none; }
.row2 input { flex: 1; }
.row3 { display: grid; grid-template-columns: 74px 1fr; gap: 6px; }
.row3 input[type=date] { grid-column: 1 / -1; }
select.st-ativa { color: var(--ok); }
select.st-pedir { color: var(--warn); }
select.st-analise { color: var(--info); }
select.st-bloqueada { color: var(--bad); }
.bk { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.bk .tag { display: inline-flex; align-items: center; gap: 2px; background: var(--accent-soft); color: var(--accent); border-radius: 999px; padding: 2px 4px 2px 9px; font-size: 12px; }
.bk .tag button { border: 0; background: transparent; color: inherit; padding: 0 5px; font-size: 13px; }
.bk .tag.convidado { background: var(--warn-soft); color: var(--warn); }
.bk .tag.ativo { background: var(--ok-soft); color: var(--ok); }
.bk .tag .tag-st { padding: 0; font-weight: 500; display: inline-flex; gap: 5px; align-items: baseline; }
.bk .tag .tag-st small { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; opacity: .85; }
.bk select { width: auto; padding: 3px 6px; font-size: 12px; }
.run { width: 100%; border-radius: 999px; padding: 7px 10px; background: var(--surface-2); color: var(--muted); font-weight: 600; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.run::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; opacity: .6; }
.run:hover { background: var(--surface-2); filter: brightness(1.1); }
.run.on { background: var(--ok-soft); color: var(--ok); border-color: var(--ok); }
.run.on::before { opacity: 1; }
.run.on:hover { background: var(--ok-soft); }
.card-box { display: grid; gap: 6px; }
.card-flags { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.flag { padding: 5px 6px; font-size: 12px; font-weight: 600; border-radius: 8px; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.flag:hover { filter: brightness(1.1); background: var(--surface-2); }
.flag.on { background: var(--ok-soft); color: var(--ok); border-color: var(--ok); }
.flag.on:hover { background: var(--ok-soft); }
.final { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.final input { flex: 1; }
.lbl { display: none; font-size: 11px; color: var(--muted); margin-bottom: 2px; }
.add-acc { margin-top: 10px; }

/* aba 3 */
.pf-head { display: flex; align-items: center; gap: 10px; padding: 12px 14px; cursor: pointer; user-select: none; }
.pf-head .caret { width: 18px; color: var(--muted); transition: transform .15s; }
.pf-head.open .caret { transform: rotate(90deg); }
.pf-head .name { font-weight: 600; flex: 1; min-width: 0; overflow-wrap: anywhere; }
.pf-head .id { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.pf-body { border-top: 1px solid var(--border); padding: 14px; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px 16px; }
.fld { display: grid; gap: 4px; }
.fld > span { font-size: 12px; color: var(--muted); }
.fld .in { display: flex; gap: 4px; }
.fld .in input { flex: 1; }
.pf-foot { grid-column: 1 / -1; display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.used { display: flex; gap: 4px; flex-wrap: wrap; align-items: center; }

.drag { cursor: grab; color: var(--muted); padding: 4px 5px; border-radius: 6px; touch-action: none; user-select: none; line-height: 1; font-size: 16px; flex: none; }
.drag:hover { background: var(--surface-2); color: var(--text); }
.dragging { opacity: .55; outline: 2px dashed var(--accent); outline-offset: 2px; border-radius: var(--radius); }
body.is-dragging, body.is-dragging * { cursor: grabbing !important; user-select: none; }
.with-grip { display: flex; align-items: center; gap: 4px; }
.with-grip input { flex: 1; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: 13px; z-index: 50; max-width: calc(100% - 32px); }

@media (max-width: 900px) {
  .acc-grid.h { display: none; }
  .acc-grid { grid-template-columns: 1fr 1fr; }
  .acc-grid > .c-nome, .acc-grid > .c-bk { grid-column: 1 / -1; }
  .acc-grid > .c-run { grid-column: 1 / 2; }
  .acc-grid > .c-del { grid-column: 1 / -1; justify-self: end; }
  .lbl { display: block; }
  .acc { padding: 12px 0; }
}
@media (max-width: 560px) {
  .top-in { flex-wrap: wrap; height: auto; padding-top: 10px; padding-bottom: 6px; gap: 6px 12px; }
  nav.tabs { order: 3; flex-basis: 100%; }
  .acc-grid { grid-template-columns: 1fr; }
  .prog .track { width: 50px; }
  .steps .when { display: none; }
}
