/* Anna Copilot design system. The rules behind it: docs/design-guide.md.
 *
 * Taken from the FDA Browser (fda.innolitics.com) so Innolitics apps look like one product. Token
 * names match its stylesheet on purpose. Every screen loads this file before its own <style>, and
 * a page's own CSS only lays things out: colors, fonts and shared components come from here.
 *
 * The one screen that does not load it is the call-facing page, realtime-slim.html (see the guide).
 */

@font-face {
  font-family: "Poppins";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/fonts/poppins_normal.woff2") format("woff2");
}
@font-face {
  font-family: "Poppins";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("/fonts/poppins_bold.woff2") format("woff2");
}
@font-face {
  font-family: "Poppins";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("/fonts/poppins_700.woff2") format("woff2");
}

:root {
  color-scheme: light;

  /* Surfaces */
  --bg: #f7f8fa;
  --bg-raised: #ffffff;
  --bg-card: #ffffff;
  --bg-card-hover: #f9fafb;
  --bg-input: #ffffff;
  --bg-head: #f3f5fa;

  /* Lines */
  --border: #d8dde5;
  --border-soft: #e3e7ef;
  --border-focus: #2d3f86;

  /* Text. Blue is for headings with content under them; content is near-black. */
  --text: #1c1e24;
  --text-dim: #6b7280;
  --text-bright: #2d3f86;
  --slate: #9ca3af;

  /* Brand */
  --accent: #2d3f86;
  --accent-dim: rgba(45, 63, 134, 0.1);
  --accent-glow: rgba(45, 63, 134, 0.05);

  /* Signals. The -text shades pass 4.5:1 on white, so small text uses them. */
  --green: #16a34a;
  --green-text: #15803d;
  --green-bg: rgba(22, 163, 74, 0.08);
  --green-border: rgba(22, 163, 74, 0.2);
  --amber: #f97316;
  --amber-text: #b45309;
  --amber-bg: rgba(249, 115, 22, 0.1);
  --amber-border: rgba(249, 115, 22, 0.3);
  --red: #e85036;
  --red-text: #c93b22;
  --red-bg: rgba(232, 80, 54, 0.08);
  --red-border: rgba(232, 80, 54, 0.28);

  /* Type */
  --font-display: "Poppins", system-ui, sans-serif;
  --font-body: "Poppins", system-ui, sans-serif;
  --font-mono: "Menlo", "Consolas", monospace;

  /* Shape */
  --radius-sm: 4px;
  --radius: 6px;
  --radius-lg: 8px;
  --radius-pill: 999px;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-menu: 0 8px 24px rgba(0, 0, 0, 0.12);

  /* Layout */
  --app-header-h: 52px;
  --gutter: 28px;
}

/* ── Base ── */
*,
*::before,
*::after {
  box-sizing: border-box;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
::selection {
  background: var(--accent);
  color: #fff;
}
.hidden {
  display: none !important;
}
a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.15s;
}
a:hover {
  color: var(--red);
}
h1,
h2,
h3,
h4,
p {
  margin: 0;
  letter-spacing: 0;
}
h1 {
  color: var(--text-bright);
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 600;
  line-height: 1.3;
}
h2 {
  color: var(--text-bright);
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 600;
  line-height: 1.35;
}
h3 {
  color: var(--text-bright);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.35;
}
h4 {
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.35;
}
code,
pre,
kbd {
  font-family: var(--font-mono);
}
pre {
  margin: 0;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  background: var(--bg);
  color: var(--text);
  font-size: 12px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}
.label,
.section-label {
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.dim {
  color: var(--text-dim);
}

/* ── Forms ── */
:where(label) {
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 500;
}
:where(
  input:not([type="checkbox"], [type="radio"], [type="range"], [type="file"], [type="color"]),
  select,
  textarea
) {
  min-height: 37px;
  max-width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 7px 12px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  transition:
    border-color 0.15s,
    box-shadow 0.15s,
    background-color 0.15s;
}
:where(
  input:not([type="checkbox"], [type="radio"], [type="range"], [type="file"], [type="color"]),
  select,
  textarea
):hover {
  background-color: var(--bg-input);
}
:where(input, select, textarea):focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
  outline: none;
}
:where(input, textarea)::placeholder {
  color: var(--slate);
  font-style: italic;
}
:where(textarea) {
  resize: vertical;
}
:where(select) {
  appearance: none;
  padding-right: 30px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236B7280' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
  background-position: right 10px center;
  background-repeat: no-repeat;
  cursor: pointer;
}
:where(input[type="checkbox"], input[type="radio"]) {
  accent-color: var(--accent);
}

