:root {
  color-scheme: dark;
  --bg: #050b1d; --bg-2: #0a1633; --surface: rgba(255,255,255,.045); --surface-2: rgba(255,255,255,.075);
  --text: #e9efff; --muted: #8b9cc4; --line: rgba(130,165,255,.16);
  --blue: #2f6bff; --navy-2: #5b8cff; --navy: #9db9ff; --red: #ee3b52; --red-soft: rgba(238,59,82,.16);
  --gold-soft: rgba(91,140,255,.16); --warn: #ffb454; --ok: #3ddc97; --danger: #ff6b7d;
  --sab: #2f6bff; --dom: #ee3b52; --qua: #20b4e8;
  --glow: 0 0 0 1px rgba(91,140,255,.35), 0 8px 40px rgba(47,107,255,.25);
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0; font: 15px/1.5 "Segoe UI", system-ui, sans-serif; color: var(--text); background: var(--bg);
  background-image:
    radial-gradient(900px 600px at 85% -10%, rgba(47,107,255,.28), transparent 60%),
    radial-gradient(700px 500px at -5% 105%, rgba(238,59,82,.14), transparent 60%),
    linear-gradient(180deg, var(--bg-2), var(--bg) 70%);
  background-attachment: fixed; min-height: 100vh;
}
a { color: var(--navy-2); }
h1 { font-size: 1.75rem; font-weight: 800; letter-spacing: -.02em; margin: 0 0 4px; }
h2 { font-size: .8rem; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); margin: 30px 0 12px; display: flex; align-items: center; gap: 10px; }
h2::before { content: ""; width: 22px; height: 3px; border-radius: 3px; background: var(--red); }
.muted { color: var(--muted); }

