:root {
  --bg: #f4f6f9;
  --bg-card: #ffffff;
  --ink: #1a2332;
  --muted: #5c6b7f;
  --accent: #1e3a5f;
  --accent-light: #2d5a8a;
  --gold: #c9a227;
  --line: #dde3ea;
  --shadow: 0 8px 24px rgba(30, 58, 95, 0.1);
  --radius: 14px;
  --max: 1080px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, #e8eef5 0, transparent 30rem),
    radial-gradient(circle at top right, #f0ebe0 0, transparent 24rem),
    var(--bg);
  line-height: 1.6;
}

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

.wrap {
  width: min(100% - 1.5rem, var(--max));
  margin: 0 auto;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

/* Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(10px);
  background: rgba(244, 246, 249, 0.92);
  border-bottom: 1px solid var(--line);
}

.site-header .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  color: var(--ink);
  text-decoration: none;
  font-size: 1.05rem;
}

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

.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--accent-light));
  color: var(--gold);
  font-size: 1.4rem;
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 700;
  box-shadow: var(--shadow);
}

.brand-text small {
  color: var(--muted);
  font-weight: 400;
}

.nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.nav a {
  padding: 0.45rem 0.85rem;
  border-radius: 999px;
  background: #fff;
  border: 1px solid var(--line);
  color: var(--ink);
  font-size: 0.92rem;
  text-decoration: none;
}

.nav a:hover,
.nav a[aria-current="page"] {
  border-color: var(--accent);
  background: #eef3f8;
  font-weight: 600;
}

.nav-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 2.75rem;
  height: 2.75rem;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  cursor: pointer;
}

.nav-toggle-bars {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 18px;
}

.nav-toggle-bars span {
  display: block;
  height: 2px;
  background: currentColor;
  border-radius: 2px;
  transition: transform 0.2s, opacity 0.2s;
}

.site-header.is-nav-open .nav-toggle-bars span:nth-child(1) {
  transform: translateY(6px) rotate(45deg);
}
.site-header.is-nav-open .nav-toggle-bars span:nth-child(2) { opacity: 0; }
.site-header.is-nav-open .nav-toggle-bars span:nth-child(3) {
  transform: translateY(-6px) rotate(-45deg);
}

/* Hero */
.hero { padding: 1.5rem 0 0.5rem; }

.hero-card {
  background: linear-gradient(135deg, var(--accent) 0%, #2a4d73 100%);
  color: #fff;
  border-radius: var(--radius);
  padding: 2rem 1.5rem;
  box-shadow: var(--shadow);
}

.hero-card h1 {
  margin: 0.5rem 0 0.75rem;
  font-size: clamp(1.5rem, 4vw, 2rem);
  line-height: 1.25;
}

.hero-card p {
  margin: 0;
  max-width: 42rem;
  opacity: 0.92;
}

.hero-brand .brand-mark { box-shadow: none; }
.hero-brand .brand-text { color: #fff; }
.hero-brand .brand-text small { color: rgba(255,255,255,0.75); }

.hero--compact .hero-card { padding: 1.25rem 1.5rem; }
.hero-card--compact h1 { margin-top: 0; font-size: 1.5rem; }

.hero-search {
  display: flex;
  gap: 0.5rem;
  margin-top: 1.25rem;
  max-width: 36rem;
}

.hero-search input {
  flex: 1;
  min-width: 0;
  padding: 0.75rem 1rem;
  border: none;
  border-radius: 10px;
  font-size: 1rem;
}

.hero-search button,
.search-form button,
.btn {
  padding: 0.75rem 1.25rem;
  border: none;
  border-radius: 10px;
  background: var(--gold);
  color: var(--ink);
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}

.btn-secondary {
  background: #fff;
  border: 1px solid var(--line);
  color: var(--ink);
}

/* Sections */
.section { padding: 1.5rem 0 2rem; }

.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}

.section-head h2 {
  margin: 0;
  font-size: 1.35rem;
}

.section-head p {
  margin: 0.25rem 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}

/* Document cards */
.doc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr));
  gap: 1rem;
}

