/* ===========================================================================
   FinLens — Base CSS
   Reset + body + typography + utility classes. ALL values via var(--*).
   =========================================================================== */

/* ---- Reset ---------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html, body, h1, h2, h3, h4, h5, h6, p, ul, ol, li, figure, blockquote, pre, table, th, td {
  margin: 0; padding: 0;
}
ul, ol { list-style: none; }
img, svg { display: block; max-width: 100%; }
button { font: inherit; border: 0; background: none; cursor: pointer; color: inherit; }
input, select, textarea { font: inherit; color: inherit; }
a { color: var(--color-link); text-decoration: none; }
a:hover { color: var(--color-link-hover); text-decoration: underline; }
hr { border: 0; border-top: var(--bw-thin) solid var(--color-border); margin: var(--sp-4) 0; }

/* ---- Body / typography ---------------------------------------------------- */
html { font-size: var(--fs-base); }
body {
  font-family: var(--font-ui);
  font-size: var(--fs-base);
  line-height: var(--lh-normal);
  color: var(--color-text);
  background: var(--color-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1 { font-size: var(--fs-2xl);  font-weight: var(--fw-bold);   line-height: var(--lh-tight); }
h2 { font-size: var(--fs-xl);   font-weight: var(--fw-bold);   line-height: var(--lh-tight); }
h3 { font-size: var(--fs-lg);   font-weight: var(--fw-bold);   line-height: var(--lh-tight); }
h4 { font-size: var(--fs-md);   font-weight: var(--fw-bold);   line-height: var(--lh-tight); }
h5 { font-size: var(--fs-base); font-weight: var(--fw-bold);   text-transform: uppercase; letter-spacing: 0.5px; color: var(--color-text-muted); }
h6 { font-size: var(--fs-xs);   font-weight: var(--fw-bold);   text-transform: uppercase; letter-spacing: 0.5px; color: var(--color-text-muted); }

code, pre, .mono, .text-mono {
  font-family: var(--font-mono);
  font-size: 0.95em;
}

/* ---- Display utilities ---------------------------------------------------- */
.d-flex   { display: flex; }
.d-inline-flex { display: inline-flex; }
.d-grid   { display: grid; }
.d-block  { display: block; }
.d-inline { display: inline; }
.d-inline-block { display: inline-block; }
.d-none   { display: none; }

/* ---- Flex utilities ------------------------------------------------------- */
.flex-col          { flex-direction: column; }
.flex-row          { flex-direction: row; }
.flex-wrap         { flex-wrap: wrap; }
.flex-1            { flex: 1; }
.items-center      { align-items: center; }
.items-start       { align-items: flex-start; }
.items-end         { align-items: flex-end; }
.items-baseline    { align-items: baseline; }
.justify-start     { justify-content: flex-start; }
.justify-center    { justify-content: center; }
.justify-end       { justify-content: flex-end; }
.justify-between   { justify-content: space-between; }

/* ---- Gap ------------------------------------------------------------------ */
.gap-1 { gap: var(--sp-1); }
.gap-2 { gap: var(--sp-2); }
.gap-3 { gap: var(--sp-3); }
.gap-4 { gap: var(--sp-4); }
.gap-5 { gap: var(--sp-5); }
.gap-6 { gap: var(--sp-6); }

/* ---- Spacing utilities ---------------------------------------------------- */
.m-0  { margin: 0; }
.mt-0 { margin-top: 0; }
.mt-1 { margin-top: var(--sp-1); }
.mt-2 { margin-top: var(--sp-2); }
.mt-3 { margin-top: var(--sp-3); }
.mt-4 { margin-top: var(--sp-4); }
.mt-5 { margin-top: var(--sp-5); }
.mt-6 { margin-top: var(--sp-6); }
.mt-7 { margin-top: var(--sp-7); }

.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: var(--sp-1); }
.mb-2 { margin-bottom: var(--sp-2); }
.mb-3 { margin-bottom: var(--sp-3); }
.mb-4 { margin-bottom: var(--sp-4); }
.mb-5 { margin-bottom: var(--sp-5); }
.mb-6 { margin-bottom: var(--sp-6); }
.mb-7 { margin-bottom: var(--sp-7); }

.ml-auto { margin-left: auto; }
.mr-auto { margin-right: auto; }
.mx-auto { margin-left: auto; margin-right: auto; }

.p-0 { padding: 0; }
.p-2 { padding: var(--sp-2); }
.p-3 { padding: var(--sp-3); }
.p-4 { padding: var(--sp-4); }
.p-5 { padding: var(--sp-5); }
.p-6 { padding: var(--sp-6); }
.py-2 { padding-top: var(--sp-2); padding-bottom: var(--sp-2); }
.py-3 { padding-top: var(--sp-3); padding-bottom: var(--sp-3); }
.py-4 { padding-top: var(--sp-4); padding-bottom: var(--sp-4); }
.py-5 { padding-top: var(--sp-5); padding-bottom: var(--sp-5); }
.px-3 { padding-left: var(--sp-3); padding-right: var(--sp-3); }
.px-4 { padding-left: var(--sp-4); padding-right: var(--sp-4); }
.px-5 { padding-left: var(--sp-5); padding-right: var(--sp-5); }

/* ---- Text utilities ------------------------------------------------------- */
.text-left   { text-align: left; }
.text-right  { text-align: right; }
.text-center { text-align: center; }
.text-muted  { color: var(--color-text-muted); }
.text-subtle { color: var(--color-text-subtle); }
.text-danger { color: var(--color-danger); }
.text-accent { color: var(--color-accent); }
.text-warn   { color: var(--color-warn); }
.text-info   { color: var(--color-info); }
.text-inverse{ color: var(--color-text-inverse); }
.uppercase   { text-transform: uppercase; letter-spacing: 0.5px; }
.nowrap      { white-space: nowrap; }
.truncate    { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.fs-xs   { font-size: var(--fs-xs); }
.fs-sm   { font-size: var(--fs-sm); }
.fs-base { font-size: var(--fs-base); }
.fs-md   { font-size: var(--fs-md); }
.fs-lg   { font-size: var(--fs-lg); }
.fs-xl   { font-size: var(--fs-xl); }

.fw-regular { font-weight: var(--fw-regular); }
.fw-medium  { font-weight: var(--fw-medium); }
.fw-bold    { font-weight: var(--fw-bold); }

/* ---- Sizing --------------------------------------------------------------- */
.w-full   { width: 100%; }
.h-full   { height: 100%; }
.maxw-md  { max-width: 480px; }
.maxw-lg  { max-width: 720px; }
.maxw-xl  { max-width: var(--content-max-w); }

/* ---- Borders -------------------------------------------------------------- */
.border        { border: var(--bw-thin) solid var(--color-border); }
.border-top    { border-top: var(--bw-thin) solid var(--color-border); }
.border-bottom { border-bottom: var(--bw-thin) solid var(--color-border); }
.border-strong { border-color: var(--color-border-strong); }

/* ---- Background ----------------------------------------------------------- */
.bg-bg-subtle { background: var(--color-bg-subtle); }
.bg-bg-muted  { background: var(--color-bg-muted); }

/* ---- Icon ----------------------------------------------------------------- */
.icon { display: inline-block; vertical-align: middle; flex-shrink: 0; }
.icon path, .icon line, .icon polyline, .icon rect, .icon circle, .icon polygon {
  stroke: currentColor;
  fill: none;
  stroke-width: var(--icon-stroke);
  stroke-linecap: round;
  stroke-linejoin: round;
}
.icon-fill path, .icon-fill rect, .icon-fill circle, .icon-fill polygon {
  fill: currentColor; stroke: none;
}

/* ---- Money / numeric ------------------------------------------------------ */
.num    { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.num-pos{ color: var(--color-accent); }
.num-neg{ color: var(--color-danger); }

/* ---- Responsive helpers --------------------------------------------------- */
@media (max-width: 768px) {
  .hide-mobile { display: none !important; }
}
@media (min-width: 769px) {
  .show-mobile-only { display: none !important; }
}

/* ---- Skip link / a11y ----------------------------------------------------- */
.skip-link {
  position: absolute; left: -9999px; top: 0;
  background: var(--color-text); color: var(--color-text-inverse);
  padding: var(--sp-2) var(--sp-3);
}
.skip-link:focus { left: var(--sp-2); top: var(--sp-2); z-index: 100; }

/* ---- App density: compact page titles + headings inside the app shell ---- */
.app-main h1 { font-size: var(--fs-xl); margin-bottom: var(--sp-1); }
.app-main h2 { font-size: var(--fs-lg); }
.app-main h3 { font-size: var(--fs-md); }
.app-main .card { margin-bottom: var(--sp-3); }
.app-main .mb-4 { margin-bottom: var(--sp-3) !important; }
