/* TF7 Gestão: tokens e componentes compartilhados.
   Identidade Twenty Four Seven: claro, editorial, preto + vermelho de identidade só como acento.
   Sem modo escuro (decisão da marca). Guia em /assets/README-design.md. */

:root {
  color-scheme: light;
  --canvas: #f4f4f2;
  --card: #ffffff;
  --ink: #111111;
  --ink-2: #4a4a48;
  --muted: #8e8e8b;
  --line: #e3e3e0;
  --line-2: #d2d2ce;
  --track: #ecece9;
  --hover: #f8f8f6;
  --accent: #b51c2a;
  --accent-soft: #f6e6e8;
  --ok: #2f7d4f;
  --ok-soft: #e5f1ea;
  --warn: #a8680f;
  --warn-soft: #f8efdc;
  --crit: #d30c1f;
  --crit-soft: #fbe7e9;
  --radius: 2px;
  --font: 'Montserrat', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  --shadow: 0 1px 2px rgba(17, 17, 17, .04), 0 8px 24px rgba(17, 17, 17, .06);
  --shadow-pop: 0 2px 6px rgba(17, 17, 17, .06), 0 18px 48px rgba(17, 17, 17, .14);
  --topbar-h: 64px;
  --ease: cubic-bezier(.2, .7, .2, 1);
  --sat: env(safe-area-inset-top, 0px);
  --sar: env(safe-area-inset-right, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; min-height: 100dvh;
  background: var(--canvas); color: var(--ink);
  font-family: var(--font); font-size: 15px; line-height: 1.55;
  -webkit-font-smoothing: antialiased; overflow-x: hidden;
}
h1, h2, h3, h4, p, ul, ol, figure { margin: 0; }
ul, ol { padding: 0; list-style: none; }
img { display: block; max-width: 100%; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sr-only {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.num { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--mono); font-size: .92em; }
.muted { color: var(--muted); }
.ink-2 { color: var(--ink-2); }
.skip {
  position: absolute; left: 12px; top: -60px; z-index: 100; background: var(--ink); color: #fff;
  padding: 10px 14px; border-radius: var(--radius); text-decoration: none; font-size: 14px;
}
.skip:focus { top: calc(8px + var(--sat)); }

/* ---------- Tipografia ---------- */
.eyebrow {
  font-size: 11px; font-weight: 600; letter-spacing: .2em; text-transform: uppercase; color: var(--muted);
}
.title-caps {
  font-weight: 300; letter-spacing: .18em; text-transform: uppercase; font-size: 15px; line-height: 1.3;
}
.page-title { font-size: 26px; font-weight: 300; letter-spacing: -.005em; line-height: 1.2; }
.page-lead { color: var(--ink-2); font-size: 14px; max-width: 64ch; }
@media (min-width: 720px) { .page-title { font-size: 30px; } }

/* ---------- Botões ---------- */
.btn {
  --h: 44px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--h); padding: 0 18px; border-radius: var(--radius);
  border: 1px solid var(--ink); background: var(--ink); color: #fff;
  font-size: 13px; font-weight: 600; letter-spacing: .06em; text-decoration: none; white-space: nowrap;
  transition: background-color .15s var(--ease), border-color .15s var(--ease), color .15s var(--ease);
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { background: var(--accent); border-color: var(--accent); }
.btn:active { transform: translateY(1px); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .45; cursor: not-allowed; pointer-events: none; }
.btn svg { width: 18px; height: 18px; flex: none; }
.btn-ghost { background: var(--card); color: var(--ink); border-color: var(--line-2); }
.btn-ghost:hover { background: var(--card); color: var(--accent); border-color: var(--ink); }
.btn-text {
  background: none; border-color: transparent; color: var(--ink-2); padding: 0 10px;
}
.btn-text:hover { background: var(--hover); border-color: transparent; color: var(--ink); }
.btn-danger { background: var(--card); color: var(--crit); border-color: var(--crit); }
.btn-danger:hover { background: var(--crit); border-color: var(--crit); color: #fff; }
.btn-danger.solid { background: var(--crit); color: #fff; }
.btn-danger.solid:hover { background: #a90918; border-color: #a90918; }
.btn-sm { --h: 36px; padding: 0 12px; font-size: 12px; }
.btn-block { width: 100%; }
.btn.is-busy { position: relative; color: transparent !important; pointer-events: none; }
.btn.is-busy::after {
  content: ''; position: absolute; width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, .35); border-top-color: #fff; animation: spin .7s linear infinite;
}
.btn-ghost.is-busy::after, .btn-text.is-busy::after { border-color: var(--line); border-top-color: var(--ink); }
.icon-btn {
  display: inline-grid; place-items: center; width: 44px; height: 44px; flex: none;
  border: 1px solid transparent; background: none; border-radius: var(--radius); color: var(--ink-2);
}
.icon-btn:hover { background: var(--hover); color: var(--ink); }
.icon-btn svg { width: 20px; height: 20px; }
.link-btn {
  background: none; border: 0; padding: 0; color: var(--ink); text-decoration: underline;
  text-underline-offset: 3px; font-size: inherit; min-height: 44px;
}
.link-btn:hover { color: var(--accent); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Formulários ---------- */
.field { display: grid; gap: 6px; min-width: 0; }
.field > label, .field-label {
  font-size: 11px; font-weight: 600; letter-spacing: .16em; text-transform: uppercase; color: var(--ink-2);
}
.fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
.fieldset > legend { padding: 0; margin-bottom: 6px; }
.field .hint { font-size: 12.5px; color: var(--muted); line-height: 1.45; }
.input, .select, .textarea {
  width: 100%; min-height: 48px; padding: 0 14px; border: 1px solid var(--line-2); border-radius: var(--radius);
  background: var(--card); font-size: 16px; color: var(--ink); appearance: none; -webkit-appearance: none;
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
.textarea { padding: 12px 14px; min-height: 88px; resize: vertical; line-height: 1.45; }
.select {
  padding-right: 40px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%23111' stroke-width='1.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center;
}
.input::placeholder, .textarea::placeholder { color: #a9a9a6; }
.input:hover, .select:hover, .textarea:hover { border-color: var(--muted); }
.input:focus, .select:focus, .textarea:focus { border-color: var(--ink); box-shadow: 0 0 0 3px var(--accent-soft); outline: none; }
.input[readonly] { background: var(--canvas); color: var(--ink-2); }
.input[aria-invalid="true"], .select[aria-invalid="true"] { border-color: var(--crit); }
.input-wrap { position: relative; }
.input-wrap .input { padding-right: 52px; }
.input-wrap .pw-toggle { position: absolute; right: 2px; top: 50%; transform: translateY(-50%); }
.input-icon { position: relative; }
.input-icon > svg { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--muted); pointer-events: none; }
.input-icon .input { padding-left: 42px; }
.form-grid { display: grid; gap: 18px; }
.form-error {
  display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--radius);
  background: var(--crit-soft); color: #8f0613; font-size: 14px; line-height: 1.45;
}
.form-error svg { width: 18px; height: 18px; flex: none; margin-top: 1px; color: var(--crit); }
.form-error:empty { display: none; }
.field-error { font-size: 13px; color: var(--crit); }
.field-error:empty { display: none; }

/* Caixas de seleção e rádios */
.check {
  display: flex; gap: 12px; align-items: flex-start; min-height: 44px; padding: 10px 0; cursor: pointer;
  font-size: 14px; line-height: 1.4;
}
.check input {
  appearance: none; -webkit-appearance: none; flex: none; width: 20px; height: 20px; margin: 0;
  border: 1.5px solid var(--ink-2); border-radius: var(--radius); background: var(--card); cursor: pointer;
  display: grid; place-items: center; transition: background-color .12s, border-color .12s;
}
.check input[type="radio"] { border-radius: 50%; }
.check input::after { content: ''; width: 10px; height: 6px; border: 2px solid #fff; border-top: 0; border-right: 0; transform: rotate(-45deg) translate(1px, -1px); opacity: 0; }
.check input[type="radio"]::after { width: 8px; height: 8px; border: 0; border-radius: 50%; background: #fff; transform: none; }
.check input:checked, .check input:indeterminate { background: var(--ink); border-color: var(--ink); }
.check input:checked::after { opacity: 1; }
.check input:indeterminate::after { opacity: 1; width: 10px; height: 0; border-left: 0; border-bottom: 2px solid #fff; transform: none; }
.check input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.check input:disabled { cursor: not-allowed; opacity: .55; }
.check:has(input:disabled) { cursor: default; }
.check .check-text { display: grid; gap: 1px; }
.check small { color: var(--muted); font-size: 12px; }

/* Interruptor (liberar / retirar) */
.switch {
  display: inline-flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 4px; border: 0; background: none;
  font-size: 13px; font-weight: 500; color: var(--ink-2); -webkit-tap-highlight-color: transparent; text-align: left;
}
.switch .track {
  position: relative; width: 40px; height: 22px; flex: none; border-radius: 11px; background: var(--line-2);
  transition: background-color .18s var(--ease);
}
.switch .track::after {
  content: ''; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .25); transition: transform .18s var(--ease);
}
.switch[aria-checked="true"] { color: var(--ink); }
.switch[aria-checked="true"] .track { background: var(--ink); }
.switch[aria-checked="true"] .track::after { transform: translateX(18px); }
.switch:hover .track { box-shadow: 0 0 0 4px var(--track); }
.switch[aria-busy="true"] { pointer-events: none; }
.switch[aria-busy="true"] .track::after { animation: pulse .8s ease-in-out infinite alternate; }
.switch[disabled] { cursor: not-allowed; opacity: .55; }
.switch:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--radius); }
@keyframes pulse { from { opacity: 1; } to { opacity: .35; } }

/* Controle segmentado */
.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: var(--radius); background: var(--card); padding: 2px; gap: 2px; }
.seg button {
  min-height: 40px; padding: 0 14px; border: 0; background: none; border-radius: 1px;
  font-size: 12px; font-weight: 600; letter-spacing: .08em; color: var(--ink-2); white-space: nowrap;
}
.seg button:hover { color: var(--ink); background: var(--hover); }
.seg button[aria-pressed="true"], .seg button[aria-selected="true"] { background: var(--ink); color: #fff; }

/* ---------- Superfícies ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); min-width: 0; }
.card-pad { padding: 20px; }
@media (min-width: 720px) { .card-pad { padding: 24px; } }
.divider { height: 1px; background: var(--line); border: 0; margin: 0; }
.rule-accent { width: 32px; height: 2px; background: var(--accent); border: 0; margin: 0; }

/* Chips, etiquetas, status */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; min-height: 26px; padding: 2px 10px;
  border: 1px solid var(--line-2); border-radius: var(--radius); background: var(--card);
  font-size: 12px; font-weight: 500; color: var(--ink-2); white-space: nowrap; line-height: 1.3;
}
.chip.solid { background: var(--ink); border-color: var(--ink); color: #fff; }
.chip.accent { background: var(--accent-soft); border-color: transparent; color: var(--accent); }
.chip.ghost { border-style: dashed; color: var(--muted); }
.tag {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 8px; border-radius: var(--radius);
  font-size: 10.5px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; white-space: nowrap;
  background: var(--track); color: var(--ink-2);
}
.tag.accent { background: var(--accent-soft); color: var(--accent); }
.tag svg { width: 12px; height: 12px; }
.status { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 500; white-space: nowrap; }
.status::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: currentColor; flex: none; }
.status.ok { color: var(--ok); }
.status.off { color: var(--muted); }
.status.warn { color: var(--warn); }
.status.crit { color: var(--crit); }

/* Avisos (semáforo sempre com ícone + rótulo) */
.notice {
  display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: var(--radius);
  font-size: 14px; line-height: 1.5; background: var(--track); color: var(--ink);
}
.notice > svg { width: 20px; height: 20px; flex: none; margin-top: 1px; }
.notice strong { font-weight: 600; }
.notice.warn { background: var(--warn-soft); }
.notice.warn > svg { color: var(--warn); }
.notice.crit { background: var(--crit-soft); }
.notice.crit > svg { color: var(--crit); }
.notice.ok { background: var(--ok-soft); }
.notice.ok > svg { color: var(--ok); }
.notice.info > svg { color: var(--ink-2); }

/* Avatar */
.avatar {
  display: inline-grid; place-items: center; width: 34px; height: 34px; flex: none; border-radius: 50%;
  background: var(--ink); color: #fff; font-size: 12px; font-weight: 600; letter-spacing: .04em;
}
.avatar.lg { width: 44px; height: 44px; font-size: 14px; }
.avatar.soft { background: var(--track); color: var(--ink); }

/* ---------- Topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30; background: rgba(255, 255, 255, .96);
  border-bottom: 1px solid var(--line); padding-top: var(--sat);
  -webkit-backdrop-filter: saturate(1.4) blur(8px); backdrop-filter: saturate(1.4) blur(8px);
}
.topbar-in {
  display: flex; align-items: center; gap: 8px; height: var(--topbar-h);
  max-width: 1280px; margin: 0 auto; padding: 0 max(12px, var(--sar)) 0 max(12px, var(--sal));
}
@media (min-width: 720px) { .topbar-in { padding-inline: 24px; gap: 16px; } }
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; min-height: 44px; flex: none; }
.brand img { width: 62px; height: 62px; margin: -4px -4px; mix-blend-mode: multiply; }
.brand-sep { width: 1px; height: 26px; background: var(--line-2); }
.brand-name { font-weight: 300; font-size: 13px; letter-spacing: .26em; text-transform: uppercase; }
.back-link {
  display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 10px 0 6px;
  text-decoration: none; font-size: 13px; font-weight: 500; color: var(--ink-2); border-radius: var(--radius);
}
.back-link:hover { color: var(--accent); background: var(--hover); }
.back-link svg { width: 18px; height: 18px; }
.topbar .spacer { flex: 1; }
@media (max-width: 520px) {
  .topbar.has-back .brand-sep, .topbar.has-back .brand-name { display: none; }
  .brand img { width: 56px; height: 56px; }
}

/* Menu da conta */
.account { position: relative; }
.account-btn {
  display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 4px 8px 4px 4px;
  border: 1px solid transparent; border-radius: var(--radius); background: none; text-align: left;
}
.account-btn:hover, .account-btn[aria-expanded="true"] { background: var(--hover); border-color: var(--line); }
.account-btn .who { display: grid; line-height: 1.25; }
.account-btn .who b { font-size: 13px; font-weight: 600; max-width: 22ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-btn .who small { font-size: 11.5px; color: var(--muted); }
.account-btn > svg { width: 16px; height: 16px; color: var(--muted); }
@media (max-width: 640px) { .account-btn .who, .account-btn > svg { display: none; } .account-btn { padding: 4px; } }
.menu {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 40; min-width: 260px; max-width: calc(100vw - 24px);
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-pop);
  padding: 6px; animation: pop .14s var(--ease);
}
.menu-head { padding: 12px 12px 12px; border-bottom: 1px solid var(--line); margin-bottom: 6px; display: grid; gap: 2px; }
.menu-head b { font-size: 14px; font-weight: 600; }
.menu-head span { font-size: 12.5px; color: var(--muted); word-break: break-all; }
.menu-head .tag { justify-self: start; margin-top: 6px; }
.menu-item {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 44px; padding: 0 12px;
  border: 0; background: none; border-radius: var(--radius); font-size: 14px; text-align: left; text-decoration: none; color: var(--ink);
}
.menu-item svg { width: 18px; height: 18px; color: var(--ink-2); }
.menu-item:hover, .menu-item:focus-visible { background: var(--hover); outline: none; }
.menu-item:focus-visible { box-shadow: inset 0 0 0 2px var(--accent); }
.menu-item.danger { color: var(--crit); }
.menu-item.danger svg { color: var(--crit); }
.menu-sep { height: 1px; background: var(--line); margin: 6px 0; }
@keyframes pop { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }

/* ---------- Layouts ---------- */
.wrap { max-width: 1280px; margin: 0 auto; padding: 0 max(16px, var(--sar)) 0 max(16px, var(--sal)); }
@media (min-width: 720px) { .wrap { padding-inline: 24px; } }
.page { padding-top: 28px; padding-bottom: calc(64px + var(--sab)); display: grid; gap: 28px; }
@media (min-width: 720px) { .page { padding-top: 40px; gap: 36px; } }
.page-head { display: flex; flex-wrap: wrap; gap: 16px 24px; align-items: flex-end; justify-content: space-between; }
.page-head > div { display: grid; gap: 8px; min-width: 0; }
.section { display: grid; gap: 16px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.section-head h2 { font-weight: 300; letter-spacing: .18em; text-transform: uppercase; font-size: 14px; }
.section-head .count { font-size: 12px; color: var(--muted); }

/* Administração: navegação lateral (desktop) / abas (celular) */
.admin-shell { max-width: 1280px; margin: 0 auto; }
@media (min-width: 1000px) {
  .admin-shell { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 0 40px; padding: 0 24px; }
  .admin-shell > main .wrap { padding-inline: 0; }
  .admin-shell > main .boot { min-height: 60vh; }
}
.adminnav { border-bottom: 1px solid var(--line); background: var(--card); position: sticky; top: calc(var(--topbar-h) + var(--sat)); z-index: 20; }
.adminnav-label { display: none; }
.adminnav ul { display: flex; gap: 0; overflow-x: auto; scrollbar-width: none; padding: 0 max(8px, var(--sal)); }
.adminnav ul::-webkit-scrollbar { display: none; }
.adminnav a {
  display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 0 14px; white-space: nowrap;
  text-decoration: none; font-size: 12px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-2);
  border-bottom: 2px solid transparent;
}
.adminnav a svg { width: 18px; height: 18px; display: none; }
.adminnav a:hover { color: var(--ink); }
.adminnav a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--accent); }
@media (min-width: 1000px) {
  .adminnav { background: none; border: 0; position: sticky; top: calc(var(--topbar-h) + var(--sat) + 40px); align-self: start; margin-top: 40px; }
  .adminnav-label { display: block; margin: 0 0 12px 12px; }
  .adminnav ul { display: grid; gap: 2px; padding: 0; overflow: visible; }
  .adminnav a {
    border-bottom: 0; border-left: 2px solid transparent; min-height: 44px; padding: 0 12px;
    letter-spacing: .12em; border-radius: 0 var(--radius) var(--radius) 0;
  }
  .adminnav a svg { display: block; color: var(--muted); }
  .adminnav a:hover { background: var(--card); }
  .adminnav a[aria-current="page"] { border-left-color: var(--accent); background: var(--card); }
  .adminnav a[aria-current="page"] svg { color: var(--ink); }
}

/* Barra de ferramentas (busca + filtros) */
.toolbar { display: grid; gap: 10px; }
.toolbar .filters { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.toolbar .filters .field.wide { grid-column: 1 / -1; }
@media (min-width: 720px) {
  .toolbar { grid-template-columns: minmax(220px, 1fr) auto; align-items: end; }
  .toolbar .filters { display: flex; flex-wrap: wrap; }
  .toolbar .filters .field { width: 170px; }
}
.toolbar .select, .toolbar .input { min-height: 44px; }
.result-line { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; font-size: 13px; color: var(--muted); min-height: 32px; }
.result-line .link-btn { min-height: 32px; font-size: 13px; color: var(--ink-2); }

/* ---------- Tabela responsiva (vira cartões no celular) ---------- */
.table-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.rtable { width: 100%; border-collapse: collapse; font-size: 14px; }
.rtable th {
  text-align: left; font-size: 10.5px; font-weight: 600; letter-spacing: .16em; text-transform: uppercase; color: var(--muted);
  padding: 14px 16px; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--card);
}
.rtable td { padding: 14px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.rtable tbody tr:last-child td { border-bottom: 0; }
.rtable tbody tr:hover td { background: var(--hover); }
.rtable tr.is-off td { color: var(--muted); }
.rtable .th-sort {
  display: inline-flex; align-items: center; gap: 6px; border: 0; background: none; padding: 0; min-height: 32px;
  font: inherit; letter-spacing: inherit; text-transform: inherit; color: inherit;
}
.rtable .th-sort:hover { color: var(--ink); }
.rtable .th-sort svg { width: 12px; height: 12px; opacity: .35; }
.rtable th[aria-sort] .th-sort { color: var(--ink); }
.rtable th[aria-sort] .th-sort svg { opacity: 1; }
.rtable th[aria-sort="descending"] .th-sort svg { transform: rotate(180deg); }
.rtable .cell-actions { text-align: right; white-space: nowrap; width: 1%; }
.cell-person { display: flex; align-items: center; gap: 12px; min-width: 0; }
.cell-person > div { display: grid; min-width: 0; }
.cell-person b { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; }
.cell-person span { font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; }
.row-day td {
  background: var(--canvas) !important; padding: 10px 16px; font-size: 11px; font-weight: 600; letter-spacing: .16em;
  text-transform: uppercase; color: var(--ink-2);
}
@media (max-width: 759px) {
  .table-card { background: none; border: 0; }
  .rtable, .rtable tbody, .rtable tr, .rtable td { display: block; width: 100%; }
  .rtable thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .rtable tbody { display: grid; gap: 10px; }
  .rtable tr { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 6px 16px; }
  .rtable tbody tr:hover td { background: none; }
  .rtable td { border: 0; padding: 8px 0; display: grid; grid-template-columns: 110px minmax(0, 1fr); gap: 12px; align-items: center; }
  .rtable td::before {
    content: attr(data-label); font-size: 10.5px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--muted);
  }
  .rtable td.td-main { grid-template-columns: 1fr; padding-top: 10px; }
  .rtable td.td-main::before, .rtable td.cell-actions::before { display: none; }
  .rtable td + td { border-top: 1px solid var(--track); }
  .rtable .cell-actions { width: 100%; text-align: left; display: flex; gap: 8px; flex-wrap: wrap; padding: 10px 0; }
  .rtable .cell-actions .btn { flex: 1; }
  .rtable tr.row-day { background: none; border: 0; padding: 8px 2px 0; }
  .rtable .row-day td { display: block; background: none !important; padding: 0; }
  .rtable .row-day td::before { display: none; }
}

/* ---------- Estados: carregando, vazio, erro ---------- */
.skeleton { display: grid; gap: 10px; }
.sk {
  height: 14px; border-radius: var(--radius);
  background: linear-gradient(90deg, var(--track) 0%, #f6f6f4 40%, var(--track) 80%); background-size: 200% 100%;
  animation: shimmer 1.3s linear infinite;
}
.sk.lg { height: 22px; width: 50%; }
.sk.block { height: 120px; }
.sk.w90 { width: 90%; } .sk.w75 { width: 75%; } .sk.w70 { width: 70%; } .sk.w60 { width: 60%; }
.sk-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; display: grid; gap: 12px; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.empty {
  display: grid; justify-items: center; text-align: center; gap: 12px; padding: 48px 24px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
}
.empty .empty-mark { width: 56px; height: 56px; display: grid; place-items: center; border: 1px solid var(--line-2); border-radius: 50%; color: var(--ink-2); margin-bottom: 4px; }
.empty .empty-mark svg { width: 24px; height: 24px; }
.empty h3 { font-weight: 300; font-size: 14px; letter-spacing: .18em; text-transform: uppercase; }
.empty p { color: var(--ink-2); font-size: 14px; max-width: 46ch; }
.empty .btn { margin-top: 8px; }
.empty.error .empty-mark { border-color: var(--crit-soft); background: var(--crit-soft); color: var(--crit); }
.empty.compact { padding: 28px 20px; }

/* ---------- Diálogos ---------- */
dialog.modal {
  width: min(560px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); padding: 0; border: 0; border-radius: var(--radius);
  background: var(--card); color: var(--ink); box-shadow: var(--shadow-pop); overflow: hidden;
}
dialog.modal[open] { display: flex; flex-direction: column; animation: dlg-in .2s var(--ease); }
dialog.modal.wide { width: min(820px, calc(100vw - 24px)); }
dialog.modal::backdrop { background: rgba(17, 17, 17, .38); animation: fade .2s var(--ease); }
.modal form, .modal .modal-inner { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.modal-head { display: flex; align-items: flex-start; gap: 12px; padding: 22px 22px 14px; border-bottom: 1px solid var(--line); }
.modal-head > div { display: grid; gap: 4px; flex: 1; min-width: 0; }
.modal-head h2 { font-weight: 300; font-size: 15px; letter-spacing: .18em; text-transform: uppercase; line-height: 1.35; }
.modal-head p { font-size: 13.5px; color: var(--ink-2); }
.modal-head .icon-btn { margin: -10px -10px 0 0; }
.modal-body { padding: 20px 22px; overflow-y: auto; display: grid; gap: 18px; align-content: start; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.modal-foot {
  display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap-reverse; padding: 14px 22px calc(14px + var(--sab));
  border-top: 1px solid var(--line); background: var(--card);
}
.modal-foot .foot-note { margin-right: auto; align-self: center; font-size: 12.5px; color: var(--muted); }
@media (max-width: 600px) {
  dialog.modal, dialog.modal.wide {
    width: 100vw; max-width: 100vw; max-height: 94dvh; margin: auto 0 0; border-radius: 6px 6px 0 0;
  }
  dialog.modal[open] { animation: sheet-in .26s var(--ease); }
  .modal-foot .btn { flex: 1; }
  .modal-foot .foot-note { flex-basis: 100%; }
}
dialog.modal.confirm { width: min(440px, calc(100vw - 24px)); }
@media (max-width: 600px) { dialog.modal.confirm { width: 100vw; } }
@keyframes dlg-in { from { opacity: 0; transform: translateY(8px) scale(.99); } to { opacity: 1; transform: none; } }
@keyframes sheet-in { from { transform: translateY(40px); opacity: .4; } to { transform: none; opacity: 1; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
body.has-modal { overflow: hidden; }

/* Senha temporária (mostrada uma vez) */
.secret {
  display: flex; align-items: center; gap: 8px; padding: 6px 6px 6px 16px; border: 1px dashed var(--ink-2);
  border-radius: var(--radius); background: var(--canvas);
}
.secret code { flex: 1; font-family: var(--mono); font-size: 20px; letter-spacing: .06em; word-break: break-all; user-select: all; -webkit-user-select: all; }

/* Regras de senha */
.rules { display: grid; gap: 6px; font-size: 13px; color: var(--muted); }
.rules li { display: flex; gap: 8px; align-items: center; }
.rules li svg { width: 16px; height: 16px; flex: none; }
.rules li .r-ok { display: none; }
.rules li.ok { color: var(--ok); }
.rules li.ok .r-ok { display: block; }
.rules li.ok .r-no { display: none; }
.meter { height: 3px; background: var(--track); border-radius: 2px; overflow: hidden; }
.meter i { display: block; height: 100%; width: 0; background: var(--ink); transition: width .2s var(--ease), background-color .2s; }

/* ---------- Toasts ---------- */
.toasts {
  position: fixed; z-index: 1000; left: 50%; transform: translateX(-50%); bottom: calc(16px + var(--sab));
  display: grid; gap: 8px; width: min(440px, calc(100vw - 24px)); pointer-events: none;
}
.toast {
  display: flex; align-items: flex-start; gap: 12px; padding: 14px 10px 14px 16px; border-radius: var(--radius);
  background: var(--ink); color: #fff; box-shadow: var(--shadow-pop); font-size: 14px; line-height: 1.45;
  pointer-events: auto; animation: toast-in .22s var(--ease);
}
.toast > svg { width: 18px; height: 18px; flex: none; margin-top: 1px; }
.toast.ok > svg { color: #8fd3aa; }
.toast.erro { background: #fff; color: var(--ink); border: 1px solid var(--crit); }
.toast.erro > svg { color: var(--crit); }
.toast.aviso > svg { color: #f1c27a; }
.toast p { flex: 1; }
.toast button { margin: -10px -2px -10px 0; color: inherit; opacity: .7; }
.toast button:hover { opacity: 1; background: rgba(255, 255, 255, .08); color: inherit; }
.toast.erro button:hover { background: var(--hover); }
.toast.saindo { opacity: 0; transform: translateY(6px); transition: opacity .2s, transform .2s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* Barra de progresso */
.progress { height: 4px; background: var(--track); border-radius: 2px; overflow: hidden; }
.progress i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s linear; }

/* Carregamento inicial da página */
.boot { min-height: calc(100dvh - var(--topbar-h)); display: grid; place-items: center; }
.boot .spinner { width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--line); border-top-color: var(--ink); animation: spin .8s linear infinite; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
  .sk { animation: none; }
}
