:root {
  --bg: #f6f7f4;
  --surface: #ffffff;
  --surface-muted: #eef2ed;
  --ink: #17201d;
  --muted: #63706b;
  --line: #d8dfda;
  --green: #256f4b;
  --green-dark: #174e35;
  --red: #a43d32;
  --amber: #b66b19;
  --blue: #315f89;
  --shadow: 0 18px 45px rgba(23, 32, 29, 0.11);
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
}

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

button {
  border: 0;
}

.loading-screen,
.auth-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.loader-card,
.auth-card {
  width: min(100%, 520px);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 28px;
}

.brand-mark {
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--green);
  color: #ffffff;
  font-weight: 800;
  letter-spacing: 0;
}

.auth-card h1,
.loader-card h1 {
  margin: 18px 0 8px;
  font-size: clamp(1.7rem, 3vw, 2.4rem);
  line-height: 1.08;
  letter-spacing: 0;
}

.auth-card p,
.loader-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.field {
  display: grid;
  gap: 7px;
}

.field span {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 650;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  color: var(--ink);
  padding: 10px 12px;
  outline: none;
}

.field textarea {
  min-height: 92px;
  resize: vertical;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(37, 111, 75, 0.14);
}

.form-grid {
  display: grid;
  gap: 14px;
  margin-top: 24px;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 38px;
  border-radius: 6px;
  padding: 9px 13px;
  background: var(--surface-muted);
  color: var(--ink);
  font-weight: 750;
  cursor: pointer;
  transition: transform 120ms ease, background 120ms ease, color 120ms ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.6;
  transform: none;
}

.btn.primary {
  background: var(--green);
  color: #ffffff;
}

.btn.primary:hover {
  background: var(--green-dark);
}

.btn.danger {
  background: #f8e8e4;
  color: var(--red);
}

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

.btn.small {
  min-height: 32px;
  padding: 7px 10px;
  font-size: 0.86rem;
}

.segmented {
  display: inline-grid;
  grid-template-columns: repeat(2, 1fr);
  background: var(--surface-muted);
  border-radius: 7px;
  padding: 4px;
}

.segmented button {
  min-height: 34px;
  border-radius: 5px;
  background: transparent;
  color: var(--muted);
  font-weight: 750;
  cursor: pointer;
}

.segmented button.active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 1px 6px rgba(23, 32, 29, 0.12);
}

.notice {
  display: none;
  margin-top: 14px;
  border-radius: 6px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  color: var(--ink);
  background: #fff8e9;
  line-height: 1.4;
}

.notice.show {
  display: block;
}

.notice.error {
  border-color: #ecc4bc;
  background: #fff0ed;
  color: #7f2c24;
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(246, 247, 244, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
}

.topbar-inner {
  width: min(100%, 1460px);
  margin: 0 auto;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 18px;
  align-items: center;
  padding: 14px 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand strong {
  display: block;
  font-size: 1rem;
}

.brand span {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
  white-space: nowrap;
}

.tabs {
  display: flex;
  gap: 6px;
  justify-content: center;
  overflow-x: auto;
  min-width: 0;
}

.tabs button {
  min-height: 36px;
  border-radius: 6px;
  padding: 8px 12px;
  white-space: nowrap;
  background: transparent;
  color: var(--muted);
  font-weight: 750;
  cursor: pointer;
}

.tabs button.active {
  background: #ffffff;
  color: var(--green-dark);
  box-shadow: 0 1px 8px rgba(23, 32, 29, 0.1);
}

.user-tools {
  display: flex;
  gap: 10px;
  align-items: center;
}

.user-pill {
  min-width: 0;
  max-width: 220px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #ffffff;
  padding: 7px 10px;
  color: var(--muted);
  font-size: 0.84rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.page {
  width: min(100%, 1460px);
  margin: 0 auto;
  padding: 22px 18px 44px;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 20px;
  align-items: end;
  border-bottom: 1px solid var(--line);
  padding: 10px 0 18px;
  margin-bottom: 18px;
}

.hero h1 {
  margin: 0 0 8px;
  font-size: clamp(1.8rem, 3vw, 3rem);
  line-height: 1.04;
  letter-spacing: 0;
}

.hero p {
  max-width: 760px;
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 12px;
  margin: 18px 0;
}

.kpi {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

.kpi span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.kpi strong {
  display: block;
  margin-top: 6px;
  font-size: 1.75rem;
  line-height: 1;
}

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

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

.panel h2 {
  margin: 0 0 12px;
  font-size: 1rem;
  letter-spacing: 0;
}

.panel-title-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
}

.panel-title-row h2 {
  margin: 0;
}

.filters {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) repeat(3, auto);
  gap: 10px;
  align-items: center;
  margin-bottom: 14px;
}

.meeting-list {
  display: grid;
  gap: 14px;
}

.meeting {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.meeting-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  padding: 15px;
  background: #fbfcfa;
  border-bottom: 1px solid var(--line);
}

.meeting-date {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: baseline;
}

.meeting-date strong {
  font-size: 1.1rem;
}

.meeting-date span,
.meeting-meta {
  color: var(--muted);
  font-size: 0.88rem;
}

.role-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(180px, 1fr));
  gap: 1px;
  background: var(--line);
}

