:root {
  --bg: #0e1116;
  --bg-elev: #151a22;
  --panel: #1b222d;
  --border: #2c3544;
  --border-soft: #242c38;
  --text: #e8edf5;
  --muted: #8b95a7;
  --accent: #4c8dff;
  --accent-strong: #3a78e8;
  --accent-ink: #f4f8ff;
  --accent-soft: rgba(76, 141, 255, 0.14);
  --danger: #ff7a6e;
  --ok: #5ecf8e;
  --paper: #ffffff;
  --ink: #1a1a1a;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.4);
  --radius: 12px;
  --font: 'Lexend', system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(900px 420px at 8% -12%, rgba(76, 141, 255, 0.12), transparent 55%),
    radial-gradient(700px 380px at 100% 0%, rgba(60, 90, 140, 0.1), transparent 50%),
    var(--bg);
  color: var(--text);
  font-family: var(--font);
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code {
  font-size: 0.92em;
  background: rgba(255, 255, 255, 0.06);
  padding: 0.1em 0.4em;
  border-radius: 5px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: color-mix(in srgb, var(--bg-elev) 88%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-soft);
}

.topbar-inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.topbar-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
}

.viewer-topbar {
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
  min-width: 0;
}
.brand i { color: var(--accent); flex-shrink: 0; }

.tabs {
  display: flex;
  gap: 6px;
  flex-wrap: nowrap;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding-bottom: 2px;
}
.tabs::-webkit-scrollbar { display: none; }
.tabs a {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 12px;
  border-radius: 999px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  flex-shrink: 0;
}
.tabs a.active,
.tabs a:hover {
  background: var(--accent-soft);
  color: var(--accent);
}

.user-menu {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--muted);
  min-width: 0;
}
.user-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.user-name {
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 180px;
}
.user-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--border);
  flex-shrink: 0;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 10px;
  cursor: pointer;
  text-decoration: none;
}
.btn:hover {
  text-decoration: none;
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
}
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}
.btn.primary:hover { background: var(--accent-strong); }
.btn.ghost {
  background: transparent;
  color: var(--muted);
}

.page {
  max-width: 1120px;
  margin: 0 auto;
  padding: 28px 20px 64px;
}
.page.narrow { max-width: 640px; }

.page-hero {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: end;
  margin-bottom: 28px;
  flex-wrap: wrap;
}
.page-hero h1 {
  font-family: var(--font);
  font-size: clamp(26px, 3.4vw, 34px);
  font-weight: 600;
  letter-spacing: -0.02em;
  margin: 4px 0 8px;
  line-height: 1.2;
}
.eyebrow {
  margin: 0;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  gap: 7px;
}
.lede {
  margin: 0;
  max-width: 48ch;
  color: var(--muted);
  line-height: 1.55;
}

.job-chips {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: 4px 8px;
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--accent);
  white-space: nowrap;
}
.chip.subtle {
  background: rgba(255, 255, 255, 0.05);
  color: var(--muted);
  font-weight: 600;
}

.doc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
  align-items: stretch;
}
.doc-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 148px;
  padding: 14px 14px 12px;
  background: var(--panel);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  color: inherit;
  text-decoration: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.doc-card:hover {
  border-color: color-mix(in srgb, var(--accent) 50%, var(--border));
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 25%, transparent);
  text-decoration: none;
}
.doc-card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  min-height: 24px;
}
.doc-date {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}
.doc-card h3 {
  margin: 0;
  flex: 1;
  font-family: var(--font);
  font-size: 15px;
  font-weight: 600;
  line-height: 1.35;
  color: var(--text);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.doc-author {
  margin: 0;
  margin-top: auto;
  font-size: 12px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.kind-tag {
  margin-left: auto;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 2px 6px;
  border-radius: 4px;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: end;
  margin-bottom: 18px;
  padding: 16px;
  background: var(--panel);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
}
.filters label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.filters label.grow { flex: 1; min-width: 200px; }
.filters select,
.filters input,
.admin-form input {
  font: inherit;
  font-size: 14px;
  text-transform: none;
  letter-spacing: 0;
  font-weight: 500;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
}
.filters button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  color: var(--accent-ink);
  background: var(--accent);
  border: none;
  border-radius: 10px;
  padding: 10px 16px;
  cursor: pointer;
}

.meta-line {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
  margin: 0 0 14px;
}
.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }

