/* ═══════════════════════════════════════════════════════════════════════════
   НЮУ ім. Ярослава Мудрого — дизайн-система
   Палітра: deep navy + teal + gold accents
   ═══════════════════════════════════════════════════════════════════════════ */

:root {
  /* Primary */
  --navy-900: #001f31;
  --navy-800: #003B5C;
  --navy-700: #0B4F6C;
  --teal-700: #005A66;
  --teal-600: #006B73;
  --teal-500: #008a94;

  /* Accents */
  --gold-500: #C9A227;
  --gold-300: #E5C76B;
  --burgundy: #920B0B;
  --emerald:  #059669;

  /* Surfaces */
  --bg:        #F7F8FA;
  --surface:   #FFFFFF;
  --surface-2: #F1F3F7;
  --border:    #E2E8F0;

  /* Text */
  --text:  #1E293B;
  --muted: #64748B;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0,31,49,.06), 0 1px 3px rgba(0,31,49,.04);
  --shadow-md: 0 4px 12px rgba(0,31,49,.06), 0 2px 4px rgba(0,31,49,.04);
  --shadow-lg: 0 12px 28px rgba(0,31,49,.08), 0 4px 8px rgba(0,31,49,.05);

  --radius: 14px;
  --radius-sm: 8px;
  --radius-lg: 20px;

  --transition: 160ms cubic-bezier(.4,0,.2,1);

  --sidebar-w: 240px;
  --sidebar-w-collapsed: 72px;
  --header-h: 60px;
}

[data-theme="dark"] {
  --navy-800: #002b44;
  --navy-700: #00334e;
  --bg:        #071923;
  --surface:   #0D2630;
  --surface-2: #123640;
  --border:    #1c3a47;
  --text:      #F8FAFC;
  --muted:     #94A3B8;

  --shadow-sm: 0 1px 2px rgba(0,0,0,.4);
  --shadow-md: 0 4px 12px rgba(0,0,0,.35);
  --shadow-lg: 0 12px 28px rgba(0,0,0,.45);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  transition: background var(--transition), color var(--transition);
}

.text-muted { color: var(--muted); }
.link, .link-subtle { text-decoration: none; }
.link { color: var(--teal-600); font-weight: 500; }
.link:hover { color: var(--teal-500); text-decoration: underline; }
.link-subtle { color: var(--text); }
.link-subtle:hover { color: var(--teal-600); text-decoration: underline; }

/* ═══ Layout shell ═══════════════════════════════════════════════════════ */
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr;
       grid-template-rows: var(--header-h) 1fr; min-height: 100vh;
       transition: grid-template-columns var(--transition); }
.app.collapsed { grid-template-columns: var(--sidebar-w-collapsed) 1fr; }

/* ═══ Header ════════════════════════════════════════════════════════════ */
.header {
  grid-column: 1 / -1;
  display: flex; align-items: center; gap: 16px;
  padding: 0 20px;
  background: linear-gradient(90deg, var(--navy-800) 0%, var(--navy-700) 60%, var(--teal-700) 100%);
  color: #fff;
  box-shadow: var(--shadow-md);
  position: sticky; top: 0; z-index: 40;
  height: var(--header-h);
}
.header-brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.header-logo {
  width: 34px; height: 34px; border-radius: 8px; flex-shrink: 0;
  background: linear-gradient(135deg, var(--gold-500) 0%, var(--gold-300) 100%);
  display: grid; place-items: center; font-weight: 800; color: var(--navy-900);
  font-size: 14px; letter-spacing: -0.5px;
}
.header-title { font-weight: 600; font-size: 14px; line-height: 1.2; white-space: nowrap; }
.header-sub { font-size: 11px; opacity: .7; }
.header-spacer { flex: 1; }
.header-actions { display: flex; align-items: center; gap: 8px; }
.icon-btn {
  background: rgba(255,255,255,.08); color: #fff; border: 1px solid rgba(255,255,255,.12);
  width: 36px; height: 36px; border-radius: 10px;
  display: grid; place-items: center; cursor: pointer; font-size: 15px;
  transition: var(--transition);
}
.icon-btn:hover { background: rgba(255,255,255,.16); }
.api-status { display: inline-flex; align-items: center; gap: 6px;
  font-size: 11px; padding: 5px 10px; border-radius: 999px;
  background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.12); }
