:root {
  --primary-blue: #1f3c88;
  --primary-green: #00a651;
  --background-soft: #f4f9f6;
  --border-soft: #dde7e0;
  --text-main: #1f2933;
  --text-muted: #6b7280;
  --danger: #e02424;
}

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

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--background-soft);
  color: var(--text-main);
  overflow-x: hidden;
}

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

.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.layout {
  flex: 1;
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 230px;
  min-height: 100vh;
  background: #e2e5e9;
  color: #1f2933;
  display: flex;
  flex-direction: column;
  padding: 1.25rem 1rem 1.5rem;
  box-shadow: 2px 0 12px rgba(0, 0, 0, 0.06);
}

.sidebar-header-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1.4rem;
}

.sidebar-header-row .sidebar-logo {
  margin-bottom: 0;
  flex: 1;
  min-width: 0;
}

.sidebar-close-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  flex-shrink: 0;
  border: none;
  background: rgba(0, 0, 0, 0.06);
  border-radius: 10px;
  cursor: pointer;
  color: var(--text-main);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.sidebar-close-btn:hover {
  background: rgba(0, 0, 0, 0.1);
}

.sidebar-close-btn svg {
  display: block;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0;
  text-decoration: none;
  color: inherit;
}

.sidebar-logo img {
  height: 100px;
  width: auto;
}

.sidebar-title {
  display: flex;
  flex-direction: column;
}

.sidebar-title-main {
  font-weight: 700;
  letter-spacing: 0.03em;
}

.sidebar-title-sub {
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.82);
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  flex: 1;
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 1rem;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0.75rem;
  border-radius: 999px;
  font-size: 0.9rem;
  transition: background 0.2s ease, transform 0.08s ease;
}

.sidebar-link .sidebar-icon {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  color: var(--primary-green);
  display: flex;
  align-items: center;
  justify-content: center;
}

.sidebar-link .sidebar-icon svg {
  width: 100%;
  height: 100%;
}

.mobile-topbar,
.sidebar-overlay {
  display: none;
}

.sidebar-link:hover {
  background: rgba(0, 0, 0, 0.06);
  transform: translateX(2px);
}

.main-content {
  flex: 1;
  display: flex;
  min-width: 0;
}

.navbar {
  background: linear-gradient(120deg, var(--primary-green), var(--primary-blue));
  color: #fff;
  padding: 0.75rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.12);
}

.navbar-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.navbar-logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.navbar-logo img {
  height: 40px;
  width: auto;
}

.navbar-title {
  display: flex;
  flex-direction: column;
}

.navbar-title-main {
  font-weight: 700;
  letter-spacing: 0.03em;
}

.navbar-title-sub {
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.8);
}

.navbar-menu {
  display: flex;
  gap: 1rem;
}

.navbar-link {
  padding: 0.4rem 0.8rem;
  border-radius: 999px;
  font-size: 0.9rem;
  transition: background 0.2s ease, transform 0.1s ease;
}

.navbar-link:hover {
  background: rgba(255, 255, 255, 0.18);
  transform: translateY(-1px);
}

.container {
  max-width: 1100px;
  width: 100%;
  margin: 1.5rem auto 2rem;
  padding: 0 1rem;
  flex: 1;
  min-width: 0;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.page-title {
  font-size: 1.4rem;
  font-weight: 600;
  color: var(--primary-blue);
}

.page-subtitle {
  font-size: 0.9rem;
  color: var(--text-muted);
}

.card {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
  padding: 1.25rem 1.5rem;
  border: 1px solid rgba(15, 118, 110, 0.08);
  min-width: 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.card + .card {
  margin-top: 1rem;
}

/* Modal de confirmação Sair */
.logout-modal {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

.logout-modal--open {
  opacity: 1;
  visibility: visible;
}

.logout-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  backdrop-filter: blur(4px);
}

.logout-modal-dialog {
  position: relative;
  background: #fff;
  border-radius: 16px;
  padding: 2rem;
  max-width: 360px;
  width: 100%;
  text-align: center;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border-soft);
  animation: logout-modal-in 0.25s ease;
}

@keyframes logout-modal-in {
  from {
    opacity: 0;
    transform: scale(0.95) translateY(-10px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.logout-modal-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 1.25rem;
  color: var(--primary-green);
  display: flex;
  align-items: center;
  justify-content: center;
}

.logout-modal-icon svg {
  width: 100%;
  height: 100%;
}

.logout-modal-title {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text-main);
  margin: 0 0 0.5rem;
}

.logout-modal-text {
  font-size: 0.95rem;
  color: var(--text-muted);
  margin: 0 0 1.5rem;
  line-height: 1.5;
}

.logout-modal-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  flex-wrap: wrap;
}

.logout-modal-actions .btn {
  min-width: 120px;
}

.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.stat-card {
  background: #fff;
  border-radius: 10px;
  padding: 0.85rem 1rem;
  border: 1px solid var(--border-soft);
  text-align: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.stat-card .stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.2;
}

.stat-card .stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
}

