/* Aster MR Portal — mobile-first, no external fonts, no frameworks. */

:root {
  --bg: #f2f4f7;
  --surface: #ffffff;
  --surface-2: #f7f9fb;
  --text: #17212b;
  --text-muted: #5b6876;
  --border: #dce2e8;
  --border-strong: #c3ccd5;
  --accent: #0e7065;
  --accent-strong: #0a574f;
  --accent-soft: #e6f4f1;
  --blue: #1f4fbf;
  --blue-soft: #e8eefc;
  --focus: #2563eb;
  --danger: #b42318;
  --danger-soft: #fbe9e7;
  --warn: #8a4b06;
  --warn-soft: #fdf1dc;
  --ok: #17603a;
  --ok-soft: #e3f4ea;
  --grey: #3d4650;
  --grey-soft: #ebedf0;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.05);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Noto Sans Bengali", Arial, sans-serif;
}

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 var(--font);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

h1, h2, h3 { line-height: 1.25; margin: 0 0 0.5em; color: var(--text); }
h1 { font-size: 1.5rem; font-weight: 700; letter-spacing: -0.01em; }
h2 { font-size: 1.15rem; font-weight: 650; }
h3 { font-size: 1rem; font-weight: 650; }
p { margin: 0 0 0.9em; }
a { color: var(--blue); text-underline-offset: 2px; }
a:hover { color: var(--accent-strong); }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.skip-link {
  position: absolute; left: 8px; top: -60px; z-index: 10;
  background: var(--surface); padding: 8px 14px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong);
}
.skip-link:focus { top: 8px; }

/* ---- Top bar ------------------------------------------------------------ */
.topbar { background: var(--surface); border-bottom: 1px solid var(--border); }
.topbar__inner {
  max-width: 1040px; margin: 0 auto; padding: 10px 16px;
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; justify-content: space-between;
}
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); min-height: 44px; }
.brand__mark { display: block; width: 34px; height: 34px; object-fit: contain; flex: none; }
.brand__text { font-size: 1.05rem; }
.brand__name { font-weight: 750; letter-spacing: 0.01em; }
.brand__product { color: var(--text-muted); font-weight: 500; }
.brand__tag {
  font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--blue); background: var(--blue-soft); padding: 2px 8px; border-radius: 999px;
}

.nav {
  display: flex; flex-wrap: nowrap; align-items: center; gap: 2px;
  width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -8px; padding: 0 0 2px;
}
.nav a, .nav__button {
  display: inline-flex; align-items: center; min-height: 44px; padding: 0 10px; border-radius: var(--radius-sm);
  color: var(--text); text-decoration: none; font: inherit; font-size: 0.95rem; white-space: nowrap;
  background: none; border: 0; cursor: pointer;
}
.nav__form { margin-left: auto !important; }
.nav a:hover, .nav__button:hover { background: var(--surface-2); color: var(--accent-strong); }
.nav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent-strong); font-weight: 600; }
.nav__form { margin: 0; }
.nav__button { color: var(--text-muted); }

/* ---- Layout ------------------------------------------------------------- */
.container { width: 100%; max-width: 1040px; margin: 0 auto; padding: 20px 16px 48px; flex: 1; }
.container:focus { outline: none; }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px; margin-bottom: 16px;
}
.card > :last-child { margin-bottom: 0; }
.narrow { max-width: 560px; margin-left: auto; margin-right: auto; }
.form-card { max-width: 680px; margin-left: auto; margin-right: auto; }

.page-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.page-head h1 { margin-bottom: 0.15em; }
.page-head--card { margin-bottom: 12px; }
.section-title { font-size: 1.05rem; margin: 24px 0 10px; }

.eyebrow { text-transform: uppercase; letter-spacing: 0.08em; font-size: 0.75rem; font-weight: 700; color: var(--accent); margin-bottom: 6px; }
.lead { font-size: 1.05rem; color: var(--text-muted); }
.muted { color: var(--text-muted); font-weight: 400; }
.small { font-size: 0.875rem; }
.breadcrumb { margin-bottom: 10px; font-size: 0.95rem; }
.tag {
  display: inline-block; font-size: 0.75rem; color: var(--text-muted); background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 999px; padding: 0 8px; vertical-align: middle;
}

