:root {
  --bg: #f5f3ef;
  --card: #ffffff;
  --text: #252525;
  --muted: #777;
  --primary: #6f8f72;
  --primary-dark: #4f6f52;
  --danger: #b64b4b;
  --border: #e4e0d8;
  --soft: #eef1ea;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow-x: hidden;
}

a {
  color: inherit;
  text-decoration: none;
}

.topbar {
  background: #ffffff;
  border-bottom: 1px solid var(--border);
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  font-weight: 800;
  letter-spacing: .4px;
}

.nav {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.nav a {
  padding: 8px 12px;
  border-radius: 10px;
  background: var(--soft);
  font-size: 14px;
}

.nav a:hover {
  background: #dfe7db;
}

.container {
  width: 100%;
  max-width: none;
  margin: 0 auto;
  padding: 18px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px;
  box-shadow: 0 8px 24px rgba(0,0,0,.04);
  margin-bottom: 18px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 14px;
}

.stat {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px;
}

.stat small {
  display: block;
  color: var(--muted);
  margin-bottom: 8px;
}

.stat strong {
  font-size: 28px;
}

h1 {
  margin: 0 0 18px;
}

h2 {
  margin-top: 0;
}

.muted {
  color: var(--muted);
}

.btn {
  display: inline-block;
  border: 0;
  border-radius: 10px;
  padding: 10px 14px;
  background: var(--primary);
  color: #fff;
  cursor: pointer;
  font-weight: 700;
}

.btn:hover {
  background: var(--primary-dark);
}

.btn:disabled {
  opacity: .65;
  cursor: not-allowed;
}

.btn-danger {
  background: var(--danger);
}

.btn-danger:hover {
  background: #963737;
}

.input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  background: #fff;
}

.form-new {
  display: grid;
  grid-template-columns: 1fr 1fr 1.5fr .7fr 1fr .7fr auto;
  gap: 8px;
  align-items: center;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border-radius: 14px;
  overflow: hidden;
}

th,
td {
  border-bottom: 1px solid var(--border);
  padding: 10px;
  text-align: left;
  vertical-align: top;
  font-size: 14px;
}

th {
  background: var(--soft);
}

