/* ============================================================================
   Stone Age Software — Apps Platform stylesheet (static/css/platform.css)

   Clean, professional SaaS look: light background, dark ink, one confident
   blue accent, system font stack, subtle shadows, responsive to 360px.
   No frameworks — every class here is part of the template contract in
   docs/SPEC.md.
   ========================================================================== */

/* --- Design tokens ---------------------------------------------------------- */

:root {
  --ink: #1c2431;            /* primary text */
  --ink-soft: #4a5568;       /* secondary text, nav links */
  --muted: #64748b;          /* helper / meta text */
  --bg: #f5f7fa;             /* page background */
  --surface: #ffffff;        /* cards, header, inputs */
  --line: #dde4ee;           /* hairline borders */
  --line-soft: #eaeef5;

  --accent: #2457d6;         /* the one confident accent */
  --accent-strong: #1c46b3;
  --accent-tint: #e9effc;
  --accent-line: #c6d5f5;
  --accent-ring: rgba(36, 87, 214, 0.16);

  --green: #15803d;
  --green-tint: #e7f6ec;
  --green-line: #b9e2c6;

  --amber: #b45309;
  --amber-tint: #fdf3e2;
  --amber-line: #f2dcb0;

  --red: #b3261e;
  --red-tint: #fdecea;
  --red-line: #f2c4c0;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow-card: 0 1px 2px rgba(16, 24, 40, 0.05), 0 4px 14px rgba(16, 24, 40, 0.06);
  --shadow-header: 0 1px 3px rgba(16, 24, 40, 0.06);

  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue",
    Arial, "Noto Sans", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
    "Liberation Mono", monospace;
}

/* --- Base --------------------------------------------------------------------- */

*,
*::before,
*::after {
  box-sizing: border-box;
}

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

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

h1, h2, h3, h4 {
  color: var(--ink);
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.25;
  margin: 0 0 0.6rem;
}

h1 { font-size: 1.6rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1.05rem; }
h4 { font-size: 0.95rem; }

p {
  margin: 0 0 1rem;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  color: var(--accent-strong);
  text-decoration: underline;
}

ul, ol {
  margin: 0 0 1rem;
  padding-left: 1.25rem;
}

li {
  margin: 0.3rem 0;
}

code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: #eef1f6;
  border-radius: 6px;
  padding: 0.12em 0.4em;
}

hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 1.5rem 0;
}

img, svg {
  max-width: 100%;
}

::selection {
  background: var(--accent-tint);
  color: var(--ink);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

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

.container {
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 1.25rem;
}

.main-content {
  flex: 1 0 auto;
  padding: 2rem 1.25rem 3.5rem;
}

/* --- Sticky header ------------------------------------------------------------------ */

.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255, 255, 255, 0.94);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  box-shadow: var(--shadow-header);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1.25rem;
  flex-wrap: wrap;
  min-height: 3.6rem;
  padding-top: 0.5rem;
  padding-bottom: 0.5rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--ink);
  font-size: 1.05rem;
  font-weight: 500;
  white-space: nowrap;
}

.brand:hover {
  color: var(--ink);
  text-decoration: none;
}

.brand strong {
  font-weight: 800;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-size: 0.75rem;
  line-height: 1;
  flex: none;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 0.35rem 1.1rem;
  flex-wrap: wrap;
}

.site-nav a {
  color: var(--ink-soft);
  font-size: 0.95rem;
  font-weight: 500;
  padding: 0.25rem 0;
}

.site-nav a:hover {
  color: var(--accent);
  text-decoration: none;
}

.inline-form {
  display: inline-block;
  margin: 0;
}

/* --- Footer --------------------------------------------------------------------------- */

.site-footer {
  flex-shrink: 0;
  border-top: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  font-size: 0.85rem;
  padding: 1.4rem 0 1.8rem;
}

.site-footer p {
  margin: 0;
}

.site-footer a {
  color: var(--muted);
  text-decoration: underline;
}

.site-footer a:hover {
  color: var(--accent);
}

