/* ============================================================
 *  DESIGN SYSTEM — PIN
 *  Mobile First: estilos base para celular; @media para telas maiores
 * ============================================================ */
:root {
  --bg: #FFFFFF;
  --text: #1A1A1A;
  --primary: #1B1D2E;
  --primary-2: #2A2D45;
  --accent: #F2570A;
  --accent-soft: #FFF1E8;
  --muted: #6B6E80;
  --line: #E6E7EE;
  --surface: #F6F7FA;
  --pos: #1E8E5A;
  --neg: #D23C1E;
  --radius-lg: 16px;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(27, 29, 46, .06), 0 4px 16px rgba(27, 29, 46, .06);
  --nav-h: 64px;
  --font: 'Montserrat', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
body.no-scroll { overflow: hidden; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
p { margin: 0 0 .6em; }
img, svg { display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; background: var(--surface); padding: 1px 5px; border-radius: 4px; word-break: break-all; }
svg { width: 20px; height: 20px; flex-shrink: 0; }

/* ---------- Botões ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 42px; padding: 0 18px;
  border: 1px solid transparent; border-radius: var(--radius);
  font-weight: 600; font-size: 14px; cursor: pointer; text-decoration: none;
  transition: background .15s, border-color .15s, transform .1s;
  white-space: nowrap;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .6; cursor: wait; }
.btn svg { width: 18px; height: 18px; }
.btn--primary { background: var(--primary); color: #fff; }
.btn--primary:hover { background: var(--primary-2); }
.btn--accent { background: var(--accent); color: #fff; }
.btn--accent:hover { background: #DA4D07; }
.btn--outline { background: #fff; border-color: var(--line); color: var(--primary); }
.btn--outline:hover { border-color: var(--primary); }
.btn--danger { background: var(--neg); color: #fff; }
.btn--danger-ghost { background: transparent; color: var(--neg); margin-right: auto; }
.btn--danger-ghost:hover { background: #FDECEA; }
.btn--ghost-light { background: transparent; color: #fff; border-color: rgba(255,255,255,.3); }
.btn--ghost-light:hover { border-color: #fff; }
.btn--sm { min-height: 34px; padding: 0 12px; font-size: 13px; }
.btn--block { width: 100%; }

.icon-btn {
  display: inline-grid; place-items: center; width: 38px; height: 38px;
  border: 0; border-radius: 50%; background: transparent; color: var(--primary); cursor: pointer; font-size: 16px;
}
.icon-btn:hover { background: var(--surface); }
.icon-btn--light { color: #fff; }
.icon-btn--light:hover { background: rgba(255,255,255,.1); }

/* ---------- Formulários ---------- */
.form { display: grid; gap: 14px; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field { display: grid; gap: 6px; }
.field > span { font-size: 13px; font-weight: 600; color: var(--primary); }
.field input, .field select, .field textarea, .input-month, .search input {
  width: 100%; min-height: 44px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: var(--radius); background: #fff;
  font-size: 16px; /* 16px evita zoom automático no iPhone */
}
.field textarea { resize: vertical; min-height: 88px; }
.field input:focus, .field select:focus, .field textarea:focus, .input-month:focus, .search input:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(27,29,46,.08);
}
.check { display: flex; align-items: flex-start; gap: 10px; font-size: 14px; cursor: pointer; }
.check input { width: 18px; height: 18px; margin-top: 2px; accent-color: var(--accent); }

.segmented { display: inline-flex; padding: 3px; background: var(--surface); border-radius: var(--radius); gap: 2px; }
.segmented button { border: 0; background: transparent; padding: 7px 12px; border-radius: 7px; font-size: 13px; font-weight: 600; color: var(--muted); cursor: pointer; }
.segmented button.is-active { background: #fff; color: var(--primary); box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.segmented--full { display: flex; }
.segmented--full button { flex: 1; padding: 10px; }

/* ---------- Estrutura do app ---------- */
.app { min-height: 100vh; }
.main { padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom)); }

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(14px + env(safe-area-inset-top)) 18px 16px;
  background: var(--primary); color: #fff;
}
.topbar__hello { margin: 0; font-size: 12px; opacity: .7; }
.topbar__title { font-size: 21px; font-weight: 700; letter-spacing: -.01em; }
.topbar__actions { display: flex; align-items: center; gap: 6px; }

