:root {
  color-scheme: light;
  --bg-top: #f2efe4;
  --bg-bottom: #f8fbff;
  --panel: rgba(255, 255, 255, 0.88);
  --panel-border: rgba(23, 48, 74, 0.12);
  --text: #19324a;
  --muted: #5c7287;
  --accent: #0c6d73;
  --accent-strong: #084e52;
  --warning: #9c5a16;
  --warning-bg: #fff3dc;
  --success: #0d6b43;
  --success-bg: #eaf8f1;
  --shadow: 0 18px 40px rgba(13, 39, 64, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(12, 109, 115, 0.16), transparent 30%),
    linear-gradient(180deg, var(--bg-top), var(--bg-bottom));
  min-height: 100vh;
}

a {
  color: var(--accent-strong);
}

.page-shell {
  max-width: 1160px;
  margin: 0 auto;
  padding: 32px 20px 48px;
}

.narrow-shell {
  max-width: 560px;
}

.hero {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: end;
  margin-bottom: 24px;
}

.user-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 16px;
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(23, 48, 74, 0.1);
  color: var(--muted);
  box-shadow: 0 8px 24px rgba(13, 39, 64, 0.06);
  flex-wrap: wrap;
}

.user-strip-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.eyebrow {
  margin: 0 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.75rem;
  color: var(--muted);
}

h1 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 3.6rem);
  line-height: 0.95;
}

.hero-copy {
  max-width: 100%;
  font-size: 1rem;
  line-height: 1.5;
  color: var(--muted);
}

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

.hero-actions {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.primary-button,
.secondary-button,
.ghost-link,
.danger-button {
  border-radius: 999px;
  padding: 12px 18px;
  font-weight: 700;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.primary-button,
.secondary-button,
.danger-button {
  border: none;
}

.primary-button {
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: white;
  box-shadow: var(--shadow);
}

.secondary-button {
  background: #18344d;
  color: white;
}

.danger-button {
  background: #8f2d2d;
  color: white;
}

.ghost-link {
  color: var(--text);
  background: rgba(255, 255, 255, 0.6);
  border: 1px solid var(--panel-border);
}

.flash-stack {
  display: grid;
  gap: 10px;
  margin-bottom: 20px;
}

.flash {
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid transparent;
}

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

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

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.stat-card,
.panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 24px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
}

.stat-card {
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.stat-card strong {
  font-size: 1.8rem;
}

.stat-card.wide small {
  color: var(--muted);
}

.stat-label {
  color: var(--muted);
  font-size: 0.92rem;
}

.panel {
  padding: 22px;
  margin-bottom: 18px;
}

.filter-panel {
  position: relative;
  z-index: 20;
  overflow: visible;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  margin-bottom: 16px;
}

.panel-header h2 {
  margin: 0;
  font-size: 1.2rem;
}

.filters {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  align-items: end;
}

.filter-picker {
  display: grid;
  gap: 8px;
  font-weight: 600;
  position: relative;
  min-width: 0;
}

.filter-picker > span {
  color: var(--muted);
  font-size: 0.92rem;
}

.favorites-bar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.favorite-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid rgba(12, 109, 115, 0.42);
  background: rgba(255, 255, 255, 0.08);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.2);
  white-space: nowrap;
  transition: background 140ms ease, border-color 140ms ease, box-shadow 140ms ease, transform 140ms ease;
}

.favorite-chip:hover {
  border-color: rgba(12, 109, 115, 0.6);
  background: rgba(12, 109, 115, 0.08);
  box-shadow: 0 10px 20px rgba(12, 109, 115, 0.08);
  transform: translateY(-1px);
}

.favorite-link {
  color: var(--accent-strong);
  font-weight: 700;
  text-decoration: none;
  letter-spacing: 0.01em;
}

.favorite-chip.active {
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  border-color: rgba(8, 78, 82, 0.2);
  box-shadow:
    0 12px 24px rgba(12, 109, 115, 0.22),
    inset 0 0 0 1px rgba(255, 255, 255, 0.16);
}

.favorite-chip.active .favorite-link {
  color: white;
}

.favorite-delete-form {
  margin: 0;
}

.favorite-delete-button {
  border: none;
  background: transparent;
  color: rgba(12, 109, 115, 0.8);
  font-weight: 700;
  cursor: pointer;
  width: 20px;
  height: 20px;
  border-radius: 999px;
  padding: 0;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 140ms ease, color 140ms ease;
}

.favorite-delete-button:hover {
  background: rgba(12, 109, 115, 0.12);
  color: var(--accent-strong);
}

.favorite-chip.active .favorite-delete-button {
  color: rgba(255, 255, 255, 0.92);
}

.favorite-chip.active .favorite-delete-button:hover {
  background: rgba(255, 255, 255, 0.16);
  color: white;
}

select {
  width: 100%;
  border-radius: 14px;
  border: 1px solid rgba(23, 48, 74, 0.16);
  padding: 12px 14px;
  background: white;
  color: var(--text);
  font-size: 0.98rem;
}

.multi-select {
  position: relative;
}

.multi-select summary {
  list-style: none;
  width: 100%;
  border-radius: 14px;
  border: 1px solid rgba(23, 48, 74, 0.16);
  padding: 12px 42px 12px 14px;
  background: white;
  color: var(--text);
  font-size: 0.98rem;
  cursor: pointer;
  position: relative;
}

.multi-select summary::-webkit-details-marker {
  display: none;
}

.multi-select summary::after {
  content: "▾";
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: 0.9rem;
}

.multi-select[open] summary::after {
  content: "▴";
}

