/* Q Cista – visaren på /valv. Bygger på /style.css (Q Signum, ljust läge). */

:root {
  --ok: #1d7a46;
  --ok-soft: color-mix(in srgb, var(--ok) 10%, transparent);
  --danger: #b3261e;
  --danger-soft: color-mix(in srgb, var(--danger) 10%, transparent);
  --mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
}

.valv { padding-bottom: 64px; }
.valv h2 { font-family: var(--font-serif); font-weight: 400; font-size: 32px; line-height: 1.1; margin: 8px 0 16px; overflow-wrap: anywhere; }
.valv h3 { font-size: 16px; font-weight: 700; margin: 28px 0 10px; overflow-wrap: anywhere; }
.valv code, .mono { font-family: var(--mono); font-size: 0.86em; overflow-wrap: anywhere; word-break: break-word; }
.muted { color: var(--text-muted); font-size: 14px; }
.empty { color: var(--text-muted); font-size: 15px; padding: 8px 0; }
[hidden] { display: none !important; }

/* Öppna */
.open { padding: 48px 0 0; max-width: 720px; }
.open-card { border: 1px solid var(--border); border-radius: var(--radius-card); padding: 24px; margin: 28px 0 24px; display: grid; gap: 14px; }
.drop {
  display: grid; gap: 4px; justify-items: center; text-align: center;
  border: 1.5px dashed var(--border); border-radius: var(--radius-card);
  padding: 28px 16px; cursor: pointer; background: var(--bg-subtle);
  transition: border-color .15s, background .15s;
}
.drop:hover, .drop.dragging { border-color: var(--primary); background: var(--primary-soft); }
.drop:focus-within { outline: 2px solid var(--primary); outline-offset: 2px; }
.drop.has-file { border-style: solid; border-color: var(--primary); }
.drop input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.drop-title { font-weight: 700; color: var(--primary); }
.drop-sub { font-size: 14px; color: var(--text-sub); }
.drop-file { font-size: 14px; margin-top: 6px; overflow-wrap: anywhere; }

.field { display: grid; gap: 6px; font-size: 14px; font-weight: 600; min-width: 0; }
.field input, .field select {
  font: inherit; font-weight: 400; font-size: 16px; color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-btn);
  padding: 10px 12px; background: var(--bg); width: 100%; min-width: 0;
}
#key { font-family: var(--mono); letter-spacing: 0.04em; }
.field input:focus, .field select:focus { outline: 2px solid var(--primary); outline-offset: 1px; border-color: var(--primary); }
.check { display: inline-flex; gap: 8px; align-items: center; font-size: 14px; color: var(--text-sub); }
.help { font-size: 13px; color: var(--text-muted); }

.btn {
  font: inherit; font-weight: 600; font-size: 15px; border-radius: var(--radius-btn);
  padding: 10px 18px; cursor: pointer; border: 1px solid transparent;
}
.btn-primary { background: var(--primary); color: #fff; justify-self: start; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-primary:disabled { opacity: .6; cursor: progress; }
.btn-secondary { background: var(--bg); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { border-color: var(--primary); color: var(--primary); }
.btn-ghost { background: transparent; color: var(--primary); border-color: var(--border); padding: 6px 12px; font-size: 14px; }
.btn-small { font-size: 13px; padding: 4px 10px; margin-top: 8px; }
.btn:focus-visible, .link:focus-visible, .tabs button:focus-visible, tr.clickable:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.link { font: inherit; background: none; border: 0; color: var(--primary); cursor: pointer; padding: 0; text-align: left; overflow-wrap: anywhere; }
.link:hover { text-decoration: underline; }

.status { font-size: 15px; min-height: 1.5em; }
.status-info { color: var(--text-sub); }
.status-error { color: var(--danger); background: var(--danger-soft); border-radius: var(--radius-btn); padding: 10px 12px; }

.facts-list { list-style: none; margin-bottom: 24px; }
.facts-list li { position: relative; padding-left: 22px; margin: 6px 0; color: var(--text-sub); font-size: 15px; }
.facts-list li::before { content: ''; position: absolute; left: 4px; top: 0.6em; width: 7px; height: 7px; border-radius: 50%; background: var(--primary); }

/* Visaren */
.viewer { padding-top: 28px; }
.viewer-bar { display: flex; gap: 16px; align-items: flex-start; justify-content: space-between; margin-bottom: 20px; }
.verified { background: var(--ok-soft); border: 1px solid color-mix(in srgb, var(--ok) 35%, transparent); border-radius: var(--radius-card); padding: 12px 16px; font-size: 15px; flex: 1; min-width: 0; }
.verified strong { color: var(--ok); }

.tabs { display: flex; flex-wrap: wrap; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 20px; }
.tabs button {
  font: inherit; font-size: 15px; font-weight: 600; color: var(--text-sub);
  background: none; border: 0; border-bottom: 2px solid transparent;
  padding: 10px 12px; cursor: pointer; margin-bottom: -1px;
}
.tabs button:hover { color: var(--text); }
.tabs button[aria-selected="true"] { color: var(--primary); border-bottom-color: var(--primary); }
.panel:focus { outline: none; }

.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; margin-bottom: 24px; }
.stat { border: 1px solid var(--border); border-radius: var(--radius-card); padding: 14px 16px; display: grid; }
.stat strong { font-size: 26px; font-weight: 700; line-height: 1.1; }
.stat span { color: var(--text-sub); font-size: 14px; }
.stat small { color: var(--text-muted); font-size: 12px; margin-top: 4px; }

.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px 24px; margin: 8px 0 8px; }
.facts div { min-width: 0; }
.facts dt { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); }
.facts dd { font-size: 15px; overflow-wrap: anywhere; }

