/* ===========================
   MAIN APP - FLUID DESIGN
   =========================== */

:root {
  --bg: #f5f4f1;
  --surface: #ffffff;
  --surface-muted: #fbfaf7;
  --text: #111827;
  --muted: #5f6368;
  --accent: #1f7a8c;
  --accent-strong: #155766;
  --accent-soft: rgba(31, 122, 140, 0.12);
  --ok: #198754;
  --danger: #c2410c;
  --border: #e2ddd3;
  --radius: clamp(0.75rem, 1vw, 1rem);
  --shadow: 0 10px 24px rgba(17, 24, 39, 0.08);
  --shadow-soft: 0 6px 16px rgba(17, 24, 39, 0.06);
  --font-body: 'Manrope', 'Segoe UI', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --font-display: 'Space Grotesk', 'Segoe UI', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  font-family: var(--font-body);
}

* {
  box-sizing: border-box;
}

html, body {
  height: 100%;
}

body {
  margin: 0;
  min-height: 100%;
  background: radial-gradient(circle at top, #ffffff 0%, var(--bg) 45%, var(--bg) 100%);
  color: var(--text);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 clamp(0.75rem, 3vw, 2.5rem) clamp(0.75rem, 3vw, 2.5rem);
  line-height: 1.6;
  font-size: clamp(0.9rem, 0.9rem + 0.25vw, 1rem);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

body, button, input, select, textarea {
  font-family: var(--font-body);
}

h1, h2, h3, h4, .workspace-title, .expense-hero-amount, .expense-hero-title,
.person-hero-name, .person-hero-balance .balance-amount {
  font-family: var(--font-display);
  letter-spacing: -0.01em;
}

.workspace-shell {
  width: min(1180px, 100%);
  position: relative;
  display: flex;
  flex-direction: column;
  gap: clamp(1.5rem, 3vw, 2.5rem);
}

.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background: var(--accent);
  color: #fff;
  padding: 8px 12px;
  text-decoration: none;
  z-index: 100;
  border-radius: 999px;
  box-shadow: var(--shadow-soft);
}

.skip-link:focus {
  top: 16px;
}

/* Header */
.app-header {
  width: 100vw;
  margin-left: calc(50% - 50vw);
  margin-right: calc(50% - 50vw);
  background: var(--surface);
  border-radius: 0 0 calc(var(--radius) * 1.15) calc(var(--radius) * 1.15);
  border: 1px solid var(--border);
  padding: clamp(1rem, 2.5vw, 1.75rem);
  box-shadow: var(--shadow-soft);
  position: sticky;
  top: 0;
  z-index: 50;
  transition: padding 0.3s ease;
}

/* Header collapsed state when scrolling down */
.app-header.header-collapsed .header-content {
  max-height: 0;
  opacity: 0;
  margin-bottom: 0;
  overflow: hidden;
  pointer-events: none;
}

.app-header .header-content {
  max-height: 200px;
  opacity: 1;
  transition: max-height 0.3s ease, opacity 0.2s ease, margin-bottom 0.3s ease;
}

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: clamp(1rem, 2vw, 2rem);
  margin-bottom: clamp(0.75rem, 1.5vw, 1.5rem);
  flex-wrap: wrap;
}

.workspace-brand {
  display: flex;
  flex-direction: column;
  gap: clamp(0.35rem, 0.8vw, 0.65rem);
}

.eyebrow {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--muted);
}

.workspace-eyebrow {
  margin: 0;
  color: var(--muted);
}

.workspace-title {
  margin: 0;
  font-size: clamp(1.8rem, 4vw, 2.4rem);
  font-weight: 700;
  line-height: 1.1;
}

.workspace-tagline {
  margin: 0;
  color: var(--muted);
  font-size: clamp(0.9rem, 1.8vw, 1rem);
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: clamp(0.5rem, 1vw, 0.75rem);
  font-size: clamp(1rem, 2vw, 1.25rem);
  font-weight: 600;
  color: var(--text);
  transition: color 0.2s ease;
}

.logo svg {
  color: var(--accent);
  transition: color 0.2s ease;
}

.logo:hover {
  color: var(--accent);
}

.logo:hover svg {
  color: var(--accent-strong);
}

/* Navigation */
.view-nav {
  display: flex;
  gap: clamp(4px, 0.5vw, 8px);
  background: var(--surface-muted);
  padding: 6px;
  border-radius: 999px;
  border: 1px solid var(--border);
  width: 100%;
}

.nav-item {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: clamp(8px, 1.5vw, 10px) clamp(12px, 2vw, 16px);
  background: transparent;
  border: none;
  border-radius: 999px;
  color: var(--muted);
  font-size: clamp(0.8rem, 1.5vw, 0.95rem);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
  min-height: 44px;
}

.nav-item:hover {
  background: rgba(31, 122, 140, 0.12);
  color: var(--accent);
}

.nav-item.active {
  background: var(--surface);
  color: var(--accent);
  box-shadow: var(--shadow-soft);
}

.nav-item svg {
  flex-shrink: 0;
}

.group-name-section {
  margin-top: clamp(0.75rem, 2vw, 1.25rem);
  background: var(--surface);
  border-radius: calc(var(--radius) * 1.1);
  border: 1px solid var(--border);
  padding: clamp(0.75rem, 2vw, 1.25rem);
  box-shadow: var(--shadow-soft);
  display: flex;
  justify-content: center;
}

.group-name-inner {
  width: min(720px, 100%);
  display: flex;
  justify-content: center;
  align-items: center;
}

