:root {
  --font: "Hanken Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif;
  --fs-xs: 12px;
  --fs-sm: 13px;
  --fs-md: 14px;
  --fs-lg: 16px;
  --fs-xl: 20px;
  --fs-2xl: 24px;

  --s1: 4px;
  --s2: 8px;
  --s3: 12px;
  --s4: 16px;
  --s5: 24px;
  --s6: 32px;
  --s7: 48px;

  --radius: 6px;
  --radius-sm: 4px;

  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #16202e;
  --text-2: #4b5565;
  --text-3: #6b7383;
  --line: #e3e6eb;
  --line-strong: #cfd4dc;
  --hover: #f1f3f6;

  --primary: #0b3fa8;
  --primary-hover: #0a3590;
  --primary-soft: #e8eefb;
  --on-primary: #ffffff;

  --danger: #b42318;
  --danger-soft: #fdecea;
  --warning: #8a5300;
  --warning-soft: #fff4e0;
  --success: #1f7a4d;
  --success-soft: #e6f4ec;

  --t-m: #e3ecfb;
  --t-m-text: #0b3f8f;
  --t-t: #ece7fb;
  --t-t-text: #4b2c9c;
  --t-i: #e1f3f1;
  --t-i-text: #0f5e55;
  --t-n: #eceef2;
  --t-n-text: #2d3644;

  --sidebar-w: 232px;
  --control-h: 36px;
  --focus: 0 0 0 3px rgba(11, 63, 168, 0.25);
  --shadow-overlay: 0 12px 32px rgba(16, 24, 40, 0.18);
  --dur: 120ms;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  font-size: var(--fs-md);
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: var(--fs-2xl); font-weight: 600; letter-spacing: -0.01em; line-height: 1.25; }
h2 { font-size: var(--fs-lg); font-weight: 600; line-height: 1.3; }
h3 { font-size: var(--fs-md); font-weight: 600; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: var(--radius-sm); }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--text-2); }
.small { font-size: var(--fs-sm); }
.num { font-variant-numeric: tabular-nums; }

.app { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column;
  background: var(--surface); border-right: 1px solid var(--line);
  padding: var(--s5) var(--s3);
}
.brand { display: flex; align-items: center; gap: var(--s2); padding: 0 var(--s3) var(--s5); font-weight: 700; font-size: var(--fs-lg); color: var(--text); letter-spacing: 0.02em; }
.brand:hover { text-decoration: none; }
.brand-mark { width: 28px; height: 28px; border-radius: var(--radius); background: var(--primary); color: var(--on-primary); display: grid; place-items: center; font-size: var(--fs-sm); font-weight: 700; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { display: block; padding: var(--s2) var(--s3); border-radius: var(--radius); color: var(--text-2); font-weight: 500; }
.nav a:hover { background: var(--hover); color: var(--text); text-decoration: none; }
.nav a[aria-current="page"] { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.sidebar-foot { margin-top: auto; padding: var(--s4) var(--s3) 0; border-top: 1px solid var(--line); font-size: var(--fs-sm); }
.sidebar-foot .who { font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-foot a { color: var(--text-2); }
.sidebar .menu-toggle { display: none; }

.main { min-width: 0; }
.page { max-width: 1440px; padding: var(--s6) var(--s6) var(--s7); }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s4); flex-wrap: wrap; }
.page-head p { margin-top: var(--s1); color: var(--text-2); }
.actions { display: flex; gap: var(--s2); flex-wrap: wrap; align-items: center; }
.toolbar { display: flex; gap: var(--s2); flex-wrap: wrap; align-items: center; margin-top: var(--s5); padding-bottom: var(--s4); border-bottom: 1px solid var(--line); }
.toolbar .spacer { flex: 1; }
.section { margin-top: var(--s6); }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s3); margin-bottom: var(--s3); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  height: var(--control-h); padding: 0 var(--s4);
  border: 1px solid var(--line-strong); border-radius: var(--radius);
  background: var(--surface); color: var(--text);
  font: inherit; font-size: var(--fs-sm); font-weight: 600; cursor: pointer; white-space: nowrap;
  transition: background var(--dur), border-color var(--dur);
}
.btn:hover { background: var(--hover); text-decoration: none; }
.btn:disabled { opacity: 0.55; cursor: progress; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--hover); color: var(--text); }
.btn-danger { border-color: transparent; background: transparent; color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); }
.btn-sm { height: 30px; padding: 0 var(--s3); }
.btn-icon { width: var(--control-h); padding: 0; }

