/* Workflow - estilos. Sem estilos inline no HTML (CSP style-src 'self'). */
:root, :root[data-theme="light"] {
  --bg: #f3f5f9; --surface: #ffffff; --surface-2: #f7f9fc; --text: #18212f; --muted: #5b6a7f;
  --border: #dbe2ec; --primary: #2563eb; --primary-h: #1d4ed8; --on-primary: #ffffff; --primary-soft: #e3ecff;
  --danger: #dc2626; --danger-soft: #fde8e8; --shadow: 0 6px 24px rgba(15, 30, 60, .12);
  --gray: #64748b; --blue: #2563eb; --red: #dc2626; --green: #16a34a; --dark: #334155; --amber: #d97706; --purple: #7c3aed;
  --gray-bg: #e8edf4; --blue-bg: #dbe7ff; --red-bg: #fde2e2; --green-bg: #d9f3e2; --dark-bg: #dfe3ea; --amber-bg: #fdebc8; --purple-bg: #eadffd;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0b0f16; --surface: #131a24; --surface-2: #19222f; --text: #e6ebf3; --muted: #93a1b5;
  --border: #263244; --primary: #5b9bff; --primary-h: #7cb0ff; --on-primary: #06101f; --primary-soft: #14284a;
  --danger: #ff6b6b; --danger-soft: #3a1b1f; --shadow: 0 6px 24px rgba(0, 0, 0, .55);
  --gray: #9aa8bb; --blue: #5b9bff; --red: #ff6b6b; --green: #4ade80; --dark: #b4c0d0; --amber: #fbbf24; --purple: #a78bfa;
  --gray-bg: #232e3d; --blue-bg: #15294d; --red-bg: #3a1b1f; --green-bg: #12301f; --dark-bg: #2a3442; --amber-bg: #3a2c10; --purple-bg: #2a2150;
  color-scheme: dark;
}
:root[data-theme="dim"] { /* semi escuro */
  --bg: #20283a; --surface: #2a3347; --surface-2: #313b52; --text: #e9edf6; --muted: #aab5c9;
  --border: #44506a; --primary: #7aa7ff; --primary-h: #98bcff; --on-primary: #0d1830; --primary-soft: #36456b;
  --danger: #ff8080; --danger-soft: #4a2c36; --shadow: 0 6px 22px rgba(8, 12, 24, .45);
  --gray: #b0bccf; --blue: #7aa7ff; --red: #ff8080; --green: #5fe39a; --dark: #c3cde0; --amber: #fbc54a; --purple: #b79cff;
  --gray-bg: #3a4560; --blue-bg: #34477a; --red-bg: #4d2f3a; --green-bg: #25503b; --dark-bg: #404c66; --amber-bg: #53432a; --purple-bg: #45396f;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; background: var(--bg); color: var(--text); }
h1, h2, h3 { margin: 0 0 .5rem; line-height: 1.25; }
h1 { font-size: 1.35rem; } h2 { font-size: 1.15rem; } h3 { font-size: 1rem; }
a { color: var(--primary); }
.muted { color: var(--muted); } .small { font-size: .85rem; } .tiny { font-size: .75rem; }
.right { margin-left: auto; } .hidden { display: none !important; }
.row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.col { display: flex; flex-direction: column; gap: .6rem; }
.grow { flex: 1 1 auto; min-width: 0; }

/* ---- boot / login ---- */
.boot { min-height: 100vh; display: grid; place-content: center; text-align: center; gap: .5rem; }
.boot-logo, .logo { width: 56px; height: 56px; border-radius: 16px; display: grid; place-items: center; font-weight: 800; font-size: 28px; color: #fff; background: linear-gradient(135deg, #3b82f6, #1d4ed8); margin: 0 auto; }
.boot-ver, .ver { color: var(--muted); font-size: .8rem; }
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.login-card { width: min(400px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 1.6rem; box-shadow: var(--shadow); }
.login-card h1 { text-align: center; font-size: 1.6rem; margin-top: .6rem; }
.login-foot { text-align: center; margin-top: 1rem; }

/* ---- controles ---- */
label.f { display: flex; flex-direction: column; gap: .25rem; font-size: .85rem; color: var(--muted); }
input, select, textarea, button { font: inherit; color: inherit; }
input[type=text], input[type=password], input[type=email], input[type=date], input[type=number], select, textarea {
  width: 100%; padding: .55rem .7rem; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); color: var(--text); min-height: 40px;
}
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
textarea.autogrow { overflow: hidden; resize: none; min-height: 90px; }
.btn { border: 1px solid var(--border); background: var(--surface); padding: .5rem .9rem; border-radius: 10px; cursor: pointer; min-height: 40px; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--primary); color: var(--on-primary); border-color: var(--primary); font-weight: 600; }
.btn.primary:hover { background: var(--primary-h); }
.btn.danger { color: var(--danger); border-color: var(--danger); }
.btn.sm { min-height: 32px; padding: .25rem .6rem; font-size: .85rem; }
.btn.icon { padding: .4rem .55rem; min-width: 40px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.err { color: var(--danger); font-size: .88rem; min-height: 1.2em; }
.ok { color: var(--green); font-size: .88rem; }

/* ---- shell ---- */
.topbar { position: sticky; top: 0; z-index: 30; background: var(--surface); border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: .5rem; padding: .5rem .8rem; padding-top: calc(.5rem + env(safe-area-inset-top)); }
.brand { display: flex; align-items: center; gap: .5rem; font-weight: 800; font-size: 1.1rem; }
.brand .logo { width: 32px; height: 32px; font-size: 17px; border-radius: 9px; margin: 0; }
.tabs { display: flex; gap: .2rem; overflow-x: auto; flex: 1; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { padding: .45rem .8rem; border-radius: 9px; border: 0; background: transparent; color: var(--muted); cursor: pointer; white-space: nowrap; font-weight: 600; }
.tab:hover { background: var(--surface-2); }
.tab.active { background: var(--primary-soft); color: var(--primary); }
main { padding: 1rem; max-width: 1500px; margin: 0 auto; padding-bottom: 6rem; }
.pagehead { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; margin-bottom: .8rem; }
.footer { text-align: center; padding: 1rem; color: var(--muted); font-size: .8rem; }

.fab { position: fixed; left: max(16px, env(safe-area-inset-left)); bottom: max(16px, env(safe-area-inset-bottom)); z-index: 40; background: var(--primary); color: var(--on-primary); border: 0; border-radius: 999px; padding: .85rem 1.4rem; font-weight: 800; font-size: 1.05rem; box-shadow: var(--shadow); cursor: pointer; }
.fab:hover { background: var(--primary-h); }

/* ---- sino ---- */
.bell-wrap { position: relative; }
.bell-count { position: absolute; top: -4px; right: -4px; min-width: 18px; height: 18px; border-radius: 9px; background: var(--danger); color: #fff; font-size: .7rem; display: grid; place-items: center; padding: 0 4px; font-weight: 700; }
.dropdown { position: absolute; right: 0; top: calc(100% + 6px); width: min(380px, 92vw); max-height: 70vh; overflow: auto; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow); z-index: 60; }
.dd-item { padding: .7rem .9rem; border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: .3rem; cursor: pointer; }
.dd-item:hover { background: var(--surface-2); }
.dd-item:last-child { border-bottom: 0; }
.dd-title { font-weight: 700; font-size: .9rem; }
.lvl { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: .4rem; background: var(--gray); }
.lvl.action { background: var(--primary); } .lvl.warn { background: var(--red); } .lvl.task { background: var(--amber); }

/* ---- cards / paineis ---- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 1rem; }
.card-head { display: flex; align-items: center; gap: .5rem; margin-bottom: .6rem; }
.card-head h3 { margin: 0; flex: 1; }
.card.min .card-body { display: none; }
.card.min .card-head { margin-bottom: 0; }
.grid { display: grid; gap: .8rem; grid-template-columns: repeat(12, 1fr); }
.span-3 { grid-column: span 3; } .span-4 { grid-column: span 4; } .span-6 { grid-column: span 6; } .span-8 { grid-column: span 8; } .span-12 { grid-column: span 12; }
@media (max-width: 900px) { .span-3, .span-4, .span-6, .span-8 { grid-column: span 12; } .span-3 { grid-column: span 6; } }
.kpi { font-size: 2rem; font-weight: 800; line-height: 1.1; }
.chart-host { position: relative; height: 280px; }
.chart-host.tall { height: 340px; }
.empty { color: var(--muted); text-align: center; padding: 2rem 1rem; }

/* ---- filtros ---- */
.filters { display: grid; gap: .6rem; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); align-items: end; }
.filters .wide { grid-column: span 2; }
.chips { display: flex; gap: .4rem; flex-wrap: wrap; margin: .6rem 0; }

/* ---- tabela ---- */
.table-wrap { overflow: auto; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); }
table { border-collapse: collapse; width: 100%; min-width: 980px; }
th, td { text-align: left; padding: .55rem .7rem; border-bottom: 1px solid var(--border); vertical-align: top; }
th { position: sticky; top: 0; background: var(--surface-2); font-size: .8rem; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; white-space: nowrap; cursor: pointer; user-select: none; }
tbody tr:hover { background: var(--surface-2); }
tr.clickable { cursor: pointer; }
td.desc { min-width: 260px; max-width: 420px; word-break: break-word; }
td.num, th.num { text-align: right; }

/* ---- badges / progresso ---- */
.badge { display: inline-block; padding: .15rem .6rem; border-radius: 999px; font-size: .78rem; font-weight: 700; white-space: nowrap; border: 0; }
.badge.btn-like { cursor: pointer; }
.badge.gray { background: var(--gray-bg); color: var(--gray); } .badge.blue { background: var(--blue-bg); color: var(--blue); }
.badge.red { background: var(--red-bg); color: var(--red); } .badge.green { background: var(--green-bg); color: var(--green); }
.badge.dark { background: var(--dark-bg); color: var(--dark); } .badge.amber { background: var(--amber-bg); color: var(--amber); }
.badge.purple { background: var(--purple-bg); color: var(--purple); }
.bar { height: 8px; background: var(--gray-bg); border-radius: 999px; overflow: hidden; min-width: 70px; }
.bar-fill { height: 100%; background: var(--primary); border-radius: 999px; transition: width .25s; }
.bar-fill.done { background: var(--green); }
.prog { display: flex; align-items: center; gap: .5rem; }
.prog .bar { flex: 1; } .prog span { font-size: .8rem; color: var(--muted); min-width: 2.6em; text-align: right; }

/* ---- modal ---- */
.overlay { position: fixed; inset: 0; background: rgba(5, 10, 20, .55); z-index: 100; display: flex; align-items: flex-start; justify-content: center; padding: 4vh 12px; overflow: auto; }
.modal { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; width: min(560px, 100%); box-shadow: var(--shadow); display: flex; flex-direction: column; margin-bottom: 4vh; }
.modal.wide { width: min(860px, 100%); }
.modal-head { display: flex; align-items: center; gap: .5rem; padding: 1rem 1.1rem .4rem; }
.modal-head h2 { margin: 0; flex: 1; }
.modal-body { padding: .5rem 1.1rem 1rem; display: flex; flex-direction: column; gap: .8rem; }
.modal-foot { padding: .8rem 1.1rem 1rem; display: flex; gap: .5rem; justify-content: flex-end; border-top: 1px solid var(--border); flex-wrap: wrap; }
.choices { display: grid; gap: .5rem; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.choice { text-align: left; border: 1px solid var(--border); background: var(--surface-2); border-radius: 12px; padding: .8rem; cursor: pointer; font-weight: 600; }
.choice:hover, .choice.sel { border-color: var(--primary); background: var(--primary-soft); }
.steps-dots { display: flex; gap: 4px; }
.steps-dots i { width: 22px; height: 4px; border-radius: 2px; background: var(--border); display: block; }
.steps-dots i.on { background: var(--primary); }
.stepitem { display: flex; gap: .6rem; align-items: flex-start; padding: .55rem .6rem; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); }
.stepitem.done .stext { text-decoration: line-through; color: var(--muted); }
.stepitem input[type=checkbox] { width: 20px; height: 20px; margin-top: 2px; }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: .3rem .8rem; font-size: .92rem; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; word-break: break-word; }