.group-name-button,
.group-name-input {
  font-size: clamp(1.1rem, 2.5vw, 1.6rem);
  font-weight: 600;
  color: var(--text);
  text-align: center;
}

.group-name-button {
  background: transparent;
  border: none;
  padding: 0.3rem 0.75rem;
  border-radius: 0.75rem;
  cursor: text;
  transition: background 0.2s ease;
}

.group-name-button:hover {
  background: var(--surface-muted);
}

.group-name-input {
  display: none;
  width: min(520px, 100%);
  padding: 0.45rem 0.75rem;
  border-radius: 0.75rem;
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow-soft);
}

.group-name-input:focus {
  outline: 2px solid rgba(31, 122, 140, 0.2);
  border-color: var(--accent);
}

.group-name-section.editing .group-name-button {
  display: none;
}

.group-name-section.editing .group-name-input {
  display: block;
}

@media (max-width: 640px) {
  .view-nav {
    gap: 4px;
    padding: 4px;
  }

  .nav-item {
    gap: 4px;
    padding: 8px 10px;
  }

  .nav-item span {
    display: none;
  }

  .nav-item.active span {
    display: inline;
  }
}

/* Layout */
.layout {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr));
  gap: clamp(1rem, 2vw, 1.5rem);
  align-items: start;
}

.expenses-section {
  grid-column: 1 / -1;
}

/* View visibility */
body[data-view="people"] .settlements-section,
body[data-view="people"] .expenses-section { display: none; }
body[data-view="people"] .people-section { grid-column: 1 / -1; }

body[data-view="settlements"] .people-section,
body[data-view="settlements"] .expenses-section { display: none; }
body[data-view="settlements"] .settlements-section { grid-column: 1 / -1; }

body[data-view="expenses"] .people-section,
body[data-view="expenses"] .settlements-section { display: none; }

/* Section */
.section {
  background: var(--surface);
  border-radius: calc(var(--radius) * 0.95);
  padding: clamp(1rem, 3vw, 2rem);
  box-shadow: var(--shadow-soft);
  border: 1px solid var(--border);
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: clamp(0.5rem, 1.5vw, 1rem);
  margin-bottom: clamp(1rem, 2vw, 1.5rem);
  padding-bottom: clamp(0.5rem, 1vw, 1rem);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.section-header h2 {
  margin: 0;
  font-size: clamp(1.1rem, 2vw, 1.25rem);
  font-weight: 600;
}

/* Buttons */
.add-person-btn,
.add-expense-btn {
  display: flex;
  align-items: center;
  gap: clamp(4px, 1vw, 8px);
  background: var(--accent);
  color: #fff;
  border: none;
  padding: clamp(9px, 1.5vw, 12px) clamp(14px, 2.5vw, 18px);
  border-radius: 999px;
  font-size: clamp(0.85rem, 1.5vw, 0.9rem);
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: var(--shadow-soft);
  transition: background 0.2s ease, box-shadow 0.2s ease;
  min-height: 44px;
}

.add-person-btn:hover,
.add-expense-btn:hover {
  background: var(--accent-strong);
  box-shadow: var(--shadow);
}

/* People */
.people-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: clamp(0.5rem, 1vw, 0.75rem);
}

.person {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: clamp(0.5rem, 1.5vw, 1rem);
  padding: clamp(12px, 2vw, 16px) clamp(14px, 2.5vw, 18px);
  border-radius: calc(var(--radius) * 0.7);
  background: var(--surface);
  border: 1.5px solid var(--border);
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
  box-shadow: var(--shadow-soft);
  min-height: 56px;
  flex-wrap: wrap;
}

.person-clickable {
  cursor: pointer;
}

.person-clickable:hover {
  background: var(--surface-muted);
  border-color: var(--accent);
  box-shadow: var(--shadow);
}

.person-info {
  display: flex;
  align-items: center;
  gap: clamp(0.5rem, 1.5vw, 1rem);
  flex: 1;
  min-width: 0;
}

.person-name-section {
  flex: 1;
  min-width: 0;
}

.person .name {
  font-weight: 600;
  font-size: clamp(0.9rem, 1.5vw, 0.95rem);
  color: var(--text);
  display: block;
}

.person-balance-section {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  margin-left: auto;
  transition: opacity 0.2s;
}

/* Person Action Buttons */
.person-actions {
  display: none;
  align-items: center;
  gap: clamp(4px, 1vw, 6px);
  margin-left: auto;
}

.person:hover .person-actions {
  display: flex;
}

.person:hover .person-balance-section {
  opacity: 0;
  pointer-events: none;
}

.person-action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: clamp(36px, 6vw, 44px);
  height: clamp(36px, 6vw, 44px);
  min-width: 44px;
  min-height: 44px;
  padding: 6px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
  color: var(--text);
  flex-shrink: 0;
}

.person-action-btn:hover {
  background: var(--surface-muted);
  border-color: var(--accent);
}

.person-edit-btn:hover {
  background: rgba(31, 122, 140, 0.1);
  border-color: var(--accent);
  color: var(--accent);
}

.person-delete-btn:hover {
  background: rgba(194, 65, 12, 0.1);
  border-color: var(--danger);
  color: var(--danger);
}

.net-balance {
  font-weight: 700;
  font-size: clamp(0.85rem, 1.5vw, 0.9rem);
  padding: 5px 10px;
  border-radius: 6px;
  white-space: nowrap;
}

.net-credit {
  color: var(--ok);
  background: rgba(25, 135, 84, 0.12);
  border: 1px solid rgba(25, 135, 84, 0.2);
}

.net-owes {
  color: var(--danger);
  background: rgba(194, 65, 12, 0.12);
  border: 1px solid rgba(194, 65, 12, 0.2);
}

