:root {
  --bg: #F5F6F8;
  --surface: #FFFFFF;
  --surface-2: #F9FAFB;
  --line: #E4E7EC;
  --line-2: #EAECF0;
  --line-strong: #D0D5DD;
  --ink: #101828;
  --ink-2: #344054;
  --muted: #475467;
  --faint: #98A2B3;
  --red: #D7101C;
  --red-dark: #B80D18;
  --radius: 14px;
  --font: 'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Consolas, monospace;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font); line-height: 1.5; }
img { max-width: 100%; }
a { color: var(--red-dark); }
a:hover { color: #8F0A12; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

.container { max-width: 1200px; margin: 0 auto; padding: 0 24px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Header */
.header { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.header .container { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 24px; padding-top: 14px; padding-bottom: 14px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); }
.brand img { width: 32px; height: 32px; }
.brand span { font-size: 18px; font-weight: 700; letter-spacing: -0.01em; }
.nav { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 24px; font-size: 14px; font-weight: 500; }
.nav a { color: var(--ink-2); text-decoration: none; padding: 10px 0; }
.nav a:hover { color: var(--ink); }
.pill { font-size: 12px; color: var(--muted); padding: 4px 10px; border: 1px solid var(--line); border-radius: 999px; }

/* Hero */
.hero { background: var(--surface); border-bottom: 1px solid var(--line); }
.hero .container { display: flex; flex-wrap: wrap; gap: 40px; align-items: flex-end; justify-content: space-between; padding-top: 64px; padding-bottom: 56px; }
.hero-text { flex: 1 1 520px; min-width: 0; max-width: 680px; }
.eyebrow { margin: 0 0 16px; font-size: 13px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--red-dark); }
.hero h1 { margin: 0; font-size: clamp(30px, 4.4vw, 44px); line-height: 1.1; font-weight: 700; letter-spacing: -0.025em; }
.lead { margin: 20px 0 0; font-size: 17px; line-height: 1.6; color: var(--muted); }
.search-label { display: block; margin: 32px 0 8px; font-size: 13px; font-weight: 600; color: var(--ink-2); }
.search { display: flex; align-items: center; gap: 10px; max-width: 520px; height: 48px; padding: 0 14px; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 10px; }
.search:focus-within { border-color: var(--ink); box-shadow: 0 0 0 3px rgba(16,24,40,.08); }
.search input { flex: 1; min-width: 0; border: 0; background: transparent; font: inherit; font-size: 15px; color: var(--ink); }
.search input:focus { outline: none; }

.stats { flex: 0 1 340px; margin: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.stats > div { background: var(--surface); padding: 18px 20px; }
.stats .wide { grid-column: span 2; }
.stats dt { font-size: 12px; color: var(--muted); }
.stats dd { margin: 4px 0 0; font-size: 28px; font-weight: 700; letter-spacing: -0.02em; }
.stats .wide dd { font-size: 15px; font-weight: 600; letter-spacing: 0; }

/* Toolbar */
.catalogue { padding-top: 40px; padding-bottom: 24px; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
.tabs { display: flex; flex-wrap: wrap; gap: 4px; padding: 4px; background: var(--line-2); border-radius: 10px; }
.tab { height: 36px; padding: 0 14px; font: inherit; font-size: 14px; font-weight: 600; color: var(--ink-2); background: transparent; border: 0; border-radius: 7px; cursor: pointer; }
.tab[aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(16,24,40,.08); }
.tab .count { font-family: var(--mono); font-size: 12px; color: var(--muted); margin-left: 4px; }
.result { margin: 0; font-size: 14px; color: var(--muted); }

/* App cards */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.card { display: flex; flex-direction: column; gap: 16px; padding: 22px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); transition: border-color .15s ease, box-shadow .15s ease; }
.card:hover { border-color: #C9CED6; box-shadow: 0 6px 24px -12px rgba(16,24,40,.18); }
.card-head { display: flex; align-items: flex-start; gap: 14px; }
.card-head img { width: 44px; height: 44px; flex-shrink: 0; object-fit: contain; }
.card-title { flex: 1; min-width: 0; }
.card-title h2 { margin: 0; font-size: 17px; font-weight: 600; line-height: 1.3; }
.card-title p { margin: 2px 0 0; font-size: 13px; color: var(--muted); line-height: 1.4; }
.version { flex-shrink: 0; font-family: var(--mono); font-size: 12px; color: var(--ink-2); padding: 3px 8px; background: #F2F4F7; border-radius: 6px; }
.desc { margin: 0; min-height: 67px; font-size: 14px; line-height: 1.6; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.desc.empty { color: var(--faint); font-style: italic; }

.actions { margin-top: auto; display: flex; flex-direction: column; gap: 12px; }
.actions-main, .actions-docs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.actions-docs { gap: 6px; padding-top: 12px; border-top: 1px solid #F2F4F7; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 44px; padding: 0 12px; font-size: 14px; font-weight: 600; text-decoration: none; border-radius: 10px; border: 1px solid transparent; white-space: nowrap; }
.btn svg { flex-shrink: 0; }
.btn-primary { background: var(--red); color: #fff; }
.btn-primary:hover { background: var(--red-dark); color: #fff; }
.btn-secondary { background: var(--surface); color: var(--ink); border-color: var(--line-strong); }
.btn-secondary:hover { background: #F2F4F7; color: var(--ink); }
.btn-doc { justify-content: flex-start; height: 36px; padding: 0 10px; font-size: 13px; font-weight: 500; color: var(--ink-2); background: var(--surface-2); border-color: var(--line-2); border-radius: 8px; }
.btn-doc:hover { color: var(--ink); background: #F2F4F7; }
.btn-doc span { overflow: hidden; text-overflow: ellipsis; }
.btn.is-disabled { color: var(--faint); background: var(--surface); border: 1px dashed var(--line-strong); cursor: not-allowed; }
.btn-primary.is-disabled { background: #F2F4F7; border-color: transparent; }
.btn-doc.is-disabled { border-color: var(--line-2); }

/* Link cards */
.grid-links { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.link-card { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 18px 20px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; text-decoration: none; color: var(--ink); transition: border-color .15s ease; }
.link-card:hover { border-color: #C9CED6; color: var(--ink); }
.link-card strong { display: block; font-size: 15px; font-weight: 600; }
.link-card small { display: block; margin-top: 2px; font-size: 13px; color: var(--muted); }

.empty-state { padding: 56px 24px; text-align: center; background: var(--surface); border: 1px dashed var(--line-strong); border-radius: var(--radius); }
.empty-state p { margin: 0; }
.empty-state .t { font-size: 16px; font-weight: 600; }
.empty-state .s { margin: 6px 0 16px; font-size: 14px; color: var(--muted); }
.empty-state button { height: 40px; padding: 0 16px; font: inherit; font-size: 14px; font-weight: 600; color: var(--ink); background: var(--surface); border: 1px solid var(--line-strong); border-radius: 10px; cursor: pointer; }

/* Contact */
.contact { padding-top: 56px; padding-bottom: 64px; }
.contact-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 24px; }
.contact-head h2 { margin: 0; font-size: 26px; font-weight: 700; letter-spacing: -0.02em; }
.contact-head p { margin: 6px 0 0; font-size: 15px; color: var(--muted); }
.mail { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; text-decoration: none; padding: 10px 0; }
.offices { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }
.office { padding: 22px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.office h3 { margin: 0; font-size: 16px; font-weight: 600; }
.office p { margin: 8px 0 0; font-size: 14px; line-height: 1.55; color: var(--muted); }
.office dl { margin: 16px 0 0; padding-top: 14px; border-top: 1px solid #F2F4F7; display: flex; flex-direction: column; gap: 6px; }
.office dl div { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; }
.office dt { color: var(--muted); }
.office dd { margin: 0; font-family: var(--mono); color: var(--ink); }

/* Footer */
.footer { background: var(--surface); border-top: 1px solid var(--line); }
.footer .container { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px; padding-top: 24px; padding-bottom: 24px; }
.footer img { height: 40px; width: auto; }
.footer p { margin: 0; font-size: 13px; color: var(--muted); }

/* Single app page (ems.html) */
.single { min-height: calc(100vh - 61px - 89px); display: flex; align-items: center; padding: 48px 0; }
.single .card { max-width: 440px; margin: 0 auto; width: 100%; text-align: center; align-items: center; }
.single .card-head { flex-direction: column; align-items: center; }
.single .card-head img { width: 64px; height: 64px; }
.single .btn { width: 100%; }

@media (max-width: 480px) {
  .container { padding: 0 16px; }
  .hero .container { padding-top: 40px; padding-bottom: 40px; }
  .hero .container { gap: 28px; }
  .stats { flex: 1 1 100%; margin-top: 8px; }
  .toolbar { margin-top: 8px; }
  .tabs { flex-wrap: nowrap; width: 100%; overflow-x: auto; }
  .tab { flex: 1 0 auto; padding: 0 10px; white-space: nowrap; }
  .grid { grid-template-columns: 1fr; }
  .card { padding: 18px; }
}
