/* Retrôfit · Painel
   Claro: Cal.com (Refero) "Monochrome Utility": fundo Paper, cards brancos 12px com sombra difusa, ação em Ink, pílulas.
   Escuro: Cron Calendar (Refero) "obsidian void": canvas #0f0d0a, superfície #161412, texto #cccccc, títulos brancos, sem sombra.
   Layout: 21st App Dashboard Layout (sidebar + equipe + KPIs + gráfico + listas). */
:root {
  --bg: #f4f4f4; --card: #ffffff; --ink: #101010; --text: #242424; --muted: #6b7280; --stone: #898989; --line: #e5e7eb; --hover: #f4f4f4; --soft: #f4f4f4;
  --on-ink: #ffffff; --shadow: rgba(36,36,36,.05) 0 4px 8px 0; --shadow-h: rgba(36,36,36,.7) 0 1px 5px -4px, rgba(36,36,36,.05) 0 4px 8px 0;
  --font: 'Inter', system-ui, -apple-system, sans-serif; --ease: cubic-bezier(.2,.7,.2,1);
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0f0d0a; --card: #161412; --ink: #ffffff; --text: #ffffff; --muted: #cccccc; --stone: #8a8580; --line: #2a2723; --hover: #1d1a17; --soft: #1d1a17;
  --on-ink: #0f0d0a; --shadow: none; --shadow-h: 0 0 0 1px #2a2723; color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; touch-action: manipulation; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 14px; line-height: 1.45; letter-spacing: -0.2px; -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; }
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
input, select, textarea { font-size: 16px; } /* sem zoom no iOS */
button { cursor: pointer; background: none; border: 0; padding: 0; }
a { color: inherit; text-decoration: none; }
img { display: block; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
[hidden] { display: none !important; }

/* ---------- login ---------- */
.login { min-height: 100svh; display: grid; place-items: center; padding: 24px; }
.login-card { width: 100%; max-width: 380px; background: var(--card); border-radius: 12px; box-shadow: var(--shadow); padding: 32px 24px; }
.login-card img { width: 64px; height: 64px; border-radius: 12px; margin-bottom: 20px; }
.login-card h1 { font-size: 24px; font-weight: 600; letter-spacing: .24px; margin: 0 0 6px; }

/* ---------- shell ---------- */
.app { display: grid; grid-template-columns: 248px 1fr; min-height: 100svh; }
.side { position: sticky; top: 0; height: 100svh; display: flex; flex-direction: column; padding: 16px 12px; border-right: 1px solid var(--line); background: var(--card); overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 20px; font-weight: 600; font-size: 15px; }
.brand img { width: 32px; height: 32px; border-radius: 8px; }
.brand small { display: block; font-weight: 400; font-size: 12px; color: var(--muted); }
.navlist { display: grid; gap: 2px; }
.navlist button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 0 10px; height: 36px; border-radius: 8px; color: var(--muted); font-size: 14px; text-align: left; transition: background .15s var(--ease), color .15s var(--ease); }
.navlist button:hover { background: var(--hover); color: var(--text); }
.navlist button[aria-current="page"] { background: var(--hover); color: var(--text); font-weight: 500; }
.navlist .count { margin-left: auto; font-size: 12px; background: var(--ink); color: var(--on-ink); border-radius: 9999px; padding: 0 7px; line-height: 18px; }
.side-label { font-size: 12px; color: var(--stone); padding: 20px 10px 8px; }
.teamlist { display: grid; gap: 2px; }
.teamlist button { display: flex; align-items: center; gap: 10px; padding: 6px 10px; border-radius: 8px; font-size: 13px; text-align: left; width: 100%; }
.teamlist button:hover { background: var(--hover); }
.teamlist img { width: 24px; height: 24px; border-radius: 50%; object-fit: cover; }
.teamlist .st { margin-left: auto; font-size: 12px; color: var(--muted); }
.dot { width: 6px; height: 6px; border-radius: 50%; background: var(--ink); display: inline-block; }
.dot.off { background: var(--line); }
.side-foot { margin-top: auto; padding-top: 16px; display: grid; gap: 8px; }
.me { display: flex; align-items: center; gap: 10px; padding: 8px 10px; font-size: 13px; }
.me .av { width: 32px; height: 32px; border-radius: 50%; background: var(--ink); color: var(--on-ink); display: grid; place-items: center; font-weight: 600; font-size: 13px; }
.me small { display: block; color: var(--muted); font-size: 12px; }

.main { min-width: 0; }
.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px; height: 64px; padding: 0 24px; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.top h1 { font-size: 20px; font-weight: 600; letter-spacing: .2px; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top .sp { flex: 1; }
.iconbtn { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 8px; color: var(--muted); position: relative; flex: none; }
.iconbtn:hover { background: var(--hover); color: var(--text); }
.iconbtn .badge { position: absolute; top: 6px; right: 6px; width: 8px; height: 8px; border-radius: 50%; background: var(--ink); border: 2px solid var(--bg); }
.menu-btn { display: none; }
.content { padding: 24px; max-width: 1400px; display: grid; gap: 16px; }

/* ---------- botões ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 40px; padding: 0 18px; border-radius: 9999px; font-size: 14px; font-weight: 500; white-space: nowrap; transition: background .15s var(--ease), color .15s var(--ease), border-color .15s var(--ease); }
.btn-ink { background: var(--ink); color: var(--on-ink); }
.btn-ink:hover { opacity: .88; }
.btn-ghost { border: 1px solid var(--line); background: var(--card); color: var(--text); }
.btn-ghost:hover { background: var(--hover); }
.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; }
.btn-rect { border-radius: 8px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.link { text-decoration: underline; text-underline-offset: 3px; color: var(--muted); font-size: 13px; }
.link:hover { color: var(--text); }

/* segmentado / tags */
.seg { display: inline-flex; background: var(--card); border-radius: 9999px; padding: 3px; box-shadow: var(--shadow-h); gap: 2px; }
.seg button { height: 30px; padding: 0 12px; border-radius: 9999px; font-size: 13px; color: var(--muted); }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--on-ink); }
.tag { display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 9px; border-radius: 9999px; background: var(--soft); font-size: 12px; font-weight: 500; white-space: nowrap; }
.tag.ink { background: var(--ink); color: var(--on-ink); }
.tag.line { background: transparent; border: 1px solid var(--line); color: var(--muted); }
.tag.strike { text-decoration: line-through; color: var(--muted); }

