/* ============================================================================
   "PRO 2 · Estudio claro" — Purchases Dashboard ONLY (#/projects/dashboard).
   Scoped under `.dash-ds`; no other screen is affected. Light-only (the brief
   gave no dark tokens). Fonts vendored locally (OFL) — no CDN.
   Archivo: titles + big numbers + UI. Geist Mono: small figures.
   ============================================================================ */

/* Fonts (@font-face) and the canonical --ds-* tokens now live in the shared
   design-system.css, loaded app-wide. The dashboard sources its local tokens
   from those --ds-* values below, so it renders exactly the same. */

.dash-ds {
  --bg: var(--ds-bg);
  --surface: var(--ds-surface);
  --raised: var(--ds-raised);
  --line: var(--ds-line);
  --line-strong: var(--ds-line-strong);   /* input / filter / secondary-button borders */
  --ink: var(--ds-ink);
  --ink-2: var(--ds-ink-2);
  --ink-3: var(--ds-ink-3);                /* never lighter than this */
  --accent: var(--ds-accent);              /* white text on top */
  --accent-soft: var(--ds-accent-soft);
  --warn: var(--ds-warn); --warn-bg: var(--ds-warn-bg);
  --good: var(--ds-good); --good-bg: var(--ds-good-bg);
  --bad: var(--ds-bad);  --bad-bg: var(--ds-bad-bg);
  --month-now: var(--ds-month-now);        /* current month in charts */
  --shadow-sm: var(--ds-shadow-sm);
  --shadow-lg: var(--ds-shadow-lg);
  --font-display: var(--ds-font-display);
  --font-ui: var(--ds-font-ui);
  --font-mono: var(--ds-font-mono);

  /* legacy aliases so shared components adopt the palette */
  --muted: var(--ink-2); --line-soft: #E4EBF1; --blue: var(--accent);
  --green: var(--good); --green-dark: var(--good); --green-soft: var(--good-bg);
  --amber: var(--warn); --red: var(--bad);

  font-family: var(--font-ui); font-size: 14px; line-height: 1.5; color: var(--ink);
  font-variant-numeric: tabular-nums;
  position: relative; z-index: 0;
}

/* ---- Typography ----------------------------------------------------------- */
.dash-ds h1, .dash-ds h2, .dash-ds .kpi-val, .dash-ds .num-xl { font-family: var(--font-display); }
.dash-ds .page-head h1 { font-size: 28px; font-weight: 700; letter-spacing: -0.02em; color: var(--ink); margin: 0; }
.dash-ds .page-head .sub { font-size: 14px; color: var(--ink-2); }
.dash-ds .panel h2 { font-size: 17px; font-weight: 600; letter-spacing: -0.01em; color: var(--ink); }
.dash-ds .panel h2 .dim { font-family: var(--font-ui); font-weight: 500; color: var(--ink-3); }
.dash-ds .mono, .dash-ds .spark-cap { font-family: var(--font-mono); }

/* ---- Accessibility: visible focus ring + screen-reader-only text ---------- */
.dash-ds :focus-visible, .dash-ds a:focus-visible, .dash-ds button:focus-visible,
.dash-ds input:focus-visible, .dash-ds [tabindex]:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px;
}
.dash-ds .vh {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---- Header --------------------------------------------------------------- */
.dash-ds .dash-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 20px; }
.dash-ds .dash-head .greet { font-family: var(--font-display); font-size: 28px; font-weight: 700; letter-spacing: -0.02em; margin: 0; flex: 0 0 auto; }
.dash-ds .dash-head .grow { flex: 1 1 180px; }
.dash-ds .dash-search { position: relative; flex: 1 1 240px; min-width: 180px; }
.dash-ds .dash-search input {
  width: 100%; height: 40px; padding: 0 12px 0 34px; border: 1px solid var(--line-strong);
  border-radius: 10px; background: var(--surface) 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='%235F6878' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m21 21-4.3-4.3'/%3E%3C/svg%3E") no-repeat 10px center;
  font: inherit; color: var(--ink);
}
.dash-ds .dash-results {
  position: absolute; top: 44px; left: 0; right: 0; z-index: 20; background: var(--surface);
  border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-sm), var(--shadow-lg);
  max-height: 320px; overflow: auto; padding: 6px;
}
.dash-ds .dash-results:empty { display: none; }
.dash-ds .dash-results a { display: block; padding: 8px 10px; border-radius: 8px; color: var(--ink); text-decoration: none; font-size: 13px; }
.dash-ds .dash-results a:hover, .dash-ds .dash-results a:focus-visible { background: var(--accent-soft); }
.dash-ds .dash-results .res-kind { color: var(--ink-3); font-size: 11px; font-family: var(--font-mono); }