.api-status .dot { width: 7px; height: 7px; border-radius: 50%; background: #94a3b8; }
.api-status.ok .dot { background: #34d399; box-shadow: 0 0 0 3px rgba(52,211,153,.25); }
.api-status.err .dot { background: #f87171; box-shadow: 0 0 0 3px rgba(248,113,113,.25); }

/* ═══ Sidebar ═══════════════════════════════════════════════════════════ */
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 16px 10px;
  position: sticky; top: var(--header-h);
  height: calc(100vh - var(--header-h));
  overflow-y: auto;
  transition: width var(--transition);
  z-index: 30;
}
.sidebar-toggle {
  width: 100%; display: flex; align-items: center; justify-content: center;
  background: transparent; border: 1px dashed var(--border);
  color: var(--muted); font-size: 11px; padding: 6px; border-radius: 8px;
  cursor: pointer; margin-bottom: 12px; transition: var(--transition);
}
.sidebar-toggle:hover { color: var(--teal-600); border-color: var(--teal-600); }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: 10px;
  color: var(--text); text-decoration: none;
  font-size: 13.5px; font-weight: 500;
  transition: var(--transition); position: relative;
  white-space: nowrap; overflow: hidden;
}
.nav-item .nav-icon { font-size: 17px; flex-shrink: 0; width: 20px; text-align: center; }
.nav-item:hover { background: var(--surface-2); }
.nav-item.active {
  background: linear-gradient(90deg, rgba(0,90,102,.12), rgba(0,90,102,.02));
  color: var(--teal-700); font-weight: 600;
}
.nav-item.active::before {
  content: ''; position: absolute; left: 0; top: 8px; bottom: 8px; width: 3px;
  border-radius: 0 3px 3px 0;
  background: linear-gradient(180deg, var(--gold-500), var(--teal-600));
}
.app.collapsed .sidebar { padding: 16px 8px; }
.app.collapsed .nav-item { justify-content: center; padding: 10px 0; }
.app.collapsed .nav-item span:not(.nav-icon) { display: none; }
.app.collapsed .sidebar-toggle span { display: none; }

/* ═══ Main ══════════════════════════════════════════════════════════════ */
.main { padding: 24px 28px 40px; min-width: 0; }
@media (max-width: 900px) { .main { padding: 18px 16px 32px; } }

.page-head { display: flex; flex-wrap: wrap; align-items: flex-end;
             justify-content: space-between; gap: 12px; margin-bottom: 22px; }
.page-title { font-size: 24px; font-weight: 700; letter-spacing: -0.4px;
              color: var(--text); margin: 0; }
.page-sub { font-size: 13px; color: var(--muted); margin-top: 4px; }
.page-actions { display: flex; gap: 8px; align-items: center; }

/* ═══ Cards ═════════════════════════════════════════════════════════════ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}
.card-hover:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.card-pad { padding: 18px 20px; }
.card-title { font-size: 13px; font-weight: 600; color: var(--muted);
              text-transform: uppercase; letter-spacing: 0.6px; margin: 0 0 12px; }

/* ═══ KPI grid ══════════════════════════════════════════════════════════ */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 24px; }
@media (max-width: 1100px) { .kpi-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 520px)  { .kpi-grid { grid-template-columns: 1fr; } }

.kpi { position: relative; overflow: hidden; padding: 18px 18px 16px; }
.kpi::after {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(120px 80px at 100% 0%, rgba(0,90,102,.06), transparent 70%);
}
.kpi-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.kpi-label { font-size: 11.5px; font-weight: 600; color: var(--muted);
             text-transform: uppercase; letter-spacing: 0.5px; }