/* ---- Landing ------------------------------------------------------------ */
.hero { padding: 24px 18px; }
.hero h1 { font-size: 1.6rem; }
.signin { margin: 18px 0 10px; }
.steps__list { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; }
.step { margin: 0; position: relative; padding-top: 16px; }
.step__number {
  display: inline-flex; width: 32px; height: 32px; align-items: center; justify-content: center;
  border-radius: 50%; background: var(--accent-soft); color: var(--accent-strong); font-weight: 700; margin-bottom: 8px;
}
.step p { color: var(--text-muted); margin: 0; }

/* ---- Buttons ------------------------------------------------------------ */
.button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 0 18px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  font: inherit; font-weight: 600; font-size: 0.95rem; text-decoration: none; cursor: pointer;
}
.button:hover { background: var(--surface-2); color: var(--text); }
.button--primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.button--primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); color: #fff; }
.button--danger { background: var(--surface); border-color: #e4a7a1; color: var(--danger); }
.button--danger:hover { background: var(--danger-soft); color: var(--danger); }
.button--large { min-height: 52px; padding: 0 26px; font-size: 1.05rem; }
.button--small { min-height: 36px; padding: 0 12px; font-size: 0.875rem; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }

/* ---- Forms -------------------------------------------------------------- */
.field { margin-bottom: 16px; }
.field label { display: block; font-weight: 600; margin-bottom: 4px; }
.field__optional { font-weight: 400; color: var(--text-muted); font-size: 0.875rem; }
.field__hint { margin: 0 0 6px; color: var(--text-muted); font-size: 0.875rem; }
.field__error { margin: 6px 0 0; color: var(--danger); font-size: 0.9rem; font-weight: 600; }
input[type="text"], input[type="tel"], input[type="email"], input[type="password"], input[type="search"], select, textarea {
  width: 100%; min-height: 44px; padding: 10px 12px; font: inherit; font-size: 16px; color: var(--text);
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
}
textarea { resize: vertical; line-height: 1.45; }
input[readonly] { background: var(--surface-2); }
input:focus, select:focus, textarea:focus { border-color: var(--focus); }
.field--invalid input, .field--invalid select, .field--invalid textarea { border-color: var(--danger); }
.field--check { display: grid; grid-template-columns: 24px 1fr; gap: 4px 10px; align-items: start; }
.field--check input { width: 22px; height: 22px; margin: 2px 0 0; accent-color: var(--accent); }
.field--check label { font-weight: 500; margin: 0; }
.field--check .field__error { grid-column: 2; }
fieldset { border: 0; padding: 0; margin: 0 0 16px; }
legend { font-weight: 600; margin-bottom: 6px; }
.radio { display: flex; align-items: flex-start; gap: 10px; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); margin-bottom: 8px; background: var(--surface); }
.radio input { width: 20px; height: 20px; margin-top: 2px; accent-color: var(--accent); }

.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-bottom: 14px; }
.filters .field { margin: 0; flex: 1 1 200px; }
.filters .field--narrow { flex: 0 1 180px; }

