/* ==========================================================================
   SupTools — shared design system
   ========================================================================== */

:root {
  --navy-900: #001f3f;
  --navy-800: #003366;
  --navy-700: #0a4278;
  --navy-600: #135a9c;
  --accent:   #2f8fd6;
  --accent-soft: #e6f1fa;

  --ink:      #16212e;
  --ink-soft: #4a5a6b;
  --ink-faint:#8494a4;

  --bg:       #f4f6f9;
  --surface:  #ffffff;
  --line:     #dfe5ec;

  --good:     #63be7b;
  --mid:      #ffeb84;
  --bad:      #f8696b;

  --radius:   14px;
  --radius-sm: 9px;
  --shadow-sm: 0 1px 2px rgba(16, 32, 51, .06), 0 2px 6px rgba(16, 32, 51, .05);
  --shadow-md: 0 2px 4px rgba(16, 32, 51, .05), 0 12px 28px rgba(16, 32, 51, .09);

  --font: "Segoe UI", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
}

a { color: var(--navy-600); }

/* ---------- Header ------------------------------------------------------ */

.masthead {
  background: linear-gradient(135deg, var(--navy-900) 0%, var(--navy-800) 55%, var(--navy-700) 100%);
  color: #fff;
  border-bottom: 3px solid var(--accent);
}

.masthead-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 28px;
  height: 66px;
  display: flex;
  align-items: center;
  gap: 28px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  color: #fff;
  text-decoration: none;
  font-weight: 700;
  font-size: 1.12rem;
  letter-spacing: -0.01em;
}

.brand-mark {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: rgba(255, 255, 255, .12);
  border: 1px solid rgba(255, 255, 255, .22);
  display: grid;
  place-items: center;
  flex: none;
}

.brand-mark span {
  display: block;
  width: 13px;
  height: 13px;
  border-radius: 3px;
  background: linear-gradient(135deg, var(--good) 0%, var(--mid) 50%, var(--bad) 100%);
}

.brand em {
  font-style: normal;
  font-weight: 400;
  opacity: .62;
}

.masthead nav {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 2px;
  min-width: 0;
}

/* Only the destinations scroll. The account controls sit outside this box so
   Sign out can never end up somewhere you have to go looking for it. */
.nav-links {
  display: flex;
  align-items: center;
  gap: 2px;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
}

.nav-links::-webkit-scrollbar { display: none; }

.masthead nav a {
  color: rgba(255, 255, 255, .72);
  text-decoration: none;
  font-size: .85rem;
  font-weight: 500;
  padding: 8px 12px;
  border-radius: 8px;
  white-space: nowrap;
  flex: none;
  transition: background .13s ease, color .13s ease;
}

.masthead nav a:hover { background: rgba(255, 255, 255, .12); color: #fff; }

/* The current page reads as current without shouting: brighter text and a thin
   underline rather than a heavy filled box. */
.masthead nav a.is-current {
  color: #fff;
  font-weight: 600;
  background: rgba(255, 255, 255, .1);
  box-shadow: inset 0 -2px 0 var(--accent);
}

/* Separates navigation from the account controls. */
.nav-divider {
  flex: none;
  width: 1px;
  height: 22px;
  margin: 0 8px;
  background: rgba(255, 255, 255, .18);
}

/* ---------- Layout ------------------------------------------------------ */

main {
  flex: 1 0 auto;
  max-width: 1180px;
  width: 100%;
  margin: 0 auto;
  padding: 40px 28px 64px;
}

.page-head { margin-bottom: 30px; }

.eyebrow {
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 9px;
}

h1 {
  margin: 0 0 10px;
  font-size: 1.95rem;
  letter-spacing: -0.02em;
  color: var(--navy-900);
}

.lede {
  margin: 0;
  max-width: 68ch;
  color: var(--ink-soft);
  font-size: 1.02rem;
  line-height: 1.6;
}

.backlink {
  display: inline-block;
  margin-bottom: 16px;
  font-size: .85rem;
  color: var(--ink-soft);
  text-decoration: none;
  font-weight: 500;
}

.backlink:hover { color: var(--navy-700); }

/* ---------- Tool cards (home) ------------------------------------------ */

.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
  gap: 20px;
}

.tool-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-sm);
  transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
}

a.tool-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: #c3d2e2;
}

.tool-card h2 {
  margin: 16px 0 7px;
  font-size: 1.12rem;
  color: var(--navy-900);
  letter-spacing: -0.01em;
}

.tool-card p {
  margin: 0;
  font-size: .9rem;
  line-height: 1.55;
  color: var(--ink-soft);
}

.tool-card .cta {
  margin-top: 18px;
  font-size: .85rem;
  font-weight: 600;
  color: var(--navy-600);
}

