
:root {
  --bg: #f7f3ed;
  --surface: #fffdfa;
  --sidebar: #efe5d9;
  --text: #302820;
  --muted: #81766d;
  --primary: #805846;
  --primary-dark: #674433;
  --border: #eadfd3;
  --green: #8aaf9b;
  --pink: #dba1c2;
  --shadow: 0 12px 35px rgba(65, 46, 32, 0.05);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
  font-size: 15px;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.hidden {
  display: none !important;
}

h1,
h2,
strong {
  font-family: Georgia, "Times New Roman", serif;
}

h1 {
  margin: 8px 0;
  font-size: clamp(30px, 3vw, 44px);
  font-weight: 600;
  letter-spacing: -1px;
}

h2 {
  margin: 0;
  font-size: 25px;
  font-weight: 600;
}

p {
  line-height: 1.5;
}

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

/* Login */

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

.login-card {
  width: min(100%, 430px);
  padding: 38px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 24px;
  box-shadow: var(--shadow);
}

.login-card h1 {
  font-size: 32px;
}

.login-card form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 26px 0 18px;
}

.login-card label {
  margin-top: 8px;
  font-weight: 600;
}

.login-card input {
  width: 100%;
}

.login-card small {
  display: block;
  line-height: 1.6;
}

.mark {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #f1e5d7;
  color: var(--primary);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 23px;
}

.mark.small {
  width: 46px;
  height: 46px;
  flex-shrink: 0;
}

/* Layout principal */

.layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: 100vh;
}

aside {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 30px 24px;
  background: var(--sidebar);
  border-right: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 34px;
}

.brand b,
.brand small {
  display: block;
}

.brand b {
  margin-bottom: 5px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 17px;
}

aside a {
  display: block;
  padding: 16px;
  border-radius: 13px;
  color: var(--text);
  text-decoration: none;
  transition: background 0.2s ease;
}

aside a:hover {
  background: rgba(128, 88, 70, 0.09);
}

aside a.active {
  background: var(--primary);
  color: white;
}

.logout {
  margin-top: auto;
  padding: 12px 16px;
  border: 0;
  background: transparent;
  color: var(--primary);
  text-align: left;
}

main {
  width: 100%;
  min-width: 0;
  padding: 42px clamp(20px, 3vw, 54px) 24px;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 34px;
}

header h1 {
  margin-top: 12px;
}

.muted {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 16px;
}

.eyebrow {
  margin: 0;
  color: #a06f55;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 2px;
}

.tools {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 14px;
}

#user-email {
  color: var(--muted);
  overflow-wrap: anywhere;
}

/* Botões e campos */

button,
input,
select {
  border-radius: 10px;
}

.primary,
.secondary {
  padding: 14px 18px;
  border: 1px solid var(--border);
  font-weight: 600;
}

.primary {
  margin-top: 10px;
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

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

.secondary {
  background: #f4e9dc;
  color: var(--text);
}

input,
select {
  min-height: 43px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  outline-color: var(--green);
}

input::placeholder {
  color: #9a8e84;
}

.message {
  min-height: 20px;
  color: #a14c43;
}

/* Indicadores */

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 20px;
  margin-bottom: 28px;
}

.metrics article {
  min-width: 0;
  padding: 25px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 21px;
  box-shadow: var(--shadow);
}

.metrics article > span {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  margin-bottom: 18px;
  border-radius: 50%;
  background: #f1e5d7;
  color: var(--primary);
  font-size: 23px;
}

.metrics article:nth-child(2) > span,
.metrics article:nth-child(4) > span {
  background: #e2f0e8;
  color: #568a72;
}

.metrics article:nth-child(3) > span {
  background: #f6e3ed;
  color: #b05f91;
}

.metrics article p {
  margin: 0 0 18px;
  color: #6e6258;
}

.metrics article strong {
  display: block;
  margin-bottom: 8px;
  font-size: 36px;
  font-weight: 600;
}

/* Painéis e gráficos */

.panel {
  min-width: 0;
  padding: 26px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 21px;
  box-shadow: var(--shadow);
}

.analytics-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
  margin: 24px 0;
}

.chart-panel {
  min-width: 0;
  overflow: hidden;
}

.chart-area {
  position: relative;
  width: 100%;
  height: 280px;
  margin-top: 20px;
}

.chart-area canvas {
  display: block;
  max-width: 100%;
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 20px;
  margin-bottom: 18px;
}

.panel-head .muted {
  font-size: 15px;
}

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

.filters input {
  width: 220px;
}

.filters select {
  max-width: 100%;
}

/* Mensagens e tabela */

