/* =========================================================
   Banco de Horas — identidade premium felina
   Mobile-first + desktop. Tema claro/escuro via [data-theme].
   ========================================================= */

/* ---------- tokens ---------- */
:root {
  --accent: #c56e84;          /* rosé / mauve principal */
  --accent-strong: #b05870;
  --gold: #c9a86a;            /* champagne — detalhes premium */
  --extra: #6e9e83;           /* sálvia — positivo/extra */
  --danger: #d76a6a;

  --bg: #fbf6f4;
  --surface: #ffffff;
  --surface-2: #fbf1ee;
  --text: #2c2230;
  --muted: #9a8a93;
  --border: #f1e6e2;
  --shadow: 0 1px 2px rgba(124, 62, 84, .04), 0 14px 38px rgba(124, 62, 84, .08);
  --shadow-sm: 0 1px 2px rgba(124, 62, 84, .05), 0 6px 18px rgba(124, 62, 84, .06);
  --radius: 22px;
  --radius-sm: 14px;

  --paw: url('data:image/svg+xml,%3Csvg xmlns=%22http://www.w3.org/2000/svg%22 width=%2254%22 height=%2254%22 viewBox=%220 0 54 54%22%3E%3Cg fill=%22%23C56E84%22 fill-opacity=%220.05%22%3E%3Cellipse cx=%2227%22 cy=%2233%22 rx=%229.5%22 ry=%227.5%22/%3E%3Cellipse cx=%2214%22 cy=%2220%22 rx=%224%22 ry=%224.6%22/%3E%3Cellipse cx=%2222%22 cy=%2213%22 rx=%224%22 ry=%224.6%22/%3E%3Cellipse cx=%2232%22 cy=%2213%22 rx=%224%22 ry=%224.6%22/%3E%3Cellipse cx=%2240%22 cy=%2220%22 rx=%224%22 ry=%224.6%22/%3E%3C/g%3E%3C/svg%3E');

  --font-serif: "Fraunces", "Georgia", serif;
  --font-sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

[data-theme="dark"] {
  --accent: #e495a7;
  --accent-strong: #d2768c;
  --gold: #d8bc82;
  --extra: #8fbfa3;
  --danger: #e58a8a;

  --bg: #181016;
  --surface: #221821;
  --surface-2: #2a1f29;
  --text: #f5eaef;
  --muted: #b49faa;
  --border: #382a34;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 16px 40px rgba(0, 0, 0, .4);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 22px rgba(0, 0, 0, .32);
}

* { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

svg { width: 1em; height: 1em; display: inline-block; vertical-align: -.125em; }

/* ---------- shell ---------- */
.app { min-height: 100dvh; }

.view {
  max-width: 560px;
  margin: 0 auto;
  padding: 22px 16px calc(104px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.page-head h2 {
  margin: 0;
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: 1.85rem;
  letter-spacing: -.01em;
  font-optical-sizing: auto;
}
.page-head .muted { margin: 0 0 1px; }
.page-head--row { display: flex; align-items: center; gap: 12px; }
.page-head--row h2 { font-size: 1.35rem; }
.page-head--row.between { justify-content: space-between; }

.muted { color: var(--muted); font-size: .9rem; }
.section-title { margin: 10px 0 0; font-size: 1.05rem; font-family: var(--font-serif); font-weight: 600; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.empty { color: var(--muted); text-align: center; padding: 36px 0; }

/* ---------- bottom nav ---------- */
.tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  display: flex;
  justify-content: space-around;
  background: color-mix(in srgb, var(--surface) 86%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  border-top: 1px solid var(--border);
  padding: 9px 6px calc(9px + env(safe-area-inset-bottom));
  z-index: 30;
}
.tabbar__item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  text-decoration: none;
  color: var(--muted);
  font-size: .68rem;
  font-weight: 500;
  padding: 4px 0;
  transition: color .15s ease;
}
.tabbar__item svg { width: 22px; height: 22px; }
.tabbar__item.is-active { color: var(--accent); }

/* ---------- FAB ---------- */
.fab {
  position: fixed;
  right: 18px;
  bottom: calc(82px + env(safe-area-inset-bottom));
  width: 58px; height: 58px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: #fff;
  border-radius: 50%;
  box-shadow: 0 10px 26px rgba(176, 88, 112, .42);
  z-index: 31;
  text-decoration: none;
  transition: transform .12s ease, box-shadow .12s ease;
}
.fab svg { width: 26px; height: 26px; }
.fab:active { transform: scale(.95); }
.fab.hidden { display: none; }

/* ---------- buttons ---------- */
.btn {
  appearance: none;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
  transition: transform .06s ease, background .15s ease, opacity .15s ease, box-shadow .15s ease, filter .15s ease;
}
.btn:active { transform: scale(.99); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn--primary { background: linear-gradient(135deg, var(--accent), var(--accent-strong)); color: #fff; box-shadow: 0 8px 20px rgba(176, 88, 112, .26); }
.btn--ghost { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn--danger { background: var(--danger); color: #fff; }
.btn--block { width: 100%; }
.btn--lg { padding: 17px; font-size: 1.05rem; }
.btn--logout { margin-top: 8px; color: var(--danger); }

.icon-btn {
  appearance: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: 42px; height: 42px;
  display: grid; place-items: center;
  color: var(--text);
  cursor: pointer;
  transition: background .15s ease;
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn--sm { width: 34px; height: 34px; border-radius: 10px; }
.icon-btn--sm svg { width: 17px; height: 17px; }
.icon-btn--danger { color: var(--danger); }
.icon-btn--flip svg { transform: scaleX(-1); }

/* ---------- fields ---------- */
.field { display: flex; flex-direction: column; gap: 7px; border: 0; padding: 0; margin: 0; }
.field > span { font-size: .82rem; font-weight: 600; color: var(--muted); }
.field input, .field textarea, .field select {
  width: 100%;
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 13px 14px;
  outline: none;
  transition: border .15s ease, box-shadow .15s ease;
}
.field input:focus, .field textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 16%, transparent);
}
.field textarea { resize: vertical; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ---------- segmented ---------- */
.seg {
  display: flex;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px;
  gap: 4px;
}
.seg__btn {
  flex: 1;
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 600;
  padding: 10px 8px;
  border-radius: 10px;
  cursor: pointer;
  transition: background .15s ease, color .15s ease;
}
.seg__btn.is-on { background: var(--surface); color: var(--accent); box-shadow: var(--shadow-sm); }

/* ---------- day toggle ---------- */
.day-toggle { display: flex; flex-wrap: wrap; gap: 8px; }
.day-toggle__btn {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font: inherit; font-weight: 600;
  width: 46px; height: 44px;
  border-radius: 12px;
  cursor: pointer;
  transition: all .15s ease;
}
.day-toggle__btn.is-on { background: linear-gradient(135deg, var(--accent), var(--accent-strong)); color: #fff; border-color: transparent; }

/* ---------- cards ---------- */
.cards { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 17px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  box-shadow: var(--shadow-sm);
}
.card__label { font-size: .82rem; color: var(--muted); font-weight: 500; }
.card__value { font-family: var(--font-serif); font-weight: 600; font-size: 1.7rem; letter-spacing: -.01em; }
.card--accent {
  background: linear-gradient(140deg, var(--accent), var(--accent-strong));
  border-color: transparent;
  position: relative;
  overflow: hidden;
}
.card--accent::after {
  content: "";
  position: absolute;
  right: -16px; bottom: -16px;
  width: 86px; height: 86px;
  background: var(--paw);
  background-size: 86px 86px;
  filter: brightness(0) invert(1);
  opacity: .16;
}
.card--accent .card__label, .card--accent .card__value { color: #fff; position: relative; }
.card--skeleton { height: 90px; background: var(--surface-2); animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: .5; } }

/* ---------- recent list ---------- */
.entry-list { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.entry-row {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 13px 15px;
  cursor: pointer;
  transition: border .15s ease, transform .06s ease;
}
.entry-row:hover { border-color: color-mix(in srgb, var(--accent) 40%, var(--border)); }
.entry-row:active { transform: scale(.995); }
.entry-row__note { display: block; font-size: .8rem; color: var(--muted); margin-top: 2px; }
.entry-row__right { display: flex; align-items: center; gap: 8px; }
.entry-row__worked { font-weight: 600; }
.badge { font-size: .72rem; font-weight: 700; padding: 3px 9px; border-radius: 999px; }
.badge--extra { background: color-mix(in srgb, var(--extra) 18%, transparent); color: var(--extra); }

/* ---------- preview ---------- */
.preview {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.preview:empty { display: none; }
.preview__main { display: flex; justify-content: space-between; gap: 8px; }
.preview__cell { display: flex; flex-direction: column; gap: 3px; flex: 1; }
.preview__label { font-size: .74rem; color: var(--muted); }
.preview__cell strong { font-family: var(--font-serif); font-weight: 600; font-size: 1.25rem; }
.preview__cell--extra strong { color: var(--extra); }
.preview__hint { margin: 13px 0 0; font-size: .82rem; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.preview__hint b { color: var(--text); }

/* ---------- search ---------- */
.search { position: relative; display: flex; align-items: center; }
.search svg { position: absolute; left: 13px; color: var(--muted); width: 18px; height: 18px; }
.search input {
  width: 100%; font: inherit; color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px 12px 40px;
  outline: none;
}
.search input:focus { border-color: var(--accent); }

/* ---------- table ---------- */
.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-sm); }
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th { text-align: left; font-size: .7rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 13px 10px; border-bottom: 1px solid var(--border); }
.table td { padding: 12px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table tbody tr:last-child td { border-bottom: 0; }
.cell-note { display: block; font-size: .76rem; color: var(--muted); margin-top: 2px; }
.table td.is-extra { color: var(--extra); font-weight: 600; }
.table tfoot td { font-weight: 700; background: var(--surface-2); border-top: 1px solid var(--border); }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }

/* ---------- calendar ---------- */
.legend { display: flex; gap: 16px; font-size: .8rem; color: var(--muted); flex-wrap: wrap; }
.legend span { display: flex; align-items: center; gap: 6px; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.dot--normal { background: var(--accent); }
.dot--extra { background: var(--extra); }
.dot--empty { background: var(--border); }

.cal { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow-sm); }
.cal__head, .cal__body { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal__head { margin-bottom: 6px; }
.cal__head span { text-align: center; font-size: .72rem; color: var(--muted); font-weight: 600; }
.cal__cell {
  appearance: none;
  aspect-ratio: 1;
  border: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: 12px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; padding: 2px;
  font: inherit; color: var(--text); cursor: default;
}
.cal__cell--blank { border: 0; background: transparent; }
.cal__day { font-size: .82rem; font-weight: 600; }
.cal__worked { font-size: .62rem; color: var(--muted); }
.cal__cell--normal { border-color: color-mix(in srgb, var(--accent) 42%, var(--border)); background: color-mix(in srgb, var(--accent) 12%, var(--surface)); cursor: pointer; }
.cal__cell--extra { border-color: color-mix(in srgb, var(--extra) 45%, var(--border)); background: color-mix(in srgb, var(--extra) 14%, var(--surface)); cursor: pointer; }
.cal__cell--extra .cal__worked { color: var(--extra); }
.cal__cell.is-today { outline: 2px solid var(--accent); outline-offset: 1px; }

/* ---------- auth ---------- */
.auth {
  min-height: 100dvh;
  display: grid; place-items: center;
  padding: 24px;
  background-image: var(--paw);
  background-size: 130px 130px;
}
.auth__card {
  width: 100%; max-width: 400px;
  display: flex; flex-direction: column; gap: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 28px;
  padding: 36px 28px;
  box-shadow: var(--shadow);
}
.auth__brand { text-align: center; }
.auth__cat {
  width: 76px; height: 76px;
  margin: 0 auto 14px;
  display: grid; place-items: center;
  border-radius: 24px;
  background: linear-gradient(140deg, var(--accent), var(--accent-strong));
  box-shadow: 0 10px 26px rgba(176, 88, 112, .32);
}
.auth__cat svg { width: 44px; height: 44px; color: #fff; }
.auth__brand h1 { margin: 4px 0 4px; font-family: var(--font-serif); font-weight: 600; font-size: 1.8rem; letter-spacing: -.01em; }
.auth__brand p { margin: 0; color: var(--muted); }
.auth__form { display: flex; flex-direction: column; gap: 13px; }
.auth__switch { appearance: none; background: none; border: 0; color: var(--accent); font: inherit; font-weight: 600; cursor: pointer; padding: 4px; }
.auth__switch:hover { text-decoration: underline; }

/* ---------- toast ---------- */
.toast {
  position: fixed;
  left: 50%; bottom: calc(104px + env(safe-area-inset-bottom));
  transform: translate(-50%, 16px);
  background: var(--text); color: var(--bg);
  padding: 13px 20px; border-radius: 999px;
  font-size: .9rem; font-weight: 600;
  box-shadow: var(--shadow);
  opacity: 0; transition: opacity .2s ease, transform .2s ease;
  z-index: 60; max-width: 90vw; text-align: center;
}
.toast--show { opacity: 1; transform: translate(-50%, 0); }
.toast--error { background: var(--danger); color: #fff; }

/* ---------- modal ---------- */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(44, 34, 48, .5);
  display: grid; place-items: center;
  padding: 24px; z-index: 50;
  opacity: 0; transition: opacity .2s ease;
}
.modal-overlay--show { opacity: 1; }
.modal {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 24px;
  width: 100%; max-width: 360px;
  box-shadow: var(--shadow);
  transform: translateY(8px); transition: transform .2s ease;
}
.modal-overlay--show .modal { transform: translateY(0); }
.modal__title { margin: 0 0 8px; font-family: var(--font-serif); font-weight: 600; font-size: 1.2rem; }
.modal__message { margin: 0 0 18px; color: var(--muted); }
.modal__actions { display: flex; gap: 10px; }
.modal__actions .btn { flex: 1; }

/* =========================================================
   DESKTOP — layout proposital, não "mobile esticado"
   ========================================================= */
@media (min-width: 768px) {
  .view {
    max-width: 760px;
    padding: 40px 28px 56px;
    gap: 22px;
  }
  .page-head h2 { font-size: 2.2rem; }

  .cards { grid-template-columns: repeat(3, 1fr); gap: 16px; }
  .card { padding: 22px; }
  .card__value { font-size: 1.9rem; }

  /* nav vira uma "pílula" flutuante centralizada */
  .tabbar {
    left: 50%;
    transform: translateX(-50%);
    width: max-content;
    bottom: 22px;
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 8px 10px;
    gap: 6px;
    box-shadow: var(--shadow);
    background: color-mix(in srgb, var(--surface) 92%, transparent);
  }
  .tabbar__item {
    flex-direction: row;
    gap: 8px;
    padding: 10px 18px;
    border-radius: 999px;
    font-size: .85rem;
    transition: background .15s ease, color .15s ease;
  }
  .tabbar__item.is-active { background: color-mix(in srgb, var(--accent) 14%, transparent); }

  .fab {
    right: calc(50% - 380px + 4px);
    bottom: 30px;
  }

  .auth__card { max-width: 440px; padding: 44px 40px; }
}

@media (min-width: 768px) and (max-width: 880px) {
  .fab { right: 28px; }
}

@media (min-width: 1024px) {
  .view { max-width: 880px; }
  .table { font-size: .95rem; }
  .cal { padding: 18px; }
  .cal__head, .cal__body { gap: 8px; }
}

@media (hover: hover) {
  .btn--primary:hover { filter: brightness(1.03); }
}