.net-settled {
  color: var(--muted);
  background: var(--surface-muted);
  border: 1px solid var(--border);
}

/* Person Menu */
.person-menu {
  position: fixed;
  display: none;
  z-index: 999;
  background: var(--surface);
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  overflow: hidden;
  min-width: 140px;
}

.person-menu[aria-hidden="false"] {
  display: block;
}

.person-menu-content {
  display: flex;
  flex-direction: column;
  padding: 4px;
}

.person-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: clamp(0.85rem, 1.5vw, 0.9rem);
  font-weight: 500;
  color: var(--text);
  text-align: left;
  border-radius: 6px;
  transition: all 0.15s;
  min-height: 44px;
}

.person-menu-item:hover {
  background: var(--surface-muted);
}

.person-menu-item.person-menu-delete {
  color: var(--danger);
}

.person-menu-item.person-menu-delete:hover {
  background: rgba(194, 65, 12, 0.12);
}

/* Expenses */
.expenses-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
  gap: clamp(0.5rem, 1.5vw, 1rem);
  margin-bottom: clamp(1rem, 2vw, 1.5rem);
  padding: clamp(0.75rem, 2vw, 1rem);
  background: var(--surface-muted);
  border-radius: calc(var(--radius) * 0.6);
  border: 1px solid var(--border);
}

.summary-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-align: center;
}

.summary-label {
  font-size: clamp(0.7rem, 1.2vw, 0.75rem);
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.summary-value {
  font-size: clamp(1.1rem, 2vw, 1.25rem);
  font-weight: 700;
  color: var(--text);
}

.expenses-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: clamp(0.5rem, 1.5vw, 1rem);
}

.expense {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: clamp(0.5rem, 1.5vw, 1rem);
  padding: clamp(0.75rem, 2vw, 1rem);
  border-radius: calc(var(--radius) * 0.7);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all 0.2s;
  flex-wrap: wrap;
  min-height: 56px;
}

.expense:hover {
  background: var(--surface-muted);
  border-color: var(--accent);
  box-shadow: var(--shadow-soft);
}

.expense.settled {
  opacity: 0.6;
}

.expense-status-icon {
  width: clamp(28px, 5vw, 32px);
  height: clamp(28px, 5vw, 32px);
  flex-shrink: 0;
  border-radius: 6px;
  background: rgba(31, 122, 140, 0.12);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
}

.expense.settled .expense-status-icon {
  background: rgba(25, 135, 84, 0.12);
  color: var(--ok);
}

.expense-left {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  min-width: 0;
}

.expense .desc {
  font-weight: 600;
  font-size: clamp(0.9rem, 1.5vw, 0.95rem);
}

.meta {
  font-size: clamp(0.8rem, 1.3vw, 0.85rem);
  color: var(--muted);
}

.amount {
  font-weight: 700;
  font-size: clamp(0.95rem, 1.7vw, 1.1rem);
}

/* Debts */
.debt-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: clamp(0.5rem, 1.5vw, 1rem);
}

.debt-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: clamp(0.5rem, 1.5vw, 1rem);
  padding: clamp(0.75rem, 2vw, 1rem);
  background: var(--surface-muted);
  border-radius: calc(var(--radius) * 0.7);
  border: 1px solid var(--border);
  transition: all 0.2s;
  flex-wrap: wrap;
  min-height: 56px;
}

.debt-item:hover {
  background: var(--surface);
  border-color: var(--accent);
  box-shadow: var(--shadow-soft);
}

.debt-status-icon {
  width: clamp(32px, 5vw, 40px);
  height: clamp(32px, 5vw, 40px);
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-strong) 100%);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: clamp(0.9rem, 1.5vw, 1rem);
  flex-shrink: 0;
}

.debt-info {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  flex-wrap: wrap;
}

.debt-person {
  font-weight: 600;
  font-size: clamp(0.9rem, 1.5vw, 1rem);
}

.debt-arrow {
  color: var(--muted);
  font-size: clamp(1rem, 2vw, 1.2rem);
}

.debt-amount {
  font-weight: 700;
  color: var(--text);
  font-size: clamp(1rem, 2vw, 1.1rem);
  margin-left: auto;
}

.settle-debt-btn,
.settle-all-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: clamp(8px, 1.5vw, 10px) clamp(12px, 2vw, 18px);
  border-radius: 999px;
  font-size: clamp(0.85rem, 1.5vw, 0.9rem);
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s ease, box-shadow 0.2s ease;
  white-space: nowrap;
  min-height: 44px;
}

.settle-debt-btn:hover,
.settle-all-btn:hover {
  background: var(--accent-strong);
  box-shadow: var(--shadow);
}

/* Modals */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: clamp(1rem, 3vw, 1.5rem);
}

.modal-overlay[aria-hidden="false"] {
  display: flex;
}

.modal-content {
  position: relative;
  background: #fff;
  border-radius: var(--radius);
  padding: clamp(1rem, 3vw, 1.5rem);
  box-shadow: var(--shadow);
  border: 1px solid rgba(231, 229, 221, 0.9);
  max-width: min(500px, 95vw);
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  animation: modalIn 0.25s ease;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: clamp(1rem, 2vw, 1.5rem);
  gap: 1rem;
  position: relative;
  z-index: 1;
  padding: clamp(0.75rem, 2vw, 1rem);
  border-radius: 12px;
  border: 1px solid rgba(229, 224, 214, 0.8);
  background: var(--surface-muted);
}

.modal-header h2 {
  margin: 0;
  font-size: clamp(1.25rem, 2.5vw, 1.5rem);
  font-weight: 700;
}