.badge {
  display: inline-block;
  padding: 5px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.badge-green {
  background: #dcebd8;
  color: #315f31;
}

.badge-red {
  background: #f0d8d8;
  color: #813636;
}

.badge-gray {
  background: #eeeeee;
  color: #555;
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}

.login-card {
  width: 100%;
  max-width: 380px;
}

.error {
  background: #f6dddd;
  color: #7e2525;
  border: 1px solid #e8bcbc;
  border-radius: 10px;
  padding: 10px;
  margin-bottom: 14px;
}

.success {
  background: #dfeedd;
  color: #315f31;
  border: 1px solid #c8e0c4;
  border-radius: 10px;
  padding: 10px;
  margin-bottom: 14px;
}

/* Botões de ordenação na lista de usuários */
.sort-btn {
  width: 100%;
  border: 0;
  background: transparent;
  padding: 0;
  text-align: left;
  font: inherit;
  font-weight: 800;
  color: inherit;
  cursor: pointer;
}

.sort-btn:hover,
.sort-btn.active {
  text-decoration: underline;
}

/* Agenda compacta sem scroll horizontal */
.agenda-top-card,
.agenda-rules-card {
  margin-bottom: 10px;
}

.agenda-rules-card {
  padding: 12px 16px;
}

.agenda-rules-card p {
  margin: 6px 0;
}

.agenda-table-card {
  padding: 8px;
}

.agenda-fit-wrap {
  overflow-x: hidden;
  overflow-y: auto;
  max-height: calc(100vh - 270px);
  border-radius: 14px;
  position: relative;
}

.agenda-editavel-table {
  width: 100%;
  table-layout: fixed;
  min-width: 0;
  border-collapse: separate;
  border-spacing: 0;
}

.agenda-editavel-table th,
.agenda-editavel-table td {
  padding: 5px;
  font-size: 11px;
  min-width: 0;
}

.agenda-editavel-table thead th {
  position: sticky;
  top: 0;
  z-index: 10;
  background: #e8eee2;
  box-shadow: 0 2px 0 rgba(0,0,0,.08);
}

.agenda-editavel-table .hora-col {
  width: 58px;
  text-align: center;
}

.agenda-editavel-table td.hora-col {
  vertical-align: middle;
  background: #fbfaf7;
  font-weight: 800;
}

/* Linhas alternadas por horário */
.agenda-editavel-table tr.hour-row-even td {
  background: #ffffff;
}

.agenda-editavel-table tr.hour-row-odd td {
  background: #f8f6f1;
}

.agenda-editavel-table tr.hour-row-even td.hora-col {
  background: #f2efe8;
}

.agenda-editavel-table tr.hour-row-odd td.hora-col {
  background: #e9e4d8;
}

.agenda-edit-cell {
  display: flex;
  flex-direction: column;
  gap: 4px;
  border-radius: 10px;
  padding: 5px;
}

/* Célula normal */
.cell-user-ok {
  background: #f7faf4;
  border: 1px solid #dcebd8;
}

.cell-admin-only {
  background: #fafafa;
  border: 1px dashed #d5d0c8;
}

/* A célula inteira NÃO fica azul quando ocupada */
.agenda-edit-cell.cell-user-ok.cell-occupied {
  background: #f7faf4 !important;
  border: 1px solid #dcebd8 !important;
  box-shadow: none !important;
}

.agenda-edit-cell.cell-admin-only.cell-occupied {
  background: #fafafa !important;
  border: 1px dashed #d5d0c8 !important;
  box-shadow: none !important;
}

.cell-occupied .cell-label {
  color: #666 !important;
}

.cell-empty {
  opacity: .86;
}

.cell-label {
  font-size: 9px;
  font-weight: 800;
  text-transform: uppercase;
  color: #666;
  line-height: 1;
}

.agenda-edit-slot {
  border-radius: 8px;
  padding: 4px;
  border: 1px solid var(--border);
  font-size: 10px;
  background: #fff;
}

.agenda-edit-slot span {
  display: block;
  font-weight: 700;
  margin-bottom: 3px;
  font-size: 9px;
}

/* Apenas a LISTA ocupada fica azul */
.agenda-edit-slot.slot-occupied {
  background: #d8ecff !important;
  border-color: #7fb6e8 !important;
}

.slot-empty {
  background: rgba(255,255,255,.72);
}

.agenda-edit-slot select {
  font-size: 10px;
  padding: 4px;
  border-radius: 7px;
}

.agenda-edit-slot.slot-occupied select,
.agenda-edit-slot select.select-occupied {
  background: #ffffff !important;
  border-color: #6fa9df !important;
  font-weight: 700 !important;
  color: #173f63 !important;
}

@media (max-width: 900px) {
  .grid,
  .form-new {
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
    gap: 12px;
  }

  .container {
    padding: 10px;
  }

  .agenda-editavel-table th,
  .agenda-editavel-table td {
    padding: 3px;
    font-size: 9px;
  }

  .agenda-editavel-table .hora-col {
    width: 44px;
  }

  .agenda-edit-slot select {
    font-size: 9px;
    padding: 3px;
  }
}
/* PATCH: cabeçalho fixo real da Agenda
   Cole este bloco no FINAL do arquivo:
   /var/www/duck-panel/public/style.css
*/

/* O cabeçalho agora fica fora da tabela, acima do bloco que rola */
.agenda-table-card {
  padding: 8px !important;
}

.agenda-fixed-head {
  display: grid;
  grid-template-columns: 58px repeat(7, minmax(0, 1fr));
  gap: 0;
  position: sticky;
  top: 0;
  z-index: 30;
  background: #e8eee2;
  border: 1px solid var(--border);
  border-bottom: 0;
  border-radius: 12px 12px 0 0;
  overflow: hidden;
  box-shadow: 0 2px 0 rgba(0,0,0,.08);
}

.agenda-fixed-head > div {
  padding: 8px 5px;
  font-size: 11px;
  font-weight: 800;
  text-align: left;
  border-right: 1px solid var(--border);
  white-space: nowrap;
}

.agenda-fixed-head > div:last-child {
  border-right: 0;
}

.agenda-fixed-head .agenda-head-hour {
  text-align: center;
}

/* O scroll fica só no corpo da agenda */
.agenda-fit-wrap {
  overflow-x: hidden !important;
  overflow-y: auto !important;
  max-height: calc(100vh - 315px) !important;
  border: 1px solid var(--border);
  border-top: 0;
  border-radius: 0 0 12px 12px;
}

/* Como o cabeçalho agora é separado, a tabela não precisa mais de thead fixo */
.agenda-no-thead thead {
  display: none !important;
}

/* Mantém as mesmas larguras do cabeçalho */
.agenda-editavel-table {
  table-layout: fixed !important;
  width: 100% !important;
}

.agenda-editavel-table .hora-col {
  width: 58px !important;
}

@media (max-width: 900px) {
  .agenda-fixed-head {
    grid-template-columns: 44px repeat(7, minmax(0, 1fr));
  }

  .agenda-fixed-head > div {
    padding: 6px 3px;
    font-size: 9px;
  }

  .agenda-editavel-table .hora-col {
    width: 44px !important;
  }

  .agenda-fit-wrap {
    max-height: calc(100vh - 300px) !important;
  }
}
