/* Poirot — single stylesheet. Start small; grow with intent. */

:root {
  --ink: #1a1a1a;
  --ink-soft: #555;
  --ink-faint: #888;
  --paper: #fafaf7;
  --rule: #e3ddd0;
  --accent: #1a3a52;
  --accent-soft: #2a5a7c;
  --error: #b03020;
  --warn-bg: #fff5e6;
  --ok: #2a7a3a;
  --serif: Georgia, "Times New Roman", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Helvetica Neue", Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 17px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
a:hover { color: var(--accent-soft); }

h1, h2, h3 { font-weight: 600; line-height: 1.2; margin: 0 0 0.5em; }
h1 { font-size: 1.85rem; }
h2 { font-size: 1.4rem; }
h3 { font-size: 1.15rem; }

.muted { color: var(--ink-soft); }
.error { color: var(--error); margin: 0.5em 0; }
.success { color: var(--ok); }

/* Header --------------------------------------------------------------- */
.site-header {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--rule);
  background: #fff;
}
.site-header .brand {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--ink);
  text-decoration: none;
  letter-spacing: 0.02em;
}
.site-header .tagline {
  color: var(--ink-faint);
  font-style: italic;
  font-size: 0.85rem;
}
.site-nav {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: 0.9rem;
}
.site-nav .user { color: var(--ink-soft); }

/* Container ------------------------------------------------------------ */
.container {
  max-width: 720px;
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
}

/* Hero ----------------------------------------------------------------- */
.hero {
  padding: 1rem 0 2rem;
  border-bottom: 1px solid var(--rule);
  margin-bottom: 2rem;
}
.hero h1 { font-size: 2.5rem; margin-bottom: 0.25rem; }
.hero .lead { font-size: 1.1rem; color: var(--ink-soft); margin-top: 0; }

/* Cards ---------------------------------------------------------------- */
.card {
  background: #fff;
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 1.5rem 1.75rem;
  box-shadow: 0 1px 0 rgba(0,0,0,0.02);
}

/* Forms ---------------------------------------------------------------- */
.stacked {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-top: 1rem;
}
.stacked label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.95rem;
  color: var(--ink-soft);
  font-family: var(--sans);
}
.stacked input[type=email],
.stacked input[type=text],
.stacked input[type=tel],
.stacked select,
.stacked textarea {
  font-family: var(--sans);
  font-size: 1rem;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--rule);
  border-radius: 4px;
  background: #fff;
  color: var(--ink);
}
.stacked input:focus,
.stacked select:focus,
.stacked textarea:focus {
  outline: 2px solid var(--accent-soft);
  outline-offset: -1px;
}

