:root {
  --bg: #f5f1ea;
  --bg-soft: #fcfaf7;
  --panel: rgba(255, 252, 248, 0.92);
  --panel-strong: #fffdfa;
  --text: #183047;
  --muted: #64748b;
  --line: rgba(24, 48, 71, 0.12);
  --brand: #16324f;
  --brand-soft: #2d6278;
  --accent: #c88b4a;
  --accent-soft: #f3ddc1;
  --danger: #b94b4b;
  --danger-dark: #9f3838;
  --shadow-soft: 0 18px 45px rgba(22, 50, 79, 0.12);
  --shadow-strong: 0 24px 60px rgba(22, 50, 79, 0.18);
}

html {
  box-sizing: border-box;
  scroll-behavior: smooth;
}

*,
*::before,
*::after {
  box-sizing: inherit;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top right, rgba(200, 139, 74, 0.16), transparent 28%),
    radial-gradient(circle at top left, rgba(45, 98, 120, 0.16), transparent 26%),
    linear-gradient(180deg, #f8f4ed 0%, #f3efe7 48%, #f7f3ec 100%);
  color: var(--text);
  font-family: "Assistant", sans-serif;
  font-size: 1rem;
  line-height: 1.55;
}

a {
  color: inherit;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  padding: 1rem 1.2rem 0;
  backdrop-filter: blur(14px);
}

.site-nav {
  max-width: 1240px;
  margin: 0 auto;
  padding: 0.9rem 1.2rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 1.4rem;
  background: linear-gradient(135deg, rgba(16, 36, 56, 0.92), rgba(35, 76, 96, 0.88));
  color: #fffaf4;
  box-shadow: 0 22px 50px rgba(17, 37, 57, 0.22);
}

ul {
  margin: 0;
  list-style: none;
  padding: 0;
}

.nav-links {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  flex: 1;
  flex-wrap: wrap;
}

.nav-links li,
.logout button {
  transition: transform 160ms ease, background-color 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.nav-links li {
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
}

.nav-links li:hover,
.logout button:hover {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, 0.16);
  box-shadow: 0 14px 24px rgba(9, 20, 33, 0.2);
}

.nav-links a,
.logout button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.72rem 1rem;
  font-weight: 700;
  text-decoration: none;
  color: inherit;
  font-family: inherit;
  font-size: 0.98rem;
}

.logout {
  display: flex;
  justify-content: flex-start;
}

#logout-form {
  margin: 0;
}

.logout button {
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  cursor: pointer;
}

.app-name {
  margin: 0;
  font-family: "Rubik", sans-serif;
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  white-space: nowrap;
}

.site-main {
  max-width: 1240px;
  margin: 0 auto;
  padding: 2.25rem 1.2rem 4rem;
}

.eyebrow {
  margin: 0 0 0.5rem;
  color: var(--brand-soft);
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.78rem;
  text-align: right;
}

h1,
h2,
h3 {
  font-family: "Rubik", sans-serif;
  letter-spacing: -0.03em;
  line-height: 1.15;
  margin-top: 0;
}

h1 {
  font-size: clamp(2.1rem, 4vw, 3.4rem);
  margin-bottom: 0.35rem;
}

h2 {
  font-size: clamp(1.4rem, 2vw, 1.9rem);
}

p {
  margin-top: 0;
}

.page-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.75rem;
}

.page-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.9rem;
  flex-wrap: wrap;
}

.sort-toggle-panel {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.45rem;
  text-align: right;
}

.sort-toggle-label {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 700;
  width: 100%;
  text-align: right;
}

.sort-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.2rem;
  padding: 0.2rem;
  border: 1px solid rgba(24, 48, 71, 0.12);
  border-radius: 999px;
  background: rgba(19, 50, 77, 0.05);
  box-shadow: inset 0 1px 2px rgba(19, 50, 77, 0.06);
  direction: rtl;
  align-self: flex-end;
}

.sort-toggle-option {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 4.6rem;
  min-height: 2rem;
  padding: 0.2rem 0.8rem;
  border-radius: 999px;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 800;
  transition: background-color 160ms ease, color 160ms ease, box-shadow 160ms ease,
    transform 160ms ease;
}

.sort-toggle-option:hover {
  color: var(--brand-soft);
  transform: translateY(-1px);
}

