:root {
  color-scheme: light;
  font-family: "Segoe UI", "Malgun Gothic", "Apple SD Gothic Neo", sans-serif;
  color: #192d25;
  background: #f2f5f0;
  --muted: #496158;
  --green: #176346;
  --green-deep: #104b37;
  --green-pale: #e9f4ed;
  --border: #d7e0d9;
  --input-border: #b9c9bf;
  --amber: #6d4d1b;
  --amber-pale: #fcf2db;
  --error: #a22c25;
  --radius: 1.1rem;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; line-height: 1.55; }
h1, h2, h3, h4, p, dl, dd { margin: 0; }

.wrap { width: min(100% - 2rem, 73rem); margin-inline: auto; }

.hero {
  color: #fff;
  background:
    radial-gradient(ellipse at 92% 145%, transparent 0 21%, #ffffff0c 21.5% 22%, transparent 22.5% 27%, #ffffff11 27.5% 28%, transparent 28.5% 33%, #ffffff0c 33.5% 34%, transparent 34.5% 40%, #ffffff0c 40.5% 41%, transparent 41.5%),
    linear-gradient(112deg, #123b2e, #14583f 72%, #1e6b4c);
}

.hero-inner { display: flex; align-items: center; gap: 1rem; padding-block: 2rem; }
.hero h1 { font-size: clamp(1.7rem, 2.7vw, 2.45rem); line-height: 1.24; letter-spacing: -.055em; }
.hero p { margin-top: .4rem; color: #dbeee3; font-size: .95rem; overflow-wrap: anywhere; }

.flag {
  position: relative;
  flex: 0 0 3.25rem;
  height: 3.25rem;
  border: 1px solid #ffffff38;
  border-radius: .95rem;
  background: #ffffff13;
}

.flag::before {
  position: absolute;
  top: .62rem;
  left: 1.03rem;
  width: 2px;
  height: 1.88rem;
  background: #f2fbe8;
  border-radius: 2px;
  content: "";
}

.flag::after {
  position: absolute;
  top: .7rem;
  left: 1.15rem;
  border-top: .37rem solid transparent;
  border-bottom: .37rem solid transparent;
  border-left: 1rem solid #c9eda8;
  content: "";
}

main.wrap { padding-block: 1.85rem 1.5rem; }
.tabs {
  display: flex;
  flex-wrap: wrap;
  width: fit-content;
  gap: .3rem;
  margin-bottom: .55rem;
  padding: .27rem;
  border: 1px solid var(--border);
  border-radius: .8rem;
  background: #e8eee8;
}

.tabs button {
  min-height: 2.75rem;
  border: 0;
  border-radius: .52rem;
  padding: .45rem 1rem;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.tabs button[aria-selected="true"] { color: var(--green-deep); background: #fff; box-shadow: 0 1px 4px #183e2c1a; }
.tabs button:hover:not([aria-selected="true"]) { background: #f3f7f3; }
.storage-bar { margin-bottom: 1.2rem; }
#storage-status { color: var(--muted); font-size: .875rem; }
#storage-status[data-mode="error"] { color: var(--error); }
.app-status { margin-bottom: .8rem; color: var(--green-deep); overflow-wrap: anywhere; }
.app-status:empty, #backup-status:empty { display: none; }
.home-quick, .manage-row { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .85rem; }
.home-quick h2 { font-size: clamp(1.35rem, 2.4vw, 1.7rem); letter-spacing: -.035em; }
.home-quick p { color: var(--muted); margin-top: .25rem; }
.home-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; gap: 1rem; }
.home-quick + .home-grid { margin-top: 1rem; }
.manage-list { padding: 0; margin: .65rem 0 0; list-style: none; }
.manage-list li { padding-block: .65rem; }
.manage-list li + li { border-top: 1px solid var(--border); }
.manage-list li:last-child { padding-bottom: 0; }
.manage-row > div { min-width: 0; overflow-wrap: anywhere; }
.manage-row strong { display: block; }
.manage-form { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr) auto; gap: .7rem; align-items: end; }
.setting-field, .backup-actions, #backup-status { margin-top: .65rem; }
.backup-actions + .field-note { margin-top: .5rem; }
button:disabled { cursor: not-allowed; opacity: .6; }

@media (max-width: 42rem) {
  .tabs { display: grid; width: 100%; grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .tabs button { padding-inline: .3rem; font-size: .875rem; line-height: 1.3; overflow-wrap: anywhere; }
  .home-grid { grid-template-columns: minmax(0, 1fr); }
  .manage-form { grid-template-columns: minmax(0, 1fr) minmax(0, 1.5fr); }
  .manage-form button { grid-column: 1 / -1; justify-self: start; }
}
.section-heading, .card-heading, .actions { display: flex; align-items: center; gap: .65rem; }
.section-heading { justify-content: space-between; margin-bottom: 1rem; gap: 1rem; }
.section-heading h2 { font-size: 1.55rem; letter-spacing: -.045em; }
.section-heading p { color: var(--muted); margin-top: .25rem; font-size: .95rem; }
.actions { flex-wrap: wrap; }

.button, input, select, textarea { font: inherit; }
.button {
  min-height: 2.75rem;
  padding: .5rem .88rem;
  border: 1px solid transparent;
  border-radius: .65rem;
  font-weight: 680;
  font-size: .875rem;
  cursor: pointer;
  color: inherit;
}

.button.subtle { background: transparent; color: var(--muted); }
.button.subtle:hover { background: #e6ede7; }
.button.secondary { background: #fff; border-color: var(--input-border); color: var(--green-deep); }
.button.secondary:hover { background: var(--green-pale); }
.button.primary { background: var(--green); color: #fff; padding-inline: 1rem; }
.button.primary:hover { background: var(--green-deep); }

:focus-visible { outline: 3px solid #3a8864; outline-offset: 2px; }

.quote-comparison {
  margin-bottom: 1rem;
  border: 1px solid #c7e0d1;
  border-radius: .8rem;
  padding: .78rem 1rem;
  background: var(--green-pale);
  color: var(--green-deep);
  font-weight: 700;
}

.quote-comparison[data-state="pending"] { color: var(--amber); background: var(--amber-pale); border-color: #ead9b3; }
.quote-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; align-items: start; }

.card {
  min-width: 0;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.15rem;
  box-shadow: 0 .25rem .9rem #183e2c08;
}

.card-heading { flex-wrap: wrap; }
.card h3 { font-size: 1.15rem; letter-spacing: -.035em; }
.sample-badge {
  padding: .11rem .52rem;
  background: var(--amber-pale);
  color: var(--amber);
  border-radius: .35rem;
  font-size: .8125rem;
  font-weight: 700;
}

.quote-amounts, .settlement-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .7rem;
  margin-top: .8rem;
  padding: .7rem .8rem;
  border-radius: .7rem;
  background: #f2f7f3;
}

.quote-amounts dt, .settlement-summary dt { font-size: .875rem; color: var(--muted); }
.quote-amounts dd, .settlement-summary dd {
  color: var(--green-deep);
  font-size: clamp(1.08rem, 2.15vw, 1.55rem);
  font-weight: 740;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
  line-height: 1.4;
}

.quote-unknown { margin-top: .5rem; font-size: .875rem; color: var(--amber); }
.quote-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .68rem .75rem; margin-top: 1rem; }
.field { display: flex; flex-direction: column; gap: .25rem; min-width: 0; }
.field > span, .field > label, .fee-label, legend { font-size: .875rem; font-weight: 680; }
.field-note { color: var(--muted); font-size: .875rem; }

input:not([type="checkbox"]), select, textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--input-border);
  border-radius: .55rem;
  color: inherit;
  background-color: #fff;
}

input:not([type="checkbox"]), select { min-height: 2.75rem; padding: .43rem .6rem; }
input::placeholder { color: #587065; opacity: 1; }
input[aria-invalid="true"] { border-color: var(--error); }
select {
  appearance: none;
  padding-right: 1.7rem;
  background-image: linear-gradient(45deg, transparent 50%, #496158 50%), linear-gradient(135deg, #496158 50%, transparent 50%);
  background-position: right .85rem center, right .55rem center;
  background-repeat: no-repeat;
  background-size: .3rem .3rem;
}

.amount-inputs { display: grid; grid-template-columns: minmax(0, 1fr) minmax(5.6rem, max-content); gap: .4rem; }
.fee-list { border: 0; border-top: 1px solid var(--border); margin: 1rem 0 0; padding: .15rem 0 0; min-width: 0; }
.fee-list legend { padding: 0 .45rem 0 0; }
.fee-rows { display: grid; gap: .4rem; margin-top: .5rem; }
.fee-row { display: grid; grid-template-columns: minmax(3rem, .48fr) minmax(6.5rem, .68fr) minmax(0, 1.45fr); gap: .5rem; align-items: center; }
.session-note { color: var(--muted); font-size: .875rem; margin-top: 1.4rem; }

.participants { margin-bottom: 1rem; }
.participants .card-heading { justify-content: space-between; }
.participants select { width: 5.7rem; }
.participant-fields { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .7rem; margin-top: .75rem; }

.settlement-grid {
  display: grid;
  grid-template-areas: "editor results" "records results";
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
}

.expense-editor { grid-area: editor; }
.expense-records { grid-area: records; }
.settlement-results { grid-area: results; }
#expense-form { display: grid; gap: .8rem; margin-top: .75rem; }
.editor-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .7rem; }
.wide-field { grid-column: 1 / -1; }
#booking-fields { display: grid; gap: .55rem; }
.booking-preview { padding: .55rem .7rem; border-radius: .55rem; background: var(--green-pale); color: var(--green-deep); font-size: .9rem; overflow-wrap: anywhere; }
.member-field { margin: 0; padding: 0; border: 0; min-width: 0; }
.member-field legend { padding: 0; }
.member-choices { display: flex; flex-wrap: wrap; gap: .4rem; margin-block: .35rem; }
.member-choices label {
  display: flex;
  align-items: center;
  gap: .4rem;
  padding: .45rem .65rem;
  min-height: 2.65rem;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: .55rem;
  font-size: .875rem;
  cursor: pointer;
  overflow-wrap: anywhere;
}

.member-choices label:has(:checked) { background: var(--green-pale); border-color: #b7d5c3; }
.member-choices input { margin: 0; width: 1.05rem; height: 1.05rem; flex: 0 0 auto; accent-color: var(--green); }
.error { color: var(--error); font-size: .875rem; font-weight: 650; }
.error:empty, #copy-status:empty { display: none; }
.participants .error:not(:empty) { margin-top: .55rem; }
.settlement-summary { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.empty-note { color: var(--muted); font-size: .925rem; margin-top: .65rem; }
.record-list { list-style: none; padding: 0; margin: .65rem 0 0; }
.record-list:empty { margin: 0; }
.record-list li { overflow-wrap: anywhere; }
.record-list li + li { border-top: 1px solid var(--border); }

.entry-top, .transfer-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  column-gap: .7rem;
}

.expense-entry, .transfer-row, .account-row { padding-block: .6rem; }
.entry-actions { display: flex; gap: .25rem; margin-top: .2rem; }
.entry-actions .button { padding-inline: .55rem; }
.entry-amount, .transfer-amount { color: var(--green-deep); font-variant-numeric: tabular-nums; }
.transfer-arrow { color: var(--muted); white-space: pre; }
.account-details, .share-panel { border-top: 1px solid var(--border); margin-top: .8rem; padding-top: .75rem; }
.account-details summary { font-size: .9rem; font-weight: 680; cursor: pointer; }
.account-amounts { display: flex; flex-wrap: wrap; gap: .15rem .65rem; color: var(--muted); font-size: .875rem; }
.account-net { font-weight: 680; color: var(--green-deep); }
.share-panel h4 { font-size: 1rem; }
.share-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-block: .45rem; }
.share-actions select { width: auto; }
.share-panel textarea { display: block; padding: .6rem; resize: vertical; background: #f7f9f7; }
#copy-status { margin-top: .4rem; }

@media (max-width: 54rem) {
  .quote-grid { grid-template-columns: minmax(0, 1fr); }
  .section-heading { flex-wrap: wrap; }
  .quote-amounts dd, .settlement-summary dd { font-size: 1.3rem; }
  .settlement-grid { grid-template-areas: "editor" "results" "records"; grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 31rem) {
  .wrap { width: calc(100% - 1.35rem); }
  .hero-inner { padding-block: 1.35rem; gap: .72rem; }
  .hero p { font-size: .875rem; }
  .flag { flex-basis: 2.85rem; height: 2.85rem; }
  .flag::before { top: .53rem; left: .85rem; height: 1.67rem; }
  .flag::after { top: .64rem; left: .97rem; }
  main.wrap { padding-top: 1.2rem; }
  .card { padding: .86rem; }
  .quote-fields .field:last-child { grid-column: 1 / -1; }
  .fee-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .fee-inputs { grid-column: 1 / -1; }
  .participant-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