.kpi-icon {
  width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center;
  background: linear-gradient(135deg, rgba(0,90,102,.14), rgba(11,79,108,.08));
  color: var(--teal-700); font-size: 15px;
}
.kpi-value { font-size: 30px; font-weight: 700; letter-spacing: -0.8px; line-height: 1.1;
             color: var(--text); font-variant-numeric: tabular-nums; }
.kpi-delta { font-size: 12px; font-weight: 600; margin-top: 6px; color: var(--muted); }
.kpi-delta.up { color: var(--emerald); }
.kpi-delta.down { color: var(--burgundy); }
.kpi-gold .kpi-value { color: var(--gold-500); }

/* ═══ Charts ════════════════════════════════════════════════════════════ */
.charts-row { display: grid; grid-template-columns: 2fr 1fr; gap: 14px; margin-bottom: 24px; }
@media (max-width: 1000px) { .charts-row { grid-template-columns: 1fr; } }
.chart-card { padding: 18px 20px; }
.chart-card h3 { font-size: 14px; font-weight: 600; margin: 0 0 12px;
                 display: flex; align-items: center; gap: 8px; }
.chart-card h3 .accent {
  width: 4px; height: 16px; border-radius: 2px;
  background: linear-gradient(180deg, var(--gold-500), var(--teal-600));
}
.chart-wrap { position: relative; height: 280px; }
.chart-wrap.sm { height: 220px; }

