/* Calm tables: hairline rows, no zebra, pinned first column, quiet zeros, right-aligned numbers. */

.table-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-tile); overflow: hidden; }
[data-theme='light'] .table-card { border-top: var(--rule-weight) solid var(--rule); border-radius: 0 0 var(--radius-tile) var(--radius-tile); }
.table-scroll { overflow-x: auto; max-width: 100%; }
table.calm { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13.5px; }
table.calm th, table.calm td { height: var(--row-h); padding: 0 14px; border-bottom: 1px solid var(--border); text-align: left; white-space: nowrap; vertical-align: middle; }
table.calm th { height: 40px; font-weight: 500; font-size: 12px; color: var(--muted); background: var(--surface); position: sticky; top: 0; z-index: 2; user-select: none; }
table.calm th.sortable { cursor: pointer; }
table.calm th.sortable:hover { color: var(--text); }
table.calm th .sort-mark { display: inline-block; width: 10px; margin-left: 4px; color: var(--text); }
table.calm tbody tr { transition: background var(--t-fast) var(--ease); }
table.calm tbody tr:hover td { background: var(--hover); }
table.calm tbody tr.is-click { cursor: pointer; }
table.calm tbody tr:last-child td { border-bottom: 0; }
table.calm td.num, table.calm th.num { text-align: right; }
table.calm td.wrap { white-space: normal; min-width: 220px; max-width: 420px; }
table.calm td.actions { text-align: right; width: 1%; }

/* Pinned first column so the name stays put while numbers scroll. */
table.calm .pin { position: sticky; left: 0; z-index: 1; background: var(--surface); box-shadow: 1px 0 0 var(--border); }
table.calm th.pin { z-index: 3; }
table.calm tbody tr:hover td.pin { background: var(--surface-2); }

/* Row tints: only when the row needs attention. */
table.calm tr.is-danger td { background: var(--danger-soft); }
table.calm tr.is-warn td { background: var(--warn-soft); }
/* Pinned cells must be opaque, so the same tint is laid over the card colour. */
table.calm tr.is-danger td.pin { background: linear-gradient(var(--danger-soft), var(--danger-soft)), var(--surface); }
table.calm tr.is-warn td.pin { background: linear-gradient(var(--warn-soft), var(--warn-soft)), var(--surface); }
table.calm tr.is-muted td { color: var(--faint); }

/* Totals strip under the table */
.totals { display: flex; gap: 28px; flex-wrap: wrap; padding: 12px 14px; border-top: 1px solid var(--border-strong); background: var(--surface-2); font-size: 13px; }
.totals b { font-family: var(--font-num); font-variant-numeric: tabular-nums; font-weight: 500; margin-left: 6px; }

.empty { padding: 40px 16px; text-align: center; color: var(--muted); }
.empty strong { display: block; color: var(--text); font-weight: 500; margin-bottom: 4px; }

/* Name cell: name on top, small code below */
.who-cell { display: flex; flex-direction: column; line-height: 1.25; }
.who-cell small { color: var(--faint); font-size: 11.5px; font-family: var(--font-num); }

/* Copyable ID */
.copy { border: 0; background: transparent; padding: 2px 4px; margin: -2px -4px; border-radius: 4px; font-family: var(--font-num); font-size: 12px; color: var(--muted); cursor: copy; }
.copy:hover { background: var(--hover); color: var(--text); }

/* Small status words: text with a dot, not filled pills, except where action is needed. */
.state { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; }
.state::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--faint); }
.state.ok::before { background: var(--ok); }
.state.warn { color: var(--warn); }
.state.warn::before { background: var(--warn); }
.state.danger { color: var(--danger); }
.state.danger::before { background: var(--danger); }
.state.accent::before { background: var(--accent); }

.tag { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 99px; font-size: 11.5px; background: var(--selected); color: var(--muted); }
.tag.warn { background: var(--warn-soft); color: var(--warn-ink); }
.tag.danger { background: var(--danger-soft); color: var(--danger-ink); }
.tag.accent { background: var(--accent-soft); color: var(--text); }

.brand-dot { display: inline-flex; align-items: center; gap: 7px; }
.brand-dot::before { content: ''; width: 7px; height: 7px; border-radius: 2px; background: var(--faint); }
.brand-dot.b-RAM::before { background: var(--brand-RAM); }
.brand-dot.b-YGBET::before { background: var(--brand-YGBET); }
.brand-dot.b-ACE::before { background: var(--brand-ACE); }
.brand-dot.b-BETON::before { background: var(--brand-BETON); }
.brand-dot.b-REI::before { background: var(--brand-REI); }
.brand-dot.b-HQ::before { background: var(--brand-HQ); }

.money-neg { color: var(--danger); }

/* Loading skeleton rows */
.skeleton { height: 12px; border-radius: 4px; background: linear-gradient(90deg, var(--selected), var(--hover), var(--selected)); background-size: 200% 100%; animation: shimmer 1.2s linear infinite; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .skeleton { animation: none; } }

/* Phones: rows become cards. Name first, then "label  value" lines, buttons at the bottom. */
@media (max-width: 760px) {
  table.calm.is-cards, table.calm.is-cards tbody, table.calm.is-cards tr, table.calm.is-cards td { display: block; }
  table.calm.is-cards thead { display: none; }
  table.calm.is-cards tbody tr { padding: 12px 14px; border-bottom: 1px solid var(--border); }
  table.calm.is-cards tbody tr:last-child { border-bottom: 0; }
  table.calm.is-cards td { height: auto; padding: 3px 0; border: 0; white-space: normal; display: flex; align-items: baseline; justify-content: space-between; gap: 14px; text-align: right; min-width: 0; max-width: none; }
  table.calm.is-cards td:empty { display: none; }
  table.calm.is-cards td[data-label]::before { content: attr(data-label); color: var(--muted); font-size: 12.5px; text-align: left; flex: none; max-width: 45%; }
  table.calm.is-cards td.pin { position: static; box-shadow: none; background: transparent; text-align: left; font-size: 15px; padding-bottom: 6px; justify-content: flex-start; }
  table.calm.is-cards td.actions { width: auto; justify-content: flex-end; padding-top: 10px; }
  table.calm.is-cards td.actions .btn-group { flex-wrap: wrap; justify-content: flex-end; }
  table.calm.is-cards tbody tr:hover td, table.calm.is-cards tbody tr:hover td.pin { background: transparent; }
  table.calm.is-cards tr.is-danger, table.calm.is-cards tr.is-warn { border-left: 3px solid var(--warn); }
  table.calm.is-cards tr.is-danger { border-left-color: var(--danger); background: var(--danger-soft); }
  table.calm.is-cards tr.is-warn { background: var(--warn-soft); }
  table.calm.is-cards tr.is-danger td, table.calm.is-cards tr.is-warn td, table.calm.is-cards tr.is-danger td.pin, table.calm.is-cards tr.is-warn td.pin { background: transparent; }
  table.calm.is-cards td .empty { width: 100%; }
  .totals { gap: 8px 20px; }
  .kv { grid-template-columns: 110px minmax(0, 1fr); }
}

/* Key-value list for detail drawers */
.kv { display: grid; grid-template-columns: 140px minmax(0, 1fr); gap: 8px 16px; font-size: 13.5px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