.doc-card {
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
  transition: box-shadow 0.2s, transform 0.2s;
}

.doc-card:hover {
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}

.doc-thumb {
  height: 72px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #eef3f8, #e4ebf2);
  font-size: 2rem;
  color: var(--accent);
}

.doc-qr-mini {
  float: right;
  width: 88px;
  height: 88px;
  margin: 0.1rem 0 0.55rem 0.75rem;
  padding: 3px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
  object-fit: contain;
  box-shadow: 0 2px 6px rgba(30, 58, 95, 0.08);
}

.doc-card--compact .doc-qr-mini {
  width: 76px;
  height: 76px;
  margin-left: 0.6rem;
}

.doc-excerpt-wrap {
  flex: 1;
  overflow: hidden;
}

.doc-excerpt-wrap::after {
  content: "";
  display: block;
  clear: both;
}

.doc-body {
  padding: 1rem 1.1rem 1.15rem;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.doc-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.5rem;
}

.pill {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  background: #eef3f8;
  color: var(--muted);
  font-size: 0.78rem;
}

.doc-body h3 {
  margin: 0 0 0.5rem;
  font-size: 1.05rem;
  line-height: 1.35;
}

.doc-body h3 a { color: var(--ink); text-decoration: none; }
.doc-body h3 a:hover { color: var(--accent-light); text-decoration: underline; }

.doc-excerpt {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.doc-link {
  font-weight: 600;
  font-size: 0.9rem;
}

.doc-footer {
  margin-top: 0.65rem;
  clear: both;
}

/* Categories */
.category-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.category-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.55rem 0.9rem;
  border-radius: 999px;
  background: #fff;
  border: 1px solid var(--line);
  color: var(--ink);
  font-size: 0.92rem;
  text-decoration: none;
}

.category-chip:hover {
  border-color: var(--accent);
  background: #eef3f8;
  text-decoration: none;
}

.category-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.category-row {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.9rem 1rem;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
}

.category-row:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow);
}

.category-row-main {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  flex: 1;
  min-width: 0;
  color: var(--ink);
  text-decoration: none;
}

.category-row-main:hover {
  text-decoration: none;
}

.category-row-extra {
  flex-shrink: 0;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
  white-space: nowrap;
}

.category-row-extra:hover {
  text-decoration: underline;
}

.law-full-link {
  margin: 0 0 1rem;
}

.category-row-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: #eef3f8;
  font-size: 1.3rem;
  flex-shrink: 0;
}

.category-row-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.category-row-body small {
  color: var(--muted);
  font-size: 0.85rem;
}

.category-row-arrow {
  color: var(--muted);
  flex-shrink: 0;
}

/* Search */
.search-form {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.search-form input {
  flex: 1;
  min-width: min(100%, 16rem);
  padding: 0.8rem 1rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 1rem;
}

.search-summary {
  margin: 1rem 0 0;
  color: var(--muted);
}

.search-hint,
.search-empty {
  margin-top: 1rem;
  padding: 1rem 1.25rem;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--muted);
}

.alert {
  padding: 1rem 1.25rem;
  border-radius: var(--radius);
  border: 1px solid;
}

.alert-error {
  background: #fff5f2;
  border-color: #ffb4a2;
  color: #8a2e1a;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-top: 1.5rem;
  flex-wrap: wrap;
}

.pagination-info {
  color: var(--muted);
  font-size: 0.92rem;
}

/* Article page */
.doc-page { padding: 1rem 0 2.5rem; }

.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
  font-size: 0.88rem;
  color: var(--muted);
  margin-bottom: 1rem;
}

.breadcrumb a { color: var(--accent-light); }

.doc-article {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem 1.5rem;
  box-shadow: var(--shadow);
}

.doc-article h1 {
  margin: 0.75rem 0 1rem;
  font-size: clamp(1.35rem, 4vw, 1.85rem);
  line-height: 1.3;
}

