/* =========================================================
   Cleaning Schedule Lite v1.0 — styles.css
   Mobile-first · CSS Variables · Flexbox + Grid · Print-ready
   ========================================================= */

/* ---------- 1. TOKENS ---------- */
:root {
  /* Brand */
  --c-primary:        #0f766e;
  --c-primary-dark:   #0b5d56;
  --c-primary-light:  #ccfbf1;
  --c-accent:         #0ea5e9;

  /* Semantic */
  --c-success:        #16a34a;
  --c-success-bg:     #dcfce7;
  --c-warn:           #d97706;
  --c-warn-bg:        #fef3c7;
  --c-danger:         #dc2626;
  --c-danger-bg:      #fee2e2;
  --c-info-bg:        #dbeafe;
  --c-info:           #1d4ed8;

  /* Neutrals */
  --c-bg:             #f4f6f8;
  --c-surface:        #ffffff;
  --c-surface-alt:    #f9fafb;
  --c-border:         #e4e7ec;
  --c-border-strong:  #cbd2da;
  --c-text:           #101828;
  --c-text-soft:      #475467;
  --c-text-mute:      #98a2b3;

  /* Shape & motion */
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-full: 999px;
  --sh-sm: 0 1px 2px rgba(16,24,40,.06);
  --sh-md: 0 4px 12px rgba(16,24,40,.08);
  --sh-lg: 0 12px 32px rgba(16,24,40,.16);
  --t-fast: .15s ease;
  --t-base: .25s ease;

  /* Layout */
  --sidebar-w: 248px;
  --bottom-h: 64px;
  --pad: 16px;

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* ---------- 2. RESET ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--c-text);
  background: var(--c-bg);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}
h1, h2, h3, p { margin: 0; }
button { font: inherit; cursor: pointer; }
input, select, textarea, button { font-family: inherit; }
svg { width: 22px; height: 22px; fill: currentColor; flex: none; }
[hidden] { display: none !important; }
.muted { color: var(--c-text-soft); font-size: 13.5px; }

/* ---------- 3. APP SHELL ---------- */
.app { min-height: 100dvh; display: flex; }

.main {
  flex: 1;
  min-width: 0;
  padding: 0 var(--pad);
  padding-bottom: calc(var(--bottom-h) + 24px + env(safe-area-inset-bottom));
}

/* ---------- 4. SIDEBAR (desktop) ---------- */
.sidebar { display: none; }

.brand { display: flex; align-items: center; gap: 10px; padding: 20px 16px; }
.brand-mark {
  width: 38px; height: 38px; border-radius: var(--r-md);
  background: linear-gradient(135deg, var(--c-primary), var(--c-accent));
  color: #fff; font-weight: 700; font-size: 14px; letter-spacing: .5px;
  display: grid; place-items: center; flex: none;
}
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-text strong { font-size: 14.5px; line-height: 1.2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brand-text span { font-size: 11.5px; color: var(--c-text-mute); }

.side-nav { display: flex; flex-direction: column; gap: 4px; padding: 8px; flex: 1; }
.side-nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 12px; border: 0; border-radius: var(--r-md);
  background: transparent; color: var(--c-text-soft);
  font-size: 14.5px; font-weight: 500; text-align: left;
  transition: background var(--t-fast), color var(--t-fast);
}
.side-nav-item:hover { background: var(--c-surface-alt); color: var(--c-text); }
.side-nav-item.is-active { background: var(--c-primary-light); color: var(--c-primary-dark); font-weight: 600; }
.side-nav-item svg { width: 20px; height: 20px; }

.side-foot { padding: 12px 16px; border-top: 1px solid var(--c-border); }
.db-status { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--c-text-mute); }
.db-status .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--c-success); display: inline-block; }

/* ---------- 5. TOPBAR ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 18px 0 14px;
  position: sticky; top: 0; z-index: 20;
  background: var(--c-bg);
}
.topbar-title h1 { font-size: 22px; font-weight: 700; letter-spacing: -.3px; }
.topbar-title p { font-size: 13px; color: var(--c-text-mute); margin-top: 2px; }
.topbar-actions { display: flex; gap: 8px; }
.topbar-actions .btn { display: none; }   /* mobile usa o FAB */

