/* A. Titan Instruments — programs portal.
   The palette is the storefront's: red is the brand accent and is reserved for
   primary actions and rules. State is carried by a separate semantic set, so
   "approved" never has to compete with a red button for the same meaning. */

:root {
  --red: #d02028;
  --red-dark: #a8181f;
  --red-wash: #fdf2f3;

  --white: #ffffff;
  --panel: #f4f6f7;
  --ink: #14181c;
  --body: #3d444b;
  --border: #dbe0e4;

  --green: #1b7f3b;
  --green-wash: #edf7f0;
  --amber: #b26b00;
  --amber-wash: #fdf5e8;
  --grey: #8a9299;
  --grey-wash: #f1f3f4;

  --radius: 8px;
  --shadow: 0 1px 2px rgba(20, 24, 28, .06), 0 6px 20px rgba(20, 24, 28, .05);
  --font: 'Barlow', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.55;
  color: var(--body);
  background: var(--white);
}

h1, h2, h3 { color: var(--ink); line-height: 1.2; margin: 0 0 .4em; font-weight: 600; }
h1 { font-size: 1.85rem; letter-spacing: -.01em; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 1em; }
a { color: var(--red); }
a:hover { color: var(--red-dark); }

/* Focus is visible everywhere, and never removed. */
:focus-visible {
  outline: 3px solid var(--red);
  outline-offset: 2px;
  border-radius: 4px;
}

.skip-link {
  position: absolute; left: -9999px; top: 0;
  background: var(--ink); color: var(--white);
  padding: .6rem 1rem; z-index: 100;
}
.skip-link:focus { left: 0; }

/* ── Header ──────────────────────────────────────────────────────────────── */

.site-header {
  border-bottom: 1px solid var(--border);
  background: var(--white);
}
.site-header .inner {
  max-width: 1120px; margin: 0 auto; padding: 1rem 1.25rem;
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
}
.site-header img { height: 40px; width: auto; display: block; }
.site-header .divider { width: 1px; align-self: stretch; background: var(--border); }
.site-header .title { font-weight: 600; color: var(--ink); font-size: 1rem; }
.site-header nav { margin-left: auto; display: flex; gap: 1.25rem; flex-wrap: wrap; }
.site-header nav a {
  color: var(--body); text-decoration: none; font-weight: 500; font-size: .95rem;
  padding: .25rem 0; border-bottom: 2px solid transparent;
}
.site-header nav a:hover, .site-header nav a[aria-current="page"] {
  color: var(--ink); border-bottom-color: var(--red);
}

main { max-width: 1120px; margin: 0 auto; padding: 2rem 1.25rem 4rem; }
main.narrow { max-width: 620px; }

.lede { font-size: 1.05rem; margin-bottom: 1.75rem; }
.eyebrow {
  text-transform: uppercase; letter-spacing: .09em; font-size: .74rem;
  font-weight: 600; color: var(--red); margin-bottom: .4rem;
}

/* ── Cards ───────────────────────────────────────────────────────────────── */

.card {
  background: var(--white); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.5rem; box-shadow: var(--shadow);
}
.card + .card { margin-top: 1.25rem; }

.card-grid {
  display: grid; gap: 1.25rem;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}
a.card { text-decoration: none; color: inherit; display: block; transition: border-color .15s, transform .15s; }
a.card:hover { border-color: var(--red); transform: translateY(-2px); }
a.card h2 { color: var(--ink); }
a.card .go { color: var(--red); font-weight: 600; }

/* ── Summary tiles ───────────────────────────────────────────────────────── */

.tiles {
  display: grid; gap: 1rem; margin-bottom: 1.75rem;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}