.stat-card.stat-total .stat-value { color: var(--primary-blue); }
.stat-card.stat-open .stat-value { color: #b45309; }
.stat-card.stat-progress .stat-value { color: #1d4ed8; }
.stat-card.stat-done .stat-value { color: var(--primary-green); }
.stat-card.stat-cancelled .stat-value { color: var(--danger); }

.table-historico-agenda {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  table-layout: fixed;
}

.table-historico-agenda th,
.table-historico-agenda td {
  padding: 0.55rem 0.45rem;
  text-align: left;
  vertical-align: middle;
  border-bottom: 1px solid var(--border-soft);
}

.table-historico-agenda tbody td:nth-child(5) {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.table-historico-agenda .table-empty {
  text-align: center;
  padding: 1.2rem 0.6rem;
  color: var(--text-muted);
  font-style: italic;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

.card-title {
  font-size: 1.05rem;
  font-weight: 600;
}

.btn {
  border: none;
  border-radius: 999px;
  padding: 0.45rem 1rem;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease,
    transform 0.1s ease;
}

.btn:focus {
  outline: 2px solid rgba(59, 130, 246, 0.6);
  outline-offset: 2px;
}

.btn-primary {
  background: var(--primary-green);
  color: #fff;
  box-shadow: 0 6px 20px rgba(0, 166, 81, 0.35);
}

.btn-primary:hover {
  background: #03924a;
  transform: translateY(-1px);
}

.btn-secondary {
  background: #fff;
  color: var(--primary-blue);
  border: 1px solid rgba(31, 60, 136, 0.4);
}

.btn-secondary:hover {
  background: rgba(31, 60, 136, 0.05);
}

.btn-danger {
  background: #fff;
  color: var(--danger);
  border: 1px solid rgba(224, 36, 36, 0.5);
}

.btn-danger:hover {
  background: rgba(224, 36, 36, 0.06);
}

.btn-sm {
  padding: 0.25rem 0.6rem;
  font-size: 0.78rem;
}

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.2rem;
  min-width: 1.5rem;
  min-height: 1.5rem;
}

.btn-icon svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.btn-group {
  display: inline-flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0.25rem;
}

.btn-whatsapp {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.28rem;
  min-width: 1.75rem;
  min-height: 1.75rem;
  box-sizing: border-box;
  font-size: 0.78rem;
  border-radius: 50%;
  background: #25d366;
  color: #fff;
  text-decoration: none;
  font-weight: 500;
  transition: background 0.2s, transform 0.08s;
}

.btn-whatsapp:hover {
  background: #20bd5a;
  color: #fff;
  transform: translateY(-1px);
}

.btn-whatsapp svg {
  width: 12px;
  height: 12px;
  flex-shrink: 0;
  display: block;
  vertical-align: middle;
  transform: translate(0.5px, 0.5px);
}

.btn-group .btn-whatsapp {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.28rem;
  min-width: 1.75rem;
  min-height: 1.75rem;
  box-sizing: border-box;
}

.btn-group .btn-whatsapp svg {
  width: 12px;
  height: 12px;
  display: block;
  vertical-align: middle;
  transform: translate(0.5px, 0.5px); /* ajuste fino para centralizar o desenho do logo */
}

/* Filtros na mesma linha dos títulos (cabeçalho azul) */
.filter-row th {
  font-weight: 600;
  color: var(--text-main);
  vertical-align: top;
  padding: 0.5rem 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border-soft);
}

.filter-row .th-label {
  display: block;
  font-size: 0.9rem;
  margin-bottom: 0.35rem;
}

.filter-row th .filter-select {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

/* Data no cabeçalho: input nativo abre o calendário do sistema */
.filter-row .filter-date-input {
  width: 100%;
  min-width: 7rem;
  box-sizing: border-box;
  padding: 0.35rem 0.4rem;
  border: 1px solid var(--border-soft);
  border-radius: 6px;
  font-size: 0.8rem;
  background: #fff;
  color: var(--text-main);
}
.filter-row .filter-date-input--solo {
  margin-top: 0.25rem;
}
.filter-row .filter-date-input:focus {
  outline: none;
  border-color: var(--primary-green);
  box-shadow: 0 0 0 2px rgba(0, 166, 81, 0.15);
}

.filter-row .filter-actions {
  text-align: right;
  width: 120px;
}

.filter-row .filter-actions .th-label {
  margin-bottom: 0.25rem;
}

.filter-select {
  padding: 0.4rem 1.75rem 0.4rem 0.5rem;
  border: 1px solid var(--border-soft);
  border-radius: 6px;
  font-size: 0.85rem;
  background: #fff;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236b7280' d='M2 5l4 4 4-4z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.5rem center;
  background-size: 10px;
}

.filter-select:focus {
  outline: none;
  border-color: var(--primary-green);
  box-shadow: 0 0 0 2px rgba(0, 166, 81, 0.15);
}

.filter-select:hover {
  border-color: var(--primary-green);
}

/* Campo de pesquisa no cabeçalho (filtro por texto) */
.filter-search {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
  padding: 0.4rem 0.5rem;
  border: 1px solid var(--border-soft);
  border-radius: 6px;
  font-size: 0.85rem;
  background: #fff;
}

.filter-search:focus {
  outline: none;
  border-color: var(--primary-green);
  box-shadow: 0 0 0 2px rgba(0, 166, 81, 0.15);
}

.filter-search::placeholder {
  color: var(--text-muted);
}

.filter-row th .filter-search {
  width: 100%;
}

/* Filtro por período (mesmo padrão da página Financeiro) */
.os-period-card .finance-filter {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.75rem;
  margin-bottom: 0;
}
.os-period-card .finance-filter .form-group {
  margin-bottom: 0;
}
.os-period-card .finance-filter label {
  font-size: 0.8rem;
}
.os-period-card .finance-quick {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
}
.os-period-card .finance-quick .btn {
  font-size: 0.85rem;
  padding: 0.4rem 0.75rem;
}
.os-period-card h2 {
  font-size: 1.05rem;
  font-weight: 600;
  margin: 0 0 0.75rem;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.table-clientes {
  table-layout: fixed;
  max-width: 100%;
}

.table-clientes tbody td {
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 0;
}
.table-clientes tbody td:last-child {
  max-width: none;
  overflow: visible;
}

.table-clientes .filter-search {
  max-width: 100%;
  box-sizing: border-box;
}

thead {
  background: linear-gradient(120deg, rgba(0, 166, 81, 0.08), rgba(31, 60, 136, 0.06));
}

th,
td {
  padding: 0.6rem 0.5rem;
  text-align: left;
}

th {
  font-weight: 600;
  color: var(--text-main);
  border-bottom: 1px solid var(--border-soft);
}

tbody tr:nth-child(even) {
  background: #f8fafc;
}

tbody tr:hover {
  background: #eef7f2;
}

.table-empty {
  text-align: center;
  padding: 1.2rem 0.6rem;
  color: var(--text-muted);
  font-style: italic;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.16rem 0.55rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-open {
  background: rgba(0, 166, 81, 0.1);
  color: var(--primary-green);
}

.badge-progress {
  background: rgba(31, 60, 136, 0.1);
  color: var(--primary-blue);
}

.badge-done {
  background: rgba(22, 163, 74, 0.1);
  color: #15803d;
}

.badge-cancelled {
  background: rgba(220, 38, 38, 0.1);
  color: #b91c1c;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.85rem 1rem;
}

.customer-picker-inner {
  position: relative;
}

.customer-search-results {
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  margin-top: 4px;
  max-height: 260px;
  overflow-y: auto;
  z-index: 20;
  background: #fff;
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
}

.customer-search-results[hidden] {
  display: none !important;
}

.customer-search-item {
  display: block;
  width: 100%;
  padding: 0.5rem 0.65rem;
  text-align: left;
  border: none;
  background: transparent;
  font: inherit;
  font-size: 0.9rem;
  color: var(--text-main);
  cursor: pointer;
  border-bottom: 1px solid var(--border-soft);
}

.customer-search-item:last-child {
  border-bottom: none;
}

.customer-search-item:hover,
.customer-search-item:focus {
  background: rgba(0, 166, 81, 0.08);
  outline: none;
}

.customer-search-item .customer-search-meta {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

.customer-search-empty {
  padding: 0.65rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.form-group .btn-whatsapp {
  align-self: flex-start;
  width: auto;
}

label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
}

input[type='text'],
input[type='tel'],
input[type='email'],
input[type='number'],
input[type='date'],
input[type='password'],
select,
textarea {
  border-radius: 8px;
  border: 1px solid var(--border-soft);
  padding: 0.45rem 0.6rem;
  font-size: 0.9rem;
  transition: border 0.15s ease, box-shadow 0.15s ease;
}

input[type='date'],
select {
  height: 2.5rem;
  min-height: 2.5rem;
  cursor: pointer;
  box-sizing: border-box;
  line-height: 1.4;
}

select {
  width: 100%;
  max-width: 100%;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  padding: 0.5rem 2.25rem 0.5rem 0.65rem;
  background-color: #fff;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.5rem center;
  background-size: 1rem;
  font-family: inherit;
  font-size: 0.9rem;
  color: var(--text-main);
  border-radius: 8px;
  border: 1px solid var(--border-soft);
}

select:hover {
  border-color: #94a3b8;
}

select option {
  padding: 0.35rem 0.5rem;
  font-family: inherit;
  font-size: 0.9rem;
}

select option:disabled {
  display: none;
}

/* Horários em linha (botões lado a lado) */
.time-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
}

.time-slots-container {
  display: inline-block;
  width: fit-content;
  max-width: 100%;
  padding: 0.75rem 1rem;
  background: #f8fafc;
  border: 1px solid var(--border-soft);
  border-radius: 10px;
}

.time-manual-wrap {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.time-manual-label {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.time-manual-input {
  width: 5rem;
  padding: 0.4rem 0.5rem;
  font-size: 0.85rem;
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  font-family: inherit;
}

.time-manual-input:focus {
  border-color: var(--primary-green);
  outline: none;
  box-shadow: 0 0 0 2px rgba(0, 166, 81, 0.15);
}

.form-group--time .time-slots {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.time-slot-btn {
  padding: 0.3rem 0.55rem;
  font-size: 0.8rem;
  font-family: inherit;
  color: var(--primary-blue);
  background: #fff;
  border: 1px solid var(--border-soft);
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.time-slot-btn:hover {
  border-color: var(--primary-green);
  background: rgba(0, 166, 81, 0.06);
}

.time-slot-btn.selected {
  background: var(--primary-green);
  color: #fff;
  border-color: var(--primary-green);
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary-green);
  box-shadow: 0 0 0 2px rgba(0, 166, 81, 0.15);
  outline: none;
}

textarea {
  min-height: 80px;
  resize: vertical;
}

.form-error {
  margin-bottom: 1rem;
  padding: 0.75rem 1rem;
  background: rgba(224, 36, 36, 0.1);
  border: 1px solid var(--danger);
  border-radius: 6px;
  color: var(--danger);
  font-size: 0.9rem;
}

.form-actions {
  margin-top: 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
}

.hint {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem 1.25rem;
  font-size: 0.9rem;
}

.detail-label {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-bottom: 0.15rem;
}

.detail-value {
  font-weight: 500;
}

.footer {
  padding: 0.75rem 1rem 1.25rem;
  text-align: center;
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* Calendário */
.container--calendar {
  max-width: 1200px;
}

.page-header--calendar {
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
}

.calendar-nav {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.calendar-title {
  font-weight: 600;
  color: var(--primary-blue);
  min-width: 180px;
  text-align: center;
}

.calendar-card {
  padding: 0;
  overflow: hidden;
}

.calendar-grid {
  display: flex;
  flex-direction: column;
}

.calendar-week {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  border-bottom: 1px solid var(--border-soft);
  align-items: stretch;
}

.calendar-week:not(.calendar-week--head) {
  grid-auto-rows: 1fr;
  height: 7.5rem;
  min-height: 7.5rem;
  max-height: 7.5rem;
}

.calendar-week:last-child {
  border-bottom: none;
}

.calendar-week--head {
  min-height: auto;
  background: linear-gradient(120deg, rgba(0, 166, 81, 0.08), rgba(31, 60, 136, 0.06));
  border-bottom: 2px solid var(--border-soft);
}

.calendar-day-head {
  padding: 0.5rem 0.25rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  text-align: center;
}

.calendar-day {
  position: relative;
  border-right: 1px solid var(--border-soft);
  padding: 0.35rem;
  display: flex;
  flex-direction: column;
  background: #fff;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
  height: 100%;
}

.calendar-day-add {
  position: absolute;
  top: 0.25rem;
  right: 0.25rem;
  width: 1.5rem;
  height: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--primary-green);
  background: #fff;
  border: 1px solid var(--primary-green);
  border-radius: 50%;
  text-decoration: none;
  opacity: 0;
  transition: opacity 0.2s ease, background 0.2s ease, color 0.2s ease;
  z-index: 2;
}

.calendar-day:hover .calendar-day-add,
.calendar-day.calendar-day--add-visible .calendar-day-add {
  opacity: 1;
}

.calendar-day-add:hover {
  background: var(--primary-green);
  color: #fff;
}

.calendar-day:last-child {
  border-right: none;
}

.calendar-day--other {
  background: #f8fafc;
}

.calendar-day--other .calendar-day-num {
  color: #94a3b8;
}

.calendar-day--today {
  background: rgba(0, 166, 81, 0.06);
}

.calendar-day--today .calendar-day-num {
  background: var(--primary-green);
  color: #fff;
  border-radius: 50%;
  width: 1.6rem;
  height: 1.6rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
}

.calendar-day-num {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-main);
  margin-bottom: 0.25rem;
}

.calendar-events {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  flex: 1;
  min-height: 0;
  min-width: 0;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.calendar-event {
  display: block;
  padding: 0.3rem 0.4rem;
  font-size: 0.75rem;
  background: rgba(31, 60, 136, 0.08);
  color: var(--primary-blue);
  border-radius: 6px;
  text-decoration: none;
  border-left: 3px solid var(--primary-green);
  transition: background 0.15s ease;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
}

.calendar-event:hover {
  background: rgba(31, 60, 136, 0.14);
}

.calendar-event-time {
  display: block;
  font-weight: 600;
  color: var(--text-muted);
  font-size: 0.7rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.calendar-event-title {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

/*
 * Menu gaveta no celular:
 * 1) @media (max-width: 1024px) — funciona sem JS (CSP bloqueando inline, rede, etc.).
 * 2) html.layout-compact — JS em /js/layout-compact.js para viewport largo + toque (Safari “modo computador”).
 */
@media (max-width: 1024px) {
  .layout.layout--nav-drawer {
    flex-direction: column;
    min-height: 100vh;
    min-height: 100dvh;
    min-height: -webkit-fill-available;
  }

  .app-shell {
    min-height: 100dvh;
    min-height: -webkit-fill-available;
  }

  .layout.layout--nav-drawer .mobile-topbar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: max(0.45rem, env(safe-area-inset-top, 0px)) max(1rem, env(safe-area-inset-right, 0px)) 0.45rem
      max(1rem, env(safe-area-inset-left, 0px));
    background: #e2e5e9;
    border-bottom: 1px solid var(--border-soft);
    position: sticky;
    top: 0;
    z-index: 1002;
    flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
  }

  .layout.layout--nav-drawer .mobile-topbar-brand {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    color: inherit;
    text-decoration: none;
    min-width: 0;
  }

  .layout.layout--nav-drawer .mobile-topbar-logo-img {
    height: 40px;
    width: auto;
    max-width: 120px;
    object-fit: contain;
    display: block;
    flex-shrink: 0;
  }

  .layout.layout--nav-drawer .mobile-topbar-title {
    font-weight: 700;
    color: var(--primary-blue);
    letter-spacing: 0.02em;
    font-size: 1.05rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .layout.layout--nav-drawer .sidebar-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    margin: -6px;
    margin-right: 0;
    padding: 0;
    border: none;
    background: transparent;
    border-radius: 8px;
    cursor: pointer;
    color: var(--text-main);
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    flex-shrink: 0;
  }

  .layout.layout--nav-drawer .sidebar-toggle:hover {
    background: rgba(0, 0, 0, 0.06);
  }

  .layout.layout--nav-drawer .sidebar-toggle-icon {
    display: block;
    width: 22px;
    height: 2px;
    background: currentColor;
    box-shadow: 0 7px 0 currentColor, 0 -7px 0 currentColor;
    border-radius: 1px;
  }

  .layout.layout--nav-drawer .sidebar-overlay {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    z-index: 1001;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
    padding-top: env(safe-area-inset-top, 0px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }

  .layout.layout--nav-drawer .sidebar-overlay.sidebar-overlay--visible {
    opacity: 1;
    pointer-events: auto;
  }

  .layout.layout--nav-drawer .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: min(300px, calc(100vw - 2.5rem));
    min-height: 100vh;
    min-height: 100dvh;
    min-height: -webkit-fill-available;
    height: 100dvh;
    max-height: 100dvh;
    z-index: 1003;
    transform: translate3d(-100%, 0, 0);
    transition: transform 0.28s ease;
    will-change: transform;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    padding: max(1rem, env(safe-area-inset-top, 0px)) 1rem 1.5rem max(1rem, env(safe-area-inset-left, 0px));
    margin: 0;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.15);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
  }

  .layout.layout--nav-drawer .sidebar.sidebar--open {
    transform: translate3d(0, 0, 0);
  }

  .layout.layout--nav-drawer .sidebar-header-row {
    margin-bottom: 0.75rem;
  }

  .layout.layout--nav-drawer .sidebar-close-btn {
    display: flex;
  }

  .layout.layout--nav-drawer .sidebar-logo img {
    height: 64px;
    max-width: 100%;
  }

  .layout.layout--nav-drawer .sidebar-nav {
    flex-direction: column;
    flex-wrap: nowrap;
    justify-content: flex-start;
  }

  .layout.layout--nav-drawer .sidebar-link {
    min-height: 44px;
    padding: 0.65rem 0.85rem;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
  }

  .layout.layout--nav-drawer .main-content {
    width: 100%;
    min-width: 0;
    flex: 1;
  }

  .layout.layout--nav-drawer .main-content .container {
    margin-top: 1rem;
    padding-left: max(1rem, env(safe-area-inset-left, 0px));
    padding-right: max(1rem, env(safe-area-inset-right, 0px));
    padding-bottom: max(2rem, env(safe-area-inset-bottom, 0px));
  }

  .main-content input:not([type='checkbox']):not([type='radio']):not([type='submit']):not([type='button']):not([type='hidden']),
  .main-content select,
  .main-content textarea {
    font-size: 16px;
  }
}

html.layout-compact .layout.layout--nav-drawer {
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  min-height: -webkit-fill-available;
}

html.layout-compact .app-shell {
  min-height: 100dvh;
  min-height: -webkit-fill-available;
}

html.layout-compact .layout.layout--nav-drawer .mobile-topbar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: max(0.45rem, env(safe-area-inset-top, 0px)) max(1rem, env(safe-area-inset-right, 0px)) 0.45rem
    max(1rem, env(safe-area-inset-left, 0px));
  background: #e2e5e9;
  border-bottom: 1px solid var(--border-soft);
  position: sticky;
  top: 0;
  z-index: 1002;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}

html.layout-compact .layout.layout--nav-drawer .mobile-topbar-brand {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  color: inherit;
  text-decoration: none;
  min-width: 0;
}

html.layout-compact .layout.layout--nav-drawer .mobile-topbar-logo-img {
  height: 40px;
  width: auto;
  max-width: 120px;
  object-fit: contain;
  display: block;
  flex-shrink: 0;
}

html.layout-compact .layout.layout--nav-drawer .mobile-topbar-title {
  font-weight: 700;
  color: var(--primary-blue);
  letter-spacing: 0.02em;
  font-size: 1.05rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

html.layout-compact .layout.layout--nav-drawer .sidebar-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  margin: -6px;
  margin-right: 0;
  padding: 0;
  border: none;
  background: transparent;
  border-radius: 8px;
  cursor: pointer;
  color: var(--text-main);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  flex-shrink: 0;
}

html.layout-compact .layout.layout--nav-drawer .sidebar-toggle:hover {
  background: rgba(0, 0, 0, 0.06);
}

html.layout-compact .layout.layout--nav-drawer .sidebar-toggle-icon {
  display: block;
  width: 22px;
  height: 2px;
  background: currentColor;
  box-shadow: 0 7px 0 currentColor, 0 -7px 0 currentColor;
  border-radius: 1px;
}

html.layout-compact .layout.layout--nav-drawer .sidebar-overlay {
  display: block;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  z-index: 1001;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

html.layout-compact .layout.layout--nav-drawer .sidebar-overlay.sidebar-overlay--visible {
  opacity: 1;
  pointer-events: auto;
}

html.layout-compact .layout.layout--nav-drawer .sidebar {
  position: fixed;
  left: 0;
  top: 0;
  width: min(300px, calc(100vw - 2.5rem));
  min-height: 100vh;
  min-height: 100dvh;
  min-height: -webkit-fill-available;
  height: 100dvh;
  max-height: 100dvh;
  z-index: 1003;
  transform: translate3d(-100%, 0, 0);
  transition: transform 0.28s ease;
  will-change: transform;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  padding: max(1rem, env(safe-area-inset-top, 0px)) 1rem 1.5rem max(1rem, env(safe-area-inset-left, 0px));
  margin: 0;
  box-shadow: 4px 0 24px rgba(0, 0, 0, 0.15);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

html.layout-compact .layout.layout--nav-drawer .sidebar.sidebar--open {
  transform: translate3d(0, 0, 0);
}

html.layout-compact .layout.layout--nav-drawer .sidebar-header-row {
  margin-bottom: 0.75rem;
}

html.layout-compact .layout.layout--nav-drawer .sidebar-close-btn {
  display: flex;
}

html.layout-compact .layout.layout--nav-drawer .sidebar-logo img {
  height: 64px;
  max-width: 100%;
}

html.layout-compact .layout.layout--nav-drawer .sidebar-nav {
  flex-direction: column;
  flex-wrap: nowrap;
  justify-content: flex-start;
}

html.layout-compact .layout.layout--nav-drawer .sidebar-link {
  min-height: 44px;
  padding: 0.65rem 0.85rem;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

html.layout-compact .layout.layout--nav-drawer .main-content {
  width: 100%;
  min-width: 0;
  flex: 1;
}

html.layout-compact .layout.layout--nav-drawer .main-content .container {
  margin-top: 1rem;
  padding-left: max(1rem, env(safe-area-inset-left, 0px));
  padding-right: max(1rem, env(safe-area-inset-right, 0px));
  padding-bottom: max(2rem, env(safe-area-inset-bottom, 0px));
}

html.layout-compact .main-content input:not([type='checkbox']):not([type='radio']):not([type='submit']):not([type='button']):not([type='hidden']),
html.layout-compact .main-content select,
html.layout-compact .main-content textarea {
  font-size: 16px;
}

@media (max-width: 768px) {
  .page-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .form-grid,
  .detail-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .page-header--calendar {
    flex-direction: column;
    align-items: flex-start;
  }

  .calendar-week:not(.calendar-week--head) {
    height: 5.75rem;
    min-height: 5.75rem;
    max-height: 5.75rem;
  }

  .calendar-day-num {
    font-size: 0.75rem;
  }

  .calendar-event {
    font-size: 0.7rem;
    padding: 0.2rem 0.3rem;
  }
}

@media print {
  .mobile-topbar,
  .sidebar-overlay {
    display: none !important;
  }

  .sidebar {
    position: static !important;
    transform: none !important;
    height: auto !important;
    max-height: none !important;
    box-shadow: none !important;
  }
}

