:root {
  --bg: #060816;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(121, 138, 255, 0.24);
  --text: #f3f6ff;
  --muted: #9ca6d5;
  --accent: #6984ff;
  --accent-strong: #87a0ff;
  --pink-glow: rgba(197, 86, 255, 0.24);
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.42);
  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 16px;
  --sans: "Segoe UI", "Aptos", "Helvetica Neue", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--sans);
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(124, 73, 255, 0.28), transparent 24%),
    radial-gradient(circle at top right, rgba(0, 189, 255, 0.16), transparent 22%),
    linear-gradient(180deg, #050712 0%, #090b17 52%, #050611 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
  background-size: 30px 30px;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.85), transparent 85%);
}

body.modal-open {
  overflow: hidden;
}

button,
input {
  font: inherit;
}

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

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}

.portal-card {
  width: min(460px, 100%);
  padding: 28px;
  border: 1px solid var(--line-strong);
  border-radius: 28px;
  background: linear-gradient(180deg, rgba(14, 17, 35, 0.98), rgba(10, 12, 25, 0.98));
  box-shadow: var(--shadow);
}

.portal-copy,
.gate-message,
.results-meta,
.publication-top p,
.month-panel p,
.external-link-card span,
.tree-summary-main span,
.brand-subtitle,
.footer-credit {
  color: var(--muted);
}

.portal-copy {
  margin-top: 12px;
  line-height: 1.6;
}

.portal-form {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

.portal-form input,
.global-search input {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  padding: 13px 14px;
  outline: none;
}

.gate-message {
  margin-top: 12px;
  color: #ff9ab2;
}

.app-frame {
  width: min(1380px, calc(100% - 28px));
  margin: 0 auto;
  padding: 14px 0 36px;
}

.sticky-header {
  position: sticky;
  top: 12px;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 16px 18px;
  border: 1px solid var(--line-strong);
  border-radius: 24px;
  background: rgba(10, 12, 24, 0.82);
  backdrop-filter: blur(20px);
  box-shadow: var(--shadow);
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-mark {
  width: 44px;
  height: 52px;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(132, 110, 255, 0.95), rgba(82, 163, 255, 0.9));
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.08),
    0 0 36px rgba(105, 132, 255, 0.35);
  position: relative;
  clip-path: polygon(0 0, 72% 0, 100% 28%, 100% 100%, 0 100%);
}

.brand-mark::before {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  width: 14px;
  height: 14px;
  background: rgba(255, 255, 255, 0.2);
  clip-path: polygon(0 0, 100% 100%, 0 100%);
}

.brand-mark::after {
  content: "";
  position: absolute;
  left: 10px;
  right: 10px;
  top: 16px;
  height: 20px;
  background:
    linear-gradient(rgba(255, 255, 255, 0.9), rgba(255, 255, 255, 0.9)) 0 0 / 100% 2px no-repeat,
    linear-gradient(rgba(255, 255, 255, 0.8), rgba(255, 255, 255, 0.8)) 0 8px / 100% 2px no-repeat,
    linear-gradient(rgba(255, 255, 255, 0.7), rgba(255, 255, 255, 0.7)) 0 16px / 72% 2px no-repeat;
}

.brand-kicker,
.section-kicker {
  margin: 0 0 6px;
  color: var(--accent-strong);
  font-size: 0.74rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.brand-subtitle {
  margin-top: 6px;
}

h1,
h2,
h3,
h4,
p {
  margin: 0;
}

h1 {
  font-size: clamp(1.15rem, 2vw, 1.45rem);
  font-weight: 600;
}

h2 {
  font-size: clamp(1.4rem, 2.5vw, 2rem);
  line-height: 1.05;
}

h3,
h4 {
  font-size: clamp(1.1rem, 1.8vw, 1.4rem);
  font-weight: 600;
}

.header-actions,
.manager-header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logout-form {
  margin: 0;
}

.global-search {
  width: min(420px, 48vw);
}

.global-search input::placeholder,
.portal-form input::placeholder {
  color: #7280b6;
}

.global-search input:focus,
.portal-form input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(105, 132, 255, 0.14);
}

