:root { --brand: #d91b22; --brand-hover: #b8151c; }
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Poppins', sans-serif; background: #f8f9fa; color: #333; min-height: 100vh; transition: background .2s, color .2s; }

/* ── ESTADO DOTS ── */
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 5px; vertical-align: middle; flex-shrink: 0; }
.dot-pendente { background: #f59e0b; }
.dot-em_curso { background: #3b82f6; }
.dot-entregue { background: #22c55e; }
.dot-problema { background: var(--brand); }

/* ── TOGGLE SWITCH ── */
.pref-row { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; }
.pref-label { font-size: 13px; color: #555; display: flex; align-items: center; gap: 8px; }
.toggle-switch { position: relative; display: inline-block; width: 42px; height: 24px; flex-shrink: 0; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider { position: absolute; cursor: pointer; inset: 0; background: #ccc; border-radius: 24px; transition: .25s; }
.toggle-slider:before { position: absolute; content: ''; height: 18px; width: 18px; left: 3px; bottom: 3px; background: #fff; border-radius: 50%; transition: .25s; }
.toggle-switch input:checked + .toggle-slider { background: var(--brand); }
.toggle-switch input:checked + .toggle-slider:before { transform: translateX(18px); }

/* ── DARK MODE ── */
body.dark-mode {
  background: #141414; color: #e0e0e0;
  --border: #2d3139;
  --card-bg: #1e2328;
  --text: #e5e7eb;
  --bg: #141414;
  --primary: #c0392b;
}
body.dark-mode input, body.dark-mode select, body.dark-mode textarea { background: #2a2a2a; border-color: #3a3a3a; color: #e0e0e0; }
body.dark-mode input[type="date"]  { color-scheme: dark; }
body.dark-mode input[type="email"] { background: #2a2a2a !important; border-color: #3a3a3a !important; color: #e0e0e0 !important; }
body.dark-mode input:focus, body.dark-mode select:focus, body.dark-mode textarea:focus { border-color: var(--brand); }
body.dark-mode input::placeholder, body.dark-mode textarea::placeholder { color: #666; }
/* Login */
body.dark-mode #login-screen { background: #141414; }
body.dark-mode .login-card { background: #1e1e1e; border-color: #2e2e2e; }
body.dark-mode .login-logo span, body.dark-mode .login-card h2 { color: #e0e0e0; }
body.dark-mode .login-card > p { color: #888; }
/* Topbar */
body.dark-mode .topbar { background: #1e1e1e; border-bottom-color: #2e2e2e; }
body.dark-mode .topbar-week-row { border-top-color: #2e2e2e; }
body.dark-mode .topbar-logo { color: #e0e0e0; }
body.dark-mode .topbar-logo-divider { background: #3a3a3a; }
body.dark-mode .user-badge { background: #2a2a2a; color: #e0e0e0; }
body.dark-mode .user-badge:hover { border-color: var(--brand); color: var(--brand); }
body.dark-mode .tbtn { border-color: #3a3a3a; color: #aaa; background: none; }
body.dark-mode .tbtn:hover { background: #2a2a2a; color: #e0e0e0; }
body.dark-mode .tbtn.active { background: #2a2a2a; border-color: #555; color: #e0e0e0; }
body.dark-mode .tbtn.active:hover { background: #333; }
body.dark-mode .add-btn { border-color: #3a3a3a; color: #555; }
body.dark-mode .add-btn:hover { background: #2a2a2a; color: var(--brand); border-color: var(--brand); }
body.dark-mode .week-select { background: #2a2a2a; border-color: #3a3a3a; color: #e0e0e0; }
body.dark-mode .week-nav-label { border-color: #3a3a3a; color: #ccc; }
body.dark-mode .week-nav-label:hover { background: #2a2a2a; border-color: var(--brand); color: var(--brand); }
/* Mobile menu */
body.dark-mode #btn-mobile-menu { border-color: #3a3a3a; color: #aaa; background: #2a2a2a; }
body.dark-mode .mobile-menu { background: #1e1e1e; border-color: #2e2e2e; box-shadow: 0 8px 24px rgba(0,0,0,.4); }
body.dark-mode .mobile-menu button { color: #ccc; }
body.dark-mode .mobile-menu button:hover { background: #2a2a2a; }
body.dark-mode .mobile-menu button i { color: #666; }
/* Tabs */
body.dark-mode .tabs-bar { background: #1e1e1e; border-bottom-color: #2e2e2e; }
body.dark-mode .tab-btn { color: #888; }
body.dark-mode .tab-btn:hover { color: #e0e0e0; }
body.dark-mode .tab-badge { background: #2a2a2a; color: #888; }
/* Stats */
body.dark-mode .stats-bar { background: transparent; }
body.dark-mode .stat-pill { background: #1e1e1e; border-color: #2e2e2e; color: #888; }
body.dark-mode .stat-pill strong { color: #e0e0e0; }
/* Board */
body.dark-mode .day-col { background: #1e1e1e; border-color: #2e2e2e; }
body.dark-mode .day-header { color: #666; border-bottom-color: #2a2a2a; }
/* Delivery cards */
body.dark-mode .delivery-card { background: #252525; border-color: #2e2e2e; }
body.dark-mode .delivery-card.entregue { background: #1e1e1e; border-color: #2a2a2a; border-left-color: #22c55e; opacity: 1; }
body.dark-mode .delivery-card.entregue .dc-client { color: #4ade80; }
body.dark-mode .dc-client { color: #e0e0e0; }
body.dark-mode .dc-addr { color: #666; }
body.dark-mode .dc-notes { border-top-color: #2e2e2e; color: #666; }
body.dark-mode .dc-val { color: #f87171; }
body.dark-mode .dc-entregue-badge { background: #0a1e0a; color: #4ade80; }
body.dark-mode .dc-call-link { color: #4ade80; }
body.dark-mode .dc-meta, body.dark-mode .dc-city { color: #888; }
body.dark-mode .card-edit, body.dark-mode .card-del { color: #555; }
body.dark-mode .card-edit:hover { color: #3b82f6; background: rgba(59,130,246,.1); }
body.dark-mode .card-del:hover { color: var(--brand); background: rgba(217,27,34,.1); }
body.dark-mode .drag-handle { color: #444; }
/* Enc cards */
body.dark-mode .enc-panel { background: transparent; }
body.dark-mode .enc-card { background: #1e1e1e; border-color: #2a2a2a; }
body.dark-mode .enc-card--pendente  { background: #1e1e1e; border-left-color: #f59e0b; }
body.dark-mode .enc-card--em_curso  { background: #1e1e1e; border-left-color: #3b82f6; }
body.dark-mode .enc-card--entregue  { background: #1e1e1e; border-left-color: #22c55e; }
body.dark-mode .enc-card--problema  { background: #1e1e1e; border-left-color: var(--brand); }
body.dark-mode .enc-card-title { color: #e0e0e0; }
body.dark-mode .enc-card--pendente .enc-card-title  { color: #fbbf24; }
body.dark-mode .enc-card--em_curso .enc-card-title  { color: #60a5fa; }
body.dark-mode .enc-card--entregue .enc-card-title  { color: #4ade80; }
body.dark-mode .enc-card--problema .enc-card-title  { color: #f87171; }
body.dark-mode .enc-card-previsao { color: #888; }
body.dark-mode .enc-card-notes { color: #666; }
body.dark-mode .enc-audit { color: #555; border-top-color: #2a2a2a; }
body.dark-mode .enc-audit strong { color: #666; }
body.dark-mode .enc-btn-icon { color: #555; }
body.dark-mode .enc-btn-icon:hover { color: var(--brand); background: rgba(217,27,34,.1); }
body.dark-mode .enc-mes-label { color: #666; }
body.dark-mode .enc-search { background: #2a2a2a; border-color: #3a3a3a; color: #e0e0e0; }
body.dark-mode .enc-search-icon { color: #555; }
body.dark-mode .enc-search-wrap:focus-within .enc-search-icon { color: var(--brand); }
body.dark-mode .enc-filter-estado { background: #2a2a2a; border-color: #3a3a3a; color: #e0e0e0; }
body.dark-mode .enc-empty { color: #555; }
body.dark-mode .enc-layout-switcher,
body.dark-mode .board-layout-switcher { background: #2a2a2a; }
body.dark-mode .enc-layout-btn { color: #555; }
body.dark-mode .enc-layout-btn:hover { color: #aaa; background: #333; }
body.dark-mode .enc-layout-btn.active { background: #1e1e1e; color: var(--brand); }
/* Modais */
body.dark-mode .modal { background: #1e1e1e; border-color: #2e2e2e; }
body.dark-mode .modal h3 { color: #e0e0e0; }
body.dark-mode .modal-section { color: #888; border-bottom-color: #2e2e2e; }
body.dark-mode .form-group label { color: #888; }
body.dark-mode .btn-cancel { background: #2a2a2a; border-color: #3a3a3a; color: #aaa; }
body.dark-mode .btn-cancel:hover { background: #333; }
/* Profile modal */
body.dark-mode .profile-avatar { background: #3a3a3a; color: #e0e0e0; }
body.dark-mode .profile-header { border-bottom-color: #2e2e2e; }
body.dark-mode .profile-header .p-name { color: #e0e0e0; }
body.dark-mode .profile-header .p-user { color: #666; }
body.dark-mode .profile-header .p-cargo { background: rgba(217,27,34,.15); color: var(--brand); }
body.dark-mode .profile-tabs { background: #2a2a2a; }
body.dark-mode .profile-tab.active { background: #1e1e1e; }
body.dark-mode .pref-label { color: #aaa; }
body.dark-mode .alert-box.success { background: #0a1e0a; color: #4ade80; }
body.dark-mode .alert-box.error   { background: #2a0a0a; color: #f87171; }
body.dark-mode .users-create { background: #1a1a1a; border-color: #2a2a2a; }
body.dark-mode .pref-label { color: #aaa; }
body.dark-mode .toggle-slider { background: #3a3a3a; }
/* Confirm modal */
body.dark-mode .confirm-title { color: #e0e0e0; }
body.dark-mode .confirm-body { color: #aaa; }
body.dark-mode .confirm-sub { color: #666; }
body.dark-mode .confirm-msg { color: #ccc; }
body.dark-mode .confirm-warn { color: var(--brand); }
body.dark-mode .confirm-type-label { color: #666; }
body.dark-mode .confirm-type-label code { background: #2a2a2a; border-color: #3a3a3a; color: #e0e0e0; }
body.dark-mode .confirm-input { background: #2a2a2a; border-color: #3a3a3a; color: #e0e0e0; }
body.dark-mode .confirm-input.ok { border-color: #16a34a !important; }
/* Semana banner */
body.dark-mode .week-banner { background: #2a2a2a; border-color: #3a3a3a; color: #aaa; }
/* Detalhe modal */
body.dark-mode .detalhe-cliente { color: #e0e0e0; }
body.dark-mode .detalhe-meta, body.dark-mode .detalhe-row { color: #ccc; }
body.dark-mode .detalhe-label { color: #888; }
body.dark-mode .detalhe-audit { color: #777; border-top-color: #2a2a2a; }
body.dark-mode .detalhe-audit strong { color: #aaa; }
body.dark-mode .detalhe-notas-label { color: #888; border-bottom-color: #2a2a2a; }
body.dark-mode #detalhe-entregar-zone { border-top-color: #2a2a2a; }
body.dark-mode .btn-entregar { background: #15803d; }
body.dark-mode .btn-entregar:hover { background: #166534; }
body.dark-mode .detalhe-maps-link { color: #60a5fa; }
body.dark-mode .detalhe-call-link { color: #4ade80; }
body.dark-mode .detalhe-valor { color: #f87171; }
body.dark-mode .badge-entregue { background: #0a1e0a; color: #4ade80; }
body.dark-mode .detalhe-preview-img { border-color: #2e2e2e; background: #1a1a1a; }
body.dark-mode .detalhe-notas { background: #1e1e1e; border-color: #2e2e2e; color: #ccc; }
body.dark-mode .anexo-chip { background: #222; border-color: #333; color: #bbb; }
body.dark-mode .anexo-chip:hover { background: rgba(217,27,34,.12); border-color: var(--brand); color: var(--brand); }
body.dark-mode .anexo-icon { color: #555; }
body.dark-mode .anexo-size { color: #555; }
body.dark-mode .dc-file-chip { background: #222; color: #888; }
body.dark-mode .file-chip { background: #2a2a2a; border-color: #3a3a3a; color: #aaa; }
body.dark-mode .file-chip button { color: #555; }
body.dark-mode .file-chip button:hover { color: var(--brand); }
body.dark-mode .file-zone { border-color: #3a3a3a; color: #555; }
body.dark-mode .file-zone:hover { border-color: var(--brand); color: var(--brand); background: rgba(217,27,34,.05); }
body.dark-mode .dc-ver-mais { background: #2a2a2a; border-color: #3a3a3a; color: #aaa; }
body.dark-mode .dc-ver-mais:hover { background: rgba(217,27,34,.12); border-color: var(--brand); color: var(--brand); }
body.dark-mode .delivery-card.entregue .dc-ver-mais { background: #252525; border-color: #2a3a2a; color: #4ade80; }
body.dark-mode .delivery-card.entregue .dc-ver-mais:hover { background: #2a2a2a; border-color: #22c55e; }
/* Estado pills dropdown - dark mode */
body.dark-mode .pill-count { background: #2a2a2a; color: #666; }
body.dark-mode .estado-pills-dropdown { background: #1e1e1e; border-color: #3a3a3a; box-shadow: 0 4px 16px rgba(0,0,0,.4); }
body.dark-mode .estado-pill { background: #2a2a2a; border-color: #3a3a3a; color: #aaa; }
body.dark-mode .estado-pill:hover { background: #333; color: #e0e0e0; }
body.dark-mode .estado-pill.active[data-estado=""],
body.dark-mode .estado-pill.active[data-contacto=""],
body.dark-mode .estado-pill.active[data-periodo=""] { background: #333; border-color: #555; color: #e0e0e0; }
body.dark-mode .estado-pill.active[data-contacto]:not([data-contacto=""]),
body.dark-mode .estado-pill.active[data-periodo]:not([data-periodo=""]) { background: #3a1515; border-color: var(--brand); color: #ff6b6b; }
body.dark-mode .estado-pill.active[data-estado="pendente"] { background: #2a2000; border-color: #f59e0b; color: #fbbf24; }
body.dark-mode .estado-pill.active[data-estado="em_curso"] { background: #0a1a2e; border-color: #3b82f6; color: #60a5fa; }
body.dark-mode .estado-pill.active[data-estado="entregue"] { background: #0a1e0a; border-color: #22c55e; color: #4ade80; }
body.dark-mode .estado-pill.active[data-estado="problema"] { background: #2a0a0a; border-color: var(--brand); color: #f87171; }
/* File preview modal */
body.dark-mode .file-preview-wrap { background: #1e1e1e; }
body.dark-mode .file-preview-header { background: #1e1e1e; border-bottom-color: #2e2e2e; }
body.dark-mode .file-preview-title { color: #e0e0e0; }
body.dark-mode .file-preview-btn { background: #2a2a2a; border-color: #3a3a3a; color: #aaa; }
body.dark-mode .file-preview-btn:hover { background: #333; border-color: #555; color: #e0e0e0; }
body.dark-mode .file-preview-close:hover { background: rgba(217,27,34,.15); border-color: var(--brand); color: var(--brand); }
body.dark-mode #docx-preview-container { background: #141414; }
body.dark-mode #docx-preview-container .docx-wrapper { background: #141414 !important; }
body.dark-mode #docx-preview-container .docx-wrapper > section.docx { background: #252525; box-shadow: 0 2px 16px rgba(0,0,0,.5); }
body.dark-mode .docx-preview-loading { color: #555; }
/* Search */
body.dark-mode .search-results { background: #1e1e1e; border-color: #2e2e2e; }
body.dark-mode .sr-item { border-bottom-color: #2a2a2a; color: #ccc; }
body.dark-mode .sr-item:hover { background: #2a2a2a; }
body.dark-mode .sr-label { color: #888; }
body.dark-mode .search-group-label { color: #555; border-bottom-color: #2a2a2a; }
body.dark-mode .search-result { color: #ccc; }
body.dark-mode .search-result:hover { background: #2a2a2a; border-color: #333; }
body.dark-mode .sr-title { color: #e0e0e0; }
body.dark-mode .sr-meta { color: #666; }
body.dark-mode .sr-week { color: #555; }
body.dark-mode .sr-pill { background: #2a2a2a; color: #888; }
body.dark-mode .sr-pill-entregue { background: #0a1e0a; color: #4ade80; }
body.dark-mode .search-empty { color: #555; }
/* Users list */
body.dark-mode .user-row { border-bottom-color: #2a2a2a; }
body.dark-mode .user-row-name { color: #e0e0e0; }
body.dark-mode .user-row-meta { color: #888; }
body.dark-mode .user-item { background: #222; border-color: #2e2e2e; }
body.dark-mode .user-item-name { color: #e0e0e0; }
body.dark-mode .user-item-username { color: #555; }
body.dark-mode .user-item-cargo { background: #2a2a2a; color: #666; }
body.dark-mode .user-item-cargo.cargo-admin      { background: rgba(217,27,34,.15); color: var(--brand); }
body.dark-mode .user-item-cargo.cargo-gestor     { background: #2a2000; color: #fbbf24; }
body.dark-mode .user-item-cargo.cargo-utilizador { background: #0a1e2a; color: #60a5fa; }
body.dark-mode .user-item-del { color: #3a3a3a; }
/* Footer */
body.dark-mode .app-footer { color: #555; border-top-color: #2e2e2e; }

/* ── INPUTS ── */
input, select, textarea {
  padding: 8px 10px; border: 0.5px solid #ddd; border-radius: 6px;
  font-family: 'Poppins', sans-serif; font-size: 13px; color: #333;
  background: #fff; transition: border-color .15s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); }
textarea { resize: vertical; }

/* ── LOGIN ── */
#login-screen { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: #f8f9fa; padding: 2rem; }
.login-card { background: #fff; border: 0.5px solid #e5e5e5; border-radius: 12px; padding: 2.5rem; width: 100%; max-width: 360px; box-shadow: 0 8px 24px rgba(0,0,0,.06); }
.login-logo { display: flex; align-items: center; gap: 10px; margin-bottom: 1.5rem; }
.icon-box { width: 36px; height: 36px; background: var(--brand); border-radius: 8px; display: flex; align-items: center; justify-content: center; color: white; font-size: 18px; }
.login-logo span { font-size: 16px; font-weight: 600; color: #333; }
.login-card h2 { font-size: 18px; font-weight: 500; color: #333; margin-bottom: .25rem; }
.login-card > p { font-size: 13px; color: #777; margin-bottom: 1.5rem; }
.form-group { margin-bottom: .85rem; }
.form-group label { display: block; font-size: 11px; font-weight: 600; color: #777; margin-bottom: 4px; text-transform: uppercase; letter-spacing: .04em; }
.form-group input, .form-group select, .form-group textarea { width: 100%; }
.btn-primary { width: 100%; padding: 10px; background: var(--brand); color: white; border: none; border-radius: 6px; font-size: 14px; font-weight: 600; cursor: pointer; font-family: 'Poppins', sans-serif; margin-top: .5rem; transition: background .2s; }
.btn-primary:hover { background: var(--brand-hover); }
/* btn-primary inside modal-actions: auto width, no margin */
.modal-actions .btn-primary { width: auto; margin-top: 0; padding: 7px 18px; font-size: 13px; display: inline-flex; align-items: center; gap: 6px; }
.login-error { background: #fef2f2; color: #b91c1c; border-radius: 6px; padding: 8px 12px; font-size: 13px; margin-bottom: 1rem; display: none; }
.login-credits { text-align: center; font-size: 11px; color: #bbb; margin-top: 1.25rem; position: absolute; bottom: 1.25rem; left: 0; right: 0; }

/* ── APP ── */
#app-screen { display: none; min-height: 100vh; display: none; flex-direction: column; }

/* ── TOPBAR ── */
.topbar { display: flex; align-items: center; justify-content: space-between; padding: .75rem 1.25rem; background: #fff; border-bottom: 0.5px solid #e5e5e5; gap: 10px; flex-wrap: wrap; }
.topbar-left { display: flex; align-items: center; gap: 7px; flex: 1; order: 1; }
.topbar-week-row { display: flex; align-items: center; justify-content: center; gap: 7px; flex: 1; order: 2; }
.topbar-right { display: flex; align-items: center; gap: 8px; flex: 1; justify-content: flex-end; order: 3; }
.day-expand-hint { display: none; }
.topbar-logo { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; color: #333; white-space: nowrap; }
.topbar-logo .icon-box { width: 28px; height: 28px; border-radius: 6px; font-size: 14px; flex-shrink: 0; }
.topbar-company-logo { height: 32px; width: auto; object-fit: contain; flex-shrink: 0; }
.topbar-logo-divider { width: 1px; height: 22px; background: #e0e0e0; flex-shrink: 0; }
.week-select { font-family: 'Poppins', sans-serif; font-size: 13px; padding: 5px 10px; cursor: pointer; min-width: 200px; max-width: 260px; }
.week-nav-btn { padding: 5px 10px !important; }
.week-nav-label { display: flex; align-items: center; gap: 6px; background: none; border: 0.5px solid #e0e0e0; border-radius: 6px; padding: 5px 14px; font-size: 13px; font-weight: 600; color: #444; cursor: pointer; white-space: nowrap; font-family: 'Poppins', sans-serif; transition: all .15s; flex: 0 0 auto; justify-content: center; min-width: 220px; position: relative; }
.week-nav-label:hover { background: #f5f5f5; border-color: var(--brand); color: var(--brand); }

/* ── Calendário popup ── */
.week-nav-wrap { position: relative; display: flex; align-items: center; gap: 7px; flex: 0 0 auto; }
.week-cal-popup { display: none; position: absolute; top: calc(100% + 8px); background: #fff; border: 0.5px solid #e0e0e0; border-radius: 14px; box-shadow: 0 8px 32px rgba(0,0,0,.13); padding: 16px; z-index: 500; width: 556px; }
.week-cal-popup.open { display: block; }
.week-cal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; gap: 8px; }
.cal-header-labels { display: flex; flex: 1; justify-content: space-around; }
.week-cal-header span { font-size: 14px; font-weight: 700; color: #222; }
.week-cal-nav { background: none; border: 0.5px solid #e0e0e0; border-radius: 6px; padding: 4px 8px; cursor: pointer; color: #666; font-size: 13px; transition: all .15s; flex-shrink: 0; }
.week-cal-nav:hover { background: #f5f5f5; color: var(--brand); border-color: var(--brand); }
/* Dois meses lado a lado */
.cal-two-cols { display: flex; gap: 0; }
.cal-col { flex: 1; min-width: 0; }
.cal-col-sep { width: 1px; background: #f0f0f0; margin: 0 10px; flex-shrink: 0; }
.week-cal-days-header { display: grid; grid-template-columns: repeat(7,1fr); margin-bottom: 4px; }
.week-cal-days-header span { text-align: center; font-size: 10px; font-weight: 600; color: #bbb; padding: 2px 0; }
#cal-grid, #cal-grid-right { display: flex; flex-direction: column; gap: 2px; }
.cal-week-row { display: grid; grid-template-columns: repeat(7,1fr); border-radius: 7px; cursor: pointer; transition: background .12s; position: relative; overflow: hidden; }
.cal-week-row:hover { background: #f5f5f5; }
.cal-week-row.cal-week-selected { background: rgba(217,27,34,.07); outline: 1px solid rgba(217,27,34,.2); }

/* Label do mês clicável */
.cal-month-label-btn { background: none; border: none; font-family: 'Poppins', sans-serif; font-size: 13px; font-weight: 700; color: #333; cursor: pointer; padding: 2px 8px; border-radius: 6px; transition: background .12s; }
.cal-month-label-btn:hover { background: #f0f0f0; }
body.dark-mode .cal-month-label-btn { color: #e0e0e0; }
body.dark-mode .cal-month-label-btn:hover { background: #2a2a2a; }
/* Grid de meses */
#cal-month-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 4px 0; }
.cal-month-btn { font-family: 'Poppins', sans-serif; font-size: 12px; font-weight: 500; padding: 8px 4px; border: none; border-radius: 7px; background: transparent; color: #666; cursor: pointer; transition: all .12s; text-align: center; }
.cal-month-btn:hover { background: #f0f0f0; color: #222; }
.cal-month-btn.cal-month-today { color: var(--brand); font-weight: 700; }
.cal-month-btn.cal-month-selected { background: rgba(217,27,34,.08); color: var(--brand); font-weight: 700; }
body.dark-mode .cal-month-btn { color: #777; }
body.dark-mode .cal-month-btn:hover { background: #2a2a2a; color: #ccc; }
body.dark-mode .cal-month-btn.cal-month-today { color: var(--brand); }
body.dark-mode .cal-month-btn.cal-month-selected { background: rgba(217,27,34,.12); color: var(--brand); }
.cal-day { text-align: center; font-size: 12px; padding: 5px 2px; color: #333; position: relative; border-radius: 5px; }
.cal-other { color: #ccc; }
.cal-sun { color: #e57373; }
.cal-today { font-weight: 700; color: var(--brand); }
.cal-week-selected .cal-today { color: var(--brand); }
/* Número do dia */
.cal-day-num { position: relative; z-index: 1; }
.cal-holiday .cal-day-num { color: #fff; font-weight: 700; }
/* Feriado: círculo em volta do número */
.cal-holiday::after { content: ''; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 22px; height: 22px; border-radius: 50%; background: var(--brand); pointer-events: none; z-index: 0; }
/* Heat map — dot por dia */
.cal-day-dot { position: absolute; bottom: 2px; left: 50%; transform: translateX(-50%); width: 4px; height: 4px; border-radius: 50%; pointer-events: none; z-index: 2; }
.cal-day-dot-1 { background: rgba(217,27,34,.28); }
.cal-day-dot-2 { background: rgba(217,27,34,.58); }
.cal-day-dot-3 { background: rgba(217,27,34,.88); }
.cal-week-selected .cal-day-dot-1 { background: rgba(217,27,34,.4); }
.cal-week-selected .cal-day-dot-2 { background: rgba(217,27,34,.7); }
.cal-week-selected .cal-day-dot-3 { background: rgba(217,27,34,1); }
body.dark-mode .cal-day-dot-1 { background: rgba(217,27,34,.4); }
body.dark-mode .cal-day-dot-2 { background: rgba(217,27,34,.65); }
body.dark-mode .cal-day-dot-3 { background: rgba(217,27,34,.9); }
.week-cal-legend { display: flex; gap: 12px; margin-top: 10px; padding-top: 10px; border-top: 0.5px solid #f0f0f0; }
.cal-legend-item { display: flex; align-items: center; gap: 5px; font-size: 10px; color: #999; }
.cal-legend-sep { width: 1px; height: 12px; background: #e8e8e8; margin: 0 4px; }
.cal-dot-holiday { width: 14px; height: 14px; border-radius: 50%; background: var(--brand); display: inline-flex; align-items: center; justify-content: center; font-size: 8px; font-weight: 700; color: #fff; }
.cal-dot-today { width: 6px; height: 6px; border-radius: 50%; background: transparent; border: 1.5px solid var(--brand); display: inline-block; }
/* Dots inline na legenda (override do position:absolute do calendário) */
.cal-legend-dot { position: static !important; transform: none !important; width: 5px; height: 5px; display: inline-block; }
body.dark-mode .cal-legend-sep { background: #333; }

/* Dark mode calendário */
body.dark-mode .week-cal-popup { background: #1e1e1e; border-color: #2a2a2a; box-shadow: 0 8px 32px rgba(0,0,0,.4); }
body.dark-mode .cal-col-sep { background: #2a2a2a; }
body.dark-mode .week-cal-header span { color: #e0e0e0; }
body.dark-mode .week-cal-nav { border-color: #3a3a3a; color: #888; background: #252525; }
body.dark-mode .week-cal-nav:hover { background: #2a2a2a; color: var(--brand); border-color: var(--brand); }
body.dark-mode .cal-day { color: #ccc; }
body.dark-mode .cal-other { color: #444; }
body.dark-mode .cal-week-row:hover { background: #2a2a2a; }
body.dark-mode .week-cal-legend { border-top-color: #2a2a2a; }
.tbtn { display: flex; align-items: center; gap: 5px; background: none; border: 0.5px solid #e0e0e0; border-radius: 6px; padding: 5px 12px; font-size: 12px; font-weight: 500; color: #666; cursor: pointer; white-space: nowrap; font-family: 'Poppins', sans-serif; transition: all .15s; }
.tbtn:hover { background: #f5f5f5; color: #333; }
.tbtn.active     { border-color: #aaa; color: #333; background: #f0f0f0; font-weight: 600; }
.tbtn.active:hover { background: #e5e5e5; border-color: #999; }
.tbtn.add:hover  { border-color: var(--brand); color: var(--brand); background: rgba(217,27,34,.04); }
.tbtn.del:hover  { color: var(--brand); border-color: var(--brand); background: rgba(217,27,34,.04); }
.tbtn.print:hover{ border-color: #185FA5; color: #185FA5; background: #eef3fb; }
.topbar-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.user-badge { display: flex; align-items: center; gap: 6px; background: #f5f5f5; border-radius: 6px; padding: 5px 12px; font-size: 13px; color: #333; font-weight: 500; cursor: pointer; border: 0.5px solid transparent; transition: all .15s; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-badge:hover { border-color: var(--brand); color: var(--brand); }
.logout-btn { font-size: 14px; font-weight: 500; color: var(--brand); background: none; border: 0.5px solid var(--brand); border-radius: 6px; padding: 5px 10px; cursor: pointer; font-family: 'Poppins', sans-serif; transition: all .15s; }
.logout-btn:hover { background: var(--brand); color: white; }
#btn-toolbar-toggle { display: none; }

/* ── TABS ── */
.tabs-bar { display: flex; align-items: flex-end; padding: 0 1.25rem; background: #fff; border-bottom: 0.5px solid #e5e5e5; }
.tab-btn { font-family: 'Poppins', sans-serif; font-size: 13px; font-weight: 500; padding: 10px 18px; border: none; background: none; cursor: pointer; color: #777; border-bottom: 2px solid transparent; margin-bottom: -1px; transition: all .15s; display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.tab-btn:hover { color: #333; }
.tab-btn.active { color: var(--brand); border-bottom-color: var(--brand); }
.tab-badge { background: #f0f0f0; border-radius: 10px; font-size: 11px; padding: 1px 7px; font-weight: 600; color: #777; }
.tab-btn.active .tab-badge { background: rgba(217,27,34,.1); color: var(--brand); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── STATS ── */
.stats-bar { display: flex; align-items: center; gap: 8px; padding: .75rem 1.25rem; flex-wrap: wrap; }
#plan-toolbar { padding: .75rem 1.25rem 0; }
#stats-bar { padding: 6px 1.25rem; margin-bottom: 4px; }
.board-layout-switcher { display: flex; align-items: center; gap: 2px; background: #f0f0f0; border-radius: 6px; padding: 3px; margin-left: auto; }
.board.list-view { grid-template-columns: 1fr; }
.board.list-view .day-col { min-height: unset; }
.stat-pill { background: #fff; border: 0.5px solid #e5e5e5; border-radius: 20px; padding: 4px 14px; font-size: 12px; color: #777; display: flex; align-items: center; gap: 5px; }
.stat-pill strong { color: #333; font-weight: 600; }

/* ── BOARD (Desktop: 6 cols) ── */
.board { display: grid; grid-template-columns: repeat(6, minmax(0,1fr)); gap: 10px; padding: 0 1.25rem 1.5rem; }
.day-col { background: #fff; border: 0.5px solid #e5e5e5; border-radius: 10px; padding: 10px; min-height: 300px; display: flex; flex-direction: column; }
.day-cards { flex: 1; }
.day-col.saturday { border-top: 2px solid var(--brand); }
.day-header { font-size: 11px; font-weight: 600; color: #888; text-transform: uppercase; letter-spacing: .06em; padding-bottom: 8px; border-bottom: 0.5px solid #f0f0f0; margin-bottom: 8px; }
.day-header-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 2px; }
.day-date { font-size: 11px; font-weight: 500; color: var(--brand); letter-spacing: 0; text-transform: none; }
.day-holiday-badge { font-size: 10px; color: #f59e0b; font-weight: 600; margin-top: 3px; display: flex; align-items: center; gap: 3px; min-width: 0; }
.day-holiday-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.day-col-holiday { border-top: 2px solid #f59e0b !important; }
body.dark-mode .day-holiday-badge { color: #fbbf24; }
.day-count { background: var(--brand); color: white; border-radius: 10px; font-size: 11px; padding: 1px 7px; font-weight: 600; }

/* ── DELIVERY CARDS ── */
.delivery-card { background: #fafafa; border: 0.5px solid #ebebeb; border-left: 3px solid var(--brand); border-radius: 6px; padding: 9px 10px; margin-bottom: 7px; font-size: 12px; position: relative; animation: slideIn .2s ease; display: flex; flex-direction: column; }
.delivery-card .dc-ver-mais { margin-top: auto; }
.delivery-card .detalhe-anexos { margin-bottom: 8px; }
@keyframes slideIn { from{opacity:0;transform:translateY(-4px)}to{opacity:1;transform:translateY(0)} }
.dc-client { font-weight: 600; font-size: 13px; color: #333; margin-bottom: 2px; padding-right: 46px; }
.dc-district { display: inline-block; background: rgba(217,27,34,.1); color: var(--brand); border-radius: 4px; font-size: 11px; padding: 1px 6px; margin-bottom: 3px; font-weight: 600; }
.dc-addr { color: #888; font-size: 11px; margin-bottom: 2px; }
.dc-val  { font-size: 11px; color: var(--brand); font-weight: 600; }
.dc-notes { margin-top: 5px; margin-bottom: 8px; padding-top: 5px; border-top: 0.5px solid #ebebeb; color: #999; font-size: 11px; font-style: italic; line-height: 1.5; }
.dc-ver-mais { display: flex; align-items: center; justify-content: center; gap: 5px; width: 100%; margin-top: 8px; padding: 6px; background: #f5f5f5; border: 0.5px solid #e0e0e0; border-radius: 5px; font-family: 'Poppins', sans-serif; font-size: 11px; font-weight: 600; color: #555; cursor: pointer; transition: all .15s; }
.dc-ver-mais:hover { background: rgba(217,27,34,.06); border-color: var(--brand); color: var(--brand); }
.delivery-card.entregue .dc-ver-mais { background: #dcfce7; border-color: #bbf7d0; color: #15803d; }
.delivery-card.entregue .dc-ver-mais:hover { background: #bbf7d0; }

/* Entregue state */
.delivery-card.entregue { border-left-color: #16a34a; background: #f0fdf4; opacity: .85; }
.delivery-card.entregue .dc-client { color: #15803d; }
.dc-entregue-badge { display: inline-flex; align-items: center; gap: 4px; background: #dcfce7; color: #15803d; border-radius: 4px; font-size: 11px; font-weight: 700; padding: 2px 7px; margin-bottom: 4px; }
.dc-entregue-badge .ti { font-size: 12px; }

/* Botão marcar como entregue (modal) */
#detalhe-entregar-zone { border-top: 0.5px solid #f0f0f0; padding-top: 1rem; }
.btn-entregar { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; background: #16a34a; color: white; border: none; border-radius: 8px; padding: 11px 16px; font-size: 14px; font-weight: 600; cursor: pointer; font-family: 'Poppins', sans-serif; transition: background .15s; }
.btn-entregar:hover { background: #15803d; }
.btn-entregar:disabled { opacity: .5; cursor: not-allowed; }

/* Badge entregue no header do modal */
.badge-entregue { display: inline-flex; align-items: center; gap: 4px; background: #dcfce7; color: #15803d; border-radius: 5px; font-size: 12px; font-weight: 700; padding: 2px 9px; vertical-align: middle; margin-left: 4px; }

/* Links maps / call no modal */
.detalhe-maps-link { color: #185FA5; text-decoration: none; display: inline-flex; align-items: center; gap: 4px; }
.detalhe-maps-link:hover { text-decoration: underline; }
.detalhe-call-link { color: #15803d; text-decoration: none; display: inline-flex; align-items: center; gap: 4px; font-weight: 600; }
.detalhe-call-link:hover { text-decoration: underline; }

/* Auditoria */
.detalhe-audit { margin-top: .85rem; padding-top: .6rem; border-top: 0.5px solid #f0f0f0; font-size: 11px; color: #bbb; line-height: 1.7; }
.detalhe-audit strong { color: #999; font-weight: 600; }

/* Modal detalhe entrega */
.detalhe-distrito { display: inline-block; background: rgba(217,27,34,.1); color: var(--brand); border-radius: 4px; font-size: 12px; padding: 2px 8px; font-weight: 600; margin-bottom: .75rem; }
.detalhe-grid { display: flex; flex-direction: column; gap: 6px; margin-bottom: .75rem; }
.detalhe-row { display: flex; align-items: baseline; gap: 10px; font-size: 13px; }
.detalhe-label { min-width: 110px; font-size: 11px; font-weight: 600; color: #aaa; display: flex; align-items: center; gap: 5px; text-transform: uppercase; letter-spacing: .04em; flex-shrink: 0; }
.detalhe-label i { font-size: 13px; }
.detalhe-valor { color: var(--brand); font-weight: 700; font-size: 14px; }
.detalhe-notas-label { font-size: 11px; font-weight: 600; color: #aaa; text-transform: uppercase; letter-spacing: .06em; margin-bottom: 6px; padding-bottom: 4px; border-bottom: 0.5px solid #f0f0f0; }
.detalhe-notas { white-space: pre-wrap; font-size: 14px; color: #444; line-height: 1.75; background: #f9f9f9; border: 0.5px solid #ebebeb; border-radius: 8px; padding: 1rem; margin-bottom: .75rem; }
.detalhe-files { display: flex; flex-wrap: wrap; gap: 6px; margin-top: .25rem; }

/* Anexos com preview */
.detalhe-anexos { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.anexo-chip {
  display: flex; align-items: center; gap: 8px; text-decoration: none;
  background: #f7f7f7; border: 0.5px solid #e5e5e5; border-radius: 8px;
  padding: 7px 10px; font-size: 12px; color: #555; transition: all .15s;
  max-width: 260px; min-width: 0;
}
.anexo-chip:hover { border-color: var(--brand); background: rgba(217,27,34,.04); color: var(--brand); }
.anexo-chip:hover .anexo-icon { color: var(--brand); }
.anexo-thumb { width: 36px; height: 36px; object-fit: cover; border-radius: 5px; flex-shrink: 0; }
.anexo-icon { font-size: 22px; color: #bbb; flex-shrink: 0; }
.anexo-nome { font-size: 12px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.anexo-size { font-size: 10px; color: #bbb; white-space: nowrap; flex-shrink: 0; margin-left: auto; padding-left: 6px; }
.dc-files { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.dc-file-chip { display: flex; align-items: center; gap: 4px; background: #f0f0f0; border-radius: 4px; padding: 2px 7px; font-size: 11px; color: #666; text-decoration: none; transition: all .15s; }
.dc-file-chip:hover { color: var(--brand); background: rgba(217,27,34,.08); }
/* Chips de anexo dentro dos cards de entrega */
.delivery-card .detalhe-anexos { margin-top: 0; gap: 5px; }
.delivery-card .anexo-chip { max-width: 100%; padding: 5px 8px; font-size: 11px; }
.delivery-card .anexo-thumb { width: 28px; height: 28px; }
.delivery-card .anexo-icon { font-size: 18px; }
.delivery-card .anexo-nome { font-size: 11px; }

.card-actions { position: absolute; top: 7px; right: 7px; display: flex; gap: 3px; align-items: center; }
.card-edit, .card-del, .card-link { background: none; border: none; cursor: pointer; color: #ccc; font-size: 14px; padding: 4px 6px; border-radius: 4px; transition: all .15s; }
.card-link:hover { color: #0ea5e9; background: rgba(14,165,233,.08); }
.card-edit:hover { color: #555; background: #f0f0f0; }
.card-del:hover  { color: var(--brand); background: rgba(217,27,34,.08); }
.drag-handle { color: #ccc; font-size: 15px; cursor: grab; padding: 1px 2px; line-height: 1; opacity: 0; transition: opacity .15s; }
.delivery-card:hover .drag-handle { opacity: 1; }
.delivery-card[draggable="true"] { cursor: default; }
.delivery-card.dragging { opacity: .35; border-style: dashed; }
.day-cards { min-height: 60px; }
.day-cards.drag-over { background: rgba(217,27,34,.06); border-radius: 6px; outline: 1.5px dashed rgba(217,27,34,.3); }
.dc-call-link { color: inherit; text-decoration: none; }
.dc-call-link:hover { color: var(--brand); text-decoration: underline; }

.add-btn { width: 100%; margin-top: 8px; background: none; border: 0.5px dashed #ddd; border-radius: 6px; color: #aaa; font-size: 12px; font-weight: 500; padding: 7px; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 5px; font-family: 'Poppins', sans-serif; transition: all .15s; }
.add-btn:hover { background: #fff; color: var(--brand); border-color: var(--brand); }

/* ── ENCOMENDAS ── */
.enc-panel { padding: .75rem 1.25rem 1.5rem; }
.enc-toolbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; flex-wrap: wrap; gap: 8px; }
.enc-toolbar-left { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.enc-toolbar-right { display: flex; align-items: center; gap: 8px; }
.enc-layout-switcher { display: flex; align-items: center; gap: 2px; background: #f0f0f0; border-radius: 6px; padding: 3px; }
.enc-layout-btn { background: none; border: none; cursor: pointer; color: #bbb; width: 30px; height: 28px; border-radius: 4px; display: flex; align-items: center; justify-content: center; transition: all .15s; }
.enc-layout-btn:hover { color: #555; background: #e0e0e0; }
.enc-layout-btn.active { background: #fff; color: var(--brand); box-shadow: 0 1px 3px rgba(0,0,0,.1); }
.enc-search-wrap { position: relative; display: inline-flex; align-items: center; width: 220px; }
.enc-search-icon { position: absolute; left: 9px; font-size: 15px; color: #aaa; pointer-events: none; }
.enc-search { font-family: 'Poppins', sans-serif; font-size: 13px; padding: 7px 14px 7px 30px; border: 0.5px solid #ddd; border-radius: 6px; width: 100%; outline: none; }
.enc-search:focus { border-color: var(--brand); }
.enc-search:focus + .enc-search-icon, .enc-search-wrap:focus-within .enc-search-icon { color: var(--brand); }
.enc-search-clear {
  position: absolute; right: 7px; background: none; border: none; cursor: pointer;
  color: #bbb; font-size: 12px; padding: 2px 4px; display: flex; align-items: center; line-height: 1;
}
.enc-search-clear:hover { color: #555; }
/* ── Sort dropdown ── */
.sort-wrap { position: relative; }
.sort-dropdown { display: none; position: absolute; top: calc(100% + 6px); left: 0; background: #fff; border: 0.5px solid #e0e0e0; border-radius: 8px; padding: 6px; box-shadow: 0 4px 16px rgba(0,0,0,.1); z-index: 50; flex-direction: column; gap: 3px; min-width: 160px; }
.sort-dropdown.open { display: flex; }
.sort-pill { display: flex; align-items: center; gap: 8px; font-family: 'Poppins', sans-serif; font-size: 12px; font-weight: 500; padding: 7px 10px; border: none; border-radius: 6px; background: transparent; color: #555; cursor: pointer; transition: background .15s; white-space: nowrap; text-align: left; }
.sort-pill:hover { background: #f5f5f5; color: #222; }
.sort-pill.active { background: #f5f5f5; color: #111; font-weight: 600; }
.sort-pill i { font-size: 14px; opacity: .7; }
.sort-active-dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--brand); margin-left: 4px; vertical-align: middle; }
body.dark-mode .sort-dropdown { background: #1e1e1e; border-color: #3a3a3a; box-shadow: 0 4px 16px rgba(0,0,0,.4); }
body.dark-mode .sort-pill { color: #ccc; }
body.dark-mode .sort-pill:hover, body.dark-mode .sort-pill.active { background: #2a2a2a; color: #fff; }

/* ── Enc card drag & drop ── */
.enc-drag-handle { display: inline-flex; align-items: center; cursor: grab; color: #bbb; font-size: 15px; margin-right: 2px; flex-shrink: 0; transition: color .15s; }
.enc-drag-handle:hover { color: #888; }
.enc-dragging { opacity: .45; box-shadow: 0 6px 24px rgba(0,0,0,.15); transform: scale(.98); }
.enc-drag-over { outline: 2px dashed var(--brand); outline-offset: 2px; background: rgba(217,27,34,.03); }
body.dark-mode .enc-drag-over { background: rgba(217,27,34,.06); }

/* ── Aba arrastar próximo mês ── */
.enc-next-month-zone { position: fixed; right: -180px; top: 50%; transform: translateY(-50%); width: 160px; background: var(--brand, #d91b22); color: #fff; border-radius: 14px 0 0 14px; padding: 24px 18px; display: flex; align-items: center; justify-content: center; transition: right .35s cubic-bezier(.34,1.2,.64,1); z-index: 9999; box-shadow: -4px 0 24px rgba(0,0,0,.18); pointer-events: none; }
.enc-next-month-zone.visible { right: 0; pointer-events: all; }
.enc-next-month-zone.enc-drop-active { background: #a8101a; transform: translateY(-50%) scale(1.04); }
.enc-next-month-inner { text-align: center; }
.enc-next-month-inner i { font-size: 26px; display: block; margin-bottom: 10px; }
.enc-next-month-inner span { font-size: 12px; font-weight: 700; letter-spacing: .02em; text-transform: uppercase; line-height: 1.4; display: block; }

/* ── Picker de cópia de encomenda ── */
/* ── Navegador de semana no modal de cópia ── */
.copy-week-nav { display: flex; align-items: center; gap: 8px; background: #f7f7f7; border: 0.5px solid #e0e0e0; border-radius: 8px; padding: 6px 10px; }
.copy-week-arrow { display: flex; align-items: center; justify-content: center; width: 28px; height: 28px; border: none; border-radius: 6px; background: transparent; color: #555; cursor: pointer; transition: background .15s; flex-shrink: 0; font-size: 14px; }
.copy-week-arrow:hover { background: #e8e8e8; color: #111; }
.copy-week-label { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; }
.copy-week-name { font-size: 13px; font-weight: 600; color: #222; text-align: center; line-height: 1.3; }
.copy-week-current { font-size: 10px; font-weight: 600; color: var(--brand); background: rgba(217,27,34,.08); border-radius: 20px; padding: 1px 8px; letter-spacing: .02em; }
body.dark-mode .copy-week-name { color: #eee; }
body.dark-mode .copy-week-nav { background: #252525; border-color: #3a3a3a; }
body.dark-mode .copy-week-arrow { color: #ccc; }
body.dark-mode .copy-week-arrow:hover { background: #333; color: #fff; }


.filter-wrap { position: relative; }
.filter-active-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-left: 2px; vertical-align: middle; background: #aaa; }
.filter-active-dot.dot-pendente { background: #f59e0b; }
.filter-active-dot.dot-em_curso { background: #3b82f6; }
.filter-active-dot.dot-entregue { background: #22c55e; }
.filter-active-dot.dot-problema { background: var(--brand); }
.estado-pills-dropdown { display: none; position: absolute; top: calc(100% + 6px); left: 0; background: #fff; border: 0.5px solid #e0e0e0; border-radius: 8px; padding: 6px; box-shadow: 0 4px 16px rgba(0,0,0,.1); z-index: 50; flex-direction: column; gap: 3px; min-width: 160px; }
.filter-section-label { font-size: 10px; font-weight: 700; color: #aaa; text-transform: uppercase; letter-spacing: .06em; padding: 4px 4px 2px; }
.filter-select { font-family: 'Poppins', sans-serif; font-size: 12px; padding: 6px 8px; border: 0.5px solid #e0e0e0; border-radius: 6px; background: #fff; color: #555; width: 100%; cursor: pointer; }
body.dark-mode .filter-select { background: #2a2a2a; border-color: #3a3a3a; color: #ccc; }
body.dark-mode .filter-section-label { color: #555; }
/* ── Filtro clientes compacto ── */
.clientes-filter-dropdown { display: none; position: absolute; top: calc(100% + 6px); left: 0; background: #fff; border: 0.5px solid #e0e0e0; border-radius: 10px; padding: 10px 12px; box-shadow: 0 4px 16px rgba(0,0,0,.1); z-index: 50; min-width: 300px; flex-direction: column; gap: 8px; }
.clientes-filter-dropdown.open { display: flex; }
.cf-row { display: flex; align-items: center; gap: 8px; }
.cf-label { font-size: 11px; font-weight: 600; color: #aaa; text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; width: 68px; flex-shrink: 0; }
.cf-select { font-family: 'Poppins', sans-serif; font-size: 12px; padding: 4px 6px; border: 0.5px solid #e0e0e0; border-radius: 6px; background: #fff; color: #555; flex: 1; cursor: pointer; }
.cf-pills { display: flex; gap: 4px; flex-wrap: wrap; }
.cf-pill { font-family: 'Poppins', sans-serif; font-size: 11px; font-weight: 500; padding: 4px 9px; border: 0.5px solid #e0e0e0; border-radius: 20px; background: #fff; color: #777; cursor: pointer; transition: all .15s; white-space: nowrap; }
.cf-pill:hover { background: #f5f5f5; color: #333; }
.cf-pill.active { background: #fff0f0; border-color: var(--brand); color: var(--brand); font-weight: 600; }
.cf-pill.active[data-contacto=""], .cf-pill.active[data-periodo=""] { background: #f5f5f5; border-color: #ccc; color: #555; }
.cf-clear { font-family: 'Poppins', sans-serif; font-size: 11px; color: #bbb; background: none; border: none; cursor: pointer; padding: 2px 0; text-align: left; display: flex; align-items: center; gap: 4px; margin-top: 2px; transition: color .15s; }
.cf-clear:hover { color: var(--brand); }
body.dark-mode .clientes-filter-dropdown { background: #1e1e1e; border-color: #2e2e2e; box-shadow: 0 4px 16px rgba(0,0,0,.4); }
body.dark-mode .cf-label { color: #555; }
body.dark-mode .cf-select { background: #2a2a2a; border-color: #3a3a3a; color: #ccc; }
body.dark-mode .cf-pill { background: #1e1e1e; border-color: #2e2e2e; color: #666; }
body.dark-mode .cf-pill:hover { background: #2a2a2a; color: #ccc; }
body.dark-mode .cf-pill.active { background: #3a1515; border-color: var(--brand); color: #ff6b6b; }
body.dark-mode .cf-pill.active[data-contacto=""], body.dark-mode .cf-pill.active[data-periodo=""] { background: #2a2a2a; border-color: #444; color: #aaa; }
body.dark-mode .cf-clear { color: #444; }
.estado-pills-dropdown.open { display: flex; }
.estado-pills { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.estado-pill { display: flex; align-items: center; gap: 6px; font-family: 'Poppins', sans-serif; font-size: 12px; font-weight: 500; padding: 6px 10px; border: 0.5px solid #e0e0e0; border-radius: 6px; background: #fff; color: #666; cursor: pointer; transition: all .15s; white-space: nowrap; }
.estado-pills-dropdown .estado-pill { width: 100%; }
.estado-pill:hover { background: #f5f5f5; color: #333; }
.estado-pill.active { font-weight: 600; }
.estado-pill.active[data-estado=""],
.estado-pill.active[data-contacto=""],
.estado-pill.active[data-periodo=""] { background: #f5f5f5; border-color: #ccc; color: #333; }
.estado-pill.active[data-contacto]:not([data-contacto=""]),
.estado-pill.active[data-periodo]:not([data-periodo=""]) { background: #fff5f5; border-color: var(--brand); color: var(--brand); }
.estado-pill.active[data-estado="pendente"] { background: #fffbeb; border-color: #f59e0b; color: #92400e; }
.estado-pill.active[data-estado="em_curso"] { background: #eff6ff; border-color: #3b82f6; color: #1e40af; }
.estado-pill.active[data-estado="entregue"] { background: #f0fdf4; border-color: #22c55e; color: #166534; }
.estado-pill.active[data-estado="problema"] { background: #fff5f5; border-color: var(--brand); color: var(--brand); }
.pill-count { background: #f0f0f0; border-radius: 10px; font-size: 11px; padding: 1px 7px; font-weight: 600; color: #777; margin-left: auto; }
.enc-month-tabs { display: inline-flex; background: #f0f0f0; border-radius: 8px; padding: 3px; margin-bottom: 14px; gap: 2px; }
.enc-month-tab { font-family: 'Poppins', sans-serif; font-size: 12px; font-weight: 600; padding: 5px 14px; border: none; border-radius: 6px; background: transparent; color: #999; cursor: pointer; transition: all .2s; }
.enc-month-tab:hover { color: #666; }
.enc-month-tab.active { background: #fff; color: #333; box-shadow: 0 1px 4px rgba(0,0,0,.12); }
body.dark-mode .enc-month-tabs { background: #2a2a2a; }
body.dark-mode .enc-month-tab { color: #555; }
body.dark-mode .enc-month-tab:hover { color: #888; }
body.dark-mode .enc-month-tab.active { background: #1e1e1e; color: #e0e0e0; box-shadow: 0 1px 4px rgba(0,0,0,.3); }
.enc-mes-label { font-size: 13px; font-weight: 600; color: #888; margin-bottom: 12px; }
.enc-list { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.enc-card { background: #fff; border: 0.5px solid #e5e5e5; border-left: 3px solid #ccc; border-radius: 8px; padding: 14px 16px; position: relative; animation: slideIn .2s ease; transition: background-color .4s ease, border-left-color .4s ease; display: flex; flex-direction: column; }
.enc-card .btn-enc-ver-mais { margin-top: auto; }
.enc-card .detalhe-anexos { margin-bottom: 10px; }
.enc-card--pendente  { border-left-color: #f59e0b; background: #fffdf5; }
.enc-card--em_curso  { border-left-color: #3b82f6; background: #f5f9ff; }
.enc-card--entregue  { border-left-color: #22c55e; background: #f5fff8; }
.enc-card--problema  { border-left-color: var(--brand); background: #fff5f5; }
.enc-card-header { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-bottom: 6px; }
.enc-card-header-right { display: flex; align-items: center; gap: 2px; flex-shrink: 0; margin-left: 4px; }
.enc-card-header-right .enc-card-ref { margin-right: 6px; }
.enc-card-title-row { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; min-width: 0; }
.enc-card-title { font-weight: 600; font-size: 14px; color: #333; }
.enc-card-previsao { font-size: 13px; color: #333; display: flex; align-items: center; gap: 4px; }
.enc-card-ref { font-size: 11px; font-weight: 600; background: rgba(217,27,34,.1); color: var(--brand); border-radius: 4px; padding: 2px 8px; white-space: nowrap; }
.enc-card-meta { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.enc-meta-pill { font-size: 11px; color: #888; display: flex; align-items: center; gap: 4px; }
.enc-card-notes { font-size: 12px; color: #888; line-height: 1.5; margin-bottom: 8px; white-space: pre-wrap; }
.enc-card .detalhe-anexos { margin-top: 6px; }
.enc-card .detalhe-preview-img img { width: 72px; height: 58px; }
.enc-card .detalhe-preview-img { max-width: 84px; }
.enc-audit { font-size: 10px; color: #ccc; margin-top: 8px; padding-top: 6px; border-top: 0.5px solid #f5f5f5; line-height: 1.5; }
.enc-audit strong { color: #bbb; font-weight: 600; }
.enc-card-actions { display: flex; gap: 2px; }
.enc-btn-icon { background: none; border: none; cursor: pointer; color: #ccc; font-size: 15px; padding: 3px 4px; border-radius: 4px; transition: all .15s; }
.enc-btn-icon:hover { color: var(--brand); background: rgba(217,27,34,.08); }
.enc-empty { text-align: center; padding: 3rem 1rem; color: #aaa; font-size: 13px; grid-column: 1 / -1; }

/* ── MODAIS ── */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.4); display: none; align-items: flex-start; justify-content: center; z-index: 200; padding: 2rem 1rem; overflow-y: auto; }
/* Modal Word preview */
/* ── FILE PREVIEW MODAL ── */
.file-preview-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.75); z-index: 300; display: none; align-items: center; justify-content: center; padding: 1rem; }
.file-preview-backdrop.open { display: flex; }
.file-preview-wrap { width: 96vw; height: 94vh; background: #fff; border-radius: 12px; overflow: hidden; display: flex; flex-direction: column; box-shadow: 0 24px 64px rgba(0,0,0,.3); }
.file-preview-header { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; background: #fff; border-bottom: 1px solid #e5e5e5; gap: 12px; flex-shrink: 0; }
.file-preview-title { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 14px; color: #333; min-width: 0; overflow: hidden; }
.file-preview-title i { font-size: 18px; color: var(--brand); flex-shrink: 0; }
.file-preview-title span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-preview-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.file-preview-btn { display: flex; align-items: center; gap: 5px; font-family: 'Poppins', sans-serif; font-size: 12px; font-weight: 500; padding: 6px 12px; border: 0.5px solid #e0e0e0; border-radius: 6px; background: #fff; color: #555; cursor: pointer; text-decoration: none; transition: all .15s; }
.file-preview-btn:hover { background: #f5f5f5; color: #333; border-color: #bbb; }
.file-preview-close:hover { background: #fff5f5; border-color: var(--brand); color: var(--brand); }
#docx-preview-container { flex: 1; overflow-y: auto; overflow-x: auto; background: #e8e8e8; }
/* Word: wrapper gerado pelo docx-preview — centrar a página no fundo cinzento */
#docx-preview-container .docx-wrapper { background: #e8e8e8 !important; padding: 24px; display: flex; flex-direction: column; align-items: center; }
#docx-preview-container .docx-wrapper > section.docx { background: #fff; box-shadow: 0 2px 16px rgba(0,0,0,.12); margin-bottom: 16px; }
/* PDF iframe */
#docx-preview-container iframe { width: 100%; height: 100%; border: none; display: block; }
/* Imagens */
#docx-preview-container .preview-img-wrap { display: flex; align-items: center; justify-content: center; min-height: 100%; padding: 24px; }
#docx-preview-container .preview-img-wrap img { max-width: 100%; max-height: calc(94vh - 80px); object-fit: contain; border-radius: 6px; box-shadow: 0 4px 20px rgba(0,0,0,.2); }
.docx-preview-loading { text-align: center; padding: 3rem; color: #aaa; font-size: 13px; }
#modal-confirm { z-index: 1300; }
#modal-confirm-simple { z-index: 1200; }
#modal-orc-adjudicacao { z-index: 400; }
#modal-copy-enc { z-index: 400; }
#modal-copy { z-index: 400; }
.modal-backdrop.open { display: flex; }
.modal { background: #fff; border-radius: 12px; border: 0.5px solid #e5e5e5; padding: 1.5rem; width: 100%; max-width: 480px; animation: popIn .18s ease; margin: auto; box-shadow: 0 16px 48px rgba(0,0,0,.12); }
.modal.narrow { max-width: 520px; }
@keyframes popIn { from{opacity:0;transform:scale(.95)}to{opacity:1;transform:scale(1)} }
.modal h3 { font-size: 15px; font-weight: 600; color: #333; margin-bottom: 1rem; display: flex; align-items: center; gap: 8px; }
.modal-header { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 1rem; }
.modal-header > span { font-size: 15px; font-weight: 600; color: #333; display: flex; align-items: center; gap: 8px; min-width: 0; }
.modal-header .modal-icon { color: var(--brand); }
.modal-close { background: none; border: none; cursor: pointer; color: #bbb; font-size: 16px; padding: 2px 4px; border-radius: 6px; line-height: 1; flex-shrink: 0; transition: color .15s, background .15s; }
.modal-close:hover { color: #555; background: #f0f0f0; }
.modal-body { /* scroll container se necessário */ }
body.dark-mode .modal-header > span { color: #e0e0e0; }
body.dark-mode .modal-close { color: #555; }
body.dark-mode .modal-close:hover { color: #e0e0e0; background: #2a2a2a; }
.modal-section { font-size: 11px; font-weight: 600; color: #aaa; text-transform: uppercase; letter-spacing: .06em; margin: 1rem 0 .5rem; padding-bottom: 4px; border-bottom: 0.5px solid #f0f0f0; }
.modal .form-group textarea { height: 80px; }
.form-row { display: flex; gap: 8px; }
.form-row .form-group { flex: 1; }
.form-row .form-group.narrow { flex: 0 0 120px; }
/* ── Phone wrap com indicativo ── */
.phone-wrap { display: flex; border: 1px solid #e0e0e0; border-radius: 8px; overflow: hidden; background: #fff; transition: border-color .15s; }
.phone-wrap:focus-within { border-color: var(--brand); }
.phone-prefix-select { flex-shrink: 0; font-size: 12px; font-weight: 500; padding: 0 8px; border: none; border-right: 1px solid #e5e5e5; background: #f4f4f5; color: #555; cursor: pointer; appearance: none; -webkit-appearance: none; outline: none; min-width: 68px; }
.phone-wrap select { width: auto !important; }
.phone-wrap input { flex: 1; width: auto !important; min-width: 0; border: none !important; border-radius: 0 !important; background: transparent !important; outline: none; box-shadow: none !important; }
.phone-wrap input:focus { outline: none; box-shadow: none !important; }
body.dark-mode .phone-wrap { background: #2a2a2a; border-color: #3a3a3a; }
body.dark-mode .phone-prefix-select { background: #333; border-right-color: #3a3a3a; color: #ccc; }
body.dark-mode .phone-wrap:focus-within { border-color: var(--brand); }

.euro-wrap { position: relative; }
.euro-wrap::before { content: '€'; position: absolute; left: 9px; top: 50%; transform: translateY(-50%); font-size: 13px; color: #aaa; pointer-events: none; }
.euro-wrap input { padding-left: 22px; }
.euro-wrap input::-webkit-outer-spin-button,
.euro-wrap input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.euro-wrap input[type="number"] { -moz-appearance: textfield; }
.modal-actions { display: flex; gap: 8px; margin-top: 1.25rem; justify-content: flex-end; align-items: center; flex-wrap: wrap; }
.btn-cancel { background: none; border: 0.5px solid #ddd; border-radius: 6px; padding: 7px 18px; font-size: 13px; font-weight: 500; cursor: pointer; color: #777; font-family: 'Poppins', sans-serif; transition: all .15s; }
.btn-cancel:hover { background: #f5f5f5; }
.btn-secondary { background: #fff; border: 1px solid #d1d5db; border-radius: 6px; padding: 7px 14px; font-size: 13px; font-weight: 500; cursor: pointer; color: #374151; font-family: 'Poppins', sans-serif; transition: all .15s; display: inline-flex; align-items: center; gap: 6px; }
.btn-secondary:hover { background: #f9fafb; border-color: #9ca3af; }
.dark-mode .btn-secondary { background: #23282e; border-color: #3a3f47; color: #d1d5db; }
.dark-mode .btn-secondary:hover { background: #2d3139; }
.btn-save { background: var(--brand); color: white; border: none; border-radius: 6px; padding: 7px 20px; font-size: 13px; font-weight: 600; cursor: pointer; font-family: 'Poppins', sans-serif; transition: background .15s; }
.btn-save:hover { background: var(--brand-hover); }
.btn-save:disabled { opacity: .5; cursor: not-allowed; }
.btn-danger { background: #dc2626; color: white; border: none; border-radius: 6px; padding: 7px 14px; font-size: 13px; font-weight: 600; cursor: pointer; font-family: 'Poppins', sans-serif; transition: background .15s; display: inline-flex; align-items: center; gap: 6px; }
.btn-danger:disabled { opacity: .3; cursor: not-allowed; }
.btn-danger:not(:disabled):hover { background: #b91c1c; }
.modal-note { font-size: 12px; color: #999; margin-top: .5rem; }
.confirm-msg { font-size: 13px; color: #333; line-height: 1.6; margin-bottom: .25rem; }
.confirm-warn { font-size: 12px; color: var(--brand); margin: .5rem 0 1rem; display: flex; align-items: center; gap: 5px; }
.confirm-type-label { font-size: 12px; color: #777; margin-bottom: 6px; margin-top: .75rem; }
.confirm-type-label code { background: #f5f5f5; border: 0.5px solid #ddd; border-radius: 4px; padding: 1px 6px; font-family: monospace; font-size: 12px; color: var(--brand); }
.confirm-input { font-family: monospace !important; letter-spacing: .08em; width: 100%; }
.confirm-input.ok { border-color: #16a34a !important; }

/* Week modal */
.week-start-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; }
.week-start-label { font-size: 13px; font-weight: 600; color: #555; }
.week-start-input { font-family: 'Poppins', sans-serif; font-size: 13px; padding: 7px 10px; border: 0.5px solid #ddd; border-radius: 6px; color-scheme: light; outline: none; }
.week-start-input:focus { border-color: var(--brand); }
body.dark-mode .week-start-label { color: #aaa; }
body.dark-mode .week-start-input { background: #2a2a2a; border-color: #3a3a3a; color: #e0e0e0; color-scheme: dark; }
.week-banner { background: #f5f5f5; border: 0.5px solid #e0e0e0; border-radius: 6px; padding: 8px 12px; font-size: 12px; color: #888; margin-top: 8px; display: flex; align-items: center; }
.week-banner strong { color: var(--brand); font-weight: 600; }
.week-banner.warn { color: var(--brand); }
.day-dates-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin-top: .5rem; }
.day-date-item { display: flex; flex-direction: column; gap: 3px; }
.day-date-item label { font-size: 11px; font-weight: 600; color: #aaa; text-transform: uppercase; letter-spacing: .04em; }
.day-date-item input[type="date"] { font-family: 'Poppins', sans-serif; font-size: 12px; padding: 6px 8px; }
.day-date-item.saturday label { color: var(--brand); }
.day-date-item.saturday input { border-color: rgba(217,27,34,.35); }

/* File zone */
.file-zone { border: 0.5px dashed #ddd; border-radius: 6px; padding: 16px; text-align: center; cursor: pointer; font-size: 12px; color: #aaa; transition: all .15s; }
.file-zone:hover { border-color: var(--brand); color: var(--brand); background: rgba(217,27,34,.02); }
.file-zone input { display: none; }
.file-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.file-chip { display: flex; align-items: center; gap: 5px; background: #f5f5f5; border: 0.5px solid #e0e0e0; border-radius: 6px; padding: 4px 8px; font-size: 11px; color: #666; }
.file-chip button { background: none; border: none; cursor: pointer; color: #bbb; font-size: 12px; padding: 0; line-height: 1; transition: color .15s; }
.file-chip button:hover { color: var(--brand); }

/* Upload progress */
.upload-progress { display: none; align-items: center; gap: 10px; margin-top: 8px; background: #f5f5f5; border-radius: 6px; padding: 8px 12px; }
.upload-progress-bar { height: 6px; background: var(--brand); border-radius: 3px; width: 0%; transition: width .2s; flex-shrink: 0; min-width: 0; }
.upload-progress-label { font-size: 11px; color: #888; white-space: nowrap; display: flex; align-items: center; gap: 5px; }
.upload-spinner { animation: spin .8s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
/* trick: let the bar expand */
.upload-progress { flex-wrap: nowrap; }
.upload-progress-bar { flex: 0 0 auto; }
/* better layout: bar grows */
.upload-progress { display: none; flex-direction: column; gap: 4px; }
.upload-progress-bar { width: 0%; height: 6px; background: var(--brand); border-radius: 3px; transition: width .3s; }

/* Profile */
/* Profile modal — novo layout com tabs */
.profile-header { display: flex; align-items: center; gap: 12px; padding-bottom: 14px; margin-bottom: 0; border-bottom: 0.5px solid #f0f0f0; }
.profile-avatar { width: 46px; height: 46px; background: var(--brand); border-radius: 50%; display: flex; align-items: center; justify-content: center; color: white; font-size: 16px; font-weight: 700; flex-shrink: 0; }
.profile-header-info { flex: 1; min-width: 0; }
.profile-header .p-name  { font-size: 15px; font-weight: 600; color: #222; }
.profile-header .p-user  { font-size: 12px; color: #aaa; margin-top: 1px; }
.profile-header .p-cargo { display: inline-block; background: rgba(217,27,34,.1); color: var(--brand); border-radius: 4px; font-size: 10px; padding: 1px 7px; margin-top: 4px; font-weight: 600; }
.profile-header .modal-close { margin-left: auto; flex-shrink: 0; }
.profile-tabs { display: flex; gap: 2px; background: #f5f5f5; border-radius: 8px; padding: 3px; margin: 12px 0 14px; }
.profile-tab { flex: 1; padding: 7px 10px; border: none; background: none; border-radius: 6px; font-family: 'Poppins',sans-serif; font-size: 12px; font-weight: 500; color: #888; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 5px; transition: all .15s; white-space: nowrap; }
.profile-tab.active { background: #fff; color: var(--brand); box-shadow: 0 1px 4px rgba(0,0,0,.08); font-weight: 600; }
.profile-tab:hover:not(.active) { color: #555; }
.profile-tab-panel { animation: fadeIn .15s ease; }
.alert-box { border-radius: 6px; padding: 8px 12px; font-size: 12px; margin-top: .6rem; display: none; }
.alert-box.success { background: #f0fdf4; color: #15803d; }
.alert-box.error   { background: #fef2f2; color: #b91c1c; }

/* User management */
.users-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: .75rem; }
.user-item { display: flex; align-items: center; justify-content: space-between; background: #f9f9f9; border: 0.5px solid #ebebeb; border-radius: 6px; padding: 8px 12px; }
.user-item-info { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.user-item-name { font-size: 13px; font-weight: 600; color: #333; }
.user-item-username { font-size: 11px; color: #aaa; }
.user-item-cargo { font-size: 10px; font-weight: 600; border-radius: 4px; padding: 1px 7px; background: #f0f0f0; color: #777; }
.user-item-cargo.cargo-admin      { background: rgba(217,27,34,.1); color: var(--brand); }
.user-item-cargo.cargo-gestor     { background: #fff3cd; color: #856404; }
.user-item-cargo.cargo-utilizador { background: #d1ecf1; color: #0c5460; }
.user-item-del { background: none; border: none; cursor: pointer; color: #ccc; border-radius: 4px; padding: 3px 6px; transition: all .15s; }
.user-item-del:hover { color: var(--brand); background: rgba(217,27,34,.08); }
.users-create { background: #fafafa; border: 0.5px solid #ebebeb; border-radius: 8px; padding: 12px; margin-top: 4px; }

/* ── Permissões matrix ── */
.perm-matrix { font-size: 12px; margin-top: 8px; }
.perm-matrix-head { display: grid; grid-template-columns: 1fr repeat(3, 64px); gap: 4px; margin-bottom: 4px; }
.perm-matrix-col-head { text-align: center; font-weight: 600; color: #888; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; }
.perm-matrix-group { font-weight: 600; color: #555; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; margin: 10px 0 4px; padding-bottom: 4px; border-bottom: 1px solid #f0f0f0; }
.perm-matrix-row { display: grid; grid-template-columns: 1fr repeat(3, 64px); gap: 4px; align-items: center; padding: 4px 0; }
.perm-matrix-label { color: #555; font-size: 12px; }
.perm-matrix-row--sub .perm-matrix-label { padding-left: 14px; opacity: .85; }
.perm-matrix-row--sub .perm-matrix-label::before { content: '└ '; opacity: .45; }
.perm-matrix-cell { display: flex; justify-content: center; }
.perm-matrix-cell .toggle-switch { width: 34px; height: 20px; }
.perm-matrix-cell .toggle-slider:before { width: 14px; height: 14px; }
.perm-matrix-cell .toggle-switch input:checked + .toggle-slider:before { transform: translateX(14px); }

/* ── User list with cargo select ── */
.user-item-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.user-cargo-select { font-size: 11px; padding: 3px 6px; border: 1px solid #e0e0e0; border-radius: 6px; background: #f8f8f8; color: #555; cursor: pointer; }

/* ── Esconder valores monetários ── */
body.hide-valores .valor-cell,
body.hide-valores .enc-valor,
body.hide-valores .crm-card-valor,
body.hide-valores .kanban-card-valor,
body.hide-valores [data-hide-valor] { display: none !important; }

/* Dark mode permissões */
body.dark-mode .perm-matrix-group { color: #888; border-bottom-color: #2a2a2a; }
body.dark-mode .perm-matrix-label { color: #aaa; }
body.dark-mode .perm-matrix-col-head { color: #666; }
body.dark-mode .user-cargo-select { background: #2a2a2a; border-color: #3a3a3a; color: #ccc; }

/* ── Modal importar clientes ── */
.imp-modal { max-width: 560px; display: flex; flex-direction: column; padding: 0; overflow: hidden; max-height: 90vh; }
.imp-modal-head { display: flex; align-items: center; justify-content: space-between; padding: 20px 20px 14px; border-bottom: 1px solid #f0f0f0; flex-shrink: 0; }
.imp-modal-title { font-size: 15px; font-weight: 600; color: #333; display: flex; align-items: center; gap: 8px; }
.imp-modal-sub { flex-shrink: 0; padding: 10px 16px 0; }
.imp-subbar { display: flex; align-items: center; justify-content: space-between; }
.imp-info { font-size: 12px; color: #888; }
.imp-sel-actions { display: flex; gap: 6px; }
.imp-sel-actions .tbtn { font-size: 11px; padding: 4px 10px; }
.imp-modal-body { flex: 1; overflow-y: auto; padding: 10px 16px 16px; display: flex; flex-direction: column; gap: 6px; }
.imp-modal-foot { display: flex; gap: 10px; padding: 14px 20px; border-top: 1px solid #f0f0f0; flex-shrink: 0; }
.imp-modal-foot .btn-cancel { flex-shrink: 0; }
.imp-modal-foot .btn-primary { flex: 1; justify-content: center; }
.imp-item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid #f0f0f0; border-radius: 10px; cursor: pointer; transition: background .12s; }
.imp-item:hover { background: #fafafa; border-color: #e8e8e8; }
.imp-item:has(.imp-check:checked) { border-color: #fecaca; background: #fff8f8; }
.imp-item input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--brand); flex-shrink: 0; cursor: pointer; }
.imp-avatar { width: 34px; height: 34px; border-radius: 50%; background: #f0f0f0; color: #888; font-size: 12px; font-weight: 700; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.imp-item-info { flex: 1; min-width: 0; }
.imp-item-nome { font-size: 13px; font-weight: 600; color: #333; margin-bottom: 4px; }
.imp-item-tags { display: flex; flex-wrap: wrap; gap: 4px; }
.imp-tag { font-size: 11px; color: #666; background: #f5f5f5; border-radius: 4px; padding: 2px 7px; display: flex; align-items: center; gap: 3px; }
.imp-tag i { font-size: 11px; }
body.dark-mode .imp-modal-head { border-bottom-color: #2a2a2a; }
body.dark-mode .imp-modal-title { color: #e0e0e0; }
body.dark-mode .imp-modal-foot { border-top-color: #2a2a2a; }
body.dark-mode .imp-info { color: #666; }
body.dark-mode .imp-item { border-color: #2a2a2a; }
body.dark-mode .imp-item:hover { background: #1e1e1e; border-color: #333; }
body.dark-mode .imp-item:has(.imp-check:checked) { border-color: #5a1a1a; background: #1e1010; }
body.dark-mode .imp-avatar { background: #2a2a2a; color: #666; }
body.dark-mode .imp-item-nome { color: #e0e0e0; }
body.dark-mode .imp-tag { background: #2a2a2a; color: #aaa; }
.imp-modal-tabs { display: flex; border-bottom: 1px solid #f0f0f0; padding: 0 16px; flex-shrink: 0; }
.imp-tab { font-family: 'Poppins',sans-serif; font-size: 12px; font-weight: 600; color: #999; background: none; border: none; border-bottom: 2px solid transparent; padding: 10px 14px 9px; cursor: pointer; display: flex; align-items: center; gap: 5px; transition: color .15s; margin-bottom: -1px; }
.imp-tab:hover { color: #555; }
.imp-tab.active { color: var(--brand); border-bottom-color: var(--brand); }
.imp-tab-badge { font-size: 10px; font-weight: 700; background: #f0f0f0; color: #888; border-radius: 10px; padding: 1px 6px; min-width: 18px; text-align: center; }
.imp-tab.active .imp-tab-badge { background: #fde8e8; color: var(--brand); }
.imp-tab-badge:empty { display: none; }
.imp-diff { margin-top: 4px; display: flex; flex-direction: column; gap: 2px; }
.imp-diff-row { font-size: 11px; display: flex; align-items: center; gap: 5px; flex-wrap: wrap; }
.imp-diff-campo { color: #aaa; font-weight: 600; text-transform: uppercase; font-size: 10px; min-width: 58px; }
.imp-diff-de { color: #ccc; text-decoration: line-through; max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.imp-diff-para { color: #22c55e; font-weight: 600; }
.imp-diff-arrow { color: #ccc; font-size: 10px; }
.imp-diff-add { color: #3b82f6; font-weight: 600; display: flex; align-items: center; gap: 3px; }
.imp-diff-add i { font-size: 10px; }
body.dark-mode .imp-modal-tabs { border-bottom-color: #2a2a2a; }
body.dark-mode .imp-tab { color: #555; }
body.dark-mode .imp-tab:hover { color: #aaa; }
body.dark-mode .imp-tab-badge { background: #2a2a2a; color: #666; }
body.dark-mode .imp-tab.active .imp-tab-badge { background: #3a1010; color: var(--brand); }
body.dark-mode .imp-diff-campo { color: #555; }
body.dark-mode .imp-diff-de { color: #444; }
body.dark-mode .imp-diff-para { color: #4ade80; }

/* ── Autocomplete cliente ── */
.client-suggestions { position: absolute; top: calc(100% + 2px); left: 0; right: 0; background: #fff; border: 1px solid #e0e0e0; border-radius: 8px; box-shadow: 0 4px 16px rgba(0,0,0,.1); z-index: 200; display: none; max-height: 220px; overflow-y: auto; }
.csi-item { padding: 8px 12px; cursor: pointer; transition: background .12s; border-bottom: 1px solid #f5f5f5; }
.csi-item:last-child { border-bottom: none; }
.csi-item:hover { background: #fafafa; }
.csi-nome { font-size: 13px; font-weight: 500; color: #333; }
.csi-sub { font-size: 11px; color: #aaa; margin-top: 1px; }
body.dark-mode .client-suggestions { background: #1e1e1e; border-color: #2e2e2e; box-shadow: 0 4px 16px rgba(0,0,0,.3); }
body.dark-mode .csi-item { border-bottom-color: #2a2a2a; }
body.dark-mode .csi-item:hover { background: #2a2a2a; }
body.dark-mode .csi-nome { color: #e0e0e0; }
body.dark-mode .csi-sub { color: #666; }

/* ── PESQUISA GLOBAL ── */
.search-modal { max-width: 580px; }
.search-modal #search-global-input { font-size: 15px; padding: 10px 14px; }
#search-results { max-height: 55vh; overflow-y: auto; margin-top: .5rem; }
.search-empty { text-align: center; color: #bbb; font-size: 13px; padding: 2rem 1rem; }
.search-group-label { font-size: 11px; font-weight: 700; color: #aaa; text-transform: uppercase; letter-spacing: .06em; padding: .6rem 0 .3rem; border-bottom: 0.5px solid #f0f0f0; margin-bottom: .3rem; display: flex; align-items: center; gap: 6px; }
.search-result { padding: 10px 12px; border-radius: 7px; cursor: pointer; transition: background .12s; border: 0.5px solid transparent; margin-bottom: 4px; }
.search-result:hover { background: #f5f5f5; border-color: #e8e8e8; }
.sr-title { font-size: 13px; font-weight: 600; color: #333; margin-bottom: 4px; }
.sr-meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 11px; color: #888; }
.sr-week { color: #aaa; font-style: italic; }
.sr-pill { background: #f0f0f0; border-radius: 4px; padding: 1px 7px; font-weight: 600; color: #777; }
.sr-pill-entregue { background: #dcfce7; color: #15803d; }

/* ── FOOTER ── */
.app-footer { text-align: center; padding: 1rem 1.25rem; font-size: 11px; color: #ccc; border-top: 0.5px solid #f0f0f0; margin-top: auto; }
.app-footer strong { color: #999; font-weight: 600; }
.footer-link { text-decoration: none; color: inherit; transition: color .15s; }
.footer-link:hover { color: var(--brand); }
.footer-link:hover strong { color: var(--brand); }

/* ── PRINT ── */
#print-area { display: none; }
@media print {
  /* Forçar sempre tema claro na impressão */
  body, body.dark-mode { background: #fff !important; color: #000 !important; }
  /* Início: se o utilizador imprimir a página de início, reverter dark mode */
  body.dark-mode .inicio-kpi-card,
  body.dark-mode .inicio-chart-card,
  body.dark-mode .inicio-semana-card,
  body.dark-mode .inicio-extra-card { background: #fff !important; border-color: #e5e7eb !important; color: #111827 !important; }
  body.dark-mode .inicio-hero-greeting { color: #111827 !important; }
  body.dark-mode .inicio-hero { border-bottom-color: #e5e7eb !important; background: #fff !important; }
  body.dark-mode .inicio-kpi-value { color: #111827 !important; }
  body.dark-mode .inicio-kpi-label,
  body.dark-mode .inicio-charts-title,
  body.dark-mode .inicio-extra-title,
  body.dark-mode .inicio-semana-stat,
  body.dark-mode .inicio-semana-periodo { color: #374151 !important; }
  body.dark-mode .inicio-semana-btn,
  body.dark-mode .inicio-link-btn { background: #f9fafb !important; border-color: #e5e7eb !important; color: #374151 !important; }
  body.dark-mode .dash-list-nome { color: #111827 !important; }
  body > *:not(#print-area) { display: none !important; }
  #print-area { display: block !important; font-family: Arial, sans-serif; font-size: 11px; color: #000; background: #fff !important; }
  .print-header { text-align: center; margin-bottom: 16px; border-bottom: 2px solid #d91b22; padding-bottom: 8px; }
  .print-header h1 { font-size: 18px; color: #d91b22; font-weight: 700; }
  .print-header p  { font-size: 10px; color: #555; }
  /* Entregas grid */
  .print-grid { display: grid; grid-template-columns: repeat(6,1fr); gap: 6px; }
  .print-day { border: 1px solid #ddd; border-radius: 4px; padding: 6px; }
  .print-day.sat { border-top: 2px solid #d91b22; }
  .print-day-title { font-weight: 700; font-size: 9px; text-transform: uppercase; letter-spacing: 1px; color: #d91b22; border-bottom: 1px solid #eee; margin-bottom: 3px; padding-bottom: 3px; }
  .print-day-date  { font-size: 9px; color: #888; margin-bottom: 4px; }
  .print-card { border-left: 2px solid #d91b22; padding: 4px 4px 4px 6px; margin-bottom: 4px; font-size: 10px; background: #fafafa; }
  .print-card .pc-name     { font-weight: 700; font-size: 10px; }
  .print-card .pc-district { font-size: 9px; color: #d91b22; font-weight: 600; }
  .print-card .pc-row      { margin-top: 1px; color: #444; }
  .print-card .pc-val      { color: #d91b22; font-weight: 700; }
  .print-card .pc-notes    { color: #888; font-style: italic; margin-top: 2px; border-top: 1px solid #eee; padding-top: 2px; }
  .print-empty { color: #bbb; font-size: 9px; font-style: italic; }
  /* Detalhe individual */
  .print-detalhe { font-size: 13px; line-height: 1.8; color: #222; }
  .print-detalhe p { margin: 2px 0; }
  .print-detalhe-notas { margin-top: 10px; padding-top: 8px; border-top: 1px solid #ddd; }
  .print-detalhe-notas p { white-space: pre-wrap; color: #444; margin-top: 4px; }
  .print-detalhe-anexos { margin-top: 10px; }
  .print-detalhe-anexos ul { margin-top: 4px; padding-left: 16px; }
  /* Encomendas table */
  .print-enc-table { width: 100%; border-collapse: collapse; font-size: 10px; }
  .print-enc-table th { background: #d91b22; color: #fff; padding: 5px 8px; text-align: left; font-size: 9px; text-transform: uppercase; letter-spacing: .05em; }
  .print-enc-table td { padding: 5px 8px; border-bottom: 0.5px solid #eee; vertical-align: top; }
  .print-enc-table tr:nth-child(even) td { background: #fafafa; }
}

/* ════════════════════════════════════════
   RESPONSIVE
   ════════════════════════════════════════ */

/* Tablet: 3 colunas */
@media (max-width: 1024px) {
  .board { grid-template-columns: repeat(3, minmax(0,1fr)); }
}

/* ── TOASTS ── */
#toast-container { position: fixed; bottom: 1.5rem; right: 1.5rem; z-index: 9999; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast { display: flex; align-items: center; gap: 8px; background: #333; color: #fff; padding: 10px 16px; border-radius: 8px; font-size: 13px; font-weight: 500; box-shadow: 0 4px 16px rgba(0,0,0,.22); opacity: 0; transform: translateY(8px); transition: opacity .25s, transform .25s; pointer-events: auto; max-width: 340px; font-family: 'Poppins', sans-serif; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast-success { background: #16a34a; }
.toast-error   { background: #dc2626; }
.toast-info    { background: #2563eb; }

/* ── CONFIRM ENTREGUE (green button variant) ── */
#btn-confirm-action.btn-confirm-green { background: #16a34a; }
#btn-confirm-action.btn-confirm-green:not(:disabled):hover { background: #15803d; }

/* ── CRM ── */
.crm-panel { padding: .75rem 1.25rem 1.5rem; }
.crm-subtabs { display: flex; gap: 4px; margin-bottom: 1rem; background: #f5f5f5; border-radius: 8px; padding: 4px; }
.crm-subtab { flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px; padding: 7px 12px; font-size: 13px; font-weight: 500; font-family: 'Poppins',sans-serif; border: none; background: none; border-radius: 6px; cursor: pointer; color: #777; transition: all .15s; }
.crm-subtab.active { background: #fff; color: var(--brand); box-shadow: 0 1px 4px rgba(0,0,0,.08); }
/* Stock e Marketing não têm o .crm-panel à volta: mesmas margens que a CRM */
#tab-stock > .crm-subtabs, #tab-marketing > .crm-subtabs { margin: .75rem 1.25rem 1rem; }
.crm-toolbar { display: flex; align-items: center; gap: 8px; margin-bottom: 1rem; flex-wrap: wrap; }
.crm-search-wrap { position: relative; flex: 1; min-width: 160px; }
.crm-search-icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: #bbb; font-size: 14px; pointer-events: none; }
.crm-search { width: 100%; padding: 7px 10px 7px 30px; border: 0.5px solid #e0e0e0; border-radius: 6px; font-size: 13px; font-family: 'Poppins',sans-serif; outline: none; }
.crm-search:focus { border-color: var(--brand); }
.crm-btn-label { }
.crm-list { display: flex; flex-direction: column; gap: 8px; }
.crm-card { display: flex; align-items: flex-start; gap: 12px; background: #fff; border: 0.5px solid #e8e8e8; border-radius: 10px; padding: 12px 14px; transition: box-shadow .15s; }
.crm-card:hover { box-shadow: 0 2px 12px rgba(0,0,0,.07); }
.crm-card-avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--brand); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700; flex-shrink: 0; }
.crm-card-info { flex: 1; min-width: 0; }
.crm-card-nome { font-size: 14px; font-weight: 600; color: #222; margin-bottom: 4px; }
.crm-card-sub { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12px; color: #888; }
.crm-card-sub span { display: flex; align-items: center; gap: 4px; }
.crm-card-notas { margin-top: 5px; font-size: 12px; color: #aaa; font-style: italic; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crm-card-ficheiros { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 6px; }
.crm-card-actions { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.crm-empty { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 40px 20px; color: #ccc; font-size: 13px; }
.crm-empty i { font-size: 32px; }
.crm-loading { display: flex; align-items: center; gap: 8px; padding: 20px; color: #aaa; font-size: 13px; justify-content: center; }
/* Leads */
.lead-empresa { font-size: 12px; color: #aaa; font-weight: 400; }
.lead-estado-badge { font-size: 11px; font-weight: 600; padding: 3px 8px; border-radius: 20px; border: 0.5px solid; white-space: nowrap; }
.leads-estados-filter { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.lead-estado-pill { padding: 4px 12px; border-radius: 20px; border: 0.5px solid #e0e0e0; background: none; font-size: 12px; font-family: 'Poppins',sans-serif; cursor: pointer; color: #777; transition: all .15s; }
.lead-estado-pill.active { background: var(--brand); color: #fff; border-color: var(--brand); }
/* Histórico */
.cli-hist-info { margin-bottom: 12px; }
.hist-info-row { display: flex; flex-wrap: wrap; gap: 10px; font-size: 13px; color: #666; margin-bottom: 6px; }
.hist-info-row span { display: flex; align-items: center; gap: 5px; }
.hist-notas { font-size: 12px; color: #aaa; font-style: italic; padding: 6px 10px; background: #f9f9f9; border-radius: 6px; }
.hist-count { font-size: 12px; color: #aaa; margin-bottom: 8px; }
.hist-item { background: #f9f9f9; border-radius: 8px; padding: 10px 12px; margin-bottom: 6px; }
.hist-item-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.hist-item-cliente { font-size: 13px; font-weight: 600; color: #222; }
.hist-item-semana { font-size: 11px; color: #aaa; }
.hist-item-detail { display: flex; flex-wrap: wrap; gap: 8px; font-size: 12px; color: #888; align-items: center; }
.hist-item-detail span { display: flex; align-items: center; gap: 4px; }

/* Follow-up badge */
.lead-followup { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 500; margin-top: 5px; padding: 2px 8px; border-radius: 20px; }
.lead-followup.overdue  { background: #fee2e2; color: #dc2626; }
.lead-followup.today    { background: #fef3c7; color: #d97706; }
.lead-followup.upcoming { background: #dbeafe; color: #1d4ed8; }
/* Kanban */
.kanban-board { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 14px; min-height: 200px; }
.kanban-col { min-width: 210px; flex-shrink: 0; display: flex; flex-direction: column; gap: 6px; }
.kanban-col-header { display: flex; align-items: center; justify-content: space-between; padding: 8px 10px; border-radius: 8px; font-size: 12px; font-weight: 700; margin-bottom: 2px; }
.kanban-col-count { font-size: 11px; font-weight: 700; background: rgba(0,0,0,.10); border-radius: 20px; padding: 1px 7px; }
.kanban-card { background: #fff; border: 0.5px solid #e8e8e8; border-radius: 8px; padding: 10px 12px; cursor: pointer; transition: box-shadow .15s; }
.kanban-card:hover { box-shadow: 0 2px 10px rgba(0,0,0,.08); transform: translateY(-1px); }
.kanban-card-nome { font-size: 13px; font-weight: 600; color: #222; margin-bottom: 3px; }
.kanban-card-sub  { font-size: 11px; color: #aaa; margin-top: 2px; display: flex; align-items: center; gap: 4px; }
.kanban-card-valor { font-size: 12px; color: #16a34a; font-weight: 600; margin-top: 4px; display: flex; align-items: center; gap: 4px; }
.kanban-card-followup { font-size: 11px; margin-top: 5px; display: inline-flex; align-items: center; gap: 3px; padding: 1px 7px; border-radius: 20px; font-weight: 500; }
.kanban-card-followup.overdue  { background: #fee2e2; color: #dc2626; }
.kanban-card-followup.today    { background: #fef3c7; color: #d97706; }
.kanban-card-followup.upcoming { background: #dbeafe; color: #1d4ed8; }
.kanban-empty { font-size: 12px; color: #ccc; text-align: center; padding: 16px 8px; }
/* Activity timeline */
.ativ-add-form { margin-bottom: 16px; }
.ativ-tipo-pills { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.ativ-tipo-pill { padding: 4px 10px; border-radius: 20px; border: 0.5px solid #e0e0e0; background: none; font-size: 12px; font-family: 'Poppins',sans-serif; cursor: pointer; color: #777; display: flex; align-items: center; gap: 4px; transition: all .15s; }
.ativ-tipo-pill.active { background: var(--brand); color: #fff; border-color: var(--brand); }
.ativ-input-row { display: flex; gap: 8px; align-items: flex-end; }
.ativ-input-row textarea { flex: 1; resize: none; padding: 8px 10px; border: 0.5px solid #e0e0e0; border-radius: 8px; font-family: 'Poppins',sans-serif; font-size: 13px; outline: none; }
.ativ-input-row textarea:focus { border-color: var(--brand); }
.ativ-input-row .btn-save { padding: 8px 14px; flex-shrink: 0; }
.ativ-timeline { display: flex; flex-direction: column; gap: 8px; max-height: 340px; overflow-y: auto; padding-right: 2px; }
.ativ-item { display: flex; gap: 10px; align-items: flex-start; }
.ativ-item-dot { width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 14px; flex-shrink: 0; }
.ativ-item-body { flex: 1; min-width: 0; background: #f9f9f9; border-radius: 8px; padding: 8px 10px; }
.ativ-item-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 3px; }
.ativ-item-tipo { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; }
.ativ-item-data { font-size: 11px; color: #aaa; }
.ativ-item-desc { font-size: 13px; color: #333; line-height: 1.45; white-space: pre-wrap; }
.ativ-item-autor { font-size: 11px; color: #bbb; margin-top: 3px; }
.ativ-delete { background: none; border: none; color: #ddd; cursor: pointer; padding: 2px 4px; font-size: 11px; transition: color .15s; border-radius: 4px; }
.ativ-delete:hover { color: var(--brand); }
.ativ-empty { text-align: center; color: #ccc; padding: 28px 16px; font-size: 13px; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.ativ-empty i { font-size: 28px; }
/* Dark mode CRM */
body.dark-mode .crm-subtabs { background: #2a2a2a; }
body.dark-mode .crm-subtab.active { background: #1e1e1e; color: var(--brand); }
body.dark-mode .crm-card { background: #1e1e1e; border-color: #2e2e2e; }
body.dark-mode .crm-card-nome { color: #e0e0e0; }
body.dark-mode .crm-search { background: #1e1e1e; border-color: #3a3a3a; color: #e0e0e0; }
body.dark-mode .hist-item { background: #2a2a2a; }
body.dark-mode .hist-notas { background: #2a2a2a; }
body.dark-mode .kanban-card { background: #1e1e1e; border-color: #2e2e2e; }
body.dark-mode .kanban-card-nome { color: #e0e0e0; }
body.dark-mode .kanban-card-sub { color: #666; }
body.dark-mode .ativ-item-body { background: #2a2a2a; }
body.dark-mode .ativ-item-desc { color: #d0d0d0; }
body.dark-mode .ativ-input-row textarea { background: #2a2a2a; border-color: #3a3a3a; color: #e0e0e0; }
body.dark-mode .lead-followup.overdue  { background: #3b1212; color: #f87171; }
body.dark-mode .lead-followup.today    { background: #3b2e12; color: #fbbf24; }
body.dark-mode .lead-followup.upcoming { background: #12213b; color: #60a5fa; }
body.dark-mode .kanban-card-followup.overdue  { background: #3b1212; color: #f87171; }
body.dark-mode .kanban-card-followup.today    { background: #3b2e12; color: #fbbf24; }
body.dark-mode .kanban-card-followup.upcoming { background: #12213b; color: #60a5fa; }

/* ── IMAP STATUS ── */
.imap-status-bar { margin-bottom: 10px; }
.imap-status { display: flex; flex-wrap: wrap; gap: 8px 16px; font-size: 12px; color: #888; background: #f9f9f9; border-radius: 8px; padding: 8px 12px; }
.imap-status span { display: flex; align-items: center; gap: 5px; }
body.dark-mode .imap-status { background: #2a2a2a; color: #aaa; }

/* ── MOBILE MENU ── */
.mobile-menu-wrap { position: relative; display: none; }
.mobile-menu {
  display: none; position: absolute; top: calc(100% + 6px); right: 0;
  background: #fff; border: 0.5px solid #e5e5e5; border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,.10); min-width: 190px; z-index: 200;
  padding: 6px 0; overflow: hidden;
}
.mobile-menu.open { display: block; }
.mobile-menu button {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 11px 16px;
  background: none; border: none; font-family: 'Poppins', sans-serif;
  font-size: 13px; color: #333; cursor: pointer; text-align: left;
}
.mobile-menu button:hover { background: #f8f8f8; }
.mobile-menu button i { font-size: 15px; color: #888; }
.mobile-menu-sep { height: 1px; background: #f0f0f0; margin: 4px 0; }
body.dark-mode .mobile-menu-sep { background: #2e2e2e; }
#mm-logout i { color: var(--brand) !important; }
#mm-logout { color: var(--brand); }

/* Mobile */
@media (max-width: 640px) {
  /* File preview mobile */
  .file-preview-backdrop { padding: 0; }
  .file-preview-wrap { width: 100vw; height: 100vh; border-radius: 0; }
  .file-preview-header { padding: 10px 12px; }
  .file-preview-title { font-size: 13px; }
  .file-preview-btn span { display: none; }
  .file-preview-btn { padding: 7px 10px; }

  /* Topbar */
  .topbar { padding: .6rem .75rem .35rem; gap: 6px; }
  .topbar-logo-text { display: none; }
  #btn-print, #btn-search-global { display: none; }
  .topbar-logo-divider { display: none; }
  .topbar-company-logo { height: 26px; }
  .topbar { position: relative; justify-content: center; }
  .topbar-left  { order: 1; flex: 0 0 auto; }
  .topbar-right { position: absolute; right: .75rem; top: .4rem; order: 2; flex: 0 0 auto; }
  .topbar-week-row { order: 3; width: 100%; border-top: 0.5px solid #f0f0f0; padding-top: 6px; gap: 6px; justify-content: stretch; }
  .week-nav-wrap { flex: 1; }
  .week-nav-label { max-width: none; flex: 1; font-size: 12px; }
  .week-nav-btn { display: flex !important; flex-shrink: 0; padding: 5px 12px !important; }
  /* Calendário mobile: um único mês */
  .week-cal-popup { width: calc(100vw - 24px); }
  .cal-col:last-child, .cal-col-sep { display: none; }
  #cal-month-label-right { display: none !important; }
  .tbtn          { display: none; }
  #btn-mobile-menu { display: flex; border: 0.5px solid #d0d0d0; background: #f5f5f5; padding: 6px 9px; font-size: 16px; color: #555; }
  #btn-nova-enc  { display: flex; width: 100%; justify-content: center; }
  .user-badge  { display: none; }
  .logout-btn  { display: none; }
  .mobile-menu-wrap { display: block; flex-shrink: 0; }
  .card-edit, .card-del { padding: 8px 10px; font-size: 16px; }
  .enc-btn-icon { padding: 5px 6px; font-size: 17px; }
  .drag-handle  { display: none; }

  /* Tabs — scroll horizontal para caber todas */
  .tabs-bar   { padding: 0 .75rem; overflow-x: auto; -webkit-overflow-scrolling: touch; flex-wrap: nowrap; }
  .tab-btn    { padding: 10px 12px; font-size: 12px; white-space: nowrap; flex-shrink: 0; }

  /* CRM mobile — toolbar sempre visível com toggle */
  .crm-panel { padding: .75rem .75rem 1.5rem; }
  #tab-stock > .crm-subtabs, #tab-marketing > .crm-subtabs { margin: .75rem .75rem 1rem; }
  #btn-crm-clientes-toggle, #btn-crm-leads-toggle { display: flex !important; padding: 7px 10px !important; flex-shrink: 0; }
  #crm-sec-clientes .enc-toolbar-right,
  #crm-sec-leads    .enc-toolbar-right { display: flex !important; }
  #crm-sec-clientes .enc-toolbar-right .tbtn,
  #crm-sec-leads    .enc-toolbar-right .tbtn { display: flex !important; font-size: 12px; padding: 7px 12px; }
  #crm-sec-clientes .enc-toolbar-right .tbtn .topbar-btn-label,
  #crm-sec-leads    .enc-toolbar-right .tbtn .topbar-btn-label { display: none; }
  .crm-card-actions { flex-wrap: wrap; gap: 2px; }
  .kanban-board { gap: 8px; }
  .kanban-col { min-width: 160px; }

  /* Stats */
  .stats-bar  { padding: .6rem .75rem; gap: 6px; }
  .stat-pill  { font-size: 11px; padding: 3px 10px; }

  /* Board: coluna única com acordeão */
  .board {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 0 .75rem 1.5rem;
  }
  .day-col { min-height: unset; }
  .day-col.saturday { border-top: 2px solid var(--brand); }
  .day-header {
    cursor: pointer;
    user-select: none;
    padding-bottom: 10px;
    margin-bottom: 0;
  }
  .day-header::after { content: ' ▾'; font-size: 10px; color: #aaa; }
  .day-col.collapsed .day-header::after { content: ' ▸'; }
  .day-col.collapsed .day-cards,
  .day-col.collapsed .add-btn { display: none !important; }
  .day-col:not(.collapsed) .day-header { border-bottom: 0.5px solid #f0f0f0; margin-bottom: 8px; }
  .day-expand-hint { display: inline; font-size: 11px; color: #aaa; font-weight: 400; margin-left: 4px; }
  .day-col:not(.collapsed) .day-expand-hint { display: none; }

  /* Enc search */
  .enc-toolbar { flex-direction: column; align-items: stretch; }
  .enc-toolbar-left { flex-direction: column; align-items: stretch; }
  .enc-search-row { display: flex; align-items: center; gap: 8px; width: 100%; }
  .enc-search-wrap { flex: 1; }
  .enc-search-wrap, .enc-filter-estado, .filter-wrap, .sort-wrap { width: 100%; }
  .enc-search { width: 100%; }
  #btn-toolbar-toggle { display: flex !important; padding: 7px 11px !important; }
  #btn-toolbar-toggle.active { background: var(--brand); color: #fff; border-color: var(--brand); }
  /* Controlos escondidos por defeito no mobile */
  .filter-wrap, .sort-wrap, .enc-toolbar-right { display: none; }
  #btn-enc-ver-todas { display: none; }
  /* Mostrar quando aberto */
  .enc-toolbar.controls-open .filter-wrap,
  .enc-toolbar.controls-open .sort-wrap { display: block; width: 100%; }
  .enc-toolbar.controls-open .filter-wrap .tbtn,
  .enc-toolbar.controls-open .sort-wrap .tbtn { display: flex; width: 100%; justify-content: center; }
  .enc-toolbar.controls-open .enc-toolbar-right { display: flex; width: 100%; gap: 0; }
  .enc-toolbar.controls-open #btn-nova-enc { display: flex; width: 100%; justify-content: center; }
  .enc-toolbar.controls-open #btn-enc-ver-todas { display: flex; width: 100%; justify-content: center; }
  .sort-dropdown, .estado-pills-dropdown { position: static; width: 100%; min-width: unset; box-shadow: none; border-radius: 6px; margin-top: 4px; }
  .filter-wrap, .sort-wrap { position: relative; }
  .sort-pill[data-sort="manual"] { display: none; }
  .enc-list { grid-template-columns: 1fr; }
  .enc-layout-switcher { display: none; }
  .board-layout-switcher { display: none; }

  /* Modal */
  .modal-backdrop { padding: .5rem; -webkit-overflow-scrolling: touch; }
  .modal { padding: 1.25rem 1rem; }
  .modal-actions { flex-direction: column-reverse; }
  .modal-actions .btn-save, .modal-actions .btn-cancel,
  .modal-actions .btn-danger, .modal-actions .btn-secondary,
  .modal-actions .btn-success, .modal-actions .btn-primary { width: 100%; justify-content: center; padding: 11px; font-size: 13px; }
  .form-row { flex-direction: column; gap: 0; }
  .form-row .form-group.narrow { flex: unset; }
  .week-start-row { flex-direction: column; gap: 8px; }
}

/* ══════════════════════════════════════
   RASCUNHOS — Drawer + FAB
   ══════════════════════════════════════ */
.rascunhos-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.3);
  z-index: 1100;
  backdrop-filter: blur(2px);
}
.rascunhos-overlay.open { display: block; }

.rascunhos-drawer {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: 340px;
  max-width: 100vw;
  background: #fff;
  box-shadow: -4px 0 32px rgba(0,0,0,.12);
  z-index: 1101;
  display: flex;
  flex-direction: column;
  transform: translateX(-100%);
  transition: transform .3s cubic-bezier(.4,0,.2,1);
}
.rascunhos-drawer.open { transform: translateX(0); }
.dark-mode .rascunhos-drawer { background: #1a1a1a; }

.rascunhos-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 16px 12px;
  border-bottom: 1px solid #f0f0f0;
  flex-shrink: 0;
}
.dark-mode .rascunhos-header { border-color: #2a2a2a; }
.rascunhos-title {
  font-size: 15px; font-weight: 700;
  display: flex; align-items: center; gap: 8px;
}
.rascunhos-close {
  background: none; border: none; cursor: pointer;
  color: #aaa; font-size: 18px; padding: 4px;
  border-radius: 6px; display: flex; align-items: center;
}
.rascunhos-close:hover { background: #f5f5f5; color: #555; }
.dark-mode .rascunhos-close:hover { background: #2a2a2a; }

.rascunhos-hint {
  font-size: 11px; color: #aaa;
  padding: 8px 16px;
  display: flex; align-items: center; gap: 6px;
  border-bottom: 1px solid #f5f5f5;
  flex-shrink: 0;
}
.dark-mode .rascunhos-hint { border-color: #222; }

.rascunhos-list {
  flex: 1;
  overflow-y: auto;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.rascunho-card {
  background: #fafafa;
  border: 1px solid #ebebeb;
  border-radius: 10px;
  padding: 10px 12px;
  cursor: grab;
  transition: box-shadow .15s, border-color .15s;
  user-select: none;
}
.rascunho-card:hover { border-color: var(--brand); box-shadow: 0 2px 10px rgba(217,27,34,.1); }
.rascunho-card.dragging { opacity: .5; box-shadow: 0 4px 16px rgba(0,0,0,.15); }
.dark-mode .rascunho-card { background: #222; border-color: #333; }
.dark-mode .rascunho-card:hover { border-color: var(--brand); }

.rascunho-card-top {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 8px;
}
.rascunho-card-nome {
  font-size: 13px; font-weight: 600; color: #1a1a1a; flex: 1;
}
.dark-mode .rascunho-card-nome { color: #f0f0f0; }
.rascunho-card-actions {
  display: flex; gap: 4px; flex-shrink: 0;
}
.rascunho-card-actions button {
  background: none; border: none; cursor: pointer;
  color: #ccc; font-size: 14px; padding: 2px 4px;
  border-radius: 4px; display: flex; align-items: center;
}
.rascunho-card-actions button:hover { color: var(--brand); background: #fff0f0; }
.rascunho-card-info {
  font-size: 11px; color: #999; margin-top: 4px;
  display: flex; flex-direction: column; gap: 2px;
}
.rascunho-card-notas {
  font-size: 11px; color: #aaa;
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid #f0f0f0;
  white-space: pre-wrap;
}
.dark-mode .rascunho-card-notas { border-color: #2a2a2a; }

.rascunhos-empty {
  text-align: center; color: #bbb; padding: 40px 20px;
  font-size: 13px;
}
.rascunhos-empty i { font-size: 32px; display: block; margin-bottom: 8px; }

.rascunhos-search-wrap {
  position: relative; padding: 8px 16px 0; flex-shrink: 0;
}
.rascunhos-search-icon {
  position: absolute; left: 26px; top: calc(50% + 4px); transform: translateY(-50%);
  font-size: 13px; color: #bbb; pointer-events: none;
}
.rascunhos-search {
  width: 100%; padding: 7px 10px 7px 30px; border: 1px solid #e5e5e5;
  border-radius: 8px; font-size: 13px; font-family: inherit;
  background: #f9f9f9; color: #222; outline: none;
  -webkit-appearance: none; appearance: none;
}
.rascunhos-search:focus { border-color: var(--brand); background: #fff; }
.dark-mode .rascunhos-search { background: #2a2a2a; border-color: #333; color: #eee; }
.rascunhos-search-clear {
  position: absolute; right: 24px; top: calc(50% + 4px); transform: translateY(-50%);
  background: none; border: none; cursor: pointer; color: #bbb; font-size: 12px; padding: 2px;
  display: flex; align-items: center;
}
.rascunhos-search-clear:hover { color: #666; }

.rascunhos-footer {
  padding: 12px 16px;
  border-top: 1px solid #f0f0f0;
  flex-shrink: 0;
}
.dark-mode .rascunhos-footer { border-color: #2a2a2a; }

/* FAB */
.rascunhos-fab {
  position: fixed;
  bottom: 24px; left: 24px;
  width: 52px; height: 52px;
  background: var(--brand);
  color: #fff;
  border: none; border-radius: 50%;
  font-size: 22px;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(217,27,34,.4);
  z-index: 900;
  display: flex; align-items: center; justify-content: center;
  transition: transform .15s, box-shadow .15s;
}
.rascunhos-fab:hover { transform: scale(1.08); box-shadow: 0 6px 20px rgba(217,27,34,.5); }
.rascunhos-fab-badge {
  position: absolute;
  top: -4px; right: -4px;
  background: #1a1a1a;
  color: #fff;
  font-size: 10px; font-weight: 700;
  min-width: 18px; height: 18px;
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  padding: 0 4px;
  border: 2px solid #fff;
}


/* Drawer como zona de drop (quando arrasta entrega) */
.rascunhos-drawer.drop-target .rascunhos-list,
.rascunhos-drawer.drag-over-rascunho .rascunhos-list {
  outline: 2px dashed var(--brand);
  outline-offset: -6px;
  border-radius: 10px;
  background: rgba(217,27,34,.04);
}
.rascunhos-drawer.drop-target .rascunhos-hint,
.rascunhos-drawer.drag-over-rascunho .rascunhos-hint {
  color: var(--brand);
  font-weight: 600;
}

/* FAB estado de drop (quando arrasta entrega para o botão) */
.rascunhos-fab.fab-drop-over {
  transform: scale(1.18);
  box-shadow: 0 0 0 4px rgba(217,27,34,.35), 0 6px 24px rgba(217,27,34,.5);
  background: #b81118;
}

/* Popup agendar rascunho */
.agendar-popup {
  background: #fff;
  border: 1px solid #e5e5e5;
  border-radius: 14px;
  box-shadow: 0 12px 40px rgba(0,0,0,.25);
  padding: 24px 24px 20px;
  width: min(480px, calc(100vw - 2rem));
  margin-top: 4rem;
  align-self: flex-start;
}
.agendar-week-nav .week-nav-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.agendar-popup-title {
  font-weight: 700; font-size: 15px;
  margin-bottom: 4px;
  display: flex; align-items: center; gap: 7px;
}
.agendar-popup-sub {
  font-size: 12px; color: var(--text-muted);
  margin-bottom: 14px;
}
.agendar-week-nav {
  display: flex; align-items: center; gap: 6px;
  margin-bottom: 4px;
}
.agendar-week-nav .week-nav-btn:disabled { opacity: .3; cursor: default; }
.agendar-semanas {
  display: flex; flex-direction: column; gap: 5px;
  margin-bottom: 14px; max-height: 280px; overflow-y: auto;
}
.agendar-semana-btn {
  display: flex; align-items: center; gap: 6px;
  background: none; border: 0.5px solid #e0e0e0;
  border-radius: 6px; padding: 6px 14px;
  font-size: 13px; font-weight: 600; color: #444;
  cursor: pointer; text-align: left; font-family: 'Poppins', sans-serif;
  transition: all .15s;
}
.agendar-semana-btn:hover { background: #f5f5f5; border-color: var(--brand); color: var(--brand); }
.dark-mode .agendar-semana-btn { border-color: #3a3a3a; color: #ccc; }
.dark-mode .agendar-semana-btn:hover { background: #2a2a2a; border-color: var(--brand); color: var(--brand); }
.agendar-back {
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); padding: 2px 6px 2px 0; font-size: 14px;
  vertical-align: middle;
}
.agendar-back:hover { color: var(--brand); }
.agendar-dias {
  display: flex; flex-wrap: wrap; gap: 7px;
  margin-bottom: 14px;
}
.agendar-dia-btn {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 8px; padding: 7px 10px;
  font-size: 12px; font-weight: 600; cursor: pointer;
  flex: 1; min-width: 60px; text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  transition: background .15s, border-color .15s, color .15s;
}
.agendar-dia-btn:hover { background: var(--brand); border-color: var(--brand); color: #fff; }
.agendar-dia-nome { font-size: 12px; font-weight: 600; }
.agendar-dia-num { font-size: 15px; font-weight: 700; }
.agendar-cancel {
  width: 100%; background: none; border: 1px solid var(--border);
  border-radius: 8px; padding: 7px; font-size: 13px; cursor: pointer;
  color: var(--text-muted); transition: background .15s;
  display: flex; align-items: center; justify-content: center; gap: 5px;
}
.agendar-cancel:hover { background: var(--bg); }

@media (max-width: 768px) {
  .rascunhos-drawer { width: 100vw; }
  .rascunhos-fab { bottom: 80px; left: 16px; width: 48px; height: 48px; font-size: 20px; }
}

/* ══════════════════════════════════════
   PWA — Banner de instalação
   ══════════════════════════════════════ */
#pwa-banner {
  position: fixed;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%) translateY(120%);
  z-index: 9999;
  display: flex !important;
  align-items: center;
  gap: 12px;
  background: #fff;
  border: 1px solid #e8e8e8;
  border-radius: 16px;
  padding: 12px 14px;
  box-shadow: 0 8px 32px rgba(0,0,0,.14);
  min-width: 280px;
  max-width: calc(100vw - 2rem);
  transition: transform .4s cubic-bezier(.34,1.56,.64,1);
}
#pwa-banner.show {
  transform: translateX(-50%) translateY(0);
}
.dark-mode #pwa-banner {
  background: #1e1e1e;
  border-color: #333;
}
.pwa-banner-icon {
  width: 40px; height: 40px;
  background: var(--brand);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  font-size: 20px;
  flex-shrink: 0;
}
.pwa-banner-text {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.pwa-banner-text strong {
  font-size: 13px;
  font-weight: 600;
  color: #1a1a1a;
}
.dark-mode .pwa-banner-text strong { color: #f0f0f0; }
.pwa-banner-text span {
  font-size: 11px;
  color: #888;
  line-height: 1.4;
}
.pwa-banner-install {
  background: var(--brand);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 7px 13px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  display: flex; align-items: center; gap: 5px;
  font-family: inherit;
}
.pwa-banner-install:hover { background: var(--brand-hover); }
.pwa-banner-close {
  background: none;
  border: none;
  cursor: pointer;
  color: #aaa;
  font-size: 16px;
  padding: 4px;
  display: flex; align-items: center;
  border-radius: 6px;
  flex-shrink: 0;
}
.pwa-banner-close:hover { background: #f0f0f0; color: #555; }
.dark-mode .pwa-banner-close:hover { background: #2a2a2a; }

@media (max-width: 480px) {
  #pwa-banner {
    bottom: .75rem;
    padding: 10px 12px;
    gap: 10px;
    min-width: unset;
    width: calc(100vw - 1.5rem);
  }
  .pwa-banner-icon {
    width: 36px; height: 36px;
    font-size: 17px;
    border-radius: 8px;
  }
  .pwa-banner-text strong { font-size: 12px; }
  .pwa-banner-text span   { font-size: 11px; }
  .pwa-banner-install     { font-size: 12px; padding: 7px 11px; }
}

/* ══════════════════════════════════
   ORÇAMENTOS
   ══════════════════════════════════ */
.orc-panel { padding: .75rem 1.25rem 1.5rem; }

.orc-list { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }


/* Card de orçamento — elementos comuns */
.orc-card-notas-int { font-size: 11px; color: #9ca3af; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Card de orçamento */
.orc-card {
  background: var(--card-bg, #fff);
  border: 1px solid var(--border, #e5e7eb);
  border-left-width: 3px;
  border-radius: 12px;
  padding: 14px 16px;
  display: flex; align-items: center; gap: 14px;
  cursor: pointer;
  transition: box-shadow .15s;
}
.orc-card:hover { box-shadow: 0 2px 12px rgba(0,0,0,.08); }
.orc-card-ref-col { min-width: 110px; }
.orc-card-num { font-weight: 700; font-size: 13px; color: var(--primary, #c0392b); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.orc-card-ref-int { font-size: 11px; font-weight: 600; background: rgba(217,27,34,.1); color: var(--brand); border-radius: 4px; padding: 2px 8px; white-space: nowrap; }
.orc-card-tipo { font-size: 11px; color: #888; text-transform: uppercase; letter-spacing: .04em; }
.orc-card-cliente-col { flex: 1; display: flex; align-items: center; gap: 16px; min-width: 0; }
.orc-card-cliente-info { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.orc-card-docs-col { display: flex; flex-direction: row; gap: 6px; flex-shrink: 0; flex-wrap: wrap; }
.orc-card-docs-col .anexo-chip { max-width: 180px; }
.orc-card-docs-col .anexo-nome { max-width: 100px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.orc-doc-gerar { border: none; cursor: pointer; font-family: inherit; background: #f7f7f7; border: 0.5px solid #e5e5e5; border-radius: 8px; padding: 7px 10px; }
.orc-card-cliente-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.orc-card-cliente { font-size: 14px; font-weight: 500; }
.orc-card-morada { font-size: 12px; color: #6b7280; }
.orc-card-audit { font-size: 11px; color: #9ca3af; }
.orc-card-docs { display: flex; gap: 4px; }
.orc-doc-btn { display: flex; align-items: center; justify-content: center; width: 28px; height: 28px; border-radius: 6px; color: #6b7280; font-size: 16px; transition: color .15s, background .15s; }
.orc-doc-btn:hover { color: var(--primary,#c0392b); background: #fef2f2; }
.orc-card-docs-inline { display: flex; gap: 5px; margin-top: 4px; }
.orc-doc-chip { display: inline-flex; align-items: center; gap: 3px; font-size: 11px; font-weight: 500; padding: 2px 7px; border-radius: 4px; border: 1px solid #e5e7eb; background: #f9fafb; color: #6b7280; cursor: pointer; text-decoration: none; transition: background .15s, color .15s; font-family: 'Poppins', sans-serif; }
.orc-doc-chip:hover { background: #f3f4f6; color: #374151; }
.orc-doc-chip.orc-doc-ready { color: #16a34a; border-color: #bbf7d0; background: #f0fdf4; }
.orc-doc-chip.orc-doc-ready:hover { background: #dcfce7; }
.orc-doc-ready { color: #16a34a; }
.orc-detalhe-actions { flex-direction: column; align-items: stretch; gap: 10px; }
.orc-detalhe-row1, .orc-detalhe-row2 { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.orc-pag-saldo-bar { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; background: var(--surface2,#f9fafb); border-radius: 8px; margin: 12px 0 6px; border: 1px solid var(--border,#e5e7eb); }
.orc-pag-saldo-label { font-size: 13px; font-weight: 600; color: var(--text2,#6b7280); }
.orc-pag-saldo-valor { font-size: 15px; font-weight: 700; }
.orc-pag-row { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--border,#e5e7eb); font-size: 13px; }
.orc-pag-row:last-child { border-bottom: none; }
.orc-pag-data { min-width: 70px; color: var(--text2,#6b7280); }
.orc-pag-desc { flex: 1; color: var(--text,#374151); }
.orc-pag-val { font-weight: 600; min-width: 70px; text-align: right; color: #16a34a; }
.orc-pag-del { background: none; border: none; cursor: pointer; color: #9ca3af; padding: 2px 4px; border-radius: 4px; line-height: 1; }
.orc-pag-del:hover { color: #dc2626; background: #fef2f2; }
.orc-pag-empty { font-size: 12px; color: #9ca3af; padding: 6px 0; }
.orc-doc-ready:hover { color: #15803d; background: #f0fdf4; }
.orc-card-valor { font-size: 14px; font-weight: 600; min-width: 80px; text-align: right; }
.orc-card-valor-label { display: block; font-size: 10px; font-weight: 400; color: #9ca3af; text-transform: uppercase; letter-spacing: .04em; }
.orc-card-estado {
  font-size: 11px; font-weight: 600; padding: 3px 9px; border-radius: 20px;
  text-transform: uppercase; letter-spacing: .04em;
}
.orc-card-estado.rascunho       { background: #fffbeb; color: #92400e; border: 1px solid #f59e0b; }
.orc-card-estado.aprovado       { background: #eff6ff; color: #1e40af; border: 1px solid #3b82f6; }
.orc-card-estado.adjudicado     { background: #f0fdf4; color: #166534; border: 1px solid #22c55e; }
.orc-card-estado.nao_adjudicado { background: #fff5f5; color: var(--brand); border: 1px solid var(--brand); }
.orc-card-estado.enviado        { background: #eff6ff; color: #1e40af; border: 1px solid #3b82f6; }
.orc-card-estado.cancelado      { background: #fff5f5; color: var(--brand); border: 1px solid var(--brand); }
/* Dots orçamentos */
.dot-orc-rascunho       { background: #f59e0b; }
.dot-orc-aprovado       { background: #3b82f6; }
.dot-orc-adjudicado     { background: #22c55e; }
.dot-orc-nao_adjudicado { background: var(--brand); }
/* Filtro estado orçamentos — pills ativos */
#orc-estado-dropdown .estado-pill.active[data-estado="rascunho"]       { background: #fffbeb; color: #92400e; border-color: #f59e0b; }
#orc-estado-dropdown .estado-pill.active[data-estado="aprovado"]       { background: #eff6ff; color: #1e40af; border-color: #3b82f6; }
#orc-estado-dropdown .estado-pill.active[data-estado="adjudicado"]     { background: #f0fdf4; color: #166534; border-color: #22c55e; }
#orc-estado-dropdown .estado-pill.active[data-estado="nao_adjudicado"] { background: #fff5f5; color: var(--brand); border-color: var(--brand); }
.filter-active-dot.dot-orc-rascunho       { background: #f59e0b; }
.filter-active-dot.dot-orc-aprovado       { background: #3b82f6; }
.filter-active-dot.dot-orc-adjudicado     { background: #22c55e; }
.filter-active-dot.dot-orc-nao_adjudicado { background: var(--brand); }
.orc-card-info-col { display: flex; flex-direction: column; gap: 4px; align-items: flex-end; min-width: 130px; }
.orc-card-validade { font-size: 14px; font-weight: 500; display: flex; flex-direction: column; align-items: flex-end; gap: 1px; }
.orc-val-ok  { color: #3b82f6; }
.orc-val-hoje { color: #f59e0b; font-weight: 600; }
.orc-val-exp  { color: var(--brand); }
.orc-card-saldo { font-size: 14px; font-weight: 500; display: flex; flex-direction: column; align-items: flex-end; gap: 1px; color: var(--brand); }
.orc-saldo-de { font-weight: 400; opacity: .7; }
.orc-saldo-pago { color: #16a34a; }
.orc-card-date { font-size: 12px; color: #9ca3af; min-width: 90px; text-align: right; }
.orc-empty { text-align: center; color: #aaa; padding: 60px 0; font-size: 15px; }
.orc-mes-grupo { margin-bottom: 1.5rem; }
.orc-mes-header { font-size: 13px; font-weight: 600; color: #888; margin-bottom: 12px; }

/* Modal form orçamento */
.modal-orc-form { max-width: 860px; width: 95vw; }
.orc-form-grid { display: flex; flex-direction: column; gap: 12px; }
.orc-section-title {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em;
  color: #9ca3af; margin-top: 6px; padding-bottom: 6px;
  border-bottom: 1px solid var(--border, #e5e7eb);
  display: flex; align-items: center; justify-content: space-between;
}
.orc-artigos-btns { display: flex; gap: 6px; align-items: center; }
.orc-form-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: stretch; }
.orc-form-row .form-group { flex: 1; min-width: 140px; display: flex; flex-direction: column; }
.orc-fg-wide { flex: 2 !important; min-width: 220px !important; }

/* Tipo toggle */
.orc-tipo-toggle { display: flex; gap: 0; border: 1px solid var(--border, #e5e7eb); border-radius: 8px; overflow: hidden; align-self: stretch; }
.orc-lingua-select-wrap { display: flex; align-items: center; gap: 6px; padding: 6px 10px; border: 1px solid var(--border,#e5e7eb); border-radius: 8px; color: #6b7280; }
.orc-lingua-select-wrap i { font-size: 16px; flex-shrink: 0; }
.orc-lingua-select-wrap select { border: none; background: none; font-size: 13px; font-weight: 500; color: inherit; cursor: pointer; outline: none; padding: 0; }
.orc-canal-toggle { display: flex; gap: 0; border: 1px solid var(--border,#e5e7eb); border-radius: 8px; overflow: hidden; align-self: stretch; }
.orc-canal-btn { flex: 1; padding: 6px 12px; border: none; background: none; cursor: pointer; font-size: 13px; font-weight: 500; color: #6b7280; transition: background .15s, color .15s; display: flex; align-items: center; gap: 5px; justify-content: center; white-space: nowrap; }
.orc-canal-btn + .orc-canal-btn { border-left: 1px solid var(--border,#e5e7eb); }
.orc-canal-btn.active { background: var(--primary,#c0392b); color: #fff; }
.orc-tipo-btn {
  flex: 1; padding: 6px 14px; border: none; background: none; cursor: pointer;
  font-size: 13px; font-weight: 500; color: #6b7280; transition: background .15s, color .15s;
  line-height: 1.2; white-space: nowrap;
}
.orc-tipo-btn small { font-size: 9px; opacity: .7; font-weight: 400; }
.orc-tipo-btn.active { background: var(--primary, #c0392b); color: #fff; }

/* Tabela artigos */
.orc-artigos-table-wrap { overflow-x: auto; border: 1px solid var(--border, #e5e7eb); border-radius: 8px; }
.orc-artigos-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.orc-artigos-table th {
  background: #f9fafb; padding: 8px 10px; text-align: left;
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  color: #6b7280; letter-spacing: .04em; border-bottom: 1px solid var(--border, #e5e7eb);
}
.orc-artigos-table td { padding: 6px 6px; border-bottom: 1px solid var(--border, #e5e7eb); vertical-align: middle; }
.orc-artigos-table tr:last-child td { border-bottom: none; }
.orc-artigos-table input, .orc-artigos-table textarea {
  width: 100%; border: 1px solid var(--border, #e5e7eb); border-radius: 5px;
  padding: 5px 7px; font-size: 13px; background: var(--input-bg, #fff);
  transition: border .15s, background .15s; color: inherit;
}
.orc-artigos-table input:focus, .orc-artigos-table textarea:focus {
  border-color: var(--primary, #c0392b); outline: none;
}
.orc-artigos-table textarea { resize: vertical; min-height: 38px; }
.orc-ce-field { width: 100%; min-height: 62px; padding: 5px 8px; border: 1px solid var(--border, #e5e7eb); border-radius: 5px; font-size: 13px; line-height: 1.4; white-space: pre-wrap; word-break: break-word; cursor: text; box-sizing: border-box; outline: none; }
.orc-ce-field:focus { border-color: var(--primary, #c0392b); }
.orc-ce-field:empty::before { content: attr(data-placeholder); color: #bbb; pointer-events: none; }
.dark-mode .orc-ce-field { background: transparent; color: inherit; border-color: #3a3f47; }
.dark-mode .orc-ce-field:focus { border-color: var(--primary); background: #23282e; }
.orc-col-img  { width: 52px; }
.orc-col-qt   { width: 80px; }
.qt-wrap { display: flex; align-items: center; gap: 2px; }
.qt-wrap input { width: 32px; text-align: center; border: 1px solid var(--border,#e5e7eb); border-radius: 5px; padding: 4px 2px; font-size: 13px; }
.qt-btn { background: #f3f4f6; border: 1px solid var(--border,#e5e7eb); border-radius: 4px; width: 22px; height: 26px; cursor: pointer; font-size: 14px; line-height: 1; display: flex; align-items: center; justify-content: center; color: #555; flex-shrink: 0; }
.qt-btn:hover { background: #e5e7eb; }
.orc-col-des  { min-width: 160px; }
.orc-col-med  { min-width: 110px; }
.orc-col-mat  { min-width: 90px; }
.orc-col-preco { width: 220px; min-width: 220px; }
.orc-preco-nota-ce { font-size: 11px; color: #6b7280; margin-bottom: 4px; min-height: 24px; }
.orc-preco-nota-ce:empty::before { font-size: 11px; }
.orc-preco-total { font-size: 11px; font-weight: 600; color: #374151; margin-top: 3px; }
.orc-preco-wrap { display: flex; align-items: center; gap: 3px; }
.orc-un-lbl { font-size: 11px; color: #6b7280; white-space: nowrap; flex-shrink: 0; }
.orc-preco-wrap .orc-preco-input { flex: 1; min-width: 0; }

/* ── Per-artigo price + discount side by side ── */
.orc-artigo-precos-row { display: flex; gap: 8px; align-items: flex-end; }
.orc-artigo-precos-row .orc-preco-wrap { margin: 0; }
.orc-artigo-preco-group { display: flex; flex-direction: column; gap: 3px; }
.orc-artigo-preco-lbl { font-size: 10px; font-weight: 600; color: #9ca3af; text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; }
.orc-artigo-preco-group .orc-preco-input { width: 90px; }
.orc-artigo-desc-inner { margin-top: 5px; display: flex; flex-direction: column; gap: 4px; }
.orc-artigo-ef-wrap { display: flex; flex-direction: column; gap: 3px; }
.orc-ef-input-wrap { position: relative; display: inline-flex; align-items: center; }
.orc-artigo-preco-ef { width: 90px; font-size: 13px; padding: 3px 26px 3px 6px; border: 1px solid #fca5a5; border-radius: 6px; background: #fff5f5; color: var(--text,#111); }
.orc-ef-calc-btn { position: absolute; right: 5px; background: none; border: none; cursor: pointer; color: #9ca3af; padding: 0; line-height: 1; font-size: 14px; display: flex; align-items: center; }
.orc-ef-calc-btn:hover { color: var(--primary,#c0392b); }
.orc-ef-calc-tooltip { display: none; position: fixed; z-index: 9999; background: #fff; border: 1px solid var(--border,#e5e7eb); border-radius: 10px; padding: 10px 12px; box-shadow: 0 8px 24px rgba(0,0,0,.12); width: max-content; flex-direction: column; gap: 8px; }
.orc-ef-calc-tooltip.open { display: flex; }
.orc-ef-calc-row { display: flex; align-items: center; gap: 6px; }
.orc-ef-iva-btn { text-align: center; padding: 5px 8px; font-size: 12px; border: 1px solid var(--border,#e5e7eb); border-radius: 6px; background: #f9fafb; cursor: pointer; color: #374151; width: 100%; }
.orc-ef-iva-btn:hover { background: #f3f4f6; }
.orc-artigo-desc-result { position: absolute; right: 6px; font-size: 10px; font-weight: 600; color: #ef4444; white-space: nowrap; pointer-events: none; }
.orc-artigo-nota-row { background: #fff; }
.orc-artigo-nota-row.hidden { display: none; }
.orc-artigo-nota-row td { border: none !important; border-bottom: 1px solid var(--border,#e5e7eb) !important; padding: 0 !important; }
.orc-artigo-nota-cell { padding: 0 8px 8px 8px !important; }
.orc-artigo-main-row.nota-open td { border-bottom: none !important; }
.orc-artigo-nota-cell .orc-ce-field { font-size: 13px; min-height: 22px; }
.orc-artigo-nota-btn, .orc-artigo-dup-btn { background: none; border: none; cursor: pointer; color: #9ca3af; padding: 4px; border-radius: 5px; font-size: 15px; display: flex; align-items: center; }
.orc-artigo-nota-btn:hover, .orc-artigo-nota-btn.active { color: var(--primary,#c0392b); }
.orc-artigo-dup-btn:hover { color: #3b82f6; }
/* Linha de envio */
.orc-envio-row { background: #f9fafb; }
.orc-envio-icon-cell { text-align: center; vertical-align: middle; }
.orc-envio-gratuito-btn { background: none; border: none; cursor: pointer; color: #9ca3af; padding: 4px; border-radius: 5px; font-size: 15px; display: flex; align-items: center; }
.orc-envio-gratuito-btn:hover { color: #0f9d58; }
.orc-envio-gratuito-btn.active { color: #0f9d58; }
.orc-envio-preco-riscado { text-decoration: line-through; color: #9ca3af; }
.orc-envio-preco-linha { display: flex; align-items: center; gap: 8px; }
.orc-envio-gratuito-label { font-size: 12px; font-weight: 600; color: #0f9d58; white-space: nowrap; display: none; }
.orc-envio-gratuito-label.visible { display: inline; }
.orc-add-envio { color: #374151; border-color: #d1d5db; margin-left: 4px; }
.orc-add-envio:hover { border-color: #9ca3af; background: #f9fafb; }
.orc-artigo-desc-outer { margin-top: 4px; }
.orc-artigo-desc-wrap { display: flex; align-items: center; gap: 3px; padding: 3px 5px; background: #fef2f2; border-radius: 5px; border: 1px solid #fca5a5; }
.orc-artigo-desc-tipo { display: flex; border: 1px solid #d1d5db; border-radius: 4px; overflow: hidden; flex-shrink: 0; }
.orc-artigo-desc-btn { font-size: 10px; padding: 2px 5px; border: none; background: #f9fafb; cursor: pointer; color: #374151; line-height: 1.4; }
.orc-artigo-desc-btn.active { background: #c0392b; color: #fff; }
.orc-artigo-desc-val { width: 44px; font-size: 11px; padding: 2px 4px; border: 1px solid #d1d5db; border-radius: 4px; min-width: 0; }
.orc-artigo-desc-sym { font-size: 10px; color: #6b7280; flex-shrink: 0; }
.orc-artigo-desc-iva-btn { font-size: 9px; padding: 2px 4px; border: 1px solid #d1d5db; border-radius: 3px; background: #f9fafb; cursor: pointer; color: #374151; white-space: nowrap; flex-shrink: 0; line-height: 1.4; }
.orc-artigo-desc-iva-btn.active { background: #c0392b; color: #fff; border-color: #c0392b; }
.orc-artigo-desc-result { font-size: 11px; font-weight: 600; color: #c0392b; margin-top: 2px; }
.orc-artigo-desc-toggle { font-size: 11px; padding: 2px 5px; border: 1px solid #d1d5db; border-radius: 4px; background: #f9fafb; cursor: pointer; color: #9ca3af; line-height: 1.4; flex-shrink: 0; }
.orc-artigo-desc-toggle.active { background: #fef2f2; color: #c0392b; border-color: #fca5a5; }

/* ── Rich-text toolbar ── */
.orc-rich-toolbar {
  position: fixed; z-index: 9999; display: none;
  background: #1f2937; border-radius: 6px; padding: 3px 4px;
  gap: 2px; box-shadow: 0 2px 8px rgba(0,0,0,.25);
}
.orc-rich-toolbar button {
  background: none; border: none; color: #f9fafb; cursor: pointer;
  padding: 3px 8px; border-radius: 4px; font-size: 13px; font-family: inherit;
  transition: background .1s;
}
.orc-rich-toolbar button:hover { background: #374151; }

/* Imagem artigo */
.orc-artigo-img-wrap { position: relative; width: 38px; height: 38px; cursor: pointer; }
.orc-artigo-img-wrap img { width: 38px; height: 38px; object-fit: cover; border-radius: 5px; border: 1px solid #e5e7eb; display: block; }
.orc-artigo-img-placeholder {
  width: 38px; height: 38px; border: 1.5px dashed #d1d5db; border-radius: 5px;
  display: flex; align-items: center; justify-content: center; color: #d1d5db; font-size: 18px;
}
.orc-artigo-img-loading {
  width: 38px; height: 38px; border: 1.5px dashed #d1d5db; border-radius: 5px;
  display: flex; align-items: center; justify-content: center; color: #9ca3af; font-size: 16px;
}
.orc-artigo-img-loading i { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.orc-artigo-img-input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.orc-artigo-img-remove {
  position: absolute; top: -6px; right: -6px;
  width: 16px; height: 16px; border-radius: 50%;
  background: #ef4444; color: #fff; border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 9px; line-height: 1; padding: 0; z-index: 2;
}
.orc-artigo-img-remove:hover { background: #dc2626; }

/* Botão remover artigo */
.orc-col-del { width: 34px; text-align: center; vertical-align: top; }
.orc-col-del { display: table-cell; }
.orc-col-del > button { display: block; margin: 0 auto; }
.orc-del-artigo { background: none; border: none; cursor: pointer; color: #d1d5db; padding: 4px; border-radius: 5px; }
.orc-del-artigo:hover { color: #ef4444; background: #fee2e2; }

/* Modal header with inline tipo+lingua toggles */
.orc-modal-header { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 4px; }
.orc-ref-interna-bar { display: flex; align-items: center; gap: 10px; padding: 8px 0 10px; border-bottom: 1px solid var(--border,#e5e7eb); margin-bottom: 14px; }
.orc-ref-interna-bar label { font-size: 11px; font-weight: 600; color: #9ca3af; text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; }
.orc-ref-interna-bar input { width: 200px; font-size: 13px; padding: 4px 8px; border: 1px solid var(--border,#e5e7eb); border-radius: 6px; }
.orc-modal-header h3 { margin: 0; flex-shrink: 0; }

/* Collapsible descontos */
.orc-descontos-toggle-btn { font-size: 11px; font-weight: 600; color: #6b7280; background: var(--border,#e5e7eb); border: none; border-radius: 12px; padding: 2px 8px; cursor: pointer; white-space: nowrap; transition: background .15s; }
.orc-descontos-toggle-btn:hover { background: #d1d5db; }
.orc-descontos-toggle-btn.open .orc-descontos-arrow { display: inline-block; transform: rotate(180deg); }
.orc-descontos-wrap { overflow: hidden; transition: max-height .25s ease; max-height: 300px; }
.orc-descontos-wrap--closed { max-height: 0; }

/* Breakdown total */
.orc-breakdown { border: 1px solid var(--border,#e5e7eb); border-radius: 8px; overflow: hidden; font-size: 13px; }
.orc-breakdown-row { display: flex; align-items: center; justify-content: space-between; padding: 7px 12px; gap: 10px; }
.orc-breakdown-sub { background: #f9fafb; color: #6b7280; }
.dark-mode .orc-breakdown-sub { background: #1e2328; }
.orc-breakdown-desc { border-top: 1px solid var(--border,#e5e7eb); }
.orc-breakdown-iva  { border-top: 1px solid var(--border,#e5e7eb); }
.orc-breakdown-total { border-top: 2px solid var(--border,#e5e7eb); font-size: 15px; background: #f9fafb; }
.dark-mode .orc-breakdown-total { background: #1e2328; }
.orc-breakdown-nota { border-top: 1px solid var(--border,#e5e7eb); padding: 6px 10px; }
.orc-breakdown-nota textarea { width: 100%; border: none; outline: none; resize: none; font-size: 12px; background: transparent; color: inherit; font-family: inherit; padding: 0; }
.orc-breakdown-neg { color: #c0392b; font-weight: 600; white-space: nowrap; }
.orc-breakdown-pos { color: #374151; font-weight: 600; white-space: nowrap; }
.orc-desc-left { display: flex; align-items: center; gap: 6px; }
.orc-desc-tipo { display: flex; border: 1px solid var(--border,#e5e7eb); border-radius: 6px; overflow: hidden; }
.orc-desc-btn { padding: 3px 9px; border: none; background: none; cursor: pointer; font-size: 12px; font-weight: 500; color: #6b7280; }
.orc-desc-btn.active { background: var(--primary,#c0392b); color: #fff; }
.orc-desc-input { width: 70px; padding: 3px 6px; font-size: 13px; border: 1px solid var(--border,#e5e7eb); border-radius: 6px; }
.orc-desc-pct-wrap { display: flex; align-items: center; gap: 6px; }
.orc-desc-slider {
  -webkit-appearance: none; appearance: none;
  width: 110px; max-width: 110px; height: 16px; flex-shrink: 0; flex-grow: 0;
  background: transparent;
  cursor: pointer; padding: 0 8px; box-sizing: border-box;
  margin: 0; outline: none;
}
.orc-desc-slider::-webkit-slider-runnable-track {
  height: 4px; background: #e5e7eb; border-radius: 2px;
}
.orc-desc-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px; height: 16px; border-radius: 50%;
  background: #c0392b; cursor: pointer;
  border: 2px solid #fff; box-shadow: 0 1px 3px rgba(0,0,0,.2);
  margin-top: -6px;
}
.orc-desc-slider::-moz-range-track { height: 4px; background: #e5e7eb; border-radius: 2px; }
.orc-desc-slider::-moz-range-thumb {
  width: 16px; height: 16px; border-radius: 50%;
  background: #c0392b; cursor: pointer;
  border: 2px solid #fff; box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.orc-desc-pct-input { display: inline-block; width: 42px; min-width: 42px; padding: 2px 4px; font-size: 12px; font-weight: 600; border: 1px solid var(--border,#e5e7eb); border-radius: 5px; text-align: center; box-sizing: border-box; }
.orc-desc-pct-input::-webkit-inner-spin-button, .orc-desc-pct-input::-webkit-outer-spin-button { display: none; }
.orc-desc-preset-btn { padding: 3px 8px; border: 1px solid var(--border,#e5e7eb); border-radius: 6px; background: none; cursor: pointer; font-size: 11px; color: #6b7280; white-space: nowrap; }
.orc-desc-preset-btn:hover { background: #f3f4f6; color: #374151; }
.orc-desc-preset-btn.active { background: var(--primary,#c0392b); color: #fff; border-color: var(--primary,#c0392b); }
.orc-breakdown-check { display: flex; align-items: center; gap: 6px; cursor: pointer; user-select: none; }
.orc-breakdown-check input { accent-color: var(--primary,#c0392b); }

/* Footer opts */
/* Secção extra (entrega prevista + condições pag.) */
.orc-extra-section { display: flex; flex-direction: column; gap: 0; border: 1px solid var(--border,#e5e7eb); border-radius: 8px; overflow: hidden; font-size: 13px; }
.orc-extra-row { background: #f9fafb; padding: 8px 12px; border-bottom: 1px solid var(--border,#e5e7eb); }
.orc-extra-row:last-child { border-bottom: none; }
.orc-extra-section .orc-extra-bottom { display: flex; flex-direction: row; border-bottom: 1px solid var(--border,#e5e7eb); }
.orc-extra-section .orc-extra-bottom:last-child { border-bottom: none; }
.orc-extra-section .orc-extra-bottom .orc-extra-row { flex: 1; border-bottom: none; border-right: 1px solid var(--border,#e5e7eb); }
.orc-extra-section .orc-extra-bottom .orc-extra-row:last-child { border-right: none; }
.dark-mode .orc-extra-row { background: #1e2328; }
.orc-extra-row { display: flex; flex-direction: column; gap: 6px; }
.orc-extra-check-label { display: flex; align-items: center; gap: 6px; font-size: 13px; cursor: pointer; user-select: none; }
.orc-extra-check-label input[type="checkbox"] { width: 15px; height: 15px; cursor: pointer; accent-color: var(--primary,#c0392b); }
.orc-extra-body { padding-left: 22px; }
.orc-extra-body textarea { width: 100%; font-size: 13px; border: 1px solid var(--border,#e5e7eb); border-radius: 6px; padding: 6px 8px; resize: vertical; font-family: inherit; color: var(--text,#111827); background: var(--card-bg,#fff); }
.orc-cond-pag-row { display: flex; align-items: center; gap: 8px; font-size: 13px; flex-wrap: wrap; }
.orc-cond-pag-row input[type="number"] { width: 60px; padding: 4px 6px; font-size: 13px; border: 1px solid var(--border,#e5e7eb); border-radius: 6px; text-align: center; }
.orc-cond-sep { color: #9ca3af; font-weight: 700; }
.orc-footer-opts { display: flex; align-items: center; gap: 16px; padding: 10px 0; flex-wrap: wrap; }
.orc-footer-cell { display: flex; flex-direction: column; justify-content: flex-start; }
.iban-add-btn { display: inline-flex; align-items: center; gap: 6px; padding: 6px 14px; border: 1px dashed var(--border,#e5e7eb); border-radius: 7px; background: none; font-size: 13px; font-weight: 500; color: #6b7280; cursor: pointer; transition: border-color .15s, color .15s; margin-top: 4px; }
.iban-add-btn:hover { border-color: var(--brand,#d91b22); color: var(--brand,#d91b22); }
.dark-mode .iban-add-btn { color: #9ca3af; border-color: #3d4149; }
.dark-mode .iban-add-btn:hover { border-color: var(--brand,#d91b22); color: var(--brand,#d91b22); }
.iban-item { display: grid; grid-template-columns: 1fr 2fr auto auto; gap: 8px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--border,#e5e7eb); }
.iban-item:last-of-type { border-bottom: none; }
.iban-item input { padding: 6px 10px; border: 1px solid var(--border,#e5e7eb); border-radius: 7px; font-size: 13px; background: var(--input-bg,#fff); color: inherit; width: 100%; }
.iban-item input:focus { outline: none; border-color: var(--brand,#d91b22); }
.iban-save-btn { padding: 6px 14px; border-radius: 7px; border: 1px solid var(--border,#e5e7eb); background: #f9fafb; font-size: 13px; font-weight: 500; color: #374151; cursor: pointer; white-space: nowrap; transition: background .15s; }
.iban-save-btn:hover { background: #f3f4f6; }
.iban-del-btn { width: 32px; height: 32px; border-radius: 7px; border: none; background: #fee2e2; color: #dc2626; cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 15px; transition: background .15s; flex-shrink: 0; }
.iban-del-btn:hover { background: #fecaca; }
.dark-mode .iban-save-btn { background: #2d3139; border-color: #3d4149; color: #e5e7eb; }
.dark-mode .iban-save-btn:hover { background: #3d4149; }
.dark-mode .iban-del-btn { background: rgba(220,38,38,.2); color: #f87171; }
.dark-mode .iban-item { border-color: #2d3139; }
.orc-footer-check-label { display: flex; align-items: center; gap: 6px; font-size: 13px; cursor: pointer; user-select: none; }
.orc-footer-check-label input[type="checkbox"] { width: 15px; height: 15px; cursor: pointer; accent-color: var(--primary,#c0392b); }
.orc-footer-check-label small { color: #9ca3af; font-size: 11px; }
.orc-iva-toggle { display: inline-flex; gap: 0; border: 1px solid var(--border,#e5e7eb); border-radius: 8px; overflow: hidden; align-self: flex-start; width: fit-content; }
.orc-iva-btn { padding: 5px 14px; border: none; background: none; cursor: pointer; font-size: 13px; font-weight: 500; color: #6b7280; transition: background .15s, color .15s; }
.orc-iva-btn.active { background: var(--primary,#c0392b); color: #fff; }
.orc-iva-toggle.disabled { pointer-events: none; }
.orc-iva-toggle.disabled .orc-iva-btn { color: #9ca3af; cursor: default; background: none; }
.orc-iva-toggle.disabled .orc-iva-btn.active { background: none; color: #9ca3af; }
.orc-validade-wrap.disabled { opacity: .4; pointer-events: none; }

/* Modal detalhe */
.modal-orc-detalhe-inner { max-width: 700px; width: 95vw; }
.orc-detalhe-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 16px; }
.orc-detalhe-num { font-size: 22px; font-weight: 800; color: var(--primary, #c0392b); }
.orc-detalhe-tipo { font-size: 12px; color: #9ca3af; margin-top: 2px; }
.orc-detalhe-cliente { font-size: 14px; color: #374151; line-height: 1.6; }
.orc-detalhe-table { width: 100%; border-collapse: collapse; font-size: 13px; margin: 16px 0; }
.orc-detalhe-table th { background: #f3f4f6; padding: 7px 10px; text-align: left; font-size: 11px; font-weight: 700; color: #6b7280; text-transform: uppercase; }
.orc-detalhe-table td { padding: 8px 10px; border-bottom: 1px solid #f3f4f6; }
.orc-detalhe-table tr:last-child td { border-bottom: none; }
.orc-detalhe-table img { width: 36px; height: 36px; object-fit: cover; border-radius: 4px; }
.orc-detalhe-total { text-align: right; font-size: 15px; font-weight: 700; padding: 10px 0; border-top: 2px solid var(--border, #e5e7eb); }
.orc-detalhe-footer-txt { font-size: 12px; color: #6b7280; margin-top: 8px; padding-top: 8px; border-top: 1px solid #f3f4f6; }
.orc-detalhe-audit { font-size: 12px; color: #9ca3af; margin-top: 16px; padding-top: 12px; border-top: 1px solid #f3f4f6; }

.orc-card--rascunho       { border-left-color: #f59e0b; background: #fffdf5; }
.orc-card--aprovado       { border-left-color: #3b82f6; background: #f5f9ff; }
.orc-card--adjudicado     { border-left-color: #22c55e; background: #f5fff8; }
.orc-card--nao_adjudicado { border-left-color: var(--brand); background: #fff5f5; }
.dark-mode .orc-card { background: #1e2328; border-color: #2d3139; }
.dark-mode .orc-card--rascunho       { background: #1e2328; border-left-color: #f59e0b; }
.dark-mode .orc-card--aprovado       { background: #1e2328; border-left-color: #3b82f6; }
.dark-mode .orc-card--adjudicado     { background: #1e2328; border-left-color: #22c55e; }
.dark-mode .orc-card--nao_adjudicado { background: #1e2328; border-left-color: var(--brand); }
.dark-mode .orc-artigos-table th { background: #1e2328; color: #9ca3af; }
.dark-mode .orc-descontos-toggle-btn { background: #2d3139; color: #9ca3af; }
.dark-mode .orc-descontos-toggle-btn:hover { background: #3d4149; }
.dark-mode .orc-desc-btn { color: #9ca3af; }
.dark-mode .orc-artigos-table-wrap { border-color: #2d3139; }
.dark-mode .orc-artigos-table input, .dark-mode .orc-artigos-table textarea { background: transparent; }
.dark-mode .orc-artigos-table input:focus, .dark-mode .orc-artigos-table textarea:focus { background: #23282e; }

/* ── Botão verde ── */
.btn-success { background: #16a34a; color: #fff; border: none; border-radius: 6px; padding: 7px 14px; font-size: 13px; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; transition: background .15s; }
.btn-success:hover { background: #15803d; }

/* ── Badges estado orçamento ── */
.orc-estado.adjudicado { background: #dcfce7; color: #15803d; }
.orc-estado.nao_adjudicado { background: #f1f5f9; color: #64748b; }
.dark-mode .orc-estado.adjudicado { background: #14532d; color: #86efac; }
.dark-mode .orc-estado.nao_adjudicado { background: #1e2328; color: #94a3b8; }

/* ── Método de pagamento toggle ── */
.orc-metodo-toggle { display: flex; flex-wrap: wrap; gap: 6px; }
.orc-metodo-btn { padding: 5px 12px; font-size: 12px; border: 1px solid var(--border, #e5e7eb); border-radius: 6px; background: var(--bg, #fff); color: #6b7280; cursor: pointer; transition: all .15s; }
.orc-metodo-btn.active { background: #16a34a; color: #fff; border-color: #16a34a; }
.dark-mode .orc-metodo-btn { background: #1f2937; color: #9ca3af; }
.dark-mode .orc-metodo-btn.active { background: #16a34a; color: #fff; }

/* ── Adjudicação inline no form Proforma ── */
#orc-adj-section { margin-top: 12px; border: 1px solid var(--border,#e5e7eb); border-radius: 8px; overflow: hidden; font-size: 13px; }
.orc-adj-section-title { font-weight: 600; font-size: 12px; color: #6b7280; background: #f9fafb; padding: 7px 12px; letter-spacing: .04em; text-transform: uppercase; }
.dark-mode .orc-adj-section-title { background: #1e2328; }
#orc-adj-section .form-row, #orc-adj-section .form-group { margin: 0; }
#orc-adj-section .orc-adj-body { padding: 12px; display: flex; flex-direction: column; gap: 10px; border-top: 1px solid var(--border,#e5e7eb); }

/* ── Adjudicação info no detalhe ── */
.orc-adj-info { display:flex; gap:12px; align-items:flex-start; background:#f0fdf4; border:1.5px solid #86efac; border-radius:10px; padding:12px 14px; margin-top:14px; font-size:13px; color:#166534; }
.orc-adj-info .ti { font-size:20px; margin-top:2px; flex-shrink:0; }
.orc-adj-title { font-weight:700; margin-bottom:4px; }
.orc-adj-info div div { margin:2px 0; }
.orc-adj-edit-btn { background:none; border:none; cursor:pointer; color:#16a34a; opacity:.5; padding:2px 4px; border-radius:6px; font-size:15px; align-self:flex-start; transition:opacity .15s; }
.orc-adj-edit-btn:hover { opacity:1; background:#dcfce7; }
.dark-mode .orc-adj-info { background:#14532d; border-color:#16a34a; color:#bbf7d0; }
.dark-mode .orc-adj-edit-btn { color:#86efac; }
.dark-mode .orc-adj-edit-btn:hover { background:#166534; }

/* ── Encomenda: banner orçamento e campos wide ── */
.enc-orc-banner {
  display: flex; align-items: center; gap: 8px;
  background: #eff6ff; color: #1d4ed8; border: 1px solid #bfdbfe;
  border-radius: 8px; padding: 8px 12px; font-size: 13px; margin-bottom: 12px;
}
.dark-mode .enc-orc-banner { background: #1e2a3a; color: #93c5fd; border-color: #1e3a5f; }
.enc-fg-wide { flex: 2 !important; }

/* ── Dark mode: orçamentos ── */
/* Lista: estado badges */
.dark-mode .orc-card-estado.rascunho       { background: #292200; color: #fcd34d; border-color: #78350f; }
.dark-mode .orc-card-estado.aprovado       { background: #0d1f3c; color: #93c5fd; border-color: #1e3a5f; }
.dark-mode .orc-card-estado.adjudicado     { background: #052e16; color: #86efac; border-color: #166534; }
.dark-mode .orc-card-estado.nao_adjudicado { background: #2a0d0d; color: #fca5a5; border-color: #7f1d1d; }
.dark-mode .orc-card-estado.enviado        { background: #0d1f3c; color: #93c5fd; border-color: #1e3a5f; }
.dark-mode .orc-card-estado.cancelado      { background: #2a0d0d; color: #fca5a5; border-color: #7f1d1d; }
/* Lista: chips de documento */
.dark-mode .orc-doc-chip { background: #1e2328; border-color: #2d3139; color: #9ca3af; }
.dark-mode .orc-doc-chip:hover { background: #2d3139; color: #e5e7eb; }
.dark-mode .orc-doc-chip.orc-doc-ready { background: #052e16; color: #86efac; border-color: #166534; }
.dark-mode .orc-doc-chip.orc-doc-ready:hover { background: #065f2e; }
.dark-mode .orc-doc-gerar { background: #1e2328; border-color: #2d3139; color: #9ca3af; }
.dark-mode .orc-doc-btn { color: #9ca3af; }
.dark-mode .orc-doc-btn:hover { color: #fca5a5; background: #2a0d0d; }
.dark-mode .orc-card-morada { color: #9ca3af; }
/* Modal: toggles (tipo, canal, iva) */
.dark-mode .orc-tipo-btn,
.dark-mode .orc-canal-btn,
.dark-mode .orc-iva-btn { color: #9ca3af; background: none; }
.dark-mode .orc-tipo-btn:hover,
.dark-mode .orc-canal-btn:hover,
.dark-mode .orc-iva-btn:hover { background: #2d3139; color: #e5e7eb; }
/* Modal: breakdown */
.dark-mode .orc-breakdown-pos { color: #e5e7eb; }
.dark-mode .orc-breakdown-sub { color: #9ca3af; }
/* Modal: desc preset buttons */
.dark-mode .orc-desc-preset-btn { background: #1e2328; border-color: #2d3139; color: #9ca3af; }
.dark-mode .orc-desc-preset-btn:hover { background: #2d3139; color: #e5e7eb; }
/* Modal: ref interna bar */
.dark-mode .orc-ref-interna-bar { border-bottom-color: #2d3139; }
/* Modal: extra section border */
.dark-mode .orc-extra-section { border-color: #2d3139; }
.dark-mode .orc-extra-row { border-bottom-color: #2d3139; border-right-color: #2d3139; }
.dark-mode .orc-extra-section .orc-extra-bottom { border-bottom-color: #2d3139; }

/* ── Empresa: logo row ── */
.empresa-logo-row {
  display: flex; align-items: center; gap: 14px; margin-bottom: 14px;
  padding: 12px; background: #f9fafb; border-radius: 10px; border: 1px solid var(--border, #e5e7eb);
}
.empresa-logo-preview {
  width: 72px; height: 72px; border-radius: 8px;
  background: #fff; border: 1px solid var(--border, #e5e7eb);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden; flex-shrink: 0;
}
.empresa-logo-preview img { width: 100%; height: 100%; object-fit: contain; }
.dark-mode .empresa-logo-row { background: #1e2328; border-color: #2d3139; }
.dark-mode .empresa-logo-preview { background: #23282e; border-color: #2d3139; }

/* ── Encomenda detalhe: campos extra ── */
.enc-detalhe-section { font-size: 11px; font-weight: 700; color: #9ca3af; text-transform: uppercase; letter-spacing: .05em; margin: 10px 0 4px; }
.enc-detalhe-orc-link { display:inline-flex;align-items:center;gap:5px;font-size:13px;color:var(--primary,#c0392b);font-weight:600;cursor:pointer;text-decoration:underline; }

/* ══════════════════════════════════════════
   INÍCIO — Dashboard
   ══════════════════════════════════════════ */
.inicio-container {
  padding: 1.25rem;
}

/* Hero */
.inicio-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  padding-bottom: .75rem;
  border-bottom: 1px solid var(--border, #e5e7eb);
}
.inicio-hero-greeting {
  font-size: 20px;
  font-weight: 700;
  color: var(--text, #111827);
}
.inicio-hero-date {
  font-size: 13px;
  color: #9ca3af;
  margin-top: 2px;
}
.inicio-hero-right {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 1rem;
  flex-shrink: 0;
}
.inicio-hero-clock {
  font-size: 18px;
  font-weight: 700;
  color: var(--text, #111827);
  white-space: nowrap;
  width: auto;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1.5px solid var(--border, #e5e7eb);
  border-radius: 999px;
  padding: 6px 12px;
  background: var(--surface, #fff);
  letter-spacing: 0.02em;
}
.inicio-refresh-info {
  font-size: 11px;
  color: #9ca3af;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Links rápidos */
.inicio-quick-links {
  display: flex;
  gap: .5rem;
  flex-wrap: wrap;
}
.inicio-link-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  border: 1px solid var(--border, #e5e7eb);
  background: var(--card-bg, #fff);
  color: #374151;
  transition: all .15s;
}
.inicio-link-btn:hover { border-color: #aaa; background: #f9fafb; }
.inicio-link-btn--ig { color: #c13584; border-color: #f0d0e8; background: #fdf5fb; }
.inicio-link-btn--ig:hover { background: #f8e8f4; }
.inicio-link-btn--fb { color: #1877f2; border-color: #c8dbf8; background: #f0f5ff; }
.inicio-link-btn--fb:hover { background: #e4eeff; }
.inicio-link-btn--gmail { color: #ea4335; border-color: #fad2cf; background: #fff5f5; }
.inicio-link-btn--gmail:hover { background: #ffe8e7; }
.inicio-link-btn--drive { color: #0f9d58; border-color: #b7e5ce; background: #f0faf5; }
.inicio-link-btn--drive:hover { background: #dff5ea; }

/* GA4 badge */
.inicio-ga-badge {
  font-size: 10px;
  font-weight: 600;
  background: #f59e0b22;
  color: #b45309;
  border-radius: 4px;
  padding: 2px 6px;
  width: fit-content;
}
.inicio-kpi-card--ga .inicio-kpi-value { color: #9ca3af; }

/* Charts header + period */
.inicio-charts-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: .75rem;
}
.inicio-charts-title {
  font-size: 13px;
  font-weight: 700;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.inicio-period-btns {
  display: flex;
  gap: 4px;
}
.dash-period-btn {
  padding: 3px 10px;
  border-radius: 6px;
  border: 1px solid var(--border, #e5e7eb);
  background: none;
  font-size: 12px;
  font-weight: 600;
  color: #6b7280;
  cursor: pointer;
  font-family: 'Poppins', sans-serif;
  transition: all .15s;
}
.dash-period-btn:hover { background: #f3f4f6; }
.dash-period-btn.active { background: var(--brand, #d91b22); color: #fff; border-color: var(--brand, #d91b22); }
.inicio-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
@keyframes shimmer {
  0% { background-position: -400px 0; }
  100% { background-position: 400px 0; }
}
.skeleton {
  background: linear-gradient(90deg, var(--border,#e5e7eb) 25%, var(--hover-bg,#f3f4f6) 50%, var(--border,#e5e7eb) 75%);
  background-size: 800px 100%;
  animation: shimmer 1.4s infinite linear;
  border-radius: 6px;
  color: transparent !important;
  pointer-events: none;
}
.skeleton-card {
  background: var(--card-bg,#fff);
  border: 1px solid var(--border,#e5e7eb);
  border-radius: 12px;
  padding: 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.skeleton-line { height: 12px; border-radius: 4px; }
.skeleton-line.sm { width: 60%; }
.skeleton-line.lg { height: 28px; width: 40%; }
.inicio-kpi-card {
  background: var(--card-bg, #fff);
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 12px;
  padding: 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.inicio-kpi-label {
  font-size: 11px;
  font-weight: 600;
  color: #9ca3af;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.inicio-kpi-value {
  font-size: 22px;
  font-weight: 700;
  color: var(--text, #111827);
  line-height: 1.2;
}
.inicio-kpi-delta {
  font-size: 12px;
  font-weight: 600;
}
.inicio-kpi-delta.up { color: #16a34a; }
.inicio-kpi-delta.down { color: var(--brand, #d91b22); }
.inicio-kpi-delta.flat { color: #9ca3af; }
.inicio-semana-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.inicio-semana-card {
  background: var(--card-bg, #fff);
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 12px;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.inicio-semana-periodo {
  font-size: 12px;
  font-weight: 600;
  color: #9ca3af;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.inicio-semana-stats {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.inicio-semana-stat {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--text, #111827);
}
.inicio-semana-stat i { font-size: 15px; color: #9ca3af; width: 18px; text-align: center; flex-shrink: 0; }
.inicio-semana-stat-val { font-weight: 700; font-size: 15px; min-width: 24px; }
.inicio-semana-stat-sub { font-size: 11px; color: #9ca3af; margin-left: auto; }
.inicio-semana-divider { border: none; border-top: 1px solid var(--border, #e5e7eb); margin: 0; }
.inicio-semana-actions { display: flex; flex-direction: column; gap: 8px; }
.inicio-semana-grafico-wrap { position: relative; height: 200px; width: 100%; }
.sg-legend { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px 10px; margin-bottom: 10px; }
.sg-legend.cols-4 { grid-template-columns: repeat(4, auto); justify-content: start; gap: 5px 24px; }
.sg-legend-item { display: flex; align-items: center; gap: 5px; font-size: 11px; color: #6b7280; }
.sg-legend-dot { width: 10px; height: 10px; border-radius: 2px; flex-shrink: 0; }
.sg-legend-line { width: 16px; height: 3px; border-radius: 2px; flex-shrink: 0; }
.inicio-semana-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  border-radius: 8px;
  border: 1.5px solid var(--border, #e5e7eb);
  background: var(--surface, #fff);
  font-size: 13px;
  font-weight: 600;
  color: var(--text, #111827);
  cursor: pointer;
  transition: background .15s, border-color .15s;
  text-align: left;
}
.inicio-semana-btn:hover { background: var(--hover-bg, #f9fafb); border-color: var(--brand, #d91b22); color: var(--brand, #d91b22); }
.inicio-semana-btn i { font-size: 15px; }
.inicio-charts-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
}
.inicio-chart-card {
  background: var(--card-bg, #fff);
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 12px;
  padding: 1rem 1.25rem 1.25rem;
}
.inicio-chart-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text, #111827);
  margin-bottom: .75rem;
}
.dark-mode .inicio-kpi-card,
.dark-mode .inicio-chart-card {
  background: #1e2328;
  border-color: #2d3139;
}
.dark-mode .inicio-kpi-value { color: #f3f4f6; }
.dark-mode .inicio-chart-title { color: #e5e7eb; }

/* ── Dashboard Extras ── */
.inicio-extras-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-top: 1.5rem;
}
.inicio-bottom-grid {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 1rem;
  margin-top: 1rem;
}
.inicio-extra-card {
  background: var(--card-bg, #fff);
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 12px;
  padding: 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: .5rem;
}
.inicio-extra-title {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: #6b7280;
  display: flex;
  align-items: center;
  gap: .4rem;
}
.inicio-extra-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: .25rem;
}
.dash-loading, .dash-empty {
  color: #9ca3af;
  font-size: 13px;
  padding: .5rem 0;
}
.dash-list-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  padding: .35rem 0;
  border-bottom: 1px solid var(--border, #f3f4f6);
  font-size: 13px;
}
.dash-list-row:last-child { border-bottom: none; }
.dash-list-clickable { cursor: pointer; }
.dash-list-clickable:hover { background: var(--hover-bg, #f9fafb); border-radius: 6px; }
.dash-list-left {
  display: flex;
  align-items: center;
  gap: .5rem;
  min-width: 0;
}
.dash-list-nome {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 160px;
}
.dash-list-loc, .dash-list-ref {
  font-size: 12px;
  color: #9ca3af;
  white-space: nowrap;
  flex-shrink: 0;
}
.dash-dia-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  white-space: nowrap;
  flex-shrink: 0;
}
.dash-dia-badge.verde  { background: #dcfce7; color: #16a34a; }
.dash-dia-badge.vermelho { background: #fee2e2; color: #dc2626; }
.dash-dia-badge.amarelo { background: #fef3c7; color: #d97706; }
.dash-dia-badge.cinza  { background: #f3f4f6; color: #6b7280; }
.dash-atv-icon { font-size: 15px; color: #9ca3af; flex-shrink: 0; }

/* Top clientes */
.dash-top-row { display: flex; flex-direction: column; gap: .25rem; padding: .4rem 0; border-bottom: 1px solid var(--border,#f3f4f6); }
.dash-top-row:last-child { border-bottom: none; }
.dash-top-meta { display: flex; align-items: center; gap: .5rem; font-size: 13px; }
.dash-top-pos { font-weight: 700; color: #9ca3af; width: 16px; text-align: center; flex-shrink: 0; }
.dash-top-nome { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dash-top-valor { font-weight: 600; color: #111827; white-space: nowrap; flex-shrink: 0; }
.dash-top-bar-wrap { height: 4px; background: #f3f4f6; border-radius: 2px; }
.dash-top-bar { height: 4px; background: var(--brand, #d91b22); border-radius: 2px; transition: width .4s; }

/* Dark mode extras */
.dark-mode .inicio-extra-card { background: #1e2328; border-color: #2d3139; }
.dark-mode .dash-list-row { border-color: #2d3139; }
.dark-mode .dash-list-nome { color: #e5e7eb; }
.dark-mode .dash-top-valor { color: #f3f4f6; }
.dark-mode .dash-top-bar-wrap { background: #2d3139; }
.dark-mode .dash-dia-badge.cinza { background: #2d3139; color: #9ca3af; }

/* Dark mode — semana e hero */
.dark-mode .inicio-semana-card { background: #1e2328; border-color: #2d3139; }
.dark-mode .inicio-semana-btn { background: #2d3139; border-color: #3d4149; color: #e5e7eb; }
.dark-mode .inicio-semana-btn:hover { background: #3d4149; }
.dark-mode .inicio-hero-clock { background: #1e2328; border-color: #2d3139; color: #e5e7eb; }
.dark-mode .inicio-charts-title { color: #9ca3af; }
.dark-mode .inicio-extra-title { color: #9ca3af; }
.dark-mode .sg-legend-item { color: #9ca3af; }
.dark-mode .dash-period-btn { color: #9ca3af; }
.dark-mode .dash-period-btn:hover { background: #2d3139; }
.dark-mode .dash-period-btn.active { background: var(--brand,#d91b22); color: #fff; }
.dark-mode .inicio-ga-badge { background: rgba(245,158,11,.15); color: #fbbf24; }
.dark-mode .inicio-link-btn { background: #1e2328; border-color: #2d3139; color: #e5e7eb; }
.dark-mode .inicio-semana-stat { color: #e5e7eb; }
.dark-mode .inicio-semana-periodo { color: #9ca3af; }
.dark-mode .inicio-semana-divider { border-color: #2d3139; }
.dark-mode .inicio-semana-stat-sub { color: #6b7280; }
.dark-mode .inicio-hero-greeting { color: #f3f4f6; }
.dark-mode .inicio-hero { border-bottom-color: #2d3139; }

/* ── Início — responsivo mobile ── */
@media (max-width: 768px) {
  .inicio-hero { align-items: center; }
  .inicio-hero-right { flex-shrink: 0; }
  .inicio-hero-clock { font-size: 1.4rem; }
  .inicio-quick-links { display: none; }
  .inicio-link-btn { font-size: 11px; padding: 3px 7px; }
  .dash-list-nome { max-width: 120px; }
  .dash-list-loc { max-width: 100px; overflow: hidden; text-overflow: ellipsis; }
  .inicio-kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .inicio-semana-grid { grid-template-columns: 1fr; }
  .inicio-charts-grid { grid-template-columns: 1fr; }
  .inicio-extras-grid { grid-template-columns: 1fr; }
  .inicio-bottom-grid { grid-template-columns: 1fr; }
  .sg-legend { grid-template-columns: repeat(2, 1fr); }
  .sg-legend.cols-4 { grid-template-columns: repeat(2, 1fr); }
  #dash-mapa { min-height: 220px !important; }
  .inicio-charts-header { flex-wrap: wrap; gap: .5rem; }
  .inicio-period-btns { flex-wrap: wrap; }
  .inicio-chart-card { overflow: hidden; }
  .inicio-chart-card canvas { max-width: 100%; }
  .inicio-semana-card { overflow: hidden; }
}

/* ══════════════════════════════════════
   STOCK
   ══════════════════════════════════════ */
.stock-resumo { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 14px; }
.stock-resumo-card { background: var(--card-bg,#fff); border: 1px solid var(--border,#e5e7eb); border-radius: 12px; padding: 12px 14px; border-left-width: 3px; }
.stock-resumo-nome { font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: #8b9098; }
.stock-resumo-num { font-size: 26px; font-weight: 700; line-height: 1.1; margin-top: 2px; }
.stock-resumo-sub { font-size: 11.5px; color: #8b9098; margin-top: 2px; }
.stock-tipo--loja    { border-left-color: #c0392b; }
.stock-tipo--armazem { border-left-color: #2563eb; }

.stock-toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.stock-search { position: relative; flex: 1; min-width: 220px; }
.stock-search i { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: #9ca3af; font-size: 16px; }
.stock-search input { width: 100%; padding: 9px 12px 9px 34px; border: 1px solid var(--border,#e5e7eb); border-radius: 9px; font-size: 14px; font-family: inherit; background: var(--input-bg,#fff); color: inherit; }
.stock-search input:focus { outline: none; border-color: var(--brand,#c0392b); }
.stock-filtros { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.stock-filtros select { padding: 8px 10px; border: 1px solid var(--border,#e5e7eb); border-radius: 9px; font-size: 13px; font-family: inherit; background: var(--input-bg,#fff); color: inherit; }
.stock-chk { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: inherit; white-space: nowrap; cursor: pointer; }
/* o .btn-primary da app é full-width por omissão — aqui tem de ser compacto */
.stock-filtros .btn-primary { width: auto; padding: 8px 16px; font-size: 13px; white-space: nowrap; }
/* fora de .form-group, senão apanha o estilo de rótulo em maiúsculas */
.stock-online-row { margin: 14px 0; }

.stock-list { display: flex; flex-direction: column; gap: 8px; }
.stock-card { display: grid; grid-template-columns: 64px minmax(140px, 1.4fr) 2fr 78px; gap: 14px; align-items: center; background: var(--card-bg,#fff); border: 1px solid var(--border,#e5e7eb); border-radius: 12px; padding: 10px 14px; cursor: pointer; transition: border-color .15s, transform .1s; }
.stock-card:hover { border-color: var(--brand,#c0392b); transform: translateY(-1px); }
.stock-card-foto { width: 64px; height: 64px; border-radius: 9px; overflow: hidden; background: var(--wash,#f6f7f8); display: flex; align-items: center; justify-content: center; }
.stock-card-foto img { width: 100%; height: 100%; object-fit: cover; }
.stock-card-foto i { font-size: 26px; color: #c8ccd2; }
.stock-card-nome { font-weight: 600; font-size: 14.5px; display: flex; align-items: center; gap: 6px; }
.stock-card-nome i { font-size: 14px; color: #2563eb; }
.stock-card-ref { font-size: 11.5px; color: #8b9098; font-variant-numeric: tabular-nums; }
.stock-card-meta { font-size: 12.5px; color: #6b7280; margin-top: 2px; }
.stock-card-locais { display: flex; flex-wrap: wrap; gap: 5px; }
.stock-card-total { text-align: right; }
.stock-card-total span { display: block; font-size: 20px; font-weight: 700; }
.stock-card-total small { font-size: 9px; letter-spacing: .08em; color: #8b9098; }

.stock-badge { display: inline-flex; align-items: baseline; gap: 4px; font-size: 12px; padding: 3px 8px; border-radius: 6px; background: var(--wash,#f6f7f8); border-left: 3px solid #ccc; }
.stock-badge b { font-weight: 600; }
.stock-badge em { font-style: normal; font-size: 10.5px; color: #8b9098; }
.stock-badge small { font-size: 10.5px; color: #8b9098; }
.stock-badge--esgotado { opacity: .5; }

.stock-fotos { display: flex; flex-wrap: wrap; gap: 8px; }
.stock-foto { position: relative; width: 88px; height: 88px; border-radius: 8px; overflow: hidden; border: 1px solid var(--border,#e5e7eb); }
.stock-foto img { width: 100%; height: 100%; object-fit: cover; }
.stock-foto-del { position: absolute; top: 3px; right: 3px; width: 20px; height: 20px; border: none; border-radius: 50%; background: rgba(0,0,0,.6); color: #fff; cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 12px; }
.stock-vazio { font-size: 13px; color: #9ca3af; }

.stock-exist-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--border,#e5e7eb); }
.stock-exist-row:last-child { border-bottom: none; }
.stock-exist-local { display: flex; align-items: center; gap: 6px; min-width: 190px; }
.stock-exist-local b { font-size: 13px; }
.stock-exist-row label { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; color: #6b7280; }
.stock-exist-row input, .stock-exist-row select { padding: 5px 8px; border: 1px solid var(--border,#e5e7eb); border-radius: 6px; font-size: 13px; font-family: inherit; background: var(--input-bg,#fff); color: inherit; }
.stock-exist-row input[type=number] { width: 62px; }
.stock-exist-nota { flex: 1; min-width: 150px; }
.stock-exist-livre { font-size: 12px; font-weight: 600; color: #16a34a; white-space: nowrap; }
.stock-exist-livre.zero { color: #9ca3af; }

.stock-hist { display: flex; flex-direction: column; gap: 4px; max-height: 220px; overflow-y: auto; }
.stock-hist-row { display: grid; grid-template-columns: 84px 34px 1fr 1.2fr auto; gap: 8px; align-items: center; font-size: 12px; padding: 4px 0; border-bottom: 1px solid var(--border,#e5e7eb); }
.stock-hist-tipo { font-size: 10px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; padding: 2px 6px; border-radius: 4px; text-align: center; background: var(--wash,#f6f7f8); }
.stock-hist--entrada { color: #166534; background: #f0fdf4; }
.stock-hist--saida   { color: #991b1b; background: #fef2f2; }
.stock-hist--transferencia { color: #1e40af; background: #eff6ff; }
.stock-hist--reserva { color: #92400e; background: #fffbeb; }
.stock-hist--venda   { color: #5b21b6; background: #f5f3ff; }
.stock-hist-qt { font-weight: 700; text-align: right; }
.stock-hist-local, .stock-hist-motivo { color: #6b7280; }
.stock-hist-meta { font-size: 10.5px; color: #9ca3af; white-space: nowrap; }

.dark-mode .stock-card-meta, .dark-mode .stock-hist-local, .dark-mode .stock-hist-motivo { color: #9ca3af; }
.dark-mode .stock-card-foto i { color: #4b5563; }
.dark-mode .stock-badge, .dark-mode .stock-hist-tipo { background: #2d3139; }
.dark-mode .stock-hist--entrada { background: #052e16; color: #86efac; }
.dark-mode .stock-hist--saida   { background: #2a0d0d; color: #fca5a5; }
.dark-mode .stock-hist--transferencia { background: #0d1f3c; color: #93c5fd; }
.dark-mode .stock-hist--reserva { background: #292200; color: #fcd34d; }
.dark-mode .stock-hist--venda   { background: #2e1065; color: #c4b5fd; }
.dark-mode .stock-card-foto { background: #1e2328; }

@media (max-width: 860px) {
  .stock-card { grid-template-columns: 52px 1fr; grid-template-areas: "foto info" "locais locais" "total total"; }
  .stock-card-foto { width: 52px; height: 52px; grid-area: foto; }
  .stock-card-info { grid-area: info; }
  .stock-card-locais { grid-area: locais; }
  .stock-card-total { grid-area: total; text-align: left; display: flex; align-items: baseline; gap: 6px; }
}
.stock-card-cat { font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: #c0392b; }
.dark-mode .stock-card-cat { color: #e07a6d; }
/* Lojas e armazéns: nome, morada, tipo, guardar, apagar */
.loja-item { display: grid; grid-template-columns: 1fr 1.6fr auto auto auto; gap: 8px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--border,#e5e7eb); }
.loja-item:last-of-type { border-bottom: none; }
.loja-item input, .loja-item select { padding: 6px 10px; border: 1px solid var(--border,#e5e7eb); border-radius: 7px; font-size: 13px; font-family: inherit; background: var(--input-bg,#fff); color: inherit; width: 100%; }
.loja-item input:focus, .loja-item select:focus { outline: none; border-color: var(--brand,#d91b22); }
.dark-mode .loja-item { border-color: #2d3139; }
@media (max-width: 720px) { .loja-item { grid-template-columns: 1fr 1fr; } }


/* Barra de separadores: o fluxo de venda à esquerda, os outros módulos
   empurrados para a direita por este espaçador. */
.tabs-spacer { flex: 1 1 auto; min-width: 12px; }
.tab-btn--extra { color: #8b9098; }
.tab-btn--extra i { opacity: .8; }
.tab-btn--extra.active { color: inherit; }
.tab-btn--extra.active i { opacity: 1; }
@media (max-width: 720px) {
  /* em ecrã estreito a barra faz scroll horizontal — o espaçador só atrapalharia */
  .tabs-spacer { display: none !important; }
}

/* ── Barra de separadores: fluxo de venda vs. outros módulos ── */
/* Início fica destacado do fluxo por um intervalo */
.tabs-gap { width: 18px; flex: 0 0 auto; }
/* Orçamentos › Encomendas › Entregas leem-se como um percurso */
.tabs-seta { align-self: stretch; display: flex; align-items: center; color: #d5d7dc; }
.tabs-seta i { font-size: 13px; }
.tab-btn--fluxo { padding-left: 12px; padding-right: 12px; }
/* filete a ancorar o grupo da direita */
.tabs-divisor { align-self: stretch; width: 1px; background: #e5e5e5; margin: 0 10px; flex: 0 0 auto; }
/* badge só quando há alguma coisa para mostrar */
.tab-badge.vazio { display: none; }

.dark-mode .tabs-seta { color: #3d4149; }
.dark-mode .tabs-divisor { background: #2d3139; }

@media (max-width: 860px) {
  /* em ecrã estreito a barra faz scroll — setas e intervalos só roubavam espaço */
  .tabs-gap, .tabs-seta, .tabs-divisor { display: none !important; }
  .tab-btn--fluxo { padding-left: 14px; padding-right: 14px; }
}

/* ── Aba em desenvolvimento (Marketing) ── */
.breve-wrap { max-width: 780px; margin: 0 auto; padding: 3rem 1.25rem; text-align: center; }
.breve-icone {
  width: 56px; height: 56px; margin: 0 auto 14px; border-radius: 16px;
  background: var(--wash,#f6f7f8); display: flex; align-items: center; justify-content: center;
}
.breve-icone i { font-size: 26px; color: var(--brand,#c0392b); }
.breve-selo {
  display: inline-block; font-size: 10px; font-weight: 700; letter-spacing: .12em;
  text-transform: uppercase; color: #92400e; background: #fffbeb;
  border: 1px solid #fde68a; padding: 3px 10px; border-radius: 20px; margin-bottom: 10px;
}
.breve-wrap h2 { font-size: 22px; font-weight: 600; margin-bottom: 6px; }
.breve-sub { font-size: 14px; color: #6b7280; line-height: 1.6; max-width: 520px; margin: 0 auto 2rem; }
.breve-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px,1fr)); gap: 12px; text-align: left; }
.breve-card {
  background: var(--card-bg,#fff); border: 1px solid var(--border,#e5e7eb);
  border-radius: 12px; padding: 16px;
}
.breve-card i { font-size: 20px; color: var(--brand,#c0392b); }
.breve-card h4 { font-size: 14px; font-weight: 600; margin: 8px 0 4px; }
.breve-card p { font-size: 12.5px; color: #6b7280; line-height: 1.55; }
.breve-nota {
  display: flex; gap: 10px; align-items: flex-start; text-align: left;
  margin-top: 18px; padding: 12px 14px; border-radius: 10px;
  background: var(--wash,#f6f7f8); font-size: 12.5px; color: #6b7280; line-height: 1.55;
}
.breve-nota i { font-size: 16px; color: #9ca3af; flex-shrink: 0; margin-top: 1px; }
.breve-nota b { color: inherit; font-weight: 600; }

.dark-mode .breve-icone { background: #1e2328; }
.dark-mode .breve-selo { background: #292200; border-color: #78350f; color: #fcd34d; }
.dark-mode .breve-sub, .dark-mode .breve-card p, .dark-mode .breve-nota { color: #9ca3af; }
.dark-mode .breve-nota { background: #1e2328; }

/* ── Marketing: controlo de questões ── */
.mkt-panel { display: none; }
.mkt-panel.active { display: block; }

.mkt-barra { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 0 1.25rem; margin-bottom: 10px; }
.mkt-select { padding: 8px 12px; border: 1px solid var(--border,#e5e7eb); border-radius: 9px; font-size: 13px; font-family: inherit; background: var(--input-bg,#fff); color: inherit; }
.mkt-barra-dir { display: flex; gap: 8px; align-items: center; margin-left: auto; }
.mkt-busca { min-width: 180px; }
.mkt-barra-dir .btn-primary { width: auto; padding: 8px 14px; font-size: 13px; white-space: nowrap; }

.mkt-canais { display: flex; gap: 4px; background: var(--wash,#f6f7f8); padding: 3px; border-radius: 9px; flex-wrap: wrap; }
.mkt-canal { display: flex; align-items: center; gap: 5px; padding: 5px 10px; border: none; background: none; border-radius: 7px; font-family: inherit; font-size: 12.5px; color: #6b7280; cursor: pointer; }
.mkt-canal i { font-size: 15px; }
.mkt-canal.active { background: var(--card-bg,#fff); color: var(--brand,#c0392b); font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,.06); }
@media (max-width: 900px) { .mkt-canal span { display: none; } }
.mkt-total-bar { padding: 0 1.25rem 10px; font-size: 13px; color: #6b7280; }
.mkt-total-num { font-size: 20px; font-weight: 700; color: var(--text,#111); margin-right: 4px; }

.mkt-grupo { margin: 0 1.25rem 12px; border: 1px solid var(--border,#e5e7eb); border-radius: 12px; overflow: hidden; background: var(--card-bg,#fff); }
.mkt-grupo-cab { display: flex; justify-content: space-between; align-items: center; padding: 9px 14px; background: var(--wash,#f6f7f8); font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: #8b9098; }
.mkt-grupo-cab b { font-size: 13px; color: var(--text,#111); letter-spacing: 0; }

.mkt-linha { display: flex; align-items: center; gap: 10px; padding: 8px 14px; border-top: 1px solid var(--border,#e5e7eb); font-size: 13.5px; }
.mkt-linha--zero { color: #9ca3af; }
.mkt-nome { flex: 1; min-width: 0; }
.mkt-subcat { font-size: 11px; color: #9ca3af; white-space: nowrap; }
.mkt-contagem { min-width: 34px; text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.mkt-linha--zero .mkt-contagem { font-weight: 400; }

.mkt-mais, .mkt-menos, .mkt-editar { border: 1px solid var(--border,#e5e7eb); background: var(--card-bg,#fff); border-radius: 7px; cursor: pointer; font-family: inherit; color: #6b7280; flex-shrink: 0; }
.mkt-mais { padding: 4px 12px; font-size: 13px; font-weight: 700; color: var(--brand,#c0392b); }
.mkt-mais:hover { background: var(--brand,#c0392b); color: #fff; border-color: var(--brand,#c0392b); }
.mkt-mais:disabled { opacity: .5; cursor: default; }
.mkt-menos, .mkt-editar { width: 28px; height: 28px; display: inline-flex; align-items: center; justify-content: center; font-size: 14px; }
.mkt-menos:hover, .mkt-editar:hover { background: var(--wash,#f6f7f8); }

/* Resumo */
.mkt-resumo-topo { display: flex; flex-wrap: wrap; gap: 10px; padding: 0 1.25rem 12px; }
.mkt-kpi { flex: 1; min-width: 140px; background: var(--card-bg,#fff); border: 1px solid var(--border,#e5e7eb); border-radius: 12px; padding: 12px 14px; }
.mkt-kpi-num { display: block; font-size: 26px; font-weight: 700; line-height: 1.1; }
.mkt-kpi-lbl { font-size: 11.5px; color: #8b9098; }
.mkt-resumo-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px,1fr)); gap: 12px; padding: 0 1.25rem; }
.mkt-bloco { background: var(--card-bg,#fff); border: 1px solid var(--border,#e5e7eb); border-radius: 12px; padding: 14px; margin: 0 1.25rem; }
.mkt-resumo-grid .mkt-bloco { margin: 0; }
.mkt-bloco h4 { font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: #8b9098; margin-bottom: 10px; }
.mkt-barra-linha { display: grid; grid-template-columns: 1fr 90px 32px; gap: 8px; align-items: center; font-size: 12.5px; padding: 3px 0; }
.mkt-barra-nome { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mkt-barra-nome em { font-style: normal; font-size: 10px; color: #9ca3af; }
.mkt-barra-viz { height: 6px; background: var(--wash,#f6f7f8); border-radius: 3px; overflow: hidden; }
.mkt-barra-viz span { display: block; height: 100%; background: var(--brand,#c0392b); border-radius: 3px; }
.mkt-barra-linha b { text-align: right; font-variant-numeric: tabular-nums; }

.mkt-evo { display: flex; align-items: flex-end; gap: 8px; height: 130px; }
.mkt-evo-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; }
.mkt-evo-barra { width: 100%; max-width: 46px; background: var(--brand,#c0392b); border-radius: 4px 4px 0 0; opacity: .85; }
.mkt-evo-n { font-size: 11px; font-weight: 700; margin-top: 4px; }
.mkt-evo-mes { font-size: 10px; color: #9ca3af; }

.dark-mode .mkt-canal.active { background: #2d3139; }
.dark-mode .mkt-mais, .dark-mode .mkt-menos, .dark-mode .mkt-editar { background: #1e2328; border-color: #2d3139; }
.dark-mode .mkt-menos:hover, .dark-mode .mkt-editar:hover { background: #2d3139; }

/* ── Resumo da semana: dois gráficos pequenos (orçamentos / entregas) ── */
#inicio-semana-card2 { display: flex; flex-direction: column; gap: 14px; }
.sg-mini { display: flex; flex-direction: column; min-width: 0; }
.sg-mini + .sg-mini { padding-top: 12px; border-top: 1px solid var(--border,#eef0f3); }
.sg-mini-cab { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.sg-mini-tit { font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: #8b9098; }
.sg-mini-resumo { font-size: 12px; color: #6b7280; }
.sg-mini-resumo b { color: var(--text,#111); font-weight: 700; }
.sg-mini-legenda { display: flex; gap: 14px; margin: 5px 0 2px; }
/* a altura inclui a banda do eixo x — senão os rótulos dos dias ficavam cortados */
.sg-mini-plot { position: relative; height: 118px; width: 100%; }
.dark-mode .sg-mini-resumo { color: #9ca3af; }
.dark-mode .sg-mini-resumo b { color: #e5e7eb; }

/* ── Stock: sub-abas e galeria das lojas ── */
.st-panel { display: none; }
.st-panel.active { display: block; }
/* A galeria já tem margens nos seus blocos; os artigos ficavam colados às margens da página */
#st-artigos { padding: 0 1.25rem 1.5rem; }
@media (max-width: 768px) { #st-artigos { padding: 0 .75rem 1.5rem; } }

.gal-barra { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; padding: 0 1.25rem; margin-bottom: 14px; }
/* Igual ao "Nova encomenda" (.tbtn.add); é um <label> por causa do input de ficheiros */
.gal-add { margin: 0; }
.gal-progresso { margin: 0 1.25rem 12px; padding: 9px 14px; border-radius: 9px; background: var(--wash,#f6f7f8); font-size: 13px; color: #6b7280; }

.gal-grelha { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; padding: 0 1.25rem 1.5rem; }
.gal-cartao { display: flex; flex-direction: column; text-align: left; padding: 0; border: 1px solid var(--border,#e5e7eb); border-radius: 12px; overflow: hidden; background: var(--card-bg,#fff); cursor: pointer; font-family: inherit; color: inherit; transition: border-color .15s, transform .1s; }
.gal-cartao:hover { border-color: var(--brand,#c0392b); transform: translateY(-1px); }
.gal-cartao:focus-visible { outline: 2px solid var(--brand,#c0392b); outline-offset: 2px; }
.gal-mini { display: block; aspect-ratio: 4 / 3; background: var(--wash,#f6f7f8); overflow: hidden; }
.gal-mini img { width: 100%; height: 100%; object-fit: cover; display: block; }
.gal-cartao-info { display: flex; flex-direction: column; gap: 3px; padding: 9px 11px 11px; }
.gal-loja-selo { align-self: flex-start; font-size: 10px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--brand,#c0392b); }
.gal-cartao-nota { font-size: 13px; line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.gal-cartao-nota.vazia { color: #9ca3af; font-style: italic; }
.gal-cartao-data { font-size: 11px; color: #9ca3af; }

.gal-previas { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.gal-previas img { width: 58px; height: 58px; object-fit: cover; border-radius: 7px; }
.gal-previa-mais { width: 58px; height: 58px; border-radius: 7px; background: var(--wash,#f6f7f8); display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 600; color: #6b7280; }

/* Visor */
/* O visor encolhe à medida da foto (min-content = largura da imagem), por isso não há barras pretas */
.modal.gal-visor { width: min-content; min-width: 340px; max-width: calc(100vw - 32px); padding: 0; display: flex; flex-direction: column; overflow: hidden; position: relative; }
.gal-fechar { position: absolute; top: 10px; right: 10px; z-index: 3; width: 34px; height: 34px; border-radius: 50%; background: rgba(255,255,255,.92); color: #111; display: flex; align-items: center; justify-content: center; }
.gal-visor-img { position: relative; background: #111; display: flex; align-items: center; justify-content: center; }
.gal-visor-img img { width: auto; height: auto; max-width: calc(100vw - 32px); max-height: 80vh; display: block; }
.gal-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 40px; height: 40px; border-radius: 50%; border: none; background: rgba(255,255,255,.92); color: #111; cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 20px; box-shadow: 0 2px 8px rgba(0,0,0,.25); }
.gal-ant { left: 12px; } .gal-seg { right: 12px; }
.gal-legenda { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 14px 18px 16px; }
.gal-legenda-texto { min-width: 0; flex: 1; }
.gal-legenda-nota { margin: 4px 0 0; font-size: 14px; line-height: 1.55; color: var(--text,#111); white-space: pre-wrap; }
.gal-legenda-nota.vazia { color: #9ca3af; font-style: italic; }
.gal-btn-editar { width: auto; flex-shrink: 0; }
.gal-pills { display: flex; flex-wrap: wrap; gap: 6px; }
/* Barra da galeria ao estilo das Encomendas: pesquisa + Filtro (dropdown) + resumo */
.gal-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; flex: 1; min-width: 0; }
.gal-toolbar .enc-search-wrap { width: 280px; max-width: 100%; }
.gal-resumo-filtro { font-size: 12px; color: #9ca3af; white-space: nowrap; }
#gal-filtro-dropdown { min-width: 380px; }
#gal-filtro-dropdown .cf-row { align-items: flex-start; }
#gal-filtro-dropdown .cf-label { padding-top: 5px; }
.cf-pill.active[data-mat=""], .cf-pill.active[data-loja=""] { background: #f5f5f5; border-color: #ccc; color: #555; }
body.dark-mode .cf-pill.active[data-mat=""], body.dark-mode .cf-pill.active[data-loja=""] { background: #2a2a2a; border-color: #444; color: #aaa; }
/* ── Entregas › modo mapa: lista do dia à esquerda, mapa à direita ── */
.plan-mapa { display: grid; grid-template-columns: minmax(300px, 380px) minmax(0, 1fr); gap: 12px; padding: 0 1.25rem 1.5rem; align-items: start; }
.plan-mapa-lista { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.plan-mapa-dias { display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; }
.plan-mapa-dia { position: relative; display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 6px 2px 5px; border: 0.5px solid #e0e0e0; border-radius: 8px; background: #fff; color: #6b7280; font-family: inherit; cursor: pointer; transition: all .15s; }
.plan-mapa-dia span { font-size: 10.5px; text-transform: uppercase; letter-spacing: .04em; }
.plan-mapa-dia b { font-size: 16px; font-weight: 600; color: #222; font-variant-numeric: tabular-nums; }
.plan-mapa-dia i { position: absolute; top: -6px; right: -4px; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 999px; background: #6b7280; color: #fff; font-size: 10px; font-style: normal; font-weight: 700; line-height: 17px; }
.plan-mapa-dia:hover:not(:disabled) { border-color: #bbb; }
.plan-mapa-dia.hoje b { color: var(--brand); }
.plan-mapa-dia.active { border-color: var(--brand); background: #fff0f0; color: var(--brand); }
.plan-mapa-dia.active b { color: var(--brand); }
.plan-mapa-dia.active i { background: var(--brand); }
.plan-mapa-dia:disabled { opacity: .45; cursor: default; }
.plan-mapa-cabecalho { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 2px; }
.pm-cab-texto { display: flex; flex-direction: column; min-width: 0; }
/* Anexo marcado para sair ao guardar */
.file-chip.a-remover { opacity: .45; text-decoration: line-through; border-color: #d1d5db; }
.file-chip.a-remover i { color: var(--brand,#c0392b); }
.file-chip.a-remover button { text-decoration: none; }

.ef-ref-aviso { display: block; margin-top: 4px; font-size: 11.5px; line-height: 1.4; color: #b45309; }
.sr-cliente { display: inline-flex; align-items: center; gap: 3px; }

/* ── Ver artigo: dados + gestão de stock ── */
.sv-topo { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 14px; margin-bottom: 4px; }
.sv-foto { aspect-ratio: 1; border-radius: 10px; overflow: hidden; background: var(--wash,#f3f4f6); display: flex; align-items: center; justify-content: center; color: #cbd5e1; font-size: 34px; }
.sv-foto img { width: 100%; height: 100%; object-fit: cover; }
.sv-dados { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.sv-online { align-self: flex-start; display: inline-flex; align-items: center; gap: 5px; margin-bottom: 6px; padding: 3px 10px; border-radius: 999px; font-size: 11.5px; font-weight: 600; }
.sv-online.sim { background: #f0fdf4; color: #15803d; }
.sv-online.nao { background: #fff7ed; color: #b45309; }
.sv-linha { display: grid; grid-template-columns: 110px minmax(0, 1fr); gap: 8px; align-items: baseline; font-size: 13px; padding: 3px 0; border-bottom: 1px solid var(--border,#f3f4f6); }
.sv-linha span { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: #9ca3af; }
.sv-linha b { font-weight: 600; overflow-wrap: anywhere; }
.sv-seccao { margin: 18px 0 8px; font-size: 11px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: #9ca3af; }
.sv-seccao-linha { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.sv-seccao-linha span { font-weight: 500; letter-spacing: 0; text-transform: none; font-size: 11.5px; }
.stock-hist.aberto { max-height: 260px; overflow-y: auto; padding-right: 4px; }
.st-hist-mais { display: inline-flex; align-items: center; gap: 5px; margin-top: 6px; padding: 5px 10px; border: 1px solid var(--border,#e5e7eb); border-radius: 8px; background: none; font-family: inherit; font-size: 12px; color: #6b7280; cursor: pointer; }
.st-hist-mais:hover { border-color: #bbb; color: #333; }
body.dark-mode .st-hist-mais { border-color: #2e2e2e; color: #bbb; }
body.dark-mode .sv-online.sim { background: rgba(22,163,74,.16); color: #86efac; }
body.dark-mode .sv-online.nao { background: rgba(180,83,9,.18); color: #fcd34d; }
body.dark-mode .sv-linha { border-color: #2a2a2a; }
@media (max-width: 640px) { .sv-topo { grid-template-columns: 1fr; } .sv-foto { max-width: 180px; } }

.st-dims { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.st-dims label { display: flex; flex-direction: column; gap: 3px; }
.st-dims span { font-size: 11px; color: #9ca3af; }
.st-dims-antigas { display: block; margin-top: 5px; font-size: 11.5px; color: #9ca3af; }
.st-link-atributos { border: none; background: none; padding: 0 0 0 6px; font-family: inherit; font-size: 11px; color: var(--brand,#c0392b); cursor: pointer; text-decoration: underline; }
.st-guardado { font-size: 12.5px; color: #16a34a; align-self: center; }
body.dark-mode .st-abas { background: #2a2a2a; }
body.dark-mode .st-aba.active { background: #1e1e1e; }

/* ── Stock por local (dentro do artigo) ── */
.ex-local { border: 1px solid var(--border,#e5e7eb); border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; background: var(--card-bg,#fff); }
.ex-local.vazio { background: var(--wash,#fafafa); }
.ex-local-topo { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.ex-local-topo b { font-size: 13.5px; }
.ex-livres { font-size: 12px; font-weight: 600; color: #16a34a; }
.ex-livres.zero { color: #9ca3af; font-weight: 400; }
.ex-linha { display: grid; grid-template-columns: auto auto 1fr auto; align-items: center; gap: 10px; padding: 8px 0 0; }
.ex-linha + .ex-linha { border-top: 1px solid var(--border,#f0f0f0); margin-top: 8px; }
.ex-estado { font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; padding: 2px 8px; border-radius: 999px; background: #eef2ff; color: #3730a3; white-space: nowrap; }
.ex-estado--exposicao { background: #fef3c7; color: #92400e; }
.ex-estado--defeito { background: #fee2e2; color: #b91c1c; }
.ex-passo { display: inline-flex; align-items: center; border: 1px solid var(--border,#e5e7eb); border-radius: 8px; overflow: hidden; }
.ex-passo button { width: 30px; height: 30px; border: none; background: none; font-size: 17px; line-height: 1; color: #555; cursor: pointer; }
.ex-passo button:hover:not(:disabled) { background: var(--wash,#f5f5f5); color: #111; }
.ex-passo input { width: 46px; height: 30px; border: none; border-left: 1px solid var(--border,#e5e7eb); border-right: 1px solid var(--border,#e5e7eb); text-align: center; font-family: inherit; font-size: 14px; font-weight: 600; background: none; color: inherit; -moz-appearance: textfield; }
.ex-passo input::-webkit-outer-spin-button, .ex-passo input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.ex-resumo { font-size: 12px; color: #6b7280; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ex-abrir { width: 28px; height: 28px; border: none; border-radius: 7px; background: none; color: #9ca3af; cursor: pointer; }
.ex-abrir:hover { background: var(--wash,#f5f5f5); color: #333; }
.ex-linha.aberta .ex-abrir { transform: rotate(180deg); color: var(--brand,#c0392b); }
.ex-detalhes[hidden] { display: none; }   /* o display:grid abaixo anulava o hidden */
.ex-detalhes { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 8px; padding: 10px; border-radius: 8px; background: var(--wash,#f7f7f8); }
.ex-detalhes label { display: flex; flex-direction: column; gap: 3px; font-size: 11px; color: #6b7280; }
.ex-detalhes input { padding: 6px 8px; border: 1px solid var(--border,#e5e7eb); border-radius: 7px; font-family: inherit; font-size: 13px; background: var(--input-bg,#fff); color: inherit; }
.ex-nota-wrap { grid-column: 1 / -1; }
.ex-add { display: inline-flex; align-items: center; gap: 5px; margin-top: 8px; padding: 5px 10px; border: 1px dashed var(--border,#d1d5db); border-radius: 8px; background: none; font-family: inherit; font-size: 12px; color: #6b7280; cursor: pointer; }
.ex-add:hover { border-color: var(--brand,#c0392b); color: var(--brand,#c0392b); }
body.dark-mode .ex-estado { background: #26305c; color: #c7d2fe; }
body.dark-mode .ex-estado--exposicao { background: #3a2e10; color: #fcd34d; }
body.dark-mode .ex-estado--defeito { background: #3a1515; color: #fca5a5; }
body.dark-mode .ex-detalhes { background: #262626; }
@media (max-width: 640px) {
  .ex-linha { grid-template-columns: auto 1fr auto; }
  .ex-resumo { grid-column: 1 / -1; white-space: normal; }
  .ex-detalhes { grid-template-columns: 1fr 1fr; }
}

/* ── Acabamentos e categorias (janela de gestão) ── */
.at-abas { margin-bottom: 10px; }
.at-novo { display: flex; gap: 8px; margin-bottom: 12px; }
.at-novo input { flex: 1; padding: 8px 10px; border: 1px solid var(--border,#e5e7eb); border-radius: 8px; font-family: inherit; font-size: 13px; background: var(--input-bg,#fff); color: inherit; }
.at-novo .tbtn { white-space: nowrap; }
.at-lista { display: flex; flex-direction: column; gap: 6px; max-height: 50vh; overflow-y: auto; }
.at-linha { display: flex; align-items: center; gap: 8px; }
.at-valor { flex: 1; padding: 7px 10px; border: 1px solid var(--border,#e5e7eb); border-radius: 8px; font-family: inherit; font-size: 13px; background: var(--input-bg,#fff); color: inherit; }
.at-usos { font-size: 11.5px; color: #9ca3af; white-space: nowrap; }
.at-apagar { width: 30px; height: 30px; border: none; border-radius: 7px; background: none; color: #9ca3af; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.at-apagar:hover { background: #fff0f0; color: var(--brand,#c0392b); }
body.dark-mode .at-apagar:hover { background: #3a1515; }

/* ── Importar artigos do site ── */
.imp-estado { margin: -4px 0 10px; font-size: 12.5px; color: #6b7280; }
.imp-grelha { display: grid; grid-template-columns: repeat(4, 1fr); border: 0.5px solid #e0e0e0; border-radius: 10px; overflow: hidden; }
.imp-linha { display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 10px 4px; }
.imp-linha + .imp-linha { border-left: 0.5px solid #e0e0e0; }
.imp-linha b { font-size: 17px; font-variant-numeric: tabular-nums; color: #222; }
.imp-linha b.verde { color: #16a34a; }
.imp-linha b.ambar { color: #b45309; }
.imp-linha span { font-size: 11px; color: #9ca3af; text-align: center; }
.imp-nota { margin-top: 8px; padding: 8px 10px; border-radius: 8px; background: #f7f7f7; font-size: 12px; line-height: 1.5; color: #555; }
.imp-nota-final { margin: 10px 2px 0; font-size: 11.5px; color: #9ca3af; }
.imp-a-carregar { padding: 18px 10px; text-align: center; font-size: 13px; color: #6b7280; }
.imp-a-carregar.erro { color: #b45309; }
.imp-fotos { margin-top: 12px; }
.imp-fotos-topo { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 6px; font-size: 12.5px; color: #555; }
.imp-barra { height: 8px; border-radius: 999px; background: #eceef1; overflow: hidden; }
.imp-barra > div { height: 100%; width: 0; background: var(--brand,#c0392b); transition: width .25s; }
body.dark-mode .imp-grelha { border-color: #2e2e2e; }
body.dark-mode .imp-linha + .imp-linha { border-color: #2e2e2e; }
body.dark-mode .imp-linha b { color: #e5e5e5; }
body.dark-mode .imp-nota { background: #262626; color: #ccc; }
body.dark-mode .imp-barra { background: #2a2a2a; }

/* ── Simulação de rota (modal) ── */
.modal.rota-modal { width: min(1180px, calc(100vw - 32px)); max-width: none; }
.rota-modal-corpo { display: grid; grid-template-columns: 380px minmax(0, 1fr); gap: 14px; height: min(720px, calc(100vh - 170px)); min-height: 440px; }
.rota-lateral { overflow-y: auto; padding-right: 4px; min-width: 0; }
.rota-mapa-wrap { position: relative; z-index: 0; isolation: isolate; border-radius: 10px; overflow: hidden; border: 0.5px solid #e0e0e0; }
#rota-mapa { width: 100%; height: 100%; }
body.dark-mode .rota-mapa-wrap { border-color: #2e2e2e; }
@media (max-width: 900px) {
  .rota-modal-corpo { grid-template-columns: 1fr; height: auto; min-height: 0; }
  .rota-lateral { overflow: visible; padding-right: 0; }
  .rota-mapa-wrap { height: 340px; order: -1; }
}
.rota-painel { display: flex; flex-direction: column; gap: 10px; }
.rota-resultado { display: flex; flex-direction: column; gap: 10px; }
.rota-campos { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.rota-campo { display: flex; flex-direction: column; gap: 3px; }
.rota-campo span { font-size: 10.5px; font-weight: 700; color: #9ca3af; text-transform: uppercase; letter-spacing: .05em; }
.rota-campo .hora-picker { max-width: none; }
.rota-campo input, .rota-campo select { width: 100%; padding: 6px 8px; border: 0.5px solid #e0e0e0; border-radius: 6px; background: #fff; font-family: 'Poppins', sans-serif; font-size: 13px; color: #333; font-variant-numeric: tabular-nums; }
.rota-campo input.invalida { border-color: var(--brand); }
.rota-estado { padding: 16px 10px; font-size: 12.5px; color: #6b7280; text-align: center; }
.rota-estado.erro { color: #b45309; }
.rota-resumo { display: grid; grid-template-columns: repeat(4, 1fr); border: 0.5px solid #e0e0e0; border-radius: 10px; background: #fff; }
.rota-resumo > div { display: flex; flex-direction: column; align-items: center; padding: 8px 4px; }
.rota-resumo > div + div { border-left: 0.5px solid #e0e0e0; }
.rota-resumo b { font-size: 15px; font-weight: 700; color: #222; font-variant-numeric: tabular-nums; }
.rota-resumo span { font-size: 10.5px; color: #9ca3af; text-transform: uppercase; letter-spacing: .04em; }
.rota-aviso { display: flex; gap: 6px; padding: 8px 10px; border-radius: 8px; background: #f7f7f7; font-size: 12px; line-height: 1.45; color: #555; }
.rota-aviso i { flex-shrink: 0; margin-top: 1px; }
.rota-aviso.atraso { background: #fff4f4; color: #b91c1c; }
.rota-lista { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.rota-ponto { display: flex; align-items: flex-start; gap: 10px; padding: 9px 10px 9px 8px; border: 0.5px solid #e0e0e0; border-radius: 10px; background: #fff; }
.rota-ponto[data-id] { cursor: pointer; }
.rota-ponto[data-id]:hover { border-color: #bbb; }
.rota-ponto.sel { border-color: var(--brand); box-shadow: 0 0 0 1px var(--brand); }
.rota-ponto.base { background: #f7f7f7; }
.rota-marca { flex-shrink: 0; width: 24px; height: 24px; border-radius: 50%; background: var(--brand); color: #fff; font-size: 12px; font-weight: 700; display: flex; align-items: center; justify-content: center; font-variant-numeric: tabular-nums; }
.rota-ponto.entregue .rota-marca { background: #16a34a; }
.rota-ponto.base .rota-marca { background: #333; font-size: 13px; }
.rota-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.rota-linha1 { display: flex; align-items: baseline; gap: 7px; min-width: 0; }
.rota-hora { flex-shrink: 0; font-size: 13px; font-weight: 700; color: #222; font-variant-numeric: tabular-nums; }
.rota-cliente { font-size: 13px; font-weight: 600; color: #222; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rota-info small { font-size: 11.5px; color: #6b7280; line-height: 1.4; }
.rota-tag { align-self: flex-start; margin-top: 2px; padding: 1px 7px; border-radius: 999px; font-size: 11px; font-weight: 600; background: #f3f4f6; color: #555; }
.rota-tag.atraso { background: #fee2e2; color: #b91c1c; }
.rota-tag.espera { background: #fef3c7; color: #92400e; }
.rota-trajeto { display: flex; align-items: center; gap: 5px; padding: 4px 0 4px 14px; font-size: 11.5px; color: #9ca3af; font-variant-numeric: tabular-nums; }
.rota-nota { margin: 2px 2px 0; font-size: 11px; color: #9ca3af; line-height: 1.45; }
.pm-pin.base { width: 30px; height: 30px; background: #333; font-size: 15px; }
body.dark-mode .rota-campo input, body.dark-mode .rota-campo select, body.dark-mode .rota-resumo, body.dark-mode .rota-ponto { background: #1e1e1e; border-color: #2e2e2e; color: #ddd; }
body.dark-mode .rota-resumo > div + div { border-color: #2e2e2e; }
body.dark-mode .rota-resumo b, body.dark-mode .rota-hora, body.dark-mode .rota-cliente { color: #e5e5e5; }
body.dark-mode .rota-ponto.base, body.dark-mode .rota-aviso, body.dark-mode .rota-tag { background: #262626; color: #ccc; }
body.dark-mode .rota-aviso.atraso, body.dark-mode .rota-tag.atraso { background: #3a1515; color: #fca5a5; }
body.dark-mode .rota-tag.espera { background: #3a2e10; color: #fcd34d; }
body.dark-mode .rota-ponto.base .rota-marca, body.dark-mode .pm-pin.base { background: #555; }
.plan-mapa-cabecalho h3 { margin: 0; font-size: 14px; font-weight: 600; color: #222; }
.plan-mapa-cabecalho small { font-size: 12px; color: #6b7280; white-space: nowrap; }
.plan-mapa-entregas { display: flex; flex-direction: column; gap: 6px; max-height: calc(100vh - 300px); min-height: 200px; overflow-y: auto; padding-right: 2px; }
.pm-entrega { display: flex; align-items: flex-start; gap: 10px; width: 100%; padding: 10px 10px 10px 8px; border: 0.5px solid #e0e0e0; border-radius: 10px; background: #fff; font-family: inherit; text-align: left; color: inherit; cursor: pointer; transition: border-color .15s, box-shadow .15s; }
.pm-entrega:hover { border-color: #bbb; }
.pm-entrega.sel { border-color: var(--brand); box-shadow: 0 0 0 1px var(--brand); }
.pm-entrega:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
.pm-num { flex-shrink: 0; width: 24px; height: 24px; border-radius: 50%; background: var(--brand); color: #fff; font-size: 12px; font-weight: 700; display: flex; align-items: center; justify-content: center; font-variant-numeric: tabular-nums; }
.pm-entrega.entregue .pm-num { background: #16a34a; }
.pm-entrega.sem-local .pm-num { background: #fff; color: #9ca3af; border: 1.5px dashed #cbd5e1; }
.pm-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.pm-topo { display: flex; align-items: center; gap: 6px; min-width: 0; }
.pm-hora { flex-shrink: 0; font-size: 12px; font-weight: 700; color: #333; font-variant-numeric: tabular-nums; }
.pm-cliente { font-size: 13px; font-weight: 600; color: #222; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pm-morada { font-size: 12px; color: #6b7280; line-height: 1.4; }
.pm-estado { font-size: 11px; color: #16a34a; font-weight: 600; }
.pm-aviso-local { font-size: 11px; color: #b45309; }
.pm-ver { flex-shrink: 0; width: 28px; height: 28px; border-radius: 6px; display: flex; align-items: center; justify-content: center; color: #9ca3af; font-size: 15px; }
.pm-ver:hover { background: #f5f5f5; color: #333; }
.plan-mapa-vazio { padding: 28px 12px; text-align: center; font-size: 13px; color: #9ca3af; border: 0.5px dashed #e0e0e0; border-radius: 10px; }
/* isolation: as camadas do Leaflet (z-index 400–1000) ficam fechadas aqui dentro e não passam por cima dos modais */
.plan-mapa-mapa { position: relative; z-index: 0; isolation: isolate; border-radius: 10px; overflow: hidden; border: 0.5px solid #e0e0e0; }
#dash-mapa { position: relative; z-index: 0; isolation: isolate; }
#plan-mapa-leaflet { height: calc(100vh - 230px); min-height: 440px; }
.plan-mapa-aviso { position: absolute; left: 10px; bottom: 10px; z-index: 500; max-width: calc(100% - 20px); padding: 6px 10px; border-radius: 8px; background: rgba(255,255,255,.95); box-shadow: 0 1px 4px rgba(0,0,0,.15); font-size: 12px; color: #444; }
.pm-pin { width: 26px; height: 26px; border-radius: 50%; background: #d91b22; color: #fff; border: 2px solid #fff; box-shadow: 0 1px 5px rgba(0,0,0,.35); display: flex; align-items: center; justify-content: center; font: 700 12px/1 'Poppins', sans-serif; }
.pm-pin.ok { background: #16a34a; }
.pm-pin.sel { transform: scale(1.25); box-shadow: 0 0 0 3px rgba(217,27,34,.35), 0 1px 5px rgba(0,0,0,.35); }
body.dark-mode .plan-mapa-dia, body.dark-mode .pm-entrega { background: #1e1e1e; border-color: #2e2e2e; }
body.dark-mode .plan-mapa-dia b, body.dark-mode .pm-cliente, body.dark-mode .plan-mapa-cabecalho h3 { color: #e5e5e5; }
body.dark-mode .plan-mapa-dia.active { background: #3a1515; }
body.dark-mode .pm-hora { color: #e5e5e5; }
body.dark-mode .pm-ver:hover { background: #2a2a2a; color: #ddd; }
body.dark-mode .plan-mapa-mapa, body.dark-mode .plan-mapa-vazio { border-color: #2e2e2e; }
body.dark-mode .plan-mapa-aviso { background: rgba(30,30,30,.95); color: #ddd; }
@media (max-width: 900px) {
  .plan-mapa { grid-template-columns: 1fr; }
  .plan-mapa-entregas { max-height: none; }
  #plan-mapa-leaflet { height: 380px; min-height: 0; }
}

/* ── Carregamento de imagens (fotos e anexos em /uploads/) ──
   O JS marca-as com .img-carregar e junta .img-ok quando chegam (ou falham).
   Até lá o contentor mostra um brilho e a imagem aparece com um desvanecer. */
@keyframes img-brilho { from { background-position: 100% 0; } to { background-position: 0 0; } }
@keyframes img-roda { to { transform: rotate(360deg); } }
img.img-carregar { opacity: 0; transition: opacity .3s ease; }
img.img-carregar.img-ok { opacity: 1; }
:has(> img.img-carregar:not(.img-ok)) {
  background-color: #eceef1;
  background-image: linear-gradient(90deg, #eceef1 0%, #f7f8fa 45%, #eceef1 90%);
  background-size: 300% 100%;
  animation: img-brilho 1.3s ease-in-out infinite;
}
body.dark-mode :has(> img.img-carregar:not(.img-ok)) {
  background-color: #262626;
  background-image: linear-gradient(90deg, #262626 0%, #333 45%, #262626 90%);
}
/* O visor tem fundo escuro: indicador a rodar em vez do brilho, e tamanho mínimo para não saltar */
.gal-visor-img:has(> img.img-carregar:not(.img-ok)) { animation: none; background: #111; min-width: min(760px, calc(100vw - 32px)); min-height: min(60vh, 520px); }
.gal-visor-img:has(> img.img-carregar:not(.img-ok))::after { content: ''; position: absolute; top: 50%; left: 50%; width: 34px; height: 34px; margin: -17px 0 0 -17px; border: 3px solid rgba(255,255,255,.2); border-top-color: #fff; border-radius: 50%; animation: img-roda .8s linear infinite; }
@media (prefers-reduced-motion: reduce) {
  :has(> img.img-carregar:not(.img-ok)) { animation: none; }
  img.img-carregar { transition: none; }
}

/* Seletor de hora da entrega (substitui o seletor nativo do browser) */
.hora-picker { position: relative; max-width: 150px; }
.hora-picker-icone { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); font-size: 15px; color: #9ca3af; pointer-events: none; }
.hora-picker input { width: 100%; padding-left: 32px !important; padding-right: 30px !important; font-variant-numeric: tabular-nums; letter-spacing: .02em; cursor: pointer; }
.hora-picker input.invalida { border-color: var(--brand) !important; }
.hora-picker-limpar { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); width: 22px; height: 22px; border: none; border-radius: 50%; background: none; color: #9ca3af; cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 13px; }
.hora-picker-limpar:hover { background: #f0f0f0; color: #333; }
.hora-picker-painel { display: none; position: absolute; top: calc(100% + 6px); left: 0; z-index: 60; width: 272px; padding: 10px; background: #fff; border: 0.5px solid #e0e0e0; border-radius: 10px; box-shadow: 0 6px 20px rgba(0,0,0,.12); }
.hora-picker-painel.open { display: block; }
.hora-grupo + .hora-grupo { margin-top: 8px; }
.hora-grupo-titulo { font-size: 10px; font-weight: 700; color: #aaa; text-transform: uppercase; letter-spacing: .06em; margin: 0 2px 5px; }
.hora-grelha { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.hora-op { padding: 6px 0; border: 0.5px solid #e0e0e0; border-radius: 6px; background: #fff; color: #444; font-family: 'Poppins', sans-serif; font-size: 12.5px; font-variant-numeric: tabular-nums; cursor: pointer; transition: all .12s; }
.hora-op:hover { border-color: #bbb; background: #f7f7f7; }
.hora-op.sel { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
.hora-op:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
.hora-dica { margin: 8px 2px 0; font-size: 11px; color: #9ca3af; }
body.dark-mode .hora-picker-painel { background: #1e1e1e; border-color: #2e2e2e; box-shadow: 0 6px 20px rgba(0,0,0,.45); }
body.dark-mode .hora-op { background: #1e1e1e; border-color: #2e2e2e; color: #ccc; }
body.dark-mode .hora-op:hover { background: #2a2a2a; border-color: #444; }
body.dark-mode .hora-op.sel { background: var(--brand); border-color: var(--brand); color: #fff; }
body.dark-mode .hora-picker-limpar:hover { background: #2a2a2a; color: #ddd; }

/* Hora marcada no cartão da entrega */
.dc-hora { display: inline-flex; align-items: center; gap: 4px; margin-bottom: 4px; padding: 2px 8px; border-radius: 999px; background: #f3f4f6; color: #333; font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: .01em; }
.dc-hora i { font-size: 12px; color: #888; }
body.dark-mode .dc-hora { background: #2a2a2a; color: #e5e5e5; }
body.dark-mode .dc-hora i { color: #999; }

.gal-barra-dir { display: flex; align-items: center; gap: 8px; }
@media (max-width: 1400px) { .enc-layout-switcher.gal-vista { display: flex; } }

/* ── Planta da loja: grelha 24×14 (a mesma medida está em app.js e stock.js) ── */
.gal-planta-vista { padding: 0 1.25rem 1.5rem; }
.gal-planta-topo { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.gal-planta-acoes { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.gal-planta-dica { font-size: 12px; color: #6b7280; max-width: 460px; }
#btn-gal-planta-editar.active { border-color: var(--brand,#c0392b); color: var(--brand,#c0392b); font-weight: 600; }
.gal-planta-corpo { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 14px; align-items: start; }
.gal-planta { position: relative; aspect-ratio: 24 / 14; background-color: var(--card-bg,#fff); border: 1.5px solid #d1d5db; border-radius: 10px; overflow: hidden; touch-action: none; user-select: none;
  background-image: radial-gradient(circle, #d8dce2 1px, transparent 1.3px); background-size: calc(100% / 24) calc(100% / 14); }
.gal-planta.editar { cursor: crosshair; border-style: dashed; border-color: var(--brand,#c0392b);
  background-image: linear-gradient(#eceef1 1px, transparent 1px), linear-gradient(90deg, #eceef1 1px, transparent 1px); }
.gal-div { position: absolute; box-sizing: border-box; padding: 3px; }
.gal-div-bloco { position: relative; width: 100%; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; gap: 1px; padding: 7px 9px; border: 1.5px solid #9ca3af; border-radius: 6px; background: #f3f4f6 center / cover no-repeat; color: #111; font-family: inherit; text-align: left; cursor: pointer; overflow: hidden; }
.gal-div-bloco > span { position: relative; }
.gal-div-bloco.tem-foto { border-color: transparent; color: #fff; }
.gal-div-bloco.tem-foto::before { content: ''; position: absolute; inset: 0; background: linear-gradient(to top, rgba(0,0,0,.72), rgba(0,0,0,.08) 65%); }
.gal-div-bloco:hover { border-color: var(--brand,#c0392b); }
.gal-div-bloco:focus-visible { outline: 2px solid var(--brand,#c0392b); outline-offset: 1px; }
.gal-div-bloco.sel { box-shadow: 0 0 0 3px var(--brand,#c0392b); }
.gal-div-nome { font-size: 12.5px; font-weight: 600; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gal-div-n { font-size: 11px; opacity: .85; font-variant-numeric: tabular-nums; }
.gal-planta.editar .gal-div-bloco { cursor: move; background-image: none !important; color: #111; border-style: dashed; border-color: #6b7280; }
.gal-planta.editar .gal-div-bloco::before { display: none; }
.gal-div-pega { position: absolute; right: 3px; bottom: 3px; width: 16px; height: 16px; display: none; cursor: nwse-resize; background: var(--brand,#c0392b); border-radius: 4px 0 6px 0; }
.gal-planta.editar .gal-div-pega { display: block; }
.gal-div-rascunho { position: absolute; box-sizing: border-box; border: 2px dashed var(--brand,#c0392b); background: rgba(192,57,43,.08); border-radius: 6px; pointer-events: none; }
.gal-planta-vazia { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 20px; color: #6b7280; font-size: 13px; line-height: 1.5; pointer-events: none; }
.gal-planta-painel { border: 1px solid var(--border,#e5e7eb); border-radius: 10px; background: var(--card-bg,#fff); padding: 12px; max-height: 70vh; overflow: auto; }
.gal-painel-titulo { margin: 0 0 2px; font-size: 14px; font-weight: 600; }
.gal-painel-sub { margin: 0 0 10px; font-size: 12px; color: #6b7280; }
.gal-painel-grelha { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.gal-painel-foto { padding: 0; border: 1px solid var(--border,#e5e7eb); border-radius: 8px; overflow: hidden; background: none; cursor: pointer; aspect-ratio: 4 / 3; }
.gal-painel-foto:hover { border-color: var(--brand,#c0392b); }
.gal-painel-foto img { width: 100%; height: 100%; object-fit: cover; display: block; }
.gal-painel-vazio { padding: 18px 6px; font-size: 12.5px; line-height: 1.5; color: #6b7280; text-align: center; }
.gal-painel-sem { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--border,#e5e7eb); }
.gal-painel-sem small { font-size: 11.5px; color: #9ca3af; }
#gal-div-sugestoes { margin-top: -4px; }
body.dark-mode .gal-planta { border-color: #3a3a3a; background-image: radial-gradient(circle, #3a3a3a 1px, transparent 1.3px); }
body.dark-mode .gal-planta.editar { background-image: linear-gradient(#2a2a2a 1px, transparent 1px), linear-gradient(90deg, #2a2a2a 1px, transparent 1px); }
body.dark-mode .gal-div-bloco { background-color: #262626; color: #e5e7eb; border-color: #4b5563; }
body.dark-mode .gal-div-bloco.tem-foto { color: #fff; border-color: transparent; }
body.dark-mode .gal-planta.editar .gal-div-bloco { color: #e5e7eb; }
@media (max-width: 900px) { .gal-planta-corpo { grid-template-columns: 1fr; } }
@media (max-width: 600px) {
  .gal-toolbar .enc-search-wrap { width: 100%; }
  #gal-filtro-dropdown { min-width: 0; width: calc(100vw - 40px); }
}
.gal-contagem { font-size: 11px; opacity: .65; font-variant-numeric: tabular-nums; }
.gal-estado-campo { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 11px 13px; border: 1px solid var(--border,#e5e7eb); border-radius: 10px; margin-bottom: 4px; }
.gal-estado-campo b { display: block; font-size: 13.5px; }
.gal-estado-campo small { display: block; margin-top: 2px; font-size: 12px; line-height: 1.45; color: #6b7280; }
.gal-selo-arquivo { align-self: flex-start; display: inline-flex; align-items: center; gap: 3px; padding: 1px 7px; border-radius: 999px; background: var(--wash,#f3f4f6); color: #6b7280; font-size: 10.5px; font-weight: 600; }
.gal-cartao.arquivo .gal-mini img { filter: grayscale(.35); }
body.dark-mode .gal-estado-campo small { color: #9ca3af; }
body.dark-mode .gal-selo-arquivo { background: rgba(255,255,255,.08); color: #d1d5db; }
.gal-pill-n { font-size: 11px; opacity: .6; font-variant-numeric: tabular-nums; }
.gal-pill.on .gal-pill-n { opacity: .85; }
.gal-pill { display: inline-flex; align-items: center; gap: 4px; padding: 6px 12px; border: 1px solid var(--border,#e5e7eb); border-radius: 999px; background: var(--card-bg,#fff); color: #4b5563; font-family: inherit; font-size: 13px; cursor: pointer; transition: background .12s, border-color .12s, color .12s; }
.gal-pill:hover { border-color: var(--brand,#c0392b); }
.gal-pill:focus-visible { outline: 2px solid var(--brand,#c0392b); outline-offset: 2px; }
.gal-pill.on { background: var(--brand,#c0392b); border-color: var(--brand,#c0392b); color: #fff; font-weight: 600; }
.gal-pill i { font-size: 13px; }
.gal-tags { display: flex; flex-wrap: wrap; gap: 4px; }
.gal-tag { padding: 2px 8px; border-radius: 999px; background: var(--wash,#f3f4f6); color: #4b5563; font-size: 11px; font-weight: 500; white-space: nowrap; }
.gal-legenda .gal-tags { margin-top: 8px; }
body.dark-mode .gal-pill { color: #d1d5db; }
body.dark-mode .gal-tag { background: rgba(255,255,255,.08); color: #d1d5db; }
.gal-edit-mini { display: block; width: 100%; max-height: 190px; object-fit: cover; border-radius: 10px; margin-bottom: 14px; }
.gal-visor-meta { font-size: 12.5px; color: #6b7280; line-height: 1.6; }
.gal-visor-meta b { color: var(--text,#111); }
.gal-visor-meta small { display: block; font-size: 11px; color: #9ca3af; }
.gal-contador { margin-left: 8px; font-size: 11px; color: #9ca3af; font-variant-numeric: tabular-nums; }

.dark-mode .gal-nav, .dark-mode .gal-fechar { background: rgba(30,35,40,.92); color: #e5e7eb; }

@media (max-width: 760px) {
  .modal.gal-visor { max-height: 92vh; overflow-y: auto; }
  .gal-legenda { flex-direction: column; align-items: stretch; }
  .modal.gal-visor { min-width: 0; }
  .gal-visor-img img { max-height: 60vh; }
  .gal-grelha { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .gal-cartao-info { padding: 7px 8px 9px; }
}
@media (prefers-reduced-motion: reduce) { .gal-cartao { transition: none; } .gal-cartao:hover { transform: none; } }
