:root {
  --brand: #2563EB;
  --brand-dark: #1d4ed8;
  --brand-soft: #eff6ff;
  --text: #1a2332;
  --muted: #64748b;
  --border: #e2e8f0;
  --surface: #ffffff;
  --bg: #f1f5f9;
  --danger: #ef4444;
  --success: #22c55e;
  --warn: #f59e0b;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: Inter, system-ui, -apple-system, sans-serif;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
}

button { font-family: inherit; cursor: pointer; }
a { color: var(--brand); }

/* ── Botões ── */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  border: 1px solid var(--brand); background: var(--brand); color: #fff;
  padding: 9px 16px; border-radius: 9px; font-weight: 600; font-size: .9rem;
  transition: filter .15s;
}
.btn:hover { filter: brightness(1.05); }
.btn.secondary { background: #fff; color: var(--text); border-color: var(--border); }
.btn.danger { background: var(--danger); border-color: var(--danger); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.sm { padding: 5px 10px; font-size: .8rem; border-radius: 7px; }

input, select, textarea {
  width: 100%; padding: 9px 12px; border: 1px solid var(--border);
  border-radius: 9px; font-size: .9rem; font-family: inherit; background: #fff;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand-soft); border-color: var(--brand); }
label { font-size: .8rem; font-weight: 600; color: var(--muted); display: block; margin-bottom: 4px; }
.field { margin-bottom: 12px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > .field { flex: 1; min-width: 160px; }

.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .72rem; font-weight: 600; }
.badge.green { background: #dcfce7; color: #15803d; }
.badge.gray  { background: #f1f5f9; color: #64748b; }
.badge.blue  { background: var(--brand-soft); color: var(--brand-dark); }

/* ── Toast ── */
#toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: #111827; color: #fff; padding: 12px 20px; border-radius: 10px;
  opacity: 0; pointer-events: none; transition: all .25s; z-index: 9999; font-size: .9rem;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.err { background: var(--danger); }

/* ── Modal ── */
.modal-bg {
  position: fixed; inset: 0; background: rgba(15,23,42,.5); display: none;
  align-items: center; justify-content: center; z-index: 1000; padding: 16px;
}
.modal-bg.show { display: flex; }
.modal {
  background: #fff; border-radius: 16px; width: 100%; max-width: 560px;
  max-height: 90vh; overflow-y: auto; padding: 24px;
}
.modal h3 { margin-bottom: 16px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }

/* ── App shell ── */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 230px; background: #0f172a; color: #cbd5e1; flex-shrink: 0;
  display: flex; flex-direction: column; padding: 18px 12px;
}
.sidebar .logo { color: #fff; font-weight: 800; font-size: 1.15rem; padding: 6px 12px 18px; display:flex; gap:8px; align-items:center; }
.sidebar nav a {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 9px;
  color: #cbd5e1; text-decoration: none; font-weight: 500; font-size: .92rem; margin-bottom: 2px;
}
.sidebar nav a:hover { background: #1e293b; color: #fff; }
.sidebar nav a.active { background: var(--brand); color: #fff; }
.sidebar .spacer { flex: 1; }
.sidebar .user { font-size: .8rem; padding: 10px 12px; border-top: 1px solid #1e293b; }
.sidebar .user b { color: #fff; display: block; }

.main { flex: 1; padding: 22px 26px; overflow-x: auto; }
.page-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 12px; margin-bottom: 18px; }
.page-head h1 { font-size: 1.5rem; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 18px; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.toolbar .grow { flex: 1; min-width: 180px; }

/* ── Tabela ── */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); font-size: .88rem; }
th { color: var(--muted); font-size: .76rem; text-transform: uppercase; letter-spacing: .04em; }
tr:hover td { background: #f8fafc; }
.avatar { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; background: #e2e8f0; }
.avatar.lg { width: 72px; height: 72px; }

/* ── Agenda / Kanban ── */
.agenda-controls { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background:#fff; }
.seg button { border: 0; background: #fff; padding: 8px 14px; font-weight: 600; font-size: .85rem; color: var(--muted); }
.seg button.active { background: var(--brand); color: #fff; }
.chk { display: inline-flex; align-items: center; gap: 6px; font-size: .85rem; color: var(--text); }
.chk input { width: auto; }

.kanban { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 10px; align-items: flex-start; }
.kcol {
  min-width: 210px; width: 210px; flex-shrink: 0; background: #fff;
  border: 1px solid var(--border); border-radius: 12px; display: flex; flex-direction: column;
}
.kcol.today { border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand-soft); }
.kcol-head { padding: 10px 12px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background:#fff; border-radius: 12px 12px 0 0; }
.kcol-head .dow { font-size: .72rem; color: var(--muted); text-transform: uppercase; }
.kcol-head .day { font-size: 1.05rem; font-weight: 700; }
.kcol-body { padding: 10px; display: flex; flex-direction: column; gap: 8px; min-height: 60px; }
.kcol-body.drag-over { background: var(--brand-soft); }
.kcol-add { padding: 8px 10px 12px; }

.turno-tag { font-size:.68rem; font-weight:700; padding:1px 6px; border-radius:5px; }
.turno-tag.manha { background:#fef9c3; color:#a16207; }
.turno-tag.noite { background:#e0e7ff; color:#3730a3; }

.kcard {
  background: #fff; border: 1px solid var(--border); border-left: 4px solid var(--brand);
  border-radius: 9px; padding: 8px 10px; cursor: grab; display: flex; gap: 8px; align-items: center;
  box-shadow: 0 1px 2px rgba(0,0,0,.04);
}
.kcard:active { cursor: grabbing; }
.kcard.dragging { opacity: .4; }
.kcard .nome { font-size: .82rem; font-weight: 600; line-height: 1.1; }
.kcard .meta { font-size: .7rem; color: var(--muted); }
.kcard .x { margin-left: auto; color: var(--muted); border:0; background:transparent; font-size:1rem; }
.kcard.conflito { border-left-color: var(--danger); background: #fef2f2; }
.kcard .warn-i { color: var(--danger); }

.month-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; }
.month-grid .dow-h { text-align:center; font-size:.72rem; color:var(--muted); font-weight:700; text-transform:uppercase; padding:4px; }
.mcell { background:#fff; border:1px solid var(--border); border-radius:10px; min-height:96px; padding:6px; }
.mcell.empty { background: transparent; border: 0; }
.mcell.today { border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand-soft); }
.mcell .d { font-size:.8rem; font-weight:700; color:var(--muted); margin-bottom:4px; display:flex; justify-content:space-between; }
.mcell.drag-over { background: var(--brand-soft); }
.mchip { font-size:.72rem; padding:2px 6px; border-radius:6px; background:var(--brand-soft); color:var(--brand-dark);
  margin-bottom:3px; cursor:grab; display:flex; gap:4px; align-items:center; }
.mchip.conflito { background:#fef2f2; color:var(--danger); }

.empty-state { text-align:center; color:var(--muted); padding:40px 20px; }
.spin { display:inline-block; width:18px; height:18px; border:2px solid var(--border); border-top-color:var(--brand); border-radius:50%; animation:spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.status-pill {
  margin-top: 4px; font-size: .68rem; font-weight: 700; padding: 1px 7px;
  border: 1px solid; border-radius: 999px; background: #fff; line-height: 1.4;
}
.status-pill:disabled { cursor: default; opacity: .9; }

@media (max-width: 760px) {
  .sidebar { position: fixed; z-index: 50; height: 100vh; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: translateX(0); }
  .main { padding: 16px; }
}

/* ── Impressão / PDF ── */
@media print {
  .sidebar, .agenda-controls, .page-head .btn, #conflitoAviso, .kcol-add, .no-print { display: none !important; }
  body { background: #fff; }
  .main { padding: 0; overflow: visible; }
  .kanban { flex-wrap: wrap; overflow: visible; }
  .kcol { width: 31%; min-width: 31%; page-break-inside: avoid; border-color: #cbd5e1; margin-bottom: 8px; }
  .kcard { box-shadow: none; }
  .page-head h1::after { content: " — Escala"; font-weight: 400; color: #64748b; }
}
