:root {
  --paper: #f4efdf;
  --paper-2: #e8dbc0;
  --ink: #16120d;
  --muted: #766d5c;
  --line: #c9b894;
  --olive: #596b32;
  --blue: #155da8;
  --red: #a74432;
  --green: #22735a;
  --gold: #c78718;
  --shadow: 0 24px 70px rgba(60, 43, 17, 0.18);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  font-family: "IBM Plex Sans", "Helvetica Neue", sans-serif;
  background:
    linear-gradient(135deg, rgba(21, 93, 168, 0.12), transparent 34%),
    linear-gradient(315deg, rgba(89, 107, 50, 0.18), transparent 38%),
    var(--paper);
  min-height: 100vh;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(22, 18, 13, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(22, 18, 13, 0.035) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.8), transparent 80%);
}

.shell {
  width: min(1440px, calc(100% - 32px));
  margin: 0 auto;
  padding: 26px 0 44px;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 20px;
  align-items: stretch;
  border: 2px solid var(--ink);
  background: rgba(244, 239, 223, 0.92);
  box-shadow: var(--shadow);
}

.topbar > div:first-child {
  padding: 24px 28px;
}

.eyebrow {
  margin: 0 0 7px;
  color: var(--blue);
  font-family: "IBM Plex Sans Condensed", sans-serif;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2,
h3 {
  margin: 0;
  font-family: "IBM Plex Sans Condensed", sans-serif;
  letter-spacing: 0;
  overflow-wrap: break-word;
  word-break: break-word;
}

h1 {
  font-size: clamp(2.2rem, 6vw, 5.5rem);
  line-height: 0.9;
}

h2 {
  font-size: 1.65rem;
  line-height: 1;
}

.rate-tile {
  min-width: 190px;
  padding: 20px 24px;
  display: grid;
  align-content: center;
  color: #f8f1dd;
  background: var(--ink);
  border-left: 2px solid var(--ink);
}

.rate-tile span {
  color: var(--paper-2);
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
}

.rate-tile strong {
  margin-top: 6px;
  font-family: "IBM Plex Sans Condensed", sans-serif;
  font-size: 2.35rem;
  line-height: 1;
}

.is-hidden {
  display: none !important;
}

.logout-button {
  width: max-content;
  margin-top: 14px;
  padding: 7px 10px;
  color: var(--paper-2);
  font: 700 0.78rem "IBM Plex Sans Condensed", sans-serif;
  text-transform: uppercase;
  border: 1px solid var(--paper-2);
  background: transparent;
  cursor: pointer;
}

.login-panel {
  min-height: 58vh;
  display: grid;
  place-items: center;
  padding: 42px 0;
}

.login-card {
  width: min(440px, 100%);
  padding: 24px;
  border: 2px solid var(--ink);
  background: rgba(250, 246, 232, 0.92);
  box-shadow: 12px 12px 0 rgba(22, 18, 13, 0.14);
}

.login-card h2 {
  margin-bottom: 18px;
  font-size: clamp(1.8rem, 5.5vw, 2.6rem);
}

.login-card label {
  display: grid;
  gap: 7px;
  margin-bottom: 14px;
}

.login-card span {
  color: var(--muted);
  font-family: "IBM Plex Sans Condensed", sans-serif;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
}

.login-card input {
  width: 100%;
  min-height: 46px;
  padding: 0 12px;
  color: var(--ink);
  font: 700 1rem "IBM Plex Sans", sans-serif;
  border: 1px solid var(--ink);
  background: rgba(255, 253, 245, 0.95);
  border-radius: 0;
}

.login-card .primary-action {
  width: 100%;
}

#loginMessage {
  min-height: 20px;
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 700;
}

#loginMessage[data-tone="error"] {
  color: var(--red);
}

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

.metric-card,
.panel,
.control-strip {
  border: 2px solid var(--ink);
  background: rgba(250, 246, 232, 0.88);
  box-shadow: 10px 10px 0 rgba(22, 18, 13, 0.12);
}

.metric-card {
  min-height: 128px;
  padding: 16px;
  display: grid;
  align-content: space-between;
}

.metric-label {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
}

.metric-value {
  margin-top: 18px;
  font-family: "IBM Plex Sans Condensed", sans-serif;
  font-size: clamp(1.55rem, 2.3vw, 2.4rem);
  font-weight: 700;
  line-height: 0.95;
}

.metric-note {
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.86rem;
}

.control-strip {
  display: inline-flex;
  padding: 5px;
  margin-bottom: 16px;
  background: var(--ink);
  box-shadow: none;
}