.tool-card.is-soon { opacity: .62; cursor: default; }
.tool-card.is-soon .cta { color: var(--ink-faint); }

.tile {
  width: 42px;
  height: 42px;
  border-radius: 11px;
  background: var(--accent-soft);
  display: grid;
  place-items: center;
  color: var(--navy-700);
}

.tile svg { width: 22px; height: 22px; }

/* Miniature heat-map glyph used on the Stack Rank card */
.heat-glyph { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px; }
.heat-glyph i { width: 6px; height: 6px; border-radius: 1.5px; display: block; }

/* ---------- Panels ------------------------------------------------------ */

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 26px;
  margin-bottom: 22px;
}

.panel > h2 {
  margin: 0 0 4px;
  font-size: 1.04rem;
  color: var(--navy-900);
}

.panel > h2 + .hint { margin-top: 0; }

.hint {
  margin: 0 0 18px;
  font-size: .875rem;
  color: var(--ink-soft);
  line-height: 1.55;
}

/* ---------- Dropzone ---------------------------------------------------- */

.dropzone {
  border: 2px dashed #c3d2e2;
  border-radius: var(--radius);
  background: #fbfcfe;
  padding: 44px 26px;
  text-align: center;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease;
}

.dropzone:hover { border-color: var(--accent); background: var(--accent-soft); }
.dropzone.is-over { border-color: var(--accent); background: var(--accent-soft); border-style: solid; }
.dropzone:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }

.dropzone svg { width: 40px; height: 40px; color: var(--accent); margin-bottom: 12px; }

.dropzone strong { display: block; font-size: 1rem; color: var(--navy-900); margin-bottom: 5px; }
.dropzone span { font-size: .85rem; color: var(--ink-soft); }

/* ---------- Buttons ----------------------------------------------------- */

.btn {
  appearance: none;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 11px 20px;
  font: inherit;
  font-size: .92rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: background .14s ease, box-shadow .14s ease;
}

.btn svg { width: 17px; height: 17px; }