/* ---- toast ---- */
.toasts { position: fixed; right: 12px; bottom: 12px; z-index: 200; display: flex; flex-direction: column; gap: .5rem; max-width: min(360px, 92vw); }
.toast { background: var(--text); color: var(--bg); padding: .65rem .9rem; border-radius: 10px; box-shadow: var(--shadow); font-size: .9rem; }
.toast.err { background: var(--danger); color: #fff; }
.updating { position: fixed; inset: 0; z-index: 300; background: var(--bg); display: grid; place-content: center; text-align: center; gap: .6rem; }
.pw-box { font: 700 1.2rem/1.2 ui-monospace, Menlo, Consolas, monospace; background: var(--surface-2); border: 1px dashed var(--primary); border-radius: 10px; padding: .8rem; text-align: center; word-break: break-all; user-select: all; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.seg button { border: 0; background: var(--surface); padding: .4rem .8rem; cursor: pointer; }
.seg button.on { background: var(--primary); color: var(--on-primary); font-weight: 700; }
.warn-box { background: var(--danger-soft); border: 1px solid var(--danger); color: var(--text); padding: .7rem .9rem; border-radius: 10px; font-size: .9rem; }
.info-box { background: var(--primary-soft); border: 1px solid var(--primary); padding: .7rem .9rem; border-radius: 10px; font-size: .9rem; }
@media (max-width: 640px) { .topbar { flex-wrap: wrap; } .tabs { order: 5; flex-basis: 100%; } main { padding: .7rem; } .kv { grid-template-columns: 1fr; } .filters .wide { grid-column: span 1; } }
@media print { .topbar, .fab, .toasts { display: none; } }

/* ---- extras ---- */
.pre { white-space: pre-wrap; word-break: break-word; }
.badge-x { border: 0; background: transparent; color: inherit; cursor: pointer; padding: 0 0 0 .2rem; font-size: .8rem; }
.contents { display: contents; }

@media (max-width: 760px) { .hidden-sm { display: none; } }
