/* ============================================================
   Reusable components — Spike-inspired light admin panel
   ============================================================ */

/* ---------- Buttons: solid, rounded, no uppercase ---------- */
.btn{
  display:inline-flex;align-items:center;gap:8px;justify-content:center;
  border:1px solid var(--border-strong); background:var(--surface); color:var(--text);
  border-radius:var(--radius-md); padding:10px 16px; font-weight:600; font-size:13px;
  letter-spacing:0; box-shadow:var(--shadow-xs);
  transition:background-color .14s var(--ease), border-color .14s var(--ease), color .14s var(--ease), box-shadow .14s var(--ease), transform .1s var(--ease);
}
.btn .icon{width:14px;height:14px}
.btn:hover{border-color:var(--text-faint);box-shadow:var(--shadow-sm)}
.btn:active{transform:translateY(1px);box-shadow:var(--shadow-xs)}
.btn.primary{
  background:var(--accent); border-color:var(--accent); color:var(--accent-contrast);
  box-shadow:var(--glow-accent);
}
.btn.primary:hover{background:color-mix(in srgb, var(--accent) 88%, black);box-shadow:var(--glow-accent), var(--shadow-sm)}
.btn.primary:active{box-shadow:var(--shadow-xs)}
.btn.ghost{background:transparent;border-color:transparent;box-shadow:none;color:var(--text-dim)}
.btn.ghost:hover{color:var(--text);background:var(--surface-2);border-color:transparent;box-shadow:none}
.btn.danger{background:transparent;border-color:var(--neg);box-shadow:none;color:var(--neg)}
.btn.danger:hover{background:var(--neg-bg)}
.btn.sm{padding:7px 12px;font-size:12px}
.btn.block{width:100%}
.btn[disabled]{opacity:.4;pointer-events:none}

/* Quiet text-link action (row-level edit/delete) — no border, no box */
.link-action{
  display:inline-flex;align-items:center;gap:5px;color:var(--text-faint);font-size:12px;
  font-weight:600;letter-spacing:0;text-transform:none;border:0;background:transparent;
  transition:color .14s var(--ease);
}
.link-action:hover{color:var(--accent)}
.link-action.danger:hover{color:var(--neg)}
.link-action .icon{width:12px;height:12px}

/* ---------- Page header ---------- */
.page-head{
  display:flex;justify-content:space-between;align-items:flex-end;gap:20px;
  margin-bottom:28px;
}
.page-head h2{font-size:26px;font-weight:700;letter-spacing:-.01em}
.page-head .sub{color:var(--text-faint);margin-top:6px;font-size:13px}
.page-head .actions{display:flex;gap:10px}
.eyebrow{font-size:11px;letter-spacing:.08em;text-transform:uppercase;color:var(--accent);font-weight:700;margin-bottom:6px;display:block}

.grid{display:grid;gap:20px}
.grid.stats{grid-template-columns:repeat(4,minmax(0,1fr));margin-bottom:0}
.grid.two{grid-template-columns:1.55fr 1fr;gap:20px}
.grid.split{grid-template-columns:1fr 1fr;gap:20px}
.grid.cards{grid-template-columns:repeat(auto-fill,minmax(280px,1fr));gap:20px}

/* ---------- Section: plain content wrapper ---------- */
.section{margin-bottom:8px}
.section h3{font-size:15px;font-weight:700;letter-spacing:0}
.section .section-sub{color:var(--text-faint);font-size:12px;margin-bottom:16px}

/* ---------- Card ---------- */
.card{
  background:var(--surface);
  border:1px solid var(--border); border-radius:var(--radius-xl);
  box-shadow:var(--shadow-sm); padding:24px;
  transition:box-shadow .18s var(--ease), border-color .18s var(--ease);
}
.card h3{font-size:15px;margin-bottom:4px;font-weight:700}
.card .card-sub{color:var(--text-faint);font-size:12px;margin-bottom:16px}

/* ---------- Hero/welcome card: plain surface, not a colored banner —
   the reference keeps this card neutral; only the KPI cards carry color ---------- */
.hero-card{
  background:var(--surface); border:1px solid var(--border);
  border-radius:var(--radius-xl); padding:26px 30px; margin-bottom:24px;
  display:flex; align-items:center; justify-content:space-between; gap:24px; flex-wrap:wrap;
  box-shadow:var(--shadow-sm);
}
.hero-card h2{font-size:24px}
.hero-card p{color:var(--text-faint);margin-top:6px;font-size:13px}

/* ---------- KPI stat cards: all share the single accent (matches the
   reference exactly — Sales/Refunds/Earnings are the same blue, never
   a different loud hue per card). Variety comes only from the small
   decorative corner blob, not the card itself. ---------- */
