/* ==========================================================================
   Backlinks Observer · Design system
   Shared by the public site (site.css), the auth pages and the client app (app.css).
   1. Tokens   2. Base   3. Layout   4. Components   5. Utilities
   Rules: Inter only, no gradient, no shadow, text never below 14px,
   orange is reserved for the main call to action and for detected changes.
   ========================================================================== */

/* 1. Tokens --------------------------------------------------------------- */
:root {
  /* Brand */
  --brand: #00B2FF;
  --accent: #FF7A00;
  --navy: #06364D;

  /* Semantic colours (light) */
  --bg: #FFFFFF;
  --bg-app: #F5FAFD;
  --surface: #FFFFFF;
  --tint: #EEF9FF;
  --tint-strong: #BFE9FC;
  --line: #D6E7F0;
  --ink: #042B3F;
  --ink-2: #43657A;
  --brand-ink: #00719F;
  --on-accent: #06364D;
  --on-ink: #FFFFFF;
  --ok-bg: #E2F5FE;      --ok-ink: #005F87;
  --warn-bg: #FFEFDD;    --warn-ink: #8F4500;
  --danger: #C2334A;     --danger-bg: #FCEBEE;   --danger-ink: #A32439;
  --neutral-bg: #EDF2F5; --neutral-ink: #48687A;

  /* Typography */
  --font: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", Consolas, "Liberation Mono", monospace;
  --fs-sm: 0.875rem;   /* 14 */
  --fs-md: 1rem;       /* 16 */
  --fs-lg: 1.125rem;   /* 18 */
  --fs-xl: 1.375rem;   /* 22 */
  --fs-2xl: clamp(1.625rem, 1.2rem + 1.6vw, 2.25rem);
  --fs-3xl: clamp(2.25rem, 1.3rem + 3.6vw, 3.75rem);

  /* Space (4px grid) */
  --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px; --s-5: 24px;
  --s-6: 32px; --s-7: 48px; --s-8: 64px; --s-9: 96px;

  /* Shape and motion */
  --r-sm: 6px; --r-md: 10px; --r-pill: 999px;
  --ease: cubic-bezier(.2, .7, .2, 1);
  --t-fast: .16s; --t-slow: .6s;
  --header-h: 68px;
  --container: 1160px;
  color-scheme: light;
}
[data-bs-theme="dark"] {
  /* Black leads the dark theme; blues carry structure and light. */
  --bg: #000000;
  --bg-app: #03080B;
  --surface: #071219;
  --tint: #081C27;
  --tint-strong: #12394E;
  --line: #16303F;
  --ink: #F2FAFF;
  --ink-2: #9CB8C7;
  --brand-ink: #4FC8FF;
  --on-ink: #021824;
  --ok-bg: #0A2C3D;      --ok-ink: #8EDBFF;
  --warn-bg: #3A2206;    --warn-ink: #FFB872;
  --danger: #FF8094;     --danger-bg: #3A141D;   --danger-ink: #FFA3B2;
  --neutral-bg: #10222D; --neutral-ink: #9CB8C7;
  color-scheme: dark;
}

