﻿:root {
  --bg: #f7f1e8;
  --bg-elevated: rgba(255, 252, 247, 0.92);
  --bg-soft: rgba(255, 245, 235, 0.88);
  --text: #1f2937;
  --text-muted: #6b7280;
  --line: rgba(119, 74, 44, 0.12);
  --line-strong: rgba(119, 74, 44, 0.22);
  --brand: #c84c27;
  --brand-strong: #a5301f;
  --brand-soft: rgba(200, 76, 39, 0.12);
  --accent: #f0b429;
  --accent-soft: rgba(240, 180, 41, 0.18);
  --success: #0f766e;
  --success-soft: rgba(15, 118, 110, 0.14);
  --danger: #b42318;
  --danger-soft: rgba(180, 35, 24, 0.14);
  --shadow: 0 18px 50px rgba(61, 35, 17, 0.12);
  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 14px;
  --sidebar-width: 312px;
  --content-max: 1440px;
  --font-ui: "Trebuchet MS", "Segoe UI", Tahoma, sans-serif;
}

:root[data-theme="dark"] {
  --bg: #181311;
  --bg-elevated: rgba(28, 23, 20, 0.94);
  --bg-soft: rgba(38, 30, 26, 0.88);
  --text: #f7efe5;
  --text-muted: #c9b9aa;
  --line: rgba(255, 235, 205, 0.08);
  --line-strong: rgba(255, 235, 205, 0.18);
  --brand: #ed6c42;
  --brand-strong: #ff8d59;
  --brand-soft: rgba(237, 108, 66, 0.18);
  --accent: #f7c648;
  --accent-soft: rgba(247, 198, 72, 0.16);
  --success: #34d399;
  --success-soft: rgba(52, 211, 153, 0.16);
  --danger: #f87171;
  --danger-soft: rgba(248, 113, 113, 0.16);
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.38);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  background:
    radial-gradient(circle at top right, rgba(240, 180, 41, 0.14), transparent 24%),
    radial-gradient(circle at bottom left, rgba(200, 76, 39, 0.16), transparent 22%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.35), transparent 34%),
    var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
}

body.page--app {
  height: 100vh;
  overflow: hidden;
}

img {
  display: block;
  max-width: 100%;
}

a {
  color: inherit;
  text-decoration: none;
}

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

button {
  cursor: pointer;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.auth-layout {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(320px, 1.1fr) minmax(320px, 1fr);
}

.auth-hero {
  padding: 56px;
  background:
    linear-gradient(135deg, rgba(36, 18, 11, 0.9), rgba(164, 48, 26, 0.82)),
    linear-gradient(180deg, rgba(247, 198, 72, 0.2), transparent 40%);
  color: #fff9f4;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
}

.auth-hero::after {
  content: "";
  position: absolute;
  inset: auto -10% -28% 35%;
  height: 320px;
  background: radial-gradient(circle, rgba(255, 237, 179, 0.28), transparent 62%);
  transform: rotate(-9deg);
}

.auth-hero__pill,
.hero-card__pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  color: inherit;
  border: 1px solid rgba(255, 255, 255, 0.18);
  width: fit-content;
}

.auth-hero h1 {
  font-size: clamp(2.3rem, 4vw, 4.5rem);
  line-height: 1.04;
  margin: 20px 0 18px;
}

.auth-hero p {
  max-width: 580px;
  color: rgba(255, 249, 244, 0.84);
  font-size: 1.04rem;
}

.auth-hero__list {
  display: grid;
  gap: 12px;
  padding: 0;
  margin: 28px 0 0;
  list-style: none;
}

.auth-hero__list li {
  display: flex;
  align-items: center;
  gap: 10px;
  color: rgba(255, 249, 244, 0.88);
}

.auth-panel {
  padding: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.auth-card,
.surface-card,
.section-card,
.member-detail-card,
.hero-card {
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.auth-card {
  width: min(100%, 520px);
  border-radius: 32px;
  padding: 34px;
}

.auth-card__top {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-bottom: 24px;
}

.auth-card__brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.auth-card__brand img,
.logo-lockup img,
.sidebar-brand img {
  width: 62px;
  height: 62px;
  border-radius: 20px;
  object-fit: cover;
  border: 1px solid var(--line);
  background: #fff6ec;
}

.logo-lockup {
  display: flex;
  align-items: center;
  gap: 16px;
}

.logo-lockup h2,
.auth-card h2,
.sidebar-brand h2,
.section-header h2,
.panel-title,
.member-hero__info h2 {
  margin: 0;
}

.logo-lockup p,
.auth-card p,
.sidebar-brand p,
.section-header p,
.member-hero__info p,
.form-caption,
.empty-state p,
.stat-card p,
.member-mini-card p,
.hero-card__content p,
.table-summary p {
  margin: 0;
  color: var(--text-muted);
}

.badge,
.small-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--text);
  border: 1px solid rgba(240, 180, 41, 0.22);
  width: fit-content;
}