/* segmented range filter */
.dash-ds .seg { display: inline-flex; background: var(--raised); border-radius: 10px; padding: 3px; gap: 2px; }
.dash-ds .seg button {
  border: 0; background: transparent; color: var(--ink-2); font: 500 13px var(--font-ui);
  padding: 6px 12px; border-radius: 8px; cursor: pointer; transition: background .25s cubic-bezier(.32,.72,0,1), color .25s;
}
.dash-ds .seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }

.dash-ds .btn-scan {
  display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 16px; border: 0;
  border-radius: 999px; background: var(--accent); color: #fff; font: 600 14px var(--font-ui);
  cursor: pointer; text-decoration: none; transition: transform .25s cubic-bezier(.32,.72,0,1), background .25s;
}
.dash-ds .btn-scan:hover { background: #121C38; }
.dash-ds .btn-scan:active { transform: scale(.98); }

/* ---- KPI row: double-bezel tiles with change arrow + sparkline ------------ */
.dash-ds .kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 20px; }
.dash-ds .kpi {
  position: relative; background: rgba(30, 46, 86, .05); padding: 5px; border-radius: 22px;
  border: 1px solid rgba(20, 24, 32, .05);
  transition: transform .3s cubic-bezier(.32,.72,0,1);
}
.dash-ds .kpi-core {
  position: relative; background: var(--surface); border-radius: 17px; padding: 18px 18px 14px;
  box-shadow: 0 1px 0 rgba(255,255,255,.7) inset; overflow: hidden; min-height: 132px;
  display: flex; flex-direction: column;
}
.dash-ds .kpi-core::after {    /* cursor glow (desktop only) */
  content: ""; position: absolute; inset: 0; pointer-events: none; opacity: 0;
  background: radial-gradient(200px circle at var(--mx,50%) var(--my,50%), rgba(94,127,159,.12), transparent 70%);
  transition: opacity .3s cubic-bezier(.32,.72,0,1);
}
@media (hover: hover) and (pointer: fine) { .dash-ds .kpi:hover .kpi-core::after { opacity: 1; } }
.dash-ds .kpi-top { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; position: relative; z-index: 1; }
.dash-ds .kpi-label { font-size: 13px; font-weight: 500; color: var(--ink-2); }
.dash-ds .kpi-val { font-size: 32px; font-weight: 700; letter-spacing: -0.02em; color: var(--ink); margin: 6px 0 2px; position: relative; z-index: 1; }
.dash-ds .kpi-foot { font-size: 12px; color: var(--ink-3); margin-top: auto; position: relative; z-index: 1; }
.dash-ds .chg { display: inline-flex; align-items: center; gap: 3px; font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; }
.dash-ds .chg.pos { color: var(--good); } .dash-ds .chg.neg { color: var(--bad); } .dash-ds .chg.flat { color: var(--ink-3); }
.dash-ds .chg svg { width: 12px; height: 12px; }
.dash-ds .spark { width: 100%; height: 30px; display: block; margin: 8px 0 2px; position: relative; z-index: 1; }

/* ---- Panels --------------------------------------------------------------- */
.dash-ds .panel {
  background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 22px 24px;
  box-shadow: var(--shadow-sm), var(--shadow-lg); margin-bottom: 20px;
}
.dash-ds .panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.dash-ds .link-plain { color: var(--accent); font-size: 13px; font-weight: 500; text-decoration: none; background: none; border: 0; cursor: pointer; font-family: var(--font-ui); }
.dash-ds .link-plain:hover { text-decoration: underline; }
.dash-ds .grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.dash-ds .grid2 > .panel { margin-bottom: 0; }