.notice {
  margin: 0 0 15px;
  color: var(--muted);
  font-size: 14px;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

th,
td {
  padding: 16px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.4px;
  white-space: nowrap;
}

td {
  font-size: 14px;
}

tbody tr:hover {
  background: #fcf8f2;
}

.whatsapp-link {
  color: #438468;
  text-decoration: none;
}

.whatsapp-link:hover {
  text-decoration: underline;
}

.status-select {
  min-width: 125px;
  padding: 8px;
}

.action-button {
  padding: 9px 13px;
  border: 0;
  background: #f1e5d7;
  color: var(--primary);
  font-weight: 700;
}

.action-button:hover {
  background: #e8d4c2;
}

.action-button:disabled {
  cursor: wait;
  opacity: 0.6;
}

.empty {
  padding: 32px 16px;
  color: var(--muted);
  text-align: center;
}

footer {
  padding: 25px 0 10px;
  color: var(--muted);
  font-size: 13px;
}

/* Responsividade */

@media (max-width: 1200px) {
  .layout {
    grid-template-columns: 235px minmax(0, 1fr);
  }

  aside {
    padding: 25px 18px;
  }

  main {
    padding: 30px 24px;
  }

  .metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

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

  aside {
    position: static;
    height: auto;
    display: flex;
    flex-direction: row;
    align-items: center;
    flex-wrap: wrap;
    padding: 16px;
  }

  .brand {
    width: 100%;
    margin-bottom: 8px;
  }

  aside a {
    padding: 12px;
  }

  .logout {
    margin: 0 0 0 auto;
  }

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

  .tools {
    justify-content: flex-start;
  }

  .analytics-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 600px) {
  main {
    padding: 22px 14px;
  }

  .metrics {
    grid-template-columns: 1fr;
    gap: 13px;
  }

  .metrics article {
    padding: 20px;
  }

  .metrics article strong {
    font-size: 32px;
  }

  .panel {
    padding: 18px 14px;
  }

  .chart-area {
    height: 230px;
  }

  .filters {
    flex-direction: column;
    width: 100%;
  }

  .filters input,
  .filters select {
    width: 100%;
    min-width: 0;
  }

  .panel-head {
    flex-direction: column;
  }

  .login-card {
    padding: 26px 20px;
  }

  .tools {
    align-items: flex-start;
    flex-direction: column;
  }

  .tools button {
    width: 100%;
  }
}

/* ===== MELHORIAS EXCLUSIVAS PARA CELULAR ===== */

@media (max-width: 600px) {
  html {
    scroll-padding-top: 12px;
  }

  body {
    font-size: 14px;
    overflow-x: hidden;
  }

  .layout {
    display: block;
    width: 100%;
    min-width: 0;
  }

  /* Menu mais compacto */
  aside {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    padding: 12px;
  }

  .brand {
    width: 100%;
    gap: 10px;
    margin: 0 0 8px;
  }

  .brand .mark.small {
    width: 40px;
    height: 40px;
    font-size: 19px;
  }

  .brand b {
    font-size: 15px;
  }

  aside a {
    flex: 1 1 auto;
    padding: 11px 9px;
    border-radius: 10px;
    font-size: 13px;
    text-align: center;
    white-space: nowrap;
  }

  .logout {
    flex: 0 0 auto;
    margin: 0;
    padding: 10px;
    font-size: 13px;
  }

  /* Conteúdo */
  main {
    width: 100%;
    min-width: 0;
    padding: 22px 14px 18px;
  }

  header {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 16px;
    margin-bottom: 22px;
  }

  header h1 {
    font-size: 32px;
    line-height: 1.15;
  }

  header .muted {
    font-size: 14px;
  }

  .tools {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    width: 100%;
  }

  #user-email {
    font-size: 12px;
    overflow-wrap: anywhere;
  }

  .tools button {
    width: 100%;
    min-height: 46px;
  }

  /* Indicadores em duas colunas */
  .metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 18px;
  }

  .metrics article {
    padding: 15px 12px;
    border-radius: 15px;
  }

  .metrics article > span {
    width: 38px;
    height: 38px;
    margin-bottom: 12px;
    font-size: 18px;
  }

  .metrics article p {
    margin-bottom: 10px;
    font-size: 12px;
    line-height: 1.4;
  }

  .metrics article strong {
    margin-bottom: 5px;
    font-size: 28px;
  }

  .metrics article small {
    font-size: 10px;
    overflow-wrap: anywhere;
  }

  /* Gráficos */
  .analytics-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 14px;
    margin: 18px 0;
  }

  .panel {
    min-width: 0;
    padding: 17px 13px;
    border-radius: 16px;
  }

  .chart-panel {
    width: 100%;
  }

  .panel-head {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 13px;
    margin-bottom: 12px;
  }

  .panel h2 {
    font-size: 21px;
    line-height: 1.25;
  }

  .panel-head .muted {
    font-size: 13px;
  }

  .chart-area {
    width: 100%;
    height: 235px;
    min-height: 0;
    margin-top: 10px;
  }

  .chart-area canvas {
    max-width: 100%;
  }

  /* Filtros */
  .filters {
    display: flex;
    flex-direction: column;
    gap: 9px;
    width: 100%;
  }

  .filters input,
  .filters select {
    width: 100%;
    min-width: 0;
    min-height: 45px;
  }

  /* Tabela com rolagem horizontal */
  .table-wrap {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 8px;
  }

  table {
    min-width: 720px;
  }

  th,
  td {
    padding: 12px 10px;
    font-size: 12px;
    white-space: nowrap;
  }

  .status-select {
    min-width: 120px;
    min-height: 40px;
  }

  .action-button {
    min-height: 40px;
    padding: 9px 12px;
  }

  .notice {
    font-size: 12px;
    line-height: 1.5;
  }

  footer {
    padding: 20px 0 8px;
    font-size: 11px;
  }

  /* Tela de login */
  .login-shell {
    min-height: 100vh;
    padding: 16px;
  }

  .login-card {
    width: 100%;
    max-width: 430px;
    padding: 25px 20px;
    border-radius: 18px;
  }

  .login-card h1 {
    font-size: 28px;
  }

  .login-card input,
  .login-card button {
    min-height: 46px;
  }
}

/* Celulares muito estreitos */
@media (max-width: 360px) {
  main {
    padding-right: 10px;
    padding-left: 10px;
  }

  .metrics {
    gap: 8px;
  }

  .metrics article {
    padding: 12px 9px;
  }

  .metrics article strong {
    font-size: 25px;
  }

  aside a {
    font-size: 12px;
    padding: 10px 6px;
  }

  .chart-area {
    height: 210px;
  }
}

/* Gráfico de evolução mensal */
.monthly-panel {
  margin-bottom: 24px;
}

.monthly-chart-area {
  position: relative;
  width: 100%;
  height: 300px;
}

@media (max-width: 600px) {
  .monthly-chart-area {
    height: 250px;
  }
}
