:root {
  --royal-blue: #0b2a55;
  --royal-deep: #081d3b;
  --gold: #c6a74a;
  --gold-soft: #e9d7a0;
  --white: #ffffff;
  --ink: #0f172a;
  --slate: #475569;
  --danger: #8c1c13;
  --success: #1f6f3f;
  --line: #d7c89b;
  --panel: #f6f2e8;
  --serif: "Cinzel", "Cormorant Garamond", serif;
  --sans: "IBM Plex Sans", sans-serif;
  --max-width: 1200px;
  --radius: 16px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background: radial-gradient(circle at 12% -10%, #e8d9ac 0%, transparent 32%),
    radial-gradient(circle at 88% 0%, #dbc689 0%, transparent 20%),
    linear-gradient(180deg, #f8f5ee 0%, #f3eee3 100%);
  font-family: var(--sans);
  overflow-x: hidden;
}

.page {
  width: min(100%, var(--max-width));
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 28px 20px 56px;
}

.site-header {
  width: 100%;
  max-width: 100%;
  padding: 0;
  border: 1px solid rgba(198, 167, 74, 0.5);
  border-radius: var(--radius);
  background: linear-gradient(140deg, rgba(8, 29, 59, 0.97), rgba(11, 42, 85, 0.94));
  box-shadow: 0 18px 35px rgba(8, 29, 59, 0.2);
}

.header-inner {
  width: 100%;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 20px;
  min-height: 92px;
  padding: 12px 18px;
}

.login-header {
  grid-template-columns: 1fr;
}

.logo-link {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--white);
  text-decoration: none;
}

.site-logo {
  width: min(110px, 30vw);
  height: auto;
  filter: drop-shadow(0 6px 14px rgba(0, 0, 0, 0.35));
}

.brand-name {
  font-family: var(--serif);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-size: 14px;
  color: #efe3bf;
}

.main-nav {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: center;
}

.menu-item {
  position: relative;
}

.menu-link {
  border: 0;
  background: transparent;
  color: #f4eccc;
  text-decoration: none;
  padding: 8px 6px;
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  font-family: var(--sans);
  display: inline-flex;
  align-items: center;
  border-bottom: 2px solid transparent;
}

.menu-toggle {
  display: none;
  border: 1px solid rgba(233, 215, 160, 0.65);
  color: #f3e8c4;
  background: transparent;
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.menu-link.active,
.menu-item.active > .menu-link {
  color: var(--gold-soft);
  border-bottom-color: var(--gold);
}

.has-dropdown.open > .dropdown-menu {
  display: grid;
}

.dropdown-menu {
  display: none;
  position: absolute;
  top: calc(100% + 10px);
  left: 0;
  min-width: 210px;
  background: #fffdf8;
  border: 1px solid rgba(198, 167, 74, 0.55);
  border-radius: 12px;
  box-shadow: 0 12px 24px rgba(8, 29, 59, 0.2);
  padding: 8px;
  z-index: 30;
  gap: 2px;
}

.dropdown-menu a,
.dropdown-menu button {
  background: transparent;
  border: 0;
  color: var(--royal-blue);
  text-align: left;
  text-decoration: none;
  padding: 9px 10px;
  border-radius: 8px;
  font-size: 13px;
  letter-spacing: 0.02em;
  text-transform: none;
  font-family: var(--sans);
  cursor: pointer;
}

.dropdown-menu a:hover,
.dropdown-menu button:hover {
  background: rgba(198, 167, 74, 0.18);
}

.profile-menu {
  position: relative;
}

.profile-trigger {
  border: 1px solid rgba(233, 215, 160, 0.6);
  color: #f3e8c4;
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: transparent;
}

.profile-dropdown {
  left: auto;
  right: 0;
  min-width: 180px;
}

.profile-dropdown form {
  margin: 0;
}

.inline-action {
  margin: 0;
}

.inline-action button {
  padding: 6px 10px;
  font-size: 11px;
}

.button,
button:not(.menu-link):not(.profile-trigger),
input[type="submit"] {
  border: 1px solid var(--royal-blue);
  background: var(--royal-blue);
  color: var(--white);
  text-decoration: none;
  padding: 10px 14px;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  font-family: var(--sans);
  border-radius: 10px;
  transition: transform 120ms ease, background 120ms ease, border-color 120ms ease;
}

.button:hover,
button:not(.menu-link):not(.profile-trigger):hover,
input[type="submit"]:hover {
  transform: translateY(-1px);
  background: #0e3768;
}

.content {
  margin-top: 18px;
  display: grid;
  gap: 16px;
  min-width: 0;
}

.content > * {
  min-width: 0;
  max-width: 100%;
}

h1,
h2,
h3 {
  font-family: var(--serif);
  color: var(--royal-blue);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-top: 0;
}

h1 {
  font-size: clamp(28px, 4.6vw, 44px);
}

h2 {
  font-size: 22px;
  margin-bottom: 14px;
}

h3 {
  font-size: 17px;
  margin-bottom: 8px;
}

.panel {
  max-width: 100%;
  min-width: 0;
  border: 1px solid rgba(198, 167, 74, 0.5);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.95);
  padding: 18px;
  box-shadow: 0 16px 32px rgba(11, 42, 85, 0.1);
}

.kpi-grid,
.quick-grid,
.events-grid,
.doc-grid,
.form-grid,
.members-grid,
.admin-grid {
  display: grid;
  gap: 14px;
}

.kpi-grid,
.quick-grid,
.events-grid,
.doc-grid,
.form-grid,
.admin-grid {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.kpi {
  border: 1px solid rgba(198, 167, 74, 0.4);
  border-radius: 12px;
  padding: 14px;
  background: linear-gradient(160deg, rgba(11, 42, 85, 0.03), rgba(198, 167, 74, 0.08));
}

.kpi .label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--slate);
}

.kpi .value {
  margin-top: 8px;
  font-family: var(--serif);
  font-size: 30px;
  color: var(--royal-blue);
}

.table-wrap {
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

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

th,
td {
  text-align: left;
  border-bottom: 1px solid #ecdfbd;
  padding: 10px 8px;
  vertical-align: top;
}

th {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--slate);
}

label {
  display: block;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 6px;
  color: var(--slate);
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid #dfd0a5;
  border-radius: 10px;
  padding: 10px;
  font-family: var(--sans);
  font-size: 14px;
  background: #fffefb;
}

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

.flash {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fefcf7;
  color: var(--royal-blue);
  padding: 10px 12px;
}

.flash.error {
  border-color: #d0a29e;
  color: var(--danger);
}

.login-shell {
  min-height: 80vh;
  display: grid;
  align-items: center;
}

.login-card {
  max-width: 560px;
  margin: 0 auto;
  border: 1px solid rgba(198, 167, 74, 0.5);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.96);
  padding: 22px;
  box-shadow: 0 16px 32px rgba(11, 42, 85, 0.15);
}