.small-badge {
  padding: 6px 10px;
  font-size: 0.88rem;
}

.button,
.icon-button,
.inline-action {
  border: 0;
  border-radius: 14px;
  transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 46px;
  padding: 0 18px;
  background: var(--brand);
  color: #fff8f4;
  font-weight: 700;
  box-shadow: 0 12px 24px rgba(200, 76, 39, 0.18);
}

.button:hover,
.icon-button:hover,
.inline-action:hover {
  transform: translateY(-1px);
}

.button--ghost,
.icon-button,
.inline-action {
  background: var(--bg-soft);
  color: var(--text);
  border: 1px solid var(--line);
  box-shadow: none;
}

.button--light {
  background: rgba(255, 255, 255, 0.16);
  color: #fff8f4;
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: none;
}

.button--danger {
  background: var(--danger-soft);
  color: var(--danger);
  border: 1px solid rgba(180, 35, 24, 0.14);
}

.button--full {
  width: 100%;
}

.icon-button {
  width: 46px;
  height: 46px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

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

.field-grid--three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.field,
.field--full {
  display: grid;
  gap: 10px;
}

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

.field label,
.fieldset-title {
  font-weight: 700;
}

.input,
.select,
.textarea {
  width: 100%;
  min-height: 48px;
  border-radius: 14px;
  border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, 0.76);
  color: var(--text);
  padding: 0 14px;
}

:root[data-theme="dark"] .input,
:root[data-theme="dark"] .select,
:root[data-theme="dark"] .textarea {
  background: rgba(18, 15, 13, 0.86);
}

.textarea {
  min-height: 110px;
  padding: 12px 14px;
  resize: vertical;
}

.input:focus,
.select:focus,
.textarea:focus {
  outline: 2px solid rgba(240, 180, 41, 0.32);
  border-color: rgba(240, 180, 41, 0.55);
}

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

.form-section {
  display: grid;
  gap: 18px;
  padding: 24px;
  border-radius: 22px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
}

.form-section__header {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
}

.field-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.toggle-group {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.choice-pill,
.month-chip {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  border-radius: 999px;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid var(--line);
}

:root[data-theme="dark"] .choice-pill,
:root[data-theme="dark"] .month-chip {
  background: rgba(18, 15, 13, 0.74);
}

.choice-pill input,
.month-chip input {
  accent-color: var(--brand);
}

.month-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(128px, 1fr));
  gap: 12px;
}

.month-chip--current {
  border-color: rgba(240, 180, 41, 0.44);
  box-shadow: inset 0 0 0 1px rgba(240, 180, 41, 0.2);
}

.photo-uploader {
  display: grid;
  gap: 16px;
}

.field-row--photo {
  display: grid;
  grid-template-columns: minmax(180px, 220px) minmax(0, 1fr);
  align-items: start;
  gap: 20px;
}

.photo-uploader__preview,
.photo-uploader__panel,
.photo-editor,
.photo-control {
  display: grid;
  gap: 14px;
}

.photo-preview,
.member-hero__avatar img,
.member-cell img,
.member-mini-card img {
  width: 90px;
  height: 90px;
  object-fit: cover;
  border-radius: 24px;
  border: 1px solid var(--line);
  background: rgba(255, 248, 241, 0.92);
}

.photo-preview--editor {
  width: min(100%, 220px);
  height: auto;
  aspect-ratio: 1;
  border-radius: 30px;
  box-shadow: var(--shadow);
}

.photo-editor {
  padding: 18px;
  border-radius: 24px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.5);
}

:root[data-theme="dark"] .photo-editor {
  background: rgba(18, 15, 13, 0.72);
}

.photo-editor.is-processing {
  opacity: 0.78;
}

.photo-editor__header,
.photo-control__label,
.photo-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.photo-editor__header h4,
.photo-editor__header p,
.photo-helper {
  margin: 0;
}

.photo-editor__header p,
.photo-helper {
  color: var(--text-muted);
}

.photo-editor__controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 18px;
}

.range-input {
  width: 100%;
  accent-color: var(--brand);
}

.member-hero__avatar img {
  width: 128px;
  height: 128px;
  border-radius: 32px;
}

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  height: 100vh;
}

