:root {
  color-scheme: light;
  --ink: #202124;
  --muted: #666a70;
  --line: #dddeda;
  --soft: #f6f6f2;
  --paper: #ffffff;
  --blue: #d43a20;
  --green: #4e9d31;
  --red: #b52b20;
  --brand-red: #d43a20;
  --brand-orange: #f29b20;
  --brand-yellow: #f1d82d;
  --brand-green: #56ad35;
  --footer-bg: #202124;
  --footer-text: #c2c4c7;
  --shadow: 0 18px 45px rgba(32, 33, 36, 0.11);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  overflow-x: hidden;
  background: #ffffff;
  color: var(--ink);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

button {
  cursor: pointer;
}

.site-header {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 28px;
  min-height: 112px;
  padding: 12px 28px 16px;
  background: #ffffff;
  box-shadow: 0 4px 18px rgba(32, 33, 36, 0.08);
}

.site-header::after {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  height: 5px;
  background: linear-gradient(90deg, #e63324 0%, var(--brand-orange) 34%, var(--brand-yellow) 58%, var(--brand-green) 100%);
  content: "";
}

.site-brand {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}

.site-brand img {
  display: block;
  width: 210px;
  max-height: 84px;
  object-fit: contain;
}

.site-title {
  color: #252525;
  font-size: 26px;
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.02em;
}

.site-title small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

main {
  min-height: calc(100vh - 138px);
}

.page-view[hidden],
.admin-section[hidden],
.admin-subsection[hidden],
.login-screen[hidden] {
  display: none;
}

.login-screen {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 28px;
  background: rgba(244, 247, 250, 0.96);
}

.login-card {
  display: grid;
  gap: 16px;
  width: min(440px, 100%);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 26px;
  background: #ffffff;
  box-shadow: var(--shadow);
}

.app-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: calc(100vh - 138px);
}

.workspace {
  min-width: 0;
  padding: 28px;
  background: #ffffff;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 24px;
  background: rgb(37, 40, 43);
  color: #f7fbff;
}

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

.nav-item {
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #c8d3e3;
  padding: 12px 14px;
  text-align: left;
  font-weight: 700;
}

.nav-item.active,
.nav-item:hover {
  background: var(--brand-red);
  color: #ffffff;
}

.subnav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
}

.subnav-item {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 14px;
  color: var(--ink);
  background: #ffffff;
  font-weight: 800;
}

.subnav-item.active,
.subnav-item:hover {
  color: #ffffff;
  border-color: var(--brand-red);
  background: var(--brand-red);
}

