/* ==========================================================================
   Nuvanea — design system
   Clean, neutral surfaces, one accent colour, thin borders and soft shadows.
   ========================================================================== */
:root{
  --bg:#F6F7F9;
  --surface:#FFFFFF;
  --surface-2:#F4F5F7;
  --surface-3:#EBEDF0;
  --border:#E5E7EB;
  --border-strong:#D1D5DB;
  --text:#111827;
  --text-muted:#4B5563;
  --text-faint:#9CA3AF;
  --accent:#4F46E5;
  --accent-strong:#4338CA;
  --accent-soft:#EEF2FF;
  --accent-ring:rgba(79,70,229,.22);
  --success:#059669;
  --success-soft:#ECFDF5;
  --danger:#DC2626;
  --danger-soft:#FEF2F2;
  --warn:#B45309;
  --warn-soft:#FFFBEB;
  --info:#2563EB;
  --info-soft:#EFF6FF;
  --appbar-bg:rgba(255,255,255,.86);
  --overlay:rgba(17,24,39,.38);
  --shadow-xs:0 1px 2px rgba(16,24,40,.05);
  --shadow:0 1px 3px rgba(16,24,40,.06), 0 1px 2px rgba(16,24,40,.04);
  --shadow-lg:0 12px 32px -8px rgba(16,24,40,.18), 0 4px 8px -4px rgba(16,24,40,.06);
  --radius-s:6px;
  --radius-m:10px;
  --radius-l:12px;
  --font:Inter, -apple-system, BlinkMacSystemFont, "Segoe UI Variable Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
@media (prefers-color-scheme: dark){
  :root{
    --bg:#0B0D12;
    --surface:#12151C;
    --surface-2:#181C25;
    --surface-3:#222734;
    --border:#252A35;
    --border-strong:#343B4A;
    --text:#E7E9EE;
    --text-muted:#A3A9B6;
    --text-faint:#6B7280;
    --accent:#818CF8;
    --accent-strong:#A5B4FC;
    --accent-soft:rgba(129,140,248,.14);
    --accent-ring:rgba(129,140,248,.30);
    --success:#34D399;
    --success-soft:rgba(52,211,153,.12);
    --danger:#F87171;
    --danger-soft:rgba(248,113,113,.12);
    --warn:#FBBF24;
    --warn-soft:rgba(251,191,36,.12);
    --info:#60A5FA;
    --info-soft:rgba(96,165,250,.12);
    --appbar-bg:rgba(11,13,18,.82);
    --overlay:rgba(0,0,0,.6);
    --shadow-xs:0 1px 2px rgba(0,0,0,.3);
    --shadow:0 1px 3px rgba(0,0,0,.35);
    --shadow-lg:0 16px 40px -8px rgba(0,0,0,.6);
  }
}

*{ box-sizing:border-box; }
html, body{ margin:0; padding:0; }
html{ -webkit-text-size-adjust:100%; height:100%; }
body{
  background:var(--bg);
  color:var(--text);
  font-family:var(--font);
  font-size:14px;
  line-height:1.45;
  -webkit-font-smoothing:antialiased;
  -moz-osx-font-smoothing:grayscale;
  -webkit-tap-highlight-color:transparent;
  overscroll-behavior-y:none;
  min-height:100%;
  min-height:100dvh;
}
button, .btn, .chip, .view-tabs button, .segmented button, .swatch, .swatch-mini{
  touch-action:manipulation; -webkit-touch-callout:none;
}
:focus-visible{ outline:2px solid var(--accent); outline-offset:2px; }
.mono{ font-variant-numeric:tabular-nums; font-feature-settings:"tnum" 1; letter-spacing:-0.005em; }
[hidden]{ display:none !important; }

/* ---------- layout ---------- */
.app{
  max-width:1160px;
  margin:0 auto;
  padding:0 calc(24px + env(safe-area-inset-right)) calc(56px + env(safe-area-inset-bottom)) calc(24px + env(safe-area-inset-left));
  display:flex;
  flex-direction:column;
  gap:20px;
}

/* Sticky app bar: brand + actions on the first line, section tabs on the second. */
.appbar{
  position:sticky; top:0; z-index:40;
  margin:0 calc(-24px - env(safe-area-inset-right)) 0 calc(-24px - env(safe-area-inset-left));
  padding:calc(12px + env(safe-area-inset-top)) calc(24px + env(safe-area-inset-right)) 0 calc(24px + env(safe-area-inset-left));
  background:var(--appbar-bg);
  -webkit-backdrop-filter:saturate(180%) blur(12px);
  backdrop-filter:saturate(180%) blur(12px);
  border-bottom:1px solid var(--border);
}
.topbar{ display:flex; align-items:center; justify-content:space-between; gap:16px; flex-wrap:wrap; }
.topbar-main{ display:flex; align-items:center; gap:10px; min-width:0; }
.brand-mark{ border-radius:8px; flex:none; box-shadow:var(--shadow-xs); }
.topbar h1{ margin:0; font-size:16px; font-weight:650; letter-spacing:-0.01em; white-space:nowrap; }
.topbar .subtitle{ display:none; }
.subtitle{ margin:0; color:var(--text-muted); font-size:13.5px; }
.topbar-actions{ display:flex; align-items:center; gap:8px; flex-wrap:wrap; }

.utility-menu{ position:relative; flex:0 0 auto; }
.utility-menu > summary{ display:inline-flex; align-items:center; gap:6px; width:auto; list-style:none; cursor:pointer; }
.utility-menu > summary::marker{ content:""; }
.utility-menu > summary::-webkit-details-marker{ display:none; }
.utility-menu[open] > summary{ background:var(--surface-2); }
.utility-menu-panel{
  position:absolute; top:calc(100% + 6px); right:0; z-index:60;
  width:min(260px,calc(100vw - 24px)); max-height:min(70vh,480px); overflow-y:auto; padding:6px;
  display:flex; flex-direction:column; align-items:stretch; gap:2px;
  background:var(--surface); border:1px solid var(--border); border-radius:var(--radius-m); box-shadow:var(--shadow-lg);
}
.utility-menu-panel > .btn, .utility-menu-panel .account-box > .btn{
  width:100%; min-width:0; justify-content:flex-start; text-align:left; white-space:normal;
  border-color:transparent; background:transparent; box-shadow:none; font-weight:500;
}
.utility-menu-panel > .btn:hover, .utility-menu-panel .account-box > .btn:hover{ background:var(--surface-2); }
.utility-menu-panel > .account-box{
  display:flex; flex-direction:column; align-items:stretch; justify-content:flex-start; gap:2px; width:100%; min-width:0;
  margin-top:4px; padding-top:6px; border-top:1px solid var(--border);
}
.utility-menu-panel .sync-status{ color:var(--text-faint); font-size:12px; line-height:1.4; padding:4px 10px 6px; }
.utility-menu-panel .account-session-actions{ display:flex; flex-direction:column; gap:2px; min-width:0; }

/* Section tabs: underline style with icons. */
.view-tabs{
  display:flex; gap:4px; margin-top:10px; overflow-x:auto; -webkit-overflow-scrolling:touch; scrollbar-width:none;
}
.view-tabs::-webkit-scrollbar{ display:none; }
.view-tabs button{
  display:inline-flex; align-items:center; gap:8px;
  font-family:inherit; font-size:13.5px; font-weight:500; padding:10px 12px 11px; margin-bottom:-1px;
  border:none; border-bottom:2px solid transparent; background:transparent; color:var(--text-muted);
  cursor:pointer; white-space:nowrap; border-radius:0; transition:color .15s ease, border-color .15s ease;
}
.view-tabs button svg{ flex:none; opacity:.85; }
.view-tabs button:hover{ color:var(--text); }
.view-tabs button.active{ color:var(--text); border-bottom-color:var(--accent); font-weight:600; }
.view-tabs button.active svg{ color:var(--accent); opacity:1; }

/* ---------- buttons ---------- */
.btn{
  display:inline-flex; align-items:center; justify-content:center; gap:6px;
  font-family:inherit; font-size:13.5px; font-weight:550; line-height:1.2; border-radius:8px; padding:8px 14px;
  border:1px solid transparent; cursor:pointer; white-space:nowrap; min-height:36px;
  transition:background .15s ease, border-color .15s ease, color .15s ease, box-shadow .15s ease;
}
.btn:active{ transform:translateY(0.5px); }
.btn-icon{ flex:none; }
.btn-primary{ background:var(--accent); color:#fff; box-shadow:var(--shadow-xs), inset 0 1px 0 rgba(255,255,255,.12); }
.btn-primary:hover{ background:var(--accent-strong); }
@media (prefers-color-scheme: dark){ .btn-primary{ color:#0B0D12; } }
.btn-ghost{ background:var(--surface); color:var(--text); border-color:var(--border); box-shadow:var(--shadow-xs); }
.btn-ghost:hover{ background:var(--surface-2); border-color:var(--border-strong); }
.btn-danger{ background:var(--surface); color:var(--danger); border-color:var(--border); box-shadow:var(--shadow-xs); }
.btn-danger:hover{ background:var(--danger-soft); border-color:var(--danger); }
.btn-danger.confirming{ background:var(--danger); color:#fff; border-color:var(--danger); }
.btn-sm{ padding:6px 10px; font-size:12.5px; min-height:32px; border-radius:7px; }
.btn:disabled{ opacity:.5; cursor:not-allowed; }
.btn-block{ align-self:stretch; width:100%; }

/* ---------- banners ---------- */
.banner{
  display:flex; align-items:center; justify-content:space-between; gap:12px;
  background:var(--info-soft); border:1px solid transparent; border-radius:var(--radius-m);
  padding:10px 14px; font-size:13px; color:var(--text);
}
.banner button{ flex:none; background:none; border:none; color:var(--accent); font-weight:600; cursor:pointer; font-size:13px; font-family:inherit; padding:4px 0; }
.banner button:hover{ text-decoration:underline; }
.banner.warn{ background:var(--warn-soft); color:var(--text); }
.banner.warn button{ color:var(--warn); }

/* ---------- client filter chips ---------- */
.filters{ display:flex; align-items:center; gap:6px; flex-wrap:wrap; }
.chip{
  display:inline-flex; align-items:center; gap:6px; padding:5px 11px 5px 9px; border-radius:999px;
  background:var(--surface); border:1px solid var(--border); color:var(--text-muted);
  font-family:inherit; font-size:12.5px; font-weight:500; cursor:pointer;
  transition:border-color .15s ease, color .15s ease, background .15s ease;
}
.chip:hover{ border-color:var(--border-strong); color:var(--text); }
.chip.active{ background:var(--text); border-color:var(--text); color:var(--surface); }
.chip .dot{ width:8px; height:8px; border-radius:50%; flex:none; }
.chip .count{ color:var(--text-faint); font-weight:500; font-variant-numeric:tabular-nums; }
.chip.active .count{ color:var(--surface); opacity:.7; }

/* ---------- tasks ---------- */
.task-quickadd{ display:flex; flex-direction:column; gap:12px; }
.task-quickadd-trigger{
  display:flex; align-items:center; gap:10px; width:100%; text-align:left; cursor:text;
  font-family:inherit; font-size:14px; color:var(--text-faint); padding:11px 14px;
  border-radius:var(--radius-m); border:1px solid var(--border); background:var(--surface); box-shadow:var(--shadow-xs);
  transition:border-color .15s ease, box-shadow .15s ease, color .15s ease;
}
.task-quickadd-trigger:hover, .task-quickadd-trigger:focus-visible{ border-color:var(--accent); box-shadow:0 0 0 3px var(--accent-ring); color:var(--text-muted); outline:none; }
.task-quickadd-plus{ display:flex; align-items:center; justify-content:center; width:20px; height:20px; border-radius:6px; background:var(--accent-soft); color:var(--accent); font-weight:700; font-size:15px; line-height:1; flex:none; }
.task-quickadd-preview{ font-size:12px; color:var(--text-faint); padding:2px 2px 0; min-height:16px; }
.task-quickadd-preview.has-parts{ color:var(--accent); font-weight:600; }

.task-toolbar{ display:flex; align-items:center; gap:10px; flex-wrap:wrap; }
.task-toolbar-label{ font-size:12.5px; font-weight:500; color:var(--text-muted); }
.task-grouping{ width:auto; }
.task-grouping button{ min-height:30px; padding:5px 14px; }
.task-toolbar-check{ display:flex; align-items:center; gap:6px; font-size:13px; color:var(--text-muted); cursor:pointer; }
.task-toolbar-check input{ width:16px; height:16px; accent-color:var(--accent); }

.board{ display:flex; flex-direction:column; gap:20px; }
.task-group{ border-radius:var(--radius-l); transition:background .15s ease, outline-color .15s ease; outline:2px dashed transparent; outline-offset:4px; }
.task-group.drag-over{ background:var(--accent-soft); outline-color:var(--accent); }
.task-group-head{
  display:flex; align-items:center; gap:8px; padding:0 2px 8px; width:100%;
  background:none; border:none; font-family:inherit; color:inherit; text-align:left;
}
button.task-group-head{ cursor:pointer; }
button.task-group-head:hover .task-group-title{ color:var(--text); }
.task-group-title{ font-size:13px; font-weight:600; color:var(--text-muted); }
.task-group-chevron{ margin-left:auto; color:var(--text-faint); font-size:11px; }
.task-group.is-collapsed .task-group-head{ padding-bottom:0; }
.task-group-client .task-group-head{ gap:8px; }
.task-group-client .client-dot{ width:9px; height:9px; }
.task-group-title.task-group-client-name{ font-size:14px; color:var(--text); }
.task-group-done-info{ font-size:12px; color:var(--text-faint); }

.task-list{
  display:flex; flex-direction:column; background:var(--surface); border:1px solid var(--border);
  border-radius:var(--radius-l); box-shadow:var(--shadow); overflow:hidden;
}
.task-empty{ padding:14px 16px; font-size:13px; color:var(--text-faint); }
.task-empty-all{ text-align:center; padding:32px; }

.task-row{
  display:flex; align-items:center; gap:12px; padding:11px 16px 11px 13px; cursor:pointer;
  border-top:1px solid var(--border); border-left:3px solid var(--client-color, transparent);
  transition:background .12s ease;
}
.task-row:first-child{ border-top:none; }
.task-row:hover{ background:var(--surface-2); }
.task-row.dragging{ opacity:.45; }
.task-row.flash{ animation:task-flash 1.4s ease-out; }
@keyframes task-flash{ from{ background:var(--accent-soft); } to{ background:transparent; } }

.task-status{
  flex:none; width:20px; height:20px; border-radius:50%; border:1.5px solid var(--border-strong);
  background:transparent; color:#fff; font-size:11px; font-weight:800; line-height:1; padding:0;
  display:flex; align-items:center; justify-content:center; cursor:pointer;
  transition:transform .12s ease, background .15s ease, border-color .15s ease;
}
.task-status:hover{ transform:scale(1.08); border-color:var(--accent); }
.task-status.status-doing{ border-color:var(--warn); background:conic-gradient(var(--warn) 0 50%, transparent 50% 100%); }
.task-status.status-done{ border-color:var(--success); background:var(--success); }

.task-row-main{ flex:1; min-width:0; display:flex; flex-direction:column; gap:2px; }
.task-title{ font-size:14px; font-weight:500; line-height:1.35; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.task-sub{ display:flex; align-items:center; gap:6px; font-size:12.5px; color:var(--text-muted); overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.task-row.task-done .task-title{ text-decoration:line-through; color:var(--text-faint); }
.task-row.task-done .task-sub{ color:var(--text-faint); }
.task-side{ flex:none; display:flex; align-items:center; gap:8px; }

.column-count{ font-size:11.5px; font-weight:600; color:var(--text-muted); background:var(--surface-3); border-radius:999px; padding:1px 7px; font-variant-numeric:tabular-nums; }
.empty-hint{ color:var(--text-faint); font-size:13px; padding:12px 6px; text-align:center; }

.client-dot{ width:7px; height:7px; border-radius:50%; flex:none; }
.client-name{ font-size:12px; font-weight:500; color:var(--text-muted); overflow:hidden; text-overflow:ellipsis; white-space:nowrap; flex:1; min-width:0; }
.client-name.none{ font-style:italic; color:var(--text-faint); }

.priority-badge{ flex:none; font-size:11px; font-weight:600; padding:2px 8px; border-radius:999px; }
.priority-alta{ background:var(--danger-soft); color:var(--danger); }
.priority-media{ background:var(--warn-soft); color:var(--warn); }
.priority-baixa{ background:var(--surface-3); color:var(--text-muted); }

.due{ font-size:12px; font-weight:500; color:var(--text-faint); }
.due.due-today{ color:var(--warn); font-weight:600; }
.due.due-overdue{ color:var(--danger); font-weight:600; }

.icon-btn{
  background:var(--surface); border:1px solid var(--border); color:var(--text-muted); border-radius:7px;
  width:30px; height:30px; font-size:15px; line-height:1; display:flex; align-items:center; justify-content:center;
  cursor:pointer; font-family:inherit; flex:none; box-shadow:var(--shadow-xs); transition:background .15s ease, color .15s ease;
}
.icon-btn:hover{ background:var(--surface-2); color:var(--text); }
.icon-btn:disabled{ opacity:.35; cursor:not-allowed; }

/* ---------- meetings / projects ---------- */
.meetings-view, .projects-view, .expenses-view{ display:flex; flex-direction:column; gap:14px; }
.meetings-list, .projects-list{
  display:flex; flex-direction:column; background:var(--surface); border:1px solid var(--border);
  border-radius:var(--radius-l); box-shadow:var(--shadow); overflow:hidden;
}
.meetings-list:empty, .projects-list:empty{ display:none; }
.meetings-list > .empty-hint, .projects-list > .empty-hint{ padding:28px 16px; }
.meeting-row, .project-row{
  display:flex; align-items:center; gap:14px; background:var(--surface);
  border-top:1px solid var(--border); padding:13px 16px; cursor:pointer; transition:background .12s ease;
}
.meeting-row:first-child, .project-row:first-child{ border-top:none; }
.meeting-row:hover, .project-row:hover{ background:var(--surface-2); }
.meeting-row-date{ flex:none; width:84px; font-size:12.5px; font-weight:500; color:var(--text-muted); font-variant-numeric:tabular-nums; }
.meeting-row-main, .project-row-main{ flex:1; min-width:0; display:flex; flex-direction:column; gap:2px; }
.meeting-row-title, .project-row-title{ font-size:14px; font-weight:550; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.meeting-row-sub, .project-row-sub{ display:flex; align-items:center; gap:6px; font-size:12.5px; color:var(--text-muted); }
.meeting-row-badge{ flex:none; font-size:11.5px; font-weight:600; color:var(--warn); background:var(--warn-soft); border-radius:999px; padding:2px 9px; }
.project-status-badge{ flex:none; font-size:11.5px; font-weight:600; padding:2px 9px; border-radius:999px; }
.project-status-ativo{ background:var(--success-soft); color:var(--success); }
.project-status-pausado{ background:var(--warn-soft); color:var(--warn); }
.project-status-concluido{ background:var(--surface-3); color:var(--text-muted); }
.project-row-docs{ flex:none; font-size:12px; font-weight:500; color:var(--text-faint); }

.documents-list{ display:flex; flex-direction:column; gap:6px; max-height:220px; overflow-y:auto; padding-right:2px; }
.document-item{ display:flex; align-items:center; gap:10px; background:var(--surface); border:1px solid var(--border); border-radius:var(--radius-m); padding:8px 10px; }
.document-icon{ flex:none; width:30px; height:30px; border-radius:7px; background:var(--accent-soft); color:var(--accent); display:flex; align-items:center; justify-content:center; font-size:11px; font-weight:700; }
.document-info{ flex:1; min-width:0; display:flex; flex-direction:column; }
.document-name{ font-size:13px; font-weight:550; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; background:none; border:none; padding:0; text-align:left; color:var(--text); cursor:pointer; font-family:inherit; }
.document-name:hover{ text-decoration:underline; color:var(--accent); }
.document-meta{ font-size:11.5px; color:var(--text-faint); }
.document-add{ display:flex; flex-direction:column; gap:6px; }
.document-add-status{ font-size:12px; color:var(--text-muted); }
.document-add-status.error{ color:var(--danger); }

/* ---------- home ---------- */
.home-view{ display:flex; flex-direction:column; gap:16px; }
.home-view[hidden]{ display:none; }
.home-toolbar{ display:flex; align-items:center; justify-content:space-between; gap:12px; flex-wrap:wrap; }
.home-cards{ display:grid; grid-template-columns:repeat(2, minmax(0,1fr)); gap:16px; }
.home-card{
  display:flex; flex-direction:column; gap:6px; padding:20px 22px; background:var(--surface);
  border:1px solid var(--border); border-radius:var(--radius-l); box-shadow:var(--shadow);
}
.home-card-label{ display:flex; align-items:center; gap:8px; font-size:13px; font-weight:500; color:var(--text-muted); }
.home-card-label::before{ content:""; width:8px; height:8px; border-radius:2px; background:var(--accent); flex:none; }
.home-card-purchase .home-card-label::before{ background:var(--info); }
.home-card-value{ font-size:30px; font-weight:650; letter-spacing:-0.025em; color:var(--text); line-height:1.15; overflow-wrap:anywhere; font-variant-numeric:tabular-nums; }
.home-card-hint{ font-size:12.5px; color:var(--text-faint); }
.home-brands{ background:var(--surface); border:1px solid var(--border); border-radius:var(--radius-l); box-shadow:var(--shadow); padding:18px 22px 8px; }
.home-brands-title{ margin:0 0 6px; font-size:14px; font-weight:600; color:var(--text); }
.home-brand-list{ list-style:none; margin:0; padding:0; display:flex; flex-direction:column; }
.home-brand-row{ display:grid; grid-template-columns:minmax(90px,160px) 1fr auto; align-items:center; gap:16px; padding:11px 0; border-top:1px solid var(--border); }
.home-brand-row:first-child{ border-top:none; }
.home-brand-name{ font-size:13.5px; font-weight:500; color:var(--text); overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.home-brand-bar{ height:6px; border-radius:999px; background:var(--surface-3); overflow:hidden; }
.home-brand-bar-fill{ display:block; height:100%; border-radius:999px; background:var(--accent); }
.home-brand-value{ font-size:13.5px; font-weight:600; color:var(--text); text-align:right; min-width:110px; font-variant-numeric:tabular-nums; }
.home-brand-row.is-empty .home-brand-name, .home-brand-row.is-empty .home-brand-value{ color:var(--text-faint); font-weight:500; }
.home-files{ display:flex; flex-direction:column; gap:8px; padding:14px 16px; background:var(--surface-2); border:1px solid var(--border); border-radius:var(--radius-m); }
.home-import{ display:flex; align-items:center; gap:10px; flex-wrap:wrap; }
.home-import-label{ min-width:72px; font-size:12.5px; font-weight:600; color:var(--text); }
.home-import-status{ font-size:12.5px; color:var(--text-muted); }
.home-import-status.error{ color:var(--danger); }
.home-format-hint{ margin:0; font-size:12px; color:var(--text-faint); }

/* ---------- expenses ---------- */
.expenses-toolbar{ display:flex; align-items:center; gap:10px; flex-wrap:wrap; }
.month-nav{ display:flex; align-items:center; gap:6px; }
.month-nav-label{ font-size:15px; font-weight:600; letter-spacing:-0.01em; min-width:150px; text-align:center; text-transform:capitalize; }
.expenses-export-status{ font-size:12px; color:var(--text-muted); }
.expenses-export-status.error{ color:var(--danger); }
.excel-sync-status{ font-size:12px; color:var(--success); }
.excel-sync-status.error{ color:var(--danger); font-weight:600; }

.expense-cat-badge{ flex:none; font-size:11.5px; font-weight:600; padding:2px 9px; border-radius:999px; min-width:96px; text-align:center; }
.expense-cat-combustivel, .expense-cat-viatura{ background:var(--info-soft); color:var(--info); }
.expense-cat-almocos, .expense-cat-jantares, .expense-cat-refeicoes{ background:var(--warn-soft); color:var(--warn); }
.expense-cat-estadias{ background:var(--accent-soft); color:var(--accent); }
.expense-cat-portagens, .expense-cat-parques{ background:var(--danger-soft); color:var(--danger); }
.expense-cat-material, .expense-cat-outros{ background:var(--surface-3); color:var(--text-muted); }

.expenses-table-wrap{ overflow-x:auto; border:1px solid var(--border); border-radius:var(--radius-l); background:var(--surface); box-shadow:var(--shadow); }
table.expenses-table{ width:100%; min-width:600px; border-collapse:collapse; font-size:13px; font-variant-numeric:tabular-nums; }
.expenses-table th, .expenses-table td{ padding:10px 14px; text-align:right; border-bottom:1px solid var(--border); white-space:nowrap; }
.expenses-table th:first-child, .expenses-table td:first-child{ text-align:left; }
.expenses-table thead th{ font-size:12px; color:var(--text-muted); font-weight:500; background:var(--surface-2); }
.expenses-table tbody tr{ cursor:pointer; transition:background .12s ease; }
.expenses-table tbody tr:hover{ background:var(--surface-2); }
.expenses-table tbody tr:last-child td{ border-bottom:none; }
.expenses-table td.amount-empty{ color:var(--text-faint); }
.expenses-table td.total-cell, .expenses-table th.total-cell{ font-weight:600; border-left:1px solid var(--border); }
.expenses-table tfoot td, .expenses-table tfoot th{ font-weight:600; border-top:1px solid var(--border-strong); border-bottom:none; background:var(--surface-2); }
.expenses-table-empty{ padding:32px 12px; text-align:center; color:var(--text-faint); font-size:13px; }

/* Phone version of the month table (shown only at phone width, see the 480px block). */
.expense-day-cards{ display:none; flex-direction:column; gap:10px; }
.expense-month-total{ display:flex; align-items:baseline; justify-content:space-between; gap:12px; padding:2px 4px; color:var(--text-muted); font-size:13px; }
.expense-month-total strong{ font-size:18px; color:var(--text); }
.expense-day-card{ display:flex; flex-direction:column; gap:10px; width:100%; padding:14px 16px; text-align:left; font:inherit; color:inherit; background:var(--surface); border:1px solid var(--border); border-radius:var(--radius-l); box-shadow:var(--shadow); cursor:pointer; }
.expense-day-card-head{ display:flex; align-items:baseline; justify-content:space-between; gap:12px; }
.expense-day-card-date{ font-weight:600; }
.expense-day-card-total{ font-weight:600; }
.expense-day-card-cats{ display:flex; flex-wrap:wrap; gap:6px; }
.expense-day-card-cats .expense-cat-badge{ min-width:0; }

.day-expenses-list{ display:flex; flex-direction:column; max-height:300px; overflow-y:auto; border:1px solid var(--border); border-radius:var(--radius-m); }
.day-expenses-list > .hint{ padding:14px; }
.day-expense-item{ display:flex; align-items:center; gap:10px; background:var(--surface); border-top:1px solid var(--border); padding:10px 12px; cursor:pointer; transition:background .12s ease; }
.day-expense-item:first-child{ border-top:none; }
.day-expense-item:hover{ background:var(--surface-2); }
.day-expense-desc{ flex:1; min-width:0; font-size:13px; font-weight:500; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.day-expense-amount{ flex:none; font-size:13px; font-weight:600; font-variant-numeric:tabular-nums; }

/* ---------- modals & forms ---------- */
.modal-overlay{
  position:fixed; inset:0; background:var(--overlay); display:flex; align-items:flex-start; justify-content:center;
  padding:calc(48px + env(safe-area-inset-top)) calc(16px + env(safe-area-inset-right)) calc(40px + env(safe-area-inset-bottom)) calc(16px + env(safe-area-inset-left));
  overflow-y:auto; -webkit-overflow-scrolling:touch; z-index:50;
  -webkit-backdrop-filter:blur(2px); backdrop-filter:blur(2px);
  animation:overlay-in .15s ease-out;
}
.modal{
  background:var(--surface); border-radius:14px; border:1px solid var(--border); width:100%; max-width:500px;
  padding:22px 24px; display:flex; flex-direction:column; gap:16px; box-shadow:var(--shadow-lg);
  animation:modal-in .18s ease-out;
}
@keyframes overlay-in{ from{ opacity:0; } to{ opacity:1; } }
@keyframes modal-in{ from{ opacity:0; transform:translateY(6px) scale(.99); } to{ opacity:1; transform:none; } }
.modal-lg{ max-width:600px; }
.modal h2{ margin:0 0 2px; font-size:17px; font-weight:650; letter-spacing:-0.01em; }

.field{ display:flex; flex-direction:column; gap:6px; }
.field label{ font-size:13px; font-weight:550; color:var(--text); }
.field .hint-inline{ font-size:12px; font-weight:400; color:var(--text-faint); }
.field input[type="text"], .field input[type="date"], .field input[type="time"], .field select, .field textarea,
.actions-add input, .client-add-row input[type="text"]{
  font-family:inherit; font-size:16px; line-height:1.3; padding:9px 11px; border-radius:8px;
  border:1px solid var(--border-strong); background:var(--surface); color:var(--text); width:100%;
  box-shadow:var(--shadow-xs); -webkit-appearance:none; appearance:none;
  transition:border-color .15s ease, box-shadow .15s ease;
}
.field select{
  padding-right:34px; cursor:pointer;
  background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%239CA3AF' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat:no-repeat; background-position:right 10px center;
}
.field input::placeholder, .field textarea::placeholder, .actions-add input::placeholder{ color:var(--text-faint); }
.field textarea{ resize:vertical; min-height:64px; }
.field input:focus, .field select:focus, .field textarea:focus, .actions-add input:focus, .client-add-row input:focus{
  outline:none; border-color:var(--accent); box-shadow:0 0 0 3px var(--accent-ring);
}
.field-row{ display:flex; gap:12px; }
.field-row .field{ flex:1; min-width:0; }
.field-error{ margin:2px 0 0; font-size:12.5px; font-weight:500; color:var(--danger); }
.hint{ font-size:12px; color:var(--text-faint); }

/* Segmented control: pill track with a raised selected item. */
.segmented{ display:flex; gap:2px; padding:3px; background:var(--surface-3); border-radius:9px; }
.segmented button{
  flex:1; border:none; border-radius:7px; background:transparent; color:var(--text-muted);
  font-family:inherit; font-size:13px; font-weight:500; padding:7px 8px; min-height:32px; cursor:pointer;
  transition:background .15s ease, color .15s ease, box-shadow .15s ease;
}
.segmented button:hover{ color:var(--text); }
.segmented button.active{ background:var(--surface); color:var(--text); font-weight:600; box-shadow:var(--shadow); }
.segmented-wrap{ flex-wrap:wrap; }
.segmented-wrap button{ flex:1 1 30%; }

.meal-supplier{ display:flex; flex-direction:column; gap:6px; margin-top:10px; }
.meal-supplier[hidden]{ display:none; }
.fuel-fields{ display:flex; flex-direction:column; gap:14px; padding:14px; border:1px solid var(--border); border-radius:var(--radius-m); background:var(--surface-2); }
.fuel-fields[hidden]{ display:none; }
#expenseFleetFields{ display:flex; flex-direction:column; gap:14px; }
#expenseFleetFields[hidden]{ display:none; }

.receipt-scan{ display:flex; align-items:center; gap:10px; margin:0; }
.receipt-scan-status{ color:var(--text-muted); font-size:12px; line-height:1.4; }
.receipt-scan-status.error{ color:var(--danger); }

.modal-actions{ display:flex; justify-content:space-between; align-items:center; gap:10px; margin-top:6px; padding-top:16px; border-top:1px solid var(--border); }
.modal-actions-right{ display:flex; gap:8px; margin-left:auto; }

.client-row{ display:flex; align-items:center; gap:8px; }
.client-row input[type="text"]{ flex:1; }
.swatch{ width:30px; height:30px; border-radius:50%; flex:none; border:2px solid var(--surface); box-shadow:0 0 0 1px var(--border-strong); cursor:pointer; }
.swatch-picker{ display:flex; gap:8px; flex-wrap:wrap; padding:6px 0 2px; }
.swatch-mini{ width:24px; height:24px; border-radius:50%; cursor:pointer; border:2px solid transparent; }
.swatch-mini.selected{ border-color:var(--text); }
.client-add-row{ display:flex; gap:8px; border-top:1px solid var(--border); padding-top:14px; }
.client-add-row input{ flex:1; }

.actions-list{ display:flex; flex-direction:column; gap:6px; max-height:200px; overflow-y:auto; padding-right:2px; }
.action-item{ display:flex; align-items:center; gap:10px; background:var(--surface); border:1px solid var(--border); border-radius:8px; padding:8px 10px; min-height:42px; }
.action-item input[type="checkbox"]{ width:18px; height:18px; flex:none; accent-color:var(--accent); }
.action-text{ flex:1; font-size:13.5px; word-break:break-word; }
.action-text.done{ color:var(--text-faint); text-decoration:line-through; }
.action-item .icon-btn{ width:26px; height:26px; box-shadow:none; border-color:transparent; background:transparent; }
.action-item .icon-btn:hover{ background:var(--surface-2); }
.actions-add{ display:flex; gap:6px; }
.actions-add input{ flex:1; }
.field .actions-add + .field-error, .field select + .actions-add{ margin-top:6px; }

/* ---------- authentication ---------- */
.auth-screen{
  min-height:100vh; min-height:100dvh; display:flex; align-items:center; justify-content:center;
  padding:calc(24px + env(safe-area-inset-top)) calc(16px + env(safe-area-inset-right)) calc(24px + env(safe-area-inset-bottom)) calc(16px + env(safe-area-inset-left));
  background:radial-gradient(1200px 500px at 50% -10%, var(--accent-soft), transparent 70%), var(--bg);
}
.auth-card{
  width:100%; max-width:380px; background:var(--surface); border:1px solid var(--border); border-radius:16px;
  box-shadow:var(--shadow-lg); padding:32px 28px; display:flex; flex-direction:column; gap:14px; text-align:center;
}
.auth-card h1{ margin:4px 0 0; font-size:20px; font-weight:650; letter-spacing:-0.01em; }
.auth-card .subtitle{ font-size:13.5px; color:var(--text-muted); }
.auth-logo{ align-self:center; border-radius:12px; box-shadow:var(--shadow); }
.auth-form{ display:flex; flex-direction:column; gap:12px; text-align:left; }
.auth-form .field input{
  font-family:inherit; font-size:16px; padding:10px 12px; border-radius:8px; border:1px solid var(--border-strong);
  background:var(--surface); color:var(--text); width:100%; -webkit-appearance:none; appearance:none;
}
.auth-form .field input:focus{ outline:none; border-color:var(--accent); box-shadow:0 0 0 3px var(--accent-ring); }
.auth-code-input{ font-size:24px !important; letter-spacing:.35em; text-align:center; }
.auth-providers{ display:flex; flex-direction:column; gap:8px; margin-top:6px; }
.auth-provider{ width:100%; min-height:42px; }
.auth-divider{ display:flex; align-items:center; gap:10px; color:var(--text-faint); font-size:12px; margin:4px 0; }
.auth-divider::before, .auth-divider::after{ content:""; flex:1; height:1px; background:var(--border); }
.auth-sent{ margin:0; font-size:13px; color:var(--text-muted); text-align:center; word-break:break-all; }
.auth-secondary{ display:flex; justify-content:space-between; gap:8px; }
.auth-message{ margin:0; min-height:1.2em; font-size:12.5px; color:var(--text-muted); }
.auth-message.error{ color:var(--danger); }
.auth-ios-hint{ margin:0; text-align:left; }

.account-box{ display:flex; align-items:center; gap:8px; width:100%; justify-content:flex-end; }

/* ---------- responsive ---------- */
@media (max-width:760px){
  .app{ padding-left:calc(16px + env(safe-area-inset-left)); padding-right:calc(16px + env(safe-area-inset-right)); gap:16px; }
  .appbar{
    margin-left:calc(-16px - env(safe-area-inset-left)); margin-right:calc(-16px - env(safe-area-inset-right));
    padding-left:calc(16px + env(safe-area-inset-left)); padding-right:calc(16px + env(safe-area-inset-right));
  }
}
@media (max-width:600px){
  .home-cards{ grid-template-columns:1fr; gap:12px; }
  .home-card{ padding:16px 18px; }
  .home-card-value{ font-size:26px; }
  .home-brands{ padding:14px 16px 4px; }
  .home-brand-row{ grid-template-columns:1fr auto; gap:6px 12px; }
  .home-brand-bar{ grid-column:1 / -1; grid-row:2; }
  .home-brand-value{ min-width:0; }
}

/* Phones: compact header, bottom tab bar with icons. */
@media (max-width:480px){
  /* Room for the bottom tab bar plus the floating "+ Nova …" button, so neither covers the last item. */
  .app{ padding-bottom:calc(150px + env(safe-area-inset-bottom)); }
  /* The floating button already does this; the in-page duplicates would sit right under it. */
  #addMeetingBottomBtn, #addProjectBottomBtn, #addExpenseBottomBtn{ display:none; }
  .expenses-table-wrap{ display:none; }
  .expense-day-cards{ display:flex; }
  /* No blur here: a blurred ancestor would pin the fixed bottom tab bar to the header instead. */
  .appbar{ padding-bottom:10px; background:var(--surface); -webkit-backdrop-filter:none; backdrop-filter:none; }
  .topbar{ gap:10px; }
  .topbar h1{ font-size:15px; }
  .topbar{ flex-wrap:nowrap; }
  .topbar-actions{ display:flex; width:auto; gap:8px; }
  .utility-menu-toggle span{ display:none; }
  .utility-menu-toggle{ width:40px; padding:0; }
  /* "+ Nova …" floats above the bottom tab bar instead of taking a header row. */
  .topbar-actions #newItemBtn{
    position:fixed; z-index:46; right:calc(16px + env(safe-area-inset-right)); bottom:calc(80px + env(safe-area-inset-bottom));
    height:48px; padding:0 20px; border-radius:999px; font-size:15px; box-shadow:var(--shadow-lg);
  }
  .utility-menu-panel{ width:min(260px,calc(100vw - 24px)); }
  .modal-overlay{ padding:calc(12px + env(safe-area-inset-top)) 8px calc(12px + env(safe-area-inset-bottom)); }
  .modal, .modal-lg{ max-width:100%; padding:18px 16px; border-radius:14px; }
  .field-row{ flex-direction:column; gap:14px; }
  .modal-actions{ flex-wrap:wrap; }
  .banner{ align-items:flex-start; }
  .filters{ flex-wrap:nowrap; overflow-x:auto; padding-bottom:2px; scrollbar-width:none; }
  .filters::-webkit-scrollbar{ display:none; }
  .filters .chip{ flex:none; }
  .task-row{ gap:10px; padding:12px 12px 12px 9px; }
  .task-title{ white-space:normal; }
  .task-side{ flex-direction:column; align-items:flex-end; gap:4px; }
  .meeting-row-date{ width:auto; }
  .view-tabs{
    position:fixed; z-index:45; right:0; bottom:0; left:0; margin:0;
    display:flex; justify-content:space-around; gap:0;
    padding:6px 4px calc(6px + env(safe-area-inset-bottom));
    background:var(--appbar-bg);
    -webkit-backdrop-filter:saturate(180%) blur(12px); backdrop-filter:saturate(180%) blur(12px);
    border-top:1px solid var(--border);
  }
  .view-tabs button{
    flex:1 1 0; min-width:0; flex-direction:column; gap:3px; margin:0;
    padding:6px 2px; font-size:10.5px; font-weight:500; border:none; border-radius:10px;
  }
  .view-tabs button svg{ width:22px; height:22px; }
  .view-tabs button.active{ border:none; color:var(--accent); background:var(--accent-soft); }
}
@supports (-webkit-touch-callout:none){
  /* iOS Safari: keep the keyboard from pushing long pages around */
  .modal-overlay{ align-items:flex-start; }
}

/* ---------- clients map (Leaflet) ---------- */
.home-map-card{ background:var(--surface); border:1px solid var(--border); border-radius:var(--radius-l); box-shadow:var(--shadow); padding:18px 22px 20px; display:flex; flex-direction:column; gap:10px; }
.home-map-head{ display:flex; align-items:baseline; justify-content:space-between; gap:12px; flex-wrap:wrap; }
.home-map-head .home-brands-title{ margin:0; }
.home-map-count{ font-size:12.5px; color:var(--text-faint); }
.home-map-hint{ margin:0; }
/* Own stacking context: Leaflet's panes use high z-indexes and must stay under the sticky app bar. */
.home-map, .location-map{ position:relative; z-index:0; isolation:isolate; border:1px solid var(--border); border-radius:var(--radius-m); overflow:hidden; background:var(--surface-2); }
.home-map{ height:380px; }
.location-map{ height:340px; cursor:crosshair; }
.leaflet-container{ font-family:var(--font); font-size:13px; }
.leaflet-container a{ color:var(--accent); }
.leaflet-control-zoom a{ color:var(--text) !important; }
.leaflet-popup-content-wrapper, .leaflet-popup-tip, .leaflet-tooltip{ background:var(--surface); color:var(--text); box-shadow:var(--shadow-lg); }
.leaflet-popup-content-wrapper{ border-radius:10px; border:1px solid var(--border); }
.leaflet-popup-content{ margin:12px 14px; }
.leaflet-tooltip{ border:1px solid var(--border); border-radius:6px; font-weight:600; }
.map-popup{ display:flex; flex-direction:column; gap:3px; min-width:150px; }
.map-popup strong{ font-size:14px; }
.map-popup-address{ color:var(--text-muted); font-size:12.5px; }
.map-popup-meta{ color:var(--text-faint); font-size:12px; }
/* Draggable pin used when choosing a client's location */
.map-pin span{ display:block; width:26px; height:26px; border-radius:50% 50% 50% 0; transform:rotate(-45deg);
  background:var(--accent); border:3px solid #fff; box-shadow:0 3px 8px rgba(16,24,40,.35); }
.client-location-btn{ width:36px; height:36px; }
.client-location-btn.is-set{ color:var(--accent); border-color:var(--accent); background:var(--accent-soft); }
#locationStatus.error{ color:var(--danger); }
@media (prefers-color-scheme: dark){
  /* Darker, softer map tiles in dark mode */
  .leaflet-tile-pane{ filter:brightness(.72) contrast(1.08) saturate(.75); }
  .leaflet-control-zoom a, .leaflet-control-attribution{ background:var(--surface) !important; color:var(--text-muted) !important; border-color:var(--border) !important; }
}
@media (max-width:600px){
  .home-map-card{ padding:14px 16px 16px; }
  .home-map{ height:300px; }
  .location-map{ height:280px; }
}

/* ---------- clients page ---------- */
.clients-view{ display:flex; flex-direction:column; gap:14px; }
.clients-toolbar{ display:flex; align-items:center; gap:10px; flex-wrap:wrap; }
.clients-search{
  flex:1 1 280px; font-family:inherit; font-size:16px; padding:8px 12px; border-radius:8px; border:1px solid var(--border-strong);
  background:var(--surface); color:var(--text); box-shadow:var(--shadow-xs); min-width:0;
  -webkit-appearance:none; appearance:none; transition:border-color .15s ease, box-shadow .15s ease;
}
.clients-search:focus{ outline:none; border-color:var(--accent); box-shadow:0 0 0 3px var(--accent-ring); }
.clients-type-filter{ flex:none; }
.clients-type-filter button{ min-height:30px; padding:5px 12px; }
.clients-list{
  display:flex; flex-direction:column; background:var(--surface); border:1px solid var(--border);
  border-radius:var(--radius-l); box-shadow:var(--shadow); overflow:hidden;
}
.client-card{
  display:flex; align-items:center; gap:14px; cursor:pointer;
  padding:12px 14px 12px 13px; border-top:1px solid var(--border); border-left:3px solid var(--client-color, transparent);
  transition:background .12s ease;
}
.client-card:first-child{ border-top:none; }
.client-card:hover{ background:var(--surface-2); }
.client-card:focus-visible{ outline:2px solid var(--accent); outline-offset:-2px; }
.client-color{ flex:none; width:12px; height:12px; border-radius:50%; }
.client-main{ flex:1; min-width:0; display:flex; flex-direction:column; gap:2px; }
.client-title{ display:flex; align-items:center; gap:8px; min-width:0; }
.client-name{ font-size:14.5px; font-weight:600; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.client-type-badge{ flex:none; font-size:11px; font-weight:600; padding:1px 8px; border-radius:999px; background:var(--warn-soft); color:var(--warn); }
.client-sector{ flex:none; font-size:11.5px; color:var(--text-faint); }
.client-meta{ font-size:12.5px; color:var(--text-muted); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.client-actions{ flex:none; display:flex; gap:6px; }
.client-action{ width:32px; height:32px; text-decoration:none; }
.client-action.is-set{ color:var(--accent); border-color:transparent; background:var(--accent-soft); }

/* Location button inside the client form */
.client-location{
  display:inline-flex; align-items:center; gap:8px; max-width:100%; min-height:40px; padding:8px 12px;
  font-family:inherit; font-size:14px; font-weight:500; color:var(--text-muted); cursor:pointer; text-align:left;
  background:var(--surface); border:1px dashed var(--border-strong); border-radius:8px; transition:all .15s ease;
}
.client-location span{ overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.client-location svg{ flex:none; }
.client-location:hover{ border-color:var(--accent); color:var(--accent); }
.client-location.is-set{ border-style:solid; border-color:transparent; background:var(--accent-soft); color:var(--accent); }
.client-location-wide{ width:100%; }
@media (max-width:600px){
  .clients-type-filter{ flex:1 1 auto; }
  .clients-toolbar #addClientBtn{ display:none; } /* "+ Novo cliente" is already in the top bar */
  .client-sector{ display:none; }
}

/* ---------- sidebar navigation (tablet and desktop) ---------- */
/* Phones keep the compact header + bottom tab bar defined above. */
.sidebar-toggle{ display:none; }
@media (min-width:481px){
  body{ --sidebar-w:236px; }
  body.sidebar-collapsed{ --sidebar-w:68px; }

  .app{
    max-width:none; margin:0;
    padding:28px calc(32px + env(safe-area-inset-right)) calc(56px + env(safe-area-inset-bottom)) calc(var(--sidebar-w) + 32px);
    transition:padding-left .2s ease;
  }
  .app > :not(.appbar){ width:100%; max-width:1120px; }

  .appbar{
    position:fixed; top:0; bottom:0; left:0; z-index:40; width:var(--sidebar-w); margin:0;
    padding:calc(16px + env(safe-area-inset-top)) 12px calc(14px + env(safe-area-inset-bottom)) calc(12px + env(safe-area-inset-left));
    display:flex; flex-direction:column; gap:4px; overflow-y:auto; overflow-x:hidden;
    background:var(--surface); border-bottom:none; border-right:1px solid var(--border);
    -webkit-backdrop-filter:none; backdrop-filter:none;
    transition:width .2s ease;
  }
  /* Let the header pieces become items of the sidebar column, in this order. */
  .topbar, .topbar-actions{ display:contents; }
  .topbar-main{ order:1; padding:2px 6px 14px; gap:10px; }
  .topbar h1{ font-size:15px; }
  #newItemBtn{ order:2; width:100%; margin-bottom:10px; }
  .view-tabs{ order:3; flex-direction:column; gap:2px; margin:0; overflow:visible; }
  .view-tabs button{
    width:100%; justify-content:flex-start; gap:12px; margin:0; padding:9px 10px;
    border:none; border-radius:8px; font-size:14px;
  }
  .view-tabs button:hover{ background:var(--surface-2); }
  .view-tabs button.active{ background:var(--accent-soft); color:var(--accent); border:none; }
  .utility-menu{ order:5; margin-top:auto; }
  .utility-menu > summary{
    width:100%; justify-content:flex-start; gap:12px; padding:9px 10px; font-weight:500;
    background:transparent; border-color:transparent; box-shadow:none; color:var(--text-muted);
  }
  .utility-menu > summary:hover, .utility-menu[open] > summary{ background:var(--surface-2); color:var(--text); }
  .utility-menu-panel{ top:auto; bottom:calc(100% + 6px); left:0; right:auto; }
  .sidebar-toggle{
    order:6; display:flex; align-items:center; gap:12px; width:100%; padding:9px 10px; margin-top:2px;
    font-family:inherit; font-size:13.5px; font-weight:500; color:var(--text-faint); cursor:pointer;
    background:transparent; border:none; border-radius:8px; text-align:left;
  }
  .sidebar-toggle:hover{ background:var(--surface-2); color:var(--text); }
  .sidebar-toggle svg{ flex:none; transition:transform .2s ease; }

  /* Collapsed: icons only, names shown as tooltips. */
  .sidebar-collapsed .topbar h1,
  .sidebar-collapsed .view-tabs button span,
  .sidebar-collapsed .utility-menu-toggle span,
  .sidebar-collapsed .sidebar-toggle span{ display:none; }
  .sidebar-collapsed .topbar-main{ justify-content:center; padding:2px 0 14px; }
  .sidebar-collapsed .view-tabs button,
  .sidebar-collapsed .utility-menu > summary,
  .sidebar-collapsed .sidebar-toggle{ justify-content:center; padding:10px 0; }
  .sidebar-collapsed #newItemBtn{ font-size:0; padding:0; height:40px; }
  .sidebar-collapsed #newItemBtn::before{ content:"+"; font-size:22px; font-weight:500; line-height:1; }
  .sidebar-collapsed .sidebar-toggle svg{ transform:scaleX(-1); }
}

/* ---------- project schedule (cronograma) ---------- */
.schedule-list{ display:flex; flex-direction:column; border:1px solid var(--border); border-radius:var(--radius-m); overflow:hidden; }
.schedule-list > .hint{ padding:12px 14px; }
.schedule-step{ display:flex; align-items:center; gap:10px; padding:9px 10px 9px 12px; border-top:1px solid var(--border); background:var(--surface); }
.schedule-step:first-child{ border-top:none; }
.schedule-step input[type="checkbox"]{ width:18px; height:18px; flex:none; accent-color:var(--success); }
.schedule-step-main{ flex:1; min-width:0; display:flex; flex-direction:column; gap:4px; }
.schedule-step-name{ font-size:14px; font-weight:550; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.step-done .schedule-step-name, .step-done-late .schedule-step-name{ text-decoration:line-through; color:var(--text-faint); font-weight:500; }
.schedule-step-dates{ display:flex; align-items:center; gap:6px; flex-wrap:wrap; }
.schedule-step-dates input{
  font-family:inherit; font-size:16px; padding:3px 6px; border-radius:6px; border:1px solid var(--border);
  background:var(--surface); color:var(--text-muted); -webkit-appearance:none; appearance:none;
}
.schedule-step-dates input:focus{ outline:none; border-color:var(--accent); box-shadow:0 0 0 3px var(--accent-ring); }
.schedule-arrow{ color:var(--text-faint); font-size:12px; }
.schedule-state{ flex:none; font-size:11.5px; font-weight:600; padding:2px 9px; border-radius:999px; white-space:nowrap; }
.state-planned{ background:var(--surface-3); color:var(--text-muted); }
.state-soon{ background:var(--warn-soft); color:var(--warn); }
.state-late{ background:var(--danger-soft); color:var(--danger); }
.state-done{ background:var(--success-soft); color:var(--success); }
.state-done-late{ background:var(--warn-soft); color:var(--warn); }
.schedule-step .icon-btn{ width:26px; height:26px; box-shadow:none; border-color:transparent; background:transparent; }
.schedule-step .icon-btn:hover{ background:var(--surface-2); }
.schedule-add{ display:flex; align-items:flex-end; gap:8px; flex-wrap:wrap; margin-top:8px; }
.schedule-add > input{
  flex:1 1 220px; min-width:0; font-family:inherit; font-size:16px; padding:9px 11px; border-radius:8px;
  border:1px solid var(--border-strong); background:var(--surface); color:var(--text); -webkit-appearance:none; appearance:none;
}
.schedule-date{ display:flex; flex-direction:column; gap:3px; font-size:11.5px; font-weight:500; color:var(--text-muted); }
.schedule-date input{
  font-family:inherit; font-size:16px; padding:7px 8px; border-radius:8px; border:1px solid var(--border-strong);
  background:var(--surface); color:var(--text); -webkit-appearance:none; appearance:none;
}
.schedule-add > input:focus, .schedule-date input:focus{ outline:none; border-color:var(--accent); box-shadow:0 0 0 3px var(--accent-ring); }
.schedule-add .btn{ min-height:38px; }

/* Timeline chart */
.schedule-chart{ border:1px solid var(--border); border-radius:var(--radius-m); background:var(--surface-2); padding:6px 10px 10px; margin-bottom:8px; overflow:hidden; }
.schedule-axis{ position:relative; height:20px; border-bottom:1px solid var(--border); margin-bottom:6px; }
.schedule-tick{ position:absolute; top:2px; transform:translateX(-50%); font-size:11px; color:var(--text-faint); white-space:nowrap; }
.schedule-tick::after{ content:""; position:absolute; left:50%; top:16px; height:4px; border-left:1px solid var(--border-strong); }
.schedule-rows{ position:relative; display:flex; flex-direction:column; gap:5px; padding-top:2px; }
.schedule-row{ position:relative; height:22px; }
.schedule-bar{
  position:absolute; top:0; height:22px; min-width:6px; border-radius:6px; overflow:hidden;
  display:flex; align-items:center; padding:0 7px; box-sizing:border-box;
}
.schedule-bar-label{ font-size:11.5px; font-weight:600; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; color:#fff; }
.bar-planned{ background:var(--accent); }
.bar-soon{ background:var(--warn); }
.bar-late{ background:var(--danger); }
.bar-done{ background:var(--success); opacity:.75; }
.bar-done-late{ background:var(--warn); opacity:.75; }
@media (prefers-color-scheme: dark){ .schedule-bar-label{ color:#0B0D12; } }
.schedule-today{ position:absolute; top:-8px; bottom:-4px; width:0; border-left:2px dashed var(--danger); z-index:1; pointer-events:none; }
.schedule-today span{ position:absolute; top:-12px; left:3px; font-size:10.5px; font-weight:700; color:var(--danger); }

/* Project list: progress and next deadline */
.project-row-schedule{ display:flex; align-items:center; gap:12px; flex-wrap:wrap; margin-top:4px; font-size:12px; }
.project-progress{ display:inline-flex; align-items:center; gap:7px; color:var(--text-muted); }
.project-progress-bar{ width:70px; height:5px; border-radius:999px; background:var(--surface-3); overflow:hidden; }
.project-progress-fill{ display:block; height:100%; background:var(--success); border-radius:999px; }
.project-next{ padding:1px 8px; border-radius:999px; font-weight:600; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; max-width:100%; }
@media (max-width:480px){
  .schedule-step{ flex-wrap:wrap; }
  .schedule-state{ order:3; margin-left:28px; }
  .schedule-add > input{ flex-basis:100%; }
}
/* Compact date inputs inside the schedule (the generic .field rule makes inputs full width). */
.field .schedule-step-dates input[type="date"]{ width:auto; padding:3px 6px; font-size:16px; border-radius:6px; box-shadow:none; border-color:var(--border); color:var(--text-muted); }
.field .schedule-date input[type="date"]{ width:auto; padding:7px 8px; }
.field .schedule-weeks input[type="number"]{
  width:96px; font-family:inherit; font-size:16px; padding:7px 8px; border-radius:8px; border:1px solid var(--border-strong);
  background:var(--surface); color:var(--text); -webkit-appearance:none; appearance:none;
}
.field .schedule-weeks input[type="number"]:focus{ outline:none; border-color:var(--accent); box-shadow:0 0 0 3px var(--accent-ring); }
.schedule-duration{ font-size:11.5px; color:var(--text-faint); margin-left:2px; }

/* ---------- project vertical timeline ---------- */
.project-block + .project-block{ border-top:1px solid var(--border); }
.project-block > .project-row{ border-top:none; }
.project-timeline-toggle{
  align-self:flex-start; margin-top:6px; padding:3px 9px; border-radius:6px; cursor:pointer;
  font-family:inherit; font-size:12px; font-weight:600; color:var(--accent); background:var(--accent-soft); border:none;
}
.project-timeline-toggle:hover{ filter:brightness(.97); }
.ptl{ list-style:none; margin:0; padding:4px 16px 18px; position:relative; }
/* the vertical line runs behind the dots */
.ptl::before{ content:""; position:absolute; top:6px; bottom:18px; left:calc(16px + 74px + 7px); width:2px; background:var(--border); border-radius:2px; }
.ptl-item{ position:relative; display:grid; grid-template-columns:74px 16px minmax(0,1fr); column-gap:12px; align-items:start; padding:6px 0; }
.ptl-date{ text-align:right; font-size:12px; font-weight:600; color:var(--text-muted); padding-top:10px; font-variant-numeric:tabular-nums; white-space:nowrap; }
.ptl-dot{ position:relative; z-index:1; width:16px; height:16px; margin-top:10px; border-radius:50%; background:var(--surface); border:3px solid var(--accent); box-sizing:border-box; }
.ptl-tarefa .ptl-dot{ border-color:var(--info); }
.ptl-reuniao .ptl-dot{ border-color:var(--warn); }
.ptl-item.is-past .ptl-date{ color:var(--text-faint); }
.ptl-card{
  display:flex; flex-direction:column; gap:3px; width:100%; text-align:left; cursor:pointer;
  padding:9px 12px; border-radius:10px; border:1px solid var(--border); background:var(--surface);
  font-family:inherit; color:var(--text); transition:border-color .15s ease, box-shadow .15s ease;
}
.ptl-card:hover{ border-color:var(--border-strong); box-shadow:var(--shadow); }
.ptl-head{ display:flex; align-items:center; gap:8px; min-width:0; flex-wrap:wrap; }
.ptl-kind{ flex:none; font-size:10.5px; font-weight:700; text-transform:uppercase; letter-spacing:.05em; color:var(--accent); }
.ptl-tarefa .ptl-kind{ color:var(--info); }
.ptl-reuniao .ptl-kind{ color:var(--warn); }
.ptl-title{ flex:1 1 160px; min-width:0; font-size:14px; font-weight:600; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.ptl-state{ flex:none; font-size:11px; font-weight:600; padding:1px 8px; border-radius:999px; }
.ptl-detail{ font-size:12.5px; color:var(--text-muted); overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.ptl-points{ list-style:none; margin:4px 0 0; padding:0; display:flex; flex-direction:column; gap:3px; }
.ptl-points li{ display:flex; align-items:center; gap:7px; font-size:12.5px; color:var(--text); }
.ptl-points li.is-done{ color:var(--text-faint); text-decoration:line-through; }
.ptl-check{ flex:none; width:14px; height:14px; border-radius:4px; border:1.5px solid var(--border-strong); font-size:10px; line-height:11px; text-align:center; color:#fff; }
.ptl-points li.is-done .ptl-check{ background:var(--success); border-color:var(--success); }
.ptl-today{ position:relative; display:grid; grid-template-columns:74px 16px minmax(0,1fr); column-gap:12px; align-items:center; padding:4px 0; }
.ptl-today::after{ content:""; grid-column:2 / 4; height:0; border-top:2px dashed var(--danger); }
.ptl-today-label{ grid-column:1; text-align:right; font-size:11px; font-weight:700; color:var(--danger); white-space:nowrap; }
@media (max-width:480px){
  .ptl{ padding:2px 10px 14px; }
  .ptl::before{ left:calc(10px + 54px + 7px); }
  .ptl-item, .ptl-today{ grid-template-columns:54px 16px minmax(0,1fr); column-gap:8px; }
  .ptl-date{ font-size:11px; white-space:normal; }
}

/* ---------- plano de visitas ---------- */
.home-visits{ background:var(--surface); border:1px solid var(--border); border-radius:var(--radius-l); box-shadow:var(--shadow); padding:18px 22px 16px; display:flex; flex-direction:column; gap:10px; }
.home-visits .home-brands-title{ margin:0; }
.visits-day-nav{ display:flex; align-items:center; gap:4px; }
.visits-day-label{ border:none; background:transparent; color:var(--text); font:inherit; font-size:13px; font-weight:600; padding:4px 6px; border-radius:6px; cursor:pointer; min-width:150px; }
.visits-day-label:hover{ background:var(--surface-2); }
.visits-list{ list-style:none; margin:0; padding:0; display:flex; flex-direction:column; gap:6px; }
.visits-empty{ padding:6px 0; }
.visit-row{ display:flex; align-items:center; gap:10px; padding:8px 10px; border:1px solid var(--border); border-radius:var(--radius-m); background:var(--surface); }
.visit-row.is-done{ background:var(--surface-2); }
.visit-row.is-done .visit-name{ color:var(--text-muted); text-decoration:line-through; }
.visit-num{ flex:none; width:26px; height:26px; border-radius:50%; border:2px solid var(--accent); display:grid; place-items:center; font-size:12px; font-weight:700; color:var(--text); }
.visit-row.is-done .visit-num{ border-color:var(--success); color:var(--success); }
.visit-main{ flex:1; min-width:0; }
.visit-name{ border:none; background:none; padding:0; font:inherit; font-weight:600; font-size:14px; color:var(--text); cursor:pointer; text-align:left; max-width:100%; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; display:block; }
.visit-name:hover{ color:var(--accent); }
.visit-sub{ font-size:12px; color:var(--text-faint); overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.visit-leg{ font-size:12px; color:var(--text-muted); }
.visit-leg:empty{ display:none; }
.visit-actions{ flex:none; display:flex; gap:2px; }
.visit-btn{ width:30px; height:30px; font-size:14px; }
.visit-check.is-set{ color:var(--success); }
.visits-add{ display:flex; gap:8px; margin:0; flex-direction:row; align-items:center; }
.visits-add select{ flex:1; min-width:0; }
.visits-actions{ display:flex; gap:8px; flex-wrap:wrap; }
.visits-status{ margin:0; min-height:1em; }
.visits-status.error{ color:var(--danger, #DC2626); }
.visit-pin{ background:var(--accent); color:#fff; border:2px solid #fff; border-radius:50%; display:grid; place-items:center; font:700 12px/1 system-ui, sans-serif; box-shadow:0 1px 4px rgba(0,0,0,.35); }
.visit-pin.is-done{ background:var(--success); }
.map-popup-plan{ margin-top:8px; width:100%; }
.visit-badge{ color:var(--accent); background:var(--accent-soft); }
.visit-badge.is-done{ color:var(--success); background:var(--success-soft); }
@media (max-width:480px){
  .home-visits{ padding:14px 14px 12px; }
  .visits-day-label{ min-width:0; }
  .visit-row{ flex-wrap:wrap; }
  .visit-actions{ width:100%; justify-content:flex-end; }
  .visit-btn{ width:36px; height:36px; }
  .visits-actions .btn{ flex:1; }
}

/* ---------- agenda (Início) ---------- */
.home-agenda{ background:var(--surface); border:1px solid var(--border); border-radius:var(--radius-l); box-shadow:var(--shadow); padding:18px 22px 16px; display:flex; flex-direction:column; gap:10px; margin-bottom:16px; }
.home-agenda .home-brands-title{ margin:0; }
.agenda-days{ display:flex; flex-direction:column; }
.agenda-day{ border-top:1px solid var(--border); padding:7px 0; }
.agenda-day:first-child, .agenda-late + .agenda-day{ border-top:none; }
.agenda-day-head{ display:flex; align-items:center; gap:8px; min-height:28px; }
.agenda-day-name{ font-weight:600; font-size:13.5px; text-transform:capitalize; min-width:70px; }
.agenda-day-date{ font-size:12.5px; color:var(--text-muted); }
.agenda-free{ font-size:12.5px; color:var(--text-faint); }
.agenda-add{ margin-left:auto; width:28px; height:28px; font-size:16px; opacity:.55; }
.agenda-day:hover .agenda-add, .agenda-add:focus-visible{ opacity:1; }
.agenda-day.is-today .agenda-day-name{ color:var(--accent); }
.agenda-day.is-past{ opacity:.7; }
.agenda-list{ display:flex; flex-direction:column; gap:4px; margin-top:4px; }
.agenda-item{ display:flex; align-items:flex-start; gap:10px; width:100%; text-align:left; font:inherit; color:var(--text); background:var(--surface-2); border:1px solid transparent; border-left:3px solid var(--accent); border-radius:var(--radius-s); padding:7px 10px; cursor:pointer; }
.agenda-item:hover{ background:var(--surface-3); }
.agenda-item.agenda-visita{ border-left-color:var(--info); }
.agenda-item.agenda-tarefa{ border-left-color:var(--warn); }
.agenda-item.agenda-etapa{ border-left-color:var(--success); }
.agenda-item.is-done .agenda-title{ text-decoration:line-through; color:var(--text-muted); }
.agenda-time{ flex:none; width:48px; font-size:12.5px; color:var(--text-muted); padding-top:1px; }
.agenda-main{ display:flex; flex-direction:column; gap:2px; min-width:0; flex:1; }
.agenda-title{ font-size:13.5px; overflow-wrap:anywhere; }
.agenda-kind{ font-size:11px; font-weight:600; text-transform:uppercase; letter-spacing:.03em; color:var(--text-muted); margin-right:6px; }
.agenda-sub{ font-size:12px; color:var(--text-muted); display:flex; align-items:center; gap:6px; }
.agenda-flag{ flex:none; font-size:11.5px; color:var(--success); background:var(--success-soft); border-radius:999px; padding:2px 8px; }
.agenda-late{ background:var(--danger-soft); border-radius:var(--radius-m); padding:6px 10px 8px; margin-bottom:4px; }
.agenda-late-head{ cursor:pointer; color:var(--danger); font-weight:600; font-size:13px; padding:2px 0; }
.agenda-late .agenda-item{ margin-top:4px; background:var(--surface); border-left-color:var(--danger); }
.meeting-time-field{ max-width:130px; }
@media (max-width:480px){
  .home-agenda{ padding:14px 14px 12px; }
  .agenda-add{ opacity:1; width:36px; height:36px; }
  .agenda-time{ width:44px; }
  .meeting-time-field{ max-width:none; }
}

/* ---------- resumo antes da visita ---------- */
.brief-kicker{ margin:0 0 2px; font-size:12px; font-weight:600; color:var(--accent); text-transform:uppercase; letter-spacing:.04em; }
.brief-modal h2{ margin:0; }
.brief-meta{ margin:4px 0 12px; font-size:13px; color:var(--text-muted); }
.brief-body{ display:flex; flex-direction:column; gap:14px; }
.brief-heading{ margin:0 0 6px; font-size:13px; font-weight:600; color:var(--text); }
.brief-list{ list-style:none; margin:0; padding:0; display:flex; flex-direction:column; gap:6px; }
.brief-item{ display:flex; flex-direction:column; gap:2px; padding:8px 10px; border:1px solid var(--border); border-left:3px solid var(--border-strong); border-radius:8px; background:var(--surface); }
.brief-item.is-action{ border-left-color:var(--warn, #D97706); }
.brief-item.is-task{ border-left-color:var(--accent); }
.brief-item.is-late{ border-left-color:var(--danger); }
.brief-item.is-project{ border-left-color:var(--success); }
.brief-item-text{ border:none; background:none; padding:0; font:inherit; font-size:14px; font-weight:600; color:var(--text); text-align:left; cursor:pointer; }
span.brief-item-text{ cursor:default; }
.brief-item-text:hover{ color:var(--accent); }
.brief-item-extra{ font-size:12.5px; color:var(--text-muted); white-space:pre-line; }
.brief-item.is-late .brief-item-extra{ color:var(--danger); }
.brief-item.is-meeting .brief-item-text{ font-weight:600; font-size:13px; color:var(--text-muted); }
.brief-item.is-meeting .brief-item-extra{ font-size:13.5px; color:var(--text); }
.visits-arrival-btn{ align-self:flex-start; border:none; background:none; padding:0; font:inherit; font-size:12.5px; color:var(--accent); cursor:pointer; text-decoration:underline; }
.visits-arrival-hint{ margin:0; color:var(--success); }