/* ═══ Badges ════════════════════════════════════════════════════════════ */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 600; padding: 3px 9px; border-radius: 999px;
  white-space: nowrap;
}
.badge-oa     { background: rgba(5,150,105,.1);  color: var(--emerald); }
.badge-closed { background: var(--surface-2);    color: var(--muted); }
.badge-gold   { background: rgba(201,162,39,.14); color: #8a6f10; }
[data-theme="dark"] .badge-gold { color: var(--gold-300); }

/* ═══ Tables ════════════════════════════════════════════════════════════ */
.table-wrap { overflow-x: auto; border-radius: var(--radius); }
table.data {
  width: 100%; border-collapse: collapse; font-size: 13.5px;
  background: var(--surface);
}
table.data th {
  text-align: left; font-size: 11px; font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.6px;
  padding: 12px 14px; border-bottom: 1px solid var(--border);
  background: var(--surface-2); white-space: nowrap;
}
table.data td {
  padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: top;
}
table.data tr:last-child td { border-bottom: none; }
table.data tr:hover td { background: var(--surface-2); }
table.data td.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data td.center { text-align: center; }
.rank { font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; }
.cit-count { font-weight: 700; color: var(--teal-700); font-variant-numeric: tabular-nums; }
[data-theme="dark"] .cit-count { color: #4dd4c8; }

/* ═══ Buttons ═══════════════════════════════════════════════════════════ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 16px; border-radius: 10px; font-size: 13px; font-weight: 600;
  cursor: pointer; border: 1px solid transparent; transition: var(--transition);
  text-decoration: none; white-space: nowrap;
}
.btn:focus-visible { outline: 2px solid var(--gold-500); outline-offset: 2px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--navy-800); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--navy-700); }
.btn-accent  { background: var(--gold-500); color: var(--navy-900); }
.btn-accent:hover:not(:disabled) { background: var(--gold-300); }
.btn-ghost   { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); border-color: var(--muted); }
.btn-sm { padding: 6px 12px; font-size: 12px; }

/* ═══ Filters ═══════════════════════════════════════════════════════════ */
.filters {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 16px; margin-bottom: 18px;
  display: grid; grid-template-columns: 2fr 1fr 1fr auto auto; gap: 10px;
  align-items: center;
}
@media (max-width: 900px) { .filters { grid-template-columns: 1fr 1fr; } }
@media (max-width: 560px) { .filters { grid-template-columns: 1fr; } }
.input, select.input {
  width: 100%; padding: 9px 12px; font-size: 13.5px;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface); color: var(--text);
  transition: var(--transition);
}
.input:focus { outline: none; border-color: var(--teal-600);
               box-shadow: 0 0 0 3px rgba(0,107,115,.12); }

/* ═══ Public list ══════════════════════════════════════════════════════ */
.pub-list { display: flex; flex-direction: column; gap: 10px; }
.pub-item {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 18px;
  display: grid; grid-template-columns: 1fr auto; gap: 14px;
  transition: var(--transition);
}
.pub-item:hover { border-color: var(--teal-600); box-shadow: var(--shadow-md); }
.pub-title { font-weight: 600; font-size: 15px; color: var(--text);
             margin: 0 0 6px; line-height: 1.4; }
.pub-meta { font-size: 12.5px; color: var(--muted); display: flex;
            flex-wrap: wrap; gap: 8px; align-items: center; }
.pub-meta > * { display: inline-flex; align-items: center; gap: 4px; }
.pub-meta .sep { opacity: .4; }
.pub-tldr { font-size: 13px; color: var(--muted); font-style: italic;
            border-left: 2px solid var(--gold-300); padding-left: 10px;
            margin-top: 8px; }
.pub-cit {
  text-align: right; padding-left: 14px; border-left: 1px solid var(--border);
  display: flex; flex-direction: column; justify-content: center;
  min-width: 80px;
}
.pub-cit .n { font-size: 22px; font-weight: 700; color: var(--teal-700);
              line-height: 1; font-variant-numeric: tabular-nums; }
.pub-cit .lbl { font-size: 10.5px; color: var(--muted); text-transform: uppercase;
                letter-spacing: 0.4px; margin-top: 4px; }
[data-theme="dark"] .pub-cit .n { color: #4dd4c8; }

/* ═══ Pagination ═══════════════════════════════════════════════════════ */
.pagination { display: flex; align-items: center; justify-content: center;
              gap: 14px; margin-top: 26px; }
.page-info { font-size: 13px; color: var(--muted); }

/* ═══ Loading skeleton ═════════════════════════════════════════════════ */
@keyframes shimmer {
  0%   { background-position: -400px 0; }
  100% { background-position: 400px 0; }
}
.skeleton-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 18px;
}
.skel {
  height: 12px; border-radius: 6px; margin-bottom: 10px;
  background: linear-gradient(90deg,
    var(--surface-2) 0%,
    color-mix(in srgb, var(--surface-2) 60%, var(--border)) 40%,
    var(--surface-2) 80%);
  background-size: 800px 100%;
  animation: shimmer 1.4s linear infinite;
}
.skel-title { height: 16px; width: 65%; }
.skel-line  { width: 90%; }
.skel-line.short { width: 45%; }
.skel-big   { height: 28px; width: 55%; margin: 14px 0; }

/* ═══ Empty / error ════════════════════════════════════════════════════ */
.state {
  padding: 60px 20px; text-align: center; border-radius: var(--radius);
  background: var(--surface); border: 1px dashed var(--border);
}
.state-icon { font-size: 36px; opacity: .7; margin-bottom: 10px; }
.state-title { font-weight: 600; font-size: 15px; margin-bottom: 4px; }
.state-hint { font-size: 13px; color: var(--muted); max-width: 500px;
              margin: 0 auto; word-break: break-word; }
.state-error { border-color: rgba(146,11,11,.3); }

/* ═══ Responsive drawer ════════════════════════════════════════════════ */
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .app.collapsed { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; top: var(--header-h); left: 0;
    width: 260px; max-width: 85vw;
    transform: translateX(-105%);
    transition: transform var(--transition);
    box-shadow: var(--shadow-lg); height: calc(100vh - var(--header-h));
  }
  .app.drawer-open .sidebar { transform: translateX(0); }
  .sidebar-toggle { display: none; }
  .backdrop {
    display: none; position: fixed; inset: var(--header-h) 0 0 0;
    background: rgba(0,31,49,.4); z-index: 25;
  }
  .app.drawer-open .backdrop { display: block; }
}
@media (min-width: 901px) { .hamburger, .backdrop { display: none !important; } }

/* ═══ Utility ═════════════════════════════════════════════════════════ */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
@media (max-width: 800px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mb-3 { margin-bottom: 12px; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
