:root {
  --bg: #f4f7fb;
  --card: #ffffff;
  --line: #e7edf5;
  --text: #0f172a;
  --muted: #64748b;
  --primary: #1d4ed8;
  --primary-soft: #eff6ff;
  --green: #047857;
  --green-soft: #ecfdf5;
  --orange: #b45309;
  --orange-soft: #fffbeb;
  --red: #b91c1c;
  --red-soft: #fef2f2;
  --shadow: 0 14px 32px rgba(15, 23, 42, 0.08);
  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 16px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  font-family: "Pretendard", "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  background: linear-gradient(180deg, #f8fbff 0%, var(--bg) 100%);
  color: var(--text);
}

button, input, select {
  font: inherit;
}

.page {
  max-width: 1540px;
  margin: 0 auto;
  padding: 24px;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
}

.header {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: flex-start;
  padding: 28px;
  margin-bottom: 18px;
}

.header h1 {
  margin: 8px 0 6px;
  font-size: 34px;
  line-height: 1.15;
  letter-spacing: -0.04em;
}

.header .sub {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.7;
  margin: 0;
}

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

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 700;
  border: 1px solid transparent;
  white-space: nowrap;
}

.pill.dark { background: #0f172a; color: #fff; }
.pill.primary { background: var(--primary-soft); color: var(--primary); border-color: #bfdbfe; }
.pill.green { background: var(--green-soft); color: var(--green); }
.pill.orange { background: var(--orange-soft); color: var(--orange); }
.pill.red { background: var(--red-soft); color: var(--red); }

.btn {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  border-radius: 16px;
  padding: 12px 16px;
  font-weight: 700;
  cursor: pointer;
  transition: .18s ease;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

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

.btn.primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.btn.ghost {
  background: #f8fafc;
}

.btn.small {
  padding: 10px 12px;
  font-size: 13px;
  border-radius: 14px;
}

.tabs {
  display: flex;
  gap: 10px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.tab-btn {
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.9);
  color: var(--muted);
  border-radius: 16px;
  padding: 13px 18px;
  font-weight: 800;
  cursor: pointer;
}

.tab-btn.active {
  background: #0f172a;
  color: #fff;
  border-color: #0f172a;
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 18px;
}

.summary-card {
  padding: 22px;
  min-height: 150px;
  display: grid;
  align-content: space-between;
}

.summary-card .label {
  color: var(--muted);
  font-size: 13px;
  margin: 0;
}

.summary-card .value {
  font-size: 30px;
  line-height: 1.15;
  letter-spacing: -0.04em;
  font-weight: 800;
  margin: 8px 0;
  word-break: keep-all;
}

.summary-card .help {
  color: var(--muted);
  font-size: 13px;
  margin: 0;
  line-height: 1.6;
}

.settlement-layout {
  display: grid;
  grid-template-columns: minmax(360px, 1.1fr) minmax(340px, 0.95fr) minmax(320px, 0.8fr);
  gap: 18px;
}

.panel {
  padding: 20px;
}

.panel h2 {
  margin: 0 0 6px;
  font-size: 21px;
  letter-spacing: -0.02em;
}

.panel .desc {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

.left-stack,
.middle-stack,
.right-stack {
  display: grid;
  gap: 18px;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

.member-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.member-table th,
.member-table td {
  border-bottom: 1px solid var(--line);
  padding: 14px 10px;
  text-align: left;
  vertical-align: middle;
  font-size: 14px;
  line-height: 1.55;
  word-break: keep-all;
  white-space: normal;
}

.member-table th {
  background: #f8fafc;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.member-cell {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.member-cell-name {
  font-weight: 700;
  word-break: keep-all;
}

.avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  object-fit: cover;
  background: #dbeafe;
  border: 2px solid #fff;
  box-shadow: 0 6px 14px rgba(15, 23, 42, 0.08);
  flex-shrink: 0;
}

.avatar-sm {
  width: 36px;
  height: 36px;
}

.avatar.fallback {
  display: grid;
  place-items: center;
  color: #1d4ed8;
  font-weight: 800;
  font-size: 18px;
  background: linear-gradient(135deg, #dbeafe, #eff6ff);
}

.member-cards-mobile {
  display: none;
}

.member-mobile-card {
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 14px;
  background: #fcfdff;
}

.member-mobile-card + .member-mobile-card {
  margin-top: 10px;
}

.member-mobile-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 12px;
}

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

.member-mobile-name {
  margin: 0 0 6px;
  font-size: 16px;
  font-weight: 800;
}

.member-mobile-grid {
  display: grid;
  gap: 8px;
}

.mobile-info-row {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  padding: 12px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.mobile-info-label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.summary-table {
  display: grid;
  gap: 8px;
}

.summary-row {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fcfdff;
  padding: 14px;
  display: grid;
  grid-template-columns: 104px 1fr auto;
  gap: 12px;
  align-items: center;
}

.summary-row .turn {
  font-size: 13px;
  color: var(--muted);
  font-weight: 800;
  word-break: keep-all;
}

.summary-row .meta {
  font-size: 14px;
  color: var(--text);
  font-weight: 700;
  line-height: 1.6;
  word-break: keep-all;
}

.summary-row .money {
  font-size: 18px;
  font-weight: 900;
  letter-spacing: -0.03em;
  word-break: keep-all;
}

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

.thumb-card {
  border: 1px solid var(--line);
  border-radius: 18px;
  overflow: hidden;
  background: #fff;
}

.thumb-box {
  position: relative;
  height: 170px;
  background: #e2e8f0;
  cursor: pointer;
}

.thumb-box img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.thumb-fallback {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  font-size: 18px;
  font-weight: 800;
  color: #475569;
  background: linear-gradient(135deg, #e2e8f0, #f8fafc);
}

.thumb-badge {
  position: absolute;
  top: 12px;
  left: 12px;
  background: rgba(15, 23, 42, 0.8);
  color: #fff;
  padding: 7px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
}

.thumb-info {
  padding: 14px;
  display: grid;
  gap: 6px;
}

.thumb-title {
  margin: 0;
  font-size: 15px;
  font-weight: 800;
  line-height: 1.5;
  word-break: break-all;
}

.thumb-meta {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
  word-break: break-all;
}

.thumb-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 4px;
}

.bank-main-card .thumb-box {
  height: 240px;
}

.bank-list {
  display: grid;
  gap: 12px;
}

.account-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 14px;
}

.account-card {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fcfdff;
  padding: 14px;
}

.account-label {
  margin: 0 0 8px;
  font-size: 12px;
  color: var(--muted);
  font-weight: 800;
}

.account-bank {
  margin: 0 0 6px;
  font-size: 14px;
  font-weight: 700;
}

.account-number {
  margin: 0;
  font-size: 18px;
  font-weight: 900;
  letter-spacing: -0.02em;
  word-break: break-all;
}

.upload-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.filter-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.filter-chip {
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.filter-chip.active {
  background: var(--primary-soft);
  color: var(--primary);
  border-color: #bfdbfe;
}

.upload-form {
  margin-bottom: 18px;
  border: 1px solid var(--line);
  background: #fcfdff;
  border-radius: 20px;
  padding: 16px;
  display: grid;
  grid-template-columns: 180px 1fr auto;
  gap: 10px;
  align-items: end;
}

.upload-form label {
  display: grid;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
  font-weight: 700;
}

.upload-form select,
.upload-form input[type="file"] {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  padding: 12px 14px;
}

.upload-status {
  margin: 10px 0 0;
  font-size: 13px;
  color: var(--muted);
}

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

.group-section + .group-section {
  margin-top: 26px;
}

.group-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.group-head h3 {
  margin: 0;
  font-size: 18px;
}

.manage-section + .manage-section {
  margin-top: 18px;
}

.manage-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.manage-grid {
  display: grid;
  gap: 12px;
}

.manage-item {
  border: 1px solid var(--line);
  background: #fcfdff;
  border-radius: 18px;
  padding: 14px;
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
}

.manage-info h3 {
  margin: 0 0 4px;
  font-size: 16px;
}

.manage-info p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.manage-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.setting-form {
  display: grid;
  gap: 16px;
}

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

.input-group {
  display: grid;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
  font-weight: 700;
}

.input-group input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  padding: 12px 14px;
  color: var(--text);
}

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

.form-status {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

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

.folder-item {
  border: 1px dashed #cbd5e1;
  background: #f8fafc;
  border-radius: 16px;
  padding: 14px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.folder-item strong {
  display: block;
  margin-bottom: 4px;
}

.folder-item p {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
  word-break: break-all;
}

.empty-box {
  border: 1px dashed #cbd5e1;
  background: #f8fafc;
  color: var(--muted);
  border-radius: 18px;
  padding: 18px;
  font-size: 14px;
  line-height: 1.7;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.68);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 999;
}

.modal.show { display: flex; }

.modal-card {
  width: min(1120px, 100%);
  max-height: 90vh;
  background: #fff;
  border-radius: 26px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.2);
  box-shadow: 0 24px 80px rgba(15, 23, 42, 0.28);
  display: grid;
  grid-template-rows: auto 1fr;
}

.modal-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}

.modal-top h3 {
  margin: 0 0 4px;
  font-size: 18px;
}

.modal-top p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.modal-body {
  overflow: auto;
  background: #f8fafc;
  padding: 20px;
  display: grid;
  place-items: center;
}

.modal-body img {
  width: auto;
  max-width: 100%;
  height: auto;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: #fff;
}

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

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

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

@media (max-width: 820px) {
  .page {
    padding: 16px;
  }

  .header {
    flex-direction: column;
    padding: 20px;
  }

  .header h1 {
    font-size: 28px;
  }

  .header-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .header-actions .btn {
    flex: 1 1 calc(50% - 10px);
    min-width: 0;
  }

  .tabs {
    gap: 8px;
  }

  .tab-btn {
    flex: 1 1 calc(33.333% - 8px);
    min-width: 0;
    padding: 12px 10px;
    font-size: 13px;
  }

  .summary-grid,
  .grid-4,
  .receipt-grid,
  .evidence-grid,
  .form-grid,
  .account-grid {
    grid-template-columns: 1fr;
  }

  .summary-card {
    min-height: auto;
    padding: 18px;
  }

  .summary-card .value {
    font-size: 26px;
  }

  .settlement-layout {
    grid-template-columns: 1fr;
  }

  .member-table-desktop {
    display: none;
  }

  .member-cards-mobile {
    display: block;
  }

  .summary-row {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .summary-row .money {
    font-size: 17px;
  }

  .thumb-box,
  .bank-main-card .thumb-box {
    height: 220px;
  }

  .upload-form {
    grid-template-columns: 1fr;
  }

  .manage-item {
    grid-template-columns: 1fr;
  }

  .manage-actions {
    justify-content: flex-start;
  }

  .form-actions {
    flex-direction: column;
    align-items: flex-start;
  }

  .mobile-info-row {
    flex-direction: column;
    align-items: flex-start;
  }

  .modal {
    padding: 12px;
  }

  .modal-card {
    width: 100%;
    max-height: 92vh;
  }

  .modal-top {
    flex-direction: column;
    align-items: flex-start;
  }
}

@media (min-width: 821px) {
  .member-cards-mobile {
    display: none;
  }
}