.modal-title-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  flex: 1;
}

.modal-eyebrow {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  font-weight: 700;
  color: var(--accent);
}

.modal-subtitle {
  margin: 0;
  color: var(--muted);
  font-size: clamp(0.85rem, 1.4vw, 0.95rem);
  max-width: 34ch;
}

.person-details-modal .modal-header,
.expense-details-modal .modal-header {
  padding: clamp(0.5rem, 1.5vw, 0.75rem) 0 clamp(0.75rem, 2vw, 1rem);
  border: none;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  background: transparent;
}

.person-details-modal .modal-eyebrow,
.expense-details-modal .modal-eyebrow {
  color: var(--muted);
  letter-spacing: 0.14em;
  font-weight: 600;
}

.person-details-modal .modal-header h2,
.expense-details-modal .modal-header h2 {
  font-weight: 600;
}

.close-modal {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  min-width: 44px;
  min-height: 44px;
  border-radius: 999px;
  position: relative;
  z-index: 1;
}

.close-modal:hover {
  color: var(--text);
  background: rgba(0, 0, 0, 0.05);
}

@keyframes modalIn {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@media (prefers-reduced-motion: reduce) {
  .modal-content {
    animation: none;
  }
}

/* Forms */
.form label {
  display: block;
  margin-bottom: clamp(0.75rem, 1.5vw, 1rem);
  font-size: clamp(0.85rem, 1.5vw, 0.9rem);
  font-weight: 600;
}

.form-section {
  padding: clamp(0.75rem, 2vw, 1rem);
  border-radius: 12px;
  border: 1px solid rgba(229, 224, 214, 0.7);
  background: var(--surface-muted);
  margin-bottom: clamp(0.75rem, 1.5vw, 1rem);
  position: relative;
  z-index: 1;
}

.form-grid {
  display: grid;
  gap: clamp(0.75rem, 1.5vw, 1rem);
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.form-grid .span-2 {
  grid-column: 1 / -1;
}

.form-helper {
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.label-with-icon {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.form input[type="text"],
.form input[type="number"],
.form select {
  width: 100%;
  padding: clamp(10px, 2vw, 14px);
  border-radius: 8px;
  border: 1px solid var(--border);
  font-size: clamp(0.9rem, 1.5vw, 0.95rem);
  min-height: 44px;
  background: var(--surface);
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.form input[type="text"]:focus,
.form input[type="number"]:focus,
.form select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(31, 122, 140, 0.18);
  background: #fff;
}

.participants-section {
  border: 1px solid rgba(229, 224, 214, 0.8);
  padding: clamp(0.9rem, 2vw, 1.1rem);
  border-radius: 12px;
  margin: clamp(0.75rem, 1.5vw, 1rem) 0;
  background: var(--surface-muted);
}

.participants-section legend,
.split-mode legend {
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.7rem;
  color: var(--accent-strong);
}

.participants-list {
  display: flex;
  flex-wrap: wrap;
  gap: clamp(0.5rem, 1vw, 0.75rem);
  margin-top: clamp(0.5rem, 1vw, 0.75rem);
}

.participant-checkbox {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: clamp(6px, 1.5vw, 8px) clamp(10px, 2vw, 14px);
  background: var(--surface);
  border-radius: 999px;
  cursor: pointer;
  font-size: clamp(0.85rem, 1.5vw, 0.9rem);
  min-height: 44px;
  border: 1px solid rgba(229, 224, 214, 0.9);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.participant-checkbox input {
  accent-color: var(--accent);
}

.participant-checkbox:hover {
  background: #fff;
  border-color: var(--accent);
  box-shadow: var(--shadow-soft);
}

.split-mode {
  display: flex;
  gap: 10px;
  margin: clamp(0.75rem, 1.5vw, 1rem) 0;
  flex-wrap: wrap;
}

.split-mode label {
  font-size: clamp(0.85rem, 1.5vw, 0.9rem);
  cursor: pointer;
  padding: clamp(7px, 1.5vw, 9px) clamp(12px, 2vw, 16px);
  border-radius: 999px;
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  border: 1px solid rgba(229, 224, 214, 0.9);
  background: var(--surface);
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.split-mode input {
  accent-color: var(--accent);
}

.split-mode label:has(input:checked) {
  border-color: var(--accent);
  background: rgba(31, 122, 140, 0.12);
  color: var(--accent-strong);
  box-shadow: var(--shadow-soft);
}

.split-mode label:hover {
  background: #fff;
  border-color: var(--accent);
  box-shadow: var(--shadow-soft);
}

.custom-split {
  padding: clamp(0.75rem, 2vw, 1rem);
  background: var(--surface-muted);
  border-radius: 8px;
  border: 1px dashed var(--border);
  margin-bottom: clamp(0.75rem, 1.5vw, 1rem);
}

.custom-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin: clamp(0.5rem, 1vw, 0.75rem) 0;
}

.form-actions {
  display: flex;
  gap: clamp(0.5rem, 1vw, 0.75rem);
  margin-top: clamp(0.75rem, 1.5vw, 1rem);
  flex-wrap: wrap;
}

.form-actions.spread {
  justify-content: space-between;
  width: 100%;
}

.primary {
  background: var(--accent);
  color: #fff;
  padding: clamp(9px, 1.5vw, 11px) clamp(14px, 2vw, 18px);
  border-radius: 999px;
  border: 0;
  cursor: pointer;
  font-weight: 600;
  min-height: 44px;
  transition: background 0.2s ease, box-shadow 0.2s ease;
}

.primary:hover {
  background: var(--accent-strong);
  box-shadow: var(--shadow);
}

.muted {
  background: transparent;
  border: 1px solid var(--border);
  padding: clamp(8px, 1.5vw, 10px) clamp(12px, 2vw, 16px);
  border-radius: 8px;
  cursor: pointer;
  min-height: 44px;
  color: var(--text);
}

.muted:hover {
  background: var(--surface-muted);
}

/* Expense Details Modal */
.expense-details-modal {
  max-width: min(540px, 95vw);
  padding: 0;
  overflow-y: auto;
}

.expense-hero {
  background: var(--surface);
  color: var(--text);
  padding: clamp(1.5rem, 3vw, 2rem);
  text-align: center;
  position: relative;
  border-bottom: 1px solid var(--border);
}

.expense-hero::after {
  content: none;
}

.expense-hero-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: clamp(0.5rem, 1.5vw, 1rem);
  gap: clamp(0.5rem, 1.5vw, 1rem);
}

.expense-hero-title {
  margin: 0;
  font-size: clamp(1.1rem, 2.5vw, 1.25rem);
  font-weight: 700;
  text-align: left;
  flex: 1;
  line-height: 1.3;
}

.expense-status {
  padding: 4px 10px;
  border-radius: 999px;
  font-size: clamp(0.75rem, 1.5vw, 0.8rem);
  font-weight: 600;
}

.expense-status.settled {
  background: rgba(25, 135, 84, 0.12);
  color: var(--ok);
}

.expense-status.unsettled {
  background: rgba(194, 65, 12, 0.12);
  color: var(--danger);
}

.expense-hero-amount {
  font-size: clamp(2rem, 6vw, 3rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: clamp(0.5rem, 1.5vw, 1rem) 0;
  line-height: 1;
}

.expense-hero-subtitle {
  font-size: clamp(0.9rem, 1.5vw, 0.95rem);
  color: var(--muted);
  opacity: 1;
  font-weight: 500;
}

.expense-info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: clamp(0.5rem, 1.5vw, 1rem);
  padding: clamp(1rem, 2.5vw, 1.5rem);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.expense-info-card {
  display: flex;
  gap: 12px;
  padding: clamp(0.75rem, 2vw, 1rem);
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: 10px;
  align-items: flex-start;
}

.info-card-icon {
  width: 40px;
  height: 40px;
  background: rgba(31, 122, 140, 0.12);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  flex-shrink: 0;
}

.info-card-content {
  flex: 1;
  min-width: 0;
}

.info-card-label {
  font-size: clamp(0.7rem, 1.2vw, 0.75rem);
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}

.info-card-value {
  font-size: clamp(0.95rem, 1.8vw, 1rem);
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
}

.expense-split-section {
  padding: clamp(1rem, 3vw, 1.5rem);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.split-section-header {
  display: flex;
  align-items: center;
  gap: clamp(0.5rem, 1vw, 0.75rem);
  margin-bottom: clamp(0.75rem, 2vw, 1rem);
}

.split-section-header h4 {
  margin: 0;
  font-size: clamp(0.95rem, 1.8vw, 1rem);
  font-weight: 600;
}

.split-participants-list {
  display: flex;
  flex-direction: column;
  gap: clamp(0.5rem, 1vw, 0.75rem);
}

.split-participant-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: clamp(0.5rem, 1.5vw, 1rem);
  padding: clamp(0.75rem, 2vw, 1rem);
  background: var(--surface-muted);
  border-radius: calc(var(--radius) * 0.7);
  border: 1px solid var(--border);
  flex-wrap: wrap;
}

.participant-card-left {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
}

.participant-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(31, 122, 140, 0.12);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.1rem;
  flex-shrink: 0;
}

.participant-name {
  font-weight: 600;
  font-size: clamp(0.9rem, 1.5vw, 0.95rem);
  color: var(--text);
}

.payer-badge {
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.7rem;
  font-weight: 700;
  background: var(--ok);
  color: #fff;
  text-transform: uppercase;
}

.participant-amount {
  font-weight: 700;
  font-size: clamp(0.95rem, 1.8vw, 1rem);
  color: var(--text);
}

.participant-card-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.settle-participant-btn {
  padding: 6px 16px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  background: var(--accent);
  color: #fff;
  border: none;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
  white-space: nowrap;
}

.settle-participant-btn:hover {
  background: var(--accent-strong);
}

.settle-participant-btn:active {
  transform: scale(0.96);
}

.expense-details-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: clamp(0.5rem, 1vw, 0.75rem);
  padding: clamp(1rem, 2vw, 1.5rem);
  background: var(--surface);
  border-top: 1px solid var(--border);
}

.expense-action-edit,
.expense-action-primary,
.expense-action-danger {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: clamp(10px, 2vw, 12px);
  border-radius: 8px;
  font-size: clamp(0.85rem, 1.5vw, 0.9rem);
  font-weight: 600;
  cursor: pointer;
  border: none;
  white-space: nowrap;
  min-height: 44px;
}

.expense-action-edit {
  background: var(--accent);
  color: #fff;
  box-shadow: var(--shadow-soft);
}

.expense-action-edit:hover {
  background: var(--accent-strong);
}

.expense-action-primary {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--accent);
}

.expense-action-primary:hover {
  background: var(--surface-muted);
  border-color: var(--accent);
}

.expense-action-danger {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--danger);
}

.expense-action-danger:hover {
  background: rgba(194, 65, 12, 0.1);
  border-color: var(--danger);
}

/* Person Details Modal */
.person-details-modal {
  max-width: min(540px, 95vw);
  padding: 0;
  overflow-y: auto;
  max-height: 90vh;
}

.person-hero {
  background: var(--surface);
  color: var(--text);
  padding: clamp(1.5rem, 3vw, 2rem);
  text-align: center;
  position: relative;
  border-bottom: 1px solid var(--border);
}

.person-hero::after {
  content: none;
}

.person-hero-avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: rgba(31, 122, 140, 0.12);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 2rem;
  margin: 0 auto 1rem;
  border: 1px solid var(--border);
}