/* ---------- estrutura ---------- */
.shell { display: grid; grid-template-columns: 262px 1fr; min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 22px 14px;
  background: linear-gradient(180deg, rgba(10,22,51,.92), rgba(5,11,29,.96)); border-right: 1px solid var(--line); backdrop-filter: blur(14px);
}
.brand { display: flex; gap: 12px; align-items: center; padding: 4px 8px 22px; }
.logo { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; font-weight: 800; letter-spacing: .02em; color: #fff;
  background: linear-gradient(135deg, var(--blue), #1236a8); box-shadow: var(--glow); position: relative; }
.logo::after { content: ""; position: absolute; right: -3px; bottom: -3px; width: 12px; height: 12px; border-radius: 50%; background: var(--red); border: 2px solid var(--bg-2); }
.brand strong { display: block; font-size: 1.1rem; letter-spacing: .08em; line-height: 1.1; }
.brand span { font-size: .78rem; color: var(--muted); }
nav { display: flex; flex-direction: column; gap: 3px; }
nav a { position: relative; display: flex; align-items: center; gap: 12px; padding: 11px 14px; border-radius: 10px; color: #b4c4ea; text-decoration: none; font-weight: 500; transition: .18s; }
nav a svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }
nav a:hover { background: var(--surface-2); color: #fff; }
nav a.on { color: #fff; background: linear-gradient(90deg, rgba(47,107,255,.34), rgba(47,107,255,.06)); }
nav a.on::before { content: ""; position: absolute; left: -14px; top: 9px; bottom: 9px; width: 4px; border-radius: 0 4px 4px 0; background: var(--red); box-shadow: 0 0 14px var(--red); }
nav a.on svg { color: var(--navy-2); }
.side-foot { margin-top: auto; padding: 14px 10px 0; border-top: 1px solid var(--line); font-size: .8rem; color: var(--muted); }
.side-foot span { color: var(--red); font-weight: 600; letter-spacing: .06em; font-size: .72rem; text-transform: uppercase; }
.content { min-width: 0; }
main { max-width: 1120px; margin: 0 auto; padding: 32px 32px 80px; animation: rise .45s ease both; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.mobilebar, .scrim { display: none; }

/* ---------- hero (início) ---------- */
.hero { position: relative; overflow: hidden; border-radius: 22px; padding: 44px 40px; margin-bottom: 22px; border: 1px solid var(--line);
  background: radial-gradient(600px 300px at 90% 0%, rgba(47,107,255,.55), transparent 65%), radial-gradient(380px 260px at 100% 100%, rgba(238,59,82,.38), transparent 65%), linear-gradient(135deg, #0b1f55, #070f28 75%);
  box-shadow: 0 30px 80px rgba(0,0,0,.45); }
.hero::after { content: ""; position: absolute; inset: 0; background: repeating-linear-gradient(0deg, rgba(255,255,255,.02) 0 1px, transparent 1px 3px); pointer-events: none; }
.eyebrow { font-size: .75rem; font-weight: 700; letter-spacing: .24em; text-transform: uppercase; color: #ff7384; }
.hero h1 { font-size: clamp(2rem, 5vw, 3.4rem); margin: 6px 0 4px; line-height: 1.05; }
.hero p { margin: 0 0 22px; color: #b9c9f0; font-size: 1.05rem; }

/* ---------- componentes ---------- */
.head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 18px; margin-bottom: 14px; backdrop-filter: blur(8px); transition: border-color .2s; }
.card:hover { border-color: rgba(91,140,255,.32); }
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.stat { position: relative; overflow: hidden; margin: 0; }
.stat::after { content: ""; position: absolute; right: -30px; top: -30px; width: 110px; height: 110px; border-radius: 50%; background: radial-gradient(circle, rgba(47,107,255,.35), transparent 70%); }
.stat:nth-child(even)::after { background: radial-gradient(circle, rgba(238,59,82,.3), transparent 70%); }
.stat b { display: block; font-size: 2.4rem; font-weight: 800; line-height: 1.1; color: #fff; }
button, .btn { font: inherit; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; text-decoration: none; border: 1px solid var(--line); background: var(--surface); color: var(--text); padding: 8px 15px; border-radius: 10px; transition: .15s; }
button:hover, .btn:hover { background: var(--surface-2); border-color: rgba(91,140,255,.55); }
button:disabled { opacity: .4; cursor: default; }
button.primary, .btn.primary { background: linear-gradient(135deg, #3c78ff, #1f4fd8); border-color: transparent; color: #fff; box-shadow: 0 6px 22px rgba(47,107,255,.4); }
button.primary:hover, .btn.primary:hover { filter: brightness(1.12); }
.btn.red { background: linear-gradient(135deg, #f24a60, #c4213a); border-color: transparent; color: #fff; box-shadow: 0 6px 22px rgba(238,59,82,.35); }
button.danger { color: var(--danger); }
button.small { padding: 3px 10px; font-size: .84rem; border-radius: 8px; }
input, select, textarea { font: inherit; padding: 8px 11px; border: 1px solid var(--line); border-radius: 10px; background: rgba(5,11,29,.7); color: var(--text); max-width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(91,140,255,.55); outline-offset: 0; border-color: transparent; }
::placeholder { color: #6679a3; }
option { background: #0a1633; }
label { display: flex; flex-direction: column; gap: 4px; font-size: .85rem; color: var(--muted); margin-bottom: 10px; }
label.check { flex-direction: row; align-items: center; gap: 8px; color: var(--text); }
input[type=checkbox] { accent-color: var(--blue); width: 16px; height: 16px; }
table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; }
th, td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .72rem; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); background: rgba(5,11,29,.5); }
tr:last-child td { border-bottom: 0; }
tbody tr[style*="pointer"]:hover { background: var(--surface-2); }
.table-wrap { overflow-x: auto; }
.tag { display: inline-block; padding: 1px 10px; border-radius: 999px; font-size: .78rem; background: var(--gold-soft); color: #cfe0ff; margin: 1px 3px 1px 0; }
.tag.off { background: rgba(255,255,255,.08); color: var(--muted); }
.badge { font-size: .74rem; padding: 2px 9px; border-radius: 999px; background: var(--surface-2); color: #c9d6f5; }
.badge.warn { background: var(--red-soft); color: #ff8a98; }
.badge.ok { background: rgba(61,220,151,.15); color: var(--ok); }
button.primary .badge { background: rgba(255,255,255,.22); color: #fff; }

/* ---------- escala ---------- */
.week-title { display: flex; justify-content: space-between; align-items: center; margin: 26px 0 10px; color: var(--muted); font-weight: 700; font-size: .8rem; letter-spacing: .1em; text-transform: uppercase; }
.svc { padding: 0; overflow: hidden; border-left: 4px solid var(--sab); }
.svc.domingo { border-left-color: var(--dom); } .svc.quarta { border-left-color: var(--qua); }
.svc-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; padding: 13px 18px; background: linear-gradient(90deg, rgba(47,107,255,.14), transparent); }
.svc.domingo .svc-head { background: linear-gradient(90deg, rgba(238,59,82,.16), transparent); }
.svc.quarta .svc-head { background: linear-gradient(90deg, rgba(32,180,232,.14), transparent); }
.svc-head strong { font-size: 1.05rem; }
.svc-body { padding: 8px 18px 14px; }
.role { display: grid; grid-template-columns: 220px 1fr; gap: 8px; padding: 8px 0; border-bottom: 1px dashed var(--line); align-items: start; }
.role:last-child { border: 0; }
.role > span { color: var(--muted); font-size: .86rem; padding-top: 7px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chip { background: rgba(47,107,255,.22); border: 1px solid rgba(91,140,255,.35); border-radius: 999px; padding: 3px 4px 3px 12px; display: inline-flex; gap: 4px; align-items: center; }
.chip.free { background: var(--red-soft); border: 1px dashed rgba(238,59,82,.55); }
.chip button { border: 0; background: transparent; padding: 0 7px; color: var(--muted); }
.chip button:hover { color: var(--red); background: transparent; }
.chips input { border-style: dashed; min-width: 150px; padding: 4px 10px; background: transparent; }

/* ---------- calendário ---------- */
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; }
.cal .dow { background: rgba(5,11,29,.8); text-align: center; font-size: .72rem; padding: 8px 0; color: var(--muted); text-transform: uppercase; letter-spacing: .1em; }
.cal .day { background: rgba(10,22,51,.85); min-height: 100px; padding: 5px; cursor: pointer; overflow: hidden; transition: background .15s; }
.cal .day:hover { background: rgba(47,107,255,.14); }
.cal .day.out { background: rgba(5,11,29,.85); opacity: .5; }
.cal .day.today .n { background: var(--red); color: #fff; border-radius: 999px; padding: 1px 8px; box-shadow: 0 0 14px rgba(238,59,82,.6); }
.cal .n { font-size: .82rem; font-weight: 600; }
.ev { display: block; font-size: .74rem; padding: 2px 6px; margin-top: 3px; border-radius: 5px; background: rgba(47,107,255,.3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ev.svc-ev { background: transparent; color: var(--muted); border: 1px solid var(--line); }

/* ---------- diálogo ---------- */
dialog { border: 1px solid var(--line); border-radius: 20px; padding: 24px; width: min(560px, 94vw); background: linear-gradient(180deg, #0d1c42, #070f28); color: var(--text); box-shadow: 0 40px 100px rgba(0,0,0,.65), var(--glow); }
dialog::backdrop { background: rgba(2,6,18,.72); backdrop-filter: blur(4px); }
dialog.wide { width: min(780px, 96vw); }
.dlg-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 2px 10px; max-height: 190px; overflow: auto; border: 1px solid var(--line); border-radius: 10px; padding: 8px; }
#cardCanvas { width: 100%; height: auto; border-radius: 12px; border: 1px solid var(--line); }
.drop { border: 2px dashed var(--line); border-radius: 12px; padding: 14px; }
.result { margin-top: 10px; padding: 10px 14px; border-radius: 10px; background: rgba(61,220,151,.12); color: var(--ok); font-size: .9rem; }
.result.err { background: var(--red-soft); color: #ff8a98; }
.result ul { margin: 6px 0 0; padding-left: 18px; max-height: 140px; overflow: auto; }
#toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%) translateY(90px); background: linear-gradient(135deg, #1f4fd8, #12318a); border: 1px solid rgba(91,140,255,.5); color: #fff; padding: 11px 20px; border-radius: 12px; transition: transform .28s; z-index: 30; box-shadow: var(--glow); }
#toast.show { transform: translateX(-50%) translateY(0); }

/* ---------- nomeações ---------- */
.appt { display: grid; grid-template-columns: 190px 1fr 90px 34px; gap: 8px; padding: 4px 0; align-items: center; }
.appt .state { text-align: center; }
.appt input { min-width: 0; width: 100%; }

/* ---------- responsivo ---------- */
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 40; left: 0; top: 0; width: 276px; transform: translateX(-102%); transition: transform .25s; }
  body.menu-open .sidebar { transform: none; }
  body.menu-open .scrim { display: block; position: fixed; inset: 0; z-index: 35; background: rgba(2,6,18,.65); }
  .mobilebar { display: flex; align-items: center; gap: 12px; position: sticky; top: 0; z-index: 20; padding: 10px 16px; background: rgba(5,11,29,.9); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
  .mobilebar button { padding: 4px 12px; font-size: 1.2rem; }
  main { padding: 20px 16px 70px; }
  .hero { padding: 30px 22px; }
}
@media (max-width: 640px) {
  .role { grid-template-columns: 1fr; gap: 2px; } .role > span { padding: 0; }
  .cal .day { min-height: 64px; } .ev { font-size: .66rem; }
  .appt { grid-template-columns: minmax(0,1fr) minmax(0,1.4fr) 34px; } .appt .state { display: none; }
}
@media print {
  .sidebar, .mobilebar, .head .row, #toast, .appt button, .card .row button { display: none !important; }
  .shell { display: block; } body { background: #fff; color: #000; } main { padding: 0; animation: none; }
  .card { break-inside: avoid; border-color: #bbb; background: #fff; } h1, .card strong { color: #000; }
  .appt input { border: 0; background: transparent; padding: 0; color: #000; } .appt .state .badge { display: none; }
}

/* ---------- acesso ---------- */
[hidden] { display: none !important; }
.mono { font-family: Consolas, "Cascadia Mono", monospace; }
body:not(.authed) .shell { display: none; }
body.authed #auth { display: none; }
body:not(.is-admin) .admin-only { display: none; }
#auth { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login { width: min(400px, 100%); padding: 34px 30px; border-radius: 22px; border: 1px solid var(--line); text-align: center;
  background: linear-gradient(180deg, rgba(13,28,66,.85), rgba(7,15,40,.92)); box-shadow: 0 40px 100px rgba(0,0,0,.6), var(--glow); backdrop-filter: blur(12px); }
.login .logo { width: 58px; height: 58px; margin: 0 auto 14px; font-size: 1.25rem; }
.login label { text-align: left; }
.login input { padding: 11px 13px; }
#whoami { padding-bottom: 12px; margin-bottom: 12px; border-bottom: 1px solid var(--line); display: grid; gap: 10px; color: var(--text); }
.role-pill { font-size: .7rem; letter-spacing: .08em; text-transform: uppercase; color: #ff8a98; font-weight: 700; }