.save-button,
.utility-button,
.tree-actions button,
.chip,
.icon-button,
.admin-link,
.logout-button {
  border: 1px solid transparent;
  border-radius: 14px;
  color: var(--text);
  cursor: pointer;
  transition:
    transform 180ms ease,
    border-color 180ms ease,
    background-color 180ms ease,
    box-shadow 180ms ease,
    opacity 180ms ease,
    color 180ms ease;
}

.save-button:hover,
.utility-button:hover,
.tree-actions button:hover,
.chip:hover,
.icon-button:hover,
.admin-link:hover,
.logout-button:hover {
  transform: translateY(-1px);
}

.save-button {
  background: linear-gradient(135deg, #5671ff, #7f54ff);
  box-shadow: 0 10px 26px rgba(92, 113, 255, 0.32);
}

.logout-button {
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.08);
  color: var(--muted);
}

.logout-button:hover {
  color: var(--text);
  border-color: rgba(121, 138, 255, 0.3);
}

.save-button,
.utility-button {
  padding: 12px 16px;
}

.dashboard-shell {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 18px;
  margin-top: 18px;
}

.compact-shell {
  align-items: start;
}

.sidebar-panel {
  display: grid;
  gap: 18px;
  align-self: start;
  position: sticky;
  top: 108px;
}

.compact-sidebar {
  top: 108px;
}

.sidebar-card,
.directory-panel,
.manager-card,
.manager-drawer {
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(14, 17, 35, 0.96), rgba(10, 12, 25, 0.96));
  box-shadow: var(--shadow);
}

.sidebar-card,
.directory-panel,
.manager-card {
  border-radius: var(--radius-xl);
  padding: 20px;
}

.card-heading,
.directory-topline {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
}

.filter-group + .filter-group {
  margin-top: 20px;
}

.filter-title {
  margin-bottom: 12px;
  font-weight: 600;
}

.chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.chip {
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.08);
}

.chip.active {
  background: rgba(105, 132, 255, 0.18);
  border-color: rgba(105, 132, 255, 0.44);
  box-shadow: 0 0 0 1px rgba(105, 132, 255, 0.18) inset;
}

.content-column {
  display: grid;
  gap: 18px;
}

.directory-content {
  display: grid;
  gap: 18px;
  margin-top: 20px;
}

.publication-block {
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.02);
  padding: 18px;
}

.publication-top {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.publication-top p {
  max-width: 380px;
  line-height: 1.6;
}

.years-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.year-panel {
  padding: 18px;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: linear-gradient(180deg, rgba(18, 22, 42, 0.96), rgba(11, 13, 27, 0.98));
}

.year-panel-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.year-pill,
.month-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 82px;
  padding: 10px 14px;
  border-radius: 999px;
  font-weight: 700;
}

.year-pill {
  background: rgba(105, 132, 255, 0.16);
  border: 1px solid rgba(105, 132, 255, 0.24);
}

.year-meta {
  color: var(--muted);
  font-size: 0.92rem;
}

.month-panel {
  border-top: 1px solid rgba(255, 255, 255, 0.07);
}

.month-panel:first-of-type {
  border-top: 0;
}

.month-panel summary,
.tree-item {
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.month-panel summary {
  padding: 16px 0;
  cursor: pointer;
}

.month-panel summary::-webkit-details-marker,
.tree-node > summary::-webkit-details-marker {
  display: none;
}

.month-summary-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.folder-glyph {
  width: 42px;
  height: 34px;
  border-radius: 11px;
  background: linear-gradient(180deg, rgba(104, 129, 255, 0.96), rgba(86, 64, 189, 0.96));
  position: relative;
  flex: 0 0 auto;
}

.folder-glyph::before {
  content: "";
  position: absolute;
  top: -6px;
  left: 6px;
  width: 18px;
  height: 10px;
  border-radius: 8px 8px 3px 3px;
  background: #87a0ff;
}

.month-count {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--accent-strong);
  font-size: 0.84rem;
}

.month-links {
  display: grid;
  gap: 10px;
  padding: 0 0 16px;
}

.external-link-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.07);
  text-decoration: none;
  color: var(--text);
  background: rgba(255, 255, 255, 0.03);
  transition:
    border-color 180ms ease,
    box-shadow 180ms ease,
    background-color 180ms ease;
}