/* Buttons -------------------------------------------------------------- */
.btn {
  display: inline-block;
  padding: 0.65rem 1.2rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 4px;
  font-size: 1rem;
  font-family: var(--sans);
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: background 120ms ease;
}
.btn:hover { background: var(--accent-soft); color: #fff; }
.btn:focus { outline: 2px solid var(--ink); outline-offset: 2px; }
.btn-danger { background: var(--error); }
.btn-danger:hover { background: #8a2418; }

.stacked .btn { align-self: flex-start; }
.stacked .checkbox { font-family: var(--sans); }

button.link, .logout-form button {
  background: none;
  border: none;
  padding: 0;
  color: var(--accent);
  text-decoration: underline;
  cursor: pointer;
  font: inherit;
  font-family: var(--sans);
  font-size: 0.9rem;
}
.logout-form { display: inline; margin: 0; }

/* Badges --------------------------------------------------------------- */
.badge {
  display: inline-block;
  padding: 0.1rem 0.5rem;
  background: var(--warn-bg);
  border: 1px solid var(--rule);
  border-radius: 3px;
  font-size: 0.75rem;
  color: var(--ink-soft);
  font-family: var(--sans);
  margin-left: 0.5rem;
}

/* Lists ---------------------------------------------------------------- */
.nav-list { list-style: none; padding: 0; }
.nav-list li { padding: 0.4rem 0; border-bottom: 1px dotted var(--rule); }

/* Admin layout -------------------------------------------------------- */
.admin-header {
  margin-bottom: 1.5rem;
}
.admin-header h1 { margin-bottom: 0.25rem; }
.admin-header .muted { margin: 0; }

section + section { margin-top: 2rem; }

/* Inline form: stack on mobile, side-by-side on wide */
.inline-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.75rem;
  align-items: end;
}
.inline-form label { margin: 0; }
.inline-form .btn { white-space: nowrap; }

/* Tables -------------------------------------------------------------- */
table.data {
  width: 100%;
  border-collapse: collapse;
  margin-top: 0.75rem;
  font-family: var(--sans);
  font-size: 0.92rem;
}
table.data thead {
  background: #fff;
  border-bottom: 2px solid var(--rule);
}
table.data th {
  text-align: left;
  padding: 0.55rem 0.7rem;
  color: var(--ink-soft);
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
table.data td {
  padding: 0.55rem 0.7rem;
  border-bottom: 1px dotted var(--rule);
  vertical-align: middle;
}
table.data tbody tr:hover { background: rgba(26, 58, 82, 0.03); }
table.data .muted { color: var(--ink-faint); }

/* Keep long strings + wide content inside their cards (was overrunning the
   right edge on narrow screens — long URLs, codes, emails don't wrap by
   default, and width:100% tables push past the card). */
.card { overflow-wrap: anywhere; }
.card code, .card pre { overflow-wrap: anywhere; word-break: break-all; }
table.data td, table.data th { overflow-wrap: anywhere; }

/* Status pills -------------------------------------------------------- */
.status {
  display: inline-block;
  padding: 0.1rem 0.55rem;
  font-size: 0.78rem;
  font-weight: 600;
  border-radius: 999px;
  letter-spacing: 0.02em;
}
.status-pending { background: #e8f0f8; color: #1a3a52; border: 1px solid #c4d4e4; }
.status-expired { background: #f4e8e6; color: #813020; border: 1px solid #e0c0b8; }
.status-registered { background: #e6f2ea; color: #2a7a3a; border: 1px solid #b8d8c0; }
.status-active { background: #d4eada; color: #1a5a2a; border: 1px solid #94c4a4; }
.status-pass { background: #d4eada; color: #1a5a2a; border: 1px solid #94c4a4; }
.status-fail { background: #f4e8e6; color: #813020; border: 1px solid #e0c0b8; }
.status-blocked { background: #fff5e6; color: #8a5a10; border: 1px solid #e0c890; }

/* Observe form ------------------------------------------------------- */
.stacked fieldset {
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: 0.6rem 1rem 0.9rem;
  margin: 0;
}
.stacked fieldset legend { font-family: var(--sans); font-size: 0.85rem; color: var(--ink-soft); padding: 0 0.3rem; }
.stacked .radio { display: inline-flex; align-items: center; gap: 0.4rem; margin-right: 1rem; flex-direction: row; font-family: var(--sans); }
.btn-sm { padding: 0.3rem 0.7rem; font-size: 0.85rem; }

/* Count badges next to section headings */
h2 .count {
  display: inline-block;
  background: #f4f0e8;
  color: var(--ink-soft);
  border: 1px solid var(--rule);
  border-radius: 999px;
  padding: 0.05rem 0.55rem;
  margin-left: 0.4rem;
  font-size: 0.7rem;
  font-weight: 500;
  vertical-align: middle;
  font-family: var(--sans);
}
.empty { padding: 1rem 0; }

/* Flash messages ------------------------------------------------------ */
.flash {
  padding: 0.7rem 1rem;
  border-radius: 4px;
  margin: 0 0 1.25rem;
  font-family: var(--sans);
  font-size: 0.95rem;
}
.flash-ok { background: #e6f2ea; color: #1f5a2a; border: 1px solid #b8d8c0; }
.flash-error { background: #f8e6e0; color: #813020; border: 1px solid #e0c0b8; }

/* Profile detail ------------------------------------------------------ */
.profile-block { margin-bottom: 1.25rem; }
.profile-block h2 { font-size: 1.1rem; margin-top: 0; padding-bottom: 0.5rem; border-bottom: 1px solid var(--rule); }
.profile-block h3 { font-size: 0.95rem; margin-top: 1rem; color: var(--ink-soft); font-weight: 600; }
.profile-block address { font-style: normal; line-height: 1.5; }
.prewrap { white-space: pre-wrap; }
dl.profile {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.4rem 1.25rem;
  margin: 0;
  font-family: var(--sans);
  font-size: 0.95rem;
}
dl.profile dt { color: var(--ink-soft); font-weight: 500; }
dl.profile dd { margin: 0; color: var(--ink); }
.see-all { font-family: var(--sans); font-size: 0.8rem; font-weight: 500; margin-left: 0.5rem; vertical-align: middle; }

/* Registration ------------------------------------------------------- */
.register-intro { margin-bottom: 1.5rem; padding-bottom: 1rem; border-bottom: 1px solid var(--rule); }
.register-intro h1 { margin-bottom: 0.4rem; }
.register-intro .muted { margin: 0; }
.register-form fieldset { border: 1px solid var(--rule); border-radius: 6px; padding: 1.25rem 1.5rem 1.5rem; background: #fff; margin: 0 0 1.25rem; }
.register-form legend { padding: 0 0.5rem; font-weight: 600; font-family: var(--sans); font-size: 0.95rem; color: var(--ink); }
.register-form fieldset > * + * { margin-top: 0.85rem; }
.register-form .row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0.85rem; }
.req { color: var(--error); font-weight: 700; margin-left: 0.15rem; }
.small { font-size: 0.85rem; }
.btn-primary { display: inline-block; padding: 0.85rem 1.6rem; font-size: 1.05rem; }

/* NDA display + checkbox --------------------------------------------- */
.nda-document {
  background: #fff;
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 1.5rem 2rem;
  max-height: 60vh;
  overflow-y: auto;
  margin: 1rem 0 1.5rem;
  font-size: 0.96rem;
}
.nda-document h1 { font-size: 1.4rem; margin-top: 0; }
.nda-document h2 { font-size: 1.15rem; margin-top: 1.5rem; padding-top: 0.5rem; border-top: 1px solid var(--rule); }
.nda-document h3 { font-size: 1rem; }
.nda-document blockquote { border-left: 3px solid var(--accent); margin: 1rem 0; padding: 0.4rem 1rem; background: #f4f0e8; color: var(--ink-soft); }
.nda-document code { background: #f4f0e8; padding: 0.1rem 0.4rem; border-radius: 3px; font-size: 0.92em; }
.nda-document strong { color: var(--ink); }
.nda-document hr { border: 0; border-top: 1px solid var(--rule); margin: 1.5rem 0; }

/* One-time secret reveal (e.g. a freshly rotated vendor service token).
   Monospace + selectable-in-one-click so the operator can copy it before it's
   gone; wraps so a long token never overruns the card. */
.token-reveal {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  background: #f4f0e8;
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: 0.75rem 1rem;
  margin: 0.5rem 0;
  font-size: 0.95rem;
  overflow-wrap: anywhere;
  word-break: break-all;
  user-select: all;
}

.nda-form .checkbox {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  font-family: var(--sans);
  font-size: 1rem;
  color: var(--ink);
  cursor: pointer;
}
.nda-form .checkbox input { width: 1.15rem; height: 1.15rem; margin-top: 0.2rem; }
.register-done { text-align: left; }
.register-done h1 { color: var(--ok); }

/* Mobile (375px target) ----------------------------------------------- */
@media (max-width: 480px) {
  .site-header { flex-wrap: wrap; padding: 0.75rem 1rem; }
  .site-header .tagline { width: 100%; }
  .site-nav { margin-left: 0; }
  .container { padding: 1.25rem 1rem 3rem; }
  .hero h1 { font-size: 2rem; }
  .card { padding: 1.2rem; overflow-x: auto; } /* wide tables scroll inside the card, don't spill past it */
  .inline-form { grid-template-columns: 1fr; }
  table.data { font-size: 0.85rem; }
  table.data th, table.data td { padding: 0.4rem 0.5rem; }
  .register-form fieldset { padding: 1rem; }
  .register-form .row-2 { grid-template-columns: 1fr; }
  .nda-document { padding: 1rem; max-height: 50vh; }
}

.filter-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.9rem 1rem;
  align-items: end;
}
.filter-form label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-family: var(--sans);
  font-size: 0.85rem;
  color: var(--ink-soft);
}
.filter-form input[type=date],
.filter-form select {
  padding: 0.45rem 0.55rem;
  font-family: inherit;
  font-size: 0.95rem;
  border: 1px solid var(--ink-faint);
  border-radius: 4px;
  background: #fff;
}
.filter-form-actions {
  grid-column: 1 / -1;
  display: flex;
  gap: 0.7rem;
  align-items: center;
}
.filter-form-actions .link {
  font-family: var(--sans);
  font-size: 0.85rem;
  color: var(--ink-soft);
}

.report-totals {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin: 1rem 0 1.5rem;
}
.report-totals .total {
  background: var(--paper);
  border: 1px solid var(--ink-faint);
  padding: 0.9rem 1rem;
  border-radius: 6px;
}
.report-totals .total .label {
  font-family: var(--sans);
  font-size: 0.8rem;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.report-totals .total .value {
  font-size: 1.4rem;
  font-family: var(--serif);
  margin-top: 0.2rem;
}

/* Instance state pills -------------------------------------------------- */
.status-provisioning  { background: #dde8f8; color: #1a3a78; border: 1px solid #b4c8ec; }
.status-tearing_down  { background: #dde8f8; color: #1a3a78; border: 1px solid #b4c8ec; }
.status-ready         { background: #d4eada; color: #1a5a2a; border: 1px solid #94c4a4; }
.status-smoke_failed  { background: #f4e8e6; color: #813020; border: 1px solid #e0c0b8; }
.status-contract_violation { background: #f4e8e6; color: #813020; border: 1px solid #e0c0b8; }
.status-provision_failed   { background: #f4e8e6; color: #813020; border: 1px solid #e0c0b8; }
.status-torn_down     { background: #f0ede8; color: #555; border: 1px solid #ccc; }
.status-degraded      { background: #fff5e6; color: #8a5a10; border: 1px solid #e0c890; }

/* Animated ellipsis for in-flight states */
.dots::after {
  content: '...';
  display: inline-block;
  animation: blink-dots 1.4s infinite;
  letter-spacing: 0.05em;
}
@keyframes blink-dots {
  0%   { opacity: 1; }
  50%  { opacity: 0.2; }
  100% { opacity: 1; }
}

/* Clock-skew banners ---------------------------------------------------- */
.skew-banner {
  padding: 0.6rem 1rem;
  border-radius: 4px;
  margin: 0.75rem 0;
  font-family: var(--sans);
  font-size: 0.9rem;
}
.skew-banner-warn    { background: #fff5e6; border: 1px solid #e8c879; color: #5a3a00; }
.skew-banner-block   { background: #f8e6e0; border: 1px solid #e0a090; color: #813020; }

/* Instance detail card -------------------------------------------------- */
.instance-detail dl.profile dt { min-width: 7rem; }
.latest-error-block {
  background: #fff8e0;
  border: 1px solid #e8c879;
  border-radius: 4px;
  padding: 0.6rem 0.85rem;
  margin-top: 0.75rem;
  font-family: var(--sans);
  font-size: 0.85rem;
  white-space: pre-wrap;
  word-break: break-word;
}
.latest-error-block strong { display: block; margin-bottom: 0.2rem; color: #5a3a00; }

/* Dashboard widget ------------------------------------------------------ */
.dashboard-widget { margin-bottom: 2rem; }
.dashboard-widget-counts {
  display: flex;
  gap: 1.5rem;
  margin-bottom: 0.85rem;
  flex-wrap: wrap;
}
.dashboard-count {
  font-family: var(--sans);
  font-size: 0.9rem;
  color: var(--ink-soft);
}
.dashboard-count strong { font-size: 1.2rem; color: var(--ink); margin-right: 0.25rem; }
.dashboard-count.has-issues strong { color: var(--error); }

/* Button row spacing */
.btn-row {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-top: 0.85rem;
}
.btn-warning { background: #c07010; }
.btn-warning:hover { background: #9a5a00; }
