/* Finovas Global - components */

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 17px; border-radius: var(--r-sm);
  font-weight: 600; font-size: 13.5px; border: 1px solid transparent;
  cursor: pointer; white-space: nowrap; transition: .16s var(--ease);
}
.btn:active { transform: translateY(1px) scale(.99); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn svg { width: 17px; height: 17px; }
.btn-primary { background: var(--gradient); color: #fff;
  box-shadow: 0 4px 14px rgba(99,102,241,.34); }
.btn-primary:hover:not(:disabled) { box-shadow: 0 7px 22px rgba(99,102,241,.46);
  transform: translateY(-1px); }
.btn-ghost { background: var(--surface); border-color: var(--border); color: var(--text); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2);
  border-color: var(--border-strong); }
.btn-soft { background: var(--surface-2); color: var(--text); }
.btn-soft:hover:not(:disabled) { background: var(--surface-3); }
.btn-danger { background: var(--neg); color: #fff; }
.btn-danger:hover:not(:disabled) { filter: brightness(1.07); }
.btn-sm { height: 33px; padding: 0 12px; font-size: 12.5px; border-radius: var(--r-xs); }
.btn-icon { width: 40px; padding: 0; }
.btn-icon.btn-sm { width: 33px; }
.btn-block { width: 100%; }

/* ── Card ────────────────────────────────────────────────── */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r); box-shadow: var(--shadow-sm);
}
.card-pad { padding: 20px; }
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.card-head h2 { font-size: 15px; }
.card-head .sub { font-size: 12.5px; color: var(--text-muted); font-weight: 500; }

/* ── Stat tile ───────────────────────────────────────────── */
.stat {
  position: relative; overflow: hidden; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--r);
  padding: 18px 20px; box-shadow: var(--shadow-sm);
  transition: border-color .2s, transform .2s, box-shadow .2s;
}
.stat:hover {
  border-color: color-mix(in srgb, var(--brand) 30%, var(--border));
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}
.stat::after {
  content: ""; position: absolute; inset: 0 0 auto auto;
  width: 96px; height: 96px; border-radius: 50%;
  background: var(--gradient-soft, var(--gradient)); opacity: .14;
  transform: translate(34px, -34px);
}
.stat-label { font-size: 12px; font-weight: 600; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .04em; }
.stat-value { font-size: 27px; font-weight: 800; margin-top: 7px;
  letter-spacing: -.02em; }
.stat-foot { font-size: 12.5px; color: var(--text-soft); margin-top: 4px; }
.stat-icon {
  position: absolute; top: 16px; right: 16px; width: 38px; height: 38px;
  display: grid; place-items: center; border-radius: 11px;
  background: var(--gradient); color: #fff;
  box-shadow:
    0 6px 14px -4px color-mix(in srgb, var(--brand) 45%, transparent),
    inset 0 1px 0 rgba(255, 255, 255, .15);
}
.stat-icon svg { width: 20px; height: 20px; }

/* Darker, glassier feel in dark mode for stat tiles */
[data-theme="dark"] .stat {
  background: linear-gradient(150deg,
    color-mix(in srgb, var(--brand) 4%, var(--surface)),
    var(--surface));
  border-color: color-mix(in srgb, var(--brand) 14%, var(--border));
}
[data-theme="dark"] .stat::after {
  opacity: .22;
}
[data-theme="dark"] .stat-icon {
  background: linear-gradient(135deg,
    color-mix(in srgb, var(--brand) 80%, transparent),
    color-mix(in srgb, var(--brand-2) 70%, transparent));
  box-shadow:
    0 8px 22px -4px color-mix(in srgb, var(--brand) 60%, transparent),
    inset 0 1px 0 rgba(255, 255, 255, .25);
}

/* All tiles share the brand indigo icon for a cohesive look.  Income / expense
   tiles colour only their NUMBER (green / red) so the semantics still read at
   a glance without making the tile chrome itself feel patchwork. */
.stat-v-pos .stat-value { color: var(--pos); }
.stat-v-neg .stat-value { color: var(--neg); }

