/* ── Reset & tokens ──────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --green:        #1b6b3a;
  --green-dk:     #145229;
  --green-lt:     #f0f9f4;
  --green-border: #7ec89a;
  --gold:         #c9890a;
  --gold-vivid:   #e8a020;
  --gold-lt:      #fef9ec;
  --gold-border:  #f0c843;
  --slate-900:    #0f1a13;
  --slate-800:    #1c2e22;
  --slate-600:    #3d5c47;
  --slate-500:    #5a7a65;
  --slate-400:    #8dab97;
  --slate-200:    #d6e8dc;
  --slate-100:    #eef6f1;
  --bg-input:     #f6fbf8;
  --border-input: #cde4d5;
  --header-h:     68px;
  --radius:       14px;
}

html { font-size: 16px; -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: #edf4ef;
  background-image:
    radial-gradient(circle at 20% 30%, rgba(27,107,58,.06) 0%, transparent 50%),
    radial-gradient(circle at 80% 70%, rgba(232,160,32,.06) 0%, transparent 50%);
  color: var(--slate-800);
  min-height: 100vh;
  display: flex; flex-direction: column;
  padding-bottom: 40px;
}

/* ── Header ──────────────────────────────────────────────────── */
.header {
  position: sticky; top: 0; z-index: 100;
  background: #fff;
  box-shadow: 0 1px 0 rgba(27,107,58,.08), 0 4px 20px rgba(27,107,58,.10);
  overflow: hidden;   /* clips accent decorations */
  isolation: isolate;
}

.header-accent-gold {
  position: absolute; top: -52px; left: -52px;
  width: 130px; height: 130px; border-radius: 50%;
  background: var(--gold-vivid); opacity: .88;
  pointer-events: none; will-change: transform; transform: translateZ(0);
}
.header-accent-green {
  position: absolute; top: -28px; right: -28px;
  width: 200px; height: 130px; border-radius: 50% 0 0 50%;
  background: var(--green);
  pointer-events: none; will-change: transform; transform: translateZ(0);
}

.header-inner {
  position: relative; z-index: 1;
  height: var(--header-h);
  max-width: 1100px; margin: 0 auto;
  padding: 0 24px;
  display: flex; align-items: center; gap: 12px;
}

.logo {
  display: flex; align-items: center; gap: 10px;
  text-decoration: none;
}
.logo-img {
  width: 40px; height: 40px; border-radius: 10px;
  background: #fff; flex-shrink: 0;
  box-shadow: 0 2px 10px rgba(27,107,58,.20);
  overflow: hidden;
  display: flex; align-items: center; justify-content: center;
}
.logo-img img { width: 100%; height: 100%; object-fit: contain; }
.logo-text h1 {
  font-size: 1rem; font-weight: 700;
  color: var(--slate-800); line-height: 1.2; letter-spacing: -.01em;
}
.logo-text span { font-size: .72rem; color: var(--slate-500); font-weight: 500; }

/* ── Macro tabs bar ──────────────────────────────────────────── */
.macro-tabs-bar {
  background: var(--slate-100);
  border-top: 1px solid var(--slate-200);
}
.macro-tabs-inner {
  max-width: 1100px; margin: 0 auto;
  padding: 0 24px; display: flex; gap: 2px;
}
.macro-tab {
  display: flex; align-items: center; gap: 7px;
  padding: 8px 14px;
  font-size: .78rem; font-weight: 600;
  color: var(--slate-500);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  transition: color .18s, border-color .18s;
}
.macro-tab:hover { color: var(--green); }
.macro-tab.active { color: var(--green); border-bottom-color: var(--gold-vivid); }

/* ── Views ───────────────────────────────────────────────────── */
.view { display: none; flex: 1; }
.view.active { display: block; animation: fadeIn .28s ease both; }
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Hero ────────────────────────────────────────────────────── */
.portal-hero {
  background: linear-gradient(140deg, var(--green) 0%, var(--green-dk) 100%);
  color: #fff;
  text-align: center;
  padding: 60px 24px 76px;
  position: relative; overflow: hidden;
}
.portal-hero::after {
  content: '';
  position: absolute; inset: 0;
  background-image:
    radial-gradient(circle at 15% 50%, rgba(232,160,32,.18) 0%, transparent 45%),
    radial-gradient(circle at 85% 20%, rgba(255,255,255,.06) 0%, transparent 40%);
  pointer-events: none;
}