.login-logo {
  width: min(340px, 72vw);
  display: block;
  margin: 0 auto 14px;
}

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

.help-text {
  color: var(--slate);
  font-size: 13px;
  margin: 8px 0;
}

.history-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.compact-actions button {
  min-width: 0;
}

.reaction-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 1px solid rgba(11, 42, 85, 0.35) !important;
  background: #f7f4eb !important;
  color: var(--royal-blue) !important;
  border-radius: 999px !important;
  padding: 4px 8px !important;
  text-transform: none !important;
  letter-spacing: 0 !important;
  font-size: 12px !important;
  line-height: 1;
}

.reaction-icon {
  font-size: 12px;
  line-height: 1;
}

.reaction-count {
  font-weight: 600;
}

.calendar-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  flex-wrap: wrap;
}

.calendar-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid rgba(11, 42, 85, 0.3);
  color: var(--royal-blue);
  background: #f7f4eb;
  border-radius: 999px;
  padding: 5px 9px;
  font-size: 12px;
  text-decoration: none;
  line-height: 1;
}

.calendar-btn:hover {
  background: #f1ead8;
}

.cal-icon {
  font-size: 12px;
  line-height: 1;
}

.hide-mobile {
  display: table-cell;
}

.badge {
  display: inline-flex;
  border: 1px solid var(--gold);
  color: var(--royal-blue);
  background: rgba(233, 215, 160, 0.28);
  border-radius: 999px;
  font-size: 11px;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  padding: 3px 8px;
}

