/* ============================================================================
   QUATRON · PRODUCT SCREENS
   The visual layer for product modules (Gold, Gold Operations and anything that
   uses the same markup helpers).

   WHY THIS FILE DID NOT EXIST
   ---------------------------------------------------------------------------
   The product modules have always emitted `qtr-card`, `qtr-kpis`, `qtr-table`
   and friends, and NO stylesheet in the deployment defined any of them —
   verified by grepping every .css under deployment/: zero matches for
   `qtr-card`. So the markup was correct and complete while the browser had
   nothing to draw, which is why the Gold centre rendered as a flat list of
   unstyled text with `background: transparent; padding: 0; border-radius: 0`
   on its panel.

   It is a separate file rather than an addition to platform-shell.css because
   the shell is the chrome around a product and this is the inside of one; they
   are owned by different phases and change for different reasons.

   TOKENS, WITH FALLBACKS
   ---------------------------------------------------------------------------
   Every colour and radius reads a design token first and falls back to a
   literal. If design-tokens.css is loaded the product inherits the brand; if it
   is ever loaded late, or a token is renamed, the screen degrades to something
   readable instead of to invisible text on an invisible card. The fallbacks are
   not the design — they are the floor under it.

   RTL is not special-cased: the layout is flow-relative throughout
   (margin-inline, padding-inline, border-inline-start), so Arabic and English
   use the same rules rather than a mirrored copy that drifts.
   ============================================================================ */

/* ── Card ─────────────────────────────────────────────────────────────────── */
.qtr-card {
  background: var(--qtr-surface);
  border: 1px solid var(--qtr-border);
  border-radius: var(--radius-card);
  box-shadow: var(--qtr-shadow);
  margin-block-end: 16px;
  overflow: hidden;
}
.qtr-card-h {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  border-block-end: 1px solid var(--qtr-border);
  background: var(--qtr-surface-soft);
}
.qtr-card-h h2 { margin: 0; font-size: 1.05rem; font-weight: 600; }
.qtr-card-h i, .qtr-card-h svg { inline-size: 20px; block-size: 20px; color: var(--qtr-accent); }
.qtr-card-b { padding: 18px; }
.qtr-card-b > h3 {
  margin: 22px 0 10px;
  font-size: .95rem;
  font-weight: 600;
  color:var(--qtr-muted-text);
}
.qtr-card-b > h3:first-child { margin-block-start: 0; }

/* ── KPIs ─────────────────────────────────────────────────────────────────── */
.qtr-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-block-end: 14px;
}
.qtr-kpi {
  background: var(--qtr-surface-soft);
  border: 1px solid var(--qtr-border);
  border-radius: var(--radius-card);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
/* A KPI that opens a screen. It looks like the others until you approach it,
   because the affordance should say "this one goes somewhere" without making
   the static tiles beside it look broken. */
.qtr-kpi-link {
  text-decoration: none;
  color: inherit;
  position: relative;
  transition: border-color .15s, background .15s;
}
.qtr-kpi-link:hover { border-color: var(--qtr-accent); background: var(--qtr-surface); }
.qtr-kpi-link:focus-visible { outline: 2px solid var(--qtr-accent); outline-offset: 2px; }
.qtr-kpi-link i, .qtr-kpi-link svg {
  position: absolute;
  inset-block-start: 12px;
  inset-inline-start: 12px;      /* flow-relative: sits correctly in RTL and LTR */
  inline-size: 15px; block-size: 15px;
  color:var(--qtr-muted-text);
  opacity: 0; transition: opacity .15s;
}
.qtr-kpi-link:hover i, .qtr-kpi-link:focus-visible i,
.qtr-kpi-link:hover svg, .qtr-kpi-link:focus-visible svg { opacity: 1; }
@media (prefers-reduced-motion: reduce) {
  .qtr-kpi-link, .qtr-kpi-link i, .qtr-kpi-link svg { transition: none; }
}

.qtr-kpi-l { font-size: .82rem; color:var(--qtr-muted-text); }
.qtr-kpi-v {
  font-size: 1.35rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;   /* figures line up column-wise */
  color: var(--qtr-text);
}

/* ── The way in: section grid ─────────────────────────────────────────────── */
.qtr-navgrid ul, .qtr-list-plain { list-style: none; margin: 0; padding: 0; }
.qtr-navgrid ul {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
}
.qtr-navtile {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--qtr-border);
  border-radius: var(--radius-card);
  background: var(--qtr-surface);
  color: var(--qtr-text);
  text-decoration: none;
  font-size: .9rem;
  transition: border-color .15s, background .15s, transform .15s;
}
.qtr-navtile i, .qtr-navtile svg {
  inline-size: 18px; block-size: 18px;
  color: var(--qtr-accent);
  flex: 0 0 auto;
}
.qtr-navtile:hover { border-color: var(--qtr-accent); background: var(--qtr-surface-soft); }
/* A visible focus ring is the difference between keyboard-usable and not. */
.qtr-navtile:focus-visible {
  outline: 2px solid var(--qtr-accent);
  outline-offset: 2px;
}

/* ── Tables ───────────────────────────────────────────────────────────────── */
.qtr-table-wrap, .qtr-tablewrap { overflow-x: auto; }   /* wide tables scroll, the page does not */
.qtr-table { inline-size: 100%; border-collapse: collapse; font-size: .9rem; }
.qtr-table caption {
  text-align: start;
  padding-block-end: 8px;
  color:var(--qtr-muted-text);
  font-size: .85rem;
}
.qtr-table th, .qtr-table td {
  padding: 10px 12px;
  border-block-end: 1px solid var(--qtr-border);
  text-align: start;
  white-space: nowrap;
}
.qtr-table th {
  background: var(--qtr-surface-soft);
  font-weight: 600;
  color:var(--qtr-muted-text);
}
.qtr-table tbody tr:hover { background: var(--qtr-surface-soft); }

