:root {
  --primary: #2b6cb0;
  --primary-dark: #1a4e87;
  --accent: #f6ad55;
  --text: #1f2933;
  --muted: #52606d;
  --border: #d7e0ea;
  --background: #f5f7fb;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--background);
  color: var(--text);
  line-height: 1.6;
}

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

a:hover {
  color: var(--primary-dark);
}

.navbar {
  background: #fff;
  border-bottom: 1px solid var(--border);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
  position: sticky;
  top: 0;
  z-index: 10;
}

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

.nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 64px;
  padding: 0.4rem 0;
}

.brand-link {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 1.65rem;
  font-weight: 800;
  line-height: 1.1;
  color: var(--primary);
}

.brand-logo {
  width: 32px;
  height: 32px;
  display: block;
}

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

.nav-links a {
  padding: 0.4rem 0.75rem;
  border-radius: 8px;
  color: var(--text);
  background: transparent;
  transition: background 0.15s ease, color 0.15s ease;
}

.nav-links a:hover {
  background: rgba(43, 108, 176, 0.08);
  color: var(--primary-dark);
}

.nav-menu {
  position: relative;
}

.nav-menu summary {
  list-style: none;
  cursor: pointer;
  padding: 0.4rem 0.75rem;
  border-radius: 8px;
  color: var(--text);
  font-weight: 600;
  transition: background 0.15s ease, color 0.15s ease;
}

.nav-menu summary::-webkit-details-marker {
  display: none;
}

.nav-menu summary:hover,
.nav-menu[open] summary {
  background: rgba(43, 108, 176, 0.08);
  color: var(--primary-dark);
}

.nav-menu-links {
  position: absolute;
  right: 0;
  top: calc(100% + 0.5rem);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.5rem;
  min-width: 200px;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  box-shadow: 0 10px 20px rgba(15, 23, 42, 0.12);
  z-index: 20;
}

.nav-menu-links a {
  white-space: nowrap;
}

main {
  padding: 1.5rem 0 2rem;
}

.flash {
  margin: 0;
  padding: 0.9rem 1rem;
  border-radius: 12px;
  font-weight: 600;
  border: 1px solid rgba(43, 108, 176, 0.15);
  background: #edf2ff;
  color: #1a365d;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.12);
  animation: slide-in 200ms ease-out;
  pointer-events: auto;
}

.flash.alert {
  background: #fff5f5;
  color: #742a2a;
  border-color: #feb2b2;
}

.flash-container {
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  z-index: 1000;
  pointer-events: none;
  align-items: flex-end;
}

.flash-content {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.flash-close {
  background: transparent;
  border: none;
  color: inherit;
  font-size: 1.1rem;
  cursor: pointer;
  padding: 0.2rem;
  border-radius: 6px;
  transition: background 0.15s ease;
}

.flash-close:hover {
  background: rgba(0, 0, 0, 0.05);
}

.flash.is-leaving {
  animation: fade-out 160ms ease forwards;
}

@keyframes slide-in {
  from {
    transform: translateY(8px) translateX(6px);
    opacity: 0;
  }
  to {
    transform: translateY(0) translateX(0);
    opacity: 1;
  }
}

@keyframes fade-out {
  from {
    opacity: 1;
    transform: translateY(0);
  }
  to {
    opacity: 0;
    transform: translateY(6px);
  }
}

.card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.5rem;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.05);
}

h1, h2, h3 {
  margin-top: 0;
  color: #111827;
}

h1 {
  font-size: 1.75rem;
  margin-bottom: 0.5rem;
}

h2 {
  font-size: 1.2rem;
  margin-top: 1.5rem;
}

p {
  margin: 0 0 0.75rem;
}

.table-wrapper {
  overflow-x: auto;
  margin-top: 1rem;
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: #fff;
  margin-top: 0.5rem;
  border: 1px solid var(--border);
  border-radius: 12px;
}

th, td {
  text-align: left;
  padding: 0.75rem 0.9rem;
}

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

th {
  background: #f0f4f8;
  color: #27303a;
  font-weight: 700;
}

thead th {
  position: sticky;
  top: 64px;
  z-index: 9;
  box-shadow: 0 1px 0 var(--border);
}

table thead th:first-child {
  border-top-left-radius: 12px;
}

table thead th:last-child {
  border-top-right-radius: 12px;
}