.role-card {
  min-height: 218px;
  background: #ffffff;
  padding: 13px;
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  gap: 9px;
}

.role-card.has-mine {
  box-shadow: inset 0 0 0 2px rgba(37, 111, 75, 0.28);
}

.role-title {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 10px;
}

.role-title strong {
  line-height: 1.2;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 3px 8px;
  background: var(--surface-muted);
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 750;
  white-space: nowrap;
}

.badge.open {
  background: #e4f3ea;
  color: var(--green-dark);
}

.badge.wait {
  background: #fff0d9;
  color: var(--amber);
}

.people {
  display: grid;
  gap: 6px;
  align-content: start;
}

.person,
.empty-slot {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 7px;
  font-size: 0.86rem;
}

.person.mine {
  border-color: rgba(37, 111, 75, 0.42);
  background: #f0f8f3;
}

.person strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.person span,
.empty-slot {
  color: var(--muted);
}

.more-open {
  min-height: 30px;
  display: flex;
  align-items: center;
  color: var(--green-dark);
  font-size: 0.82rem;
  font-weight: 800;
}

.waitlist {
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.35;
}

.role-action {
  display: grid;
  gap: 8px;
}

.assign-role {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 7px;
  margin-top: 8px;
}

.assign-role select {
  width: 100%;
  min-width: 0;
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  color: var(--ink);
  padding: 6px 8px;
  font-size: 0.84rem;
}

.side-stack {
  display: grid;
  gap: 14px;
  position: sticky;
  top: 86px;
}

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

.quick-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 9px;
  color: var(--muted);
  font-size: 0.9rem;
}

.quick-row:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.profile-grid,
.meeting-admin-grid,
.bulk-import-grid,
.member-create-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.full {
  grid-column: 1 / -1;
}

.member-table {
  display: grid;
  gap: 10px;
}