.empty-state {
  padding: 36px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.02);
}
.empty-state.compact {
  text-align: center;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.empty-state h1, .empty-state h2 {
  font-family: var(--font);
  margin: 0 0 10px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.empty-state p { color: var(--muted); line-height: 1.55; }

.pagination { display: flex; gap: 10px; margin-top: 20px; }
.pagination a {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel);
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.panel {
  margin-bottom: 22px;
  padding: 18px;
  background: var(--panel);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
}
.panel h2 {
  margin: 0 0 14px;
  font-size: 16px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}
.panel h2 i { color: var(--accent); }

.admin-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  align-items: stretch;
}
.admin-form.row {
  flex-direction: row;
  flex-wrap: wrap;
  align-items: end;
}
.admin-form.row > label { max-width: 360px; flex: 1; }
.check-inline {
  display: inline-flex !important;
  flex-direction: row !important;
  align-items: center;
  gap: 8px;
  text-transform: none;
  letter-spacing: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  padding-bottom: 10px;
}
.actions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.share-url-input {
  display: block;
  width: 100%;
  margin-top: 8px;
  font: inherit;
  font-size: 12px;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
}
.admin-form > label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  max-width: 420px;
}
.field-caption {
  display: block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
}
.check-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 8px;
}
.check-grid.compact {
  grid-template-columns: 1fr;
  margin-bottom: 8px;
}
.check-card {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg);
  cursor: pointer;
  text-transform: none;
  letter-spacing: 0;
  font-weight: 500;
}
.check-card.compact {
  padding: 8px 10px;
  align-items: center;
}
.check-card input { margin-top: 3px; accent-color: var(--accent); }
.check-card.compact input { margin-top: 0; }
.check-card strong {
  display: block;
  color: var(--text);
  font-size: 13px;
  font-weight: 650;
}
.check-card small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
}
.check-card span { color: var(--text); font-size: 12.5px; }

.fineprint { font-size: 12px; color: var(--muted); margin: 12px 0 0; }

.table-wrap {
  overflow: auto;
  border: 1px solid var(--border-soft);
  border-radius: 12px;
}
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.data-table th,
.data-table td {
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border-soft);
  vertical-align: top;
}
.data-table th {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  background: rgba(0, 0, 0, 0.18);
}
.data-table tr:last-child td { border-bottom: none; }
.user-cell { display: flex; flex-direction: column; gap: 2px; }
.actions { display: flex; flex-direction: column; gap: 8px; min-width: min(260px, 100%); }
.inline-edit-jobs { display: flex; flex-direction: column; gap: 8px; }

