/* Halyard web app.
   The Corporate view's tokens and typography from site/assets/site.css, used
   loosely: this is a working product UI, not a marketing page. No web fonts
   (the app's CSP is self-only and the stack below is already on the box).

   Contrast note: --fg on --bg is 17.9:1, --mut on --bg2 is 5.7:1, --mut on
   --bg3 is 5.1:1, white on --acc is 5.2:1. All pass WCAG AA for body text.
   Every control keeps a visible focus ring; nothing is sized below 44px in a
   touch context. */

:root {
  --bg: #0b0b0c;
  --bg2: #131316;
  --bg3: #1b1b1f;
  --fg: #f4f4f5;
  --mut: #a1a1aa;
  --bd: #26262a;
  --bd2: #3a3a40;
  --acc: #2864f0;
  --acc2: #7fa3ff;
  --ok: #70d9b2;
  --warn: #ffd166;
  --bad: #ff8a7a;
  --f-ui: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  --f-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --r: 10px;
  --pad: 20px;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  overflow-wrap: break-word;
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.55 var(--f-ui);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--acc2); }
a:hover { color: var(--fg); }
:focus-visible { outline: 3px solid var(--acc2); outline-offset: 2px; border-radius: 4px; }
img, svg { max-width: 100%; }
h1, h2, h3 { margin: 0; letter-spacing: -0.02em; line-height: 1.15; }
h1 { font-size: clamp(26px, 5vw, 36px); font-weight: 650; }
h2 { font-size: 20px; font-weight: 650; }
h3 { font-size: 17px; font-weight: 650; }
p { margin: 0; }
code, .mono { font-family: var(--f-mono); font-size: 0.92em; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip {
  position: absolute; left: 12px; top: -80px; z-index: 50;
  background: var(--fg); color: var(--bg); padding: 10px 14px;
  border-radius: 6px; font-weight: 600;
}
.skip:focus { top: 12px; }
[hidden] { display: none !important; }

/* ---------- Shell ---------- */
.top {
  border-bottom: 1px solid var(--bd);
  background: var(--bg);
  position: sticky; top: 0; z-index: 20;
}
.top-in {
  max-width: 1180px; margin: 0 auto; padding: 10px var(--pad);
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
}
.logo {
  display: inline-flex; align-items: center; gap: 9px;
  text-decoration: none; color: var(--fg); font-weight: 700; font-size: 18px;
  letter-spacing: -0.02em; min-height: 44px;
}
.logo-mark { width: 22px; height: 22px; flex: none; }
.top-r { margin-left: auto; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.who { color: var(--mut); font-size: 14px; max-width: 22ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.nav {
  border-bottom: 1px solid var(--bd);
  background: var(--bg2);
  overflow-x: auto;
  scrollbar-width: thin;
}
.nav-in {
  max-width: 1180px; margin: 0 auto; padding: 0 var(--pad);
  display: flex; gap: 2px; min-height: 48px; align-items: stretch;
}
.nav a {
  display: inline-flex; align-items: center; padding: 0 14px;
  color: var(--mut); text-decoration: none; font-size: 15px; font-weight: 500;
  border-bottom: 2px solid transparent; white-space: nowrap; min-height: 44px;
}
.nav a:hover { color: var(--fg); }
.nav a[aria-current="page"] { color: var(--fg); border-bottom-color: var(--acc2); }

.main { max-width: 1180px; margin: 0 auto; padding: 28px var(--pad) 72px; }
.page-head { display: flex; gap: 16px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 22px; }
.page-head .grow { flex: 1 1 320px; min-width: 0; }
.page-head p.lede { color: var(--mut); margin-top: 6px; max-width: 68ch; }
.stack { display: flex; flex-direction: column; gap: 20px; }
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(min(260px, 100%), 1fr)); }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.row.tight { gap: 8px; }

/* ---------- Cards ---------- */
.card {
  border: 1px solid var(--bd); border-radius: var(--r);
  background: var(--bg2); padding: var(--pad);
  display: flex; flex-direction: column; gap: 12px; min-width: 0;
}
.card.flat { background: var(--bg); }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.big { font-family: var(--f-mono); font-size: clamp(28px, 5vw, 38px); font-weight: 600; letter-spacing: -0.02em; }
.mid { font-family: var(--f-mono); font-size: 20px; font-weight: 600; }
.mut { color: var(--mut); }
.small { font-size: 14px; }
.tiny { font-size: 12.5px; }
.warn-text { color: var(--warn); }
.bad-text { color: var(--bad); }
.ok-text { color: var(--ok); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 18px; border-radius: 7px;
  border: 1px solid var(--bd2); background: transparent; color: var(--fg);
  font: 600 15px var(--f-ui); text-decoration: none; cursor: pointer;
}
.btn:hover { border-color: var(--mut); color: var(--fg); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.55; cursor: not-allowed; }
.btn.pri { background: var(--acc); border-color: var(--acc); color: #fff; }
.btn.pri:hover { background: #1f55d6; border-color: #1f55d6; color: #fff; }
.btn.inv { background: var(--fg); border-color: var(--fg); color: var(--bg); }
.btn.danger { border-color: #7a3a34; color: var(--bad); }
.btn.danger:hover { background: #2a1715; border-color: var(--bad); }
.btn.link { border: 0; padding: 0 6px; min-height: 32px; color: var(--acc2); text-decoration: underline; }
.btn.sm { min-height: 36px; padding: 0 12px; font-size: 14px; }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label { font-weight: 600; font-size: 14px; }
.field .hint { color: var(--mut); font-size: 13px; }
input[type="text"], input[type="email"], input[type="search"], input[type="date"], select, textarea {
  width: 100%; min-height: 44px; padding: 10px 12px;
  background: var(--bg); color: var(--fg);
  border: 1px solid var(--bd2); border-radius: 7px;
  font: 16px var(--f-ui);
}
input::placeholder, textarea::placeholder { color: #7a7a82; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid var(--acc2); outline-offset: 1px; }
fieldset { border: 1px solid var(--bd); border-radius: var(--r); padding: 14px; margin: 0; }
legend { padding: 0 6px; font-weight: 600; font-size: 14px; }
.check { display: flex; gap: 10px; align-items: flex-start; min-height: 44px; }
.check input { width: 20px; height: 20px; margin-top: 3px; accent-color: var(--acc); }
.filters { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(min(190px, 100%), 1fr)); }

/* ---------- Pills and banners ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  font: 600 12.5px var(--f-ui); padding: 3px 9px; border-radius: 999px;
  border: 1px solid var(--bd2); color: var(--mut); white-space: nowrap;
}
.pill.ok { border-color: #2f6b56; color: var(--ok); }
.pill.bad { border-color: #7a3a34; color: var(--bad); }
.pill.warn { border-color: #6d5a22; color: var(--warn); }
.pill.acc { border-color: #2b4b96; color: var(--acc2); }
.banner {
  border: 1px solid var(--bd2); border-left: 4px solid var(--acc);
  border-radius: 8px; background: var(--bg2); padding: 14px 16px;
  display: flex; flex-direction: column; gap: 6px;
}
.banner.warn { border-left-color: var(--warn); }
.banner.bad { border-left-color: var(--bad); }
.banner.ok { border-left-color: var(--ok); }

/* ---------- Tables ---------- */
.tablewrap { overflow-x: auto; border: 1px solid var(--bd); border-radius: var(--r); }
table { width: 100%; border-collapse: collapse; font-size: 15px; }
@media (min-width: 641px) { table { min-width: 560px; } }
caption { text-align: left; padding: 12px 14px; color: var(--mut); font-size: 14px; }
th, td { text-align: left; padding: 12px 14px; border-top: 1px solid var(--bd); vertical-align: top; }
thead th { border-top: 0; color: var(--mut); font-size: 13px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; background: var(--bg3); }
tbody tr:hover { background: #16161a; }
td.num, th.num { text-align: right; font-family: var(--f-mono); white-space: nowrap; }
td.actions { white-space: nowrap; }

/* Cards instead of a table under 640px: a 375px screen cannot scroll a table
   comfortably, so each row becomes a labelled block. */
@media (max-width: 640px) {
  .rtable thead { display: none; }
  .rtable, .rtable tbody, .rtable tr, .rtable td { display: block; width: 100%; }
  .rtable tr { border-top: 1px solid var(--bd); padding: 8px 0; }
  .rtable tr:first-child { border-top: 0; }
  .rtable td { border: 0; padding: 6px 14px; }
  .rtable td[data-label]::before {
    content: attr(data-label);
    display: block; color: var(--mut); font-size: 12px; text-transform: uppercase;
    letter-spacing: 0.05em; margin-bottom: 2px;
  }
  .rtable td.num { text-align: left; }
}

/* ---------- Lists and details ---------- */
.deflist { display: grid; grid-template-columns: minmax(120px, 200px) 1fr; gap: 8px 20px; margin: 0; }
.deflist dt { color: var(--mut); font-size: 14px; }
.deflist dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
@media (max-width: 560px) {
  .deflist { grid-template-columns: 1fr; gap: 2px; }
  .deflist dt { margin-top: 10px; }
  .top-in { padding: 8px 14px; }
  .who { max-width: 14ch; }
  .main { padding: 20px 14px 56px; }
}
ul.plain { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.item {
  display: flex; gap: 14px; justify-content: space-between; align-items: flex-start;
  padding: 14px 0; border-top: 1px solid var(--bd); flex-wrap: wrap;
}
.item:first-child { border-top: 0; }
.item .meta { color: var(--mut); font-size: 14px; }

/* ---------- States ---------- */
.empty {
  border: 1px dashed var(--bd2); border-radius: var(--r);
  padding: 32px 20px; text-align: center;
  display: flex; flex-direction: column; gap: 10px; align-items: center;
}
.empty h2 { font-size: 18px; }
.empty p { color: var(--mut); max-width: 52ch; }
.failed {
  border: 1px solid #7a3a34; border-radius: var(--r); background: #1b1211;
  padding: 20px; display: flex; flex-direction: column; gap: 10px; align-items: flex-start;
}
.failed h2 { font-size: 18px; color: var(--bad); }
.skeleton { display: flex; flex-direction: column; gap: 10px; }
.skel-bar {
  height: 18px; border-radius: 5px;
  background: linear-gradient(90deg, #1b1b1f 25%, #24242a 50%, #1b1b1f 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
}
.skel-bar.short { width: 45%; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) {
  .skel-bar { animation: none; }
}
.spin {
  display: inline-block; width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid var(--bd2); border-top-color: var(--acc2);
  animation: spin 0.8s linear infinite; vertical-align: -2px;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spin { animation: none; } }

/* ---------- Dialog ---------- */
dialog {
  border: 1px solid var(--bd2); border-radius: 12px; background: var(--bg2);
  color: var(--fg); padding: 24px; max-width: min(480px, calc(100vw - 32px));
  width: 100%;
}
dialog::backdrop { background: rgba(0, 0, 0, 0.65); }
dialog h2 { margin-bottom: 8px; }
dialog .row { justify-content: flex-end; margin-top: 8px; }

/* ---------- Secret panel ---------- */
.secret {
  border: 1px solid #6d5a22; background: #1c190e; border-radius: var(--r);
  padding: 16px; display: flex; flex-direction: column; gap: 10px;
}
.secret code {
  display: block; background: var(--bg); border: 1px solid var(--bd2);
  border-radius: 7px; padding: 12px; overflow-wrap: anywhere;
  font-size: 14px; user-select: all;
}

/* ---------- Sign-in ---------- */
.center-col { max-width: 460px; margin: 0 auto; display: flex; flex-direction: column; gap: 18px; }
.signin-art { display: flex; justify-content: center; padding: 20px 0 4px; }

/* ---------- Footer ---------- */
.foot {
  border-top: 1px solid var(--bd); color: var(--mut); font-size: 13.5px;
  padding: 24px var(--pad) 40px; text-align: center;
}
.foot a { color: var(--mut); }