/* ── Buttons ──
 * A plain <button> is the default white button; .primary is the one main action of a section.
 * Page-specific buttons (tabs, chips, icons) set their own class and override what they need. */
:where(button),
.btn,
.button {
  display: inline-flex;
  min-height: 37px;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 7px 18px;
  background: var(--bg-raised);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 1.3;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition:
    color 0.15s,
    background-color 0.15s,
    border-color 0.15s;
}
:where(button):hover:not(:disabled),
.btn:hover:not(:disabled),
.button:hover {
  border-color: var(--text-dim);
  color: var(--text-bright);
}
:where(button):focus-visible,
.btn:focus-visible,
.button:focus-visible,
a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
button.primary,
.btn.primary,
.btn-primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}
button.primary:hover:not(:disabled),
.btn.primary:hover:not(:disabled),
.btn-primary:hover:not(:disabled) {
  border-color: var(--red);
  background: var(--red);
  color: #fff;
}
button.danger,
.btn.danger,
.btn-danger {
  border-color: var(--red-border);
  background: var(--bg-raised);
  color: var(--red-text);
}
button.danger:hover:not(:disabled),
.btn.danger:hover:not(:disabled),
.btn-danger:hover:not(:disabled) {
  border-color: var(--red);
  background: var(--red-bg);
  color: var(--red-text);
}
button.ghost,
.btn.ghost,
.btn-ghost {
  border-color: transparent;
  background: transparent;
  color: var(--text-dim);
}
button.ghost:hover:not(:disabled),
.btn.ghost:hover:not(:disabled),
.btn-ghost:hover:not(:disabled) {
  border-color: transparent;
  background: rgba(0, 0, 0, 0.04);
  color: var(--accent);
}
button.small,
.btn.small,
.btn-sm {
  min-height: 30px;
  padding: 4px 10px;
  font-size: 13px;
}
:where(button):disabled,
.btn:disabled {
  cursor: not-allowed;
  opacity: 0.4;
}

/* ── Panels ── */
.panel {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-raised);
  box-shadow: var(--shadow);
}
.panel-head {
  display: flex;
  min-height: 44px;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 1px solid var(--border-soft);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: 10px 16px;
  background: var(--bg-head);
}

/* ── Pills ── */
.pill {
  display: inline-flex;
  min-height: 22px;
  align-items: center;
  gap: 5px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 2px 9px;
  background: var(--bg-raised);
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.3;
  white-space: nowrap;
}
.pill.blue {
  border-color: var(--accent-dim);
  background: var(--accent-dim);
  color: var(--accent);
}
.pill.green {
  border-color: var(--green-border);
  background: var(--green-bg);
  color: var(--green-text);
}
.pill.amber {
  border-color: var(--amber-border);
  background: var(--amber-bg);
  color: var(--amber-text);
}
.pill.red {
  border-color: var(--red-border);
  background: var(--red-bg);
  color: var(--red-text);
}
.pill.live {
  border-color: var(--red);
  background: var(--red);
  color: #fff;
}
.pill.live::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  animation: design-pulse 1.6s infinite;
}
@keyframes design-pulse {
  50% {
    opacity: 0.35;
  }
}
@media (prefers-reduced-motion: reduce) {
  .pill.live::before {
    animation: none;
  }
}

/* ── Tabs: same shape as the header's links ── */
.tabs {
  display: flex;
  gap: 2px;
  overflow-x: auto;
  border-bottom: 1px solid var(--border);
  scrollbar-width: none;
}
.tabs > button,
.tab {
  flex: 0 0 auto;
  min-height: 0;
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  padding: 6px 14px;
  background: none;
  color: var(--text-dim);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0;
  white-space: nowrap;
  cursor: pointer;
}
.tabs > button:hover:not(:disabled),
.tab:hover {
  border-color: transparent;
  color: var(--accent);
}
.tabs > button[aria-selected="true"],
.tab[aria-selected="true"] {
  border-bottom-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}

/* ── Segmented choice ── */
.seg-group {
  display: inline-flex;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}
.seg-group > button {
  min-height: 34px;
  border: 0;
  border-right: 1px solid var(--border);
  border-radius: 0;
  padding: 6px 14px;
  background: var(--bg-input);
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0;
}
.seg-group > button:last-child {
  border-right: 0;
}
.seg-group > button:hover:not(:disabled) {
  background: var(--accent-dim);
  color: var(--text-bright);
}
.seg-group > button[aria-pressed="true"],
.seg-group > button.active {
  background: var(--accent);
  color: #fff;
}

/* ── Tables ── */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
th,
td {
  border-bottom: 1px solid var(--border-soft);
  padding: 8px 10px;
  text-align: left;
  vertical-align: middle;
}
th {
  color: var(--text-bright);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
}

