:root {
  color-scheme: dark;
  --bg: #101317;
  --panel: #181d23;
  --panel-strong: #202832;
  --line: #303946;
  --text: #f4f7fb;
  --muted: #a8b2c0;
  --accent: #d7b56d;
  --accent-ink: #1f1604;
  --danger: #ff7c7c;
  --success: #7ee0a1;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background:
    linear-gradient(90deg, rgba(16, 19, 23, 0.93), rgba(16, 19, 23, 0.78)),
    url("/static/img/heimdall-background.png") center / cover fixed,
    var(--bg);
}

a {
  color: inherit;
  text-decoration: none;
}

.app-shell {
  display: flex;
  align-items: stretch;
  min-height: 100vh;
}

.shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
}

.sidebar {
  position: sticky;
  top: 0;
  width: 260px;
  min-height: 100vh;
  flex: 0 0 260px;
  border-right: 1px solid var(--line);
  padding: 20px 16px;
  background: rgba(16, 19, 23, 0.9);
  backdrop-filter: blur(18px);
}

.sidebar-brand {
  margin-bottom: 28px;
}

.side-nav {
  display: grid;
  gap: 8px;
}

.side-nav a {
  display: flex;
  align-items: center;
  min-height: 38px;
  border-radius: 8px;
  padding: 0 12px;
  color: var(--muted);
}

.side-nav a:hover,
.side-nav a.active {
  color: var(--text);
  background: rgba(32, 40, 50, 0.9);
}

.side-nav-group {
  display: grid;
  gap: 8px;
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.side-nav-group span {
  padding: 0 12px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 760;
  text-transform: uppercase;
}

.sidebar + .shell .topbar .brand {
  display: none;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 22px;
  min-height: 74px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 1.1rem;
  font-weight: 750;
}

.brand img {
  display: block;
  border-radius: 8px;
}

.nav {
  display: flex;
  gap: 14px;
  margin-left: auto;
  color: var(--muted);
  font-size: 0.95rem;
}

.nav a:hover {
  color: var(--text);
}

.icon-button {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: rgba(24, 29, 35, 0.82);
  cursor: pointer;
}

main {
  padding: 28px 0 60px;
}

.login-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 48px;
  align-items: center;
  min-height: calc(100vh - 130px);
}

.login-copy h1,
.page-head h1 {
  margin: 0;
  font-size: clamp(2.2rem, 7vw, 5.6rem);
  line-height: 0.95;
  letter-spacing: 0;
}

.login-copy p:not(.eyebrow) {
  max-width: 620px;
  color: var(--muted);
  font-size: 1.12rem;
  line-height: 1.7;
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--accent);
  font-weight: 760;
  text-transform: uppercase;
  font-size: 0.9rem;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(24, 29, 35, 0.9);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.26);
}

.login-panel,
.form-grid,
.upload-form {
  display: grid;
  gap: 18px;
  padding: 24px;
}

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 0.9rem;
}

input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  color: var(--text);
  background: #10151b;
}

textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--text);
  background: #10151b;
  font: inherit;
  resize: vertical;
}

select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  color: var(--text);
  background: #10151b;
}

input[type="file"] {
  padding: 10px;
}

button,
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 14px;
  color: var(--text);
  background: var(--panel-strong);
  cursor: pointer;
  font-weight: 700;
}

.primary {
  border-color: transparent;
  color: var(--accent-ink);
  background: var(--accent);
}

.danger-button {
  min-height: 34px;
  border-color: rgba(255, 124, 124, 0.42);
  color: var(--danger);
  background: rgba(255, 124, 124, 0.08);
}

.compact-button {
  width: 100%;
  min-height: 34px;
  padding: 0 10px;
}

.messages {
  display: grid;
  gap: 10px;
  margin: 10px 0;
}

.message {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  background: rgba(24, 29, 35, 0.92);
}

.message.error {
  border-color: rgba(255, 124, 124, 0.5);
  color: var(--danger);
}

.message.success {
  border-color: rgba(126, 224, 161, 0.5);
  color: var(--success);
}

.page-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  margin: 24px 0 26px;
}

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

.stats article {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 22px;
  background: rgba(24, 29, 35, 0.82);
}

.stats span {
  font-size: 2.5rem;
  font-weight: 800;
}

.stats p {
  margin: 8px 0 0;
  color: var(--muted);
}

.section {
  display: grid;
  gap: 14px;
  margin-top: 24px;
}

.requirement-form-panel {
  margin-top: 16px;
}

.requirement-form {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 180px 160px auto;
  gap: 16px;
  align-items: end;
  padding: 24px;
}

.wide-field {
  grid-column: 1 / -2;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.section-head h2 {
  margin: 0;
}

.table {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(24, 29, 35, 0.88);
}

.row {
  display: grid;
  grid-template-columns: 1fr 180px;
  gap: 14px;
  align-items: center;
  min-height: 52px;
  padding: 12px 16px;
  border-top: 1px solid var(--line);
}

.row:first-child {
  border-top: 0;
}

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

.table-head {
  color: var(--muted);
  background: rgba(32, 40, 50, 0.88);
}

.controls-table .row {
  grid-template-columns: 170px 120px minmax(220px, 1fr) 170px;
}

.requirements-table.edit-mode .row {
  grid-template-columns: 130px minmax(180px, 0.9fr) minmax(260px, 1.4fr) 170px 150px 128px;
}

.requirements-table.read-only .row {
  grid-template-columns: 130px minmax(180px, 0.9fr) minmax(260px, 1.4fr) 170px 150px;
  align-items: start;
}

.description-cell {
  white-space: pre-line;
  line-height: 1.55;
}

.requirement-edit-row textarea {
  min-height: 84px;
}

.row-actions {
  display: grid;
  gap: 8px;
}

.users-table .row {
  grid-template-columns: minmax(220px, 1fr) 160px 220px;
}

.empty {
  padding: 18px;
  color: var(--muted);
}

@media (max-width: 780px) {
  .app-shell {
    display: block;
  }

  .sidebar {
    position: static;
    width: auto;
    min-height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .sidebar + .shell .topbar .brand {
    display: inline-flex;
  }

  .topbar {
    align-items: flex-start;
    flex-wrap: wrap;
    padding: 14px 0;
  }

  .nav {
    order: 3;
    width: 100%;
    margin-left: 0;
    overflow-x: auto;
  }

  .login-layout,
  .stats {
    grid-template-columns: 1fr;
  }

  .login-layout {
    gap: 24px;
    align-items: start;
    min-height: auto;
  }

  .row,
  .controls-table .row,
  .requirements-table.edit-mode .row,
  .requirements-table.read-only .row {
    grid-template-columns: 1fr;
  }

  .requirement-form {
    grid-template-columns: 1fr;
  }

  .wide-field {
    grid-column: auto;
  }
}
