:root {
  --bg: #e8eee9;
  --bg-deep: #d5e0d9;
  --surface: rgba(248, 251, 249, 0.94);
  --ink: #12211b;
  --muted: #5a6b63;
  --brand: #0b2e24;
  --brand-soft: #163f33;
  --action: #0f5c66;
  --action-press: #0c4a52;
  --amber: #b86a12;
  --danger: #b42318;
  --ok: #1a7a4c;
  --line: rgba(11, 46, 36, 0.12);
  --shadow: 0 8px 24px rgba(11, 46, 36, 0.08);
  --radius: 14px;
  --nav-h: 64px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
  font-family: "DM Sans", system-ui, sans-serif;
  color: var(--ink);
  background: var(--bg);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background:
    radial-gradient(900px 420px at 0% -5%, rgba(15, 92, 102, 0.1), transparent 55%),
    radial-gradient(700px 380px at 100% 0%, rgba(11, 46, 36, 0.12), transparent 50%),
    linear-gradient(165deg, #eef3f0 0%, #dde8e1 48%, #e7eeea 100%);
  background-attachment: fixed;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { -webkit-tap-highlight-color: transparent; }
a { color: var(--action); }
#app { min-height: 100dvh; }

/* —— Shell —— */
.shell {
  max-width: 720px;
  margin: 0 auto;
  padding: calc(12px + var(--safe-top)) 16px calc(var(--nav-h) + 88px + var(--safe-bottom));
  animation: rise 0.35s ease both;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.brand {
  font-family: "Fraunces", Georgia, serif;
  font-size: 1.55rem;
  font-weight: 700;
  color: var(--brand);
  letter-spacing: -0.03em;
  line-height: 1.15;
}

.today-label {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.88rem;
  text-transform: capitalize;
}

.segment {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0;
  background: rgba(11, 46, 36, 0.06);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 3px;
  margin-bottom: 16px;
}

.segment button {
  border: 0;
  background: transparent;
  border-radius: 9px;
  padding: 9px 8px;
  font-weight: 550;
  font-size: 0.9rem;
  color: var(--muted);
  cursor: pointer;
}

.segment button.active {
  background: var(--surface);
  color: var(--brand);
  box-shadow: 0 1px 3px rgba(11, 46, 36, 0.1);
}

.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  padding: 0 10px calc(8px + var(--safe-bottom));
  background: linear-gradient(180deg, transparent, rgba(232, 238, 233, 0.92) 28%, var(--bg) 70%);
  pointer-events: none;
}

.bottom-nav-inner {
  pointer-events: auto;
  max-width: 720px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 6px;
  box-shadow: var(--shadow);
}

.bottom-nav button {
  border: 0;
  background: transparent;
  border-radius: 12px;
  padding: 8px 4px 6px;
  cursor: pointer;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-size: 0.7rem;
  font-weight: 600;
}

.bottom-nav button svg {
  width: 22px;
  height: 22px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.bottom-nav button.active {
  color: var(--brand);
  background: rgba(11, 46, 36, 0.07);
}

.fab {
  position: fixed;
  right: 18px;
  bottom: calc(var(--nav-h) + 20px + var(--safe-bottom));
  width: 56px;
  height: 56px;
  border-radius: 16px;
  border: 0;
  background: var(--action);
  color: #fff;
  font-size: 1.75rem;
  line-height: 1;
  box-shadow: 0 10px 28px rgba(15, 92, 102, 0.35);
  cursor: pointer;
  z-index: 41;
  animation: fab-in 0.4s 0.1s ease both;
}

.fab:active { background: var(--action-press); transform: scale(0.96); }

/* —— Content —— */
.section {
  margin-bottom: 22px;
  animation: rise 0.4s ease both;
}

.section:nth-child(2) { animation-delay: 0.04s; }
.section:nth-child(3) { animation-delay: 0.08s; }

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin: 0 0 8px;
}

.section-head h2 {
  font-size: 0.75rem;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0;
  font-weight: 650;
}

.section-head .count {
  font-size: 0.8rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.item {
  display: grid;
  grid-template-columns: 10px 1fr auto auto;
  gap: 10px;
  align-items: center;
  padding: 13px 12px;
  cursor: pointer;
  border: 0;
  background: transparent;
  text-align: left;
  width: 100%;
  border-bottom: 1px solid var(--line);
  transition: background 0.15s ease;
}

.item:last-child { border-bottom: 0; }
.item:active { background: rgba(11, 46, 36, 0.04); }
.item.done .item-title { opacity: 0.45; text-decoration: line-through; }
.item.overdue .item-when { color: var(--amber); font-weight: 650; }

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--brand);
}
.dot.pessoal { background: var(--action); }
.dot.empresa { background: var(--brand); }

.item-title {
  font-weight: 600;
  font-size: 0.98rem;
  line-height: 1.25;
}

.item-sub {
  margin-top: 2px;
  font-size: 0.78rem;
  color: var(--muted);
}

.item-when {
  font-size: 0.82rem;
  color: var(--muted);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.item-when.event {
  color: var(--action);
  font-weight: 650;
}

.check-btn {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(11, 46, 36, 0.04);
  color: var(--brand);
  font-size: 1.1rem;
  cursor: pointer;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.check-btn:active { background: rgba(26, 122, 76, 0.15); color: var(--ok); }

.empty {
  padding: 28px 18px;
  color: var(--muted);
  text-align: center;
  background: var(--surface);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
}

.empty strong {
  display: block;
  color: var(--ink);
  margin-bottom: 6px;
  font-weight: 650;
}

.empty .btn { margin-top: 12px; }

.skeleton {
  display: grid;
  gap: 8px;
}

.skel {
  height: 54px;
  border-radius: 12px;
  background: linear-gradient(90deg, rgba(11,46,36,0.06), rgba(11,46,36,0.12), rgba(11,46,36,0.06));
  background-size: 200% 100%;
  animation: shimmer 1.1s ease infinite;
}

/* —— Forms / sheets —— */
.field { margin-bottom: 12px; }
.field label {
  display: block;
  font-size: 0.82rem;
  color: var(--muted);
  margin-bottom: 5px;
  font-weight: 550;
}

.field input, .field select, .field textarea,
.search-bar input {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 12px;
  padding: 12px 13px;
}

.field input:focus, .field select:focus, .field textarea:focus,
.search-bar input:focus {
  outline: 2px solid rgba(15, 92, 102, 0.35);
  border-color: var(--action);
}

.row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.btn {
  border: 0;
  border-radius: 12px;
  padding: 12px 14px;
  background: var(--brand);
  color: #fff;
  cursor: pointer;
  font-weight: 650;
}

.btn.secondary { background: rgba(11, 46, 36, 0.08); color: var(--ink); }
.btn.action { background: var(--action); }
.btn.danger { background: var(--danger); }
.btn.ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
}
.btn.block { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.mode-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  background: rgba(11, 46, 36, 0.06);
  border-radius: 12px;
  padding: 3px;
  margin-bottom: 14px;
}

.mode-tabs button {
  border: 0;
  background: transparent;
  border-radius: 9px;
  padding: 10px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
}

.mode-tabs button.active {
  background: #fff;
  color: var(--brand);
  box-shadow: 0 1px 3px rgba(11, 46, 36, 0.1);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(10, 24, 20, 0.48);
  display: grid;
  align-items: end;
  z-index: 50;
  padding: 10px;
  animation: fade 0.2s ease;
}

.modal {
  width: min(560px, 100%);
  margin: 0 auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px 20px 16px 16px;
  padding: 18px 16px calc(16px + var(--safe-bottom));
  max-height: 92dvh;
  overflow: auto;
  box-shadow: var(--shadow);
  animation: sheet-up 0.28s ease;
}

.modal h3 {
  margin: 0 0 12px;
  font-family: "Fraunces", Georgia, serif;
  color: var(--brand);
  font-size: 1.25rem;
}

.grabber {
  width: 36px;
  height: 4px;
  border-radius: 4px;
  background: rgba(11, 46, 36, 0.18);
  margin: 0 auto 12px;
}

details.more {
  margin-top: 4px;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

details.more summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 550;
  list-style: none;
}

details.more summary::-webkit-details-marker { display: none; }

/* —— Login —— */
.login-wrap {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 28px 20px;
  animation: rise 0.4s ease both;
}

.login-card {
  width: min(420px, 100%);
  padding: 32px 24px 28px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow);
}

.login-card .brand-hero {
  font-family: "Fraunces", Georgia, serif;
  font-size: 2rem;
  font-weight: 700;
  color: var(--brand);
  letter-spacing: -0.03em;
  margin: 0 0 8px;
  line-height: 1.1;
}

.login-card .lead {
  color: var(--muted);
  margin: 0 0 22px;
  font-size: 0.98rem;
  line-height: 1.4;
}

/* —— Lista / busca / cal —— */
.search-sticky {
  position: sticky;
  top: 0;
  z-index: 5;
  padding-bottom: 10px;
  background: linear-gradient(180deg, rgba(232,238,233,0.95) 60%, transparent);
}

.search-bar input { margin-bottom: 8px; }

.filters-toggle {
  width: 100%;
  text-align: left;
  margin-bottom: 8px;
}

.filters-panel {
  display: none;
  gap: 8px;
  margin-bottom: 12px;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.filters-panel.open { display: grid; }

.cal-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.cal-nav strong {
  text-transform: capitalize;
  color: var(--brand);
}

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.cal-head, .cal-day {
  text-align: center;
  font-size: 0.78rem;
  padding: 8px 2px;
  border-radius: 10px;
}

.cal-head { color: var(--muted); font-weight: 650; }

.cal-day {
  background: var(--surface);
  border: 1px solid var(--line);
  min-height: 48px;
  cursor: pointer;
}

.cal-day.muted { opacity: 0.35; }
.cal-day.today {
  border-color: var(--action);
  box-shadow: inset 0 0 0 1px var(--action);
}
.cal-day.selected {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
}
.cal-day .n { font-weight: 700; }
.cal-day .dots {
  display: flex;
  justify-content: center;
  gap: 3px;
  margin-top: 3px;
}
.cal-day .dot-mark {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--action);
}
.cal-day.selected .dot-mark { background: #fff; }
.cal-day .dot-mark.empresa { background: var(--brand-soft); }
.cal-day.selected .dot-mark.empresa { background: #c8e0d6; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--nav-h) + 72px + var(--safe-bottom));
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  padding: 10px 16px;
  border-radius: 12px;
  font-size: 0.88rem;
  z-index: 60;
  box-shadow: var(--shadow);
  animation: fade 0.2s ease;
}

.error { color: var(--danger); font-size: 0.9rem; margin-top: 8px; }
.sub { color: var(--muted); font-size: 0.92rem; }

@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}
@keyframes fade {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes sheet-up {
  from { opacity: 0; transform: translateY(24px); }
  to { opacity: 1; transform: none; }
}
@keyframes fab-in {
  from { opacity: 0; transform: scale(0.85); }
  to { opacity: 1; transform: none; }
}
@keyframes shimmer {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
}

@media (min-width: 720px) {
  .modal-backdrop { align-items: center; }
  .modal { border-radius: 20px; }
}
