/* ==== Administration > Data retention (/admin/retention): the databases' size against their limit, how long each history
   is kept, the size guard's runs (rt-) ====
   Same look as the rest of OneStop (app.css: toolbar, panel, table, status, notice, hint). Loaded by Components\App.razor for
   every page, after app.css. Page: TTech.Platform.Client\Apps\Admin\RetentionPage.razor. The tones of the bars have a value
   for each theme below; everything else uses the tokens of app.css. Classes built in code: rt-ok, rt-near, rt-over, rt-down
   (RetentionPage.DbState) and rt-state-*. Phones: one card per row, each kind of history one column (700 px and below). */
:root {
  --rt-ok: #3f9a4a;
  --rt-near: #cc8424;
  --rt-over: #b83a3a;
}
:root[data-theme="dark"] {
  --rt-ok: #4cc354;
  --rt-near: #e3a54d;
  --rt-over: #f08585;
}

.rt-notice { background: var(--warn-soft); color: var(--warn); }

/* ---- The databases: one card each ---- */
.rt-dbs {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr));
  gap: 12px;
  align-items: start;
}
.rt-db {
  --rt-tone: var(--rt-ok);
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow: hidden;
  padding-top: 18px;
}
.rt-db::before { position: absolute; inset: 0 0 auto 0; height: 4px; background: var(--rt-tone); content: ""; }
.rt-db.rt-near { --rt-tone: var(--rt-near); }
.rt-db.rt-over { --rt-tone: var(--rt-over); }
.rt-db.rt-down { --rt-tone: var(--faint); }

/* The state goes under the name when the card is too narrow for both, so the name keeps its own line */
.rt-db-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.rt-db-head > .status { margin-left: auto; }
.rt-db-icon {
  display: grid;
  flex: none;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent-strong);
}
.rt-db-title { display: flex; flex: 1 1 12rem; flex-direction: column; min-width: 0; }
.rt-db-title h2 { margin: 0; font-size: 1.02rem; font-weight: 800; overflow-wrap: anywhere; }
.rt-db-title .sub { color: var(--muted); font-size: 0.76rem; overflow-wrap: anywhere; }
.status.rt-state-ok { background: var(--good-soft); color: var(--good-text); }
.status.rt-state-near { background: var(--warn-soft); color: var(--warn); }
.status.rt-state-over { background: var(--bad-soft); color: var(--bad); }
.status.rt-state-down { background: var(--chip); color: var(--muted); }

.rt-gauge { display: flex; flex-direction: column; gap: 6px; }
.rt-figure { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; }
.rt-figure strong { font-size: 1.65rem; font-weight: 900; line-height: 1.1; font-variant-numeric: tabular-nums; }
.rt-figure > span:not(.rt-pct) { color: var(--muted); font-size: 0.85rem; }
.rt-pct { margin-left: auto; color: var(--rt-tone); font-size: 0.95rem; font-weight: 900; font-variant-numeric: tabular-nums; }
.rt-bar { position: relative; height: 12px; border-radius: 999px; background: var(--chip); }
.rt-fill {
  position: absolute;
  inset: 0 auto 0 0;
  border-radius: inherit;
  background: var(--rt-tone);
  transition: width 0.4s ease;
}
.rt-target {
  position: absolute;
  top: -4px;
  bottom: -4px;
  width: 3px;
  margin-left: -1px;
  border: 1px solid var(--panel);
  border-radius: 2px;
  background: var(--text);
}
.rt-scale { display: flex; justify-content: space-between; color: var(--muted); font-size: 0.74rem; font-variant-numeric: tabular-nums; }
.rt-db-facts { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 6px; margin: 0 !important; }
.rt-legend { display: inline-flex; align-items: center; gap: 6px; }
.rt-legend-mark { display: inline-block; width: 3px; height: 12px; border-radius: 2px; background: var(--text); }
.rt-stuck { font-size: 0.84rem; }

.panel h3.rt-h3 {
  display: flex;
  align-items: center;
  gap: 4px;
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.4px;
  text-transform: uppercase;
}
.rt-tables { display: flex; flex-direction: column; gap: 7px; margin: 0; padding: 0; list-style: none; }
.rt-tables li {
  display: grid;
  grid-template-areas: "name size" "bar rows";
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 3px 12px;
  font-size: 0.82rem;
}
.rt-t-name { grid-area: name; min-width: 0; overflow-wrap: anywhere; }
.rt-t-size { grid-area: size; font-weight: 800; font-variant-numeric: tabular-nums; text-align: right; }
.rt-t-rows { grid-area: rows; color: var(--muted); font-size: 0.74rem; font-variant-numeric: tabular-nums; text-align: right; }
.rt-t-bar { grid-area: bar; align-self: center; height: 5px; overflow: hidden; border-radius: 999px; background: var(--chip); }
.rt-t-bar > span { display: block; height: 100%; border-radius: inherit; background: var(--faint); }
.rt-history .rt-t-bar > span { background: var(--accent); }
.rt-chip {
  display: inline-block;
  margin-left: 6px;
  padding: 0 7px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 0.68rem;
  font-weight: 800;
  vertical-align: 1px;
}
.panel p.rt-business { margin: 0; }

