:root {
  color-scheme: dark;
  --bg: #0f1115;
  --surface: #181c22;
  --surface-2: #202630;
  --surface-3: #12161c;
  --line: #303845;
  --text: #f1f5f9;
  --muted: #a8b2c1;
  --soft: #768294;
  --cyan: #31c7d8;
  --green: #79d28b;
  --yellow: #f0c75e;
  --red: #ef6b73;
  --violet: #a993ff;
  --shadow: 0 18px 50px rgba(0,0,0,.34);
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
  line-height: 1.45;
}

a { color: inherit; }

button, input, select, textarea {
  font: inherit;
}

button { cursor: pointer; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  min-height: 68px;
  display: grid;
  grid-template-columns: 250px 1fr auto;
  gap: 18px;
  align-items: center;
  padding: 12px 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(15,17,21,.96);
  backdrop-filter: blur(14px);
}

.brand-link {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  font-weight: 800;
  letter-spacing: 0;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1fb6c8, #3b7259 55%, #b38b2c);
  color: #fff;
  font-size: 14px;
  font-weight: 800;
  box-shadow: 0 10px 30px rgba(49,199,216,.18);
}

.brand-mark.small {
  width: 34px;
  height: 34px;
  font-size: 12px;
}

.global-search {
  position: relative;
}

.global-search i {
  position: absolute;
  left: 13px;
  top: 50%;
  width: 18px;
  height: 18px;
  transform: translateY(-50%);
  color: var(--soft);
  pointer-events: none;
}

.global-search input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #0c0f13;
  color: var(--text);
  padding: 0 14px 0 42px;
  outline: none;
}

.global-search input:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px rgba(49,199,216,.12);
}

.search-results {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  max-height: 420px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 8px;
}

.search-results:empty { display: none; }

.search-hit {
  display: grid;
  gap: 3px;
  padding: 10px;
  border-radius: 6px;
  text-decoration: none;
}

.search-hit:hover { background: var(--surface-2); }
.search-hit strong { font-size: 14px; }
.search-hit span { color: var(--muted); font-size: 12px; }

.top-actions {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.top-actions a,
.top-actions button,
.inline-action,
.primary-action,
.ghost-action {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 7px;
  border: 1px solid var(--line);
  padding: 0 14px;
  background: var(--surface-2);
  color: var(--text);
  text-decoration: none;
}

.top-actions button {
  background: transparent;
}

.primary-action {
  width: 100%;
  border-color: rgba(49,199,216,.45);
  background: #146a75;
  font-weight: 700;
}

.ghost-action {
  background: transparent;
}

.app-shell {
  display: grid;
  grid-template-columns: 250px 1fr;
  min-height: calc(100vh - 68px);
}

.sidebar {
  border-right: 1px solid var(--line);
  background: #11151a;
  padding: 18px 14px;
}

.nav-block { margin-bottom: 22px; }
.nav-title {
  margin: 0 0 8px 8px;
  color: var(--soft);
  text-transform: uppercase;
  letter-spacing: .08em;
  font-size: 11px;
  font-weight: 700;
}

.side-link {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 40px;
  padding: 0 10px;
  border-radius: 7px;
  color: var(--muted);
  text-decoration: none;
}

.side-link i { width: 17px; height: 17px; }
.side-link.active,
.side-link:hover {
  background: var(--surface-2);
  color: var(--text);
}

.main {
  padding: 28px;
  min-width: 0;
}

.section-head {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 22px;
}

.section-head h1 {
  margin: 0;
  font-size: clamp(26px, 4vw, 42px);
  line-height: 1.05;
  letter-spacing: 0;
}

.section-head p { margin: 0; color: var(--muted); max-width: 860px; }
.eyebrow {
  color: var(--cyan) !important;
  text-transform: uppercase;
  letter-spacing: .08em;
  font-size: 12px;
  font-weight: 800;
}

.content-grid {
  display: grid;
  gap: 16px;
}

.content-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.content-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.content-grid.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.surface {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 18px;
  box-shadow: 0 12px 34px rgba(0,0,0,.16);
}

.surface h2,
.surface h3 {
  margin: 0 0 12px;
}

.surface p {
  color: var(--muted);
}

.metric strong {
  display: block;
  font-size: 30px;
  line-height: 1;
  margin-bottom: 7px;
}

.metric span { color: var(--muted); }

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.badge.primary { color: var(--green); border-color: rgba(121,210,139,.35); }
.badge.strong { color: var(--cyan); border-color: rgba(49,199,216,.35); }
.badge.historic { color: var(--yellow); border-color: rgba(240,199,94,.35); }
.badge.draft, .badge.ready_for_profile { color: var(--yellow); border-color: rgba(240,199,94,.35); }
.badge.published, .badge.approved { color: var(--green); border-color: rgba(121,210,139,.35); }

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 780px;
}

th, td {
  text-align: left;
  padding: 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

th {
  color: var(--soft);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .06em;
  background: #11161d;
}

td { color: var(--muted); }
td strong, .link-title { color: var(--text); }

.profile-card {
  display: grid;
  gap: 14px;
}

.profile-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.profile-header h2 {
  margin: 0;
  font-size: 26px;
}

.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

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

.link-list a {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-3);
  text-decoration: none;
}

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

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #0c0f13;
  color: var(--text);
  padding: 11px 12px;
  outline: none;
}

textarea {
  min-height: 130px;
  resize: vertical;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--cyan);
}

.span-2 { grid-column: span 2; }
.form-message { min-height: 20px; color: var(--muted); }
.form-message[data-type="ok"] { color: var(--green); }
.form-message[data-type="err"] { color: var(--red); }

.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 22px;
}

.auth-shell {
  width: min(100%, 460px);
}

.auth-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 24px;
  box-shadow: var(--shadow);
}

.back-link {
  color: var(--muted);
  text-decoration: none;
  font-size: 13px;
}

.brand-lockup {
  display: flex;
  gap: 14px;
  align-items: center;
  margin: 22px 0;
}

.brand-lockup h1 {
  margin: 0;
}

.brand-lockup p {
  margin: 4px 0 0;
  color: var(--muted);
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 5px;
  margin-bottom: 16px;
  background: #0c0f13;
}

.auth-tabs button {
  border: 0;
  border-radius: 5px;
  min-height: 38px;
  background: transparent;
  color: var(--muted);
}

.auth-tabs button.active {
  background: var(--surface-2);
  color: var(--text);
}

#auth-form {
  display: grid;
  gap: 12px;
}

.auth-note {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  display: grid;
  gap: 4px;
}

.auth-note span {
  color: var(--muted);
  font-size: 13px;
}

.account-layout {
  max-width: 980px;
  margin: 0 auto;
  padding: 32px 22px;
}

.kv {
  display: grid;
  gap: 12px;
}

.kv div {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 10px;
}

.kv dt { color: var(--muted); }
.kv dd { margin: 0; color: var(--text); }

@media (max-width: 920px) {
  .topbar {
    grid-template-columns: 1fr;
  }
  .app-shell {
    grid-template-columns: 1fr;
  }
  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    display: flex;
    overflow-x: auto;
    gap: 12px;
  }
  .nav-block {
    min-width: 220px;
    margin: 0;
  }
  .content-grid.two,
  .content-grid.three,
  .content-grid.four,
  .form-grid {
    grid-template-columns: 1fr;
  }
  .span-2 {
    grid-column: auto;
  }
}

