/* ============================================================
   FinSpy — design tokens
   Palette: ink ledger (#0F2620 base) + emerald signal (#33C481)
            + gold for growth/advice (#D8B25C) + bone text (#EDEAE0)
   Type: IBM Plex Mono for figures/data, IBM Plex Sans for body,
         IBM Plex Sans Arabic for RTL content
   Signature: perforated "receipt tape" edges + a live ledger ticker
   ============================================================ */

:root {
  --ink: #0F2620;
  --ink-2: #14312A;
  --panel: #16352D;
  --line: #26493F;
  --bone: #EDEAE0;
  --bone-dim: #AEC1B9;
  --emerald: #33C481;
  --emerald-dim: #1F8A5C;
  --gold: #D8B25C;
  --coral: #E0765A;
  --radius: 10px;
  --font-display: 'IBM Plex Sans', 'IBM Plex Sans Arabic', sans-serif;
  --font-body: 'IBM Plex Sans', 'IBM Plex Sans Arabic', sans-serif;
  --font-mono: 'IBM Plex Mono', monospace;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--ink);
  color: var(--bone);
  font-family: var(--font-body);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

html[dir="rtl"] body { font-family: 'IBM Plex Sans Arabic', var(--font-body); }

.wrap {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 28px;
}

a { color: inherit; }

/* ---- Perforated tape edges (signature element) ---- */
.tape-edge {
  height: 14px;
  width: 100%;
  background-image: radial-gradient(circle at 10px 7px, var(--ink) 5px, transparent 5.5px);
  background-size: 20px 14px;
  background-color: var(--emerald-dim);
}
.tape-top { background-color: var(--emerald-dim); }
.tape-bottom { background-color: var(--gold); }

/* ---- Header ---- */
.site-header {
  padding: 22px 0 10px;
  border-bottom: 1px solid var(--line);
}
.header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  font-family: var(--font-mono);
  font-weight: 600;
  background: var(--emerald);
  color: var(--ink);
  padding: 4px 8px;
  border-radius: 6px;
  letter-spacing: 0.02em;
}
.brand-name {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 1.05rem;
  letter-spacing: 0.01em;
}
.header-actions { display: flex; align-items: center; gap: 14px; }
.credit {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--bone-dim);
  opacity: 0.85;
}

.ghost-btn {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--bone-dim);
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 0.85rem;
  cursor: pointer;
  text-decoration: none;
  font-family: var(--font-body);
  transition: border-color .15s ease, color .15s ease;
}
.ghost-btn:hover { border-color: var(--emerald); color: var(--bone); }

/* ---- Hero ---- */
.hero {
  padding: 64px 28px 40px;
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 40px;
  align-items: center;
}
.eyebrow {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.14em;
  color: var(--emerald);
  margin: 0 0 14px;
}
.hero h1 {
  font-size: clamp(2.1rem, 4vw, 3.1rem);
  line-height: 1.12;
  margin: 0 0 18px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.hero-sub {
  color: var(--bone-dim);
  font-size: 1.05rem;
  max-width: 46ch;
  margin: 0 0 26px;
}
.hero-cta { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.hero-note { font-size: 0.8rem; color: var(--bone-dim); opacity: 0.8; }

.btn-primary, .btn-secondary {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.92rem;
  padding: 12px 22px;
  border-radius: 8px;
  cursor: pointer;
  border: 1px solid transparent;
}
.btn-primary { background: var(--emerald); color: var(--ink); }
.btn-primary:hover { background: #3fd692; }
.btn-secondary { background: transparent; color: var(--bone); border-color: var(--line); }
.btn-secondary:hover { border-color: var(--gold); color: var(--gold); }

/* ---- Hero ledger ticker ---- */
.hero-ledger {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  height: 280px;
  overflow: hidden;
  position: relative;
  font-family: var(--font-mono);
  font-size: 0.82rem;
}
.hero-ledger::after {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(to bottom, transparent 70%, var(--panel) 100%);
  pointer-events: none;
}
.ledger-strip { display: flex; flex-direction: column; gap: 10px; }
.tick-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 6px;
  background: var(--ink-2);
  border-left: 3px solid var(--line);
  animation: fadeIn .4s ease both;
}
.tick-row.out { border-left-color: var(--coral); }
.tick-row.in { border-left-color: var(--emerald); }
.tick-cat { color: var(--bone-dim); font-size: 0.72rem; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px);} to { opacity: 1; transform: translateY(0);} }

/* ---- Panels ---- */
.panel { padding: 56px 28px; border-top: 1px solid var(--line); }
.panel-head { display: flex; align-items: baseline; gap: 14px; margin-bottom: 28px; }
.panel-index {
  font-family: var(--font-mono);
  color: var(--gold);
  font-size: 0.85rem;
  border: 1px solid var(--line);
  padding: 3px 8px;
  border-radius: 6px;
}
.panel h2 { font-size: 1.5rem; margin: 0; font-weight: 600; }