.banner {
  padding: 12px 14px;
  border-radius: 12px;
  margin-bottom: 16px;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.banner.ok { background: rgba(94, 207, 142, 0.12); color: var(--ok); }
.banner.error { background: rgba(255, 122, 110, 0.12); color: var(--danger); }

.viewer-body { background: #0b0e13; }
.doc-meta {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.doc-meta strong {
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.doc-meta span {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.share-badge {
  display: block !important;
  color: var(--accent) !important;
  font-weight: 600;
}

.viewer { padding: 24px 16px 48px; }
.page-block {
  width: min(794px, 100%);
  margin: 0 auto 18px;
}
.page-indicator {
  text-align: center;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 10px 0 0;
}

.a4-page {
  width: 100%;
  max-width: 794px;
  min-height: 1123px;
  margin: 0 auto;
  background: var(--paper);
  color: var(--ink);
  border-radius: 4px;
  padding: 76px 68px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 14px;
  line-height: 1.65;
  word-break: break-word;
  box-shadow: var(--shadow);
}
.a4-page h1 { font-size: 24px; margin: 0.5em 0 0.35em; line-height: 1.3; }
.a4-page h2 { font-size: 19px; margin: 0.5em 0 0.35em; line-height: 1.3; }
.a4-page h3 { font-size: 16px; margin: 0.5em 0 0.35em; line-height: 1.3; }
.a4-page p { margin: 0 0 0.45em; }
.a4-page ul, .a4-page ol { margin: 0.35em 0 0.6em; padding-left: 1.6em; }
.a4-page hr { border: none; border-top: 1px solid #ccc; margin: 1em 0; }
.a4-page img { max-width: 100%; height: auto; }
.a4-page table { width: 100%; border-collapse: collapse; }
.a4-page td, .a4-page th { padding: 3px 6px; vertical-align: top; }

.login-body { min-height: 100vh; }
.login-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
}
.login-visual {
  position: relative;
  overflow: hidden;
  padding: 48px;
  display: flex;
  align-items: end;
  background:
    linear-gradient(160deg, rgba(14, 17, 22, 0.15), rgba(14, 17, 22, 0.88)),
    linear-gradient(145deg, #1a2740, #0e1116 72%);
}
.login-visual-copy { position: relative; z-index: 1; max-width: 420px; }
.login-visual-copy h1 {
  font-family: var(--font);
  font-size: clamp(32px, 4.5vw, 44px);
  font-weight: 600;
  letter-spacing: -0.02em;
  margin: 8px 0 14px;
  line-height: 1.1;
}
.login-visual-copy p:last-child { color: var(--muted); line-height: 1.6; margin: 0; }
.login-card {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 48px clamp(24px, 5vw, 64px);
  background: var(--bg-elev);
  border-left: 1px solid var(--border-soft);
}
.login-card h2 {
  font-family: var(--font);
  font-size: 28px;
  margin: 6px 0 12px;
  letter-spacing: -0.02em;
}
.discord-btn {
  margin-top: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  max-width: 360px;
  padding: 14px 18px;
  border-radius: 12px;
  background: #5865f2;
  color: #fff;
  font-weight: 700;
  text-decoration: none;
  transition: filter 0.15s, transform 0.15s;
}
.discord-btn:hover {
  filter: brightness(1.08);
  transform: translateY(-1px);
  text-decoration: none;
}
.discord-btn i { font-size: 18px; }

@media (max-width: 900px) {
  .login-shell { grid-template-columns: 1fr; }
  .login-visual { min-height: 200px; padding: 24px; }
  .login-card { padding: 28px 20px 40px; border-left: none; border-top: 1px solid var(--border-soft); }
  .a4-page { min-height: 0; padding: 28px 18px; font-size: 13px; }
  .page { padding: 20px 14px 48px; }
  .page-hero { align-items: start; gap: 14px; margin-bottom: 20px; }
  .job-chips { justify-content: flex-start; width: 100%; }
  .doc-grid { grid-template-columns: 1fr; }
  .filters { flex-direction: column; align-items: stretch; }
  .filters label,
  .filters label.grow,
  .admin-form.row > label { max-width: none; width: 100%; min-width: 0; }
  .filters button,
  .admin-form .btn,
  .discord-btn { width: 100%; max-width: none; }
  .check-grid { grid-template-columns: 1fr; }
  .viewer-topbar { flex-direction: column; align-items: stretch; }
  .viewer-topbar .doc-meta { order: 3; }
  .viewer-topbar .print-btn { width: 100%; }
  .pagination { flex-wrap: wrap; }
  .panel { padding: 14px; }
  .data-table { font-size: 13px; }
  .data-table th,
  .data-table td { padding: 10px; }
}

@media (max-width: 640px) {
  .topbar-inner { padding: 10px 12px; }
  .brand-text { max-width: 140px; overflow: hidden; text-overflow: ellipsis; }
  .user-name { max-width: 110px; }
  .logout-label,
  .print-label { display: none; }
  .logout-btn,
  .print-btn { padding: 8px 10px; }
  .tabs a { padding: 7px 10px; font-size: 12px; }
  .page-hero h1 { font-size: 24px; }
  .lede { max-width: none; font-size: 14px; }
  .empty-state { padding: 22px 16px; }
  .empty-state h1,
  .empty-state h2 { font-size: 18px; flex-wrap: wrap; }
  .chip { white-space: normal; }
  .doc-card { min-height: 0; }
  .doc-author { flex-wrap: wrap; white-space: normal; }
  .kind-tag { margin-left: 0; }
  .admin-form.row { flex-direction: column; align-items: stretch; }
  .check-inline { padding-bottom: 0; }
  .actions-row .btn { width: 100%; justify-content: center; }
  .actions { min-width: 0; }
  .banner { flex-wrap: wrap; }
  .share-url-input { font-size: 11px; }
  .meta-line { flex-wrap: wrap; }
  .a4-page { padding: 20px 14px; font-size: 12.5px; }
  .viewer { padding: 14px 8px 36px; }
}

@media (max-width: 420px) {
  .brand-text { display: none; }
  .user-badges .chip span,
  .user-badges .chip { font-size: 10px; padding: 3px 6px; }
}

@media print {
  .no-print { display: none !important; }
  body, .viewer-body { background: #fff !important; }
  .viewer { padding: 0; }
  .page-block { width: 210mm; margin: 0; page-break-after: always; }
  .page-block:last-child { page-break-after: auto; }
  .a4-page {
    width: 210mm;
    min-height: 297mm;
    max-width: none;
    box-shadow: none;
    border-radius: 0;
    padding: 20mm 18mm;
  }
}