.ledger-strip{
  display:grid; grid-template-columns:repeat(4,1fr); gap:20px;
  margin-bottom:28px;
}
.metric{
  border:0; border-radius:var(--radius-xl); color:#fff; overflow:hidden;
  background-color:var(--accent);
  background-image:radial-gradient(160px 160px at 105% -25%, rgba(255,255,255,.18), transparent 70%);
  box-shadow:0 10px 24px color-mix(in srgb, var(--accent) 35%, transparent);
  padding:22px; position:relative; padding-right:70px;
  transition:transform .16s var(--ease), box-shadow .16s var(--ease);
}
.metric:hover{transform:translateY(-2px);box-shadow:0 16px 32px color-mix(in srgb, var(--accent) 45%, transparent)}
.metric-label{font-size:12px;color:rgba(255,255,255,.82);font-weight:600;display:block;margin-bottom:10px}
.metric-value{font-family:var(--font-display);font-size:26px;font-weight:700;letter-spacing:-.01em;font-variant-numeric:tabular-nums;line-height:1.1;color:#fff}
.metric-delta{font-size:12px;font-weight:600;margin-top:10px;display:flex;align-items:center;gap:6px;color:rgba(255,255,255,.82)}
.metric-delta.pos,.metric-delta.neg{color:#fff}
.metric-delta .icon{width:11px;height:11px}

/* Small decorative blob, cycling through the muted jewel palette — the
   only place per-card color variety shows up */
.metric::before{
  content:""; position:absolute; top:-16px; right:-16px; width:80px; height:80px;
  border-radius:50%; background:rgba(255,255,255,.14);
}
.metric:nth-child(4n+2)::before{background:color-mix(in srgb, var(--stat-3) 55%, white 15%)}
.metric:nth-child(4n+3)::before{background:color-mix(in srgb, var(--stat-5) 55%, white 15%)}
.metric:nth-child(4n+4)::before{background:color-mix(in srgb, var(--stat-2) 55%, white 15%)}
.metric::after{
  content:"—"; position:absolute; top:22px; right:22px; width:44px; height:44px;
  border-radius:50%; background:rgba(255,255,255,.22);
  display:flex; align-items:center; justify-content:center; color:#fff; font-size:17px; font-weight:700;
}
.metric:nth-child(4n+1)::after{content:"↑"}
.metric:nth-child(4n+2)::after{content:"↓"}
.metric:nth-child(4n+3)::after{content:"$"}
.metric:nth-child(4n+4)::after{content:"%"}


@media(max-width:900px){
  .ledger-strip{grid-template-columns:1fr 1fr}
}
@media(max-width:520px){
  .ledger-strip{grid-template-columns:1fr}
}

/* ---------- Tables ---------- */
.table-wrap{overflow-x:auto;background:var(--surface);border:1px solid var(--border);border-radius:var(--radius-xl);box-shadow:var(--shadow-sm)}
.table{width:100%;border-collapse:collapse;font-size:13px}
.table thead th{
  text-align:left;font-size:11px;text-transform:uppercase;letter-spacing:.06em;color:var(--text-faint);
  font-weight:700;padding:14px 16px;background:var(--surface-2);white-space:nowrap;
}
.table thead th:first-child{border-top-left-radius:var(--radius-xl)}
.table thead th:last-child{border-top-right-radius:var(--radius-xl)}
.table tbody tr{transition:background-color .12s var(--ease)}
.table tbody tr:hover{background:var(--surface-2)}
.table tbody td{padding:14px 16px;border-bottom:1px solid var(--border);vertical-align:top}
.table tbody tr:last-child td{border-bottom:0}
.table .amount{font-family:var(--font-mono);font-weight:600;text-align:right;white-space:nowrap}
.table .amount.pos{color:var(--pos)}
.table .amount.neg{color:var(--neg)}
.table td.tright{text-align:right}
.cell-title{font-weight:600;color:var(--text)}
.cell-sub{color:var(--text-faint);font-size:11.5px;margin-top:2px}

/* ---------- Status: filled pill ---------- */
.status{display:inline-flex;align-items:center;gap:6px;font-size:11.5px;font-weight:700;white-space:nowrap;padding:4px 10px 4px 8px;border-radius:99px;background:var(--surface-3);color:var(--text-dim)}
.status-dot{width:6px;height:6px;border-radius:50%;flex:none;background:var(--text-faint)}
.status.pos{background:var(--pos-bg);color:var(--pos)} .status.pos .status-dot{background:var(--pos)}
.status.neg{background:var(--neg-bg);color:var(--neg)} .status.neg .status-dot{background:var(--neg)}
.status.gold{background:var(--accent-soft);color:var(--accent)} .status.gold .status-dot{background:var(--accent)}

/* Small categorical tag (Empresa/Pessoal, Entrada/Despesa) — filled pill */
.tag{
  display:inline-flex;align-items:center;font-size:11px;font-weight:700;letter-spacing:.01em;
  color:var(--text-dim); background:var(--surface-3); border-radius:99px; padding:4px 10px;
}
.tag.pos{color:var(--pos);background:var(--pos-bg)}
.tag.neg{color:var(--neg);background:var(--neg-bg)}
.tag.gold{color:var(--accent);background:var(--accent-soft)}

/* ---------- Forms ---------- */
.field{margin-bottom:0}
.field label{display:block;font-size:12px;font-weight:600;color:var(--text-dim);margin-bottom:8px}
.field input,.field select,.field textarea{
  width:100%;background:var(--surface-2);border:1px solid transparent;color:var(--text);
  border-radius:var(--radius-md);padding:11px 12px;outline:none;font-size:13.5px;
  transition:border-color .15s, background-color .15s;
}
.field input:focus,.field select:focus,.field textarea:focus{border-color:var(--accent);background:var(--surface)}
.field textarea{min-height:80px;resize:vertical}
.field .hint{font-size:11px;color:var(--text-faint);margin-top:7px}
.formgrid{display:grid;grid-template-columns:1fr 1fr;gap:18px 20px}
.formgrid .span2{grid-column:1/-1}

/* ---------- Progress: rounded track ---------- */
.progress{height:6px;background:var(--surface-3);border-radius:99px;position:relative;overflow:hidden}
.progress > div{height:100%;background:var(--accent);border-radius:99px;transition:width .5s var(--ease)}
.progress.danger > div{background:var(--neg)}

/* ---------- Empty state ---------- */
.empty{text-align:center;padding:48px 24px;color:var(--text-faint)}
.empty .icon{width:26px;height:26px;margin-bottom:12px;opacity:.4}
.empty p{font-size:13px}

/* ---------- Row list (recurring/entities) ---------- */
.row-list{display:flex;flex-direction:column}
.list-row{display:flex;justify-content:space-between;gap:14px;padding:14px;margin:0 -6px;border-radius:var(--radius-md);transition:background-color .12s var(--ease)}
.list-row:hover{background:var(--surface-2)}
.list-row .r-title{font-weight:600;font-size:13.5px}
.list-row .r-sub{color:var(--text-faint);font-size:11.5px;margin-top:4px}
.list-row .r-right{text-align:right;flex:none}
.list-row .r-amount{font-family:var(--font-mono);font-weight:700}

/* Entity row (category/client/recurring/user) — icon sits in a colored circle */
.entity-row{display:flex;align-items:center;gap:14px;padding:12px;margin:0 -6px;border-radius:var(--radius-md);transition:background-color .12s var(--ease)}
.entity-row:hover{background:var(--surface-2)}
.entity-glyph{
  font-size:16px;flex:none;width:38px;height:38px;border-radius:50%;
  display:flex;align-items:center;justify-content:center;background:var(--stat-1);color:#fff;
}
.entity-row:nth-child(5n+1) .entity-glyph{background:var(--stat-1)}
.entity-row:nth-child(5n+2) .entity-glyph{background:var(--stat-2)}
.entity-row:nth-child(5n+3) .entity-glyph{background:var(--stat-3)}
.entity-row:nth-child(5n+4) .entity-glyph{background:var(--stat-4)}
.entity-row:nth-child(5n+5) .entity-glyph{background:var(--stat-5)}
.entity-info{flex:1;min-width:0}
.entity-info b{display:block;font-size:14px;font-weight:600}
.entity-info .muted{font-size:11.5px;display:block;margin-top:3px;color:var(--text-faint)}
.entity-actions{display:flex;gap:14px;flex:none;align-items:center}

.subhead{font-size:11px;letter-spacing:.06em;text-transform:uppercase;color:var(--text-faint);font-weight:700;margin:28px 0 12px}
.subhead:first-of-type{margin-top:0}

/* ---------- Modal ---------- */
.modal-scrim{position:fixed;inset:0;background:var(--scrim);backdrop-filter:blur(3px);display:none;place-items:center;z-index:60;padding:20px}
.modal-scrim.open{display:grid;animation:scrimIn .2s var(--ease)}
@keyframes scrimIn{from{opacity:0}to{opacity:1}}
.modal{
  background:var(--surface);border:1px solid var(--border);border-radius:var(--radius-xl);
  padding:30px;max-width:620px;width:100%;box-shadow:var(--shadow-lg);max-height:88vh;overflow:auto;
  animation:modalIn .24s var(--ease-snap);
}
@keyframes modalIn{from{opacity:0;transform:translateY(10px)}to{opacity:1;transform:none}}
.modal-head{display:flex;justify-content:space-between;align-items:center;margin-bottom:20px;padding-bottom:16px;border-bottom:1px solid var(--border)}
.modal-head h3{font-size:18px;font-weight:700}
.modal-close{width:30px;height:30px;border-radius:50%;border:0;background:var(--surface-2);display:grid;place-items:center;color:var(--text-faint)}
.modal-close:hover{background:var(--surface-3);color:var(--text)}
.modal-foot{display:flex;justify-content:flex-end;gap:10px;margin-top:22px;padding-top:18px;border-top:1px solid var(--border)}
.error-text{color:var(--neg);font-size:12px;min-height:16px;margin-top:8px}

/* ---------- Toast ---------- */
.toast{
  position:fixed;right:26px;bottom:26px;background:var(--surface);border:1px solid var(--border);
  padding:13px 17px;border-radius:var(--radius-md);box-shadow:var(--shadow-lg);display:flex;align-items:center;gap:9px;
  transform:translateY(16px);opacity:0;pointer-events:none;transition:.28s var(--ease-snap);z-index:80;font-size:12.5px;font-weight:500;
}
.toast.show{transform:none;opacity:1}
.toast .icon{width:14px;height:14px;color:var(--pos);flex:none}
.toast.error .icon{color:var(--neg)}

/* ---------- Notification list ---------- */
.notif-list{display:flex;flex-direction:column}
.notif-item{padding:14px 0;border-bottom:1px solid var(--border);display:flex;gap:12px;align-items:flex-start}
.notif-item:last-child{border-bottom:0}
.notif-item .status-dot{margin-top:6px}
.notif-item b{display:block;margin-bottom:2px;font-size:13px}
.notif-item span{font-size:12px;color:var(--text-faint)}

/* ---------- Chart legend ---------- */
.legend{display:flex;flex-wrap:wrap;gap:14px 18px;margin-top:16px;padding-top:14px;border-top:1px solid var(--border)}
.legend-item{display:flex;align-items:center;gap:7px;font-size:11.5px;color:var(--text-dim)}
.legend-dot{width:8px;height:8px;border-radius:50%;flex:none}

/* ---------- Auth screens ---------- */
.auth-shell{min-height:100vh;display:grid;place-items:center;padding:24px;position:relative;z-index:1;background:var(--bg)}
.auth-card{
  width:100%;max-width:420px;background:var(--surface);
  border:1px solid var(--border);border-radius:var(--radius-xl);padding:40px 38px;box-shadow:var(--shadow-lg);
  animation:modalIn .4s var(--ease-snap);
}
.auth-brand{display:flex;flex-direction:column;align-items:center;text-align:center;margin-bottom:28px}
.auth-brand .brand-mark{width:48px;height:48px;border-radius:var(--radius-lg);margin-bottom:16px}
.auth-brand .brand-mark svg{width:26px;height:26px}
.auth-brand h1{font-size:22px;font-weight:700}
.auth-brand p{color:var(--text-faint);font-size:12.5px;margin-top:6px}
.auth-tabs{display:flex;gap:6px;margin-bottom:26px;background:var(--surface-2);padding:4px;border-radius:var(--radius-md)}
.auth-tab{flex:1;padding:9px 0;text-align:center;font-size:12.5px;font-weight:700;color:var(--text-faint);border:0;border-radius:var(--radius-sm);background:transparent}
.auth-tab.active{color:var(--text);background:var(--surface);box-shadow:var(--shadow-xs)}
.auth-fields{display:flex;flex-direction:column;gap:18px}
.auth-foot{text-align:center;margin-top:22px;font-size:12.5px;color:var(--text-faint)}
.auth-foot a{color:var(--accent);font-weight:600;text-decoration:none;cursor:pointer}

.welcome-scrim{position:fixed;inset:0;background:var(--scrim);backdrop-filter:blur(6px);display:none;place-items:center;z-index:70;padding:20px}
.welcome-scrim.open{display:grid}
.welcome-box{max-width:480px;background:var(--surface);border:1px solid var(--border);border-radius:var(--radius-xl);padding:40px;text-align:center;box-shadow:var(--shadow-lg)}

.profile-preview{
  width:80px;height:80px;border-radius:50%;margin:0 auto 16px;
  background:var(--accent);
  color:var(--accent-contrast);display:grid;place-items:center;font-family:var(--font-display);font-size:24px;font-weight:700;
  background-size:cover;background-position:center;
}

@media(max-width:760px){
  .grid.stats,.grid.two,.grid.split{grid-template-columns:1fr}
  .formgrid{grid-template-columns:1fr}
  .page-head{align-items:flex-start;flex-direction:column}
}