/* ── Lists, chips, badges ─────────────────────────────────────────────────── */
.qtr-list { margin: 0; padding-inline-start: 20px; }
.qtr-list li { margin-block-end: 6px; }
.qtr-chip, .qtr-badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: .78rem;
  background: var(--qtr-surface-soft);
  border: 1px solid var(--qtr-border);
  color:var(--qtr-muted-text);
}
.qtr-badge.tone-ok,   .qtr-chip.tone-ok   { background: var(--qtr-success-soft); border-color: transparent; color: var(--qtr-ink-strong); }
.qtr-badge.tone-warn, .qtr-chip.tone-warn { background: var(--qtr-warning-soft); border-color: transparent; color: var(--qtr-ink-strong); }
.qtr-badge.tone-bad,  .qtr-chip.tone-bad  { background: var(--qtr-danger-soft); border-color: transparent; color: var(--qtr-ink-strong); }

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.qtr-btn, .qtr-chip-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-control);
  border: 1px solid var(--qtr-border);
  background: var(--qtr-surface);
  color: var(--qtr-text);
  font: inherit; font-size: .88rem;
  cursor: pointer;
}
.qtr-btn:hover, .qtr-chip-btn:hover { background: var(--qtr-surface-soft); }
.qtr-btn:focus-visible, .qtr-chip-btn:focus-visible {
  outline: 2px solid var(--qtr-accent); outline-offset: 2px;
}
.qtr-btn.primary { background: var(--qtr-accent); border-color: var(--qtr-accent); color: var(--qtr-on-accent); }
.qtr-btn.ghost { background: transparent; border-color: transparent; }
.qtr-btn.xs { padding: 4px 9px; font-size: .8rem; }
.qtr-btn[disabled] { opacity: .5; cursor: not-allowed; }
.qtr-linkish {
  background: none; border: 0; padding: 0;
  color: var(--qtr-accent);
  text-decoration: underline; cursor: pointer; font: inherit;
}

/* ── Forms ────────────────────────────────────────────────────────────────── */
.qtr-form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.qtr-form-row { display: flex; flex-direction: column; gap: 5px; }
.qtr-form-row label { font-size: .85rem; color:var(--qtr-muted-text); }
.qtr-form-row input, .qtr-form-row select, .qtr-form-row textarea {
  padding: 9px 11px;
  border: 1px solid var(--qtr-border);
  border-radius: var(--radius-control);
  font: inherit;
  background: var(--qtr-surface);
  color: var(--qtr-text);
}
.qtr-form-row input:focus-visible, .qtr-form-row select:focus-visible, .qtr-form-row textarea:focus-visible {
  outline: 2px solid var(--qtr-accent); outline-offset: 1px;
}
/* The error is bound to its field by aria-describedby in the markup; this only
   makes it visible. Colour is not the sole signal - the text says what is wrong. */
.qtr-form-error { color:var(--qtr-danger-text); font-size: .82rem; }
.qtr-modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-block-start: 16px; }
.qtr-lv-filters { display: flex; flex-wrap: wrap; gap: 8px; margin-block-end: 14px; }

/* ── Empty, loading, notes ────────────────────────────────────────────────── */
.qtr-empty {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  padding: 40px 20px; color:var(--qtr-muted-text); text-align: center;
}
.qtr-empty i, .qtr-empty svg { inline-size: 30px; block-size: 30px; opacity: .5; }
.qtr-loading { display: flex; justify-content: center; padding: 40px; }
.qtr-spinner {
  inline-size: 26px; block-size: 26px;
  border: 3px solid var(--qtr-border);
  border-top-color: var(--qtr-accent);
  border-radius: 50%;
  animation: qtr-spin .8s linear infinite;
}
@keyframes qtr-spin { to { transform: rotate(360deg); } }
/* Respect a user who has asked for less motion. */
@media (prefers-reduced-motion: reduce) {
  .qtr-spinner { animation-duration: 2.4s; }
  .qtr-navtile { transition: none; }
}
.qtr-fin-note {
  display: block;
  margin-block-start: 12px;
  padding-inline-start: 12px;
  border-inline-start: 3px solid var(--qtr-accent);
  color:var(--qtr-muted-text);
  font-size: .84rem;
  line-height: 1.6;
}
.qtr-muted { color:var(--qtr-muted-text); }
.qtr-gops-lines { display: flex; flex-direction: column; gap: 10px; }

/* Visible to a screen reader, not to the eye. */
.qtr-sr-only {
  position: absolute; inline-size: 1px; block-size: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap; border: 0;
}

/* ── Dark theme ───────────────────────────────────────────────────────────── */
:root[data-theme="dark"] .qtr-card,
:root[data-theme="dark"] .qtr-navtile,
:root[data-theme="dark"] .qtr-btn {
  background: var(--qtr-surface);
  border-color: var(--qtr-border);
  color: var(--qtr-text);
}
:root[data-theme="dark"] .qtr-card-h,
:root[data-theme="dark"] .qtr-kpi,
:root[data-theme="dark"] .qtr-table th {
  background: var(--qtr-surface-soft);
  border-color: var(--qtr-border);
}
