/* VA4U platform use: shared styles (form + admin) */
:root {
  color-scheme: light;
  --bg: #f6f7f4;
  --card: #ffffff;
  --ink: #1e2e20;
  --muted: #52605a;
  --line: #d0d5dd;
  --line-soft: #eaecf0;
  --brand: #02b069;
  --brand-strong: #047a4b;
  --brand-soft: #e7f7ef;
  --danger: #b42318;
  --danger-soft: #fef3f2;
  --warn: #8a5a00;
  --warn-soft: #fff6e0;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.08);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.625;
}
img { max-width: 100%; height: auto; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 0.5rem; }
h1 { font-size: 1.75rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.0625rem; }
p { margin: 0 0 1rem; }
a { color: var(--brand-strong); }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.hidden, [hidden] { display: none !important; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

:focus-visible { outline: 3px solid var(--brand-strong); outline-offset: 2px; }

/* Layout */
.wrap { max-width: 760px; margin: 0 auto; padding: 24px 16px 64px; }
.wrap-wide { max-width: 1200px; }
.card {
  background: var(--card);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
}
.card + .card { margin-top: 16px; }
.stack > * + * { margin-top: 8px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.spacer { flex: 1; }
.logo { display: block; width: 160px; margin-bottom: 16px; }
.center-page { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 400px; }

/* Forms */
label, .label { display: block; font-weight: 600; margin-bottom: 4px; }
.hint { color: var(--muted); font-size: 14px; margin: 2px 0 8px; }
input[type="text"], input[type="email"], input[type="password"], input[type="search"], select, textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  font: inherit;
  color: inherit;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
}
textarea { min-height: 96px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--brand-strong); outline: 3px solid rgba(4, 122, 75, 0.2); outline-offset: 0; }
.field { margin-bottom: 16px; }
.field-error { color: var(--danger); font-size: 14px; margin-top: 4px; }
.honey { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 10px 18px;
  font: inherit; font-weight: 600;
  border-radius: 8px; border: 1px solid var(--line);
  background: #fff; color: var(--ink);
  cursor: pointer; text-decoration: none;
}
.btn:hover { background: #f9fafb; }
.btn-primary { background: var(--brand-strong); border-color: var(--brand-strong); color: #fff; }
.btn-primary:hover { background: #03663f; }
.btn-danger { color: var(--danger); border-color: #f4c7c3; }
.btn-danger:hover { background: var(--danger-soft); }
.btn-link { border: 0; background: none; color: var(--brand-strong); padding: 10px 8px; text-decoration: underline; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: 0.6; cursor: wait; }
.icon-btn {
  min-width: 44px; min-height: 44px; border: 0; background: none; cursor: pointer;
  font-size: 22px; line-height: 1; color: var(--muted); border-radius: 8px;
}
.icon-btn:hover { background: var(--line-soft); color: var(--ink); }

/* Alerts */
.alert { padding: 12px 14px; border-radius: 8px; margin-bottom: 16px; }
.alert-error { background: var(--danger-soft); color: var(--danger); border: 1px solid #f4c7c3; }
.alert-ok { background: var(--brand-soft); color: var(--brand-strong); border: 1px solid #b5e5cc; }
.alert-warn { background: var(--warn-soft); color: var(--warn); border: 1px solid #f3dca0; }

/* Steps on the VA form */
.step-num {
  display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%;
  background: var(--brand-soft); color: var(--brand-strong); font-weight: 700; font-size: 15px; margin-right: 8px;
}

/* ---------- Software picker ---------- */
.picker-search { position: sticky; top: 0; z-index: 2; background: var(--card); padding: 8px 0 12px; }
.picker-add { margin-top: 8px; }
.cat-title { font-size: 14px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); margin: 16px 0 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  min-height: 44px; padding: 8px 14px;
  font: inherit; font-size: 15px;
  background: #fff; color: var(--ink);
  border: 1px solid var(--line); border-radius: 999px; cursor: pointer;
}
.chip:hover { border-color: var(--brand-strong); }
.chip[aria-pressed="true"] { background: var(--brand-soft); border-color: var(--brand-strong); color: var(--brand-strong); font-weight: 600; }
.chip[aria-pressed="true"]::before { content: "✓ "; }
details.cat { border-top: 1px solid var(--line-soft); }
details.cat:last-of-type { border-bottom: 1px solid var(--line-soft); }
details.cat summary { min-height: 48px; display: flex; align-items: center; gap: 6px; cursor: pointer; font-weight: 600; list-style: none; }
details.cat summary::-webkit-details-marker { display: none; }
details.cat summary::before { content: "+"; display: inline-grid; place-items: center; width: 24px; color: var(--brand-strong); font-size: 20px; }
details.cat[open] summary::before { content: "–"; }
details.cat .chips { padding: 0 0 14px; }
.picker-empty { color: var(--muted); padding: 8px 0; }

.sel-list { list-style: none; padding: 0; margin: 0; container-type: inline-size; }
.sel {
  display: grid; grid-template-columns: 1fr auto; grid-template-areas: "name remove" "controls controls" "err err";
  align-items: center; gap: 4px 12px;
  border: 1px solid var(--line-soft); border-radius: 10px; padding: 8px 8px 10px 14px; margin-bottom: 8px; background: #fff;
}
.sel.missing { border-color: var(--danger); background: var(--danger-soft); }
.sel-name { grid-area: name; font-size: 17px; }
.sel-controls { grid-area: controls; display: flex; flex-wrap: wrap; gap: 8px; }
.sel-remove { grid-area: remove; }
.sel-error { grid-area: err; margin: 0; }
@container (min-width: 760px) {
  .sel { grid-template-columns: minmax(160px, 1fr) auto auto; grid-template-areas: "name controls remove" "err err err"; padding: 6px 6px 6px 14px; }
}
.seg { border: 0; padding: 0; margin: 0; min-width: 0; }
.seg-opts { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; flex-wrap: wrap; background: #fff; }
.seg-opts label { margin: 0; font-weight: 500; cursor: pointer; position: relative; }
.seg-opts input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.seg-opts span { display: inline-flex; align-items: center; min-height: 44px; padding: 8px 12px; font-size: 15px; border-right: 1px solid var(--line); }
.seg-opts label:last-child span { border-right: 0; }
.seg-opts input:checked + span { background: var(--brand-strong); color: #fff; font-weight: 600; }
.seg-opts input:focus-visible + span { outline: 3px solid var(--brand-strong); outline-offset: -3px; }
.badge {
  display: inline-block; font-size: 14px; font-weight: 600; padding: 1px 8px; border-radius: 999px;
  background: var(--line-soft); color: var(--muted);
}
.badge-new { background: var(--warn-soft); color: var(--warn); }
.badge-green { background: var(--brand-soft); color: var(--brand-strong); }

/* ---------- Admin ---------- */
.topbar { background: #fff; border-bottom: 1px solid var(--line-soft); }
.topbar-inner { max-width: 1200px; margin: 0 auto; padding: 8px 16px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.topbar .logo { width: 110px; margin: 0 12px 0 0; }
.nav a {
  display: inline-flex; align-items: center; min-height: 44px; padding: 0 12px;
  border-radius: 8px; text-decoration: none; color: var(--ink); font-weight: 600;
}
.nav a[aria-current="page"] { background: var(--brand-soft); color: var(--brand-strong); }

.filters { display: grid; gap: 12px; grid-template-columns: 2fr 2fr 1fr; align-items: end; }
@media (max-width: 960px) { .filters { grid-template-columns: 1fr 1fr; } }
.check { display: flex; align-items: center; gap: 8px; min-height: 44px; margin-top: 8px; font-weight: 500; cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--brand-strong); }
#sw-extra select { width: auto; }
@media (max-width: 560px) { .filters { grid-template-columns: 1fr; } }
.filter-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.filter-chip {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 4px 2px 12px; border-radius: 999px;
  background: var(--brand-soft); color: var(--brand-strong); font-weight: 600; font-size: 15px;
}
.filter-chip button { min-width: 36px; min-height: 36px; border: 0; background: none; color: inherit; font-size: 18px; cursor: pointer; border-radius: 999px; }

.summary { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 16px 0 8px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; background: #fff; }
th, td { text-align: left; padding: 12px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
th { font-size: 14px; color: var(--muted); font-weight: 600; white-space: nowrap; }
tbody tr:hover { background: #fafbfa; }
td a.va-link { font-weight: 600; text-decoration: none; }
td a.va-link:hover { text-decoration: underline; }
.tags { display: flex; flex-wrap: wrap; gap: 4px; }
.tag { font-size: 14px; padding: 1px 8px; border-radius: 6px; border: 1px solid var(--line); white-space: nowrap; }
.tag-current { background: var(--brand-soft); border-color: #b5e5cc; color: var(--ink); }
.tag-match { outline: 2px solid var(--brand-strong); }
.tag small { color: var(--muted); font-size: 14px; }

/* Cards instead of a table on phones */
@media (max-width: 720px) {
  table, thead, tbody, tr, td { display: block; }
  thead { display: none; }
  tbody tr { border: 1px solid var(--line-soft); border-radius: 10px; margin-bottom: 10px; padding: 4px 0; }
  td { border: 0; padding: 6px 12px; }
  td[data-label]::before { content: attr(data-label); display: block; font-size: 14px; color: var(--muted); }
}

.grid-2 { display: grid; gap: 0 16px; grid-template-columns: 1fr 1fr; }
@media (max-width: 640px) { .grid-2 { grid-template-columns: 1fr; } }

.facts { display: grid; grid-template-columns: 120px 1fr; gap: 8px 16px; margin: 0; }
.facts dt { color: var(--muted); font-size: 15px; }
.facts dd { margin: 0; white-space: pre-wrap; }
@media (max-width: 560px) { .facts { grid-template-columns: 1fr; gap: 0; } .facts dd { margin-bottom: 10px; } }
.history-item { border-top: 1px solid var(--line-soft); padding: 12px 0; }
.history-item:first-child { border-top: 0; }

dialog { border: 0; border-radius: var(--radius); padding: 24px; width: min(480px, calc(100vw - 32px)); box-shadow: 0 20px 40px rgba(16, 24, 40, 0.2); }
dialog::backdrop { background: rgba(16, 24, 40, 0.45); }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 10px; z-index: 50;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}
.toast.error { background: var(--danger); }
