/* ===================================================================
   Vigil28 app — the vigil28.eu "trust-first" theme (issue #28).
   Tokens, the header shell, the footer and trust badges are shared with
   vigil28.eu: static/shared/vigil28.css (from vigil28-web, issue #36),
   loaded before this file.
   No framework, no build step. Every page uses the same components:
   header, tabs, filter bar + count line + table + pager, badges, buttons,
   notices, cards, forms.
   =================================================================== */
* { box-sizing: border-box; }
[hidden] { display: none !important; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

body {
  margin: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  font-family: var(--sans);
  font-size: 0.95rem;
  line-height: 1.55;
  color: var(--ink);
  background: var(--bg);
}

h1, h2, h3 { font-family: var(--serif); line-height: 1.25; color: var(--navy); }
h1 { font-size: clamp(1.5rem, 3vw, 1.9rem); margin: 0 0 1rem; }
h2 { font-size: 1.3rem; margin: 2rem 0 0.7rem; }
h3 { font-size: 1.05rem; margin: 1.3rem 0 0.5rem; }

a { color: var(--slate); text-decoration: none; }
a:hover { color: var(--navy); text-decoration: underline; }

code, pre { font-family: var(--mono); font-size: 0.85em; }

.muted { color: var(--ink-soft); font-size: 0.9rem; }
.error { color: var(--red); font-size: 0.85rem; }

/* --- Header: the app's side of the shared header -------------------------- */
.site-nav .whoami { font-size: 0.85rem; }
/* "Log out" is a POST form (issue #56) that looks like the other nav links. */
.site-nav .nav-form { display: inline; margin: 0; }
.site-nav .nav-form button {
  background: none; border: 0; padding: 0; cursor: pointer;
  font: inherit; font-weight: 500; color: var(--ink-soft);
}
.site-nav .nav-form button:hover { color: var(--navy); }

/* --- Layout --------------------------------------------------------------- */
main.container { flex: 1; padding: 1.75rem 0 3rem; }

/* --- Tabs: section navigation on a page (vendor tabs, admin, plans) ------ */
.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  border-bottom: 1px solid var(--line);
  margin: 0 0 1.25rem;
}
.tab {
  padding: 0.5rem 0.9rem;
  color: var(--ink-soft);
  font-weight: 500;
  border-bottom: 3px solid transparent;
  margin-bottom: -1px;
}
.tab:hover { color: var(--navy); text-decoration: none; }
.tab[aria-current="page"], .tab.active { color: var(--navy); border-bottom-color: var(--gold); }
.tabs .tab-action { margin-left: auto; align-self: center; }

/* --- Flash messages and notices --------------------------------------- */
.flash {
  padding: 0.65rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 0.9rem;
  border: 1px solid var(--line);
  border-left: 4px solid var(--slate);
  background: var(--card);
}
.flash-success { border-left-color: var(--green); background: var(--green-bg); color: var(--green); }
.flash-error   { border-left-color: var(--red); background: var(--red-bg); color: var(--red); }
.flash-warning { border-left-color: var(--amber); background: var(--amber-bg); color: var(--amber); }
.verify-banner { display: flex; flex-wrap: wrap; gap: 0.5rem 1rem; align-items: center; justify-content: space-between; }

.notice {
  background: var(--card);
  border: 1px solid var(--line);
  border-left: 4px solid var(--gold);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  margin: 1rem 0;
}
.notice summary { cursor: pointer; font-weight: 600; color: var(--navy); }
.notice-gap { border-left-color: var(--amber); background: var(--amber-bg); }
.notice-gap h2 { margin-top: 0; font-size: 1.1rem; color: var(--amber); }
.notice-gap ol { padding-left: 1.25rem; }

/* --- Cards (dashboard figures) --------------------------------------------- */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
  gap: 1rem;
}
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-top: 3px solid var(--slate);
  border-radius: var(--radius);
  padding: 1rem 1.2rem;
}
.card-value { display: block; font-family: var(--serif); font-size: 2rem; font-weight: 700; color: var(--navy); }
.card-label { color: var(--ink-soft); font-size: 0.85rem; }
.card-warn { border-top-color: var(--amber); }
.card-warn .card-value { color: var(--amber); }

/* --- Lists: filter bar, count line, table, pager (same on every list) ------ */
.filter-bar { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; margin: 0.5rem 0; }
.filter-bar input[type="search"] { min-width: 16rem; flex: 1 1 16rem; max-width: 28rem; }
.list-count { margin: 0.25rem 0 0.75rem; }