.doc-content {
  line-height: 1.75;
  font-size: 1rem;
  overflow-wrap: anywhere;
}

.doc-content p { margin: 0.75rem 0; }
.doc-content table { width: 100%; overflow-x: auto; display: block; }

.doc-lead {
  margin: 0 0 1rem;
  color: var(--muted);
  font-size: 1.02rem;
  line-height: 1.55;
}

.nace-search {
  margin: 0 0 1.25rem;
}

.nace-subhead {
  margin: 1.75rem 0 0.75rem;
  font-size: 1.15rem;
}

.nace-table-wrap {
  overflow-x: auto;
  margin: 0 0 1rem;
}

.nace-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

.nace-table th,
.nace-table td {
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.nace-table th {
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
  background: #faf8f5;
}

.nace-table code {
  font-size: 0.9em;
  white-space: nowrap;
}

.nace-link {
  font-weight: 600;
  color: var(--ink);
}

.nace-link:hover {
  color: var(--accent);
}

.nace-path {
  display: block;
  margin-top: 0.2rem;
  font-size: 0.82rem;
  color: var(--muted);
}

.nace-path--detail {
  margin: 0 0 1rem;
}

.nace-actions {
  white-space: nowrap;
}

.nace-actions .doc-link {
  display: inline-block;
  margin-left: 0.65rem;
}

.nace-actions .doc-link:first-child {
  margin-left: 0;
}

@media (max-width: 720px) {
  .nace-table thead { display: none; }
  .nace-table tr {
    display: block;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--line);
  }
  .nace-table td {
    display: block;
    border: 0;
    padding: 0.2rem 0;
  }
  .nace-table td[data-label]::before {
    content: attr(data-label) ": ";
    font-weight: 600;
    color: var(--muted);
    font-size: 0.8rem;
  }
  .nace-actions .doc-link {
    display: inline-block;
    margin: 0.35rem 0.75rem 0 0;
  }
}

.doc-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}

.doc-pager {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}

.doc-pager-link {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fafbfc;
  color: inherit;
  text-decoration: none;
  transition: border-color 0.15s, background 0.15s;
}

.doc-pager-link:hover {
  border-color: var(--accent, #1e3a5f);
  background: #fff;
}

.doc-pager-link--next {
  text-align: right;
  grid-column: 2;
}

.doc-pager-link--prev {
  grid-column: 1;
}

.doc-pager-link--empty {
  visibility: hidden;
}

.doc-pager-dir {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.doc-pager-title {
  font-size: 0.92rem;
  line-height: 1.35;
  color: var(--accent, #1e3a5f);
}

/* Footer */
.site-footer {
  border-top: 1px solid var(--line);
  padding: 1.25rem 0 1.5rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.site-footer .wrap {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.75rem;
}

.site-footer .links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

/* Mobile */
@media (max-width: 720px) {
  .nav-toggle { display: flex; }

  .nav {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    padding: 0.75rem 0.75rem 1rem;
    background: rgba(244, 246, 249, 0.98);
    border-bottom: 1px solid var(--line);
    box-shadow: 0 8px 20px rgba(0,0,0,0.08);
  }

  .site-header { position: sticky; }
  .site-header .wrap { position: relative; }
  .site-header.is-nav-open .nav { display: flex; }

  .hero-search { flex-direction: column; }
  .hero-search button { width: 100%; }

  .search-form { flex-direction: column; }
  .search-form button { width: 100%; }

  .doc-article { padding: 1rem; }
  .section-head { flex-direction: column; align-items: flex-start; }
  .doc-pager { grid-template-columns: 1fr; }
  .doc-pager-link--next { grid-column: 1; text-align: left; }
}

@media print {
  .site-header,
  .site-footer,
  .doc-actions,
  .doc-pager,
  .breadcrumb { display: none !important; }
  .doc-article { box-shadow: none; border: none; }
}
