/* Components: glass cards, tables, badges, metrics, forms, dialogs and toasts. */

/* ---------- glass surfaces ---------- */

.glass {
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.13) 0%, rgba(255, 255, 255, 0.05) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(22px) saturate(160%);
  -webkit-backdrop-filter: blur(22px) saturate(160%);
  box-shadow: var(--shadow-card);
}

.card { padding: 22px; display: flex; flex-direction: column; gap: var(--s-4); min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); flex-wrap: wrap; }
.card-head .sub { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.card-actions { display: flex; gap: var(--s-2); flex-wrap: wrap; }

/* ---------- badges ---------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 650;
  color: var(--muted);
  background: var(--glass-1);
  border: 1px solid var(--border);
  white-space: nowrap;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.ok { color: #9ff5d3; border-color: rgba(52, 211, 153, 0.4); background: rgba(52, 211, 153, 0.12); }
.badge.warn { color: #fde7a0; border-color: rgba(251, 191, 36, 0.4); background: rgba(251, 191, 36, 0.12); }
.badge.bad { color: #ffc4cd; border-color: rgba(251, 113, 133, 0.45); background: rgba(251, 113, 133, 0.12); }
.badge.info { color: #c9ceff; border-color: rgba(124, 131, 255, 0.45); background: rgba(124, 131, 255, 0.14); }
.badge.violet { color: #ecd3ff; border-color: rgba(192, 132, 252, 0.45); background: rgba(192, 132, 252, 0.14); }

.chip-list { display: flex; flex-wrap: wrap; gap: var(--s-2); align-items: center; }
.chip-list .btn.ghost { padding: 0 4px; }

/* ---------- metrics ---------- */

.metrics { display: grid; gap: var(--s-3); grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.metric {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 16px 18px;
  min-width: 0;
  border-radius: var(--radius-md);
  background: rgba(6, 9, 24, 0.35);
  border: 1px solid var(--border);
}
.metric { position: relative; overflow: hidden; }
.metric::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 3px; background: var(--grad-accent); }
.metrics > .metric:nth-child(4n+2)::before { background: linear-gradient(180deg, #34d399, #22d3ee); }
.metrics > .metric:nth-child(4n+3)::before { background: linear-gradient(180deg, #c084fc, #7c83ff); }
.metrics > .metric:nth-child(4n+4)::before { background: linear-gradient(180deg, #fbbf24, #fb7185); }
.metric .label { color: var(--faint); font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.08em; }
.metric .value { color: var(--text-strong); font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.metric .hint { color: var(--muted); font-size: 12px; }

/* ---------- key/value ---------- */

.kv { display: grid; grid-template-columns: 150px 1fr; gap: 8px 14px; margin: 0; font-size: 13px; }
.kv dt { color: var(--faint); }
.kv dd { margin: 0; color: var(--text); word-break: break-word; }

/* ---------- tables ---------- */

.table-wrap {
  overflow: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: rgba(6, 9, 24, 0.28);
}
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 11px 14px; border-bottom: 1px solid rgba(255, 255, 255, 0.07); vertical-align: middle; }
th {
  position: sticky;
  top: 0;
  color: var(--faint);
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 650;
  background: rgba(255, 255, 255, 0.03);
}
tr:last-child td { border-bottom: none; }
tbody tr { transition: background 0.12s ease; }
tbody tr.clickable { cursor: pointer; }
tbody tr:hover { background: rgba(124, 131, 255, 0.1); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.empty-state { color: var(--faint); padding: 26px; text-align: center; }
.cell-title { font-weight: 600; color: var(--text-strong); }
.cell-sub { color: var(--faint); font-size: 12px; }
.cell-muted { color: var(--muted); }
.amount-debit { color: #ffc4cd; }
.amount-credit { color: #9ff5d3; }

.sources { display: flex; flex-direction: column; gap: 2px; color: var(--muted); font-size: 12px; }

/* ---------- forms ---------- */

.form { display: grid; gap: var(--s-4); grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); align-items: end; margin: 0; }
.form-stack { display: flex; flex-direction: column; gap: var(--s-4); }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > span { color: var(--muted); font-size: 12px; font-weight: 550; }
.field.span-full, .span-full { grid-column: 1 / -1; }
.form-error { min-height: 0; color: #ffb4bf; font-size: 13px; grid-column: 1 / -1; }
.form-actions { grid-column: 1 / -1; display: flex; justify-content: flex-end; gap: var(--s-2); align-items: center; }
.form-inline { display: flex; gap: var(--s-2); align-items: flex-end; flex-wrap: wrap; }
.form-inline .field { flex: 1 1 200px; }
.row-card { padding: var(--s-4); }
.check-list { display: flex; flex-wrap: wrap; gap: var(--s-2) var(--s-4); }
.check-item { display: inline-flex; align-items: center; gap: 6px; color: var(--text); font-size: 13px; cursor: pointer; }

/* ---------- dialog ---------- */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(3, 6, 18, 0.55);
  backdrop-filter: blur(6px);
  animation: fade 0.15s ease;
}
.dialog {
  width: min(640px, 100%);
  max-height: calc(100vh - 36px);
  overflow: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: var(--s-4);
  animation: rise 0.2s ease;
}
.dialog.wide { width: min(880px, 100%); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); }

/* ---------- toasts ---------- */

.toasts { position: fixed; right: 18px; bottom: 18px; z-index: 60; display: flex; flex-direction: column; gap: var(--s-2); }
.toast {
  min-width: 240px;
  max-width: 380px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  font-weight: 550;
  animation: rise 0.2s ease;
}
.toast.ok { background: rgba(16, 61, 49, 0.9); color: #c6f8e2; border-color: rgba(52, 211, 153, 0.5); }
.toast.err { background: rgba(76, 18, 36, 0.92); color: #ffd6dd; border-color: rgba(251, 113, 133, 0.55); }

/* ---------- page states ---------- */

.loading { color: var(--muted); padding: 30px; text-align: center; }

@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