table tbody tr:last-child td:first-child {
  border-bottom-left-radius: 12px;
}

table tbody tr:last-child td:last-child {
  border-bottom-right-radius: 12px;
}

tr:nth-child(even) td {
  background: #f8fbff;
}

tr:hover td {
  background: #f1f5f9;
}

.actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin: 1rem 0;
  align-items: center;
}

.actions form {
  margin: 0;
  display: flex;
  align-items: center;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.page-header .actions {
  margin: 0;
}

.table-export-actions {
  margin-top: 0.5rem;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.55rem 0.85rem;
  border-radius: 10px;
  border: 1px solid transparent;
  background: var(--primary);
  color: #fff;
  font-weight: 700;
  transition: transform 0.1s ease, box-shadow 0.2s ease, background 0.15s ease;
}

.button:hover {
  background: var(--primary-dark);
  color: #fff;
  transform: translateY(-1px);
  box-shadow: 0 8px 16px rgba(43, 108, 176, 0.2);
}

.button.secondary {
  background: #fff;
  color: var(--text);
  border-color: var(--border);
  box-shadow: none;
}

.button.secondary:hover {
  background: #eef2f7;
  color: var(--primary-dark);
}

.button.ghost {
  background: transparent;
  color: var(--primary);
  border-color: var(--border);
}

.button.ghost:hover {
  background: rgba(43, 108, 176, 0.08);
  color: var(--primary-dark);
}

.button.danger {
  background: #e53e3e;
  border-color: #e53e3e;
  color: #fff;
  box-shadow: 0 8px 16px rgba(229, 62, 62, 0.2);
}

.button.danger:hover {
  background: #c53030;
  border-color: #c53030;
  color: #fff;
}

form {
  display: grid;
  gap: 1rem;
  margin: 1rem 0;
}

.form-inline {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 0;
}

form .field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
  align-items: start;
}

form .field.checkbox-field {
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
}

label {
  font-weight: 700;
  color: #27303a;
}

input[type="text"],
input[type="number"],
select {
  padding: 0.6rem 0.75rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  font-size: 1rem;
}

.input-with-suffix {
  position: relative;
  display: flex;
  align-items: center;
}

.input-with-suffix input {
  width: 100%;
  padding-right: 2.25rem;
}

.input-suffix {
  position: absolute;
  right: 0.75rem;
  color: var(--muted);
  font-weight: 700;
  pointer-events: none;
}

input[type="checkbox"] {
  width: 1rem;
  height: 1rem;
}

.helper-text {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.errors {
  border: 1px solid #f6ad55;
  background: #fff7ed;
  color: #8a4b0f;
  padding: 1rem;
  border-radius: 10px;
}

.is-hidden {
  display: none !important;
}

.flash.notice {
  background: #ecfdf3;
  border-color: #a7f3d0;
  color: #065f46;
}

.flash.warning {
  background: #fffbea;
  border-color: #f6e05e;
  color: #744210;
}

.auth-links {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 1rem;
}

.pagy {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin: 1.25rem 0 0;
}

.pagy a,
.pagy span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.25rem;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  font-weight: 600;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.pagy a:hover {
  background: rgba(43, 108, 176, 0.1);
  border-color: rgba(43, 108, 176, 0.4);
  color: var(--primary-dark);
}

.pagy a[aria-current="page"],
.pagy span[aria-current="page"],
.pagy .page.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  box-shadow: 0 10px 20px rgba(43, 108, 176, 0.25);
  transform: translateY(-1px);
  outline: 3px solid rgba(43, 108, 176, 0.2);
  outline-offset: 1px;
}

.pagy a[aria-disabled="true"],
.pagy span[aria-disabled="true"],
.pagy .page.disabled {
  color: var(--muted);
  background: #f3f4f6;
  border-color: #e5e7eb;
  cursor: not-allowed;
}

.pagy .gap {
  border-color: transparent;
  background: transparent;
  color: var(--muted);
}

@media (max-width: 720px) {
  .nav-inner {
    flex-direction: column;
    align-items: flex-start;
    min-height: unset;
    padding: 0.9rem 0;
  }

  .nav-links {
    width: 100%;
  }

  .nav-menu {
    width: 100%;
  }

  .nav-menu-links {
    position: static;
    width: 100%;
    box-shadow: none;
  }
}