.tile {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1rem 1.1rem;
}
.tile .n { font-size: 2rem; font-weight: 600; color: var(--ink); line-height: 1.1; }
.tile .label { font-size: .82rem; text-transform: uppercase; letter-spacing: .05em; color: var(--grey); font-weight: 600; }
.tile.alert { background: var(--amber-wash); border-color: #e8d3a8; }
.tile.alert .n { color: var(--amber); }
.tile.good .n { color: var(--green); }

/* ── Pills ───────────────────────────────────────────────────────────────── */

.pill {
  display: inline-flex; align-items: center; gap: .35rem;
  padding: .15rem .55rem; border-radius: 999px;
  font-size: .78rem; font-weight: 600; letter-spacing: .02em;
  border: 1px solid transparent; white-space: nowrap;
}
.pill::before { content: ""; width: .45rem; height: .45rem; border-radius: 50%; background: currentColor; }
.pill-verified, .pill-approved { color: var(--green); background: var(--green-wash); border-color: #c3e3ce; }
.pill-pending, .pill-expiring  { color: var(--amber); background: var(--amber-wash); border-color: #ecd8ae; }
.pill-expired, .pill-inactive  { color: var(--grey); background: var(--grey-wash); border-color: var(--border); }
.pill-rejected                 { color: var(--red);  background: var(--red-wash);  border-color: #f2c8ca; }

/* ── Tables ──────────────────────────────────────────────────────────────── */

.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }
table { border-collapse: collapse; width: 100%; min-width: 720px; font-size: .93rem; }
thead th {
  background: var(--panel); text-align: left; font-weight: 600; color: var(--ink);
  padding: .7rem .9rem; border-bottom: 1px solid var(--border); white-space: nowrap;
  font-size: .8rem; text-transform: uppercase; letter-spacing: .05em;
}
tbody td { padding: .75rem .9rem; border-bottom: 1px solid var(--border); vertical-align: top; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #fafbfb; }
td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td.actions { white-space: nowrap; }
.muted { color: var(--grey); font-size: .86rem; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .86rem; }

/* ── Buttons ─────────────────────────────────────────────────────────────── */

.btn {
  display: inline-block; font: inherit; font-weight: 600; font-size: .92rem;
  padding: .5rem 1rem; border-radius: 6px; border: 1px solid var(--border);
  background: var(--white); color: var(--ink); cursor: pointer;
  text-decoration: none; transition: background .12s, border-color .12s;
}
.btn:hover { background: var(--panel); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--red); border-color: var(--red); color: var(--white); }
.btn-primary:hover { background: var(--red-dark); border-color: var(--red-dark); }
.btn-approve { border-color: #bcdfc9; color: var(--green); background: var(--green-wash); }
.btn-approve:hover { background: #dcefe3; }
.btn-reject { border-color: var(--border); color: var(--body); }
.btn-reject:hover { background: var(--grey-wash); }
.btn-lg { padding: .75rem 1.5rem; font-size: 1rem; width: 100%; }
.btn-sm { padding: .3rem .7rem; font-size: .85rem; }
.btn + .btn { margin-left: .4rem; }

/* ── Forms ───────────────────────────────────────────────────────────────── */

.field { margin-bottom: 1.15rem; }
.field label { display: block; font-weight: 600; color: var(--ink); margin-bottom: .3rem; font-size: .95rem; }
.field .hint { font-size: .85rem; color: var(--grey); margin: -.1rem 0 .4rem; }
.field input[type="text"], .field input[type="email"], .field input[type="tel"],
.field input[type="date"], .field select, .field textarea {
  width: 100%; font: inherit; color: var(--ink);
  padding: .6rem .7rem; border: 1px solid var(--border); border-radius: 6px;
  background: var(--white);
}
.field input:focus, .field select:focus { border-color: var(--red); }

fieldset { border: none; padding: 0; margin: 0 0 1.15rem; }
legend { font-weight: 600; color: var(--ink); padding: 0; margin-bottom: .45rem; font-size: .95rem; }

.choice {
  display: flex; gap: .65rem; align-items: flex-start;
  border: 1px solid var(--border); border-radius: 6px; padding: .7rem .8rem;
  cursor: pointer; margin-bottom: .5rem; background: var(--white);
}
.choice:hover { border-color: var(--grey); }
.choice input { margin: .3rem 0 0; accent-color: var(--red); }
.choice:has(input:checked) { border-color: var(--red); background: var(--red-wash); }
.choice .t { font-weight: 600; color: var(--ink); display: block; }
.choice .d { font-size: .87rem; color: var(--body); }

/* ── Messages ────────────────────────────────────────────────────────────── */

.msg { border-radius: var(--radius); padding: .85rem 1rem; margin-bottom: 1.25rem; font-size: .95rem; border: 1px solid; }
.msg-error   { background: var(--red-wash);   border-color: #f2c8ca; color: #8f1319; }
.msg-success { background: var(--green-wash); border-color: #c3e3ce; color: #145f2c; }
.msg-notice  { background: var(--amber-wash); border-color: #ecd8ae; color: #7d4b00; }
.msg ul { margin: .4rem 0 0; padding-left: 1.1rem; }
.msg[hidden] { display: none; }

.empty { padding: 2rem 1rem; text-align: center; color: var(--grey); }

.footnote {
  margin-top: 2.5rem; padding-top: 1.25rem; border-top: 1px solid var(--border);
  font-size: .87rem; color: var(--grey);
}

/* ── Admin layout ────────────────────────────────────────────────────────── */

.section-head {
  display: flex; align-items: baseline; gap: .75rem; flex-wrap: wrap;
  margin: 2.25rem 0 .9rem;
}
.section-head h2 { margin: 0; }
.section-head .count { color: var(--grey); font-size: .9rem; }
.section-head .filters { margin-left: auto; display: flex; gap: .35rem; flex-wrap: wrap; }
.filter-btn {
  font: inherit; font-size: .85rem; font-weight: 600; cursor: pointer;
  padding: .25rem .7rem; border-radius: 999px;
  border: 1px solid var(--border); background: var(--white); color: var(--body);
}
.filter-btn[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--white); }

.console-head {
  display: flex; align-items: flex-end; gap: 1rem; flex-wrap: wrap;
  margin-bottom: 1.5rem;
}
.console-head h1 { margin: 0; }
.console-actions { margin-left: auto; }

/* The one-line service status under the tiles: connection, provider, last run.
   Small on purpose — it matters when something is wrong and should not compete
   with the counts when everything is fine. */
.status-strip {
  font-size: .85rem; color: var(--grey);
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: .6rem .9rem; margin: 0 0 .5rem;
}

/* Several pills can stack in one status cell (verified + expiring, say). */
.status-cell { display: flex; flex-direction: column; align-items: flex-start; gap: .3rem; }

td .primary { color: var(--ink); font-weight: 500; }

.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;
}

@media (max-width: 640px) {
  h1 { font-size: 1.5rem; }
  main { padding: 1.5rem 1rem 3rem; }
  .site-header nav { width: 100%; margin-left: 0; }
  .console-actions { margin-left: 0; }
  .section-head .filters { margin-left: 0; width: 100%; }
}