/* 2. Base ----------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: calc(var(--header-h) + 16px); }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 var(--fs-md)/1.6 var(--font); -webkit-font-smoothing: antialiased; }
h1, h2, h3, h4, p, ul, ol, dl, dd, figure, fieldset, legend { margin: 0; padding: 0; }
h1, h2, h3, h4 { line-height: 1.15; letter-spacing: -.02em; font-weight: 700; text-wrap: balance; }
h1 { font-size: var(--fs-3xl); letter-spacing: -.035em; line-height: 1.05; }
h2 { font-size: var(--fs-2xl); }
h3 { font-size: var(--fs-lg); letter-spacing: -.01em; }
p { text-wrap: pretty; }
ul, ol { list-style: none; }
img, svg { max-width: 100%; vertical-align: middle; }
img { height: auto; }
a { color: var(--brand-ink); text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
fieldset { border: 0; min-width: 0; }
code, pre { font-family: var(--mono); font-size: var(--fs-sm); }
code { background: var(--tint); padding: 2px 6px; border-radius: 4px; overflow-wrap: anywhere; }
:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; border-radius: 4px; }
::selection { background: var(--tint-strong); color: var(--ink); }

/* 3. Layout --------------------------------------------------------------- */
.container { width: min(100% - 40px, var(--container)); margin-inline: auto; }
.section { padding-block: var(--s-9); }
.section-tint { background: var(--tint); }
.stack > * + * { margin-top: var(--s-4); }
.cluster { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-3); }
.split { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s-4); }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-5); }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s-5); }
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--s-4); }
@media (max-width: 900px) { .grid-3, .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .section { padding-block: var(--s-8); } }
@media (max-width: 620px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

/* 4. Components ----------------------------------------------------------- */

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2); min-height: 44px; padding: 10px 18px; border: 1.5px solid transparent; border-radius: var(--r-sm); background: transparent; color: var(--ink); font-size: var(--fs-sm); font-weight: 650; line-height: 1.2; text-decoration: none; white-space: nowrap; transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast), transform var(--t-fast); }
.btn:active { transform: translateY(1px); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; }
.btn-accent { background: var(--accent); color: var(--on-accent); }
.btn-accent:hover { background: #FF8F26; }
.btn-primary { background: var(--ink); color: var(--on-ink); }
.btn-primary:hover { background: var(--brand-ink); color: var(--bg); }
.btn-outline { border-color: var(--line); background: var(--surface); }
.btn-outline:hover { border-color: var(--ink); }
.btn-ghost:hover { background: var(--tint); }
.btn-danger { border-color: var(--danger); color: var(--danger-ink); }
.btn-danger:hover { background: var(--danger-bg); }
.btn-sm { min-height: 36px; padding: 6px 12px; }
.btn-lg { min-height: 52px; padding: 14px 24px; font-size: var(--fs-md); }
.btn-block { width: 100%; }

/* Arrow link */
.link-arrow { display: inline-flex; align-items: center; gap: 6px; font-weight: 650; font-size: var(--fs-sm); color: var(--ink); text-decoration: none; border-bottom: 1.5px solid var(--brand); padding-bottom: 2px; }
.link-arrow::after { content: "→"; transition: transform var(--t-fast); }
.link-arrow:hover::after { transform: translateX(3px); }

/* Forms */
.field { display: block; margin-bottom: var(--s-4); }
.field > span:first-child, .label { display: block; font-size: var(--fs-sm); font-weight: 600; margin-bottom: 6px; }
.form-control, .form-select { display: block; width: 100%; min-height: 44px; padding: 9px 12px; background: var(--surface); border: 1.5px solid var(--line); border-radius: var(--r-sm); font-size: var(--fs-md); line-height: 1.4; transition: border-color var(--t-fast); }
.form-control:hover, .form-select:hover { border-color: var(--ink-2); }
.form-control:focus, .form-select:focus { outline: 0; border-color: var(--brand); box-shadow: 0 0 0 3px var(--tint-strong); }
.form-control[readonly] { background: var(--neutral-bg); color: var(--ink-2); }
.form-control::placeholder { color: var(--ink-2); opacity: .75; }
textarea.form-control { resize: vertical; }
.form-select { appearance: none; padding-right: 36px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4 6l4 4 4-4' fill='none' stroke='%2348687A' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; background-size: 14px; }
.form-text { display: block; margin-top: 6px; font-size: var(--fs-sm); font-weight: 400; color: var(--ink-2); }
.form-check { display: flex; align-items: flex-start; gap: var(--s-3); margin-bottom: var(--s-3); font-size: var(--fs-sm); font-weight: 500; cursor: pointer; }
.form-check input { flex: none; width: 20px; height: 20px; margin: 1px 0 0; accent-color: var(--brand-ink); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 var(--s-5); }
@media (max-width: 720px) { .form-grid { grid-template-columns: 1fr; } }
.form-section { padding-top: var(--s-5); margin-top: var(--s-5); border-top: 1px solid var(--line); }
.form-section > legend { float: left; width: 100%; font-size: var(--fs-md); font-weight: 700; margin-bottom: var(--s-4); }
.form-section > legend + * { clear: both; }
.form-section > legend small { font-size: var(--fs-sm); font-weight: 400; color: var(--ink-2); }

/* Card */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: var(--s-5); min-width: 0; }
.card-title { font-size: var(--fs-lg); margin-bottom: var(--s-4); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); margin-bottom: var(--s-4); }
.card-head .card-title { margin: 0; }