.external-link-card:hover {
  border-color: rgba(121, 138, 255, 0.45);
  background: rgba(105, 132, 255, 0.08);
  box-shadow:
    0 0 0 1px rgba(121, 138, 255, 0.16) inset,
    0 0 26px rgba(105, 132, 255, 0.24);
}

.link-action {
  color: var(--accent-strong);
  font-weight: 600;
}

.empty-state {
  margin-top: 20px;
  padding: 34px 20px;
  border-radius: 18px;
  border: 1px dashed rgba(255, 255, 255, 0.14);
  text-align: center;
}

.empty-state p {
  margin-top: 10px;
  color: var(--muted);
}

.site-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 14px;
}

.footer-credit a {
  color: var(--accent-strong);
  text-decoration: none;
}

.footer-credit a:hover {
  text-decoration: underline;
}

.admin-link {
  padding: 8px 0;
  border: 0;
  background: transparent;
  color: rgba(156, 166, 213, 0.66);
  border-radius: 0;
}

.admin-link:hover {
  color: var(--accent-strong);
  opacity: 1;
}

.manager-modal[hidden] {
  display: none;
}

.manager-modal {
  position: fixed;
  inset: 0;
  z-index: 50;
}

.manager-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(2, 4, 12, 0.68);
  backdrop-filter: blur(8px);
}

.manager-drawer {
  position: absolute;
  inset: 18px 18px 18px auto;
  width: min(1080px, calc(100% - 24px));
  overflow: auto;
  padding: 20px;
  border-radius: 28px;
}

.manager-header,
.manager-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.icon-button {
  width: 42px;
  height: 42px;
  font-size: 1.4rem;
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.08);
}

.manager-actions {
  margin-top: 18px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.utility-button {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.08);
}

.utility-button-danger {
  border-color: rgba(255, 111, 145, 0.3);
  color: #ff9ab2;
}

.file-import {
  position: relative;
  overflow: hidden;
}

.file-import input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.manager-tree-card {
  padding: 0;
  overflow: hidden;
}

.manager-tree {
  padding: 14px;
}

.tree-list {
  display: grid;
  gap: 10px;
}

.tree-children {
  margin-left: 18px;
  padding-left: 14px;
  border-left: 1px solid rgba(255, 255, 255, 0.08);
}

.tree-node {
  border-radius: 18px;
}

.tree-item {
  padding: 14px 16px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.03);
}

.tree-item[draggable="true"] {
  cursor: grab;
}

.tree-item.dragging {
  opacity: 0.5;
}

.tree-item.drag-over-before {
  box-shadow: inset 0 3px 0 rgba(105, 132, 255, 0.85);
}

.tree-item.drag-over-after {
  box-shadow: inset 0 -3px 0 rgba(105, 132, 255, 0.85);
}

.tree-summary-main {
  display: grid;
  gap: 4px;
}

.tree-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.tree-actions button {
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.07);
}

.tree-actions button[data-action*="delete"] {
  color: #ff9ab2;
  border-color: rgba(255, 111, 145, 0.22);
}

@media (max-width: 1100px) {
  .dashboard-shell,
  .years-grid {
    grid-template-columns: 1fr;
  }

  .sidebar-panel {
    position: static;
  }

  .publication-top,
  .directory-topline,
  .manager-header,
  .site-footer {
    align-items: flex-start;
    flex-direction: column;
  }
}

@media (max-width: 760px) {
  .app-frame {
    width: min(100% - 14px, 1380px);
  }

  .sticky-header,
  .header-actions,
  .manager-actions,
  .tree-item,
  .month-panel summary,
  .external-link-card,
  .manager-header-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .global-search,
  .portal-card,
  .logout-form {
    width: 100%;
  }

  .save-button,
  .utility-button,
  .icon-button,
  .tree-actions button,
  .logout-button {
    width: 100%;
  }

  .sidebar-card,
  .directory-panel,
  .manager-drawer,
  .portal-card {
    padding: 16px;
    border-radius: 22px;
  }

  .manager-drawer {
    inset: 10px;
    width: auto;
  }

  .tree-actions {
    justify-content: stretch;
  }
}