.field { display: flex; flex-direction: column; gap: var(--s1); min-width: 0; }
.field > span { font-size: var(--fs-sm); font-weight: 600; color: var(--text-2); }
.field small { color: var(--text-3); font-size: var(--fs-xs); }
.input, .select, textarea.input {
  height: var(--control-h); width: 100%; padding: 0 var(--s3);
  border: 1px solid var(--line-strong); border-radius: var(--radius);
  background: var(--surface); color: var(--text); font: inherit; font-size: var(--fs-md);
}
textarea.input { height: auto; min-height: 72px; padding: var(--s2) var(--s3); }
.select { padding-right: var(--s6); appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%234b5565' stroke-width='1.5'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; }
.input:focus, .select:focus { outline: none; border-color: var(--primary); box-shadow: var(--focus); }
.toolbar .select, .toolbar .input { width: auto; min-width: 160px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: var(--s4); }
.check { display: inline-flex; align-items: center; gap: var(--s2); font-size: var(--fs-sm); }

.field .segmented { align-self: flex-start; }
.segmented { display: inline-flex; border: 1px solid var(--line-strong); border-radius: var(--radius); overflow: hidden; }
.segmented a, .segmented button { padding: 0 var(--s4); height: calc(var(--control-h) - 2px); display: inline-flex; align-items: center; color: var(--text-2); font-weight: 600; font-size: var(--fs-sm); border: 0; background: transparent; cursor: pointer; font-family: inherit; }
.segmented a + a, .segmented button + button { border-left: 1px solid var(--line-strong); }
.segmented a:hover, .segmented button:hover { background: var(--hover); text-decoration: none; }
.segmented [aria-current="true"] { background: var(--primary-soft); color: var(--primary); }

.period { display: inline-flex; align-items: center; gap: var(--s1); font-weight: 600; }
.period .label { min-width: 150px; text-align: center; }
.period .btn-icon { font-size: 20px; line-height: 1; }

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.table th { text-align: left; font-weight: 600; color: var(--text-2); padding: var(--s2) var(--s3); border-bottom: 1px solid var(--line-strong); white-space: nowrap; }
.table td { padding: var(--s3); border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:hover td { background: #fafbfc; }
.table .right { text-align: right; }
.row-actions { display: flex; gap: var(--s1); justify-content: flex-end; }

.notice { display: flex; gap: var(--s3); align-items: baseline; padding: var(--s3) 0; border-bottom: 1px solid var(--line); font-size: var(--fs-sm); }
.notice strong { font-weight: 600; }
.notice.warn { color: var(--warning); }
.notice.danger { color: var(--danger); }
.notice.ok { color: var(--success); }
.notice-list { margin: 0; padding: 0; list-style: none; }
.notice-list li { padding: var(--s1) 0; }

.empty { padding: var(--s7) 0; text-align: center; color: var(--text-2); }
.empty h2 { color: var(--text); margin-bottom: var(--s2); }
.empty .btn { margin-top: var(--s4); }

.tag { display: inline-block; padding: 1px var(--s2); border-radius: var(--radius-sm); font-size: var(--fs-xs); font-weight: 600; background: var(--t-n); color: var(--t-n-text); }
.tag.ok { background: var(--success-soft); color: var(--success); }
.tag.warn { background: var(--warning-soft); color: var(--warning); }
.tag.off { background: var(--t-n); color: var(--text-3); }

.stats { display: flex; gap: var(--s6); flex-wrap: wrap; margin-top: var(--s5); }
.stat .value { font-size: var(--fs-2xl); font-weight: 600; line-height: 1.2; }
.stat .label { color: var(--text-2); font-size: var(--fs-sm); }
.stat a.label:hover { color: var(--primary); }

.grid-scale { width: 100%; border-collapse: separate; border-spacing: 0; font-size: var(--fs-xs); table-layout: fixed; }
.grid-scale th, .grid-scale td { border-bottom: 1px solid var(--line); text-align: center; padding: 3px 2px; }
.grid-scale thead th { position: sticky; top: 0; background: var(--bg); z-index: 1; font-weight: 600; color: var(--text-2); padding: var(--s2) 2px; line-height: 1.25; }
.grid-scale thead th.today { color: var(--primary); }
.grid-scale thead th.gap { box-shadow: inset 0 -3px 0 var(--warning); }
.grid-scale th.name, .grid-scale td.name { text-align: left; position: sticky; left: 0; background: var(--bg); z-index: 2; padding-left: 0; padding-right: var(--s3); }
.grid-scale td.name .who { font-size: var(--fs-sm); font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.grid-scale td.name .role { color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.grid-scale tr.group td { text-align: left; padding: var(--s4) 0 var(--s1); font-size: var(--fs-xs); font-weight: 600; color: var(--text-2); text-transform: uppercase; letter-spacing: 0.04em; border-bottom: 1px solid var(--line-strong); }
.grid-scale .we { background: rgba(16, 24, 40, 0.025); }
.grid-scale td.total { color: var(--text-2); font-variant-numeric: tabular-nums; }
.cell {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 34px; width: 100%; border: 0; border-radius: var(--radius-sm);
  font: inherit; font-weight: 600; cursor: pointer; background: transparent; color: var(--text-3);
  line-height: 1.15;
}
.cell small { font-weight: 500; font-size: 10px; opacity: 0.85; }
.cell:hover { outline: 1px solid var(--line-strong); }
.cell.c0 { background: var(--t-m); color: var(--t-m-text); }
.cell.c1 { background: var(--t-t); color: var(--t-t-text); }
.cell.c2 { background: var(--t-i); color: var(--t-i-text); }
.cell.c3 { background: var(--t-n); color: var(--t-n-text); }
.cell.folga { color: var(--text-3); font-weight: 500; }
.cell.manual { box-shadow: inset 0 -2px 0 currentColor; }
.cell.alert { outline: 2px solid var(--warning); outline-offset: -2px; }
.cell[disabled] { cursor: default; }
.legend { display: flex; gap: var(--s4); flex-wrap: wrap; font-size: var(--fs-xs); color: var(--text-2); margin-top: var(--s3); }
.legend .sw { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: var(--s1); vertical-align: -1px; }

dialog.panel { border: 0; padding: 0; border-radius: var(--radius); box-shadow: var(--shadow-overlay); width: min(560px, calc(100vw - 32px)); color: var(--text); }
dialog.panel::backdrop { background: rgba(16, 24, 40, 0.35); }
dialog.panel form { display: flex; flex-direction: column; }
.panel-head { display: flex; justify-content: space-between; align-items: center; padding: var(--s4) var(--s5); border-bottom: 1px solid var(--line); }
.panel-body { padding: var(--s5); display: flex; flex-direction: column; gap: var(--s4); max-height: 70vh; overflow-y: auto; }
.panel-foot { display: flex; justify-content: space-between; gap: var(--s2); padding: var(--s3) var(--s5); border-top: 1px solid var(--line); }
.panel-foot .actions { margin-left: auto; }
.form-error { color: var(--danger); font-size: var(--fs-sm); }

.toast { position: fixed; bottom: var(--s5); right: var(--s5); background: var(--text); color: #fff; padding: var(--s3) var(--s4); border-radius: var(--radius); font-size: var(--fs-sm); box-shadow: var(--shadow-overlay); z-index: 100; }
.toast.error { background: var(--danger); }

.auth { min-height: 100vh; display: grid; place-items: center; padding: var(--s5); }
.auth-box { width: min(380px, 100%); }
.auth-box .brand { padding: 0 0 var(--s6); }
.auth-box h1 { font-size: var(--fs-xl); margin-bottom: var(--s1); }
.auth-box form { display: flex; flex-direction: column; gap: var(--s4); margin-top: var(--s5); }
.auth-box .btn { width: 100%; }
.auth-foot { margin-top: var(--s5); font-size: var(--fs-sm); color: var(--text-2); }

@media (max-width: 960px) {
  .app { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: var(--s3) var(--s4); border-right: 0; border-bottom: 1px solid var(--line); }
  .brand { padding: 0; }
  .sidebar .menu-toggle { display: inline-flex; margin-left: auto; }
  .nav, .sidebar-foot { display: none; width: 100%; }
  .sidebar.open .nav, .sidebar.open .sidebar-foot { display: flex; }
  .sidebar.open .nav { margin-top: var(--s3); }
  .sidebar-foot { flex-direction: column; gap: var(--s1); margin-top: var(--s3); }
  .page { padding: var(--s5) var(--s4) var(--s6); }
  h1 { font-size: var(--fs-xl); }
  .toolbar .select, .toolbar .input { min-width: 0; flex: 1 1 140px; }
}

@media print {
  .sidebar, .no-print, .toolbar .btn, .page-head .actions { display: none !important; }
  .app { display: block; }
  .page { padding: 0; max-width: none; }
  body { background: #fff; }
  .grid-scale th.name, .grid-scale td.name, .grid-scale thead th { background: #fff; }
  .cell { min-height: 0; padding: 2px 0; }
}

.cell.prevista { opacity: 0.5; }
.cell.vazia { color: var(--text-3); }
.name-btn { background: none; border: 0; padding: 0; font: inherit; text-align: left; cursor: pointer; width: 100%; color: inherit; }
.name-btn:hover .who { color: var(--primary); text-decoration: underline; }
.opts { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: var(--s2); }
.opt { display: flex; align-items: center; gap: var(--s2); padding: var(--s2) var(--s3); border: 1px solid var(--line); border-radius: var(--radius); cursor: pointer; font-size: var(--fs-sm); }
.opt:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }
.opt input { margin: 0; }
.seq { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: var(--s2); }
.seq label span { font-size: var(--fs-xs); }
.swatch.cell, .legend .sw.cell { min-height: 0; cursor: default; }
.swatch { display: inline-block; width: 22px; height: 22px; border-radius: var(--radius-sm); text-align: center; line-height: 22px; font-size: var(--fs-xs); font-weight: 700; }
.list-plain { list-style: none; margin: 0; padding: 0; }
.list-plain li { display: flex; justify-content: space-between; align-items: center; gap: var(--s3); padding: var(--s2) 0; border-bottom: 1px solid var(--line); font-size: var(--fs-sm); }
details.more summary { cursor: pointer; color: var(--text-2); font-size: var(--fs-sm); padding: var(--s1) 0; }
.toast[hidden] { display: none; }

.cell.ausencia { background: var(--warning-soft); color: var(--warning); }
.dias-modelo { grid-template-columns: repeat(auto-fill, minmax(116px, 1fr)); }
.dia-cel { display: flex; flex-direction: column; gap: var(--s1); min-width: 0; }
.dia-cel .small { font-weight: 600; color: var(--text-2); }
.dia-cel .select { padding-right: var(--s5); font-size: var(--fs-sm); }
.dia-cel .horas { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
.dia-cel .horas .input { height: 30px; padding: 0 4px; font-size: var(--fs-xs); min-width: 0; width: 100%; }
.dia-cel .horas .input::-webkit-calendar-picker-indicator { display: none; }
.semana-titulo { grid-column: 1 / -1; margin-top: var(--s2); font-size: var(--fs-sm); color: var(--text-2); }

.padrao { border: 1px solid var(--line); border-radius: var(--radius); padding: var(--s3) var(--s4); margin: 0; display: flex; flex-direction: column; gap: var(--s3); background: var(--bg); }
.padrao legend { font-size: var(--fs-sm); font-weight: 600; color: var(--text-2); padding: 0 var(--s1); }
.padrao-campos { display: flex; flex-wrap: wrap; gap: var(--s3); align-items: flex-end; }
.padrao-campos .field { min-width: 120px; flex: 1 1 140px; }
.padrao-campos [data-p="nm"] { flex: 0 1 90px; min-width: 80px; }
.padrao-horas { max-width: 280px; }

.tabs { display: flex; gap: var(--s5); margin-top: var(--s5); border-bottom: 1px solid var(--line); overflow-x: auto; overflow-y: hidden; }
.tabs [role="tab"] { background: none; border: 0; border-bottom: 2px solid transparent; margin-bottom: -1px; padding: var(--s3) 0; font: inherit; font-weight: 600; color: var(--text-2); cursor: pointer; white-space: nowrap; }
.tabs [role="tab"]:hover { color: var(--text); }
.tabs [role="tab"][aria-selected="true"] { color: var(--primary); border-bottom-color: var(--primary); }
.tab-count { display: inline-block; min-width: 20px; padding: 0 6px; margin-left: var(--s1); border-radius: 10px; background: var(--t-n); color: var(--text-2); font-size: var(--fs-xs); text-align: center; }
.tabs [aria-selected="true"] .tab-count { background: var(--primary-soft); color: var(--primary); }
.tab-panel.section { margin-top: var(--s5); }

.loja-bloco { padding: var(--s5) 0; border-bottom: 1px solid var(--line); }
.loja-bloco:last-child { border-bottom: 0; }
.loja-titulo { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); margin-bottom: var(--s3); flex-wrap: wrap; }
.loja-bloco .check { display: flex; padding: 2px 0; }
.curva td.num, .curva th.num { text-align: center; padding: var(--s2) 2px; min-width: 38px; }
.curva td[data-h] { background: color-mix(in srgb, var(--primary) calc(var(--i, 0) * 55%), transparent); }
.curva.editando td[data-h] { background: none; }
.curva td[data-h] .input { height: 28px; padding: 0 2px; text-align: center; font-size: var(--fs-xs); min-width: 34px; }
#previa-mov { flex-direction: column; align-items: flex-start; gap: var(--s2); }
.cob { margin-top: var(--s5); }
.cob-dias { display: flex; gap: var(--s1); flex-wrap: wrap; margin-bottom: var(--s3); }
.cob-dias button { border: 1px solid var(--line-strong); background: var(--surface); border-radius: var(--radius); padding: 2px var(--s2); font: inherit; font-size: var(--fs-xs); cursor: pointer; }
.cob-dias button[aria-pressed="true"] { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }
.cob-dias button.ruim { box-shadow: inset 0 -2px 0 var(--danger); }
.cob-dias button.atencao { box-shadow: inset 0 -2px 0 var(--warning); }
.cob-tab td, .cob-tab th { text-align: center; padding: 4px 2px; font-size: var(--fs-xs); min-width: 34px; }
.cob-tab th:first-child, .cob-tab td:first-child { text-align: left; min-width: 110px; }
.cob-tab td.ok { color: var(--success); }
.cob-tab td.falta { background: var(--danger-soft); color: var(--danger); font-weight: 600; }
.cob-tab td.sobra { background: var(--warning-soft); color: var(--warning); }
.resumo-prob { display: flex; gap: var(--s4); flex-wrap: wrap; font-size: var(--fs-sm); padding: var(--s3) 0; border-bottom: 1px solid var(--line); }
.resumo-prob a { color: inherit; }
.resumo-prob .ruim { color: var(--danger); font-weight: 600; }
.resumo-prob .atencao { color: var(--warning); font-weight: 600; }
.replicar { margin-top: var(--s3); padding: var(--s2) var(--s3); background: var(--primary-soft); border-radius: var(--radius); font-size: var(--fs-sm); max-width: 640px; }
.replicar[hidden] { display: none; }
.perm-tab td, .perm-tab th { text-align: center; }
.perm-tab td:first-child, .perm-tab th:first-child { text-align: left; }
.perm-tab .na { color: var(--text-3); }
.user-name { font-weight: 600; }
.user-login { color: var(--text-3); font-size: var(--fs-xs); }
@media (max-width: 720px) {
  .lista-usuarios thead { display: none; }
  .lista-usuarios tr { display: grid; grid-template-columns: 1fr auto; column-gap: var(--s3); padding: var(--s3) 0; border-bottom: 1px solid var(--line); }
  .lista-usuarios td { border: 0; padding: 2px 0; }
  .lista-usuarios .c-situacao { grid-column: 2; grid-row: 1; }
  .lista-usuarios .c-email, .lista-usuarios .c-perfil, .lista-usuarios .c-acoes { grid-column: 1 / -1; color: var(--text-2); }
  .lista-usuarios .row-actions { justify-content: flex-start; margin-left: calc(-1 * var(--s3)); }
  .lista-usuarios tbody tr:hover td { background: none; }
}
.curva .fora { display: none; }
.curva td.fechada { background: var(--t-n); }
.curva td.fechada > * { visibility: hidden; }