/* Barra de navegação inferior (celular) */
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(4, 1fr);
  height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--primary);
}
.nav__brand { display: none; }
.nav__item {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: rgba(255,255,255,.6); text-decoration: none; font-size: 11px; font-weight: 600;
}
.nav__item svg { width: 22px; height: 22px; }
.nav__item.is-active { color: #fff; }
.nav__item.is-active::before {
  content: ''; position: absolute; top: 0; left: 30%; right: 30%; height: 3px; border-radius: 0 0 3px 3px; background: var(--accent);
}

.content { padding: 16px; max-width: 1280px; margin: 0 auto; }
.view { animation: fade .2s ease; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.toolbar__group { display: flex; gap: 8px; flex-wrap: wrap; }

.panel { background: #fff; border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 14px; }
.panel__head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.panel__title { font-size: 15px; font-weight: 700; color: var(--primary); margin-bottom: 10px; }
.panel__head .panel__title { margin-bottom: 0; }

.legend { display: flex; gap: 14px; font-size: 13px; color: var(--muted); }
.legend__item { display: inline-flex; align-items: center; gap: 6px; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.dot--primary { background: var(--primary); }
.dot--accent { background: var(--accent); }
.dot--in { background: var(--pos); }
.dot--out { background: var(--neg); }

.tag { display: inline-block; padding: 1px 8px; border-radius: 20px; font-size: 11px; font-weight: 600; background: var(--surface); color: var(--primary); }
.tag--soft { color: var(--muted); }
.tag--accent { background: var(--accent-soft); color: var(--accent); }

.empty { padding: 36px 16px; text-align: center; color: var(--muted); list-style: none; }
.empty .btn { margin-top: 8px; }

/* ---------- Agenda (ajustes do FullCalendar) ---------- */
#calendar { --fc-border-color: var(--line); --fc-today-bg-color: var(--accent-soft); --fc-page-bg-color: #fff;
  --fc-button-bg-color: #fff; --fc-button-border-color: var(--line); --fc-button-text-color: var(--primary);
  --fc-button-hover-bg-color: var(--surface); --fc-button-hover-border-color: var(--line);
  --fc-button-active-bg-color: var(--primary); --fc-button-active-border-color: var(--primary);
  --fc-event-bg-color: var(--primary); --fc-event-border-color: var(--primary); --fc-now-indicator-color: var(--accent);
  font-size: 13px; }
.fc .fc-toolbar-title { font-size: 17px; font-weight: 700; color: var(--primary); }
.fc .fc-toolbar-title::first-letter { text-transform: uppercase; }
.fc .fc-button { font-weight: 600; font-size: 13px; padding: 6px 10px; border-radius: 8px !important; box-shadow: none !important; text-transform: capitalize; }
.fc .fc-button-group { gap: 4px; }
.fc .fc-button-primary:not(:disabled).fc-button-active { color: #fff; }
.fc .fc-toolbar.fc-footer-toolbar { margin-top: 12px; }
.fc .fc-col-header-cell-cushion { font-weight: 600; color: var(--muted); text-transform: capitalize; padding: 8px 2px; }
.fc .fc-daygrid-day-number { color: var(--text); font-weight: 500; padding: 6px; }
.fc .fc-day-today .fc-daygrid-day-number { color: var(--accent); font-weight: 700; }
.fc .fc-daygrid-day { cursor: pointer; }
.fc-event { cursor: pointer; border-radius: 5px; padding: 1px 3px; font-weight: 500; }
.fc-daygrid-dot-event .fc-daygrid-event-dot { border-color: var(--primary); }
.fc .ev--meta { --fc-event-bg-color: var(--accent); --fc-event-border-color: var(--accent); background: var(--accent); border-color: var(--accent); }
.fc .ev--meta .fc-daygrid-event-dot { border-color: var(--accent); }
.fc .ev--concluido { opacity: .55; text-decoration: line-through; }
.fc .ev--cancelado { opacity: .35; text-decoration: line-through; }
.fc .fc-list-event:hover td { background: var(--surface); }

/* ---------- Notas ---------- */
.search { position: relative; flex: 1; min-width: 180px; max-width: 420px; }
.search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); width: 18px; height: 18px; }
.search input { padding-left: 38px; }

.notes { columns: 2 160px; column-gap: 12px; }
.notes .empty { column-span: all; }
.note {
  position: relative; break-inside: avoid; margin-bottom: 12px; padding: 14px;
  background: var(--note-bg, #fff); border: 1px solid var(--line); border-radius: var(--radius);
  cursor: pointer; transition: box-shadow .15s, border-color .15s;
}
.note:hover { box-shadow: var(--shadow); border-color: transparent; }
.note--pinned { border-left: 3px solid var(--accent); }
.note__pin { position: absolute; top: 12px; right: 12px; width: 16px; height: 16px; color: var(--accent); }
.note__title { font-size: 15px; font-weight: 700; margin-bottom: 6px; padding-right: 20px; }
.note__body { font-size: 14px; max-height: 260px; overflow: hidden; }
.note__date { display: block; margin-top: 8px; font-size: 11px; color: var(--muted); }

.rich ul, .rich ol { margin: .3em 0; padding-left: 1.3em; }
.rich p, .rich div { margin: 0 0 .3em; }

.note-editor { background: var(--note-bg, #fff); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.note-editor__title { width: 100%; border: 0; background: transparent; padding: 14px 14px 6px; font-size: 18px; font-weight: 700; }
.note-editor__title:focus { outline: none; }
.rt-toolbar { display: flex; flex-wrap: wrap; gap: 4px; padding: 6px 10px; border-bottom: 1px solid var(--line); }
.rt-toolbar button { border: 0; background: transparent; padding: 5px 9px; border-radius: 6px; font-size: 13px; cursor: pointer; color: var(--primary); }
.rt-toolbar button:hover { background: rgba(27,29,46,.07); }
.note-editor__body { min-height: 200px; max-height: 50vh; overflow-y: auto; padding: 12px 14px; font-size: 15px; }
.note-editor__body:focus { outline: none; }
.note-editor__body:empty::before { content: attr(data-placeholder); color: var(--muted); }
.note-options { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-top: 12px; }
.swatches { display: flex; gap: 8px; }
.swatch { width: 28px; height: 28px; border-radius: 50%; border: 1px solid var(--line); cursor: pointer; }
.swatch.is-active { box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--primary); }
.chip { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: #fff; border-radius: 20px; padding: 6px 12px; font-size: 13px; font-weight: 600; cursor: pointer; color: var(--muted); }
.chip svg { width: 15px; height: 15px; }
.chip.is-active { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }

/* ---------- Finanças ---------- */
.input-month { width: auto; min-width: 170px; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.stat { display: grid; gap: 4px; padding: 14px; border: 1px solid var(--line); border-radius: var(--radius-lg); background: #fff; }
.stat__label { font-size: 12px; font-weight: 600; color: var(--muted); }
.stat__value { font-size: 18px; font-weight: 700; letter-spacing: -.01em; }
.stat__hint { font-size: 12px; opacity: .7; }
.stat:last-child { grid-column: 1 / -1; }
.stat--balance { grid-column: 1 / -1; background: var(--primary); border-color: var(--primary); color: #fff; padding: 18px; }
.stat--balance .stat__label { color: rgba(255,255,255,.7); }
.stat--balance .stat__value { font-size: 28px; }
.is-pos { color: var(--pos); }
.is-neg { color: var(--neg); }
.stat--balance .is-neg { color: #FF9C6B; }

.fin-grid { display: grid; gap: 14px; }
.chart { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; align-items: end; }
.chart__col { display: grid; gap: 6px; justify-items: center; }
.chart__bars { display: flex; align-items: flex-end; gap: 3px; height: 130px; width: 100%; justify-content: center; }
.bar { width: 40%; max-width: 18px; min-height: 2px; border-radius: 4px 4px 0 0; }
.bar--in { background: var(--pos); }
.bar--out { background: var(--neg); }
.chart__label { font-size: 11px; color: var(--muted); }
.chart__col.is-current .chart__label { color: var(--accent); font-weight: 700; }
.chart__legend { grid-column: 1 / -1; display: flex; gap: 14px; justify-content: center; font-size: 12px; color: var(--muted); margin-top: 6px; }
.chart__legend span { display: inline-flex; align-items: center; gap: 6px; }

.tx-list { list-style: none; margin: 0; padding: 0; }
.tx { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 4px; border-bottom: 1px solid var(--line); cursor: pointer; }
.tx:last-child { border-bottom: 0; }
.tx:hover { background: var(--surface); }
.tx__main { display: grid; gap: 2px; min-width: 0; }
.tx__desc { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx__meta { font-size: 12px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.tx__value { font-size: 14px; white-space: nowrap; }

.dropzone {
  display: grid; justify-items: center; gap: 8px; margin: 12px 0; padding: 26px 16px;
  border: 2px dashed var(--line); border-radius: var(--radius-lg); text-align: center; cursor: pointer; color: var(--muted);
  transition: border-color .15s, background .15s;
}
.dropzone:hover, .dropzone.is-over { border-color: var(--accent); background: var(--accent-soft); }
.dropzone input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.dropzone svg { width: 30px; height: 30px; color: var(--accent); }
.dropzone span { font-weight: 600; color: var(--primary); }
.dropzone small { font-weight: 400; color: var(--muted); }

/* ---------- Kanban ---------- */
.kanban {
  display: grid; grid-auto-flow: column; grid-auto-columns: 86%; gap: 12px;
  overflow-x: auto; scroll-snap-type: x mandatory; padding-bottom: 8px; margin: 0 -16px; padding-left: 16px; padding-right: 16px;
}
.kcol { scroll-snap-align: center; display: flex; flex-direction: column; background: var(--surface); border-radius: var(--radius-lg); padding: 10px; min-height: 60vh; }
.kcol__head { display: flex; align-items: center; justify-content: space-between; padding: 2px 4px 10px; }
.kcol__head h2 { font-size: 14px; font-weight: 700; color: var(--primary); display: flex; align-items: center; gap: 8px; }
.kcol[data-status="doing"] .kcol__head h2::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.count { font-size: 12px; font-weight: 600; color: var(--muted); background: #fff; border-radius: 10px; padding: 0 8px; }
.kcol__list { flex: 1; display: flex; flex-direction: column; gap: 8px; min-height: 80px; }
.kcard {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 12px;
  cursor: grab; user-select: none; -webkit-user-select: none;
}
.kcard:hover { box-shadow: var(--shadow); }
.kcard--alta { border-left: 3px solid var(--accent); }
.kcard--ghost { opacity: .4; background: var(--accent-soft); border-style: dashed; }
.kcard--chosen { box-shadow: 0 8px 24px rgba(27,29,46,.18); cursor: grabbing; }
.kcol[data-status="done"] .kcard__title { text-decoration: line-through; color: var(--muted); }
.kcard__title { font-size: 14px; font-weight: 600; }
.kcard__desc { font-size: 13px; color: var(--muted); margin: 4px 0 0; white-space: pre-line; }
.kcard__foot { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 8px; }
.kcard__foot:empty { display: none; }
.due { font-size: 12px; color: var(--muted); font-weight: 500; }
.due.is-late { color: var(--accent); font-weight: 700; }

/* ---------- Modal (vira "gaveta" de baixo no celular) ---------- */
.modal { position: fixed; inset: 0; z-index: 100; display: flex; align-items: flex-end; justify-content: center; }
.modal__backdrop { position: absolute; inset: 0; background: rgba(27,29,46,.5); animation: fade .15s; }
.modal__box {
  position: relative; width: 100%; max-height: 92vh; display: flex; flex-direction: column;
  background: #fff; border-radius: 18px 18px 0 0; animation: up .2s ease;
  padding-bottom: env(safe-area-inset-bottom);
}
@keyframes up { from { transform: translateY(24px); opacity: .6; } to { transform: none; opacity: 1; } }
.modal__head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px 8px; }
.modal__head h2 { font-size: 17px; font-weight: 700; color: var(--primary); }
.modal__body { padding: 8px 18px 16px; overflow-y: auto; }
.modal__foot { display: flex; gap: 8px; justify-content: flex-end; padding: 12px 18px 16px; border-top: 1px solid var(--line); }
.modal__foot:empty { display: none; }
.modal__section { font-size: 14px; font-weight: 700; color: var(--primary); margin: 18px 0 8px; }
.modal__section:first-child { margin-top: 0; }

/* ---------- Avisos ---------- */
.toasts { position: fixed; left: 50%; bottom: calc(var(--nav-h) + 16px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 200; display: grid; gap: 8px; width: min(92vw, 380px); }
.toast { padding: 12px 16px; border-radius: var(--radius); background: var(--primary); color: #fff; font-size: 14px; font-weight: 500; box-shadow: var(--shadow); animation: up .2s; transition: opacity .3s; }
.toast--error { background: var(--neg); }
.toast.is-leaving { opacity: 0; }

/* ---------- Alertas e telas de login/instalação ---------- */
.alert { padding: 12px 14px; border-radius: var(--radius); font-size: 14px; margin: 12px 0; }
.alert--ok { background: #EAF6EC; color: #145C3B; }
.alert--warn { background: var(--accent-soft); color: #8A3406; }
.alert--error { background: #FDECEA; color: #8E2412; }
.token-box { display: block; padding: 12px; margin: 8px 0 12px; background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius); font-size: 13px; user-select: all; }

.auth-page { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: var(--primary); }
.auth-card { width: 100%; max-width: 400px; background: #fff; border-radius: 20px; padding: 28px 24px; }
.auth-card--wide { max-width: 520px; }
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.auth-brand img { border-radius: 10px; }
.auth-brand h1 { font-size: 20px; font-weight: 700; color: var(--primary); }
.auth-brand p { margin: 0; font-size: 13px; color: var(--muted); }
.auth-sub { font-size: 15px; font-weight: 700; color: var(--primary); margin: 18px 0 10px; }
.auth-card .btn--block { margin-top: 6px; }
.checklist { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; font-size: 14px; }
.checklist span { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; font-size: 12px; font-weight: 700; margin-right: 6px; }
.checklist .is-ok span { background: #EAF6EC; color: var(--pos); }
.checklist .is-fail span { background: #FDECEA; color: var(--neg); }

/* ============================================================
 *  TABLET (≥ 700px)
 * ============================================================ */
@media (min-width: 700px) {
  .content { padding: 22px; }
  .stats { grid-template-columns: repeat(4, 1fr); }
  .stat--balance, .stat:last-child { grid-column: auto; }
  .notes { columns: 3 220px; }
  .kanban { grid-auto-columns: 1fr; grid-auto-flow: row; grid-template-columns: repeat(3, 1fr); overflow: visible; margin: 0; padding: 0; }
  .modal { align-items: center; padding: 20px; }
  .modal__box { max-width: 520px; border-radius: 18px; }
  .modal--wide .modal__box { max-width: 720px; }
  .toasts { bottom: 24px; }
}

/* ============================================================
 *  COMPUTADOR (≥ 1000px): menu lateral
 * ============================================================ */
@media (min-width: 1000px) {
  .app { display: grid; grid-template-columns: 232px 1fr; }
  .main { padding-bottom: 0; min-width: 0; }
  .nav {
    position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 4px;
    padding: 20px 14px;
  }
  .nav__brand { display: flex; align-items: center; gap: 10px; color: #fff; font-weight: 700; font-size: 16px; padding: 4px 10px 22px; }
  .nav__brand img { border-radius: 8px; }
  .nav__item { flex-direction: row; justify-content: flex-start; gap: 12px; padding: 12px 14px; border-radius: var(--radius); font-size: 14px; }
  .nav__item:hover { background: rgba(255,255,255,.06); color: #fff; }
  .nav__item.is-active { background: rgba(255,255,255,.08); }
  .nav__item.is-active::before { top: 10px; bottom: 10px; left: 0; right: auto; width: 3px; height: auto; border-radius: 0 3px 3px 0; }
  .topbar { padding: 20px 28px; border-left: 1px solid rgba(255,255,255,.06); }
  .topbar__title { font-size: 24px; }
  .content { padding: 26px 28px; }
  .fin-grid { grid-template-columns: 1fr 1.4fr; align-items: start; }
  .notes { columns: 4 220px; }
}

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