/* ── Avatar with logo image fallback ─────────────────────────────────────
   Every place that shows a client avatar (workspace header, topbar switcher,
   command palette, switch dropdown, client card) uses .has-logo-slot.  The
   <img> takes the slot when loaded; the <span class="avatar-mono"> with the
   client's initials serves as the placeholder until the image loads and the
   permanent fallback if the image is missing. */
.avatar.has-logo-slot {
  position: relative;
  overflow: hidden;
}
.avatar.has-logo-slot .avatar-logo {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  z-index: 1;
}
.avatar.has-logo-slot .avatar-mono {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  font-weight: 700;
  color: #fff;
  z-index: 0;
}
.avatar.has-logo-slot.has-logo .avatar-mono {
  display: none;
}

/* ── Chips & badges ──────────────────────────────────────── */
.chip {
  display: inline-flex; align-items: center; gap: 5px; height: 23px;
  padding: 0 9px; border-radius: 99px; font-size: 11.5px; font-weight: 600;
  background: var(--surface-2); color: var(--text-muted);
}
.chip .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.chip-pos { background: var(--pos-bg); color: var(--pos); }
.chip-neg { background: var(--neg-bg); color: var(--neg); }
.chip-warn { background: var(--warn-bg); color: var(--warn); }
.chip-info { background: var(--info-bg); color: var(--info); }
.chip-brand { background: rgba(99,102,241,.13); color: var(--brand); }

.badge { font-size: 11px; font-weight: 700; padding: 2px 8px;
  border-radius: 99px; background: var(--gradient); color: #fff; }

/* ── Fields ──────────────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12.5px; font-weight: 600; color: var(--text-muted); }
.input, .select, textarea.input {
  height: 40px; padding: 0 13px; background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: var(--r-sm);
  font-size: 14px; width: 100%; transition: .15s var(--ease);
}
textarea.input { height: auto; padding: 10px 13px; resize: vertical; line-height: 1.6; }
.input:focus, .select:focus, textarea.input:focus {
  border-color: var(--brand); box-shadow: var(--ring); }
.input::placeholder { color: var(--text-soft); }
.select { appearance: none; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b7197' stroke-width='2.5' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
  padding-right: 34px; }
.switch { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; }
.switch input { display: none; }
.switch .track { width: 40px; height: 23px; border-radius: 99px;
  background: var(--surface-3); transition: .18s var(--ease); position: relative; }
.switch .track::after { content: ""; position: absolute; top: 2px; left: 2px;
  width: 19px; height: 19px; border-radius: 50%; background: #fff;
  box-shadow: var(--shadow-sm); transition: .18s var(--ease); }
.switch input:checked + .track { background: var(--brand); }
.switch input:checked + .track::after { transform: translateX(17px); }

/* ── Segmented control ───────────────────────────────────── */
.segmented {
  display: inline-flex; padding: 3px; gap: 2px;
  background: var(--surface-2); border-radius: var(--r-sm);
  border: 1px solid var(--border);
}
.segmented button {
  border: 0; background: transparent; padding: 5px 12px; border-radius: 7px;
  font-size: 12.5px; font-weight: 600; color: var(--text-muted);
  transition: .14s var(--ease);
}
.segmented button.on { background: var(--surface); color: var(--text);
  box-shadow: var(--shadow-sm); }

/* ── Table ───────────────────────────────────────────────── */
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table thead th {
  position: sticky; top: 0; background: var(--surface); z-index: 1;
  text-align: left; font-size: 11.5px; font-weight: 700; letter-spacing: .03em;
  text-transform: uppercase; color: var(--text-soft);
  padding: 11px 14px; border-bottom: 1px solid var(--border);
}
.table tbody td { padding: 12px 14px; border-bottom: 1px solid var(--border); }
.table tbody tr { transition: background .12s var(--ease); }
.table tbody tr:hover { background: var(--surface-2); }
.table tbody tr:last-child td { border-bottom: 0; }
.table .right { text-align: right; }
.table .clickable { cursor: pointer; }

/* ── Tabs ────────────────────────────────────────────────── */
.tabs { display: flex; gap: 3px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  border: 0; background: transparent; padding: 10px 14px; border-radius: var(--r-sm);
  font-size: 13.5px; font-weight: 600; color: var(--text-muted);
  white-space: nowrap; transition: .14s var(--ease); display: inline-flex;
  align-items: center; gap: 7px;
}
.tab svg { width: 16px; height: 16px; }
.tab:hover { color: var(--text); background: var(--surface-2); }
.tab.on { color: var(--brand); background: rgba(99,102,241,.11); }

/* ── Modal ───────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(14,16,34,.5);
  backdrop-filter: blur(3px); display: grid; place-items: center;
  z-index: 80; padding: 24px; animation: fvFade .16s var(--ease);
}
.modal {
  background: var(--surface); border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg); width: 100%; max-width: 520px;
  max-height: 90vh; overflow: auto; animation: fvPop .2s var(--ease);
  border: 1px solid var(--border);
}
.modal.wide { max-width: 760px; }
.modal-head { display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px; border-bottom: 1px solid var(--border); }
.modal-head h2 { font-size: 16px; }
.modal-body { padding: 22px; display: flex; flex-direction: column; gap: 15px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px;
  padding: 16px 22px; border-top: 1px solid var(--border); }

/* ── Toast ───────────────────────────────────────────────── */
#toast-root {
  position: fixed; bottom: 24px; right: 24px; z-index: 120;
  display: flex; flex-direction: column; gap: 10px;
}
.toast {
  display: flex; align-items: center; gap: 10px; padding: 12px 16px;
  background: var(--surface); border: 1px solid var(--border);
  border-left: 3px solid var(--brand); border-radius: var(--r-sm);
  box-shadow: var(--shadow-pop); font-size: 13.5px; font-weight: 600;
  min-width: 240px; animation: fvFadeUp .22s var(--ease);
}
.toast.ok { border-left-color: var(--pos); }
.toast.err { border-left-color: var(--neg); }
.toast svg { width: 18px; height: 18px; }

