:root {
  color: #15241d;
  background: #f3f6f3;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* { box-sizing: border-box; }

body { margin: 0; }

button, input, select { font: inherit; }

.shell { width: min(1120px, calc(100% - 32px)); margin: 0 auto; padding: 20px 0 56px; }

.topbar { display: flex; align-items: center; gap: 20px; min-height: 48px; margin-bottom: 32px; }

.brand { color: #126344; font-size: 1.15rem; font-weight: 800; text-decoration: none; margin-right: auto; }

.view-switcher { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 22px; }

.server-form, .password-form { display: grid; gap: 12px; }

.password-form { max-width: 360px; margin-top: 24px; padding-top: 20px; border-top: 1px solid #edf1ed; }

h1 { margin: 0 0 8px; font-size: clamp(1.8rem, 5vw, 2.5rem); letter-spacing: -0.04em; }

h2 { margin: 0 0 18px; font-size: 1.05rem; }

p { line-height: 1.55; }

.muted { color: #63736a; }

.eyebrow { color: #16835a; font-size: .75rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }

.panel { background: white; border: 1px solid #e1e9e3; border-radius: 16px; box-shadow: 0 8px 28px #173a2410; margin-bottom: 18px; padding: 22px; }

:where(.panel > :is(label, .button, .button-row, form) + :is(label, .button, .button-row, form)) { margin-top: 12px; }

#signed-out { max-width: 620px; margin: 10vh auto; padding: clamp(24px, 7vw, 48px); }

#signed-out h1:focus { outline: none; }

.page-heading { display: flex; justify-content: space-between; align-items: end; gap: 16px; margin-bottom: 22px; }

.heading-controls { display: flex; gap: 16px; align-items: end; }
.month-picker, .budget-picker { max-width: 180px; }

.summary-grid { display: grid; grid-template-columns: 1.2fr 1fr; gap: 18px; }

.summary-panel { min-height: 150px; }

.total { margin: 4px 0; font-size: 2rem; font-weight: 800; }

.settlements { display: grid; gap: 8px; list-style: none; margin: 0; padding: 0; }

.settlements li { display: flex; justify-content: space-between; gap: 12px; padding-bottom: 8px; border-bottom: 1px solid #edf1ed; }

label, fieldset { display: grid; gap: 7px; color: #45554b; font-size: .86rem; font-weight: 650; }

fieldset { min-width: 0; min-height: 70px; border: 0; margin: 0; padding: 0; }

legend { margin-bottom: 7px; color: #45554b; font-size: .86rem; font-weight: 650; }

input, select { width: 100%; min-height: 42px; border: 1px solid #ccd8cf; border-radius: 9px; background: #fff; padding: 9px 11px; color: #15241d; }

input[type="file"] { padding: 6px; }

input:focus, select:focus, button:focus-visible, summary:focus-visible { outline: 3px solid #78c5a1; outline-offset: 2px; }

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

.check { display: inline-flex; align-items: center; gap: 6px; }

.check input { width: 17px; min-height: 17px; margin: 0; accent-color: #16835a; }

.button { display: inline-flex; align-items: center; justify-content: center; min-height: 42px; border: 1px solid #126344; border-radius: 9px; background: #126344; padding: 9px 16px; color: white; font-weight: 750; cursor: pointer; text-decoration: none; }

.button:hover { background: #0d5137; }

.button.secondary { border-color: #cbd9d0; background: #f7faf8; color: #234634; }

.button.secondary:hover { background: #edf4ef; }

.button.danger { border-color: #9c3932; background: #9c3932; }

.button.danger:hover { background: #7f2e28; }

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  flex: none;
  border: 1px solid #126344;
  border-radius: 9px;
  background: #126344;
  padding: 9px;
  color: white;
  cursor: pointer;
}

.icon-button:hover { background: #0d5137; }
.icon-button.secondary { border-color: #cbd9d0; background: #f7faf8; color: #234634; }
.icon-button.secondary:hover { background: #edf4ef; }
.icon-button.danger { border-color: #9c3932; background: #9c3932; color: white; }
.icon-button.danger:hover { background: #7f2e28; }
.icon-button.edit { border: 0; background: none; color: #126344; }
.icon-button.delete { border: 0; background: none; color: #9c3932; }
.icon-button:disabled { cursor: not-allowed; opacity: .55; }

.action-icon { width: 20px; height: 20px; }

.button-row, .import-form { display: flex; align-items: end; flex-wrap: wrap; gap: 12px; }

.import-form { align-items: end; }

.import-form label { flex: 1 1 230px; }

.budget-person-import { margin-bottom: 16px; }

.settlement-example { margin-top: 20px; font-size: .86rem; }

.settlement-example p { margin: 8px 0; }

.settlement-diagrams { display: flex; flex-wrap: wrap; gap: 12px; }

.settlement-diagrams > div { display: grid; gap: 4px; min-width: 150px; border: 1px solid #e1e9e3; border-radius: 9px; background: #f7faf8; padding: 10px 12px; }

.notice { min-height: 1.5em; color: #42584a; }

.notice:empty { display: none; }

.error-alert { position: fixed; z-index: 10; right: 16px; bottom: 16px; display: flex; align-items: start; gap: 12px; max-width: min(28rem, calc(100vw - 32px)); border: 1px solid #d88b85; border-radius: 9px; background: #fff3f2; padding: 12px; color: #a42b24; overflow-wrap: anywhere; box-shadow: 0 8px 28px #173a2426; }
.error-alert button { flex: none; border: 0; background: none; color: inherit; font-weight: 700; cursor: pointer; }

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

table { width: 100%; border-collapse: collapse; text-align: left; }

.table-wrap { container-type: inline-size; }
.transactions-table { table-layout: fixed; }
.date-column { width: 150px; }
.type-column { width: 115px; }
.payer-column { width: 80px; }
.people-column { width: 150px; }
.amount-column { width: 115px; }
.actions-column { width: 7rem; }

th, td { padding: 12px 10px; border-bottom: 1px solid #edf1ed; }

th { color: #66766d; font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; }

.transactions-table th, .transactions-table td { overflow-wrap: anywhere; }
.amount-cell { text-align: right; }

.refund-amount { color: #a42b24; }

.transaction-label { display: none; }

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

.transaction-editor { background: #f7faf8; }
.transaction-editor td { vertical-align: top; }
.transaction-editor input:not([type="checkbox"]), .transaction-editor select { min-width: 0; max-width: 100%; }
.transaction-editor .row-actions > .button { flex: 1 1 auto; }
.transaction-editor .row-actions > .button:not(.add-transaction) { padding-inline: 8px; }
.transaction-editor .row-actions > .add-transaction { flex: 0 0 auto; padding: 9px 12px; }
.transaction-editor .row-actions > .icon-button { flex: 0 0 42px; }
.people-field { position: relative; min-width: 0; }
.people-validity { position: absolute; z-index: -1; top: 50%; left: 50%; width: 1px; height: 1px; min-height: 0; margin: 0; padding: 0; border: 0; opacity: 0; pointer-events: none; }
.people-field:has(.people-validity:focus) .people-select summary { outline: 3px solid #78c5a1; outline-offset: 2px; }
.people-select { position: relative; min-width: 0; }
.people-select summary { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 42px; border: 1px solid #ccd8cf; border-radius: 9px; background: white; padding: 9px 11px; cursor: pointer; overflow-wrap: anywhere; }
.people-select summary::after { content: "\25BE"; flex: none; }
.transaction-editor .people-select summary {
  height: 42px;
  max-height: 42px;
  overflow: hidden;
  white-space: nowrap;
}
.transaction-editor .people-select summary .row-person-icons {
  flex-wrap: nowrap;
  min-width: 0;
  overflow: hidden;
}
.person-dropdown-summary {
  justify-content: flex-start;
  gap: 8px;
  padding-inline: 9px;
}
.person-dropdown-summary .member-icon {
  margin-right: auto;
}
.people-options { position: absolute; z-index: 2; right: 0; display: grid; gap: 10px; width: min(14rem, calc(100vw - 32px)); max-height: 16rem; overflow-y: auto; border: 1px solid #ccd8cf; border-radius: 9px; background: white; padding: 12px; box-shadow: 0 8px 20px #173a2426; }
.people-options .check { overflow-wrap: anywhere; }
.people-options .check input { flex: none; }

.edit, .delete { border: 0; background: none; font-weight: 700; cursor: pointer; }

.edit { color: #126344; }

.delete { color: #9c3932; }

.member-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  font-size: 0.72rem;
  font-weight: 750;
  line-height: 1;
  color: #fff;
  flex: none;
  overflow: hidden;
  vertical-align: middle;
  user-select: none;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}

.member-icon.has-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.member-icon.preview-icon {
  width: 44px;
  height: 44px;
  font-size: 1.1rem;
}

.member-icon.color-0 { background-color: #2d6a4f; }
.member-icon.color-1 { background-color: #1b4965; }
.member-icon.color-2 { background-color: #5c4d7d; }
.member-icon.color-3 { background-color: #8b5a2b; }
.member-icon.color-4 { background-color: #3d5a80; }
.member-icon.color-5 { background-color: #406343; }
.member-icon.color-6 { background-color: #7f4f24; }
.member-icon.color-7 { background-color: #386641; }

.person-cell {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.row-person-icons {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

.row-person-overflow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #edf3ef;
  color: #526159;
  font-size: 0.68rem;
  font-weight: 750;
  line-height: 1;
  flex: none;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}

.budget-people-list {
  list-style: none;
  margin: 0 0 16px;
  padding: 0;
  display: grid;
  gap: 10px;
}

.budget-people-list li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  border: 1px solid #e1e9e3;
  border-radius: 9px;
  background: #f7faf8;
}

.budget-people-list li .muted {
  margin-left: auto;
}

.icon-field {
  display: grid;
  gap: 8px;
  width: 100%;
}

.icon-editor-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.icon-editor-row input[type="file"] {
  flex: 1 1 200px;
}

.icon-hint {
  margin: 2px 0 0;
  font-size: 0.8rem;
}

.settlement-parties {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.hidden { display: none !important; }

@media (max-width: 760px) {
  .summary-grid { grid-template-columns: 1fr; gap: 0; }
}

@container (max-width: 900px) {
  .transactions-table, .transactions-table tbody, .transactions-table tr { display: block; }
  .transactions-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .transactions-table tr { border: 1px solid #e1e9e3; border-radius: 12px; margin-bottom: 12px; padding: 12px; }
  .transactions-table td { display: grid; grid-template-columns: minmax(0, 7.5rem) minmax(0, 1fr); gap: 8px; border: 0; padding: 4px 0; text-align: left; white-space: normal; }
  .transactions-table td > span { min-width: 0; overflow-wrap: anywhere; }
  .transactions-table .transaction-label { display: block; color: #63736a; font-size: .86rem; font-weight: 650; }
  .transactions-table .row-actions { grid-column: 1 / -1; border-top: 1px solid #edf1ed; margin-top: 4px; padding-top: 4px; }
  .transactions-table .row-actions button { min-height: 44px; padding: 8px 12px; }
  .transactions-table .transaction-editor td > label { display: contents; }
}

@media (max-width: 480px) {
  .shell { width: min(100% - 20px, 1120px); padding-top: 12px; }
  .panel { padding: 16px; }
  .page-heading { align-items: start; flex-direction: column; }
  .heading-controls { width: 100%; flex-direction: column; }
  .month-picker, .budget-picker { width: 100%; max-width: none; }
  .transactions-table .transaction-editor td { grid-template-columns: minmax(0, 1fr); }
}
