:root {
  --primary: #0e3a4a; --primary-soft: #e3f0f2;
  --bg: #f4f6fb; --card: #fff; --text: #111827; --muted: #6b7280; --border: #e5e7eb;
  --ok: #16a34a; --warn: #d97706; --err: #dc2626; --info: #2563eb;
  --radius: 16px; --shadow: 0 1px 2px rgba(16,24,40,.04), 0 4px 16px rgba(16,24,40,.06);
  --bottom-nav: 0px;
}
[hidden] { display: none !important; }
main.bare { max-width: none; padding: 0; }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-font-smoothing: antialiased; }
h1 { font-size: 1.3rem; margin: 0 0 6px; letter-spacing: -.01em; } h2 { font-size: 1.05rem; margin: 20px 0 10px; } h3 { font-size: .98rem; margin: 16px 0 8px; }
h1 + .muted, h1 + p { margin-top: 0; }
a { color: var(--primary); }
svg.i { width: 20px; height: 20px; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- topo ---------- */
#topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 16px; padding: 10px 24px; background: rgba(255,255,255,.88); backdrop-filter: saturate(180%) blur(12px); -webkit-backdrop-filter: saturate(180%) blur(12px); border-bottom: 1px solid var(--border); color: var(--text); }
#topbar .brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.02rem; white-space: nowrap; }
#topbar .brand::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--primary); box-shadow: 0 0 0 4px var(--primary-soft); }
#topbar .brand:has(img:not([hidden]))::before { display: none; }
#topbar img { height: 32px; border-radius: 8px; }
#nav { display: flex; gap: 4px; flex: 1; }
#nav a { display: flex; align-items: center; gap: 8px; color: var(--muted); text-decoration: none; padding: 8px 12px; border-radius: 10px; font-size: .92rem; font-weight: 500; }
#nav a:hover { background: #f3f4f6; color: var(--text); }
#nav a.active { background: var(--primary-soft); color: var(--primary); }
#topbar .user { display: flex; align-items: center; gap: 10px; font-size: .9rem; color: var(--muted); }
#topbar .avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--primary); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: .85rem; }
#logout { display: flex; align-items: center; gap: 6px; padding: 8px 10px; color: var(--muted); border-color: var(--border); }

main { max-width: 1180px; margin: 0 auto; padding: 24px 24px calc(32px + var(--bottom-nav)); }

/* ---------- blocos ---------- */
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin-bottom: 16px; box-shadow: var(--shadow); }
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); margin-bottom: 16px; }
.grid .card { margin: 0; display: flex; flex-direction: column; gap: 4px; }
.stat { font-size: 1.75rem; font-weight: 750; letter-spacing: -.02em; }
.stat-icon { width: 40px; height: 40px; border-radius: 12px; background: var(--primary-soft); color: var(--primary); display: grid; place-items: center; margin-bottom: 6px; }
.muted { color: var(--muted); font-size: .88rem; }