/* ── Stat tiles ── */
.stat {
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 10px 14px;
  background: var(--bg-raised);
  box-shadow: var(--shadow);
}
.stat .label {
  display: block;
}
.stat .value,
.stat strong {
  display: block;
  color: var(--text);
  font-size: 22px;
  font-weight: 700;
  line-height: 1.25;
  font-variant-numeric: tabular-nums;
}
.stat .sub {
  color: var(--text-dim);
  font-size: 12px;
}

/* ── Page frame: a title row, then the content, on the header's left edge ── */
.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 20px;
  padding: 16px var(--gutter) 0;
}
.page-head > div:first-child {
  min-width: 0;
}
.page-sub {
  margin-top: 2px;
  color: var(--text-dim);
  font-size: 13px;
}
.page-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
/* A second navbar: controls for one busy screen, directly under the site header, in its color. */
.sub-navbar {
  display: flex;
  flex: none;
  flex-wrap: wrap;
  min-height: 48px;
  align-items: center;
  gap: 6px 20px;
  border-bottom: 1px solid var(--border);
  padding: 6px var(--gutter);
  background: var(--bg-raised);
}
.page-body {
  max-width: 1800px;
  margin: 0 auto;
  padding: 16px var(--gutter) 60px;
}
.empty-state {
  padding: 48px 20px;
  color: var(--text-dim);
  text-align: center;
}

/* ── Site header: drawn by /shared/site-header.js, the same on every screen ── */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  flex: none;
  height: var(--app-header-h);
  min-height: var(--app-header-h);
  align-items: center;
  gap: 24px;
  border-bottom: 1px solid var(--border);
  padding: 0 var(--gutter);
  background: rgba(255, 255, 255, 0.95);
  font-family: var(--font-body);
  backdrop-filter: blur(12px);
}
.site-header .site-brand {
  display: flex;
  flex: none;
  align-items: center;
  gap: 10px;
  color: var(--accent);
}
.site-header .site-brand img {
  display: block;
  width: 130px;
  height: 32px;
}
.site-header .site-product {
  border-left: 1px solid var(--border);
  padding-left: 10px;
  font-size: 15px;
  font-weight: 600;
  line-height: 20px;
}
.site-header .site-links {
  display: flex;
  min-width: 0;
  flex: 1 1 auto;
  align-items: center;
}
.site-header .site-link {
  border-bottom: 2px solid transparent;
  padding: 4px 14px;
  color: var(--text-dim);
  font-size: 15px;
  font-weight: 500;
  white-space: nowrap;
}
.site-header .site-link:hover {
  color: var(--accent);
}
.site-header .site-link[aria-current="page"] {
  border-bottom-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}
.site-header .site-account {
  display: flex;
  flex: none;
  align-items: center;
  gap: 14px;
  margin-left: auto;
  color: var(--text-dim);
  font-size: 13px;
}
.site-header .site-signout {
  min-height: 0;
  border: 0;
  padding: 4px 0;
  background: none;
  color: var(--accent);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0;
}
.site-header .site-signout:hover:not(:disabled) {
  color: var(--red);
  text-decoration: underline;
}
.site-header .site-menu-btn {
  display: none;
  min-height: 0;
  margin-left: auto;
  border: 0;
  border-radius: var(--radius);
  padding: 6px;
  background: none;
  color: var(--text);
}
.site-header .site-menu-btn:hover:not(:disabled) {
  background: rgba(0, 0, 0, 0.05);
  color: var(--text);
}
@media (max-width: 1180px) {
  .site-header .site-email {
    display: none;
  }
}
@media (max-width: 960px) {
  .site-header .site-menu-btn {
    display: inline-flex;
  }
  .site-header .site-account {
    margin-left: 0;
  }
  .site-header .site-links {
    position: absolute;
    top: var(--app-header-h);
    right: 8px;
    display: none;
    min-width: 200px;
    flex-direction: column;
    align-items: stretch;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 6px;
    background: var(--bg-raised);
    box-shadow: var(--shadow-menu);
  }
  .site-header .site-links.open {
    display: flex;
  }
  .site-header .site-link {
    border-bottom: 0;
    border-left: 2px solid transparent;
    border-radius: var(--radius-sm);
    padding: 10px 14px;
  }
  .site-header .site-link:hover {
    background: rgba(0, 0, 0, 0.04);
  }
  .site-header .site-link[aria-current="page"] {
    border-left-color: var(--accent);
    background: var(--accent-glow);
  }
}
@media (max-width: 520px) {
  :root {
    --gutter: 16px;
  }
  .site-header {
    gap: 12px;
  }
  .site-header .site-brand img {
    width: 106px;
    height: 26px;
  }
}