.btn-primary { background: var(--navy-800); color: #fff; box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: var(--navy-700); }
.btn-primary:disabled { background: #b6c2d0; cursor: not-allowed; box-shadow: none; }

.btn-ghost { background: transparent; color: var(--ink-soft); border-color: var(--line); }
.btn-ghost:hover { background: #eef2f7; color: var(--navy-800); }

.actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

/* ---------- File chip / status ------------------------------------------ */

.filechip {
  display: flex;
  align-items: center;
  gap: 11px;
  background: #f0f5fa;
  border: 1px solid #d7e3ee;
  border-radius: var(--radius-sm);
  padding: 12px 15px;
  margin-bottom: 18px;
  font-size: .89rem;
}

.filechip .name { font-weight: 600; color: var(--navy-900); word-break: break-all; }
.filechip .meta { color: var(--ink-faint); margin-left: auto; white-space: nowrap; }

.alert {
  border-radius: var(--radius-sm);
  padding: 13px 16px;
  font-size: .88rem;
  line-height: 1.5;
  margin-bottom: 18px;
}

.alert-error { background: #fdecec; border: 1px solid #f5c3c3; color: #8c2020; }
.alert-ok { background: #ecf7f0; border: 1px solid #bfe3cc; color: #1d6438; }

/* ---------- Preview table ---------------------------------------------- */

.preview-scroll {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

table.preview {
  border-collapse: collapse;
  font-size: .8rem;
  width: 100%;
  min-width: max-content;
}

table.preview th,
table.preview td {
  border: 1px solid #000;
  padding: 4px 9px;
  text-align: center;
  white-space: nowrap;
}

table.preview th {
  background: var(--navy-800);
  color: #fff;
  font-weight: 700;
  vertical-align: middle;
  max-width: 108px;
  white-space: normal;
  line-height: 1.25;
}

table.preview td.tech {
  background: #d3d3d3;
  color: var(--navy-800);
  font-weight: 700;
  text-align: left;
}

table.preview th.tech-head { min-width: 180px; }

table.preview tr.summary td { background: #ffff99; font-weight: 700; }
table.preview tr.summary td.tech { background: #ffff99; }

/* The scorecard sets every fill inline, so headers stay left/centre as authored. */
table.preview-plain th { white-space: nowrap; max-width: none; }

.legend-tiers { gap: 6px; }

.tier-chip {
  display: inline-grid;
  place-items: center;
  width: 26px;
  height: 20px;
  border: 1px solid #00000033;
  border-radius: 3px;
  font-size: .74rem;
  font-weight: 700;
  color: #111;
}

.legend {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: .78rem;
  color: var(--ink-soft);
  margin-top: 14px;
}

.legend .bar {
  width: 168px;
  height: 11px;
  border-radius: 3px;
  border: 1px solid #00000022;
  background: linear-gradient(to right, var(--good) 0%, var(--mid) 50%, var(--bad) 100%);
}

.legend .bar-rev {
  background: linear-gradient(to right, var(--bad) 0%, var(--mid) 50%, var(--good) 100%);
}

/* ---------- Column picker ----------------------------------------------- */

.colpicker {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 8px;
}

.colchip {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fbfcfe;
  padding: 10px 13px;
  cursor: pointer;
  transition: background .13s ease, border-color .13s ease;
}

.colchip:hover { border-color: #c3d2e2; background: #f4f8fc; }
.colchip.is-on { background: var(--accent-soft); border-color: #b6d3ea; }

.colchip input {
  accent-color: var(--navy-800);
  width: 16px;
  height: 16px;
  flex: none;
  margin: 0;
  cursor: pointer;
}

.colchip .colname {
  font-size: .875rem;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.3;
}

.colchip abbr {
  display: inline-grid;
  place-items: center;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: #dbe3ec;
  color: var(--ink-soft);
  font-size: .66rem;
  font-weight: 700;
  text-decoration: none;
  cursor: help;
  vertical-align: 1px;
}

.colchip .dir {
  margin-left: auto;
  font-style: normal;
  font-size: .69rem;
  font-weight: 600;
  white-space: nowrap;
  padding: 3px 7px;
  border-radius: 20px;
}

.dir-high { background: #e2f3e8; color: #1d6438; }
.dir-low  { background: #fdeaea; color: #8c2020; }

.picker-note {
  font-size: .82rem;
  color: var(--ink-faint);
  margin-left: auto;
}

/* ---------- Form fields -------------------------------------------------- */

.field-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px 18px;
}

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field-wide { grid-column: 1 / -1; }

.field label,
.field > label {
  font-size: .8rem;
  font-weight: 700;
  color: var(--navy-900);
  letter-spacing: .01em;
}

.field input[type="text"],
.field input[type="date"],
.field textarea,
.tech-row input {
  font: inherit;
  font-size: .92rem;
  color: var(--ink);
  background: #fff;
  border: 1px solid #ccd7e3;
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  width: 100%;
  min-width: 0;
  transition: border-color .13s ease, box-shadow .13s ease;
}

.field textarea { resize: vertical; line-height: 1.5; }

.field input:focus,
.field textarea:focus,
.tech-row input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(47, 143, 214, .16);
}

.field input::placeholder,
.field textarea::placeholder,
.tech-row input::placeholder { color: #a9b7c6; }

.field-hint {
  font-size: .76rem;
  color: var(--ink-faint);
  line-height: 1.45;
}

.field-hint em { color: var(--navy-600); font-style: normal; font-weight: 600; }

/* ---------- Tech name rows ----------------------------------------------- */

.tech-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 9px; }

.tech-row {
  display: grid;
  grid-template-columns: 2fr 1fr auto;
  gap: 8px;
  align-items: center;
}

.icon-btn {
  appearance: none;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink-faint);
  border-radius: var(--radius-sm);
  width: 34px;
  height: 34px;
  font-size: 1.15rem;
  line-height: 1;
  cursor: pointer;
  flex: none;
}

.icon-btn:hover:not(:disabled) { background: #fdecec; border-color: #f0c4c4; color: #8c2020; }
.icon-btn:disabled { opacity: .35; cursor: not-allowed; }

.btn-sm { padding: 7px 13px; font-size: .84rem; }

/* Buttons inside a column-flex .field would otherwise stretch full width. */
.field > .btn { align-self: flex-start; }

/* ---------- Checkbox lines ----------------------------------------------- */

.check-list { display: flex; flex-direction: column; gap: 8px; }

.checkline {
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fbfcfe;
  padding: 10px 14px;
  font-size: .89rem;
  transition: background .13s ease, border-color .13s ease;
}

.checkline:hover { border-color: #c3d2e2; }
.checkline.is-on { background: var(--accent-soft); border-color: #b6d3ea; }
.checkline em { font-style: normal; color: var(--ink-faint); font-size: .84em; }

.checkline-main {
  display: flex;
  align-items: center;
  gap: 11px;
  flex: 1;
  min-width: 0;
  cursor: pointer;
}

.checkline input[type="checkbox"] {
  accent-color: var(--navy-800);
  width: 16px;
  height: 16px;
  flex: none;
  margin: 0;
  cursor: pointer;
}

/* Leakage duration, sitting inline on its checkbox row. */
.inline-num {
  display: flex;
  align-items: center;
  gap: 7px;
  flex: none;
  font-size: .84rem;
  color: var(--ink-soft);
  white-space: nowrap;
}

.inline-num input {
  font: inherit;
  font-size: .89rem;
  text-align: center;
  width: 62px;
  padding: 6px 8px;
  border: 1px solid #ccd7e3;
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--ink);
}

.inline-num input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(47, 143, 214, .16);
}

.inline-num.is-off { opacity: .4; }
.inline-num.is-off input { background: #f1f4f8; cursor: not-allowed; }

/* Test points sit in a compact row — their labels are only a word each. */
.point-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 8px;
}

/* ---------- Segmented control -------------------------------------------- */

.segmented {
  display: inline-flex;
  background: #eef2f7;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 3px;
  gap: 3px;
  align-self: flex-start;
}

.seg {
  appearance: none;
  border: none;
  background: none;
  font: inherit;
  font-size: .84rem;
  font-weight: 700;
  letter-spacing: .03em;
  color: var(--ink-soft);
  padding: 8px 26px;
  border-radius: 6px;
  cursor: pointer;
}

.seg:hover { color: var(--navy-800); }

.seg.is-active {
  background: var(--navy-800);
  color: #fff;
  box-shadow: var(--shadow-sm);
}

/* ---------- Tabs ---------------------------------------------------------- */

.tabbar {
  display: flex;
  align-items: center;
  gap: 14px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 22px;
  flex-wrap: wrap;
}

.tabs { display: flex; gap: 3px; margin-bottom: -1px; }

.tab {
  appearance: none;
  border: 1px solid transparent;
  border-bottom: none;
  background: none;
  font: inherit;
  font-size: .92rem;
  font-weight: 700;
  color: var(--ink-soft);
  padding: 11px 22px;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  cursor: pointer;
}

.tab:hover { color: var(--navy-800); background: #eef2f7; }

.tab.is-active {
  background: #fff;
  border-color: var(--line);
  color: var(--navy-900);
  box-shadow: inset 0 3px 0 var(--accent);
}

.tabbar .btn { margin-left: auto; margin-bottom: 8px; }

.form-foot { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line); }

/* ---------- Document preview --------------------------------------------- */

.doc-preview {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 26px 30px;
  font-family: Arial, Helvetica, sans-serif;
  font-size: .93rem;
  line-height: 1.5;
  color: #111;
  overflow-x: auto;
}

.doc-preview p {
  font-size: 1.16rem;
  font-weight: 700;
  font-style: italic;
  margin: 0 0 18px;
}

.doc-preview ul { margin: 0 0 16px; padding-left: 22px; list-style: disc; }
.doc-preview ul ul { margin: 4px 0 0; padding-left: 26px; list-style: circle; }
.doc-preview li { margin: 3px 0; }
.doc-preview > ul:last-child { margin-bottom: 0; }

/* ---------- Toast --------------------------------------------------------- */

.toast {
  margin-top: 14px;
  font-size: .86rem;
  font-weight: 600;
  color: #1d6438;
  background: #ecf7f0;
  border: 1px solid #bfe3cc;
  border-radius: var(--radius-sm);
  padding: 11px 15px;
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity .18s ease, transform .18s ease;
  pointer-events: none;
  visibility: hidden;
}

.toast.is-visible { opacity: 1; transform: none; visibility: visible; }
.toast.is-error { color: #8c2020; background: #fdecec; border-color: #f5c3c3; }

/* ---------- Password gate ------------------------------------------------ */

.auth-gate {
  position: fixed;
  inset: 0;
  z-index: 999;
  display: grid;
  place-items: center;
  padding: 24px;
  background: linear-gradient(135deg, var(--navy-900) 0%, var(--navy-800) 55%, var(--navy-700) 100%);
}

.auth-card {
  width: 100%;
  max-width: 360px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: 0 18px 48px rgba(0, 15, 35, .35);
  padding: 36px 32px 32px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.auth-card .brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--navy-800);
  border: none;
  margin-bottom: 16px;
}

.auth-card .brand-mark span { width: 19px; height: 19px; border-radius: 4px; }

.auth-card h1 {
  font-size: 1.4rem;
  margin: 0 0 6px;
  letter-spacing: -0.02em;
}

.auth-card h1 em { font-style: normal; font-weight: 400; color: var(--ink-faint); }

.auth-card p {
  margin: 0 0 22px;
  font-size: .875rem;
  color: var(--ink-soft);
  line-height: 1.5;
}

.auth-card input[type="password"] {
  font: inherit;
  font-size: .95rem;
  text-align: center;
  letter-spacing: .06em;
  width: 100%;
  padding: 12px 14px;
  border: 1px solid #ccd7e3;
  border-radius: var(--radius-sm);
  background: #fbfcfe;
  color: var(--ink);
  margin-bottom: 12px;
}

.auth-card input[type="password"]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(47, 143, 214, .18);
  background: #fff;
}

.auth-card .btn { width: 100%; justify-content: center; }

.auth-error {
  margin: 14px 0 0 !important;
  font-size: .82rem !important;
  font-weight: 600;
  color: #8c2020 !important;
}

.auth-card.is-shaking { animation: auth-shake .38s ease; }

@keyframes auth-shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-7px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(3px); }
}

@media (prefers-reduced-motion: reduce) {
  .auth-card.is-shaking { animation: none; }
}

/* ---------- Quick Links --------------------------------------------------- */

.conn-status {
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  margin-bottom: 20px;
  font-size: .875rem;
  line-height: 1.55;
  background: #fff6e8;
  border: 1px solid #f0dcbb;
  color: #7a4a10;
}

.conn-status strong { color: #5e370a; }
.conn-status .conn-hint { display: block; margin-top: 5px; color: #8a6535; }
.conn-status code { background: #f4e6cf; padding: 1px 5px; border-radius: 4px; }

.links-head {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.links-head h2 { margin: 0; }
.links-head .picker-note { margin-left: 0; }
.links-toolbar { margin-left: auto; }

.link-form {
  background: #fbfcfe;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  margin-bottom: 22px;
}

.link-form h3 {
  margin: 0 0 16px;
  font-size: .98rem;
  color: var(--navy-900);
}

.form-error { margin: 14px 0 0 !important; text-align: left; }

.link-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}

.link-tile {
  position: relative;
  display: flex;
  align-items: stretch;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  transition: border-color .14s ease, box-shadow .14s ease, transform .14s ease;
}

.link-tile:hover {
  border-color: #c3d2e2;
  box-shadow: var(--shadow-sm);
  transform: translateY(-2px);
}

.link-tile.is-editing { border-color: var(--accent); background: var(--accent-soft); }

.link-main {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 14px 15px;
  flex: 1;
  min-width: 0;
  text-decoration: none;
  color: inherit;
  border-radius: var(--radius-sm);
}

.link-mono {
  width: 38px;
  height: 38px;
  flex: none;
  border-radius: 9px;
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 700;
  font-size: 1.02rem;
}

.link-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }

.link-text strong {
  font-size: .92rem;
  color: var(--navy-900);
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.link-host,
.link-note {
  font-size: .76rem;
  color: var(--ink-faint);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.link-note { color: var(--ink-soft); }

.link-actions {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  padding-right: 10px;
  opacity: 0;
  transition: opacity .14s ease;
}

.link-tile:hover .link-actions,
.link-tile:focus-within .link-actions { opacity: 1; }

.link-actions .icon-btn {
  width: 28px;
  height: 26px;
  display: grid;
  place-items: center;
  font-size: 1rem;
  padding: 0;
}

.link-actions .icon-btn svg { width: 13px; height: 13px; }

.link-actions .icon-btn.is-confirming {
  width: auto;
  padding: 0 9px;
  font-size: .72rem;
  font-weight: 700;
  background: #fdecec;
  border-color: #f0c4c4;
  color: #8c2020;
  opacity: 1;
}

/* ---------- Bookmark import picker --------------------------------------- */

.bookmark-picker {
  background: #fbfcfe;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  margin-bottom: 22px;
}

.bookmark-picker h3 {
  margin: 0 0 4px;
  font-size: .98rem;
  color: var(--navy-900);
}

.bm-toolbar { margin-bottom: 14px; }

.bm-filter {
  font: inherit;
  font-size: .87rem;
  padding: 7px 12px;
  border: 1px solid #ccd7e3;
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--ink);
  min-width: 220px;
  flex: 1;
  max-width: 320px;
}

.bm-filter:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(47, 143, 214, .16);
}

/* Bookmark row: checkbox + text on the left, note box on the right. */
.bm-row { gap: 10px; }
.bm-row .checkline-main { flex: 1 1 55%; min-width: 0; }

.bm-note {
  font: inherit;
  font-size: .82rem;
  flex: 1 1 45%;
  min-width: 0;
  padding: 6px 10px;
  border: 1px solid #d7e0ea;
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--ink);
}

.bm-note::placeholder { color: #b3c0ce; }

.bm-note:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(47, 143, 214, .16);
}

@media (max-width: 620px) {
  .bm-row { flex-wrap: wrap; }
  .bm-row .checkline-main,
  .bm-note { flex-basis: 100%; }
}

/* ---------- Sort dropdown ------------------------------------------------- */

.sort-field {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: .8rem;
  font-weight: 600;
  color: var(--ink-soft);
  white-space: nowrap;
}

.sort-field select {
  font: inherit;
  font-size: .84rem;
  font-weight: 500;
  color: var(--ink);
  background: #fff;
  border: 1px solid #ccd7e3;
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  cursor: pointer;
}

.sort-field select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(47, 143, 214, .16);
}

.bookmark-list {
  max-height: 380px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fff;
  padding: 12px;
}

.bm-group + .bm-group { margin-top: 16px; }

.bm-group h4 {
  margin: 0 0 7px;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.bm-group .checkline { margin-bottom: 5px; padding: 8px 12px; }

.bm-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }

.bm-text strong {
  font-size: .87rem;
  font-weight: 600;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bm-text em {
  font-style: normal;
  font-size: .74rem;
  color: var(--ink-faint);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- Documents ----------------------------------------------------- */

.dropzone.is-disabled { opacity: .45; pointer-events: none; }

.upload-progress {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 14px;
}

.upload-bar {
  flex: 1;
  height: 8px;
  border-radius: 5px;
  background: #e6ecf3;
  overflow: hidden;
}

.upload-bar span {
  display: block;
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width .15s ease;
}

.upload-label {
  font-size: .82rem;
  font-weight: 600;
  color: var(--ink-soft);
  white-space: nowrap;
}

.doc-list { display: flex; flex-direction: column; gap: 9px; }

.doc-row {
  display: flex;
  align-items: center;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  padding: 13px 15px;
  transition: border-color .13s ease, box-shadow .13s ease;
}

.doc-row:hover { border-color: #c3d2e2; box-shadow: var(--shadow-sm); }

.doc-ext {
  width: 44px;
  height: 44px;
  flex: none;
  border-radius: 9px;
  display: grid;
  place-items: center;
  color: #fff;
  font-size: .66rem;
  font-weight: 700;
  letter-spacing: .04em;
}

.doc-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }

.doc-text strong {
  font-size: .92rem;
  color: var(--navy-900);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.doc-meta { font-size: .76rem; color: var(--ink-faint); }
.doc-note { font-size: .8rem; color: var(--ink-soft); }

.doc-actions { display: flex; align-items: center; gap: 7px; flex: none; }

@media (max-width: 620px) {
  .doc-row { flex-wrap: wrap; }
  .doc-actions { width: 100%; justify-content: flex-end; }
}

.empty-state {
  border: 2px dashed #dfe5ec;
  border-radius: var(--radius);
  padding: 40px 24px;
  text-align: center;
  color: var(--ink-soft);
}

.empty-state svg { width: 34px; height: 34px; color: var(--ink-faint); margin-bottom: 12px; }
.empty-state strong { display: block; color: var(--navy-900); font-size: .98rem; margin-bottom: 5px; }
.empty-state span { font-size: .86rem; }

@media (max-width: 640px) {
  .link-actions { opacity: 1; }
}

/* Icon only. The label cost ~70px and wrapped to two lines; the icon plus a
   tooltip says the same thing in a square. */
.masthead nav a.auth-signout {
  flex: none;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  margin-left: 4px;
  border-radius: 8px;
  color: rgba(255, 255, 255, .66);
}

.masthead nav a.auth-signout svg { width: 17px; height: 17px; }
.masthead nav a.auth-signout:hover { background: rgba(255, 255, 255, .16); color: #fff; }

/* Narrow windows: drop the name, keep the avatar. */
@media (max-width: 900px) {
  .nav-name { display: none; }
}

@media (max-width: 640px) {
  .masthead-inner { gap: 12px; padding: 0 16px; }
  .masthead nav { gap: 0; }
  .masthead nav a { padding: 8px 9px; font-size: .82rem; }
  .nav-divider { margin: 0 5px; }
}

/* ---------- Misc -------------------------------------------------------- */

.hidden { display: none !important; }

.steps {
  margin: 0;
  padding-left: 20px;
  font-size: .88rem;
  color: var(--ink-soft);
  line-height: 1.75;
}

.steps code {
  background: #eef2f7;
  padding: 1px 5px;
  border-radius: 4px;
  font-size: .93em;
}

footer.foot {
  flex: none;
  border-top: 1px solid var(--line);
  background: var(--surface);
  padding: 20px 28px;
  text-align: center;
  font-size: .8rem;
  color: var(--ink-faint);
}

@media (max-width: 640px) {
  main { padding: 28px 18px 48px; }
  .masthead-inner { padding: 0 18px; }
  h1 { font-size: 1.6rem; }
  .panel { padding: 20px; }
}

/* ---------- Auth pages ---------------------------------------------------- */

.auth-page { background: var(--navy-900); }
.auth-card-wide { max-width: 420px; text-align: left; }
.auth-card-wide h1 { text-align: center; }
.auth-card-wide .brand-mark { align-self: center; }

.auth-tabs {
  display: flex;
  gap: 3px;
  background: #eef2f7;
  border-radius: var(--radius-sm);
  padding: 3px;
  margin: 18px 0 22px;
}

.auth-tab {
  flex: 1;
  appearance: none;
  border: none;
  background: none;
  font: inherit;
  font-size: .86rem;
  font-weight: 600;
  color: var(--ink-soft);
  padding: 9px 12px;
  border-radius: 6px;
  cursor: pointer;
}

.auth-tab.is-active { background: var(--navy-800); color: #fff; box-shadow: var(--shadow-sm); }

.auth-form { display: flex; flex-direction: column; width: 100%; }

.auth-label {
  font-size: .78rem;
  font-weight: 700;
  color: var(--navy-900);
  margin-bottom: 5px;
}

.auth-form input {
  font: inherit;
  font-size: .93rem;
  width: 100%;
  padding: 11px 13px;
  border: 1px solid #ccd7e3;
  border-radius: var(--radius-sm);
  background: #fbfcfe;
  color: var(--ink);
  margin-bottom: 15px;
}

.auth-form input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(47, 143, 214, .18);
  background: #fff;
}

.auth-hint {
  font-size: .76rem;
  color: var(--ink-faint);
  margin: -10px 0 16px;
}

.auth-ok {
  margin: 14px 0 0 !important;
  font-size: .84rem !important;
  font-weight: 600;
  color: #1d6438 !important;
  background: #ecf7f0;
  border: 1px solid #bfe3cc;
  border-radius: var(--radius-sm);
  padding: 11px 13px;
}

.auth-foot {
  margin: 20px 0 0 !important;
  font-size: .78rem !important;
  color: var(--ink-faint) !important;
  text-align: center;
}

/* ---------- Signed-in masthead -------------------------------------------- */

.masthead nav .nav-user {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  flex: none;
  padding: 4px 4px 4px 0;
  font-size: .84rem;
  color: rgba(255, 255, 255, .9);
  white-space: nowrap;
  min-width: 0;
}

.nav-avatar {
  width: 28px;
  height: 28px;
  flex: none;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, .18);
  border: 1px solid rgba(255, 255, 255, .22);
  font-size: .8rem;
  font-weight: 700;
  color: #fff;
}

.nav-name {
  max-width: 15ch;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Admin is a different kind of destination from the tools, so it looks it. */
.masthead nav a.nav-admin {
  color: #fff;
  border: 1px solid rgba(255, 255, 255, .26);
  padding: 7px 12px;
}

.masthead nav a.nav-admin:hover { background: rgba(255, 255, 255, .16); }

/* ---------- Admin dashboard ----------------------------------------------- */

.badge {
  display: inline-grid;
  place-items: center;
  min-width: 22px;
  height: 22px;
  padding: 0 7px;
  border-radius: 20px;
  background: var(--accent);
  color: #fff;
  font-size: .74rem;
  font-weight: 700;
  vertical-align: 2px;
}

.user-list { display: flex; flex-direction: column; gap: 10px; }

.user-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  padding: 14px 16px;
}

.user-card.status-pending { border-color: #f0dcbb; background: #fffdf8; }
.user-card.status-denied { opacity: .72; }

.user-top { display: flex; align-items: center; gap: 13px; flex-wrap: wrap; }

.user-avatar {
  width: 38px; height: 38px; flex: none;
  border-radius: 50%;
  display: grid; place-items: center;
  background: var(--navy-800); color: #fff;
  font-weight: 700; font-size: 1rem;
}

.user-id { display: flex; flex-direction: column; gap: 1px; min-width: 0; flex: 1; }
.user-id strong { font-size: .93rem; color: var(--navy-900); }
.user-id strong em {
  font-style: normal; font-size: .7rem; font-weight: 600;
  color: var(--ink-faint); background: #eef2f7;
  padding: 1px 6px; border-radius: 20px; margin-left: 5px;
}
.user-email { font-size: .8rem; color: var(--ink-soft); }
.user-meta { font-size: .73rem; color: var(--ink-faint); }

.user-badges { flex: none; }
.user-actions { display: flex; align-items: center; gap: 7px; flex: none; }

.pill {
  font-size: .7rem; font-weight: 700; letter-spacing: .04em;
  text-transform: uppercase; padding: 3px 9px; border-radius: 20px;
}
.pill-active  { background: #ecf7f0; color: #1d6438; }
.pill-pending { background: #fff6e8; color: #7a4a10; }
.pill-denied  { background: #fdecec; color: #8c2020; }

.user-controls {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  margin-top: 13px; padding-top: 13px; border-top: 1px solid var(--line);
}

.tool-chips { display: flex; flex-wrap: wrap; gap: 6px; }

.tool-chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: .78rem; font-weight: 600; color: var(--ink-soft);
  border: 1px solid var(--line); border-radius: 20px;
  padding: 5px 12px 5px 9px; cursor: pointer;
  transition: background .13s ease, border-color .13s ease;
}

.tool-chip input { accent-color: var(--navy-800); width: 14px; height: 14px; margin: 0; cursor: pointer; }
.tool-chip.is-on { background: var(--accent-soft); border-color: #b6d3ea; color: var(--navy-800); }
.tool-chip.is-locked { opacity: .6; cursor: default; }

@media (max-width: 620px) {
  .user-actions { width: 100%; justify-content: flex-end; }
}

/* Inline description editing on a document row */
.doc-row.is-editing { border-color: var(--accent); background: var(--accent-soft); }

.doc-edit { display: flex; align-items: center; gap: 7px; margin-top: 4px; flex-wrap: wrap; }

.doc-note-input {
  font: inherit;
  font-size: .82rem;
  flex: 1 1 240px;
  min-width: 0;
  padding: 6px 10px;
  border: 1px solid #ccd7e3;
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--ink);
}

.doc-note-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(47, 143, 214, .16);
}

/* ---------- Profile ------------------------------------------------------- */

/* The nav avatar doubles as the link to the profile page. */
.masthead nav a.nav-user { text-decoration: none; border-radius: 8px; padding: 3px 8px 3px 3px; }
.masthead nav a.nav-user:hover { background: rgba(255, 255, 255, .12); }
.masthead nav a.nav-user.is-current { background: rgba(255, 255, 255, .16); }

.nav-avatar.has-photo { background: none; padding: 0; overflow: hidden; }
.nav-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }

.photo-row { display: flex; align-items: center; gap: 22px; flex-wrap: wrap; }

.photo-preview {
  width: 96px;
  height: 96px;
  flex: none;
  border-radius: 50%;
  overflow: hidden;
  display: grid;
  place-items: center;
  background: var(--navy-800);
  border: 3px solid #fff;
  box-shadow: var(--shadow-sm);
}

.photo-preview img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-initial { color: #fff; font-size: 2.2rem; font-weight: 700; }

.photo-controls { display: flex; flex-direction: column; gap: 8px; }
.photo-controls .field-hint:empty { display: none; }

/* Two credential forms stacked in one panel, each visibly its own thing. */
.stacked-form + .stacked-form {
  margin-top: 26px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
}

.stacked-form h3 {
  margin: 0 0 14px;
  font-size: .92rem;
  color: var(--navy-900);
}

/* ---------- People: names that carry a hover card ------------------------- */

.link-tile { flex-direction: column; align-items: stretch; }
.link-row { display: flex; align-items: stretch; }

.link-added {
  font-size: .73rem;
  color: var(--ink-faint);
  padding: 0 15px 11px 66px;      /* clears the monogram, aligns with the text */
  margin-top: -4px;
}

.person {
  color: var(--navy-600);
  font-weight: 600;
  cursor: help;
  border-bottom: 1px dotted currentColor;
}

.person:hover,
.person:focus-visible { color: var(--accent); outline: none; }
.person:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px; }

.person-plain { color: inherit; }

.person-card {
  position: absolute;
  z-index: 1000;
  width: 268px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 16px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px);
  transition: opacity .13s ease, transform .13s ease, visibility .13s;
  pointer-events: none;
}

.person-card.is-open {
  opacity: 1;
  visibility: visible;
  transform: none;
  pointer-events: auto;
}

.person-head { display: flex; align-items: center; gap: 12px; margin-bottom: 13px; }

.person-avatar {
  width: 44px;
  height: 44px;
  flex: none;
  border-radius: 50%;
  overflow: hidden;
  display: grid;
  place-items: center;
  background: var(--navy-800);
  color: #fff;
  font-weight: 700;
  font-size: 1.05rem;
}

.person-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }

.person-who { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.person-who strong { font-size: .93rem; color: var(--navy-900); line-height: 1.25; }

.person-who em {
  font-style: normal;
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--accent);
}

.person-lines { display: flex; flex-direction: column; gap: 7px; }

.person-line {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: .81rem;
  color: var(--ink-soft);
  text-decoration: none;
  min-width: 0;
}

a.person-line:hover { color: var(--navy-600); }
.person-line svg { width: 14px; height: 14px; flex: none; color: var(--ink-faint); }
.person-line span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.person-empty { margin: 0; font-size: .81rem; color: var(--ink-faint); }
