:root {
  --bg: #f5f5f4;
  --paper: #ffffff;
  --ink: #1f1f1f;
  --accent: #c8102e;
  --accent-2: #8a8f98;
  --danger: #a6102a;
  --warning: #8c5a00;
  --muted: #5a5f66;
  --line: #d9dde2;
  --bg-soft: #eceff2;
  --header-start: #f7f8fa;
  --header-end: #eceff2;
  --field-border: #c8cdd3;
  --surface: #ffffff;
  --btn-text: #ffffff;
  --btn-disabled-bg: #b9bec7;
  --btn-disabled-text: #f5f6f8;
  --flash-success-bg: #e8f5ee;
  --flash-success-text: #1f6b43;
  --flash-error-bg: #fdecee;
  --flash-error-text: #8f1d2f;
  --danger-soft: #f3c9cf;
  --radius: 14px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Avenir Next", "Gill Sans", "Trebuchet MS", sans-serif;
  background: radial-gradient(circle at top right, var(--bg-soft), var(--bg) 55%);
  color: var(--ink);
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 2rem;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(130deg, var(--header-start) 0%, var(--header-end) 100%);
}

.brand-wrap {
  display: flex;
  align-items: center;
  gap: 0.7rem;
}

.brand-logo {
  width: 44px;
  height: 44px;
  object-fit: contain;
  border-radius: 8px;
}

.brand {
  text-decoration: none;
  color: var(--accent);
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.tag {
  font-size: 0.9rem;
  color: var(--muted);
}

nav {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

nav a {
  color: var(--ink);
  text-decoration: none;
  font-weight: 600;
}

.container {
  max-width: 1100px;
  margin: 1.5rem auto;
  padding: 0 1rem 2rem;
}

.auth-wrap {
  max-width: 560px;
}

.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem;
  box-shadow: 0 8px 30px var(--line);
}

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

.grid-4 {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}

.stack-cards {
  display: grid;
  gap: 1rem;
  margin-bottom: 1rem;
}

.stat h2 {
  margin: 0;
  font-size: 2rem;
  color: var(--accent);
}

.stat-link {
  text-decoration: none;
  color: inherit;
  transition: transform 120ms ease, box-shadow 120ms ease;
}

.stat-link:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 24px var(--line);
}

.form-grid {
  display: grid;
  gap: 0.8rem;
}

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

label,
legend {
  font-weight: 700;
  color: var(--muted);
}

input,
select,
textarea,
button {
  width: 100%;
  font: inherit;
  margin-top: 0.35rem;
}

.password-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.password-row input {
  margin-top: 0;
  flex: 1;
}

.password-row .toggle-password {
  width: auto;
  margin-top: 0;
  padding: 0.55rem 0.8rem;
  white-space: nowrap;
}

input,
select,
textarea {
  border: 1px solid var(--field-border);
  border-radius: 10px;
  padding: 0.55rem 0.6rem;
  background: var(--surface);
}

.btn {
  border: 0;
  border-radius: 10px;
  background: var(--accent);
  color: var(--btn-text);
  font-weight: 700;
  padding: 0.6rem 0.8rem;
  cursor: pointer;
}

.btn.ghost {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
}

.btn.warning {
  background: var(--warning);
}

.btn.danger {
  background: var(--danger);
}

.btn:disabled {
  background: var(--btn-disabled-bg);
  color: var(--btn-disabled-text);
  cursor: not-allowed;
}

.inline-form {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.inline-form.wrap {
  flex-wrap: wrap;
}

.page-head-row {
  justify-content: space-between;
  margin-bottom: 0.9rem;
}

.item-list {
  list-style: none;
  padding: 0;
  margin: 0.8rem 0 0;
  display: grid;
  gap: 0.4rem;
}

.item-list li {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.35rem 0.5rem;
  background: var(--surface);
}

.item-list.mentors li {
  align-items: flex-start;
}

.list-box {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.45rem;
  margin: 0.8rem 0;
  min-height: 60px;
  overflow: auto;
  resize: both;
  background: var(--surface);
}

.edit-list {
  margin: 0;
}

.edit-list li {
  align-items: center;
}

.item-check {
  min-width: 24px;
}

.item-edit-form {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: 1;
  flex-wrap: nowrap;
}

.item-edit-form input {
  flex: 1;
  min-width: 0;
  margin-top: 0;
}

.item-edit-form .save-on-edit {
  width: auto;
  min-width: 82px;
  margin-top: 0;
}

.choices {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.4rem;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.check-row input {
  width: auto;
  margin-top: 0;
}

.flash {
  margin: 0.7rem 0;
  border-radius: 10px;
  padding: 0.7rem;
  font-weight: 700;
}

.flash.success {
  background: var(--flash-success-bg);
  color: var(--flash-success-text);
}

.flash.error {
  background: var(--flash-error-bg);
  color: var(--flash-error-text);
}

table {
  width: 100%;
  border-collapse: collapse;
}

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

.sort-head {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.sort-arrows {
  display: inline-flex;
  gap: 0.2rem;
}

.sort-arrow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.1rem;
  text-decoration: none;
  color: var(--muted);
  border-radius: 4px;
  font-weight: 700;
}

.sort-arrow.active {
  color: var(--accent);
  background: var(--paper);
}

.row-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem;
  margin: 0.9rem 0;
}

.hint {
  color: var(--muted);
}

.line-item {
  display: grid;
  gap: 0.8rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.7rem;
  margin-bottom: 0.7rem;
  background: var(--surface);
}

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

.theme-logo-preview {
  margin: 0.5rem 0 0.9rem;
}

.theme-logo-preview img {
  display: block;
  max-width: 220px;
  max-height: 88px;
  width: auto;
  height: auto;
  object-fit: contain;
}

.danger-zone {
  border-color: var(--danger-soft);
}

@media (max-width: 850px) {
  .grid-2,
  .grid-4 {
    grid-template-columns: 1fr;
  }

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

  .site-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.65rem;
  }
}