/* ---- Category bars (HTML, amount + %) ------------------------------------- */
.dash-ds .catbar { display: grid; grid-template-columns: 150px 1fr auto; align-items: center; gap: 12px; padding: 7px 0; }
.dash-ds .catbar .cname { font-size: 13px; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dash-ds .catbar .ctrack { display: block; height: 10px; background: var(--raised); border-radius: 999px; overflow: hidden; }
.dash-ds .catbar .cfill { display: block; height: 100%; min-width: 2px; background: #5E7F9F; border-radius: 999px; }
.dash-ds .catbar .cval { font-size: 13px; color: var(--ink-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.dash-ds .catbar .cpct { color: var(--ink-3); font-size: 12px; margin-left: 6px; }

/* ---- Price trend controls ------------------------------------------------- */
.dash-ds .mat-picker { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.dash-ds .mat-search { position: relative; flex: 1 1 220px; }
.dash-ds .mat-search input { width: 100%; height: 36px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: 9px; background: var(--surface); font: inherit; color: var(--ink); }
.dash-ds .mat-ac { position: absolute; top: 40px; left: 0; right: 0; z-index: 15; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow-lg); max-height: 240px; overflow: auto; }
.dash-ds .mat-ac:empty { display: none; }
.dash-ds .mat-ac button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 8px 12px; font: inherit; color: var(--ink); cursor: pointer; }
.dash-ds .mat-ac button:hover, .dash-ds .mat-ac button:focus-visible { background: var(--accent-soft); }
.dash-ds .mat-quick { display: flex; flex-wrap: wrap; gap: 6px; }
.dash-ds .mat-quick button {
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink-2);
  border-radius: 999px; padding: 6px 12px; font: 500 12px var(--font-ui); cursor: pointer; max-width: 220px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; transition: transform .2s cubic-bezier(.32,.72,0,1);
}
.dash-ds .mat-quick button:active { transform: scale(.98); }
.dash-ds .mat-quick button[aria-pressed="true"] { background: var(--accent); color: #fff; border-color: var(--accent); }
.dash-ds .pt-stats { display: flex; flex-wrap: wrap; gap: 18px; margin-top: 10px; font-size: 13px; }
.dash-ds .pt-stats .k { color: var(--ink-3); font-size: 11px; display: block; }
.dash-ds .pt-stats .v { font-family: var(--font-display); font-weight: 600; font-size: 18px; color: var(--ink); font-variant-numeric: tabular-nums; }

/* ---- Top suppliers list --------------------------------------------------- */
.dash-ds .sup-row { display: grid; grid-template-columns: 36px 1fr auto; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.dash-ds .sup-row:first-child { border-top: 0; }
.dash-ds .sup-ini { width: 36px; height: 36px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); font: 600 13px var(--font-display); display: flex; align-items: center; justify-content: center; }
.dash-ds .sup-name { font-size: 14px; color: var(--ink); font-weight: 500; }
.dash-ds .sup-meta { font-size: 12px; color: var(--ink-3); }
.dash-ds .sup-right { text-align: right; }
.dash-ds .sup-amt { font-variant-numeric: tabular-nums; color: var(--ink); font-weight: 500; }
.dash-ds .sup-pct { font-size: 12px; color: var(--ink-3); }

/* ---- Needs attention: text-labelled chips + action buttons ---------------- */
.dash-ds .attn { list-style: none; margin: 0; padding: 0; }
.dash-ds .attn li { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); flex-wrap: wrap; }
.dash-ds .attn li:first-child { border-top: 0; }
.dash-ds .tag { font-size: 11px; font-weight: 600; padding: 2px 9px; border-radius: 999px; flex: 0 0 auto; }
.dash-ds .tag.bad  { background: var(--bad-bg);  color: var(--bad); }
.dash-ds .tag.warn { background: var(--warn-bg); color: var(--warn); }
.dash-ds .tag.info { background: var(--accent-soft); color: var(--accent); }
.dash-ds .attn .what { flex: 1 1 200px; font-size: 13px; color: var(--ink-2); }
.dash-ds .attn .what a { color: var(--ink); font-weight: 500; text-decoration: none; }
.dash-ds .attn .what a:hover { text-decoration: underline; }
.dash-ds .attn .act {
  flex: 0 0 auto; border: 1px solid var(--line-strong); background: var(--surface); color: var(--accent);
  border-radius: 8px; padding: 5px 11px; font: 500 12px var(--font-ui); cursor: pointer; text-decoration: none;
  transition: transform .2s cubic-bezier(.32,.72,0,1);
}
.dash-ds .attn .act:active { transform: scale(.98); }

/* ---- Table view (monthly spend) ------------------------------------------- */
.dash-ds table { width: 100%; border-collapse: collapse; }
.dash-ds table th, .dash-ds table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); font-size: 13px; }
.dash-ds table th { color: var(--ink-3); font-weight: 500; }
.dash-ds table td.num, .dash-ds table th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---- Grain texture -------------------------------------------------------- */
.dash-ds .dash-grain {
  position: fixed; inset: 0; pointer-events: none; z-index: -1; opacity: .02;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 180px 180px;
}
.dash-ds .empty { padding: 22px 10px; color: var(--ink-3); font-size: 13px; }

/* ---- Mobile: one column, KPIs 2-up, 44px touch targets, no h-scroll ------- */
@media (max-width: 700px) {
  .dash-ds { overflow-x: hidden; }
  .dash-ds .kpis { grid-template-columns: 1fr 1fr; gap: 12px; }
  .dash-ds .grid2 { grid-template-columns: 1fr; }
  .dash-ds .panel { padding: 18px; }
  .dash-ds .dash-head .greet { font-size: 22px; }
  .dash-ds .catbar { grid-template-columns: 110px 1fr auto; }
  .dash-ds .seg button, .dash-ds .btn-scan, .dash-ds .attn .act, .dash-ds .mat-quick button { min-height: 44px; }
  .dash-ds .seg button { padding: 10px 12px; }
}

/* ---- Reduced motion ------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  .dash-ds *, .dash-ds .kpi-core::after { transition: none !important; }
  .dash-ds .kpi-core::after { display: none; }
}