/* ---- Upload ---- */
.upload-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }
.dropzone {
  border: 1.5px dashed var(--line);
  border-radius: var(--radius);
  padding: 34px 20px;
  text-align: center;
  transition: border-color .15s ease, background .15s ease;
}
.dropzone.dragover { border-color: var(--emerald); background: rgba(51,196,129,0.06); }
.dz-title { font-weight: 600; margin: 4px 0; }
.dz-sub { color: var(--bone-dim); margin: 6px 0; font-size: 0.85rem; }
.dz-hint { color: var(--bone-dim); font-size: 0.76rem; margin-top: 14px; opacity: 0.75; }

.paste-box { display: flex; flex-direction: column; gap: 10px; }
.paste-label { font-size: 0.85rem; color: var(--bone-dim); }
#pasteArea {
  background: var(--ink-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--bone);
  font-family: var(--font-mono);
  font-size: 0.82rem;
  padding: 12px;
  resize: vertical;
}
.parse-status { margin-top: 16px; font-size: 0.85rem; color: var(--emerald); min-height: 1.2em; }

/* ---- Summary row ---- */
.summary-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
  margin-bottom: 32px;
}
.summary-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
}
.summary-card .label { font-size: 0.76rem; color: var(--bone-dim); margin-bottom: 6px; }
.summary-card .value { font-family: var(--font-mono); font-size: 1.35rem; font-weight: 600; }
.summary-card.positive .value { color: var(--emerald); }
.summary-card.negative .value { color: var(--coral); }
.summary-card.neutral .value { color: var(--gold); }

/* ---- Dashboard grid ---- */
.dash-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 40px; }
.chart-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.chart-card h3 { margin: 0 0 14px; font-size: 0.95rem; color: var(--bone-dim); font-weight: 500; }
.chart-canvas-wrap { position: relative; height: 260px; width: 100%; }
.chart-canvas-wrap canvas { max-width: 100%; }

/* ---- Ledger table ---- */
.ledger-table-wrap h3 { font-size: 1.05rem; margin-bottom: 14px; }
.ledger-controls { display: flex; gap: 10px; margin-bottom: 12px; }
.txn-search, .txn-filter {
  background: var(--ink-2);
  border: 1px solid var(--line);
  color: var(--bone);
  padding: 8px 12px;
  border-radius: 6px;
  font-family: var(--font-body);
  font-size: 0.85rem;
}
.txn-search { flex: 1; }
.ledger-table { width: 100%; border-collapse: collapse; font-size: 0.86rem; }
.ledger-table th {
  text-align: left;
  color: var(--bone-dim);
  font-weight: 500;
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 10px;
  border-bottom: 1px solid var(--line);
}
html[dir="rtl"] .ledger-table th { text-align: right; }
.ledger-table td { padding: 10px; border-bottom: 1px solid var(--line); font-family: var(--font-mono); font-size: 0.82rem; }
.ledger-table tr:hover td { background: rgba(255,255,255,0.02); }
.cat-pill {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-family: var(--font-body);
  border: 1px solid var(--line);
}
.amt-out { color: var(--coral); }
.amt-in { color: var(--emerald); }

/* ---- Advice ---- */
.advice-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 18px; margin-bottom: 22px; }
.advice-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 3px solid var(--gold);
  border-radius: var(--radius);
  padding: 20px;
}
html[dir="rtl"] .advice-card { border-left: 1px solid var(--line); border-right: 3px solid var(--gold); }
.advice-card h4 { margin: 0 0 8px; font-size: 0.98rem; }
.advice-card p { margin: 0; color: var(--bone-dim); font-size: 0.88rem; }
.disclaimer { font-size: 0.78rem; color: var(--bone-dim); opacity: 0.8; border-top: 1px solid var(--line); padding-top: 16px; }

/* ---- Footer ---- */
.site-footer { padding: 30px 28px; }
.footer-row { color: var(--bone-dim); font-size: 0.82rem; }
.footer-row p { margin: 0 0 6px; }
.footer-row .credit-footer {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  opacity: 0.75;
  margin-bottom: 0;
}

/* ---- Responsive ---- */
@media (max-width: 820px) {
  .hero { grid-template-columns: 1fr; padding-top: 44px; }
  .upload-grid, .dash-grid { grid-template-columns: 1fr; }
  .hero-ledger { height: 220px; }
}

/* ---- Reduced motion ---- */
@media (prefers-reduced-motion: reduce) {
  .tick-row { animation: none; }
  html { scroll-behavior: auto; }
}

/* ---- Focus visibility ---- */
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible, a:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}