/* --- Flash messages ----------------------------------------------------------------------- */

.flash-stack {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-bottom: 1.4rem;
}

.flash {
  padding: 0.8rem 1rem;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font-size: 0.95rem;
}

.flash a {
  font-weight: 600;
  text-decoration: underline;
  color: inherit;
}

.flash a:hover {
  color: var(--accent-strong);
}

.flash-info {
  background: var(--accent-tint);
  border-color: var(--accent-line);
  color: #1e3a8a;
}

.flash-success {
  background: var(--green-tint);
  border-color: var(--green-line);
  color: #14532d;
}

.flash-warning {
  background: var(--amber-tint);
  border-color: var(--amber-line);
  color: #7c3f06;
}

.flash-error {
  background: var(--red-tint);
  border-color: var(--red-line);
  color: #8c1d18;
}

/* --- Page header ------------------------------------------------------------------------------ */

.page-header {
  margin-bottom: 1.6rem;
}

.page-header h1 {
  margin-bottom: 0.35rem;
}

.page-header p {
  margin: 0;
  max-width: 62ch;
}

/* --- Cards ---------------------------------------------------------------------------------------- */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.card > :first-child {
  margin-top: 0;
}

.card > :last-child {
  margin-bottom: 0;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}

.card-grid .card {
  margin-bottom: 0;
}

.app-card {
  display: flex;
  flex-direction: column;
}

.app-card h2 {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.app-card .btn {
  margin-top: auto;
  align-self: flex-start;
}

.auth-card {
  max-width: 430px;
  margin: 2.5rem auto 1.5rem;
}

.auth-card h1 {
  margin-bottom: 0.35rem;
}

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

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.55rem 1.15rem;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: #eef1f6;
  color: var(--ink);
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.3;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color 0.15s ease, border-color 0.15s ease,
    color 0.15s ease, box-shadow 0.15s ease;
}

.btn:hover {
  text-decoration: none;
}

.btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-ring);
}

.btn:disabled,
.btn[disabled] {
  opacity: 0.55;
  cursor: not-allowed;
  pointer-events: none;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
  color: #fff;
}

.btn-secondary {
  background: var(--surface);
  border-color: var(--line);
  color: var(--ink-soft);
}

.btn-secondary:hover {
  background: #f3f6fb;
  border-color: #c9d4e5;
  color: var(--ink);
}

.btn-danger {
  background: var(--surface);
  border-color: var(--red-line);
  color: var(--red);
}

.btn-danger:hover {
  background: var(--red);
  border-color: var(--red);
  color: #fff;
}

.btn-link {
  background: none;
  border: none;
  padding: 0.25rem 0;
  color: var(--ink-soft);
  font-size: 0.95rem;
  font-weight: 500;
}

.btn-link:hover {
  color: var(--accent);
  background: none;
  text-decoration: underline;
}

.btn-sm {
  padding: 0.32rem 0.75rem;
  font-size: 0.85rem;
  border-radius: 7px;
}

.card form + .inline-form,
.card .btn + .inline-form {
  margin-top: 0.75rem;
}

/* --- Forms ------------------------------------------------------------------------------------------------ */

.form-group {
  margin-bottom: 1.1rem;
}

.form-label {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 0.35rem;
}

.form-input {
  display: block;
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: 1px solid #c7d2e0;
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  font-family: inherit;
  font-size: 0.95rem;
  line-height: 1.4;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

textarea.form-input {
  min-height: 9rem;
  resize: vertical;
}

.form-input::placeholder {
  color: #9aa7b8;
}

.form-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}

.form-help {
  margin: 0.35rem 0 0;
  font-size: 0.82rem;
  color: var(--muted);
}

/* --- Tables ------------------------------------------------------------------------------------------------- */

.table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  font-size: 0.95rem;
}

.table th {
  text-align: left;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  padding: 0.6rem 0.75rem;
  border-bottom: 2px solid var(--line);
}

.table td {
  padding: 0.7rem 0.75rem;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: top;
}

.table tbody tr:last-child td {
  border-bottom: none;
}

