/* ===========================================================
   jatto.css — custom components for cashflow / events / tasks
   (rides on top of main.css + reports.css tokens)
   =========================================================== */

/* nav badge on Tareas tab */
.nav-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 18px; padding: 0 5px; margin-left: 4px;
  font-size: 11px; font-weight: 700; border-radius: 9px;
  background: var(--danger); color: #fff; vertical-align: middle;
}

/* flow / range toggle active state */
.cf-flow-btn.active, .ev-range-btn.active {
  background: var(--accent); color: var(--accent-fg); border-color: var(--accent);
}
.cf-flow-toggle, .ev-range { display: inline-flex; gap: 4px; }

input.input[type="month"], input.input[type="date"] {
  padding: 6px 10px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: var(--bg-elev); color: var(--fg); font-family: var(--font-sans);
}

/* span-3 panel spans the full dash grid */
.dash-grid .span-3 { grid-column: 1 / -1; }

/* ---- Cashflow: budget vs actual bars ---- */
.cf-bars { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.cf-bar-row { display: grid; grid-template-columns: 120px 1fr 130px; align-items: center; gap: 10px; }
.cf-bar-label { font-size: 13px; color: var(--fg); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cf-bar-track { position: relative; height: 16px; background: var(--bg-alt); border-radius: 8px; overflow: hidden; }
.cf-bar-budget { position: absolute; top: 0; left: 0; height: 100%; background: var(--line-strong); opacity: .5; border-radius: 8px; }
.cf-bar-actual { position: absolute; top: 0; left: 0; height: 100%; background: var(--accent); border-radius: 8px; transition: width .3s; }
.cf-bar-actual.over { background: var(--danger); }
.cf-bar-val { font-size: 12px; font-family: var(--font-mono); text-align: right; color: var(--fg); }
.cf-bar-val small { color: var(--fg-subtle); font-size: 11px; }

/* ---- Cashflow: transactions table ---- */
.cf-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.cf-table th { text-align: left; padding: 6px 8px; color: var(--fg-muted); font-weight: 600;
  border-bottom: 1px solid var(--line); font-size: 11px; text-transform: uppercase; letter-spacing: .03em; }
.cf-table td { padding: 7px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.cf-table tr:hover td { background: var(--hover); }
.tx-desc small { color: var(--fg-subtle); }
.tx-type.tx-income { color: var(--accent); }
.tx-type.tx-expense { color: var(--warn); }
.tx-amt { font-family: var(--font-mono); text-align: right; white-space: nowrap; }
.tx-amt.income { color: #16a34a; }
.tx-amt.expense { color: var(--danger); }
.tx-del { color: var(--fg-subtle); }
.tx-del:hover { color: var(--danger); }

/* ---- Events ---- */
.events-wrap { display: flex; flex-direction: column; gap: 18px; max-width: 820px; }
.ev-day-head { font-size: 13px; font-weight: 600; color: var(--fg-muted); text-transform: capitalize;
  margin: 0 0 8px; padding-bottom: 4px; border-bottom: 1px solid var(--line); }
.ev-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.ev-item { display: grid; grid-template-columns: 200px 1fr auto; align-items: start; gap: 12px;
  padding: 10px 12px; background: var(--bg-elev); border: 1px solid var(--line);
  border-left: 3px solid var(--accent); border-radius: var(--radius-sm); }
.ev-item.acct-morada { border-left-color: #f59e0b; }
.ev-item.acct-personal { border-left-color: var(--accent); }
.ev-time { font-size: 12px; font-family: var(--font-mono); color: var(--fg-muted); padding-top: 1px; }
.ev-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.ev-title { font-size: 14px; font-weight: 500; color: var(--fg); }
.ev-loc { font-size: 12px; color: var(--fg-subtle); }
.ev-desc { font-size: 12.5px; color: var(--fg-muted); line-height: 1.45; white-space: pre-wrap;
  word-break: break-word; margin-top: 2px; }
.ev-acct { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 10px;
  background: var(--accent-soft); color: var(--accent); }
.ev-acct.acct-morada { background: #fef3c7; color: #92400e; }

/* ---- Tasks ---- */
.tasks-wrap { display: flex; flex-direction: column; gap: 22px; max-width: 760px; }
.tasks-section h3 { font-size: 14px; margin: 0 0 10px; display: flex; align-items: center; gap: 8px; }
.tasks-section h3 .count { font-size: 12px; color: var(--fg-subtle); background: var(--bg-alt);
  padding: 1px 8px; border-radius: 10px; }
.task-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.task-item { display: grid; grid-template-columns: auto 1fr auto; align-items: start; gap: 12px;
  padding: 12px 14px; background: var(--bg-elev); border: 1px solid var(--line); border-radius: var(--radius); }
.task-item.status-done, .task-item.status-cancelled { opacity: .55; }
.task-check { width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--line-strong);
  background: transparent; cursor: pointer; color: var(--accent); font-size: 14px; line-height: 1; padding: 0; }
.task-check:not([disabled]):hover { border-color: var(--accent); }
.task-check[disabled] { background: var(--accent); color: #fff; border-color: var(--accent); cursor: default; }
.task-title { font-size: 14px; font-weight: 500; color: var(--fg); }
.task-title.done { text-decoration: line-through; color: var(--fg-muted); }
.task-meta { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; font-size: 12px; color: var(--fg-subtle); align-items: center; }
.task-prio { font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 8px; }
.prio-high { background: var(--danger-soft); color: var(--danger-fg); }
.prio-normal { background: var(--bg-alt); color: var(--fg-muted); }
.prio-low { background: var(--bg-alt); color: var(--fg-subtle); }
.task-flow, .task-src, .task-due { white-space: nowrap; }
.task-notes { margin-top: 6px; font-size: 13px; color: var(--fg-muted); }
.task-cancel { color: var(--fg-subtle); }
.task-cancel:hover { color: var(--danger); }

/* form rows inside modals (reuse) */
#tx-form .form-row, #task-form .form-row { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
#tx-form label, #task-form label { font-size: 12px; font-weight: 600; color: var(--fg-muted); }
#tx-form input, #tx-form select, #task-form input, #task-form select, #task-form textarea {
  padding: 8px 10px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: var(--bg-elev); color: var(--fg); font-family: var(--font-sans); font-size: 14px; }
#project-form .form-row { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
#project-form label { font-size: 12px; font-weight: 600; color: var(--fg-muted); }
#project-form input, #project-form select {
  padding: 8px 10px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: var(--bg-elev); color: var(--fg); font-family: var(--font-sans); font-size: 14px; }

/* ---- Morada flips view ---- */
#view-morada .cf-table td.num, #view-morada .cf-table th.num { text-align: right; white-space: nowrap; }
#view-morada .cf-table td.pos { color: var(--accent); }
#view-morada .cf-table td.neg { color: var(--danger); }
.mo-sub-toggle { display: inline-flex; gap: 4px; }
.mo-grid th, .mo-grid td { font-size: 12px; padding: 4px 6px; }
.mo-grid-total td { font-weight: 700; border-top: 2px solid var(--line-strong); }
/* ---- Proyectos (flips): tabla cómoda + interacción limpia ---- */
#view-morada .cf-table td.pos { color: var(--ok, #1f7a4d); font-weight: 600; }
.mo-projects { border-collapse: separate; border-spacing: 0; }
.mo-projects thead th {
  font-size: 11px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--fg-subtle); font-weight: 600; padding: 10px 14px;
  border-bottom: 1px solid var(--line);
}
.mo-projects tbody td { padding: 14px; border-bottom: 1px solid var(--line); transition: background .15s var(--ease, ease); }
.mo-projects tbody tr.mo-proj-row { cursor: pointer; }
.mo-projects tbody tr.mo-proj-row td:first-child { box-shadow: inset 3px 0 0 transparent; }
.mo-projects tbody tr.mo-proj-row:hover td { background: var(--azure-tint, #eef2f7); }
.mo-projects tbody tr.mo-proj-row:hover td:first-child { box-shadow: inset 3px 0 0 var(--azure, #264a78); }
.mo-proj-id { font-weight: 600; font-size: 13.5px; color: var(--navy, #0b2340); letter-spacing: -.01em; }
/* fila abierta resaltada */
.mo-projects tbody tr.mo-proj-row.mo-open td { background: var(--azure-tint, #eef2f7); border-bottom-color: transparent; }
.mo-projects tbody tr.mo-proj-row.mo-open td:first-child { box-shadow: inset 3px 0 0 var(--navy, #0b2340); }
/* chevron afford. de expansión */
.mo-chevron { display: inline-block; margin-left: 8px; color: var(--fg-subtle); font-size: 14px;
  transition: transform .25s var(--ease-out, ease); transform: translateY(-1px); }
.mo-proj-row.mo-open .mo-chevron { transform: rotate(180deg); color: var(--azure, #264a78); }

/* badges de estatus — pills Altto */
.mo-badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 11px;
  font-weight: 600; background: var(--bg-alt); border: 1px solid var(--line);
  color: var(--fg-muted); text-transform: capitalize; }
.mo-st-cerrado { background: #e9f6ef; border-color: #bfe3cf; color: #1f7a4d; }
.mo-st-cancelado { background: var(--danger-soft); border-color: #f0c6c1; color: var(--danger-fg); }
.mo-st-en_venta, .mo-st-remodelacion { background: var(--warn-soft); border-color: #ecd9a6; color: var(--warn-fg); }
.mo-st-prospecto, .mo-st-firmado { background: var(--azure-tint); border-color: #cdd9e8; color: var(--azure); }

/* panel de detalle: tarjeta limpia */
.mo-proj-detail > td { padding: 0 14px 16px !important; background: var(--azure-tint, #eef2f7); border-bottom: 1px solid var(--line); }
.mo-detail {
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-lg, 16px);
  box-shadow: var(--shadow-sm); padding: 18px 20px;
  animation: mo-detail-in .28s var(--ease-out, ease);
}
@keyframes mo-detail-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: translateY(0); } }
.mo-pnl { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 4px 24px; }
.mo-pnl > div { display: flex; justify-content: space-between; gap: 12px; font-size: 13px;
  border-bottom: 1px dashed var(--line); padding: 5px 0; }
.mo-pnl > div span { color: var(--fg-subtle); }
.mo-pnl-net { grid-column: 1 / -1; border-bottom: none !important; border-top: 2px solid var(--line-strong);
  font-size: 16px; padding-top: 10px !important; margin-top: 4px; }
.mo-pnl-net b { color: var(--navy, #0b2340); }
.mo-crm { display: inline-block; margin-top: 10px; font-size: 12px; color: var(--fg-subtle);
  background: var(--bg-alt); padding: 4px 10px; border-radius: 999px; }
.mo-detail-actions { margin-top: 14px; display: flex; gap: 8px; flex-wrap: wrap; }
.mo-payroll-grid tfoot td { font-weight: 700; border-top: 2px solid var(--line-strong); }
.mo-paycell { display: flex; flex-direction: column; gap: 2px; align-items: flex-end; }
.mo-paycell .link-btn { font-size: 11px; }

/* ---- Proyectos: tipografía limpia + formulario de alta agrupado ---- */
.mo-projects { font-size: 14px; }
.mo-projects td, .mo-projects th { font-family: var(--font-sans); }
.mo-projects tbody td { font-variant-numeric: tabular-nums; }

/* modal de proyecto más ancho para el grid 2-col */
#project-modal .modal-content { max-width: 600px; width: 600px; }
#project-form { padding: 4px 2px; }

.mo-form { display: flex; flex-direction: column; gap: 18px; }
.mo-fsec-t {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em;
  color: var(--azure, #264a78); margin: 0 0 10px; display: flex; align-items: center; gap: 8px;
}
.mo-opt { font-weight: 500; text-transform: none; letter-spacing: 0; font-size: 11px;
  color: var(--fg-subtle); background: var(--bg-alt); padding: 1px 8px; border-radius: 999px; }
.mo-fgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; }
.mo-field { display: flex; flex-direction: column; gap: 5px; }
.mo-field > span { font-size: 12.5px; font-weight: 600; color: var(--fg); }
.mo-field > span i { color: var(--danger, #b42318); font-style: normal; }
.mo-field small { font-size: 11px; color: var(--fg-subtle); }
.mo-field input, .mo-field select {
  font: inherit; font-size: 14px; padding: 10px 12px;
  border: 1px solid var(--line-strong); border-radius: var(--radius, 12px);
  background: var(--bg-elev); color: var(--fg); outline: none;
  transition: border-color .14s var(--ease, ease), box-shadow .14s var(--ease, ease);
}
.mo-field input:focus, .mo-field select:focus { border-color: var(--azure, #264a78); box-shadow: 0 0 0 3px rgba(38,74,120,.14); }
.mo-field input::placeholder { color: var(--fg-subtle); }
/* input con prefijo $ */
.mo-money { position: relative; display: flex; align-items: center; }
.mo-money > span { position: absolute; left: 12px; color: var(--fg-subtle); font-size: 14px; pointer-events: none; }
.mo-money input { padding-left: 24px; width: 100%; }
@media (max-width: 620px) {
  #project-modal .modal-content { width: auto; max-width: calc(100vw - 24px); }
  .mo-fgrid { grid-template-columns: 1fr; }
}