/* Status badge: colour is never the only signal, the label carries the state. */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: var(--r-pill); font-size: var(--fs-sm); font-weight: 600; white-space: nowrap; background: var(--neutral-bg); color: var(--neutral-ink); }
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.status-conformant { background: var(--ok-bg); color: var(--ok-ink); }
.status-modified { background: var(--warn-bg); color: var(--warn-ink); }
.status-missing { background: var(--danger-bg); color: var(--danger-ink); }
.status-pending::before { background: transparent; box-shadow: inset 0 0 0 1.5px currentColor; }

/* Alerts */
.notice, .error { padding: 12px 16px; border-radius: var(--r-sm); font-size: var(--fs-sm); font-weight: 500; border-left: 4px solid; }
.notice { background: var(--ok-bg); color: var(--ok-ink); border-color: var(--brand); }
.error { background: var(--danger-bg); color: var(--danger-ink); border-color: var(--danger); }

/* Table */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); }
.table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.table th { text-align: left; font-weight: 600; color: var(--ink-2); padding: 12px 16px; background: var(--bg-app); border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 14px 16px; border-bottom: 1px solid var(--line); vertical-align: top; overflow-wrap: anywhere; }
.table tbody tr:last-child td { border-bottom: 0; }
.table td small { display: block; color: var(--ink-2); font-size: var(--fs-sm); }

/* Tabs */
.tabs { display: flex; gap: var(--s-5); border-bottom: 1px solid var(--line); margin-bottom: var(--s-5); overflow-x: auto; overflow-y: hidden; scrollbar-width: thin; }
.tabs a { padding: 10px 0 12px; font-size: var(--fs-sm); font-weight: 600; color: var(--ink-2); text-decoration: none; white-space: nowrap; border-bottom: 2.5px solid transparent; }
.tabs a:hover { color: var(--ink); }
.tabs a[aria-current] { color: var(--ink); border-bottom-color: var(--accent); }

/* Disclosure */
.disclosure > summary { cursor: pointer; font-size: var(--fs-sm); font-weight: 600; list-style: none; display: flex; align-items: center; gap: var(--s-2); }
.disclosure > summary::-webkit-details-marker { display: none; }
.disclosure > summary::before { content: "+"; display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; background: var(--tint); color: var(--brand-ink); font-weight: 700; line-height: 1; }
.disclosure[open] > summary::before { content: "−"; }

/* Check list */
.check-list li { position: relative; padding-left: 28px; margin-top: var(--s-2); }
.check-list li::before { content: ""; position: absolute; left: 0; top: .32em; width: 18px; height: 18px; border-radius: 50%; background: var(--brand) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 18 18'%3E%3Cpath d='M5 9.4l2.6 2.6L13 6.6' fill='none' stroke='%2306364D' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center/18px no-repeat; }

/* Pagination */
.pager { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); margin-top: var(--s-5); font-size: var(--fs-sm); color: var(--ink-2); }
.pager .cluster { gap: var(--s-2); }

/* 5. Utilities ------------------------------------------------------------ */
.muted { color: var(--ink-2); }
.small { font-size: var(--fs-sm); }
.strong { font-weight: 650; }
.mono { font-family: var(--mono); font-size: var(--fs-sm); }
.text-break { overflow-wrap: anywhere; }
.text-success { color: var(--ok-ink); }
.text-danger { color: var(--danger-ink); }
.d-flex { display: flex; }
.mt-0 { margin-top: 0; } .mt-4 { margin-top: var(--s-4); } .mt-5 { margin-top: var(--s-5); } .mb-0 { margin-bottom: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.skip-link { position: fixed; left: 16px; top: -100px; z-index: 1000; padding: 10px 16px; background: var(--ink); color: var(--on-ink); border-radius: var(--r-sm); font-weight: 600; }
.skip-link:focus { top: 12px; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