/* ---------- 6. VIEWS ---------- */
.view { display: none; animation: fadeIn var(--t-base); }
.view.is-active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- 7. BOTÕES ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 11px 16px; border-radius: var(--r-md); border: 1px solid transparent;
  font-size: 14.5px; font-weight: 600; white-space: nowrap;
  transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast), transform var(--t-fast);
}
.btn:active { transform: scale(.98); }
.btn-sm { padding: 7px 12px; font-size: 13px; border-radius: var(--r-sm); }

.btn-primary { background: var(--c-primary); color: #fff; box-shadow: var(--sh-sm); }
.btn-primary:hover { background: var(--c-primary-dark); }
.btn-outline { background: var(--c-surface); color: var(--c-text); border-color: var(--c-border-strong); }
.btn-outline:hover { background: var(--c-surface-alt); }
.btn-ghost { background: transparent; color: var(--c-text-soft); }
.btn-ghost:hover { background: var(--c-surface-alt); color: var(--c-text); }
.btn-danger { background: var(--c-danger); color: #fff; }
.btn-danger:hover { filter: brightness(.93); }
.btn-danger-ghost { background: transparent; color: var(--c-danger); border-color: var(--c-danger-bg); }
.btn-danger-ghost:hover { background: var(--c-danger-bg); }

.icon-btn {
  width: 34px; height: 34px; border: 0; border-radius: var(--r-sm);
  background: transparent; color: var(--c-text-soft); font-size: 24px; line-height: 1;
  display: grid; place-items: center;
}
.icon-btn:hover { background: var(--c-surface-alt); color: var(--c-text); }

/* ---------- 8. FAB ---------- */
.fab {
  position: fixed; right: 18px; z-index: 30;
  bottom: calc(var(--bottom-h) + 18px + env(safe-area-inset-bottom));
  width: 56px; height: 56px; border: 0; border-radius: 50%;
  background: var(--c-primary); color: #fff; box-shadow: var(--sh-lg);
  display: grid; place-items: center;
  transition: transform var(--t-fast), background var(--t-fast);
}
.fab:hover { background: var(--c-primary-dark); }
.fab:active { transform: scale(.94); }
.fab svg { width: 28px; height: 28px; }

/* ---------- 9. BOTTOM NAV (mobile) ---------- */
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  height: calc(var(--bottom-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  display: flex; align-items: stretch;
  background: rgba(255,255,255,.94);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--c-border);
}
.bottom-nav-item {
  flex: 1; border: 0; background: transparent;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--c-text-mute); font-size: 10.5px; font-weight: 600;
  transition: color var(--t-fast);
}
.bottom-nav-item svg { width: 22px; height: 22px; }
.bottom-nav-item.is-active { color: var(--c-primary); }

/* ---------- 10. KPI CARDS ---------- */
.kpi-grid {
  display: grid; gap: 12px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-bottom: 18px;
}
.kpi {
  background: var(--c-surface); border: 1px solid var(--c-border);
  border-radius: var(--r-lg); padding: 14px;
  display: flex; flex-direction: column; gap: 4px;
  box-shadow: var(--sh-sm);
  border-left: 4px solid var(--c-border-strong);
}
.kpi--teal  { border-left-color: var(--c-primary); }
.kpi--green { border-left-color: var(--c-success); }
.kpi--blue  { border-left-color: var(--c-accent); }
.kpi--amber { border-left-color: var(--c-warn); }
.kpi-label { font-size: 12px; font-weight: 600; color: var(--c-text-soft); text-transform: uppercase; letter-spacing: .4px; }
.kpi-value { font-size: 26px; font-weight: 700; letter-spacing: -.6px; line-height: 1.15; }
.kpi-hint { font-size: 11.5px; color: var(--c-text-mute); }

/* ---------- 11. PANELS ---------- */
.panel {
  background: var(--c-surface); border: 1px solid var(--c-border);
  border-radius: var(--r-lg); box-shadow: var(--sh-sm);
  margin-bottom: 16px; overflow: hidden;
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 14px 16px; border-bottom: 1px solid var(--c-border);
}
.panel-head h2 { font-size: 15px; font-weight: 700; }
.panel-body { padding: 16px; }

/* ---------- 12. TOOLBAR / FILTROS / BUSCA ---------- */
.toolbar { display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  padding: 7px 14px; border-radius: var(--r-full);
  border: 1px solid var(--c-border-strong); background: var(--c-surface);
  color: var(--c-text-soft); font-size: 13px; font-weight: 600; white-space: nowrap;
  transition: all var(--t-fast);
}
.chip.is-active { background: var(--c-primary); border-color: var(--c-primary); color: #fff; }

.search { position: relative; display: flex; align-items: center; }
.search svg { position: absolute; left: 12px; width: 18px; height: 18px; color: var(--c-text-mute); pointer-events: none; }
.search input {
  width: 100%; padding: 11px 14px 11px 38px;
  border: 1px solid var(--c-border-strong); border-radius: var(--r-md);
  background: var(--c-surface); font-size: 14.5px; color: var(--c-text);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.search input:focus { outline: 0; border-color: var(--c-primary); box-shadow: 0 0 0 3px var(--c-primary-light); }

/* ---------- 13. LISTAS / CARDS DE REGISTRO ---------- */
.list { display: flex; flex-direction: column; gap: 10px; }
.card {
  background: var(--c-surface); border: 1px solid var(--c-border);
  border-radius: var(--r-lg); padding: 14px; box-shadow: var(--sh-sm);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.card:hover { border-color: var(--c-border-strong); box-shadow: var(--sh-md); }
.card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.card-title { font-size: 15.5px; font-weight: 700; letter-spacing: -.2px; }
.card-sub { font-size: 13px; color: var(--c-text-soft); margin-top: 2px; }
.card-meta { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 10px; font-size: 13px; color: var(--c-text-soft); }
.card-meta span { display: inline-flex; align-items: center; gap: 5px; }
.card-actions { display: flex; gap: 6px; margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--c-border); flex-wrap: wrap; }
.card-amount { font-size: 16px; font-weight: 700; color: var(--c-primary-dark); white-space: nowrap; }

/* Badges */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: var(--r-full);
  font-size: 11.5px; font-weight: 700; letter-spacing: .2px;
  background: var(--c-surface-alt); color: var(--c-text-soft);
}
.badge--scheduled { background: var(--c-info-bg);    color: var(--c-info); }
.badge--done      { background: var(--c-success-bg); color: var(--c-success); }
.badge--cancel    { background: var(--c-danger-bg);  color: var(--c-danger); }
.badge--late      { background: var(--c-warn-bg);    color: var(--c-warn); }
.badge--res       { background: var(--c-primary-light); color: var(--c-primary-dark); }
.badge--com       { background: #ede9fe; color: #6d28d9; }

/* Estado vazio */
.empty { text-align: center; padding: 36px 16px; color: var(--c-text-mute); }
.empty strong { display: block; font-size: 15px; color: var(--c-text-soft); margin-bottom: 4px; }
.empty p { font-size: 13.5px; }

/* Separador de data na agenda */
.date-sep {
  font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px;
  color: var(--c-text-mute); padding: 10px 2px 2px;
}

/* ---------- 14. FORMULÁRIOS ---------- */
.form-grid { display: grid; gap: 14px; grid-template-columns: 1fr; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 13px; font-weight: 600; color: var(--c-text-soft); }
.field input, .field select, .field textarea {
  width: 100%; padding: 11px 12px;
  border: 1px solid var(--c-border-strong); border-radius: var(--r-md);
  background: var(--c-surface); font-size: 15px; color: var(--c-text);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.field textarea { resize: vertical; min-height: 66px; }
.field input:focus, .field select:focus, .field textarea:focus {
  outline: 0; border-color: var(--c-primary); box-shadow: 0 0 0 3px var(--c-primary-light);
}
.field input[readonly] { background: var(--c-surface-alt); color: var(--c-text-mute); }
.form-actions { display: flex; gap: 8px; justify-content: flex-end; }

/* Logo */
.logo-row { display: flex; align-items: center; gap: 12px; }
.logo-preview {
  width: 84px; height: 84px; flex: none; border-radius: var(--r-md);
  border: 1px dashed var(--c-border-strong); background: var(--c-surface-alt);
  display: grid; place-items: center; overflow: hidden;
}
.logo-preview img { width: 100%; height: 100%; object-fit: contain; }
.logo-preview span { font-size: 11.5px; color: var(--c-text-mute); }
.logo-actions { display: flex; flex-direction: column; gap: 8px; }

.data-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }

/* ---------- 15. ITENS DO INVOICE ---------- */
.items { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.item-row {
  display: grid; gap: 8px; align-items: center;
  grid-template-columns: 1fr auto;
  background: var(--c-surface-alt); border: 1px solid var(--c-border);
  border-radius: var(--r-md); padding: 10px;
}
.item-row .item-desc { grid-column: 1 / -1; }
.item-row input {
  width: 100%; padding: 9px 10px; font-size: 14px;
  border: 1px solid var(--c-border-strong); border-radius: var(--r-sm); background: var(--c-surface);
}
.item-row input:focus { outline: 0; border-color: var(--c-primary); box-shadow: 0 0 0 3px var(--c-primary-light); }
.item-nums { display: grid; grid-template-columns: 68px 1fr 34px; gap: 8px; align-items: center; grid-column: 1 / -1; }
.item-del {
  width: 34px; height: 34px; border: 0; border-radius: var(--r-sm);
  background: var(--c-danger-bg); color: var(--c-danger); font-size: 18px; line-height: 1;
  display: grid; place-items: center;
}

/* Totais */
.totals {
  background: var(--c-surface-alt); border: 1px solid var(--c-border);
  border-radius: var(--r-md); padding: 12px 14px;
  display: flex; flex-direction: column; gap: 6px;
}
.totals-row { display: flex; justify-content: space-between; font-size: 14px; color: var(--c-text-soft); }
.totals-row strong { color: var(--c-text); font-weight: 600; }
.totals-row--grand {
  border-top: 1px solid var(--c-border-strong); margin-top: 4px; padding-top: 8px;
  font-size: 16px; font-weight: 700; color: var(--c-text);
}
.totals-row--grand strong { font-size: 19px; color: var(--c-primary-dark); }

/* ---------- 16. MODAIS ---------- */
.modal { position: fixed; inset: 0; z-index: 100; display: flex; align-items: flex-end; justify-content: center; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(16,24,40,.5); backdrop-filter: blur(2px); animation: fadeIn var(--t-fast); }
.modal-card {
  position: relative; width: 100%; max-height: 92dvh;
  background: var(--c-surface);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  box-shadow: var(--sh-lg);
  display: flex; flex-direction: column;
  animation: slideUp var(--t-base);
}
@keyframes slideUp { from { transform: translateY(28px); opacity: .6; } to { transform: none; opacity: 1; } }
.modal-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 14px 16px; border-bottom: 1px solid var(--c-border);
  position: sticky; top: 0; background: var(--c-surface); border-radius: inherit; z-index: 2;
}
.modal-head h2 { font-size: 16.5px; font-weight: 700; }
.modal-body { padding: 16px; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.modal-foot {
  display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap;
  padding-top: 6px; margin-top: 2px;
}
.modal-foot .btn { flex: 1; min-width: 120px; }
.modal--sm .modal-card { max-width: 420px; }

/* ---------- 17. TOAST ---------- */
.toast {
  position: fixed; z-index: 200; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--bottom-h) + 26px + env(safe-area-inset-bottom));
  max-width: calc(100% - 32px);
  padding: 11px 18px; border-radius: var(--r-full);
  background: #101828; color: #fff; font-size: 13.5px; font-weight: 600;
  box-shadow: var(--sh-lg); animation: fadeIn var(--t-fast);
}
.toast--ok    { background: var(--c-success); }
.toast--error { background: var(--c-danger); }

/* ---------- 18. ÁREA DE IMPRESSÃO (PDF) ---------- */
.print-area { display: none; }

.doc { color: #101828; font-size: 13px; }
.doc-head { display: flex; justify-content: space-between; gap: 24px; align-items: flex-start;
            padding-bottom: 16px; border-bottom: 3px solid var(--c-primary); }
.doc-logo { max-height: 72px; max-width: 200px; object-fit: contain; margin-bottom: 8px; }
.doc-company strong { display: block; font-size: 19px; letter-spacing: -.3px; }
.doc-company span { display: block; font-size: 12px; color: #475467; }
.doc-meta { text-align: right; }
.doc-meta h2 { font-size: 24px; letter-spacing: 2px; text-transform: uppercase; color: var(--c-primary); }
.doc-meta p { font-size: 12px; color: #475467; }
.doc-parties { display: flex; gap: 32px; margin: 22px 0 16px; }
.doc-parties h3 { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: #98a2b3; margin-bottom: 4px; }
.doc-table { width: 100%; border-collapse: collapse; margin-top: 8px; }
.doc-table th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .6px;
  padding: 9px 10px; background: #f2f4f7; border-bottom: 1px solid #e4e7ec; color: #475467;
}
.doc-table td { padding: 10px; border-bottom: 1px solid #eaecf0; vertical-align: top; }
.doc-table .num { text-align: right; white-space: nowrap; }
.doc-totals { margin-top: 16px; margin-left: auto; width: 260px; }
.doc-totals div { display: flex; justify-content: space-between; padding: 5px 0; font-size: 13px; }
.doc-totals .grand {
  border-top: 2px solid #101828; margin-top: 6px; padding-top: 8px;
  font-size: 17px; font-weight: 700; color: var(--c-primary);
}
.doc-notes { margin-top: 26px; font-size: 12px; color: #475467; }
.doc-foot { margin-top: 34px; padding-top: 12px; border-top: 1px solid #e4e7ec;
            font-size: 11px; color: #98a2b3; text-align: center; }

/* ---------- 19. BREAKPOINT: TABLET (>= 640px) ---------- */
@media (min-width: 640px) {
  .kpi-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .span-2 { grid-column: 1 / -1; }
  .toolbar { flex-direction: row; align-items: center; justify-content: space-between; }
  .search { min-width: 260px; max-width: 340px; }
  .item-row { grid-template-columns: 1fr 300px; }
  .item-row .item-desc { grid-column: auto; }
  .item-nums { grid-column: auto; }
  .data-actions { flex-direction: row; flex-wrap: wrap; }
  .modal { align-items: center; padding: 24px; }
  .modal-card { max-width: 560px; border-radius: var(--r-lg); max-height: 88dvh; }
  .modal-card--wide { max-width: 760px; }
  .modal-foot .btn { flex: 0 0 auto; }
}

/* ---------- 20. BREAKPOINT: DESKTOP (>= 1024px) ---------- */
@media (min-width: 1024px) {
  .sidebar {
    display: flex; flex-direction: column;
    width: var(--sidebar-w); flex: none;
    background: var(--c-surface); border-right: 1px solid var(--c-border);
    position: sticky; top: 0; height: 100dvh;
  }
  .main { padding: 0 32px; padding-bottom: 40px; }
  .bottom-nav, .fab { display: none; }
  .topbar { padding: 26px 0 18px; }
  .topbar-title h1 { font-size: 26px; }
  .topbar-actions .btn { display: inline-flex; }
  .toast { bottom: 26px; }
  .view { max-width: 1100px; }
}

/* ---------- 21. PRINT ---------- */
@media print {
  @page { size: A4; margin: 14mm; }
  body { background: #fff; font-size: 12px; }
  .app, .modal, .toast, .fab, .bottom-nav, .sidebar, .topbar { display: none !important; }
  .print-area { display: block !important; }
  .doc-table thead { display: table-header-group; }
  .doc-table tr { break-inside: avoid; }
  a { text-decoration: none; color: inherit; }
}

/* ---------- 22. ACESSIBILIDADE ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
:focus-visible { outline: 2px solid var(--c-primary); outline-offset: 2px; border-radius: 4px; }