.checks { list-style: none; }
.checks li { position: relative; padding-left: 26px; margin: 6px 0; font-size: 15px; }
.checks li::before { content: '✓'; position: absolute; left: 4px; color: var(--ok); font-weight: 700; }

.badge { display: inline-block; font-size: 12px; font-weight: 600; border-radius: 4px; padding: 2px 7px; vertical-align: middle; white-space: nowrap; font-family: var(--font-ui); }
.badge-ok { color: var(--ok); background: var(--ok-soft); }
.badge-warn { color: var(--warning); background: var(--warning-soft); }
.badge-danger { color: var(--danger); background: var(--danger-soft); }
.badge-muted { color: var(--text-muted); background: var(--bg-subtle); }

.filters { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; margin-bottom: 12px; }
.filters .field { min-width: 160px; }
.filters .grow { flex: 1 1 220px; }

.table-wrap { width: 100%; }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th { text-align: left; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); padding: 8px 10px; border-bottom: 1px solid var(--border); }
table.data td { padding: 8px 10px; border-bottom: 1px solid color-mix(in srgb, var(--border) 60%, transparent); vertical-align: top; overflow-wrap: anywhere; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--bg-subtle); }
.value { font-family: var(--mono); font-size: 13px; }

.notice { margin: 8px 0 16px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 12px; }
.card.grant { padding: 18px 20px; }
.card.grant h3 { margin: 0 0 8px; overflow-wrap: anywhere; }
.card.grant .facts { grid-template-columns: 1fr; gap: 6px; }

.series { border-top: 1px solid var(--border); padding-top: 4px; margin-top: 12px; }
.chart { width: 100%; height: auto; display: block; background: var(--bg-subtle); border-radius: var(--radius-card); margin: 8px 0 6px; }
.chart .axis { stroke: var(--border); stroke-width: 1; }
.chart .line { fill: none; stroke: var(--primary); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.chart .marker { stroke: #fff; stroke-width: 1.5; }
.chart .q-stale, .chart .q-uncertain { fill: var(--warning); }
.chart .q-missing, .chart .q-bad { fill: var(--danger); }
.legend { font-size: 13px; color: var(--text-sub); display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.key { display: inline-block; width: 14px; height: 10px; border-radius: 2px; }
.key-line { height: 3px; background: var(--primary); }
.key-stale { width: 10px; border-radius: 50%; background: var(--warning); }
.key-missing { width: 10px; border-radius: 50%; background: var(--danger); margin-left: 6px; }
details summary { cursor: pointer; color: var(--primary); font-size: 14px; font-weight: 600; margin: 4px 0; }

.events { list-style: none; }
.event { border-bottom: 1px solid color-mix(in srgb, var(--border) 60%, transparent); padding: 8px 0; }
.event-head { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: baseline; font-size: 14px; }
.seq { font-family: var(--mono); font-size: 13px; color: var(--text-muted); min-width: 3.5em; }
.json { font-family: var(--mono); font-size: 12px; background: var(--bg-subtle); border-radius: var(--radius-btn); padding: 12px; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 420px; overflow: auto; }

/* Smala skärmar: tabeller blir kort, inga sidledsscroll. */
@media (max-width: 760px) {
  .open { padding-top: 32px; }
  .open-card { padding: 18px; }
  .viewer-bar { flex-direction: column; align-items: stretch; }
  .btn-secondary { align-self: flex-start; }
  .tabs { gap: 0; }
  .tabs button { padding: 8px 9px; font-size: 14px; }
  .filters .field { min-width: 0; flex: 1 1 140px; }
  .cards { grid-template-columns: 1fr; }
  table.data thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  table.data, table.data tbody, table.data tr, table.data td { display: block; width: 100%; }
  table.data tr { border: 1px solid var(--border); border-radius: var(--radius-card); padding: 6px 4px; margin-bottom: 8px; }
  table.data td { border: 0; padding: 3px 8px; display: grid; grid-template-columns: minmax(84px, 34%) 1fr; gap: 8px; }
  table.data td .badge { justify-self: start; }
  table.data td::before { content: attr(data-label); font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); padding-top: 2px; }
}