/* ---------- botões e formulários ---------- */
button, .btn { background: var(--primary); color: #fff; border: 1px solid transparent; border-radius: 12px; padding: 11px 18px; min-height: 44px; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 6px; transition: transform .05s, filter .15s, background .15s; }
button:hover { filter: brightness(1.06); }
button:active { transform: scale(.98); }
button.ghost, .btn.ghost { background: transparent; border-color: var(--border); color: var(--text); }
button.secondary, .btn.secondary { background: var(--primary-soft); color: var(--primary); }
button.danger { background: var(--err); }
button:disabled { opacity: .55; cursor: wait; }
button.small, .btn.small { padding: 6px 12px; min-height: 34px; font-size: .84rem; border-radius: 10px; }
form.f { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); align-items: end; }
form.f .full { grid-column: 1 / -1; }
form.f > div:last-child { grid-column: 1 / -1; }
label { display: grid; gap: 6px; font-size: .84rem; font-weight: 500; color: #374151; }
label.check { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 12px; border: 1px solid var(--border); border-radius: 12px; background: #fafafa; }
input, select, textarea { font: inherit; font-size: 16px; padding: 10px 12px; min-height: 44px; border: 1px solid #d1d5db; border-radius: 12px; background: #fff; color: var(--text); width: 100%; transition: border-color .15s, box-shadow .15s; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-soft); }
input[type=color] { padding: 4px; height: 44px; cursor: pointer; }
input[type=color]::-webkit-color-swatch-wrapper { padding: 0; } input[type=color]::-webkit-color-swatch { border: 0; border-radius: 8px; }
label.check input { width: 20px; height: 20px; min-height: 0; accent-color: var(--primary); }
textarea { min-height: 80px; }

/* formulários recolhíveis */
details.fold { border: 1px dashed #cbd5e1; border-radius: 14px; margin: 14px 0; background: #fcfcfd; }
details.fold > summary { list-style: none; cursor: pointer; padding: 14px 16px; font-weight: 600; display: flex; align-items: center; gap: 10px; color: var(--primary); min-height: 48px; }
details.fold > summary::-webkit-details-marker { display: none; }
details.fold > summary::before { content: "+"; width: 26px; height: 26px; border-radius: 8px; background: var(--primary-soft); display: grid; place-items: center; font-size: 1.1rem; transition: transform .2s; }
details.fold[open] > summary::before { content: "−"; }
details.fold[open] { border-style: solid; background: #fff; }
details.fold > form, details.fold > div { padding: 0 16px 16px; }

/* ---------- tabelas ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--border); border-radius: 12px; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: 11px 12px; border-bottom: 1px solid #f1f5f9; vertical-align: top; }
tr:last-child td { border-bottom: 0; }
th { background: #f8fafc; color: var(--muted); font-weight: 600; font-size: .76rem; text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; }
tbody tr:hover { background: #fafbff; }
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 999px; font-size: .76rem; font-weight: 600; background: var(--primary-soft); color: var(--primary); margin: 2px 2px 2px 0; }
.badge button.small { min-height: 22px; padding: 0 6px; border-radius: 6px; background: transparent; color: inherit; border: 0; }
.badge.ok { background: #dcfce7; color: #15803d; } .badge.warn { background: #fef3c7; color: #b45309; } .badge.err { background: #fee2e2; color: #b91c1c; }
.issue { padding: 10px 14px; border-left: 4px solid var(--info); background: #eff6ff; margin: 8px 0; border-radius: 10px; font-size: .9rem; }
.issue.erro { border-color: var(--err); background: #fef2f2; } .issue.alerta { border-color: var(--warn); background: #fffbeb; }
.issue ul { margin: 6px 0 0; padding-left: 18px; }

/* ---------- abas ---------- */
.tabs { display: flex; flex-wrap: wrap; gap: 6px; overflow-x: auto; scrollbar-width: none; margin: 0 -4px 18px; padding: 4px; scroll-snap-type: x proximity; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a { flex: none; scroll-snap-align: start; padding: 8px 14px; border-radius: 999px; background: var(--card); border: 1px solid var(--border); text-decoration: none; color: #374151; font-size: .88rem; font-weight: 500; white-space: nowrap; }
.tabs a.active { background: var(--primary); color: #fff; border-color: var(--primary); box-shadow: 0 4px 12px color-mix(in srgb, var(--primary) 30%, transparent); }

.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.notice { display: flex; gap: 10px; background: #fffbeb; border: 1px solid #fde68a; color: #78350f; border-radius: 12px; padding: 12px 14px; font-size: .88rem; margin-bottom: 16px; }

/* ---------- login ---------- */
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: radial-gradient(1200px 600px at 10% -10%, var(--primary-soft), transparent), radial-gradient(900px 500px at 110% 110%, #ede9fe, transparent), var(--bg); }
.login { width: 100%; max-width: 420px; }
.login .card { padding: 28px; box-shadow: 0 10px 40px rgba(16,24,40,.12); }
.login .logo { width: 52px; height: 52px; border-radius: 16px; background: var(--primary); color: #fff; display: grid; place-items: center; margin-bottom: 14px; }
.login .logo svg.i { width: 28px; height: 28px; }
.login form.f { grid-template-columns: 1fr; }
.login button[type=submit] { width: 100%; }

#toast { position: fixed; left: 50%; bottom: calc(24px + var(--bottom-nav)); transform: translate(-50%, 10px); background: #111827; color: #fff; padding: 12px 18px; border-radius: 12px; opacity: 0; transition: opacity .2s, transform .2s; pointer-events: none; max-width: calc(100% - 32px); z-index: 60; box-shadow: 0 10px 30px rgba(0,0,0,.2); }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.err { background: var(--err); }

/* ---------- celular ---------- */
@media (max-width: 760px) {
  :root { --bottom-nav: 68px; }
  main { padding: 16px 16px calc(24px + var(--bottom-nav)); }
  #topbar { padding: 10px 16px; gap: 10px; background: #fff; backdrop-filter: none; -webkit-backdrop-filter: none; }
  .tabs { flex-wrap: nowrap; }
  #topbar .user { margin-left: auto; }
  #topbar .user > span:not(.avatar) { display: none; }
  #logout span { display: none; }
  #nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; justify-content: space-around; gap: 0; padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); background: rgba(255,255,255,.96); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-top: 1px solid var(--border); }
  #nav a { flex: 1; flex-direction: column; gap: 2px; padding: 6px 2px; font-size: .68rem; border-radius: 12px; text-align: center; min-width: 0; }
  #nav a span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
  #nav a.active { background: transparent; }
  #nav a.active svg.i { background: var(--primary-soft); border-radius: 10px; padding: 3px; width: 34px; height: 26px; }
  .card { padding: 16px; border-radius: 14px; }
  .grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat { font-size: 1.4rem; }
  form.f { grid-template-columns: 1fr; }
  form.f button[type=submit] { width: 100%; }
  .days-editor .d { grid-template-columns: 1fr 1fr; padding: 10px; border: 1px solid var(--border); border-radius: 12px; }
  .days-editor .d > span:first-child { font-weight: 600; }
  .days-editor .d > input { grid-column: 1 / -1; order: 3; }
  /* tabelas viram lista de cartões */
  .table-wrap.cards { border: 0; overflow: visible; }
  .cards table, .cards thead, .cards tbody, .cards tr, .cards td { display: block; width: 100%; }
  .cards thead { display: none; }
  .cards tbody tr { background: #fff; border: 1px solid var(--border); border-radius: 14px; padding: 8px 12px; margin-bottom: 10px; }
  .cards tbody tr:hover { background: #fff; }
  .cards td { display: grid; grid-template-columns: 38% 1fr; gap: 10px; padding: 7px 0; border-bottom: 1px solid #f1f5f9; overflow-wrap: anywhere; }
  .cards td::before { content: attr(data-label); color: var(--muted); font-size: .78rem; font-weight: 600; }
  .cards td[data-label=""] { grid-template-columns: 1fr; } .cards td[data-label=""]::before { display: none; }
  .cards td:empty { display: none; }
  .cards tr td:last-child { border-bottom: 0; }
  .cards td:first-child { font-weight: 600; }
  .jdias .d { grid-template-columns: 1fr 1fr; }
  .jdias .d .dn { grid-column: 1 / -1; }
  .acting { font-size: .8rem; }
}

/* ---------- Gestão de Jornadas ---------- */
.acting { display: flex; align-items: center; justify-content: center; gap: 12px; flex-wrap: wrap; background: #fef3c7; color: #78350f; padding: 8px 16px; font-size: .88rem; border-bottom: 1px solid #fde68a; }
.acting button { min-height: 32px; padding: 4px 12px; font-size: .82rem; }
.head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.head h1 { margin: 0; }
.secret { background: #f0fdf4; border: 1px solid #bbf7d0; border-radius: 14px; padding: 16px; margin: 12px 0; }
.secret code { font-size: 1.15rem; font-weight: 700; background: #fff; padding: 4px 10px; border-radius: 8px; border: 1px dashed #86efac; user-select: all; }
.secret dl { display: grid; grid-template-columns: auto 1fr; gap: 8px 14px; align-items: center; margin: 10px 0; }
.secret dt { color: var(--muted); font-size: .85rem; }
.secret dd { margin: 0; }
.muted.small { font-size: .8rem; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
input[readonly] { background: #f3f4f6; color: var(--muted); }

/* modelos de jornada */
.modelos { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); margin: 10px 0 4px; }
.modelo { text-align: left; display: block; background: #fff; color: var(--text); border: 1px solid var(--border); border-radius: 14px; padding: 12px 14px; min-height: 0; font-weight: 400; }
.modelo:hover { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); filter: none; }
.modelo strong { display: block; color: var(--primary); margin-bottom: 2px; }
.modelo span { font-size: .8rem; color: var(--muted); }

.jcard { display: grid; gap: 6px; }
.jcard .top { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; flex-wrap: wrap; }
.jcard h3 { margin: 0; }
.jcard .big { font-size: 1.5rem; font-weight: 750; color: var(--primary); }
.semana { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin-top: 4px; }
.semana div { background: var(--primary-soft); border-radius: 8px; padding: 6px 4px; text-align: center; font-size: .74rem; line-height: 1.3; }
.semana div b { display: block; font-size: .72rem; color: var(--primary); }
.semana div.folga { background: #ecfdf5; color: #047857; }

/* editor de dias */
.jdias { display: grid; gap: 6px; margin: 8px 0; }
.jdias .d { display: grid; grid-template-columns: 130px repeat(4, minmax(86px, 1fr)) 70px; gap: 8px; align-items: center; padding: 8px 10px; border: 1px solid var(--border); border-radius: 12px; background: #fff; }
.jdias .d.off { background: #f8fafc; }
.jdias .d.off input[type=time] { opacity: .35; }
.jdias .d .dn { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.jdias .d .dn input { width: 20px; height: 20px; min-height: 0; accent-color: var(--primary); }
.jdias .d .tot { font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }
.jdias .hdr { display: grid; grid-template-columns: 130px repeat(4, minmax(86px, 1fr)) 70px; gap: 8px; padding: 0 10px; font-size: .74rem; color: var(--muted); text-transform: uppercase; font-weight: 600; }
input[type=time] { padding: 8px 8px; min-height: 40px; }
.analise { position: sticky; bottom: 10px; background: #fff; border: 1px solid var(--border); border-radius: 14px; padding: 12px 14px; box-shadow: var(--shadow); margin-top: 12px; }
.analise .tot { font-size: 1.3rem; font-weight: 750; }

/* escala */
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: end; margin-bottom: 12px; }
.toolbar label { min-width: 150px; }
.pincel { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.pincel button { min-height: 36px; padding: 6px 12px; border-radius: 10px; background: #fff; color: var(--text); border: 1px solid var(--border); font-weight: 600; }
.pincel button.on { background: var(--primary); color: #fff; border-color: var(--primary); }
.grade-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 12px; background: #fff; }
table.grade { border-collapse: separate; border-spacing: 0; font-size: .8rem; width: max-content; min-width: 100%; }
table.grade th, table.grade td { padding: 0; border-bottom: 1px solid #eef2f7; border-right: 1px solid #f1f5f9; text-align: center; }
table.grade th { padding: 6px 2px; font-size: .7rem; line-height: 1.2; min-width: 30px; text-transform: none; letter-spacing: 0; }
table.grade th.dom, table.grade td.dom { background: #eef2f7; }
table.grade th.fer, table.grade td.fer { background: #fde7c7; }
table.grade .nome { position: sticky; left: 0; z-index: 2; background: #fff; text-align: left; padding: 6px 10px; min-width: 190px; max-width: 220px; border-right: 1px solid var(--border); }
table.grade th.nome { background: #f8fafc; }
table.grade .nome small { display: block; color: var(--muted); font-weight: 400; font-size: .72rem; }
table.grade td.c { cursor: pointer; width: 32px; height: 36px; font-weight: 600; color: #94a3b8; user-select: none; }
table.grade td.c:hover { outline: 2px solid var(--primary); outline-offset: -2px; }
table.grade td.c.m { color: #111827; }
table.grade td.c.F, table.grade td.c.DSR, table.grade td.c.FN { color: #047857; }
table.grade td.c.m.F, table.grade td.c.m.DSR, table.grade td.c.m.FN { background: #d1fae5; }
table.grade td.c.m.FE, table.grade td.c.m.AT { background: #fee2e2; color: #b91c1c; }
table.grade td.c.m.T, table.grade td.c.m.FER { background: #dbeafe; color: #1d4ed8; }
table.grade td.c.T { color: #64748b; }
.legenda { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: .8rem; color: var(--muted); margin-top: 10px; }
.legenda b { color: var(--text); }

/* documentos */
.docs { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.docs .card { display: flex; flex-direction: column; gap: 10px; margin: 0; }
.docs .card h3 { margin: 0; display: flex; gap: 10px; align-items: center; }
.docs .card p { margin: 0; }
.docs .card .row { margin-top: auto; }
.thumb { width: 44px; height: 44px; border-radius: 12px; background: var(--primary-soft); color: var(--primary); display: grid; place-items: center; flex: none; }
.pick { max-height: 180px; overflow: auto; border: 1px solid var(--border); border-radius: 12px; padding: 6px 10px; }
.pick label { display: flex; align-items: center; gap: 8px; font-weight: 400; padding: 3px 0; }
.pick input { width: 18px; height: 18px; min-height: 0; }
.sel-all { font-size: .8rem; }

@media (max-width: 760px) {
  .jdias .hdr { display: none; }
  .jdias .d { grid-template-columns: 1fr 1fr; }
  .jdias .d .dn { grid-column: 1 / -1; }
  .jdias .d .tot { grid-column: 1 / -1; text-align: left; }
  .semana div { font-size: .64rem; padding: 4px 2px; }
}

@media (max-width: 760px) {
  .pincel button { min-height: 32px; padding: 4px 9px; font-size: .78rem; }
  table.grade .nome { min-width: 118px; max-width: 130px; padding: 6px 8px; }
  .head .row { width: 100%; }
}

.eq { display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 4px; background: #12232e; color: #fff; font-size: .7rem; font-weight: 700; margin-right: 6px; vertical-align: 1px; }
.card.destaque { border-color: color-mix(in srgb, var(--primary) 35%, transparent); background: linear-gradient(180deg, var(--primary-soft), #fff 70%); }
.card.destaque h3 { margin: 0 0 6px; display: flex; gap: 10px; align-items: center; }
.card.destaque .toolbar { margin: 12px 0 0; align-items: end; }
table.grade th:nth-child(7n+7):not(.nome) { }
table.grade td.c.F, table.grade td.c.DSR, table.grade td.c.FN { color: #0e3a4a; background: #e3f7f2; }
table.grade td.c.m.F, table.grade td.c.m.DSR, table.grade td.c.m.FN { background: #c9f2e9; }
table.grade th.sab { background: #b42318; color: #fff; }