.sort-toggle-option.is-active {
  background: linear-gradient(135deg, var(--brand), var(--brand-soft));
  color: #fffdf9;
  box-shadow: 0 8px 16px rgba(22, 50, 79, 0.18);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 3rem;
  padding: 0.75rem 1.25rem;
  border: 1px solid transparent;
  border-radius: 1rem;
  background: linear-gradient(135deg, var(--brand), var(--brand-soft));
  color: #fffdf9;
  text-decoration: none;
  font-family: inherit;
  font-weight: 800;
  font-size: 1rem;
  cursor: pointer;
  box-shadow: 0 16px 28px rgba(22, 50, 79, 0.18);
  transition: transform 180ms ease, box-shadow 180ms ease, filter 180ms ease;
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 22px 34px rgba(22, 50, 79, 0.22);
  filter: saturate(1.05);
}

.btn:active {
  transform: translateY(0);
}

.secondary {
  background: linear-gradient(135deg, #7d8f9b, #93a3ad);
}

.danger {
  background: linear-gradient(135deg, var(--danger), var(--danger-dark));
}

.warn {
  background: linear-gradient(135deg, #c88b4a, #dda96f);
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid rgba(24, 48, 71, 0.16);
  border-radius: 1rem;
  background: rgba(255, 255, 255, 0.88);
  color: var(--text);
  font: inherit;
  padding: 0.9rem 1rem;
  transition: border-color 160ms ease, box-shadow 160ms ease, background-color 160ms ease;
}

input,
select {
  min-height: 3rem;
}

textarea {
  min-height: 8rem;
  resize: vertical;
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: rgba(45, 98, 120, 0.45);
  box-shadow: 0 0 0 4px rgba(45, 98, 120, 0.12);
  background: #fff;
}

label {
  display: block;
  margin-bottom: 0.4rem;
  color: var(--muted);
  font-weight: 700;
}

form p {
  position: relative;
  margin-bottom: 1rem;
}

.errorlist {
  margin: 0.55rem 0 0;
  padding: 0.7rem 0.9rem;
  list-style: none;
  border-radius: 0.9rem;
  background: rgba(185, 75, 75, 0.12);
  color: #8d2222;
  font-size: 0.95rem;
  font-weight: 800;
  line-height: 1.5;
}

.errorlist li + li {
  margin-top: 0.25rem;
}

form p:has(.errorlist) label {
  color: #8d2222;
}

form p:has(.errorlist) input,
form p:has(.errorlist) textarea,
form p:has(.errorlist) select {
  border-color: rgba(185, 75, 75, 0.45);
  box-shadow: 0 0 0 4px rgba(185, 75, 75, 0.1);
  background: #fff8f8;
}

input[aria-invalid="true"],
textarea[aria-invalid="true"],
select[aria-invalid="true"] {
  border-color: rgba(185, 75, 75, 0.45);
  box-shadow: 0 0 0 4px rgba(185, 75, 75, 0.1);
  background: #fff8f8;
}

.field-validation-tooltip {
  position: absolute;
  inset-inline-end: 0;
  top: calc(100% + 0.45rem);
  z-index: 90;
  max-width: min(22rem, 92vw);
  padding: 0.7rem 0.9rem;
  border-radius: 0.9rem;
  background: #8d2222;
  color: #fff8f8;
  font-size: 0.92rem;
  font-weight: 800;
  line-height: 1.45;
  box-shadow: 0 18px 28px rgba(141, 34, 34, 0.18);
}

.field-validation-tooltip::before {
  content: "";
  position: absolute;
  inset-inline-end: 1rem;
  bottom: 100%;
  border-width: 0 0.45rem 0.5rem 0.45rem;
  border-style: solid;
  border-color: transparent transparent #8d2222 transparent;
}

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

th,
td {
  text-align: right;
}

::selection {
  background: rgba(200, 139, 74, 0.24);
}

@media (max-width: 1024px) {
  .site-nav {
    flex-wrap: wrap;
    justify-content: center;
  }

  .app-name,
  .logout,
  .nav-links {
    flex: unset;
    width: 100%;
    justify-content: center;
    text-align: center;
  }
}

@media (max-width: 720px) {
  .site-main {
    padding: 1.6rem 0.9rem 3rem;
  }

  .site-header {
    padding: 0.75rem 0.75rem 0;
  }

  .site-nav {
    padding: 1rem;
    border-radius: 1.15rem;
  }

  .page-header {
    flex-direction: column;
    align-items: stretch;
  }

  .page-actions,
  .sort-toggle-panel,
  .sort-toggle {
    justify-content: stretch;
    align-items: stretch;
  }

  .sort-toggle {
    display: flex;
  }

  .sort-toggle-option {
    flex: 1 1 0;
    min-width: 0;
  }
}