.scenario-button {
  min-height: 42px;
  padding: 0 18px;
  color: var(--paper-2);
  font: 700 0.92rem "IBM Plex Sans Condensed", sans-serif;
  text-transform: uppercase;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.scenario-button.is-active {
  color: var(--ink);
  background: var(--gold);
}

.primary-action {
  min-height: 42px;
  padding: 0 16px;
  color: #fff8e7;
  font: 700 0.88rem "IBM Plex Sans Condensed", sans-serif;
  text-transform: uppercase;
  border: 2px solid var(--ink);
  background: var(--blue);
  cursor: pointer;
  box-shadow: 4px 4px 0 rgba(22, 18, 13, 0.18);
}

.primary-action:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.danger-action {
  min-height: 34px;
  padding: 0 10px;
  color: #fff8e7;
  font: 700 0.76rem "IBM Plex Sans Condensed", sans-serif;
  text-transform: uppercase;
  border: 1px solid var(--red);
  background: var(--red);
  cursor: pointer;
  white-space: nowrap;
}

.danger-action:disabled {
  opacity: 0.5;
  cursor: wait;
}

.add-expense-panel {
  position: relative;
}

.expense-form {
  display: grid;
  grid-template-columns: minmax(220px, 1.4fr) minmax(140px, 0.7fr) minmax(140px, 0.7fr) minmax(150px, 0.8fr) minmax(150px, 0.8fr) minmax(150px, 0.8fr);
  gap: 12px;
  align-items: end;
}

.expense-form.is-hidden {
  display: none;
}

.expense-form label {
  display: grid;
  gap: 7px;
}

.expense-form span {
  color: var(--muted);
  font-family: "IBM Plex Sans Condensed", sans-serif;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
}

.expense-form input,
.expense-form select {
  width: 100%;
  min-height: 42px;
  padding: 0 11px;
  color: var(--ink);
  font: 600 0.95rem "IBM Plex Sans", sans-serif;
  border: 1px solid var(--ink);
  background: rgba(255, 253, 245, 0.9);
  border-radius: 0;
}

.expense-form select:disabled {
  color: var(--muted);
  background: var(--paper-2);
}

.form-actions {
  display: grid;
  gap: 8px;
  align-self: end;
}

.form-actions .primary-action {
  width: 100%;
}

#expenseFormMessage {
  min-height: 18px;
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

#expenseFormMessage[data-tone="success"] {
  color: var(--green);
}

#expenseFormMessage[data-tone="error"] {
  color: var(--red);
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.38fr) minmax(340px, 0.62fr);
  gap: 16px;
}

.panel {
  padding: 20px;
  margin-bottom: 16px;
}

.panel-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

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

.person-card {
  min-height: 270px;
  padding: 16px;
  border: 1px solid var(--line);
  background: rgba(255, 253, 245, 0.7);
}

.person-card h3 {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 1.65rem;
}

.status-pill {
  align-self: start;
  padding: 5px 8px;
  color: #fff;
  font-family: "IBM Plex Sans Condensed", sans-serif;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
}

.status-pill.positive {
  background: var(--green);
}

.status-pill.negative {
  background: var(--red);
}

.status-pill.neutral {
  background: var(--muted);
}

.person-amount {
  margin: 18px 0 10px;
  font-family: "IBM Plex Sans Condensed", sans-serif;
  font-size: 2.15rem;
  font-weight: 700;
  line-height: 1;
}

.positive-text {
  color: var(--green);
}

.negative-text {
  color: var(--red);
}

.bar-shell {
  height: 12px;
  margin: 16px 0;
  border: 1px solid var(--ink);
  background: var(--paper-2);
}

.bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--blue), var(--olive));
}

.mini-rows {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.mini-row,
.settlement-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 0.93rem;
}

.mini-row strong,
.settlement-row strong {
  color: var(--ink);
  white-space: nowrap;
}

.settlement-stack {
  display: grid;
  gap: 12px;
}

.settlement-box {
  padding: 14px;
  color: #fff8e7;
  background: var(--ink);
}

.settlement-box h3 {
  margin-bottom: 12px;
  color: var(--paper-2);
  font-size: 1.12rem;
}

.settlement-row {
  color: rgba(255, 248, 231, 0.78);
  align-items: center;
  min-height: 34px;
}

.settlement-row strong {
  color: #fff8e7;
}

.settlement-row.is-done {
  opacity: 0.72;
}

.settlement-done {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 248, 231, 0.24);
}