.members-grid {
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.member-card {
  border: 1px solid rgba(233, 215, 160, 0.65);
  border-radius: 14px;
  background: linear-gradient(155deg, #0b2a55 0%, #0e3768 100%);
  color: var(--white);
  padding: 14px;
  display: grid;
  gap: 10px;
  text-decoration: none;
  box-shadow: 0 14px 24px rgba(8, 29, 59, 0.28);
}

.member-card h3 {
  color: var(--white);
  margin-bottom: 0;
}

.member-photo {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border: 1px solid var(--gold);
  border-radius: 10px;
  background: #092244;
}

.member-meta {
  display: flex;
  justify-content: space-between;
  color: #e7dbb6;
  font-size: 13px;
}

.member-detail {
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(280px, 400px) 1fr;
}

.member-detail img {
  width: 100%;
  border: 1px solid var(--gold);
  border-radius: 12px;
  background: #092244;
}

.admin-card {
  border: 1px solid rgba(198, 167, 74, 0.5);
  border-radius: 12px;
  padding: 14px;
  background: #fff;
}

.admin-card .num {
  font-family: var(--serif);
  color: var(--royal-blue);
  font-size: 30px;
}

.user-admin-list {
  display: grid;
  gap: 10px;
}

.user-admin-item {
  border: 1px solid rgba(198, 167, 74, 0.45);
  border-radius: 12px;
  background: #fffdfa;
  overflow: hidden;
}

.user-admin-summary {
  display: grid;
  grid-template-columns: minmax(140px, 1.2fr) minmax(120px, 1fr) minmax(120px, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  cursor: pointer;
  list-style: none;
}

.user-admin-summary::-webkit-details-marker {
  display: none;
}

.user-admin-main {
  font-weight: 600;
  color: var(--royal-blue);
}

.user-admin-meta {
  color: var(--slate);
  font-size: 13px;
}

.user-admin-body {
  border-top: 1px solid #eee2c2;
  padding: 14px;
  display: grid;
  gap: 12px;
}

.user-admin-form {
  display: grid;
  gap: 12px;
}

.user-admin-actions {
  display: flex;
  gap: 12px;
  align-items: end;
  flex-wrap: wrap;
}

.user-admin-actions > div {
  min-width: 120px;
}

.user-delete-form {
  display: flex;
  justify-content: flex-end;
}

.profile-preview {
  width: 88px;
  height: 88px;
  object-fit: cover;
  border: 1px solid var(--gold);
  border-radius: 10px;
  background: #092244;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border: 1px solid transparent;
}

.status-badge.open {
  color: #1d4d8e;
  border-color: #b8d1ee;
  background: #edf5ff;
}

.status-badge.overdue {
  color: #8c1c13;
  border-color: #e1b2ac;
  background: #fff1ef;
}

.status-badge.ok {
  color: #1f6f3f;
  border-color: #b5dbc3;
  background: #eef9f1;
}

.rule-groups {
  display: grid;
  gap: 12px;
}

.rule-group h3 {
  margin-bottom: 10px;
}

.rule-group table th:nth-child(2),
.rule-group table td:nth-child(2),
.rule-group table th:last-child,
.rule-group table td:last-child {
  text-align: right;
}

.doc-embed {
  width: 100%;
  min-height: 75vh;
  border: 1px solid rgba(198, 167, 74, 0.45);
  border-radius: 10px;
  background: #fff;
}

.guide-wrap {
  display: grid;
  gap: 10px;
}

.guide-frame {
  width: 100%;
  min-height: 85vh;
  border: 1px solid rgba(198, 167, 74, 0.45);
  border-radius: 10px;
  background: #fff;
}

.vedtaegter-sections {
  display: grid;
  gap: 12px;
}

.vedtaegter-section h3 {
  margin-bottom: 8px;
}

@media (max-width: 920px) {
  .page {
    padding: 18px 14px 40px;
  }

  .header-inner {
    grid-template-columns: 1fr;
    gap: 12px;
    padding: 12px;
  }

  .logo-link {
    justify-content: flex-start;
  }

  .site-logo {
    width: min(86px, 28vw);
  }

  .brand-name {
    font-size: 12px;
    letter-spacing: 0.09em;
  }

  .main-nav {
    justify-content: flex-start;
    overflow: visible;
    flex-wrap: wrap;
    gap: 8px;
    padding-bottom: 0;
  }

  .menu-item {
    max-width: 100%;
  }

  .menu-link {
    padding: 8px 10px;
    border: 1px solid rgba(233, 215, 160, 0.5);
    border-radius: 999px;
    font-size: 11px;
  }

  .profile-menu {
    justify-self: stretch;
  }

  .profile-trigger {
    width: 100%;
    text-align: left;
  }

  .dropdown-menu {
    position: static;
    box-shadow: none;
    min-width: 0;
    margin-top: 8px;
  }

  .profile-dropdown {
    width: 100%;
  }

  .member-detail {
    grid-template-columns: 1fr;
  }

  .user-admin-summary {
    grid-template-columns: 1fr;
    gap: 4px;
  }
}

@media (max-width: 640px) {
  .page {
    padding: 12px 10px 28px;
  }

  .header-inner {
    gap: 10px;
    min-height: 0;
  }

  .brand-name {
    display: none;
  }

  .main-nav {
    display: none;
    width: 100%;
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .site-header.mobile-nav-open .main-nav {
    display: grid;
    position: fixed;
    top: 82px;
    left: 10px;
    right: 10px;
    z-index: 1200;
    background: linear-gradient(160deg, rgba(8, 29, 59, 0.98), rgba(11, 42, 85, 0.97));
    border: 1px solid rgba(198, 167, 74, 0.55);
    border-radius: 14px;
    box-shadow: 0 14px 30px rgba(8, 29, 59, 0.28);
    padding: 12px;
    max-height: calc(100vh - 120px);
    overflow-y: auto;
  }

  .menu-toggle {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    width: fit-content;
  }

  .menu-item,
  .menu-link {
    width: 100%;
  }

  .menu-link {
    justify-content: flex-start;
    text-align: left;
    white-space: normal;
    line-height: 1.3;
  }

  .main-nav .has-dropdown .menu-link {
    border-radius: 12px;
  }

  .main-nav .has-dropdown .dropdown-menu {
    display: none;
    position: static;
    margin-top: 6px;
    margin-left: 8px;
    min-width: 0;
    width: calc(100% - 8px);
    box-shadow: none;
  }

  .main-nav .dropdown-menu a,
  .main-nav .dropdown-menu button {
    white-space: normal;
  }

  .main-nav .has-dropdown.open .dropdown-menu {
    display: grid;
  }

  .panel {
    padding: 14px;
  }

  .kpi-grid,
  .events-grid,
  .doc-grid,
  .form-grid,
  .members-grid,
  .admin-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .kpi {
    padding: 12px;
  }

  h1 {
    font-size: clamp(20px, 6.8vw, 28px);
    letter-spacing: 0.04em;
    line-height: 1.18;
    overflow-wrap: anywhere;
    word-break: break-word;
  }

  h2 {
    font-size: 18px;
  }

  .kpi .value {
    font-size: 22px;
  }

  th,
  td {
    padding: 8px 6px;
  }

  input,
  textarea,
  select {
    font-size: 16px;
  }

  .panel form button {
    width: 100%;
  }

  .hide-mobile {
    display: none !important;
  }

  .responsive-table table,
  .responsive-table thead,
  .responsive-table tbody,
  .responsive-table tr,
  .responsive-table td {
    display: block;
    width: 100%;
  }

  .responsive-table thead {
    display: none;
  }

  .responsive-table tr {
    border: 1px solid #ecdfbd;
    border-radius: 10px;
    background: #fffefb;
    padding: 8px 10px;
    margin-bottom: 10px;
  }

  .responsive-table td {
    border: 0;
    padding: 4px 0;
  }

  .responsive-table td::before {
    content: attr(data-label);
    display: block;
    color: var(--slate);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 2px;
  }

  .fines-mobile-table .history-actions {
    gap: 6px;
  }

  .fines-mobile-table .history-actions form {
    margin: 0;
  }

  .fines-mobile-table .history-actions button {
    padding: 4px 7px !important;
    width: auto !important;
    letter-spacing: 0 !important;
    text-transform: none;
    font-size: 12px !important;
  }

  .fines-mobile-table .reaction-text {
    display: none;
  }

  .fines-mobile-table .reaction-btn {
    gap: 4px;
  }

  .calendar-actions {
    gap: 6px;
  }

  .calendar-btn {
    padding: 4px 8px;
  }

  .calendar-btn .cal-text {
    display: inline;
    font-size: 11px;
  }

  .login-card {
    padding: 16px;
  }

  .login-logo {
    width: min(250px, 74vw);
  }

  .profile-preview {
    width: 72px;
    height: 72px;
  }

  .user-admin-actions {
    align-items: stretch;
  }

  .user-admin-actions > div {
    min-width: 0;
    width: 100%;
  }

  .user-delete-form button {
    width: 100%;
  }
}

@media (max-width: 430px) {
  .page {
    padding: 10px 8px 22px;
  }

  .site-logo {
    width: min(74px, 24vw);
  }

  .menu-link {
    font-size: 10px;
    padding: 7px 8px;
  }

  .profile-trigger {
    font-size: 10px;
    padding: 6px 10px;
  }

  .panel {
    padding: 12px;
    border-radius: 12px;
  }

  h2 {
    font-size: 16px;
    margin-bottom: 10px;
  }

  h3 {
    font-size: 15px;
  }

  .kpi .label {
    font-size: 11px;
  }

  .kpi .value {
    font-size: 20px;
  }

  th {
    font-size: 10px;
  }

  td {
    font-size: 13px;
  }

  .member-card {
    padding: 12px;
  }

  .member-meta {
    font-size: 12px;
  }

  .badge,
  .status-badge {
    font-size: 10px;
  }
}