.person-hero-name {
  margin: 0 0 0.75rem;
  font-size: clamp(1.25rem, 3vw, 1.5rem);
  font-weight: 700;
}

.person-hero-balance {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  margin-bottom: 1.25rem;
}

.person-hero-balance .balance-label {
  font-size: 0.85rem;
  color: var(--muted);
  opacity: 1;
  font-weight: 500;
}

.person-hero-balance .balance-amount {
  font-size: clamp(1.75rem, 5vw, 2.25rem);
  font-weight: 800;
  letter-spacing: -0.02em;
}

.person-hero-balance.balanced .balance-amount,
.person-hero-balance.in-credit .balance-amount {
  color: var(--ok);
}

.person-hero-balance.owes-money .balance-amount {
  color: var(--danger);
}

.person-hero-stats {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: clamp(1rem, 3vw, 2rem);
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.person-hero-stats .stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.person-hero-stats .stat-label {
  font-size: 0.75rem;
  opacity: 0.8;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}

.person-hero-stats .stat-value {
  font-size: clamp(1rem, 2vw, 1.15rem);
  font-weight: 700;
}

.person-hero-stats .stat-divider {
  width: 1px;
  height: 40px;
  background: var(--border);
}

/* Transactions Section */
.person-transactions-section {
  padding: clamp(1rem, 2vw, 1.5rem);
  background: var(--surface);
  border-top: 1px solid var(--border);
}

.transactions-group {
  margin-bottom: clamp(1rem, 2vw, 1.5rem);
}

.transactions-group:last-child {
  margin-bottom: 0;
}

.transactions-group-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: clamp(0.5rem, 1vw, 0.75rem);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.transactions-group-header svg {
  color: var(--accent);
}

.transactions-list {
  display: flex;
  flex-direction: column;
  gap: clamp(0.5rem, 1vw, 0.625rem);
}

.person-transaction-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: clamp(0.75rem, 2vw, 1rem);
  padding: clamp(0.75rem, 2vw, 1rem);
  background: var(--surface);
  border-radius: 10px;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all 0.15s ease;
}