.hero-badge {
  display: inline-flex; align-items: center; gap: 8px;
  background: rgba(232,160,32,.2);
  border: 1px solid rgba(232,160,32,.45);
  border-radius: 20px;
  padding: 5px 16px;
  font-size: .73rem; font-weight: 700;
  letter-spacing: .06em; text-transform: uppercase;
  margin-bottom: 20px;
  position: relative; z-index: 1;
}
.badge-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--gold-vivid);
  box-shadow: 0 0 8px var(--gold-vivid);
  flex-shrink: 0;
}
.portal-hero h1 {
  font-size: clamp(1.9rem, 4vw, 2.75rem);
  font-weight: 800; letter-spacing: -.025em;
  margin-bottom: 14px;
  position: relative; z-index: 1;
}
.portal-hero p {
  font-size: 1rem; color: rgba(255,255,255,.75);
  max-width: 500px; margin: 0 auto; line-height: 1.65;
  position: relative; z-index: 1;
}

/* ── Container ───────────────────────────────────────────────── */
.container {
  max-width: 1100px; margin: 0 auto;
  padding: 0 24px 64px;
}

/* ── Section header ──────────────────────────────────────────── */
.section-header {
  display: flex; align-items: baseline;
  justify-content: space-between; gap: 16px;
  padding: 32px 0 22px;
  border-bottom: 1px solid var(--slate-200);
  margin-bottom: 24px;
}
.section-header h2 {
  font-size: 1rem; font-weight: 700;
  color: var(--slate-800); letter-spacing: -.01em;
  padding-left: 10px;
  border-left: 3px solid var(--gold-vivid);
}
.section-header p { font-size: .82rem; color: var(--slate-500); }

/* ── Categories grid ─────────────────────────────────────────── */
.categories-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

/* ── Category card ───────────────────────────────────────────── */
.category-card {
  background: #fff;
  border: 1.5px solid var(--slate-200);
  border-radius: 18px;
  padding: 22px 18px 18px;
  cursor: pointer;
  transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
  display: flex; flex-direction: column; gap: 12px;
  text-decoration: none; color: inherit;
  box-shadow: 0 1px 2px rgba(27,107,58,.05), 0 3px 10px rgba(27,107,58,.06);
  text-align: left; font-family: inherit; width: 100%;
  animation: cardIn .35s cubic-bezier(.22,.68,0,1.2) both;
  border-top: 3px solid transparent;
  outline: none;
}
@keyframes cardIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.category-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 32px rgba(27,107,58,.16);
  border-color: var(--green-border);
  border-top-color: var(--gold-vivid);
}
.category-card:focus-visible {
  border-color: var(--green);
  box-shadow: 0 0 0 3.5px rgba(27,107,58,.12);
}
.category-card:hover .card-arrow { transform: translateX(3px); color: var(--green); }
.category-card:hover .card-icon-wrap { background: var(--green-lt); }