.sidebar {
  position: relative;
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(49, 24, 18, 0.96), rgba(118, 40, 27, 0.92)),
    linear-gradient(180deg, rgba(240, 180, 41, 0.18), transparent 45%);
  color: #fff8f4;
  padding: 28px 22px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.sidebar::before {
  content: "";
  position: absolute;
  inset: auto -20% -18% -10%;
  height: 240px;
  background: radial-gradient(circle, rgba(247, 198, 72, 0.18), transparent 64%);
}

.sidebar-brand {
  display: grid;
  gap: 12px;
  position: relative;
  z-index: 1;
}

.sidebar-brand p,
.sidebar-footer {
  color: rgba(255, 248, 241, 0.72);
}

.sidebar-nav {
  display: grid;
  gap: 8px;
  position: relative;
  z-index: 1;
}

.nav-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-radius: 18px;
  color: rgba(255, 248, 241, 0.88);
}

.nav-link:hover,
.nav-link.is-active {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.content-panel {
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 22px 26px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 250, 245, 0.78);
  backdrop-filter: blur(10px);
}

:root[data-theme="dark"] .topbar {
  background: rgba(24, 19, 17, 0.74);
}

.topbar__left,
.topbar__right,
.inline-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.toolbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
  overflow-x: auto;
  scrollbar-width: none;
}

.toolbar-actions::-webkit-scrollbar {
  display: none;
}

.toolbar-icon {
  width: 42px;
  min-width: 42px;
  height: 42px;
  padding: 0;
  border-radius: 12px;
  flex: 0 0 auto;
  font-size: 0.92rem;
  font-weight: 800;
}

.toolbar-icon--lang {
  width: 48px;
  min-width: 48px;
  font-size: 0.82rem;
  letter-spacing: 0.04em;
}

.toolbar-icon--danger {
  background: var(--danger-soft);
  color: var(--danger);
  border: 1px solid rgba(180, 35, 24, 0.14);
}

.topbar__title h1 {
  margin: 0;
  font-size: clamp(1.45rem, 2vw, 2rem);
}

.topbar__title p {
  margin: 6px 0 0;
  color: var(--text-muted);
}

.topbar__title p:empty,
.section-header p:empty,
.form-caption:empty,
.logo-lockup p:empty,
.footer-note:empty,
.sidebar-footer:empty {
  display: none;
}

.content-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

.content-scroll__inner {
  max-width: var(--content-max);
  margin: 0 auto;
  display: grid;
  gap: 24px;
}

.hero-card {
  border-radius: 30px;
  padding: 28px;
  background:
    linear-gradient(135deg, rgba(242, 202, 99, 0.18), rgba(198, 76, 39, 0.12)),
    var(--bg-elevated);
}

.hero-card--dashboard {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(280px, 0.8fr);
  gap: 24px;
}

.hero-card__content {
  display: grid;
  gap: 18px;
}

.hero-card__content h2 {
  margin: 0;
  font-size: clamp(1.7rem, 2.4vw, 2.4rem);
}

.hero-card__actions,
.section-actions,
.form-actions,
.member-hero__actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.hero-card__aside {
  display: grid;
  gap: 16px;
}

.surface-card,
.section-card,
.member-detail-card {
  border-radius: var(--radius-xl);
  padding: 24px;
}

.section-header,
.table-summary,
.member-hero,
.member-detail-grid,
.dashboard-grid,
.stats-grid,
.latest-grid {
  display: grid;
  gap: 18px;
}

.section-header {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
}

.stats-grid {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.stat-card {
  border-radius: 24px;
  padding: 24px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.34), transparent), var(--bg-elevated);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  display: grid;
  gap: 10px;
}

.stat-card__value {
  font-size: clamp(1.9rem, 2.8vw, 2.8rem);
  font-weight: 800;
}

.stat-card__link {
  color: var(--brand);
  font-weight: 700;
}

.latest-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.member-mini-card {
  display: flex;
  gap: 14px;
  align-items: center;
  padding: 18px;
  border-radius: 22px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
}

.member-mini-card h4,
.empty-state h3,
.panel-title {
  margin: 0 0 6px;
}

.empty-state {
  padding: 30px;
  border-radius: 24px;
  border: 1px dashed var(--line-strong);
  background: rgba(255, 255, 255, 0.32);
}

.table-wrapper {
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: 22px;
  border: 1px solid var(--line);
}

.data-table {
  width: 100%;
  min-width: 900px;
  border-collapse: collapse;
}

