/* ===========================================================
   Espaço 420 — sistema de identidade
   Tokens + componentes compartilhados por todas as páginas
   =========================================================== */

:root {
  --ink-950: #f7f4ee;
  --surface: #ffffff;
  --surface-2: #f1ece1;
  --border: #e2d9c6;
  --text: #211c14;
  --text-muted: #6e6455;
  --gold: #a97e2f;
  --gold-soft: #cda85c;
  --teal: #157a72;
  --teal-soft: #d7ece9;
  --amber: #b5652a;
  --amber-soft: #f3e2ce;
  --green: #157a3e;
  --green-soft: #dcefe1;
  --red: #ad1f1f;
  --red-soft: #f6e0df;
  --shadow: 0 1px 2px rgba(33, 28, 20, .06), 0 8px 24px -12px rgba(33, 28, 20, .18);
  --serif: Georgia, "Iowan Old Style", "Palatino Linotype", "Times New Roman", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ink-950: #0b0f16;
    --surface: #131a24;
    --surface-2: #1a2330;
    --border: #263042;
    --text: #eef1f6;
    --text-muted: #99a3b5;
    --gold: #d3ac68;
    --gold-soft: #e7cd97;
    --teal: #3fb3a8;
    --teal-soft: #12262a;
    --amber: #e0985a;
    --amber-soft: #2a2015;
    --green: #1f9d52;
    --green-soft: #10261c;
    --red: #d32c2c;
    --red-soft: #2a1618;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 12px 32px -16px rgba(0, 0, 0, .6);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  background: var(--ink-950);
  color: var(--text);
  font-family: var(--sans);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

a { color: inherit; }
::selection { background: var(--gold-soft); color: #211c14; }

.wrap { max-width: 1180px; margin: 0 auto; padding: 0 24px; }

h1, h2, h3 { font-family: var(--serif); font-weight: 600; text-wrap: balance; margin: 0; }

/* ---------- topbar / navegação interna ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  flex-wrap: wrap;
  gap: 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--serif);
  font-size: 18px;
  font-weight: 600;
  text-decoration: none;
  color: var(--text);
}

.brand .dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-soft);
}

.topnav {
  display: flex;
  gap: 4px;
  font-size: 13.5px;
  flex-wrap: wrap;
}

.topnav a {
  color: var(--text-muted);
  text-decoration: none;
  padding: 8px 12px;
  border-radius: 7px;
  font-weight: 500;
  transition: color .15s ease, background .15s ease;
}

.topnav a:hover { color: var(--text); }

.topnav a.active {
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
}

/* ---------- botões ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 14.5px;
  text-decoration: none;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform .15s ease, box-shadow .15s ease, background .15s ease, border-color .15s ease;
  font-family: inherit;
}

.btn-primary { background: var(--gold); color: #211505; }
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 8px 20px -8px var(--gold); }

.btn-ghost { background: transparent; border-color: var(--border); color: var(--text); }
.btn-ghost:hover { border-color: var(--text-muted); }

.btn-danger { background: var(--red-soft); color: var(--red); border-color: transparent; }
.btn-danger:hover { box-shadow: 0 8px 20px -10px var(--red); }

.btn-block { width: 100%; justify-content: center; }

/* ---------- cartões / superfícies ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
}

.section { padding: 40px 0 60px; }

/* ---------- KPIs ---------- */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 30px; }

.kpi {
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 18px;
  background: var(--surface-2);
}

.kpi .k-value { overflow-wrap: break-word; }

.kpi .k-label { font-size: 12px; color: var(--text-muted); margin-bottom: 8px; }
.kpi .k-value { font-family: var(--serif); font-size: 26px; font-variant-numeric: tabular-nums; }
.kpi.gold .k-value { color: var(--gold); }
.kpi .k-sub { font-size: 11.5px; color: var(--text-muted); margin-top: 4px; }

@media (max-width: 860px) { .kpis { grid-template-columns: 1fr 1fr; } }
@media (max-width: 480px) { .kpis { grid-template-columns: 1fr; } }

/* ---------- calendários ---------- */
.cal-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-bottom: 32px; }

.cal-card { border: 1px solid var(--border); border-radius: 12px; overflow: hidden; background: var(--surface); min-width: 0; }

.cal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}

.cal-card.piscina .cal-head { background: var(--amber-soft); }
.cal-card.aquario .cal-head { background: var(--teal-soft); }

.cal-title { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 14.5px; font-family: var(--sans); }
.cal-card.piscina .cal-title { color: var(--amber); }
.cal-card.aquario .cal-title { color: var(--teal); }
.cal-title .sw { width: 8px; height: 8px; border-radius: 2px; }
.cal-card.piscina .sw { background: var(--amber); }
.cal-card.aquario .sw { background: var(--teal); }

.cal-nav { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-muted); }
.cal-nav a { text-decoration: none; color: var(--text-muted); padding: 2px 7px; border-radius: 5px; }
.cal-nav a:hover { color: var(--text); background: var(--surface); }
.cal-nav .cal-month { font-weight: 600; color: var(--text); }