.member-row {
  display: grid;
  grid-template-columns: minmax(210px, 1.35fr) 112px 116px minmax(150px, 0.9fr) minmax(150px, 1fr) minmax(150px, 1fr) minmax(150px, 1fr) auto;
  gap: 10px;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.member-main {
  min-width: 0;
}

.member-main strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.member-main span {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.member-main em {
  display: block;
  margin-top: 3px;
  color: var(--green-dark);
  font-size: 0.78rem;
  font-style: normal;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.member-actions {
  display: grid;
  gap: 7px;
}

.create-toggle {
  align-self: end;
  min-height: 42px;
}

.access-panel {
  margin-bottom: 16px;
  border-color: rgba(37, 111, 75, 0.28);
  background: #f7fbf8;
}

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

.access-grid span {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.access-grid strong,
.access-grid code {
  display: block;
  margin-top: 4px;
  overflow-wrap: anywhere;
}

.access-grid code {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  padding: 10px 12px;
  color: var(--green-dark);
  font-size: 1rem;
  font-weight: 800;
}

.bulk-summary {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.bulk-summary span {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #ffffff;
  padding: 5px 9px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.bulk-access-table,
.skipped-list {
  display: grid;
  gap: 8px;
}

.bulk-access-table {
  margin-top: 10px;
}

.bulk-access-table div,
.skipped-list div {
  display: grid;
  grid-template-columns: minmax(140px, 0.8fr) minmax(160px, 1fr) minmax(180px, 0.9fr);
  gap: 8px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  padding: 8px;
}

.bulk-access-table span,
.skipped-list {
  color: var(--muted);
  font-size: 0.86rem;
}

.bulk-access-table code {
  color: var(--green-dark);
  font-weight: 800;
  overflow-wrap: anywhere;
}

.skipped-list {
  margin-top: 12px;
}

.skipped-list div {
  grid-template-columns: 1fr;
  background: #fff8e9;
}

.toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 700;
}

.toggle input {
  width: 18px;
  height: 18px;
  accent-color: var(--green);
}

.empty-state {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 22px;
  color: var(--muted);
  background: #ffffff;
}

.hidden {
  display: none !important;
}

@media (max-width: 1120px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .side-stack {
    position: static;
  }

  .role-grid {
    grid-template-columns: repeat(2, minmax(180px, 1fr));
  }

  .member-row {
    grid-template-columns: repeat(2, minmax(180px, 1fr));
  }

  .member-row .field,
  .member-row .toggle,
  .member-row .btn {
    width: 100%;
  }
}

@media (max-width: 760px) {
  .topbar-inner {
    grid-template-columns: 1fr;
    gap: 12px;
    padding: 12px 14px;
  }

  .tabs {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    justify-content: stretch;
    overflow-x: visible;
    width: 100%;
  }

  .tabs button {
    width: 100%;
    min-height: 42px;
    padding: 8px 7px;
    white-space: normal;
    text-align: center;
  }

  .user-tools {
    justify-content: space-between;
  }

  .user-pill {
    max-width: min(66vw, 260px);
  }

  .page {
    padding: 16px 14px 36px;
  }

  .hero {
    gap: 12px;
    padding: 4px 0 16px;
    margin-bottom: 14px;
  }

  .hero h1 {
    font-size: 1.72rem;
    line-height: 1.08;
  }

  .hero p {
    font-size: 0.95rem;
  }

  .btn {
    min-height: 44px;
  }

  .btn.small {
    min-height: 40px;
  }

  .hero,
  .meeting-header,
  .filters {
    grid-template-columns: 1fr;
  }

  .role-grid,
  .profile-grid,
  .meeting-admin-grid,
  .bulk-import-grid,
  .member-create-grid,
  .form-row {
    grid-template-columns: 1fr;
  }

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

  .kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin: 14px 0;
  }

  .kpi {
    min-height: 86px;
    padding: 12px;
  }

  .kpi strong {
    font-size: 1.55rem;
  }

  .layout {
    gap: 14px;
  }

  .side-stack {
    order: -1;
    gap: 10px;
  }

  .club-panel {
    display: none;
  }

  .filters {
    gap: 9px;
  }

  .meeting-list {
    gap: 12px;
  }

  .meeting-header {
    gap: 10px;
    padding: 13px;
  }

  .meeting-date {
    display: grid;
    gap: 5px;
  }

  .meeting-date strong {
    font-size: 1rem;
  }

  .role-card {
    min-height: auto;
    padding: 12px;
  }

  .role-action > .btn,
  .assign-role,
  .assign-role .btn {
    width: 100%;
  }

  .assign-role {
    grid-template-columns: 1fr;
  }

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

  .bulk-access-table div {
    grid-template-columns: 1fr;
  }

  .full {
    grid-column: auto;
  }
}

@media (max-width: 420px) {
  .brand-mark {
    width: 48px;
    height: 48px;
  }

  .brand strong {
    font-size: 0.95rem;
  }

  .brand span {
    white-space: normal;
  }

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