.person-transaction-card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-soft);
}

.person-transaction-card.settled {
  opacity: 0.7;
}

.transaction-card-left {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
}

.transaction-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.transaction-icon.paid {
  background: rgba(25, 135, 84, 0.12);
  color: var(--ok);
}

.transaction-icon.owes {
  background: rgba(194, 65, 12, 0.12);
  color: var(--danger);
}

.transaction-info {
  flex: 1;
  min-width: 0;
}

.transaction-description {
  font-weight: 600;
  font-size: clamp(0.875rem, 1.5vw, 0.925rem);
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  align-items: center;
  gap: 8px;
}

.transaction-meta {
  font-size: clamp(0.75rem, 1.2vw, 0.8rem);
  color: var(--muted);
  margin-top: 2px;
}

.transaction-card-right {
  text-align: right;
  flex-shrink: 0;
}

.transaction-amount {
  font-weight: 700;
  font-size: clamp(0.925rem, 1.6vw, 1rem);
}

.transaction-amount.paid {
  color: var(--ok);
}

.transaction-amount.owes {
  color: #f57c00;
}

.transaction-share {
  font-size: clamp(0.7rem, 1.1vw, 0.75rem);
  color: var(--muted);
  margin-top: 2px;
}

.settled-badge {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.65rem;
  font-weight: 700;
  background: rgba(25, 135, 84, 0.12);
  color: var(--ok);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.no-transactions {
  padding: clamp(1rem, 2vw, 1.5rem);
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
  background: var(--surface);
  border-radius: 10px;
  border: 1px dashed var(--border);
}

/* Person Details Actions */
.person-details-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: clamp(0.5rem, 1vw, 0.75rem);
  padding: clamp(1rem, 2vw, 1.5rem);
  background: var(--surface);
  border-top: 1px solid var(--border);
}

.person-action-edit,
.person-action-settle {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: clamp(10px, 2vw, 12px);
  border-radius: 8px;
  font-size: clamp(0.85rem, 1.5vw, 0.9rem);
  font-weight: 600;
  cursor: pointer;
  border: none;
  white-space: nowrap;
  min-height: 44px;
  transition: all 0.15s ease;
}

.person-action-edit {
  background: var(--accent);
  color: #fff;
  box-shadow: var(--shadow-soft);
}

.person-action-edit:hover {
  background: var(--accent-strong);
}

.person-action-settle {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--ok);
}

.person-action-settle:hover {
  background: rgba(25, 135, 84, 0.12);
  border-color: var(--ok);
}

/* Additional Support Styles */
.person-number {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
  min-width: 1.5rem;
  text-align: center;
  flex-shrink: 0;
}

.person-icon {
  width: clamp(32px, 5vw, 40px);
  height: clamp(32px, 5vw, 40px);
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-strong) 100%);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: clamp(0.9rem, 1.5vw, 1rem);
  flex-shrink: 0;
}

.person-details-section {
  display: flex;
  flex-direction: column;
  gap: clamp(0.5rem, 1vw, 0.75rem);
  margin-top: clamp(0.5rem, 1vw, 0.75rem);
}