.table tbody tr:hover td {
  background: #f7f9fc;
}

/* --- Badges & chips --------------------------------------------------------------------------------------------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.16rem 0.6rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #eef1f6;
  color: var(--ink-soft);
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.4;
  white-space: nowrap;
  vertical-align: middle;
}

.badge-source {
  background: var(--accent-tint);
  border-color: var(--accent-line);
  color: var(--accent-strong);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.badge-cert {
  white-space: normal;
  text-align: left;
}

.badge-cert-held {
  background: var(--green-tint);
  border-color: var(--green-line);
  color: var(--green);
}

.badge-cert-missing {
  background: var(--amber-tint);
  border-color: var(--amber-line);
  color: var(--amber);
}

.keyword-chip {
  display: inline-flex;
  align-items: center;
  padding: 0.14rem 0.55rem;
  margin: 0 0.3rem 0.3rem 0;
  border-radius: 999px;
  border: 1px solid #dbe3f0;
  background: #eef2f9;
  color: #3d4a5f;
  font-size: 0.78rem;
  font-weight: 500;
  white-space: nowrap;
}

.score-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.6rem;
  padding: 0.22rem 0.65rem;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 0.85rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* --- Subscription status badges ------------------------------------------------------------------------------------ */

.status-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.18rem 0.65rem;
  margin-left: 0.5rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #eef1f6;
  color: var(--ink-soft);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  vertical-align: middle;
  white-space: nowrap;
}

.status-active {
  background: var(--green-tint);
  border-color: var(--green-line);
  color: var(--green);
}

.status-trialing {
  background: var(--accent-tint);
  border-color: var(--accent-line);
  color: var(--accent-strong);
}

.status-none {
  background: #eef1f6;
  border-color: var(--line);
  color: var(--muted);
}

.status-past_due {
  background: var(--amber-tint);
  border-color: var(--amber-line);
  color: var(--amber);
}

.status-canceled {
  background: var(--red-tint);
  border-color: var(--red-line);
  color: var(--red);
}

/* --- Sourcing Bot: opportunity cards ---------------------------------------------------------------------------------- */

.opp-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.1rem;
}

.opp-card > :last-child {
  margin-bottom: 0;
}

.opp-card h3 {
  margin: 0.35rem 0;
  font-size: 1.08rem;
}

.opp-card h3 a {
  color: var(--ink);
}

.opp-card h3 a:hover {
  color: var(--accent);
}

.opp-ineligible {
  border-left-color: var(--amber);
  background: #fbfaf7;
}

.opp-ineligible h3 a {
  color: var(--ink-soft);
}

.opp-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.3rem 1.1rem;
  margin: 0.35rem 0 0.6rem;
  color: var(--muted);
  font-size: 0.85rem;
}

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

.muted {
  color: var(--muted);
}

.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
  border: 1.5px dashed #c9d4e5;
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--muted);
  margin-bottom: 1.5rem;
}

.empty-state h1,
.empty-state h2,
.empty-state h3 {
  color: var(--ink);
}

.empty-state .btn {
  margin-top: 0.5rem;
}

/* --- Responsive ------------------------------------------------------------------------------------------------------------ */

@media (max-width: 720px) {
  h1 { font-size: 1.4rem; }
  h2 { font-size: 1.12rem; }

  .main-content {
    padding: 1.4rem 1rem 2.5rem;
  }

  .container {
    padding: 0 1rem;
  }

  .card,
  .opp-card {
    padding: 1.15rem 1.15rem;
  }

  .auth-card {
    margin-top: 1.25rem;
  }

  .table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

@media (max-width: 460px) {
  .card-grid {
    grid-template-columns: 1fr;
  }

  .site-nav {
    gap: 0.25rem 0.8rem;
    font-size: 0.9rem;
  }

  .site-nav a,
  .site-nav .btn-link {
    font-size: 0.9rem;
  }

  .opp-meta {
    gap: 0.25rem 0.8rem;
  }

  .btn {
    white-space: normal;
  }
}