.legend { display: flex; gap: 14px; padding: 10px 16px; font-size: 11.5px; color: var(--text-muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 9px; height: 9px; border-radius: 3px; display: inline-block; }
.legend .liv i { background: var(--green); }
.legend .ocu i { background: var(--red); }

.cal-table { width: 100%; border-collapse: collapse; padding: 0 10px 14px; }
.cal-table th { font-size: 10.5px; color: var(--text-muted); font-weight: 600; padding: 4px 0; text-align: center; }
.cal-table td { text-align: center; padding: 3px; }

.day {
  width: 30px;
  height: 26px;
  margin: 0 auto;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  cursor: pointer;
  position: relative;
  text-decoration: none;
  color: inherit;
  border: none;
  font-family: inherit;
}

.day.livre { background: var(--green-soft); color: var(--green); }
.day.ocupado { background: var(--red-soft); color: var(--red); cursor: default; }
.day.hoje { box-shadow: 0 0 0 2px var(--gold); }
.day.blank { visibility: hidden; cursor: default; }

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

.cal-body { padding: 8px 12px 16px; overflow-x: auto; }

@media (max-width: 400px) {
  .day { width: 26px; height: 24px; font-size: 10.5px; }
  .cal-table th { font-size: 9.5px; }
  .cal-body { padding: 8px 4px 16px; }
}

/* FullCalendar — reskin para casar com a identidade do sistema */
.fc { font-family: var(--sans); }
.fc .fc-toolbar-title { font-family: var(--serif); font-size: 16px !important; color: var(--text); }
.fc .fc-button { background: var(--surface-2) !important; border: 1px solid var(--border) !important; color: var(--text) !important; box-shadow: none !important; }
.fc .fc-button:hover { background: var(--border) !important; }
.fc .fc-button-primary:not(:disabled).fc-button-active { background: var(--gold) !important; border-color: var(--gold) !important; color: #211505 !important; }
.fc .fc-daygrid-day-number { color: var(--text); font-size: 12px; font-variant-numeric: tabular-nums; }
.fc .fc-col-header-cell-cushion { color: var(--text-muted); font-size: 11px; text-transform: uppercase; letter-spacing: .04em; text-decoration: none; }
.fc-theme-standard td, .fc-theme-standard th, .fc-theme-standard .fc-scrollgrid { border-color: var(--border) !important; }
.fc .fc-day-today { background: transparent !important; }
.fc .fc-day-today .fc-daygrid-day-number { box-shadow: 0 0 0 2px var(--gold); border-radius: 6px; }
.fc-event { cursor: pointer; }
.fc-bg-event { opacity: 0.62 !important; }
.fc .fc-daygrid-day-number { font-weight: 600; position: relative; z-index: 1; }

/* ---------- tabelas ---------- */
.table-wrap { border: 1px solid var(--border); border-radius: 12px; overflow: hidden; overflow-x: auto; background: var(--surface); }

table.resv { width: 100%; border-collapse: collapse; font-size: 13.5px; min-width: 720px; }

table.resv th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
  font-weight: 600;
  padding: 12px 16px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}

table.resv td { padding: 13px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.resv tr:last-child td { border-bottom: none; }
table.resv .val { font-variant-numeric: tabular-nums; font-weight: 600; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  font-weight: 700;
  padding: 4px 9px;
  border-radius: 999px;
  white-space: nowrap;
}

.chip.piscina { background: var(--amber-soft); color: var(--amber); }
.chip.aquario { background: var(--teal-soft); color: var(--teal); }
.chip::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.status-pill { font-size: 11px; font-weight: 700; padding: 4px 9px; border-radius: 999px; border: none; cursor: pointer; font-family: inherit; text-decoration: none; display: inline-block; }
.status-pill.ok { background: var(--green-soft); color: var(--green); }
.status-pill.pend { background: var(--red-soft); color: var(--red); }

.row-actions { display: flex; gap: 12px; font-size: 13px; }
.row-actions a { color: var(--text-muted); text-decoration: none; }
.row-actions a:hover { color: var(--text); }

/* ---------- formulários ---------- */
.form-card { max-width: 480px; margin: 48px auto; padding: 34px; }

.field { display: block; margin-top: 16px; }
.field:first-child { margin-top: 0; }

.field label { display: block; font-size: 12.5px; font-weight: 600; color: var(--text-muted); margin-bottom: 6px; }

.field input, .field select {
  width: 100%;
  padding: 11px 13px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  font-size: 14.5px;
  font-family: inherit;
}

.field input:focus, .field select:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-soft);
}

.form-actions { margin-top: 24px; display: flex; flex-direction: column; gap: 10px; }

.back-link { display: block; text-align: center; margin-top: 18px; color: var(--text-muted); text-decoration: none; font-size: 13.5px; }
.back-link:hover { color: var(--text); }

.alert { padding: 12px 16px; border-radius: 8px; font-size: 13.5px; margin-bottom: 18px; }
.alert-error { background: var(--red-soft); color: var(--red); }

/* ---------- rodapé ---------- */
footer.site {
  text-align: center;
  padding: 26px 20px;
  color: var(--text-muted);
  font-size: 12.5px;
  border-top: 1px solid var(--border);
}

footer.site strong { color: var(--gold); }
