* { box-sizing: border-box; }
:root {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #111827;
  background: #f3f4f6;
}
body { margin: 0; min-height: 100vh; }
button, input, select { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 18px;
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid #e5e7eb;
}
.topbar h1 { margin: 0; font-size: 22px; }
.eyebrow { font-size: 11px; letter-spacing: .12em; color: #6b7280; font-weight: 800; }
.container { width: min(900px, 100%); margin: 0 auto; padding: 18px 14px 60px; }

.card {
  background: white; border: 1px solid #e5e7eb; border-radius: 18px;
  padding: 18px; box-shadow: 0 8px 28px rgba(17,24,39,.05); margin-bottom: 14px;
}
.hero { padding: 24px; }
.hero h2 { font-size: clamp(28px, 7vw, 44px); line-height: 1.05; margin: 10px 0; max-width: 650px; }
.badge {
  display: inline-block; background: #eef2ff; color: #3730a3; border-radius: 999px;
  padding: 7px 10px; font-size: 12px; font-weight: 800;
}
.muted { color: #6b7280; }
.stack { display: grid; gap: 12px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
label { display: grid; gap: 6px; font-size: 13px; font-weight: 700; color: #374151; }
input, select {
  width: 100%; padding: 12px 13px; border: 1px solid #d1d5db; border-radius: 12px;
  background: white; color: #111827; outline: none;
}
input:focus, select:focus { border-color: #111827; box-shadow: 0 0 0 3px rgba(17,24,39,.08); }
button { border: 0; border-radius: 12px; padding: 11px 14px; font-weight: 800; }
.primary { background: #111827; color: white; }
.secondary { background: #eef2f7; color: #111827; }
.danger { background: #fee2e2; color: #991b1b; }
.icon-btn { background: #111827; color: white; }
.feature-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px;
}
.feature-grid div { padding: 14px; border-radius: 14px; background: #f9fafb; display: grid; gap: 4px; }
.feature-grid span { font-size: 12px; color: #6b7280; }

.trip-head { display: flex; justify-content: space-between; gap: 12px; align-items: center; margin-bottom: 12px; }
.trip-head h2 { margin: 2px 0 0; }
.tabs {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px;
  background: #e5e7eb; padding: 5px; border-radius: 14px; margin-bottom: 14px;
}
.tab { background: transparent; color: #4b5563; padding: 9px 6px; }
.tab.active { background: white; color: #111827; box-shadow: 0 2px 8px rgba(17,24,39,.08); }
.section-head { display: flex; justify-content: space-between; align-items: center; }

.expense-list, .member-list, .settlement-list { display: grid; gap: 10px; }
.expense-item, .member-item, .settlement-item {
  display: flex; justify-content: space-between; gap: 12px; align-items: center;
  padding: 14px; border: 1px solid #e5e7eb; border-radius: 14px;
}
.expense-item strong, .settlement-item strong { display: block; }
.expense-meta { font-size: 12px; color: #6b7280; margin-top: 3px; }
.amount { font-variant-numeric: tabular-nums; white-space: nowrap; }
.split-editor { display: grid; gap: 8px; padding: 12px; background: #f9fafb; border-radius: 14px; }
.split-row { display: grid; grid-template-columns: 1fr 140px; gap: 10px; align-items: center; }
.split-row.checkbox { grid-template-columns: auto 1fr; }
.split-row input[type="checkbox"] { width: 20px; height: 20px; }

.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.stat { display: grid; gap: 6px; }
.stat span { color: #6b7280; font-size: 13px; }
.stat strong { font-size: 30px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 620px; }
th, td { text-align: left; padding: 12px 10px; border-bottom: 1px solid #e5e7eb; }
th { font-size: 12px; color: #6b7280; }
.positive { color: #047857; font-weight: 800; }
.negative { color: #b91c1c; font-weight: 800; }
.notice { padding: 14px; border-radius: 14px; background: #fff7ed; border: 1px solid #fed7aa; margin-bottom: 14px; }
.notice code { word-break: break-all; }
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: #111827; color: white; padding: 10px 14px; border-radius: 999px;
  box-shadow: 0 8px 30px rgba(0,0,0,.25); z-index: 100;
}
.empty { padding: 18px; text-align: center; color: #6b7280; border: 1px dashed #d1d5db; border-radius: 14px; }

@media (max-width: 680px) {
  .feature-grid { grid-template-columns: 1fr 1fr; }
  .grid2 { grid-template-columns: 1fr; }
  .trip-head { align-items: flex-start; flex-direction: column; }
  .trip-head .row { width: 100%; }
  .trip-head .row button { flex: 1; }
  .stats-grid { grid-template-columns: 1fr; }
  .split-row { grid-template-columns: 1fr 110px; }
}

/* Trip history / archive */
.brand-btn {
  appearance: none; border: 0; background: transparent; padding: 0; text-align: left;
  display: grid; gap: 1px; color: #111827;
}
.brand-btn strong { font-size: 22px; line-height: 1.05; }
.hero h1 { font-size: clamp(28px, 7vw, 44px); line-height: 1.05; margin: 10px 0; max-width: 650px; }
.small { font-size: 12px; margin: 4px 0 0; }
.history-card { padding-bottom: 8px; }
.history-head h2 { margin: 0; font-size: 21px; }
.history-count { font-size: 12px; font-weight: 800; color: #6b7280; background: #f3f4f6; padding: 6px 9px; border-radius: 999px; }
.history-section { margin: 18px 0; }
.history-section h3 { margin: 0 0 9px; font-size: 14px; display: flex; align-items: center; gap: 7px; }
.status-dot { width: 9px; height: 9px; border-radius: 999px; display: inline-block; }
.active-dot { background: #2563eb; }
.settled-dot { background: #10b981; }
.history-list { display: grid; gap: 10px; }
.history-item { border: 1px solid #e5e7eb; border-radius: 16px; overflow: hidden; background: #fff; }
.history-main {
  width: 100%; display: grid; grid-template-columns: auto minmax(0,1fr) auto auto;
  gap: 10px; align-items: center; text-align: left; background: white; border-radius: 0;
  padding: 14px;
}
.history-main:active { background: #f9fafb; }
.history-icon { font-size: 24px; }
.history-info { display: grid; min-width: 0; gap: 4px; }
.history-info strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 15px; }
.history-info span { color: #6b7280; font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.history-total { font-weight: 900; font-variant-numeric: tabular-nums; white-space: nowrap; }
.history-arrow { font-size: 26px; color: #9ca3af; font-weight: 400; }
.history-actions { display: flex; flex-wrap: wrap; gap: 6px; padding: 9px 12px 12px 48px; background: #fbfbfc; border-top: 1px solid #f3f4f6; }
.mini { padding: 7px 10px; font-size: 11px; border-radius: 9px; }
.ghost-danger { background: transparent; color: #b91c1c; }
.history-empty { border: 1px dashed #d1d5db; border-radius: 14px; color: #9ca3af; font-size: 12px; padding: 14px; text-align: center; }
.trip-title-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.trip-title-row h2 { margin: 2px 0 0; }
.trip-status { font-size: 11px; font-weight: 900; border-radius: 999px; padding: 6px 9px; }
.trip-status.active { color: #1d4ed8; background: #dbeafe; }
.trip-status.settled { color: #047857; background: #d1fae5; }
.trip-submeta { margin-top: 5px; display: flex; gap: 10px; font-size: 12px; }
.trip-submeta span + span::before { content: "•"; margin-right: 10px; color: #d1d5db; }
.trip-actions { justify-content: flex-end; }
.settlement-controls { text-align: center; }
.settlement-controls .primary { width: min(320px, 100%); }

@media (max-width: 680px) {
  .topbar { padding: 12px 14px; }
  .history-main { grid-template-columns: auto minmax(0,1fr) auto; }
  .history-arrow { display: none; }
  .history-total { font-size: 13px; }
  .history-actions { padding-left: 12px; }
  .trip-actions { width: 100%; display: grid; grid-template-columns: 1fr 1fr; }
  .trip-actions button { width: 100%; }
}

/* Couple workspace v3 */
.couple-share-card { border-color: #dbeafe; background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%); }
.couple-share-card h3 { margin-top: 0; }

/* Group / unlimited members (v5) */
.setup-member-inputs { display: grid; gap: 9px; }
.setup-member-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 9px; }
.setup-member-row button { min-width: 64px; }
.compact-heading { margin: 3px 0; font-size: 15px; }
.import-old { border-top: 1px solid #e5e7eb; margin-top: 22px; padding-top: 14px; }
.import-old h3 { margin: 0 0 8px; font-size: 15px; }
.import-old form { margin-top: 10px; }
.import-old form input { flex: 1 1 240px; min-width: 0; }
.group-members-card h3 { margin: 0 0 6px; }
.group-members-card .member-list { margin: 16px 0; max-height: 360px; overflow-y: auto; }
.space-member-form input { flex: 1 1 220px; min-width: 0; }
.group-members-card .member-item { padding: 10px 12px; }
.group-members-card .member-item strong { overflow: hidden; overflow-wrap: anywhere; }
button:disabled { cursor: not-allowed; opacity: .5; }
@media (max-width: 680px) {
  .hero { padding: 18px; }
  .import-old form button, .space-member-form button { flex: 1 1 auto; }
}
[hidden]{display:none!important}dialog{border:0;border-radius:16px;width:min(90vw,430px);padding:24px;color:#182235}dialog::backdrop{background:#15223680}.viewer #expensesTab>.card:first-child,.viewer #membersTab>.card:first-child,.viewer .danger,.viewer .settlement-controls,.viewer #statusBtn,.viewer #copyLinkBtn,.viewer #lineShareBtn,.viewer #shareBtn,.viewer #viewLink,.viewer [data-refund]{display:none!important}.expense-item{flex-wrap:wrap}.refund-detail{width:100%;font-size:.9rem;color:#355349}#syncLabel{font-weight:650}#settlementList{margin-top:12px}