.detail-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: clamp(0.5rem, 1.5vw, 1rem);
  padding: clamp(0.5rem, 1.5vw, 0.75rem);
  background: var(--surface-muted);
  border-radius: 6px;
  flex-wrap: wrap;
}

.detail-label {
  font-size: clamp(0.8rem, 1.3vw, 0.85rem);
  color: var(--muted);
  font-weight: 600;
}

.detail-value {
  font-size: clamp(0.85rem, 1.5vw, 0.9rem);
  font-weight: 600;
  color: var(--text);
}

.split-participant {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: clamp(0.5rem, 1.5vw, 1rem);
  padding: clamp(0.5rem, 1.5vw, 0.75rem);
  flex-wrap: wrap;
}

.split-participant-name {
  font-weight: 600;
  font-size: clamp(0.85rem, 1.5vw, 0.9rem);
  color: var(--text);
}

.split-participant-amount {
  font-weight: 700;
  font-size: clamp(0.9rem, 1.5vw, 0.95rem);
  color: var(--text);
}

.info-card-time {
  font-size: clamp(0.8rem, 1.3vw, 0.85rem);
  color: var(--muted);
}

.participant-percentage {
  font-size: clamp(0.75rem, 1.2vw, 0.8rem);
  color: var(--muted);
  font-weight: 500;
  margin-left: 4px;
}

.split-section-icon {
  width: clamp(20px, 3vw, 24px);
  height: clamp(20px, 3vw, 24px);
  color: var(--accent);
  flex-shrink: 0;
}

/* Share Modal */
.share-button {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--accent);
  color: white;
  border: none;
  padding: clamp(9px, 1.5vw, 11px) clamp(16px, 2vw, 20px);
  border-radius: 999px;
  font-size: clamp(0.85rem, 1.5vw, 0.9375rem);
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s ease, box-shadow 0.2s ease;
  box-shadow: var(--shadow-soft);
  min-height: 44px;
}

.share-button:hover {
  background: var(--accent-strong);
  box-shadow: var(--shadow);
}

.share-modal {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: clamp(1rem, 3vw, 1.5rem);
}

.share-modal.active {
  display: flex;
}

.share-modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
}

.share-modal-content {
  position: relative;
  background: var(--surface);
  border-radius: 16px;
  box-shadow: var(--shadow);
  max-width: min(500px, 95vw);
  width: 100%;
  overflow: hidden;
}

.share-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: clamp(1rem, 3vw, 1.5rem);
  border-bottom: 1px solid var(--border);
}

.share-modal-header h3 {
  font-size: clamp(1.25rem, 2.5vw, 1.5rem);
  font-weight: 700;
  color: var(--text);
  margin: 0;
}

.share-modal-close {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  color: var(--muted);
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.share-modal-close:hover {
  background: var(--surface-muted);
  color: var(--text);
}

.share-modal-body {
  padding: clamp(1rem, 3vw, 1.5rem);
}

.share-modal-description {
  color: var(--muted);
  margin-bottom: clamp(1rem, 2vw, 1.25rem);
  line-height: 1.6;
}

.share-link-container {
  display: flex;
  gap: 12px;
  background: var(--surface-muted);
  padding: 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  flex-wrap: wrap;
}

.share-link-input {
  flex: 1;
  background: transparent;
  border: none;
  padding: 8px;
  font-size: clamp(0.85rem, 1.5vw, 0.9375rem);
  color: var(--text);
  outline: none;
  font-family: 'Courier New', monospace;
  min-width: 0;
}

.copy-button {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--accent);
  color: white;
  border: none;
  padding: clamp(9px, 1.5vw, 11px) clamp(14px, 2vw, 18px);
  border-radius: 999px;
  font-size: clamp(0.85rem, 1.5vw, 0.9375rem);
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  min-height: 44px;
  transition: background 0.2s ease, transform 0.2s ease;
}

.copy-button:hover {
  background: var(--accent-strong);
  transform: translateY(-1px);
}

.copy-button.copied {
  background: var(--ok);
}

/* Header Actions */
.header-actions-wrap {
  display: flex;
  align-items: center;
  gap: clamp(8px, 1.5vw, 12px);
  position: relative;
}

.header-actions-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  box-shadow: var(--shadow-soft);
  transition: all 0.2s ease;
}

.header-actions-toggle:hover {
  background: var(--surface-muted);
  border-color: var(--accent);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: clamp(8px, 1.5vw, 12px);
}

/* Currency Button */
.currency-button {
  display: none;
  align-items: center;
  gap: 6px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  padding: clamp(9px, 1.5vw, 11px) clamp(14px, 2vw, 18px);
  border-radius: 999px;
  font-size: clamp(0.85rem, 1.5vw, 0.9rem);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  min-height: 44px;
  box-shadow: var(--shadow-soft);
}

.currency-button:hover {
  background: var(--surface-muted);
  border-color: var(--accent);
}

.currency-button svg {
  color: var(--muted);
}

@media (max-width: 640px) {
  .header-actions-toggle {
    display: inline-flex;
  }

  .header-actions {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    flex-direction: column;
    align-items: stretch;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 10px;
    box-shadow: var(--shadow);
    display: none;
    min-width: 180px;
    z-index: 20;
  }

  .app-header[data-actions-open="true"] .header-actions {
    display: flex;
  }

  .app-header[data-actions-open="true"] .header-actions-toggle {
    border-color: var(--accent);
    box-shadow: 0 12px 24px rgba(17, 24, 39, 0.14);
  }

  .header-actions .currency-button,
  .header-actions .share-button {
    width: 100%;
    justify-content: flex-start;
  }
}