/* ---------- cards ---------- */
.card { background: var(--card); border-radius: 12px; box-shadow: var(--shadow); padding: 20px; min-width: 0; }
:root[data-theme="dark"] .card { border: 1px solid var(--line); }
.card-h { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.card-h h2 { font-size: 16px; font-weight: 600; margin: 0; letter-spacing: -0.1px; }
.card-h p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.grid { display: grid; gap: 16px; }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g21 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.kpi .lbl { display: flex; justify-content: space-between; color: var(--text); font-size: 13px; font-weight: 500; }
.kpi .lbl svg { color: var(--muted); }
.kpi .val { font-size: 28px; font-weight: 600; letter-spacing: .3px; margin: 14px 0 4px; font-variant-numeric: tabular-nums; }
.kpi .delta { font-size: 12px; color: var(--muted); }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.toolbar .sp { flex: 1; }

/* gráfico */
.chart { width: 100%; height: 240px; display: block; }
.chart .ax { fill: var(--stone); font-size: 11px; }
.chart .gl { stroke: var(--line); }
.legend { display: flex; gap: 16px; font-size: 12px; color: var(--muted); margin-top: 8px; }
.legend i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; background: var(--ink); margin-right: 6px; }
.legend i.l { background: var(--stone); }
.tip { position: fixed; pointer-events: none; z-index: 90; background: var(--ink); color: var(--on-ink); font-size: 12px; padding: 6px 10px; border-radius: 8px; opacity: 0; transition: opacity .12s; white-space: nowrap; }

/* tabelas */
.tbl-wrap { overflow-x: auto; margin: 0 -20px; padding: 0 20px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; font-weight: 500; color: var(--muted); font-size: 12px; padding: 0 10px 10px; white-space: nowrap; }
td { padding: 11px 10px; border-top: 1px solid var(--line); white-space: nowrap; vertical-align: middle; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--hover); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.who { display: flex; align-items: center; gap: 10px; }
.who img, .who .av { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; flex: none; }
.who .av { background: var(--soft); display: grid; place-items: center; font-size: 11px; font-weight: 600; color: var(--muted); }
.who b { font-weight: 500; display: block; }
.who small { color: var(--muted); font-size: 12px; }
.bar-mini { height: 6px; border-radius: 9999px; background: var(--soft); overflow: hidden; min-width: 80px; }
.bar-mini i { display: block; height: 100%; background: var(--ink); border-radius: 9999px; }

