:root {
  --ink: #123b36;
  --ink-deep: #082d29;
  --mint: #c7f36a;
  --paper: #fcfbf7;
  --line: rgba(18,59,54,.14);
  --danger: #b3261e;
}

* { box-sizing: border-box; }
body { margin: 0; color: var(--ink); background: var(--paper); font-family: "DM Sans", sans-serif; -webkit-font-smoothing: antialiased; }
h1, h2, h3 { margin: 0; font-family: "Manrope", sans-serif; letter-spacing: -.6px; }
a { color: inherit; }

.container { max-width: 1080px; margin: 0 auto; padding: 0 24px; }
body > .container { padding-bottom: 80px; }

.top-bar { display: flex; align-items: center; justify-content: space-between; padding: 16px 0; border-bottom: 1px solid var(--line); }
.top-bar .brand { display: flex; align-items: center; gap: 10px; font: 800 18px "Manrope"; }
.top-bar img { height: 56px; width: auto; object-fit: contain; }
.top-bar .brand { cursor: pointer; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 11px 20px; border-radius: 8px; border: 1px solid transparent; font: 700 14px "DM Sans"; cursor: pointer; text-decoration: none; }
.btn-primary { background: var(--ink-deep); color: #fff; }
.btn-primary:hover { background: var(--ink); }
.btn-accent { background: var(--mint); color: var(--ink-deep); }
.btn-outline { background: transparent; border-color: var(--line); color: var(--ink); }
.btn-sm { padding: 7px 14px; font-size: 13px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.auth-card { width: 100%; max-width: 400px; background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 32px; box-shadow: 0 20px 45px rgba(8,45,41,.08); }
.auth-card h1 { font-size: 22px; margin-bottom: 6px; }
.auth-card p.sub { color: #5c7a75; font-size: 14px; margin-bottom: 24px; }

.field { margin-bottom: 16px; }
.field label { display: block; font: 700 13px "DM Sans"; margin-bottom: 6px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: 8px;
  font: 500 14px "DM Sans"; color: var(--ink); background: var(--paper);
}
.field textarea { resize: vertical; min-height: 70px; }

.error-box { background: #fdecea; border: 1px solid #f5c2be; color: var(--danger); padding: 10px 12px; border-radius: 8px; font-size: 13px; margin-bottom: 16px; display: none; }
.error-box.show { display: block; }

.auth-footer { margin-top: 18px; text-align: center; font-size: 13px; color: #5c7a75; }

.page-header { display: flex; align-items: center; justify-content: space-between; padding: 28px 0 20px; }
.page-header h1 { font-size: 24px; }
.page-header .role-tag { font: 700 12px "DM Sans"; background: var(--mint); color: var(--ink-deep); padding: 4px 10px; border-radius: 20px; margin-left: 10px; }

/* Cliente: lista de cards */
.client-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px,1fr)); gap: 16px; margin-top: 20px; }
.card-box { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 18px; }
.card-box h3 { font-size: 16px; margin-bottom: 4px; }
.card-box .doc-type { font-size: 12px; color: #5c7a75; margin-bottom: 10px; }
.phase-badge { display: inline-block; font: 700 11px "DM Sans"; padding: 4px 10px; border-radius: 20px; background: #eef4f2; color: var(--ink); }
.phase-badge.entrega_final { background: var(--mint); color: var(--ink-deep); }
.phase-badge.draft { background: #fdecea; color: var(--danger); }
.card-box .files-mini { margin-top: 12px; font-size: 12px; color: #5c7a75; }

/* Admin: kanban */
.kanban { display: grid; grid-template-columns: repeat(5, 1fr); gap: 14px; margin-top: 20px; overflow-x: auto; }
.kanban-col { background: #f2f1ea; border-radius: 12px; padding: 12px; min-height: 200px; }
.kanban-col h4 { font-size: 13px; margin-bottom: 10px; color: var(--ink); }
.kanban-card { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 12px; margin-bottom: 10px; cursor: grab; }
.kanban-card:active { cursor: grabbing; }
.kanban-card .client { font-size: 11px; color: #5c7a75; }
.kanban-card .title { font: 700 13px "DM Sans"; margin: 4px 0; }
.kc-tags { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 6px; }
.tag { display: inline-block; font: 700 10px "DM Sans"; padding: 2px 8px; border-radius: 10px; white-space: nowrap; }
.tag-doctype { background: var(--ink-deep); color: #fff; }
.tag-client { background: #eef4f2; color: var(--ink); }
.tag-date { background: #f2f1ea; color: #5c7a75; }
.kanban-col.drag-over { outline: 2px dashed var(--ink); outline-offset: -6px; }

/* Modal de detalhe do card */
.modal-overlay { position: fixed; inset: 0; background: rgba(8,45,41,.55); display: none; align-items: center; justify-content: center; padding: 20px; z-index: 50; }
.modal-overlay.show { display: flex; }
.modal-box { background: #fff; border-radius: 14px; padding: 28px; max-width: 560px; width: 100%; max-height: 85vh; overflow-y: auto; }
.modal-box h2 { font-size: 19px; margin-bottom: 4px; }
.modal-close { float: right; background: none; border: none; font-size: 20px; cursor: pointer; color: var(--ink); }

.upload-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.upload-row:last-child { border-bottom: none; }
.file-list { margin-top: 8px; font-size: 12px; }
.file-list a { color: var(--ink-deep); text-decoration: underline; }

.new-card-form { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 20px; margin-top: 20px; }

.client-hero {
  display: flex; align-items: center; justify-content: space-between; gap: 20px;
  background: linear-gradient(135deg, var(--ink-deep), var(--ink));
  color: #fff; border-radius: 16px; padding: 26px 28px; margin-top: 10px;
}
.client-hero h2 { color: #fff; }
.client-hero p { color: rgba(255,255,255,.75) !important; }

.client-info-box { background: #f2f1ea; border-radius: 10px; padding: 14px; font-size: 13px; line-height: 1.7; margin-bottom: 16px; }

.stepper { display: flex; justify-content: space-between; gap: 4px; margin: 14px 0; }
.step { flex: 1; text-align: center; font-size: 10px; color: #9fb3ae; position: relative; }
.step .dot { display: block; width: 12px; height: 12px; border-radius: 50%; background: #e2e2da; margin: 0 auto 6px; }
.step.done .dot { background: var(--ink); }
.step.current .dot { background: var(--mint); outline: 3px solid rgba(199,243,106,.35); }
.step.done .step-label { color: var(--ink); font-weight: 700; }
.step.current .step-label { color: var(--ink); font-weight: 800; }

.warning-box { display: none; background: #fff7e6; border: 1px solid #f2d488; color: #7a5b06; padding: 10px 12px; border-radius: 8px; font-size: 13px; margin: 14px 0; }
.warning-box.locked { background: #eef4f2; border-color: var(--line); color: var(--ink); }
.warning-box.overdue { background: #fdecea; border-color: #f5c2be; color: var(--danger); }

.overdue-card { outline: 2px solid var(--danger); outline-offset: -4px; }
.overdue-badge { display: inline-block; background: var(--danger); color: #fff; font: 800 10px "DM Sans"; padding: 2px 7px; border-radius: 10px; }

.timeline { margin-top: 10px; }
.timeline-item { display: flex; gap: 10px; padding-bottom: 14px; position: relative; }
.timeline-item::before { content: ''; position: absolute; left: 4px; top: 14px; bottom: 0; width: 1px; background: var(--line); }
.timeline-item:last-child::before { display: none; }
.timeline-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--ink); margin-top: 4px; flex-shrink: 0; }
.timeline-text { font-size: 13px; }
.timeline-date { font-size: 11px; color: #5c7a75; margin-top: 2px; }

.final-delivery-box { background: #fbfaf5; border: 1px dashed var(--ink); border-radius: 10px; padding: 14px; margin: 14px 0; }

.version-block { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; margin-bottom: 14px; }
.version-header { display: flex; justify-content: space-between; align-items: center; font-size: 13px; margin-bottom: 8px; }
.comments-thread { margin-bottom: 8px; }
.comment-item { background: #f8f7f2; border-radius: 8px; padding: 8px 10px; margin-bottom: 6px; font-size: 12px; }
.comment-item.resolved { opacity: .6; }
.comment-meta { color: #5c7a75; margin-bottom: 3px; }
.resolved-tag { color: #2f7a3d; font-weight: 700; }
.comment-text { font-size: 13px; }
.comment-empty { font-size: 12px; color: #9fb3ae; margin-bottom: 6px; }
.resolve-btn { margin-top: 6px; }
.comment-form textarea { width: 100%; padding: 8px; border: 1px solid var(--line); border-radius: 8px; font: 500 13px "DM Sans"; resize: vertical; margin-bottom: 6px; }

.revisions-list { margin-top: 20px; display: flex; flex-direction: column; gap: 10px; }
.revision-card { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 14px; display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; }
.revision-card .meta { font-size: 12px; color: #5c7a75; margin-bottom: 4px; }
.revision-card .text { font-size: 13px; }
.tab-row { display: flex; gap: 8px; margin-bottom: 6px; }
.tab-btn { padding: 8px 16px; border-radius: 8px; border: 1px solid var(--line); background: #fff; cursor: pointer; font: 700 13px "DM Sans"; color: var(--ink); }
.tab-btn.active { background: var(--ink-deep); color: #fff; border-color: var(--ink-deep); }
.filter-bar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.filter-bar input, .filter-bar select { padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; font: 500 13px "DM Sans"; }
.filter-bar #filterText { flex: 1; min-width: 200px; }

.msel { position: relative; }
.msel-btn { padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; font: 500 13px "DM Sans"; cursor: pointer; min-width: 160px; text-align: left; }
.msel-panel { position: absolute; top: calc(100% + 4px); left: 0; z-index: 20; width: 260px; background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 12px 30px rgba(8,45,41,.15); padding: 8px; }
.msel-search { width: 100%; padding: 7px 9px; border: 1px solid var(--line); border-radius: 6px; font: 500 13px "DM Sans"; margin-bottom: 6px; }
.msel-options { max-height: 220px; overflow-y: auto; }
.msel-opt { display: flex; align-items: center; gap: 8px; padding: 6px 4px; font-size: 13px; cursor: pointer; border-radius: 6px; }
.msel-opt:hover { background: #f2f1ea; }
.comments-count-badge { display: inline-block; background: var(--danger); color: #fff; font: 800 10px "DM Sans"; padding: 2px 7px; border-radius: 10px; margin-left: 6px; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px,1fr)); gap: 14px; margin-top: 20px; }
.stat-tile { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 16px; }
.stat-tile.stat-danger { border-color: #f5c2be; background: #fdecea; }
.stat-value { font: 800 26px "Manrope"; color: var(--ink-deep); }
.stat-tile.stat-danger .stat-value { color: var(--danger); }
.stat-tile.stat-success { border-color: #9fd2ad; background: #edf8f0; }
.stat-tile.stat-success .stat-value, .dre-positive { color: #1f6b2e; font-weight: 700; }
.dre-negative { color: var(--danger); font-weight: 700; }
.dre-note { margin: 12px 0 4px; padding: 10px 12px; border-left: 4px solid var(--ink-deep); background: #eef6f3; color: #315b54; font-size: 12px; border-radius: 6px; }
.dre-secondary { grid-template-columns: repeat(2, minmax(180px, 1fr)); }
.rx-dx-grid { display: grid; grid-template-columns: repeat(2, minmax(260px,1fr)); gap: 18px; margin-top: 18px; }
.rx-dx-card { appearance: none; text-align: left; border: 1px solid var(--line); border-radius: 16px; padding: 24px; background: #fff; cursor: pointer; color: var(--ink-deep); font-family: "DM Sans"; transition: transform .15s ease, box-shadow .15s ease; }
.rx-dx-card:hover { transform: translateY(-2px); box-shadow: 0 12px 28px rgba(8,45,41,.12); }
.rx-dx-card.revenue { border-left: 7px solid #25834a; background: linear-gradient(135deg,#fff 55%,#edf8f0); }
.rx-dx-card.expense { border-left: 7px solid #b3261e; background: linear-gradient(135deg,#fff 55%,#fff0ef); }
.rx-dx-kicker { display: block; font-size: 13px; font-weight: 700; color: #5c7a75; text-transform: uppercase; letter-spacing: .04em; }
.rx-dx-card strong { display: block; font: 800 36px "Manrope"; margin: 8px 0 14px; }
.rx-dx-sub { display: block; font-size: 14px; color: #315b54; }
.rx-dx-sub b { font-size: 18px; }
.rx-dx-link { display: block; margin-top: 16px; font-size: 12px; font-weight: 700; }
.rx-dx-result { margin-top: 18px; }
.annual-chart-section { margin-top: 24px; padding: 18px 18px 8px; background: #fff; border: 1px solid var(--line); border-radius: 16px; }
.annual-chart-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.annual-chart-head h3 { margin: 0; font-size: 17px; }
.annual-chart-head p { margin: 4px 0 0; color: #5c7a75; font-size: 12px; }
.annual-legend { font-size: 12px; white-space: nowrap; color: #315b54; }
.annual-legend span { display: inline-block; width: 11px; height: 11px; border-radius: 3px; margin: 0 4px 0 12px; }
.annual-legend .rev { background: #25834a; }
.annual-legend .exp { background: #c33127; }
.annual-totals { display: flex; flex-wrap: wrap; gap: 10px 24px; margin: 16px 0 2px; font-size: 12px; color: #5c7a75; }
.annual-totals b { display: block; color: var(--ink-deep); font-size: 17px; margin-top: 2px; }
.annual-chart-scroll { width: 100%; overflow-x: auto; }
.annual-chart { display: block; width: 100%; min-width: 900px; height: auto; }
.annual-hit { fill: transparent; }
.annual-month { cursor: pointer; outline: none; }
.annual-month:hover .annual-hit, .annual-month:focus .annual-hit { fill: #edf5f2; }
.annual-month.selected .annual-hit { fill: #e1f0eb; stroke: #8bbcad; stroke-width: 1; }
.annual-bar.revenue { fill: #25834a; }
.annual-bar.expense { fill: #c33127; }
.annual-value { font: 700 9px "DM Sans"; }
.annual-value.revenue { fill: #1f6b2e; }
.annual-value.expense { fill: #a32018; }
.annual-label { fill: #315b54; font: 700 11px "DM Sans"; }
.annual-axis { stroke: #aac8bf; stroke-width: 1; }
.stat-label { font-size: 12px; color: #5c7a75; margin-top: 4px; }

.report-bars { margin-top: 10px; }
.report-bar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; font-size: 12px; }
.report-bar-label { width: 150px; flex-shrink: 0; color: #5c7a75; }
.report-bar-track { flex: 1; height: 10px; background: #eef1ee; border-radius: 6px; overflow: hidden; }
.report-bar-fill { height: 100%; background: var(--ink-deep); border-radius: 6px; }
.report-bar-count { width: 24px; text-align: right; font-weight: 700; }

.report-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 12px; margin-top: 8px; }
.report-table th { text-align: left; color: #315b54; background: #c9ddd7; font-weight: 700; padding: 8px; border-bottom: 1px solid #aac8bf; }
.report-table tbody tr:nth-child(odd) { background: #f4f9f7; }
.report-table tbody tr:nth-child(even) { background: #dfece8; }
.report-table td { padding: 8px; border-bottom: 1px solid #c5d9d3; transition: background-color .15s ease; }
.report-table tr.clickable-row { cursor: pointer; }
.report-table tr.clickable-row:hover { background: #bfd8d0; }
.report-table input:not([type="checkbox"]) { background: rgba(255,255,255,.58) !important; }

@media print {
  .top-bar, .tab-row, .filter-bar, .kanban, .page-header, .client-hero,
  #revisionsList, .modal-overlay, .btn, .no-print { display: none !important; }
  body { background: #fff; padding: 0; }
  .container { padding-bottom: 0 !important; }
  .stat-tile, .report-table { break-inside: avoid; }
  .report-table th { background: #c9ddd7 !important; print-color-adjust: exact; -webkit-print-color-adjust: exact; }
  .report-table tbody tr:nth-child(odd) { background: #f4f9f7 !important; print-color-adjust: exact; -webkit-print-color-adjust: exact; }
  .report-table tbody tr:nth-child(even) { background: #dfece8 !important; print-color-adjust: exact; -webkit-print-color-adjust: exact; }
  .print-header h2 { margin-bottom: 2px; }
  .print-header { text-align: center; border-bottom: 2px solid var(--ink-deep); padding-bottom: 12px; margin-bottom: 16px; }
}

.bulk-toolbar { display: flex; align-items: center; gap: 8px; background: #fff7e6; border: 1px solid #f2d488; border-radius: 8px; padding: 10px 12px; margin: 10px 0; flex-wrap: wrap; }
.bulk-toolbar select, .bulk-toolbar input { padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; font: 500 13px "DM Sans"; }

.celebration-box { background: var(--mint); color: var(--ink-deep); border-radius: 12px; padding: 16px; margin-bottom: 16px; font-size: 14px; line-height: 1.5; }
.card-box.ready { border-color: var(--mint); box-shadow: 0 0 0 2px var(--mint) inset; }

@media (max-width: 860px) {
  .kanban { grid-template-columns: 1fr; }
  .rx-dx-grid { grid-template-columns: 1fr; }
}
