/* ==========================================================================
   RDS components v0.1 DRAFT — requires tokens/rds-tokens.css first.
   Plain CSS so it drops into static pages, Flask (CRM, Certificate Desks),
   Django (ASTRA) and Next.js (website) alike. Class prefix: .rw-
   ========================================================================== */

*, *::before, *::after { box-sizing: border-box; }
body.rw {
  margin: 0; background: var(--rw-bg); color: var(--rw-text);
  font: 400 var(--rw-text-md)/var(--rw-leading-body) var(--rw-font-ui);
  -webkit-font-smoothing: antialiased;
}
.rw :focus-visible { outline: 3px solid var(--rw-focus); outline-offset: 2px; border-radius: 4px; }
.rw-num { font-variant-numeric: tabular-nums lining-nums; }
.rw-sr { position:absolute; width:1px; height:1px; overflow:hidden; clip:rect(0 0 0 0); white-space:nowrap; }

/* ---- Headings: display serif only for page titles and the hero figure */
.rw-h1 { font: 600 var(--rw-text-2xl)/var(--rw-leading-tight) var(--rw-font-display); margin: 0; letter-spacing: -.01em; }
.rw-h2 { font: 600 var(--rw-text-lg)/1.3 var(--rw-font-ui); margin: 0; }
.rw-muted { color: var(--rw-text-muted); }

/* ---- App shell: top bar + (desktop) side nav / (mobile) bottom nav */
.rw-topbar {
  display:flex; align-items:center; gap: var(--rw-space-4);
  padding: var(--rw-space-3) var(--rw-space-5); background: var(--rw-surface);
  border-bottom: 1px solid var(--rw-border); position: sticky; top: 0; z-index: 10;
}
/* Approved logo files are used UNMODIFIED. The colour SVG ships on a large blank
   canvas, so we crop the view (not the file) to the artwork's box. */
.rw-logo { height: 44px; aspect-ratio: 6957 / 2750; width: auto; display:block; }
.rw-logo--light { object-fit: cover; object-view-box: inset(35.28% 28.54% 34.64% 28.66%); }
.rw-logo--dark { display:none; }
:root[data-theme="dark"] .rw-logo--light { display:none; }
:root[data-theme="dark"] .rw-logo--dark { display:block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .rw-logo--light { display:none; }
  :root:not([data-theme="light"]) .rw-logo--dark { display:block; }
}
.rw-spacer { flex: 1; }

.rw-nav { display:flex; flex-direction:column; gap: 2px; }
.rw-nav a {
  display:flex; align-items:center; gap: var(--rw-space-3); min-height: var(--rw-touch);
  padding: 0 var(--rw-space-4); border-radius: var(--rw-radius-sm);
  color: var(--rw-text); text-decoration:none; font-weight: 500;
}
.rw-nav a:hover { background: var(--rw-surface-alt); }
.rw-nav a[aria-current="page"] { background: var(--rw-surface-alt); box-shadow: inset 3px 0 0 var(--rw-accent); font-weight: 600; }
.rw-nav svg { width: 22px; height: 22px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; }

/* ---- Buttons: one primary per screen, text says exactly what happens */
.rw-btn {
  display:inline-flex; align-items:center; justify-content:center; gap: var(--rw-space-2);
  min-height: var(--rw-touch); padding: 0 var(--rw-space-5); border-radius: var(--rw-radius-sm);
  font: 600 var(--rw-text-md)/1 var(--rw-font-ui); cursor:pointer; text-decoration:none;
  border: 1px solid transparent; transition: background var(--rw-dur-fast) var(--rw-ease);
}
.rw-btn--primary { background: var(--rw-primary); color: var(--rw-on-primary); }
.rw-btn--primary:hover { filter: brightness(1.12); }
.rw-btn--secondary { background: transparent; color: var(--rw-text); border-color: var(--rw-border-strong); }
.rw-btn--secondary:hover { background: var(--rw-surface-alt); }
.rw-btn[disabled] { opacity: .45; cursor: not-allowed; }

/* ---- Segmented control (language, theme, period) */
.rw-seg { display:inline-flex; border:1px solid var(--rw-border-strong); border-radius: var(--rw-radius-sm); overflow:hidden; }
.rw-seg button {
  min-height: 40px; min-width: 44px; padding: 0 var(--rw-space-3); border:0; background: transparent;
  color: var(--rw-text); font: 500 var(--rw-text-sm)/1 var(--rw-font-ui); cursor:pointer;
}
.rw-seg button + button { border-left: 1px solid var(--rw-border); }
.rw-seg button[aria-pressed="true"] { background: var(--rw-primary); color: var(--rw-on-primary); }

/* ---- Panel: flat, hairline border. Shadows are for overlays, not panels */
.rw-panel { background: var(--rw-surface); border: 1px solid var(--rw-border); border-radius: var(--rw-radius-md); padding: var(--rw-space-5); }
.rw-panel__head { display:flex; align-items:baseline; justify-content:space-between; gap: var(--rw-space-3); margin-bottom: var(--rw-space-4); }

/* ---- The signature: gold double hairline, used ONCE per screen (the hero figure) */
.rw-hallmark {
  position:relative; background: var(--rw-surface-alt); border-radius: var(--rw-radius-md);
  padding: var(--rw-space-6); border: 1px solid var(--rw-accent);
  box-shadow: inset 0 0 0 4px var(--rw-surface-alt), inset 0 0 0 5px color-mix(in srgb, var(--rw-accent) 55%, transparent);
}
.rw-figure { font: 600 var(--rw-text-3xl)/1.05 var(--rw-font-display); letter-spacing: -.015em; }