.settlement-done h4 {
  margin: 0 0 10px;
  color: var(--gold);
  font-family: "IBM Plex Sans Condensed", sans-serif;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.settlement-action {
  min-height: 28px;
  padding: 0 9px;
  color: var(--ink);
  font: 700 0.72rem "IBM Plex Sans Condensed", sans-serif;
  text-transform: uppercase;
  border: 1px solid var(--gold);
  background: var(--gold);
  cursor: pointer;
  white-space: nowrap;
}

.settlement-action.muted {
  color: var(--paper-2);
  border-color: rgba(255, 248, 231, 0.48);
  background: transparent;
}

.settlement-action:disabled {
  opacity: 0.5;
  cursor: wait;
}

.arrow {
  color: var(--gold);
  font-weight: 700;
}

.table-head {
  align-items: center;
}

.legend {
  display: flex;
  gap: 14px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
  text-transform: uppercase;
}

.dot {
  width: 10px;
  height: 10px;
  display: inline-block;
  margin-right: 6px;
  border-radius: 50%;
}

.dot.paid {
  background: var(--green);
}

.dot.planned {
  background: var(--gold);
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 940px;
}

th,
td {
  padding: 13px 14px;
  text-align: left;
  border-bottom: 1px solid var(--line);
}

th {
  color: var(--muted);
  font-family: "IBM Plex Sans Condensed", sans-serif;
  font-size: 0.82rem;
  text-transform: uppercase;
}

td {
  font-size: 0.95rem;
}

.inline-select {
  width: 100%;
  min-height: 34px;
  padding: 0 8px;
  color: var(--ink);
  font: 700 0.84rem "IBM Plex Sans", sans-serif;
  border: 1px solid var(--line);
  background: rgba(255, 253, 245, 0.92);
  border-radius: 0;
}

.inline-select:disabled {
  color: var(--muted);
  background: var(--paper-2);
}

.status-select.paid {
  border-color: var(--green);
}

.status-select.planned {
  border-color: var(--gold);
}

tbody tr:last-child td {
  border-bottom: 0;
}

.expense-title {
  font-weight: 700;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  color: #fff;
  font-family: "IBM Plex Sans Condensed", sans-serif;
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  background: var(--blue);
}

.tag.planned {
  color: var(--ink);
  background: var(--gold);
}

.tag.paid {
  background: var(--green);
}

.empty-note {
  margin: 14px 0 0;
  color: var(--muted);
  line-height: 1.45;
}

.audit-panel {
  margin-top: 16px;
}

#auditLog {
  display: grid;
  gap: 10px;
}

.audit-row {
  padding: 12px;
  border: 1px solid var(--line);
  background: rgba(255, 253, 245, 0.72);
}

.audit-main {
  display: grid;
  grid-template-columns: minmax(170px, 0.8fr) minmax(150px, 0.55fr) minmax(260px, 1.6fr);
  gap: 14px;
  align-items: center;
}

.audit-row p {
  margin: 0;
  color: var(--muted);
  line-height: 1.35;
}

.audit-row strong {
  font-family: "IBM Plex Sans Condensed", sans-serif;
  font-size: 0.94rem;
  text-transform: uppercase;
}

.audit-time {
  margin-right: 8px;
  color: var(--muted);
  font-weight: 700;
}

.audit-badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  color: #fff8e7;
  font-family: "IBM Plex Sans Condensed", sans-serif;
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  background: var(--muted);
}

.audit-badge.admin {
  background: var(--red);
}

.audit-badge.user {
  background: var(--blue);
}

.audit-details {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.audit-details span {
  padding: 6px 8px;
  color: var(--ink);
  font-size: 0.86rem;
  font-weight: 700;
  border: 1px solid var(--line);
  background: var(--paper);
}

@media (max-width: 1100px) {
  .metrics,
  .people-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

@media (max-width: 720px) {
  .shell {
    width: min(100% - 20px, 640px);
    padding-top: 10px;
  }

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

  .rate-tile {
    border-left: 0;
    border-top: 2px solid var(--ink);
  }

  .metrics,
  .people-grid {
    grid-template-columns: 1fr;
  }

  .control-strip {
    display: grid;
    width: 100%;
    grid-template-columns: 1fr 1fr;
  }

  .panel {
    padding: 14px;
  }

  .panel-head {
    align-items: start;
    flex-direction: column;
  }

  .audit-main {
    grid-template-columns: 1fr;
  }
}

.topbar-left {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.back-link {
  width: max-content;
  margin-bottom: 10px;
  color: var(--blue);
  font: 700 0.8rem "IBM Plex Sans Condensed", sans-serif;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-decoration: none;
  border-bottom: 2px solid transparent;
}

.back-link:hover {
  border-bottom-color: var(--blue);
}

.login-sub {
  margin: -10px 0 18px;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.4;
}

.projects-panel {
  margin-top: 22px;
  padding: 26px;
  border: 2px solid var(--ink);
  background: rgba(250, 246, 232, 0.92);
  box-shadow: var(--shadow);
}

.projects-grid {
  margin-top: 18px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}

.project-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 20px;
  text-decoration: none;
  color: var(--ink);
  border: 2px solid var(--ink);
  background: rgba(244, 239, 223, 0.7);
  box-shadow: 6px 6px 0 rgba(22, 18, 13, 0.12);
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.project-card:hover {
  transform: translate(-2px, -2px);
  box-shadow: 9px 9px 0 rgba(22, 18, 13, 0.18);
}

.project-name {
  font-family: "IBM Plex Sans Condensed", sans-serif;
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1;
}

.project-slug {
  color: var(--muted);
  font-size: 0.85rem;
  letter-spacing: 0.03em;
}

.shared-summary {
  display: flex;
  gap: 28px;
  flex-wrap: wrap;
}

.shared-summary-item {
  display: grid;
  gap: 4px;
  text-align: right;
}

.shared-summary-item span {
  color: var(--muted);
  font-family: "IBM Plex Sans Condensed", sans-serif;
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.shared-summary-item strong {
  font-family: "IBM Plex Sans Condensed", sans-serif;
  font-size: 1.7rem;
  line-height: 1;
}

.shared-head-right {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
}

.contribution-form {
  margin-top: 4px;
}
