:root {
  --bg: #f4f7fb;
  --surface: #ffffff;
  --ink: #0f1b2d;
  --muted: #5b6b7c;
  --line: #d9e2ec;
  --brand: #1d4f91;
  --brand-dark: #143868;
  --brand-soft: #e8f0fa;
  --accent: #2f80ed;
  --ok: #1f7a4d;
  --ok-bg: #e8f6ee;
  --warn: #9a6700;
  --warn-bg: #fff6dd;
  --err: #b42318;
  --err-bg: #fdecec;
  --shadow: 0 10px 30px rgba(20, 56, 104, 0.08);
  --radius: 16px;
  --radius-sm: 10px;
  --max: 1120px;
  --font: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: linear-gradient(180deg, #eef4fb 0%, var(--bg) 220px);
  min-height: 100vh;
  line-height: 1.55;
}
a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-dark); text-decoration: underline; }
img { max-width: 100%; display: block; }
code { font-family: ui-monospace, Consolas, monospace; }

.container {
  width: min(100% - 2rem, var(--max));
  margin-inline: auto;
}
.container:has(.admin-docs-layout) {
  width: min(100% - 1.5rem, 1280px);
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  backdrop-filter: blur(10px);
  background: rgba(255, 255, 255, 0.92);
  border-bottom: 1px solid var(--line);
}
.header-top {
  display: flex;
  gap: 1rem;
  justify-content: space-between;
  align-items: center;
  padding: 0.85rem 0;
  flex-wrap: wrap;
}
.brand {
  display: flex;
  gap: 0.85rem;
  align-items: center;
  color: inherit;
  text-decoration: none;
}
.brand:hover { text-decoration: none; color: inherit; }
.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: linear-gradient(145deg, var(--brand), var(--accent));
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 700;
  letter-spacing: 0.02em;
  box-shadow: 0 8px 18px rgba(29, 79, 145, 0.28);
}
.brand-text strong { display: block; font-size: 1.05rem; }
.brand-text span { color: var(--muted); font-size: 0.86rem; }