/* Currency Modal */
.currency-modal {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: clamp(1rem, 3vw, 1.5rem);
}

.currency-modal.active {
  display: flex;
}

.currency-modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
}

.currency-modal-content {
  position: relative;
  background: var(--surface);
  border-radius: 16px;
  box-shadow: var(--shadow);
  max-width: min(440px, 95vw);
  width: 100%;
  max-height: 80vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.currency-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: clamp(1rem, 3vw, 1.5rem);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.currency-modal-header h3 {
  font-size: clamp(1.25rem, 2.5vw, 1.5rem);
  font-weight: 700;
  color: var(--text);
  margin: 0;
}

.currency-modal-close {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  color: var(--muted);
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.currency-modal-close:hover {
  background: var(--surface-muted);
  color: var(--text);
}

.currency-modal-body {
  padding: clamp(1rem, 3vw, 1.5rem);
  overflow-y: auto;
}

.currency-modal-description {
  color: var(--muted);
  margin-bottom: clamp(0.75rem, 1.5vw, 1rem);
  line-height: 1.6;
  font-size: clamp(0.85rem, 1.5vw, 0.9rem);
}

.currency-search-container {
  margin-bottom: clamp(0.75rem, 1.5vw, 1rem);
}

.currency-search {
  width: 100%;
  padding: 12px 14px;
  font-size: 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-muted);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s, background 0.15s;
}

.currency-search:focus {
  border-color: var(--accent);
  background: var(--surface);
}

.currency-search::placeholder {
  color: var(--muted);
}

.currency-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.currency-option {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: clamp(10px, 2vw, 14px);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s;
  width: 100%;
  text-align: left;
  min-height: 52px;
}

.currency-option:hover {
  background: var(--surface-muted);
  border-color: var(--accent);
}

.currency-option.selected {
  background: rgba(31, 122, 140, 0.08);
  border-color: var(--accent);
}

.currency-symbol {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, rgba(31, 122, 140, 0.15) 0%, rgba(21, 87, 102, 0.25) 100%);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: clamp(1rem, 2vw, 1.1rem);
  color: var(--accent);
  flex-shrink: 0;
}

.currency-option.selected .currency-symbol {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-strong) 100%);
  color: #fff;
}

.currency-info {
  flex: 1;
  min-width: 0;
}

.currency-code {
  font-weight: 700;
  font-size: clamp(0.9rem, 1.5vw, 0.95rem);
  color: var(--text);
}

.currency-name {
  font-size: clamp(0.8rem, 1.3vw, 0.85rem);
  color: var(--muted);
}

.currency-check {
  width: 24px;
  height: 24px;
  color: var(--accent);
  flex-shrink: 0;
  opacity: 0;
}

.currency-option.selected .currency-check {
  opacity: 1;
}

.currency-no-results {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--muted);
  font-size: 0.9rem;
}

/* Footer */
.app-footer {
  width: 100%;
  text-align: center;
  margin-top: clamp(1.5rem, 3vw, 2rem);
  padding: clamp(1rem, 2vw, 1.5rem) 0;
  color: var(--muted);
  font-size: clamp(0.75rem, 1.2vw, 0.8rem);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
}

.footer-links-inline {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.footer-links-inline a {
  color: var(--muted);
  text-decoration: none;
  font-weight: 500;
  transition: color 0.2s ease;
}

.footer-links-inline a:hover {
  color: var(--accent);
}

.footer-links-inline a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 2px;
}

.footer-dot {
  color: var(--border);
}

.footer-copyright-inline {
  margin: 0;
  opacity: 0.7;
}

/* Settle Modal */
.settle-modal {
  max-width: min(400px, 95vw);
}

.settle-modal-body {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.settle-summary-card {
  padding: 1rem;
  border-radius: 14px;
  border: 1px solid rgba(229, 224, 214, 0.9);
  background: var(--surface-muted);
  box-shadow: var(--shadow-soft);
}

.settle-debt-info {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-size: 1.1rem;
  font-weight: 600;
}

.settle-from {
  color: var(--danger);
}

.settle-arrow {
  color: var(--muted);
  font-weight: 400;
}

.settle-to {
  color: var(--ok);
}

.settle-total {
  text-align: center;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
}

.settle-total span {
  color: var(--accent);
}

.settle-options {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.settle-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 1rem;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
  transition: all 0.2s;
  font-size: 0.95rem;
}

.settle-option:hover {
  border-color: var(--accent);
  background: rgba(31, 122, 140, 0.08);
}

.settle-option:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(31, 122, 140, 0.15);
}

.settle-option-full {
  border-color: var(--ok);
  background: rgba(26, 162, 96, 0.06);
}

.settle-option-full:hover {
  background: rgba(26, 162, 96, 0.12);
  border-color: var(--ok);
}

.settle-option.active {
  border-color: var(--accent);
  background: rgba(31, 122, 140, 0.12);
  box-shadow: 0 12px 32px rgba(21, 87, 102, 0.18);
}

.settle-option-label {
  font-weight: 600;
}

.settle-option-amount {
  font-weight: 700;
  color: var(--ok);
}

.settle-partial-input {
  display: none;
  flex-direction: column;
  gap: 1rem;
  padding: 1rem;
  background: var(--surface-muted);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.settle-partial-input[aria-hidden="false"] {
  display: flex;
}

.settle-partial-input label {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  font-weight: 600;
  font-size: 0.9rem;
}

.settle-partial-input input {
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 1rem;
  width: 100%;
  background: var(--surface);
}

.settle-partial-input input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(31, 122, 140, 0.15);
}

.settle-modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}