/* The limit of a database: a fold at the bottom of its card */
.rt-limit { margin-top: auto; padding-top: 10px; border-top: 1px solid var(--rule); }
.rt-limit summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 10px;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 800;
  list-style: none;
}
.rt-limit summary::-webkit-details-marker { display: none; }
.rt-limit summary::before { color: var(--muted); content: "\25B8"; transition: transform 0.15s ease; }
.rt-limit[open] summary::before { transform: rotate(90deg); }
.rt-limit summary:focus-visible { border-radius: 6px; outline: 2px solid var(--accent); outline-offset: 2px; }
.rt-limit-now { margin-left: auto; color: var(--muted); font-size: 0.78rem; font-weight: 600; }
.rt-limit-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 10px; }
.rt-field { display: flex; flex-direction: column; gap: 4px; color: var(--muted); font-size: 0.78rem; font-weight: 800; }
.rt-field > span { display: flex; align-items: center; gap: 4px; }
.rt-limit-actions { display: flex; flex-wrap: wrap; grid-column: 1 / -1; gap: 8px; }
.rt-limit-form > .hint, .rt-limit-form > .rt-error, .rt-limit-form > .rt-warn { grid-column: 1 / -1; margin: 0; }

/* Fields of the page (the look of app.css's inputs) */
.rt-field input, .rt-days, .rt-select {
  min-width: 0;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--field);
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
}
.rt-field input:focus, .rt-days:focus, .rt-select:focus { border-color: var(--accent); outline: 2px solid var(--accent-soft); }
.rt-field input[aria-invalid="true"], .rt-days[aria-invalid="true"] { border-color: var(--bad); }
.rt-error { color: var(--bad); font-size: 0.78rem; font-weight: 700; }
.rt-warn { color: var(--warn); font-size: 0.78rem; font-weight: 700; }

/* ---- The kinds of history: one row each (name and meaning | tables | kept) ---- */
.rt-kinds { display: flex; flex-direction: column; }
.rt-kind {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1.15fr) minmax(250px, 0.95fr);
  gap: 8px 20px;
  align-items: start;
  padding: 12px 10px;
  border-top: 1px solid var(--rule);
}
.rt-kind:first-child { border-top: 0; }
.rt-kind.rt-dirty { border-radius: 8px; background: var(--note-soft); }
.rt-kind-name strong { display: block; font-size: 0.92rem; }
.rt-kind-what { display: block; margin-top: 3px; color: var(--muted); font-size: 0.8rem; line-height: 1.4; }
.rt-kind-tables { display: flex; flex-direction: column; gap: 6px; min-width: 0; font-size: 0.82rem; }
.rt-kind-table code { overflow-wrap: anywhere; }
.rt-kind-table .sub { display: block; margin-top: 2px; color: var(--muted); font-size: 0.76rem; }
.rt-kind-table .rt-muted-error { color: var(--warn); }
.rt-kind-keep { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.rt-keep-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.rt-select { flex: 1 1 160px; max-width: 100%; cursor: pointer; }
.rt-days { width: 90px; font-variant-numeric: tabular-nums; text-align: right; }
.rt-unit { color: var(--muted); font-size: 0.85rem; }
.rt-range, .rt-source { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; color: var(--muted); font-size: 0.76rem; }
.rt-source { color: var(--faint); }
.rt-dirty-count { color: var(--warn); font-size: 0.8rem; font-weight: 700; }

/* ---- The size guard ---- */
.rt-running { display: inline-flex; align-items: center; gap: 6px; }
.rt-running .rt-spin { width: 12px; height: 12px; color: inherit; }
.rt-runs .rt-run-what { min-width: 260px; font-size: 0.8rem; }
.rt-runs .rt-run-what > div { margin: 1px 0; overflow-wrap: anywhere; }
.rt-runs .sub.rt-run-note { color: var(--bad); }
.rt-measured-over { color: var(--bad); font-weight: 700; }
.empty.rt-empty { min-height: 80px; }

/* ---- Narrower screens ---- */
@media (max-width: 1100px) {
  .rt-kind { grid-template-columns: minmax(0, 1fr) minmax(230px, 0.9fr); }
  .rt-kind-name { grid-column: 1; grid-row: 1; }
  .rt-kind-tables { grid-column: 1; grid-row: 2; }
  .rt-kind-keep { grid-column: 2; grid-row: 1 / span 2; }
}
@media (max-width: 700px) {
  .rt-kind { grid-template-columns: minmax(0, 1fr); padding: 12px 4px; }
  .rt-kind-name, .rt-kind-tables, .rt-kind-keep { grid-column: auto; grid-row: auto; }
  .rt-limit-form { grid-template-columns: minmax(0, 1fr); }
  .rt-figure strong { font-size: 1.4rem; }
  .rt-limit-now { margin-left: 0; flex-basis: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  .rt-fill, .rt-limit summary::before { transition: none; }
}