.header-actions {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  flex-wrap: wrap;
}
.nav {
  display: flex;
  gap: 0.2rem;
  flex-wrap: wrap;
  padding: 0 0 0.75rem;
}
.nav a {
  color: var(--muted);
  padding: 0.45rem 0.8rem;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.95rem;
  text-decoration: none;
}
.nav a:hover,
.nav a.active {
  color: var(--brand-dark);
  background: var(--brand-soft);
  text-decoration: none;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 0.65rem 1.15rem;
  font-weight: 650;
  font-size: 0.95rem;
  cursor: pointer;
  text-decoration: none;
  transition: 0.15s ease;
  background: var(--brand);
  color: #fff;
}
.btn:hover {
  background: var(--brand-dark);
  color: #fff;
  text-decoration: none;
}
.btn-secondary {
  background: #fff;
  color: var(--brand-dark);
  border-color: var(--line);
}
.btn-secondary:hover {
  background: var(--brand-soft);
  color: var(--brand-dark);
}
.btn-danger {
  background: var(--err);
}
.btn-danger:hover { background: #912018; }
.btn-sm {
  padding: 0.4rem 0.8rem;
  font-size: 0.85rem;
}

.flash-wrap { margin-top: 1.25rem; }
.flash {
  border-radius: var(--radius-sm);
  padding: 0.85rem 1rem;
  margin-bottom: 0.6rem;
  border: 1px solid transparent;
}
.flash-success { background: var(--ok-bg); color: var(--ok); border-color: #b7e4c7; }
.flash-error { background: var(--err-bg); color: var(--err); border-color: #f3c1c1; }
.flash-warning { background: var(--warn-bg); color: var(--warn); border-color: #f0d48a; }
.flash-info { background: var(--brand-soft); color: var(--brand-dark); border-color: #c9daf0; }

.hero {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 1.5rem;
  align-items: stretch;
  margin: 1.6rem 0 1.2rem;
}
.hero-card,
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.hero-card { padding: 1.8rem; }
.hero-card h1 {
  margin: 0 0 0.8rem;
  font-size: clamp(1.7rem, 3vw, 2.4rem);
  line-height: 1.2;
}
.hero-card p.lead {
  color: var(--muted);
  font-size: 1.05rem;
  margin: 0 0 1.2rem;
}
.hero-actions { display: flex; gap: 0.7rem; flex-wrap: wrap; }
.hero-media {
  overflow: hidden;
  min-height: 260px;
  background: #dbe7f5 center/cover no-repeat;
}
.hero-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.quick-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
  margin: 1rem 0 1.6rem;
}
.quick-card {
  padding: 1.2rem 1.3rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.quick-card .label {
  font-size: 0.8rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
}
.quick-card .value {
  margin-top: 0.35rem;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--brand-dark);
}
.quick-card p { margin: 0.45rem 0 0; color: var(--muted); }

.section { margin: 1.5rem 0 2rem; }
.section-head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: end;
  margin-bottom: 1rem;
}
.section-head h2 { margin: 0; font-size: 1.45rem; }
.section-head p { margin: 0; color: var(--muted); }

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}
.news-card { padding: 1.2rem; display: flex; flex-direction: column; gap: 0.55rem; }
.news-card time { color: var(--muted); font-size: 0.9rem; }
.news-card h3 { margin: 0; font-size: 1.1rem; line-height: 1.35; }
.news-card h3 a { color: inherit; text-decoration: none; }
.news-card h3 a:hover { color: var(--brand); }
.news-card p { margin: 0; color: var(--muted); flex: 1; }

.goals {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.9rem;
}
.goal {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.1rem 1.15rem;
}
.goal .icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: var(--brand-soft);
  color: var(--brand);
  font-weight: 700;
  margin-bottom: 0.7rem;
}
.goal h3 { margin: 0 0 0.35rem; font-size: 1rem; }
.goal p { margin: 0; color: var(--muted); font-size: 0.95rem; }

.page-hero {
  padding: 1.5rem 0 0.5rem;
}
.page-hero h1 { margin: 0 0 0.4rem; font-size: clamp(1.6rem, 2.5vw, 2.1rem); }
.page-hero p { margin: 0; color: var(--muted); max-width: 60ch; }

.content-card { padding: 1.4rem 1.5rem; }
.prose p { margin: 0 0 1rem; }
.prose ul { margin: 0 0 1rem; padding-left: 1.2rem; }
.prose li { margin: 0.35rem 0; }

.table-wrap { overflow-x: auto; }
table.data {
  width: 100%;
  border-collapse: collapse;
}
table.data th,
table.data td {
  text-align: left;
  padding: 0.85rem 0.7rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
table.data th {
  color: var(--muted);
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
table.data tr:last-child td { border-bottom: 0; }

.admin-docs-layout {
  grid-template-columns: 200px 1fr;
}
.admin-docs-layout > .docs-layout {
  min-width: 0;
  grid-template-columns: 250px 1fr;
}
.docs-main {
  min-width: 0;
  overflow: visible;
}
.docs-table-wrap {
  overflow: visible;
  padding-bottom: 0.25rem;
}
.docs-table {
  width: 100%;
  table-layout: auto;
}
.docs-table .docs-date {
  white-space: nowrap;
  width: 6.5rem;
}
.docs-table .docs-cat-col {
  max-width: 180px;
}
.docs-table .docs-actions-cell {
  width: 250px;
  min-width: 230px;
  white-space: normal;
  vertical-align: top;
  padding-right: 0.85rem;
}

.form {
  display: grid;
  gap: 1rem;
  max-width: 560px;
}
.form.wide { max-width: 760px; }
.form-row { display: grid; gap: 0.35rem; }
.form-row label { font-weight: 650; font-size: 0.92rem; }
.form-row .hint { color: var(--muted); font-size: 0.85rem; }
.form-row input,
.form-row select,
.form-row textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.75rem 0.9rem;
  font: inherit;
  background: #fff;
  color: var(--ink);
}
.form-row textarea { min-height: 140px; resize: vertical; }
.form-row input:focus,
.form-row select:focus,
.form-row textarea:focus {
  outline: 2px solid rgba(47, 128, 237, 0.25);
  border-color: var(--accent);
}
.form-actions { display: flex; gap: 0.7rem; flex-wrap: wrap; align-items: center; }
.checkbox {
  display: flex;
  gap: 0.55rem;
  align-items: center;
  font-weight: 550;
}

.auth-shell {
  min-height: calc(100vh - 180px);
  display: grid;
  place-items: center;
  padding: 2rem 0;
}
.auth-card {
  width: min(100%, 440px);
  padding: 1.6rem;
}
.auth-card h1 { margin: 0 0 0.4rem; font-size: 1.55rem; }
.auth-card .sub { color: var(--muted); margin: 0 0 1.2rem; }

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0.2rem 0.65rem;
  font-size: 0.78rem;
  font-weight: 700;
  background: var(--brand-soft);
  color: var(--brand-dark);
}
.badge-new { background: #e7f0ff; color: #1849a9; }
.badge-in_progress { background: var(--warn-bg); color: var(--warn); }
.badge-done { background: var(--ok-bg); color: var(--ok); }
.badge-rejected { background: var(--err-bg); color: var(--err); }
.badge-admin { background: #efe7ff; color: #6941c6; }
.badge-tsn_user { background: var(--ok-bg); color: var(--ok); }
.badge-user { background: var(--brand-soft); color: var(--brand-dark); }
.badge-member { background: var(--brand-soft); color: var(--brand-dark); }

table.data select {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.35rem 0.5rem;
  font: inherit;
  background: #fff;
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.9rem;
  margin-bottom: 1.2rem;
}
.stat {
  padding: 1rem 1.1rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.stat .n {
  font-size: 1.7rem;
  font-weight: 750;
  color: var(--brand-dark);
}
.stat .l { color: var(--muted); font-size: 0.9rem; }

.panel-layout {
  display: grid;
  grid-template-columns: 230px 1fr;
  gap: 1.1rem;
  margin: 1.3rem 0 2rem;
}
.side-nav {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.8rem;
  height: fit-content;
  position: sticky;
  top: 90px;
}
.side-nav a {
  display: block;
  padding: 0.65rem 0.8rem;
  border-radius: 10px;
  color: var(--muted);
  font-weight: 600;
  text-decoration: none;
}
.side-nav a:hover,
.side-nav a.active {
  background: var(--brand-soft);
  color: var(--brand-dark);
  text-decoration: none;
}
.side-nav .side-title {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  padding: 0.4rem 0.8rem 0.6rem;
  font-weight: 700;
}

.empty {
  padding: 1.4rem;
  color: var(--muted);
  text-align: center;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: #fafcff;
}

.site-footer {
  margin-top: 2.5rem;
  border-top: 1px solid var(--line);
  background: #fff;
}
.footer-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr;
  gap: 1.2rem;
  padding: 1.6rem 0;
}
.site-footer h3 { margin: 0 0 0.55rem; font-size: 1rem; }
.site-footer p, .site-footer a { color: var(--muted); }
.site-footer a:hover { color: var(--brand); }
.footer-bottom {
  border-top: 1px solid var(--line);
  padding: 0.85rem 0 1.2rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.docs-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 1rem;
  align-items: start;
}
.docs-nav {
  position: sticky;
  top: 90px;
  max-height: calc(100vh - 120px);
  overflow: auto;
}
.docs-cat {
  display: block;
  padding: 0.45rem 0.6rem;
  border-radius: 8px;
  color: var(--muted);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.92rem;
}
.docs-cat:hover,
.docs-cat.active {
  background: var(--brand-soft);
  color: var(--brand-dark);
  text-decoration: none;
}
.docs-cat.depth-1 { padding-left: 1.1rem; font-size: 0.9rem; }
.docs-cat.depth-2 { padding-left: 1.7rem; font-size: 0.88rem; }
.docs-cat.depth-3 { padding-left: 2.3rem; font-size: 0.86rem; }
.docs-cat.depth-4 { padding-left: 2.9rem; font-size: 0.84rem; }

@media (max-width: 900px) {
  .docs-layout { grid-template-columns: 1fr; }
  .docs-nav { position: static; max-height: none; }
}

.inline-form { display: inline; }
.doc-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
  margin-bottom: 0.45rem;
}
.doc-actions .btn {
  flex: 0 0 auto;
  white-space: nowrap;
}
.move-form {
  display: grid;
  gap: 0.25rem;
  margin: 0;
}
.move-label {
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 650;
}
.move-form select {
  width: 100%;
  max-width: 220px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.4rem 0.5rem;
  font: inherit;
  background: #fff;
}

.explorer-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 0.8rem;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 0.8rem;
}
.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
  font-weight: 600;
  margin-bottom: 0.8rem;
}
.breadcrumb a { text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; }
.crumb-sep { color: var(--muted); }
.crumb-current { color: var(--brand-dark); }

.folder-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.75rem;
  margin: 0 0 1.2rem;
}
.folder-tile {
  display: flex;
  gap: 0.7rem;
  align-items: center;
  padding: 0.85rem 0.95rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fafcff;
  text-decoration: none;
  color: inherit;
  transition: 0.12s ease;
}
.folder-tile:hover {
  border-color: #b7cceb;
  background: var(--brand-soft);
  text-decoration: none;
  color: inherit;
}
.folder-icon { font-size: 1.55rem; line-height: 1; }
.folder-meta strong { display: block; margin-bottom: 0.15rem; }
.stack { display: grid; gap: 0.9rem; }
.split {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  flex-wrap: wrap;
}
.muted { color: var(--muted); }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }

@media (max-width: 900px) {
  .hero,
  .grid-3,
  .goals,
  .stats,
  .footer-grid,
  .panel-layout,
  .quick-grid {
    grid-template-columns: 1fr;
  }
  .side-nav { position: static; }
  .nav { gap: 0.1rem; }
}