.data-table th,
.data-table td {
  padding: 16px;
  text-align: start;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

.data-table thead {
  background: rgba(240, 180, 41, 0.12);
}

.member-cell {
  display: flex;
  align-items: center;
  gap: 12px;
}

.member-cell img {
  width: 56px;
  height: 56px;
  border-radius: 18px;
}

.member-cell small {
  display: block;
  color: var(--text-muted);
  margin-top: 4px;
}

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

.status-pill {
  display: inline-flex;
  align-items: center;
  padding: 8px 12px;
  border-radius: 999px;
  font-weight: 700;
}

.status-pill--paid,
.status-pill--insured {
  background: var(--success-soft);
  color: var(--success);
}

.status-pill--unpaid,
.status-pill--uninsured {
  background: var(--danger-soft);
  color: var(--danger);
}

.filter-bar {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) repeat(2, minmax(180px, 0.7fr)) auto;
  gap: 14px;
}

.member-hero {
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
}

.member-hero__avatar {
  display: grid;
  place-items: center;
}

.member-hero__info {
  display: grid;
  gap: 16px;
}

.member-detail-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

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

.detail-item {
  display: grid;
  gap: 6px;
  padding: 16px;
  border-radius: 18px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
}

.detail-item span {
  color: var(--text-muted);
  font-size: 0.92rem;
}

.stacked-notice {
  padding: 16px 18px;
  border-radius: 18px;
  background: var(--brand-soft);
  border: 1px solid rgba(200, 76, 39, 0.14);
}

.meta-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.footer-note {
  padding: 4px 0 16px;
  color: var(--text-muted);
  text-align: center;
}

.mobile-menu-toggle {
  display: none;
}

.sidebar-overlay {
  display: none;
}

.toast {
  position: fixed;
  inset: auto 24px 24px auto;
  background: rgba(31, 41, 55, 0.94);
  color: #fff;
  padding: 14px 18px;
  border-radius: 16px;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.18s ease, transform 0.18s ease;
  z-index: 1000;
}

.toast--visible {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 1200px) {
  .stats-grid,
  .latest-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .hero-card--dashboard {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .mobile-menu-toggle {
    display: inline-flex;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(90vw, 340px);
    z-index: 50;
    transform: translateX(-105%);
    transition: transform 0.22s ease;
  }

  [dir="rtl"] .sidebar {
    inset: 0 0 0 auto;
    transform: translateX(105%);
  }

  body.sidebar-open .sidebar {
    transform: translateX(0);
  }

  .sidebar-overlay {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(17, 24, 39, 0.42);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.18s ease;
    z-index: 40;
  }

  body.sidebar-open .sidebar-overlay {
    opacity: 1;
    pointer-events: auto;
  }

  .filter-bar,
  .detail-list,
  .member-detail-grid,
  .field-grid,
  .field-grid--three {
    grid-template-columns: 1fr;
  }

  .topbar {
    padding: 20px;
  }

  .content-scroll {
    padding: 18px;
  }
}

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

  .auth-hero {
    min-height: 420px;
    padding: 32px 24px;
  }

  .auth-panel {
    padding: 20px;
  }

  .auth-card,
  .hero-card,
  .section-card,
  .surface-card,
  .member-detail-card {
    padding: 20px;
    border-radius: 24px;
  }

  .stats-grid,
  .latest-grid {
    grid-template-columns: 1fr;
  }

  .section-header,
  .member-hero,
  .topbar,
  .topbar__left,
  .auth-card__top,
  .form-section__header,
  .field-row--photo,
  .photo-editor__header {
    grid-template-columns: 1fr;
    flex-direction: column;
    align-items: stretch;
  }

  .topbar__right {
    width: 100%;
    display: flex;
    justify-content: flex-start;
    align-items: center;
  }

  .toolbar-actions {
    max-width: 100%;
  }

  .member-hero {
    justify-items: start;
  }

  .section-actions,
  .hero-card__actions,
  .form-actions,
  .member-hero__actions,
  .inline-actions,
  .photo-meta {
    width: 100%;
  }

  .section-actions .button,
  .hero-card__actions .button,
  .form-actions .button,
  .member-hero__actions .button,
  .inline-actions .button,
  .inline-actions .icon-button {
    flex: 1 1 100%;
  }

  .toolbar-actions .toolbar-icon {
    flex: 0 0 auto;
  }

  .photo-editor__controls {
    grid-template-columns: 1fr;
  }

  .photo-uploader__preview {
    justify-items: start;
  }

  .table-actions {
    flex-direction: column;
  }

  .button,
  .icon-button {
    width: 100%;
  }

  .toolbar-actions .icon-button {
    width: 42px;
  }

  .data-table {
    min-width: 720px;
  }
}