.table {
  width: 100%;
  border-collapse: collapse;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 0.9rem;
}
.table th, .table td {
  text-align: left;
  vertical-align: top;
  padding: 0.6rem 0.8rem;
  border-bottom: 1px solid var(--line);
}
.table thead th {
  background: #F1F4F8;
  color: var(--navy);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  border-bottom: 2px solid var(--line);
}
.table tbody tr:hover td { background: #FAFBFC; }
.table tbody tr:last-child td { border-bottom: none; }
.table td .form-inline { margin: 0.2rem 0; }

.pagination {
  display: flex;
  gap: 1rem;
  align-items: center;
  margin-top: 1rem;
  color: var(--ink-soft);
  font-size: 0.9rem;
}

/* --- Buttons ---------------------------------------------------------------- */
.btn {
  display: inline-block;
  padding: 0.45rem 1rem;
  border: 1px solid var(--navy);
  border-radius: 3px;
  background: var(--navy);
  color: #fff;
  font: 600 0.9rem var(--sans);
  line-height: 1.4;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.btn:hover { background: #12375C; border-color: #12375C; color: #fff; text-decoration: none; }
.btn-primary { background: var(--gold); border-color: var(--gold); color: var(--navy-deep); }
.btn-primary:hover { background: var(--gold-light); border-color: var(--gold-light); color: var(--navy-deep); }
.btn-plain { background: transparent; border-color: var(--line); color: var(--navy); }
.btn-plain:hover { background: var(--slate-bg); border-color: var(--slate); color: var(--navy); }
.btn-danger { background: transparent; border-color: var(--red); color: var(--red); }
.btn-danger:hover { background: var(--red); border-color: var(--red); color: #fff; }
.btn-block { width: 100%; }
.btn-sm { padding: 0.2rem 0.65rem; font-size: 0.82rem; }
/* A row action that opens a small form in place (e.g. mark as scraping error). */
details.row-action > summary { list-style: none; display: inline-block; }
details.row-action > summary::-webkit-details-marker { display: none; }
details.row-action[open] > summary { margin-bottom: 0.4rem; }
/* A report form (issue #43) opens below the action bar, on its own row. */
.detail-actions details.report-issue[open] { flex-basis: 100%; }
details.report-issue form { max-width: 40rem; padding: 0.9rem 1rem; background: var(--card);
  border: 1px solid var(--line); border-radius: var(--radius); }
.btn-lg { padding: 0.75rem 1.6rem; font-size: 1.02rem; }

/* --- Forms -------------------------------------------------------------------- */
.form p { margin: 0 0 0.9rem; }
.form label { font-weight: 500; color: var(--ink); }
.input {
  padding: 0.45rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: #fff;
  color: var(--ink);
  font: 0.95rem var(--sans);
  max-width: 100%;
}
.input:focus { border-color: var(--slate); outline: none; box-shadow: 0 0 0 3px rgba(59, 110, 165, 0.18); }
.form-inline { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: center; }
.form-inline label { font-size: 0.85rem; color: var(--ink-soft); font-weight: 400; }

/* --- Badges (states) ---------------------------------------------------------- */
.badge {
  display: inline-block;
  padding: 0.12rem 0.5rem;
  border-radius: 2px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: #EEF1F5;
  color: var(--ink-soft);
  white-space: nowrap;
}
.badge-added   { background: var(--green-bg); color: var(--green); }
.badge-removed { background: var(--red-bg); color: var(--red); }
.badge-modified, .badge-document, .badge-gap { background: var(--amber-bg); color: var(--amber); }

.diff-added   { color: var(--green); }
.diff-removed { color: var(--red); }
pre.diff {
  white-space: pre-wrap;
  max-height: 30rem;
  overflow: auto;
  background: var(--card);
  border: 1px solid var(--line);
  border-left: 3px solid var(--gold);
  border-radius: var(--radius);
  padding: 0.8rem 1rem;
}

/* --- Detail pages ---------------------------------------------------------------- */
.detail { display: grid; grid-template-columns: 12rem 1fr; gap: 0.4rem 1.2rem; }
.detail dt { color: var(--ink-soft); font-weight: 600; font-size: 0.85rem; }
.detail dd { margin: 0; }
.detail code { background: #EEF1F5; padding: 0.1rem 0.4rem; border-radius: 3px; }
.detail-actions { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: center; margin: 1rem 0; }
.detail-actions form { margin: 0; }

/* Sub-processor chain tree (companies/_chain.html) */
ul.chain {
  list-style: none;
  margin: 0.25rem 0 0.25rem 0.5rem;
  padding-left: 1rem;
  border-left: 2px solid var(--line);
}
ul.chain li { margin: 0.25rem 0; }
details > summary { cursor: pointer; }

/* --- Sign-in, signup, onboarding ------------------------------------------------- */
.login-card {
  max-width: 24rem;
  margin: 3rem auto;
  background: var(--card);
  border: 1px solid var(--line);
  border-top: 3px solid var(--gold);
  border-radius: var(--radius);
  padding: 2rem;
  text-align: center;
}
.login-card h1 { margin-bottom: 0.2rem; }
.login-card h1 span, .login-card h1 em { color: var(--gold); font-style: normal; }
.login-card form { text-align: left; margin-top: 1.5rem; }
.login-card .input { width: 100%; }

.empty-state {
  max-width: 44rem;
  margin: 1rem 0 2rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-top: 3px solid var(--gold);
  border-radius: var(--radius);
  padding: 1.5rem 1.75rem;
}
.empty-state ol { padding-left: 1.25rem; line-height: 1.7; }
.voucher-code { font-family: var(--mono); font-size: 1.2rem; user-select: all; }
/* The OAuth consent page's redirect host, hard to miss (issue #60). */
.consent-host { font-family: var(--mono); font-size: 1.4rem; font-weight: 700; color: var(--navy);
  word-break: break-all; }
.signup { max-width: 40rem; }
.signup fieldset {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  margin: 1rem 0;
  padding: 0.75rem 1rem;
}
.signup legend { font-family: var(--serif); color: var(--navy); font-weight: 700; padding: 0 0.3rem; }

/* --- Small screens --------------------------------------------------------------- */
@media (max-width: 760px) {
  .table { display: block; overflow-x: auto; }
  .detail { grid-template-columns: 1fr; }
  .filter-bar input[type="search"] { min-width: 0; }
}