/* ---- Key figures row (not identical cards: dividers, no boxes) */
.rw-facts { display:grid; grid-template-columns: repeat(auto-fit, minmax(160px,1fr)); gap: 0; }
.rw-fact { padding: var(--rw-space-2) var(--rw-space-4); border-left: 1px solid var(--rw-border); }
.rw-fact:first-child { border-left: 0; padding-left: 0; }
.rw-fact dt { color: var(--rw-text-muted); font-size: var(--rw-text-sm); }
.rw-fact dd { margin: 2px 0 0; font-weight: 600; font-size: var(--rw-text-xl); }

/* ---- Status chip: icon + word, never colour alone */
.rw-chip { display:inline-flex; align-items:center; gap: 6px; padding: 3px 10px; border-radius: var(--rw-radius-pill); font-size: var(--rw-text-sm); font-weight: 600; white-space: nowrap; }
.rw-chip svg { width: 14px; height: 14px; stroke: currentColor; fill:none; stroke-width: 2.4; }
.rw-chip--ok { color: var(--rw-ok); background: var(--rw-ok-bg); }
.rw-chip--warn { color: var(--rw-warn); background: var(--rw-warn-bg); }
.rw-chip--danger { color: var(--rw-danger); background: var(--rw-danger-bg); }
.rw-chip--info { color: var(--rw-info); background: var(--rw-info-bg); }

/* ---- Table: tabular figures, right-aligned money, becomes stacked rows on phones */
.rw-table { width:100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.rw-table th { text-align:left; font-size: var(--rw-text-sm); font-weight: 600; color: var(--rw-text-muted); padding: var(--rw-space-2) var(--rw-space-3); border-bottom: 1px solid var(--rw-border-strong); }
.rw-table td { padding: var(--rw-space-3); border-bottom: 1px solid var(--rw-border); vertical-align: middle; }
.rw-table .r { text-align: right; }
.rw-table tbody tr:hover { background: var(--rw-surface-alt); }
@media (max-width: 640px) {
  .rw-table--stack thead { position:absolute; left:-9999px; }
  .rw-table--stack tr { display:block; border-bottom: 1px solid var(--rw-border); padding: var(--rw-space-2) 0; }
  .rw-table--stack td { display:flex; justify-content:space-between; gap: var(--rw-space-3); border:0; padding: 6px 0; }
  .rw-table--stack td::before { content: attr(data-label); color: var(--rw-text-muted); font-size: var(--rw-text-sm); }
  .rw-table--stack .r { text-align:right; }
}

/* ---- Forms: label above field, hint below, error says how to fix */
.rw-field { display:grid; gap: 6px; }
.rw-field label { font-weight: 600; }
.rw-input {
  min-height: var(--rw-touch); padding: 0 var(--rw-space-4); border-radius: var(--rw-radius-sm);
  border: 1px solid var(--rw-border-strong); background: var(--rw-surface); color: var(--rw-text);
  font: 400 var(--rw-text-md) var(--rw-font-ui);
}
.rw-hint { font-size: var(--rw-text-sm); color: var(--rw-text-muted); }

/* ---- Stepper (Re-KYC, onboarding): a real sequence, so numbered */
.rw-steps { display:flex; gap: var(--rw-space-2); list-style:none; padding:0; margin:0; counter-reset: s; }
.rw-steps li { flex:1; counter-increment: s; font-size: var(--rw-text-sm); color: var(--rw-text-muted); padding-top: var(--rw-space-2); border-top: 3px solid var(--rw-border); }
.rw-steps li::before { content: counter(s) ". "; font-weight: 700; }
.rw-steps li[data-state="done"] { border-color: var(--rw-ok); color: var(--rw-text); }
.rw-steps li[data-state="current"] { border-color: var(--rw-accent); color: var(--rw-text); font-weight: 600; }

/* ---- Charts (inline SVG) */
.rw-chart { width:100%; height:auto; display:block; overflow: visible; }
.rw-chart .grid { stroke: var(--rw-chart-grid); stroke-width: 1; }
.rw-chart .axis { fill: var(--rw-chart-axis); font: 500 12px var(--rw-font-ui); }
.rw-legend { display:flex; flex-wrap:wrap; gap: var(--rw-space-4); font-size: var(--rw-text-sm); color: var(--rw-text-muted); margin: 0 0 var(--rw-space-3); padding:0; list-style:none; }
.rw-legend i { display:inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.rw-tip {
  position:fixed; pointer-events:none; z-index: 50; background: var(--rw-surface); color: var(--rw-text);
  border:1px solid var(--rw-border-strong); border-radius: var(--rw-radius-sm); box-shadow: var(--rw-shadow-2);
  padding: 8px 12px; font-size: var(--rw-text-sm); opacity:0; transition: opacity var(--rw-dur-fast);
}

/* ---- Sample-data banner: mandatory on every preview with dummy data */
.rw-sample-banner { background: var(--rw-warn-bg); color: var(--rw-warn); text-align:center; font-weight:600; font-size: var(--rw-text-sm); padding: 6px var(--rw-space-4); }