.side-panel {
  display: grid;
  gap: 10px;
  padding-top: 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.side-panel.compact {
  margin-top: auto;
}

.mini-label {
  color: #aebbd0;
  font-size: 13px;
  font-weight: 700;
}

.user-chip {
  display: grid;
  gap: 2px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  padding: 10px 12px;
  background: #33383d;
}

.user-chip span {
  color: #aebbd0;
  font-size: 13px;
}

.status-row {
  display: flex;
  align-items: center;
  gap: 9px;
  color: #d8e3f1;
  font-size: 14px;
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: #61d394;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  margin-bottom: 18px;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 34px;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 4px;
  font-size: 19px;
}

.result-count {
  color: var(--muted);
  font-weight: 800;
  white-space: nowrap;
}

.faem-intro {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 28px;
  margin-bottom: 22px;
  overflow: hidden;
  border: 1px solid #e8d9d4;
  border-left: 6px solid var(--brand-red);
  border-radius: 12px;
  padding: 24px 26px;
  background: linear-gradient(135deg, #fff8f5 0%, #fffdf2 58%, #f7fbf4 100%);
}

.faem-intro::after {
  position: absolute;
  top: -70px;
  right: -50px;
  width: 190px;
  height: 190px;
  border: 24px solid rgba(242, 155, 32, 0.09);
  border-radius: 50%;
  content: "";
  pointer-events: none;
}

.faem-intro > * {
  position: relative;
  z-index: 1;
}

.faem-intro .eyebrow {
  display: block;
  margin-bottom: 7px;
  color: var(--brand-red);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.faem-intro h2 {
  margin-bottom: 10px;
  font-size: 23px;
}

.faem-intro p {
  max-width: 900px;
  margin-bottom: 7px;
  color: #4f5358;
  line-height: 1.58;
}

.faem-intro p:last-child {
  margin-bottom: 0;
}

.faem-info-link {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 44px;
  border-radius: 8px;
  padding: 0 15px;
  background: var(--brand-red);
  color: #ffffff;
  font-weight: 800;
  text-decoration: none;
  white-space: nowrap;
}

.faem-info-link:hover {
  background: #b92e19;
}

.panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 20px;
  background: var(--paper);
  box-shadow: var(--shadow);
}

.panel.wide {
  min-width: 0;
}

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.admin-section .panel-header {
  display: none;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(320px, 420px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.stacked-form {
  display: grid;
  gap: 14px;
}

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

.form-grid .wide {
  grid-column: 1 / -1;
}

#resourceForm {
  gap: 18px;
}

.form-step {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #ffffff;
}

.form-step-header {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 15px 18px;
  background: linear-gradient(90deg, #fff7f4 0%, #fffdfa 100%);
  border-bottom: 1px solid #eee2de;
}

.form-step-header h3,
.form-step-header p {
  margin: 0;
}

.form-step-header h3 {
  font-size: 17px;
}

.form-step-header p {
  margin-top: 2px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.step-number {
  display: grid;
  flex: 0 0 34px;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 50%;
  background: var(--brand-red);
  color: #ffffff;
  font-weight: 900;
}

.form-step-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  padding: 18px;
}

.form-step-fields.three-columns {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.form-step-modules .module-fields {
  padding: 18px;
}

.assignment-actions {
  display: flex;
  justify-content: flex-end;
  padding-top: 2px;
}

.assignment-actions .primary {
  min-width: 210px;
}

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

.module-fields label {
  display: grid;
  gap: 7px;
}

.module-summary {
  display: grid;
  gap: 5px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.module-summary strong {
  color: var(--ink);
}

.filter-row {
  display: grid;
  grid-template-columns: minmax(240px, 360px);
  gap: 14px;
  margin-bottom: 18px;
}

.admin-filter-row {
  grid-template-columns: repeat(4, minmax(180px, 1fr));
}

#publicView .filter-row {
  grid-template-columns: minmax(280px, 620px);
  align-items: end;
  margin-bottom: 22px;
  border-left: 6px solid var(--brand-red);
  border-radius: 8px;
  padding: 16px 18px;
  background: #f8fafc;
}

#publicView .filter-row label {
  gap: 9px;
  color: var(--brand-red);
  font-size: 16px;
}

#publicCategoryFilter {
  min-height: 54px;
  border: 2px solid var(--brand-red);
  padding: 12px 44px 12px 14px;
  font-size: 17px;
  font-weight: 800;
  background-color: #ffffff;
  box-shadow: 0 10px 22px rgba(115, 19, 5, 0.1);
}

#publicCategoryFilter:focus {
  outline-color: rgba(115, 19, 5, 0.22);
}

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

.field-name {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.required-field .field-name::after {
  content: "*";
  color: var(--red);
  font-weight: 900;
}

fieldset {
  min-width: 0;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

legend {
  padding: 0 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.checkbox-option {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 8px;
  background: #ffffff;
  color: var(--ink);
}

.checkbox-option input {
  width: 16px;
  min-height: 16px;
}

input,
select,
textarea {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--ink);
  background: #ffffff;
}

input[readonly] {
  background: var(--soft);
  color: var(--muted);
}

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

input:focus,
select:focus,
textarea:focus,
button:focus-visible {
  outline: 3px solid rgba(36, 84, 198, 0.22);
  outline-offset: 2px;
}

.form-actions,
.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 16px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.help-panel {
  max-width: 980px;
}

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

.help-content section {
  border-left: 4px solid var(--brand-red);
  padding-left: 14px;
}

.help-content h3 {
  margin: 0 0 8px;
  font-size: 16px;
}

.help-content p,
.help-content ol {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.help-content ol {
  padding-left: 20px;
}

.primary,
.secondary,
.small {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 14px;
  font-weight: 800;
}

.primary {
  color: #ffffff;
  border-color: var(--blue);
  background: var(--blue);
}

.primary:hover {
  border-color: #b92e19;
  background: #b92e19;
}

.secondary,
.small {
  color: var(--ink);
  background: #ffffff;
}

.secondary.full {
  width: 100%;
}

.small {
  min-height: 34px;
  padding: 0 10px;
  font-size: 13px;
}

.danger {
  color: #ffffff;
  border-color: var(--red);
  background: var(--red);
}

.form-error {
  display: none;
  margin: -4px 0 0;
  padding: 10px 12px;
  border: 1px solid #f3cbd2;
  border-radius: 8px;
  background: #fff0f2;
  color: var(--red);
  font-weight: 800;
}

.form-error.visible {
  display: block;
}

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

table {
  width: 100%;
  min-width: 860px;
  border-collapse: collapse;
  background: #ffffff;
}

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

th {
  color: #ffffff;
  background: var(--brand-red);
  font-size: 13px;
}

tbody tr:nth-child(even) {
  background: var(--soft);
}

tbody tr:last-child td {
  border-bottom: 0;
}

.empty-cell {
  color: var(--muted);
  text-align: center;
}

.site-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 60px;
  padding: 16px 28px;
  background: var(--footer-bg);
  color: var(--footer-text);
  font-size: 14px;
}

.site-footer p {
  margin: 0;
}

.site-footer nav {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  justify-content: flex-end;
}

.site-footer a,
.footer-admin-button {
  border: 0;
  padding: 0;
  color: var(--footer-text);
  background: transparent;
  font-weight: 800;
  text-decoration: none;
}

.site-footer a:hover,
.footer-admin-button:hover {
  color: #ffffff;
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .faem-intro {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .faem-info-link {
    justify-self: start;
    white-space: normal;
  }

  .sidebar {
    gap: 16px;
  }

  .nav-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .side-panel.compact {
    margin-top: 0;
  }

  .content-grid {
    grid-template-columns: 1fr;
  }

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

  .form-step-fields,
  .form-step-fields.three-columns {
    grid-template-columns: 1fr;
  }

  .checkbox-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .site-header,
  .site-footer {
    align-items: flex-start;
    flex-direction: column;
    padding: 14px;
  }

  .site-header {
    gap: 8px;
    min-height: 0;
  }

  .site-brand img {
    width: 180px;
    max-height: 76px;
  }

  .site-title {
    font-size: 20px;
  }

  .workspace,
  .sidebar {
    padding: 14px;
  }

  h1 {
    font-size: 24px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .filter-row,
  .nav-list,
  .pagination {
    grid-template-columns: 1fr;
  }

  .pagination {
    align-items: flex-start;
    flex-direction: column;
  }

  .panel {
    padding: 12px;
  }

  .module-fields {
    grid-template-columns: 1fr;
  }

  .faem-intro {
    margin-bottom: 14px;
    border-left-width: 4px;
    padding: 18px;
  }

  .faem-intro h2 {
    font-size: 20px;
  }

  .table-wrap {
    overflow-x: visible;
    border: 0;
  }

  table {
    min-width: 0;
  }

  thead {
    display: none;
  }

  table,
  tbody,
  tr,
  td {
    display: block;
    width: 100%;
  }

  tr {
    margin-bottom: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow: hidden;
    background: #ffffff;
  }

  tbody tr:nth-child(even) {
    background: #ffffff;
  }

  td {
    display: grid;
    grid-template-columns: 112px minmax(0, 1fr);
    gap: 8px;
    min-height: 42px;
    padding: 10px 11px;
    overflow-wrap: anywhere;
  }

  td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
  }

  .empty-cell {
    display: block;
  }

  .empty-cell::before {
    content: "";
  }

  #publicView {
    padding: 12px;
  }

  #publicView .panel {
    border: 0;
    box-shadow: none;
    padding: 0;
  }

  #publicView .filter-row {
    grid-template-columns: minmax(0, 1fr);
    margin-bottom: 12px;
    padding: 12px;
  }

  #publicView tr {
    box-shadow: 0 8px 22px rgba(26, 37, 52, 0.08);
  }

  #publicView td:first-child {
    color: #ffffff;
    background: var(--brand-red);
    font-weight: 800;
  }

  #publicView td:first-child::before {
    color: rgba(255, 255, 255, 0.78);
  }
}

@media (max-width: 430px) {
  .login-screen {
    padding: 14px;
  }

  .login-card {
    padding: 18px;
  }

  td {
    grid-template-columns: 1fr;
    gap: 4px;
    padding: 10px;
  }

  .site-footer nav {
    flex-direction: column;
    gap: 10px;
  }

  .checkbox-grid {
    grid-template-columns: 1fr;
  }
}