.multi-select-menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  width: max-content;
  min-width: 100%;
  max-width: min(90vw, 34rem);
  z-index: 100;
  display: grid;
  gap: 8px;
  max-height: 280px;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 12px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.98);
  border: 1px solid var(--panel-border);
  box-shadow: var(--shadow);
}

.multi-select-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(12, 109, 115, 0.04);
  flex-wrap: nowrap;
  white-space: nowrap;
}

.multi-select-option input {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--accent);
}

.multi-select-option span {
  color: var(--text);
  font-weight: 500;
  white-space: nowrap;
}

input,
textarea {
  width: 100%;
  border-radius: 14px;
  border: 1px solid rgba(23, 48, 74, 0.16);
  padding: 12px 14px;
  background: white;
  color: var(--text);
  font-size: 0.98rem;
  font-family: inherit;
}

textarea {
  resize: vertical;
}

.filter-actions {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  margin-top: 6px;
  padding-top: 4px;
}

.filter-save-group,
.filter-secondary-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.filter-secondary-actions {
  margin-left: auto;
}

.filter-actions .primary-button,
.filter-actions .secondary-button,
.filter-actions .ghost-link {
  min-height: 48px;
}

.filter-actions .ghost-link {
  background: rgba(255, 255, 255, 0.82);
}

.favorite-dialog {
  width: min(100%, 420px);
  border: 1px solid rgba(23, 48, 74, 0.12);
  border-radius: 24px;
  padding: 0;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 28px 60px rgba(13, 39, 64, 0.18);
}

.favorite-dialog::backdrop {
  background: rgba(17, 34, 51, 0.24);
  backdrop-filter: blur(4px);
}

.favorite-dialog-form {
  display: grid;
  gap: 16px;
  padding: 22px;
}

.favorite-dialog-copy h3 {
  margin: 0 0 6px;
  font-size: 1.2rem;
}

.favorite-dialog-copy p {
  margin: 0;
  color: var(--muted);
}

.favorite-dialog-form label {
  display: grid;
  gap: 8px;
  font-weight: 600;
}

.favorite-dialog-form label span {
  color: var(--muted);
  font-size: 0.92rem;
}

.favorite-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.table-wrap {
  overflow-x: auto;
}

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

th,
td {
  text-align: left;
  padding: 14px 10px;
  border-bottom: 1px solid rgba(23, 48, 74, 0.08);
}

th {
  color: var(--muted);
  font-size: 0.86rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.warning-list {
  margin: 0;
  padding-left: 18px;
}

.empty-state {
  padding: 28px 8px 10px;
  text-align: center;
}

.empty-state h3 {
  margin-bottom: 8px;
}

.empty-state p {
  color: var(--muted);
}

.admin-grid {
  display: grid;
  grid-template-columns: 1.1fr 1.9fr;
  gap: 18px;
  margin-bottom: 18px;
}

.stack-form {
  display: grid;
  gap: 14px;
}

.stack-form label {
  display: grid;
  gap: 8px;
  font-weight: 600;
}

.stack-form span {
  color: var(--muted);
  font-size: 0.92rem;
}

.recipient-admin {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 18px;
}

.recipient-list {
  display: grid;
  gap: 10px;
  align-content: start;
}

.recipient-link {
  display: grid;
  gap: 4px;
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(23, 48, 74, 0.08);
  text-decoration: none;
}

.recipient-link span {
  color: var(--muted);
  font-size: 0.9rem;
}

.recipient-link.active {
  border-color: rgba(12, 109, 115, 0.4);
  box-shadow: inset 0 0 0 1px rgba(12, 109, 115, 0.2);
}

.recipient-editor {
  display: grid;
  gap: 16px;
}

.inline-form {
  margin: 0;
}

.code-area {
  font-family: "SFMono-Regular", "Menlo", monospace;
  font-size: 0.92rem;
}

.account-grid {
  display: grid;
  grid-template-columns: 1.7fr 1fr;
  gap: 18px;
}

.checkbox-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

.preferences-grid {
  align-items: start;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 500;
}

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

.mini-heading {
  margin: 0 0 12px;
  font-size: 1rem;
}

.choice-chip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 14px;
  margin-bottom: 10px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.75);
  border: 1px solid rgba(23, 48, 74, 0.08);
  transition: border-color 120ms ease, box-shadow 120ms ease, transform 120ms ease;
}

.stack-form .choice-chip {
  display: flex;
  gap: 14px;
}

.choice-chip:hover {
  border-color: rgba(12, 109, 115, 0.28);
  box-shadow: 0 10px 24px rgba(12, 109, 115, 0.08);
  transform: translateY(-1px);
}

.choice-chip:has(input:checked) {
  border-color: rgba(12, 109, 115, 0.45);
  background: rgba(12, 109, 115, 0.12);
  box-shadow: 0 12px 26px rgba(12, 109, 115, 0.12);
}

.choice-chip span {
  color: var(--text);
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.3;
}

.choice-chip input {
  width: 18px;
  height: 18px;
  margin: 0;
  flex: 0 0 auto;
  accent-color: var(--accent);
}

.toggle-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.74);
  border: 1px solid rgba(23, 48, 74, 0.08);
}

.toggle-row input {
  width: 18px;
  height: 18px;
  margin: 0;
  flex: 0 0 auto;
  accent-color: var(--accent);
}

.toggle-row span {
  font-weight: 600;
  color: var(--text);
}

.toggle-chip {
  justify-content: flex-start;
  margin-bottom: 4px;
}

.toggle-chip span {
  flex: 1 1 auto;
}

.date-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px 18px;
}

@media (max-width: 880px) {
  .hero,
  .panel-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .stats-grid,
  .filters,
  .admin-grid,
  .recipient-admin,
  .account-grid,
  .checkbox-grid,
  .date-grid {
    grid-template-columns: 1fr;
  }
}