/* ── Dropzone ────────────────────────────────────────────── */
.dropzone {
  border: 2px dashed var(--border-strong); border-radius: var(--r-lg);
  padding: 34px 24px; text-align: center; cursor: pointer;
  transition: .16s var(--ease); background: var(--surface-2);
}
.dropzone:hover, .dropzone.over {
  border-color: var(--brand); background: rgba(99,102,241,.07);
}
.dropzone .dz-icon {
  width: 52px; height: 52px; margin: 0 auto 12px; border-radius: 15px;
  background: var(--gradient); display: grid; place-items: center; color: #fff;
}
.dropzone .dz-icon svg { width: 26px; height: 26px; }

/* ── Skeleton & empty ────────────────────────────────────── */
.skeleton {
  position: relative; overflow: hidden; background: var(--surface-2);
  border-radius: var(--r-sm);
}
.skeleton::after {
  content: ""; position: absolute; inset: 0; transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.45), transparent);
  animation: fvShimmer 1.3s infinite;
}
[data-theme="dark"] .skeleton::after {
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.07), transparent);
}
.empty {
  text-align: center; padding: 48px 24px; color: var(--text-muted);
}
.empty .e-icon {
  width: 60px; height: 60px; margin: 0 auto 14px; border-radius: 18px;
  background: var(--surface-2); display: grid; place-items: center;
  color: var(--text-soft);
}
.empty .e-icon svg { width: 28px; height: 28px; }
.empty h3 { color: var(--text); margin-bottom: 4px; }

/* ── Misc ────────────────────────────────────────────────── */
.spinner {
  width: 18px; height: 18px; border: 2.5px solid var(--surface-3);
  border-top-color: var(--brand); border-radius: 50%;
  animation: fvSpin .7s linear infinite;
}
.progress { height: 6px; background: var(--surface-3); border-radius: 99px;
  overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--gradient);
  border-radius: 99px; transition: width .3s var(--ease); }
.divider { height: 1px; background: var(--border); }
.avatar {
  width: 38px; height: 38px; border-radius: 11px; display: grid;
  place-items: center; font-weight: 700; color: #fff; flex: none;
  background: var(--gradient); font-size: 15px;
}
.muted { color: var(--text-muted); }
.tip { font-size: 12px; color: var(--text-soft); }