/* ---- Notices ------------------------------------------------------------ */
.notice {
  border: 1px solid var(--border); border-left-width: 4px; border-radius: var(--radius-sm);
  padding: 12px 14px; margin: 0 0 16px; background: var(--surface);
}
.notice p { margin: 4px 0 0; }
.notice strong { display: block; }
.notice--info { border-left-color: var(--blue); background: var(--blue-soft); }
.notice--success { border-left-color: var(--ok); background: var(--ok-soft); }
.notice--warning { border-left-color: #d08a18; background: var(--warn-soft); }
.notice--error { border-left-color: var(--danger); background: var(--danger-soft); }

/* ---- Badges ------------------------------------------------------------- */
.badge {
  display: inline-block; white-space: nowrap; font-size: 0.8rem; font-weight: 650;
  padding: 3px 10px; border-radius: 999px; background: var(--grey-soft); color: var(--grey);
}
.badge--pending { background: var(--blue-soft); color: #1e3f8a; }
.badge--needs_correction { background: var(--warn-soft); color: var(--warn); }
.badge--approved, .badge--active { background: var(--ok-soft); color: var(--ok); }
.badge--rejected { background: var(--danger-soft); color: #9b1c1c; }
.badge--suspended, .badge--retired, .badge--incomplete { background: var(--grey-soft); color: var(--grey); }

/* ---- Lists, tabs -------------------------------------------------------- */
.tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 10px; -webkit-overflow-scrolling: touch; }
.tabs a {
  display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 12px; white-space: nowrap;
  border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--text); text-decoration: none; font-size: 0.9rem;
}
.tabs a[aria-current="page"] { background: var(--accent); border-color: var(--accent); color: #fff; }
.tabs .count { font-size: 0.8rem; opacity: 0.8; }

.list { list-style: none; margin: 0 0 16px; padding: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.list__item + .list__item { border-top: 1px solid var(--border); }
.list__item--attention { box-shadow: inset 4px 0 0 #d08a18; }
.list__link { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; color: var(--text); text-decoration: none; min-height: 56px; }
.list__link:hover { background: var(--surface-2); color: var(--text); }
.list__main { display: flex; flex-direction: column; min-width: 0; }
.list__title { font-weight: 650; overflow-wrap: anywhere; }
.list__meta { font-size: 0.85rem; color: var(--text-muted); }
.empty { text-align: center; padding: 28px 18px; color: var(--text-muted); }

/* ---- Definition lists --------------------------------------------------- */
.dl { margin: 0 0 8px; }
.dl > div { padding: 10px 0; border-top: 1px solid var(--border); }
.dl > div:first-child { border-top: 0; }
.dl dt { font-size: 0.85rem; color: var(--text-muted); font-weight: 600; }
.dl dd { margin: 2px 0 0; overflow-wrap: anywhere; }
.dl--compact > div { padding: 6px 0; }
.summary { margin-top: 24px; }

/* ---- Timeline ----------------------------------------------------------- */
.timeline { list-style: none; margin: 0; padding: 0 0 0 18px; border-left: 2px solid var(--border); }
.timeline li { position: relative; padding: 4px 0 12px 8px; }
.timeline li::before { content: ""; position: absolute; left: -24px; top: 11px; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); border: 2px solid var(--surface); }
.timeline time { display: block; font-size: 0.8rem; color: var(--text-muted); }
.timeline .note { display: block; color: var(--text-muted); font-size: 0.9rem; white-space: pre-wrap; }

/* ---- Admin tables and stats -------------------------------------------- */
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 18px; }
.stat { display: block; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; text-decoration: none; color: var(--text); }
.stat:hover { border-color: var(--accent); color: var(--text); }
.stat__value { display: block; font-size: 1.6rem; font-weight: 750; line-height: 1.1; }
.stat__label { font-size: 0.85rem; color: var(--text-muted); }
.stat--attention .stat__value { color: var(--warn); }

.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 16px; }
.table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.table th, .table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table th { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); background: var(--surface-2); }
.table .flag, .table .badge, .nowrap { white-space: nowrap; }
.table pre { margin: 0; white-space: pre-wrap; max-width: 420px; }
.table tr:last-child td { border-bottom: 0; }
.table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.table .diff { background: var(--warn-soft); }
.table .match { color: var(--ok); }
.table caption { text-align: left; padding: 10px 12px; font-weight: 650; }
.flag { display: inline-block; font-size: 0.75rem; font-weight: 700; padding: 1px 8px; border-radius: 999px; background: var(--warn-soft); color: var(--warn); }
.flag--strong { background: var(--danger-soft); color: #9b1c1c; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.85em; overflow-wrap: anywhere; }

.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---- Duplicate awareness: "Already in catalogue" vs "Related" ---------- */
.match-badge { display: inline-block; font-size: 0.78rem; font-weight: 700; padding: 2px 10px; border-radius: 999px; letter-spacing: 0.01em; white-space: nowrap; }
.match-badge--exact { background: var(--accent); color: #fff; }
.match-badge--retired { background: var(--surface-2); color: var(--text); border: 1px dashed var(--border-strong); }
.match-badge--related { background: var(--warn-soft); color: var(--warn); }
.catalogue-match { border-left-width: 4px; }
.catalogue-match--exact { border-left-color: var(--accent); background: var(--accent-soft); }
.catalogue-match--retired { border-left-color: var(--border-strong); }
.catalogue-match h2, .catalogue-match h3 { margin-bottom: 8px; }
.catalogue-match__list { margin: 0 0 10px; padding-left: 1.2em; }
.catalogue-match__list li { margin-bottom: 6px; overflow-wrap: anywhere; }
.radio--unavailable { background: var(--surface-2); color: var(--text-muted); border-style: dashed; margin: 0 0 8px; }
/* Jump target after "Check the catalogue": focused for screen readers, no error-like ring. */
.catalogue-check:focus { outline: none; }
.match-group + .match-group { margin-top: 14px; }
.match-group h3 { font-size: 1rem; margin: 0 0 6px; }
.match-group ul { margin: 0; padding-left: 1.2em; }
.match-group li { margin-bottom: 6px; overflow-wrap: anywhere; }

/* ---- Approved-MR catalogue search --------------------------------------- */
.catalogue-search { align-items: flex-end; }
.catalogue-search .field { flex: 1 1 260px; }
.catalogue-search__actions { display: flex; gap: 10px; flex-wrap: wrap; }
/* Row headers hold product names: keep them exactly as stored (no uppercase transform). */
.catalogue-table th.catalogue-table__brand { font-weight: 650; color: var(--text); text-transform: none; letter-spacing: 0; font-size: inherit; background: transparent; }
.catalogue-table td, .catalogue-table th[scope="row"] { overflow-wrap: anywhere; }
.catalogue-table tr:last-child th[scope="row"] { border-bottom: 0; }
.catalogue-note { margin-top: 8px; }

/* Narrow screens: each table row becomes a labelled card. */
@media (max-width: 759.98px) {
  .table-wrap--stack { background: transparent; border: 0; border-radius: 0; overflow: visible; }
  .table--stack thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .table--stack, .table--stack tbody, .table--stack tr, .table--stack th[scope="row"], .table--stack td { display: block; width: 100%; }
  .table--stack tr { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 6px 14px; margin-bottom: 12px; }
  .table--stack tr:last-child td { border-bottom: 1px solid var(--border); }
  .table--stack th[scope="row"], .table--stack td { padding: 8px 0; border-bottom: 1px solid var(--border); }
  .table--stack tr > :last-child, .table--stack tr:last-child > :last-child { border-bottom: 0; }
  .table--stack th[scope="row"]::before, .table--stack td::before {
    content: attr(data-label); display: block; font-size: 0.72rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.04em; color: var(--text-muted); margin-bottom: 2px;
  }
  .catalogue-table th.catalogue-table__brand { font-size: 1.05rem; }
}

.grid-2 { display: grid; gap: 16px; }
.pagination { display: flex; gap: 10px; align-items: center; justify-content: space-between; margin: 0 0 16px; }

/* Administrators work with data tables: give them more width. */
.area-admin .container, .area-admin .topbar__inner, .area-admin .footer__inner { max-width: 1240px; }

/* ---- Prose -------------------------------------------------------------- */
.prose { max-width: 760px; margin-left: auto; margin-right: auto; }
.prose h2 { margin-top: 1.4em; }
.prose ul { padding-left: 1.2em; }
.prose li { margin-bottom: 0.4em; }

/* ---- Footer ------------------------------------------------------------- */
.footer { border-top: 1px solid var(--border); background: var(--surface); font-size: 0.875rem; color: var(--text-muted); }
.footer__inner { max-width: 1040px; margin: 0 auto; padding: 14px 16px; display: flex; flex-wrap: wrap; gap: 8px 16px; justify-content: space-between; }
/* Match footer typography instead of the browser's default blue underlined link. */
.footer__legal { display: inline-flex; align-items: center; flex-wrap: wrap; gap: 16px; }
.footer__privacy, .footer__privacy:visited { color: inherit; font: inherit; text-decoration: none; }
.footer__privacy:hover, .footer__privacy:visited:hover { color: var(--accent-strong); text-decoration: underline; }
.footer__privacy:focus-visible { text-decoration: underline; }


/* ---- Wider screens ------------------------------------------------------ */
@media (min-width: 760px) {
  .nav { width: auto; margin: 0; overflow: visible; gap: 4px; }
  .nav a, .nav__button { padding: 0 12px; }
  .nav__form { margin-left: 0 !important; }
  h1 { font-size: 1.75rem; }
  .hero { padding: 36px 32px; }
  .hero h1 { font-size: 2rem; max-width: 22ch; }
  .hero .lead { max-width: 60ch; }
  .card { padding: 24px; }
  .steps__list { grid-template-columns: repeat(3, 1fr); }
  .dl > div { display: grid; grid-template-columns: 220px 1fr; gap: 16px; }
  .dl dd { margin: 0; }
  .stats { grid-template-columns: repeat(4, 1fr); }
  .grid-2 { grid-template-columns: 1fr 1fr; }
}

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

@media print {
  .topbar, .footer, .actions, .nav { display: none; }
  body { background: #fff; }
  .card { box-shadow: none; border-color: #ccc; }
}