.card-icon-wrap {
  width: 48px; height: 48px; border-radius: 12px;
  background: var(--slate-100);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem;
  transition: background .2s; flex-shrink: 0;
}
.card-name {
  font-size: .95rem; font-weight: 700;
  color: var(--slate-800); line-height: 1.3; margin-bottom: 3px;
}
.card-desc {
  font-size: .78rem; color: var(--slate-500); line-height: 1.55; flex: 1;
}
.card-footer {
  display: flex; align-items: center; justify-content: space-between; margin-top: 2px;
}
.card-count {
  font-size: .71rem; font-weight: 700;
  color: var(--slate-400); background: var(--slate-100);
  padding: 2px 9px; border-radius: 20px;
  transition: color .3s, background .3s;
}
.card-count-loading {
  color: transparent;
  background: linear-gradient(90deg, var(--slate-200) 25%, var(--slate-100) 50%, var(--slate-200) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: 20px;
  min-width: 70px;
}
@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.card-arrow {
  color: var(--slate-400);
  transition: transform .2s, color .2s;
  display: flex; align-items: center;
}

/* ── Detail view ─────────────────────────────────────────────── */
.btn-back {
  display: inline-flex; align-items: center; gap: 8px;
  margin: 28px 0 24px;
  background: #fff; border: 1.5px solid var(--slate-200);
  border-radius: 10px; padding: 8px 16px;
  font-size: .82rem; font-weight: 600;
  color: var(--slate-600); cursor: pointer; font-family: inherit;
  transition: all .18s;
  box-shadow: 0 1px 3px rgba(27,107,58,.06);
}
.btn-back:hover { border-color: var(--green); color: var(--green); background: var(--green-lt); }

.detail-header {
  display: flex; align-items: flex-start; gap: 18px; margin-bottom: 24px;
}
.detail-icon-wrap {
  width: 60px; height: 60px; flex-shrink: 0;
  border-radius: 14px; background: var(--green-lt);
  display: flex; align-items: center; justify-content: center; font-size: 1.9rem;
  border: 1.5px solid var(--green-border);
}
.detail-header h2 {
  font-size: 1.55rem; font-weight: 800;
  color: var(--slate-800); margin-bottom: 6px;
  letter-spacing: -.025em; line-height: 1.2;
}
.detail-desc { font-size: .88rem; color: var(--slate-500); line-height: 1.6; }

.detail-card {
  background: #fff;
  border: 1.5px solid var(--slate-200);
  border-radius: 18px;
  box-shadow: 0 1px 2px rgba(27,107,58,.05), 0 4px 16px rgba(27,107,58,.08);
  overflow: hidden;
  border-top: 3.5px solid var(--gold-vivid);
}
.detail-table-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 11px 24px;
  background: var(--slate-100);
  border-bottom: 1.5px solid var(--slate-200);
  font-size: .7rem; font-weight: 700;
  color: var(--slate-500); text-transform: uppercase; letter-spacing: .08em;
}

/* ── Document rows ───────────────────────────────────────────── */
.doc-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 24px; border-bottom: 1px solid var(--slate-100);
  gap: 16px; transition: background .14s;
}
.doc-row:last-child { border-bottom: none; }
.doc-row:hover { background: var(--green-lt); }

.doc-info { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; }
.doc-icon {
  width: 34px; height: 34px; flex-shrink: 0;
  border-radius: 8px; background: var(--slate-100);
  display: flex; align-items: center; justify-content: center; font-size: .85rem;
}
.doc-name {
  font-size: .88rem; font-weight: 600;
  color: var(--slate-800); line-height: 1.4;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.doc-link {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: .78rem; font-weight: 700;
  color: var(--green); text-decoration: none; white-space: nowrap;
  padding: 6px 14px; border-radius: 8px;
  border: 1.5px solid var(--green-border);
  background: var(--green-lt);
  transition: all .16s; flex-shrink: 0;
}
.doc-link:hover {
  background: var(--green); color: #fff; border-color: var(--green);
}

/* ── Empty state ─────────────────────────────────────────────── */
.doc-empty {
  padding: 60px 24px; text-align: center; color: var(--slate-400);
}
.empty-icon {
  width: 56px; height: 56px; border-radius: 14px;
  background: var(--slate-100);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.6rem; margin: 0 auto 16px;
  border: 2px dashed var(--green-border);
}
.doc-empty p { font-size: .9rem; font-weight: 700; color: var(--slate-500); margin-bottom: 4px; }
.doc-empty small { font-size: .8rem; color: var(--slate-400); }

/* ── Footer ──────────────────────────────────────────────────── */
.footer {
  background: #fff;
  border-top: 1px solid var(--slate-200);
  padding: 18px 24px;
  text-align: center;
  font-size: .75rem; color: var(--slate-400);
  margin-top: auto;
}

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 920px) {
  .categories-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 560px) {
  .categories-grid { grid-template-columns: 1fr; gap: 10px; }
  .portal-hero { padding: 40px 20px 56px; }
  .container { padding: 0 16px 48px; }
  .header-inner { padding: 0 14px; }
  .macro-tabs-inner { padding: 0 14px; }
  .detail-header { flex-direction: column; gap: 12px; }
  .detail-header h2 { font-size: 1.3rem; }
  .doc-row { padding: 12px 16px; }
  .detail-table-head { padding: 10px 16px; }
  .section-header { flex-direction: column; gap: 4px; }
  :root { --header-h: 62px; }
  .header-accent-gold  { width: 100px; height: 100px; top: -42px; left: -42px; }
  .header-accent-green { width: 150px; height: 100px; top: -22px; right: -22px; }
}
