/*
Jury Marketing - Finance & Billing workspace layout. Purely additive:
new jm-fin-* classes only, reusing every existing token/component class
from tokens.css, components.css, dashboard.css (jm-dash-*), and
clients.css' already-loaded jm-modal-* classes rather than duplicating
them - same discipline as campaigns.css/operations.css.
*/

.jm-fin-section-title {
  font-size: var(--jm-fs-md);
  font-weight: var(--jm-fw-bold);
  color: var(--jm-text);
  margin: var(--jm-space-6) 0 var(--jm-space-4);
}

/* --- Revenue Overview chart --- */

.jm-fin-chart {
  display: flex;
  align-items: flex-end;
  gap: var(--jm-space-3);
  height: 180px;
  padding: var(--jm-space-4) var(--jm-space-2) 0;
  overflow-x: auto;
}

.jm-fin-chart-month {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  min-width: 52px;
  height: 100%;
  gap: var(--jm-space-1);
}

.jm-fin-chart-bars {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  flex: 1;
}

.jm-fin-chart-bar {
  width: 12px;
  border-radius: 3px 3px 0 0;
  min-height: 2px;
}

.jm-fin-chart-bar-revenue { background: var(--jm-gold); }
.jm-fin-chart-bar-expenses { background: var(--jm-border); }

.jm-fin-chart-label {
  font-size: var(--jm-fs-xs);
  color: var(--jm-text-muted);
  white-space: nowrap;
}

.jm-fin-chart-legend {
  display: flex;
  gap: var(--jm-space-4);
  margin-top: var(--jm-space-2);
  font-size: var(--jm-fs-xs);
  color: var(--jm-text-muted);
}

.jm-fin-chart-legend-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: var(--jm-radius-full);
  margin-right: 4px;
  vertical-align: middle;
}

.jm-fin-chart-legend-dot.revenue { background: var(--jm-gold); }
.jm-fin-chart-legend-dot.expenses { background: var(--jm-border); }

/* --- Toolbar --- */

.jm-fin-toolbar {
  display: flex;
  align-items: center;
  gap: var(--jm-space-3);
  flex-wrap: wrap;
  margin-top: var(--jm-space-2);
  margin-bottom: var(--jm-space-5);
}

.jm-fin-search {
  flex: 1;
  min-width: 200px;
  max-width: 320px;
}

.jm-fin-filter {
  min-width: 140px;
  max-width: 180px;
}

/* --- Desktop table (shared shape for invoices + expenses) --- */

.jm-fin-table-wrap {
  overflow-x: auto;
}

.jm-fin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--jm-fs-sm);
}

.jm-fin-table th {
  text-align: left;
  padding: var(--jm-space-3) var(--jm-space-3);
  font-size: var(--jm-fs-xs);
  font-weight: var(--jm-fw-semibold);
  color: var(--jm-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  border-bottom: 1px solid var(--jm-border);
  white-space: nowrap;
}

.jm-fin-table td {
  padding: var(--jm-space-3) var(--jm-space-3);
  border-bottom: 1px solid var(--jm-border);
  vertical-align: middle;
  white-space: nowrap;
}

.jm-fin-table tbody tr:last-child td { border-bottom: none; }

.jm-fin-name-text {
  font-weight: var(--jm-fw-semibold);
  color: var(--jm-text);
}

.jm-fin-client-link {
  color: var(--jm-text);
  cursor: pointer;
  text-decoration: underline;
  text-decoration-color: var(--jm-border);
  text-underline-offset: 2px;
}

.jm-fin-client-link:hover {
  text-decoration-color: var(--jm-text);
}

.jm-fin-status-select {
  min-width: 110px;
}

.jm-fin-row-actions {
  display: flex;
  align-items: center;
  gap: var(--jm-space-2);
  flex-wrap: wrap;
}

/* --- Mobile stacked cards --- */

.jm-fin-cards {
  display: none;
  flex-direction: column;
  gap: var(--jm-space-3);
}

.jm-fin-card {
  display: flex;
  flex-direction: column;
  gap: var(--jm-space-2);
}

.jm-fin-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--jm-space-2);
}

.jm-fin-card-name {
  font-size: var(--jm-fs-base);
  font-weight: var(--jm-fw-bold);
  color: var(--jm-text);
}

.jm-fin-card-meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--jm-space-2) var(--jm-space-4);
  font-size: var(--jm-fs-sm);
  color: var(--jm-text-muted);
}

/* --- Accepted proposals awaiting invoice --- */

.jm-fin-proposal-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--jm-space-3);
  flex-wrap: wrap;
}

/* --- Reports --- */

.jm-fin-reports-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: var(--jm-space-3);
  margin-bottom: var(--jm-space-4);
}

.jm-fin-format-row {
  display: flex;
  gap: var(--jm-space-2);
  flex-wrap: wrap;
}

/* --- Categories --- */

.jm-fin-category-row {
  display: flex;
  align-items: center;
  gap: var(--jm-space-3);
}

.jm-fin-category-label-input {
  flex: 1;
  min-width: 120px;
}

@media (max-width: 900px) {
  /* Finance's header has 3 real action buttons (Refresh/New Expense/
     New Invoice) vs. the 1-2 every prior workspace header had - the
     shared .jm-dash-header-actions row has no flex-wrap, so it
     overflows at mobile widths with a 3rd button. Scoped to Finance
     only via this additional class - dashboard.css and every other
     workspace's header are untouched. */
  .jm-fin-header-actions {
    flex-wrap: wrap;
    row-gap: var(--jm-space-2);
  }
  .jm-fin-table-wrap {
    display: none;
  }
  .jm-fin-cards {
    display: flex;
  }
  .jm-fin-toolbar {
    flex-direction: column;
    align-items: stretch;
  }
  .jm-fin-search,
  .jm-fin-filter {
    max-width: none;
  }
  .jm-dash-header-actions .jm-btn {
    height: var(--jm-touch-target);
    padding: 0 var(--jm-space-4);
  }
  .jm-fin-status-select {
    height: var(--jm-touch-target);
  }
  .jm-fin-row-actions .jm-btn {
    height: var(--jm-touch-target);
  }
  .jm-fin-proposal-row {
    flex-direction: column;
    align-items: stretch;
  }
}