/* listas */
.list { display: grid; }
.row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.row:first-child { border-top: 0; }
.row .time { font-variant-numeric: tabular-nums; font-weight: 500; width: 46px; flex: none; }
.row .grow { flex: 1; min-width: 0; }
.row .grow b { font-weight: 500; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .grow small { color: var(--muted); font-size: 12px; }
.empty { text-align: center; color: var(--muted); padding: 32px 12px; font-size: 13px; }

/* ---------- agenda ---------- */
.agenda { position: relative; overflow-x: auto; }
.ag-grid { display: grid; min-width: max-content; }
.ag-head { position: sticky; top: 0; z-index: 3; background: var(--card); display: flex; align-items: center; gap: 8px; padding: 10px 8px; border-bottom: 1px solid var(--line); font-size: 13px; font-weight: 500; }
.ag-head img { width: 26px; height: 26px; border-radius: 50%; object-fit: cover; }
.ag-head small { color: var(--muted); font-weight: 400; display: block; font-size: 11px; }
.ag-times { position: relative; border-right: 1px solid var(--line); }
.ag-times span { position: absolute; right: 8px; transform: translateY(-50%); font-size: 11px; color: var(--stone); font-variant-numeric: tabular-nums; }
.ag-col { position: relative; border-right: 1px solid var(--line); background-image: linear-gradient(var(--line) 1px, transparent 1px); background-size: 100% var(--hour); }
.ag-off { position: absolute; left: 0; right: 0; background: repeating-linear-gradient(135deg, transparent 0 6px, var(--line) 6px 7px); font-size: 11px; color: var(--stone); padding: 4px 8px; }
.ag-ev { position: absolute; left: 4px; right: 4px; border-radius: 8px; padding: 6px 8px; font-size: 12px; line-height: 1.3; overflow: hidden; text-align: left; background: var(--ink); color: var(--on-ink); transition: opacity .15s; }
.ag-ev:hover { opacity: .9; }
.ag-ev b { font-weight: 600; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ag-ev span { opacity: .75; }
.ag-ev.concluido { background: var(--soft); color: var(--text); box-shadow: inset 0 0 0 1px var(--line); }
.ag-ev.faltou, .ag-ev.cancelado { background: transparent; color: var(--muted); box-shadow: inset 0 0 0 1px var(--line); text-decoration: line-through; }
.ag-now { position: absolute; left: 0; right: 0; height: 0; border-top: 2px solid var(--ink); z-index: 2; pointer-events: none; }
.ag-now::before { content: ''; position: absolute; left: -4px; top: -5px; width: 8px; height: 8px; border-radius: 50%; background: var(--ink); }
.ag-free { position: absolute; left: 0; right: 0; z-index: 0; }
.ag-free:hover { background: var(--hover); }

/* ---------- gaveta e modal ---------- */
.scrim { position: fixed; inset: 0; background: rgba(16,16,16,.35); z-index: 70; opacity: 0; transition: opacity .25s var(--ease); }
.scrim.open { opacity: 1; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(520px, 100%); background: var(--card); z-index: 80; display: flex; flex-direction: column; transform: translateX(100%); transition: transform .3s var(--ease); box-shadow: rgba(0,0,0,.08) 0 0 24px; }
.drawer.open { transform: none; }
.dr-h { display: flex; align-items: center; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.dr-h h2 { font-size: 18px; font-weight: 600; margin: 0; flex: 1; letter-spacing: .1px; }
.dr-b { flex: 1; overflow-y: auto; padding: 20px; display: grid; gap: 20px; align-content: start; overscroll-behavior: contain; }
.dr-f { padding: 14px 20px calc(14px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.sec h3 { font-size: 13px; font-weight: 600; margin: 0 0 10px; color: var(--text); }
.kv { display: grid; grid-template-columns: 120px 1fr; gap: 8px 12px; font-size: 13px; }
.kv span { color: var(--muted); }

/* formulários */
.field { display: grid; gap: 6px; }
.field label { font-size: 13px; font-weight: 500; }
.input, select.input, textarea.input { height: 40px; width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 0 12px; background: var(--card); outline: none; transition: border-color .15s; }
textarea.input { height: auto; min-height: 84px; padding: 10px 12px; resize: vertical; }
.input:focus { border-color: var(--ink); }
.fgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.fgrid .full { grid-column: 1 / -1; }
.search { position: relative; }
.search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--stone); }
.search .input { padding-left: 36px; min-width: 240px; }
.switch { position: relative; width: 36px; height: 20px; flex: none; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; border-radius: 9999px; background: var(--line); transition: background .2s var(--ease); }
.switch span::after { content: ''; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .2s var(--ease); box-shadow: rgba(0,0,0,.15) 0 1px 2px; }
.switch input:checked + span { background: var(--ink); }
.switch input:checked + span::after { transform: translateX(16px); }
:root[data-theme="dark"] .switch input:checked + span::after { background: #0f0d0a; }
.sched { display: grid; gap: 6px; }
.sched-row { display: grid; grid-template-columns: 40px 64px 1fr 1fr 1fr 1fr; gap: 6px; align-items: center; font-size: 13px; }
.sched-row .input { height: 36px; padding: 0 6px; font-size: 16px; }
.sched-row.off .input { opacity: .35; }
.sched-h { font-size: 11px; color: var(--muted); }
.svc-row { display: grid; grid-template-columns: 24px 1fr 92px 84px; gap: 8px; align-items: center; padding: 6px 0; border-top: 1px solid var(--line); font-size: 13px; }
.svc-row .input { height: 34px; padding: 0 8px; }
.check { width: 18px; height: 18px; accent-color: var(--ink); }
.slotpick { display: grid; grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); gap: 6px; }
.slotpick button { height: 36px; border-radius: 8px; background: var(--soft); font-weight: 500; font-variant-numeric: tabular-nums; }
.slotpick button[aria-pressed="true"] { background: var(--ink); color: var(--on-ink); }
.hist { display: grid; }
.hist .row small { display: block; }

/* email preview */
.mail { border-radius: 12px; overflow: hidden; box-shadow: var(--shadow-h); background: #fff; color: #000; }
.mail-bar { padding: 10px 14px; font-size: 12px; color: #6b7280; border-bottom: 1px solid #e5e7eb; background: #fafafa; }
.mail iframe { width: 100%; height: 520px; border: 0; display: block; }

/* toast */
.toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 100; display: grid; gap: 8px; width: min(92vw, 380px); }
.toast { background: var(--ink); color: var(--on-ink); border-radius: 12px; padding: 12px 16px; font-size: 13px; animation: tin .3s var(--ease); display: flex; gap: 10px; align-items: center; }
@keyframes tin { from { opacity: 0; transform: translateY(8px); } }

/* ---------- responsivo ---------- */
@media (max-width: 1180px) { .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g21 { grid-template-columns: 1fr; } }
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .side { position: fixed; left: 0; z-index: 85; width: 272px; transform: translateX(-100%); transition: transform .3s var(--ease); box-shadow: rgba(0,0,0,.1) 0 0 24px; }
  .side.open { transform: none; }
  .menu-btn { display: grid; }
  .top { padding: 0 12px; }
  .content { padding: 16px 12px 96px; }
  .g2 { grid-template-columns: 1fr; }
  .card { padding: 16px; }
  .tbl-wrap { margin: 0 -16px; padding: 0 16px; }
  .search .input { min-width: 0; }
  .search { flex: 1 1 100%; }
  .hide-m { display: none; }
  .fgrid { grid-template-columns: 1fr; }
  .sched-row { grid-template-columns: 34px 46px repeat(4, 1fr); }
}
@media (max-width: 520px) { .g4 { gap: 10px; } .kpi .val { font-size: 22px; } .card { padding: 14px; } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ajustes de encaixe */
.switch { display: inline-block; vertical-align: middle; }
.dr-b > *, .fgrid > *, .field { min-width: 0; }
.input { min-width: 0; }
.sched-row .input { width: 100%; padding: 0 4px; text-align: center; }
.sched-row input[type=time]::-webkit-calendar-picker-indicator, .slotpick + * input[type=time]::-webkit-calendar-picker-indicator { display: none; }
.drawer .grid.g2 { grid-template-columns: 1fr 1fr; }
.more { display: flex; justify-content: center; padding-top: 14px; }
@media (max-width: 520px) { #newBtn .lbl-long { display: none; } .top h1 { font-size: 18px; } }
@media (min-width: 521px) { #newBtn .lbl-short { display: none; } }
