:root {
  --bg: #f5f3ef;
  --surface: #ffffff;
  --surface-soft: #f9faf7;
  --text: #172026;
  --muted: #65717c;
  --line: #dce2df;
  --teal: #0f766e;
  --teal-soft: #d9f0ec;
  --blue: #2563eb;
  --amber: #b45309;
  --amber-soft: #fff2cc;
  --green: #15803d;
  --green-soft: #dff5e5;
  --red: #b42318;
  --red-soft: #fee4df;
  --ink: #24313a;
  --shadow: 0 12px 34px rgba(23, 32, 38, .12);
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  letter-spacing: 0;
}

button,
input,
select,
textarea {
  font: inherit;
  letter-spacing: 0;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: calc(14px + env(safe-area-inset-top)) 14px calc(28px + env(safe-area-inset-bottom));
}

.topbar {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.eyebrow {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  margin-top: 3px;
  font-size: 28px;
  line-height: 1.1;
}

h2 {
  font-size: 18px;
  line-height: 1.2;
}

h3 {
  font-size: 15px;
  line-height: 1.25;
}

.icon-button {
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  display: inline-grid;
  place-items: center;
  font-size: 22px;
  line-height: 1;
}

.tabs {
  position: sticky;
  top: 0;
  z-index: 3;
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 8px 0 12px;
  background: var(--bg);
}

.tab,
.filter,
.text-button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  min-height: 38px;
  padding: 8px 12px;
  white-space: nowrap;
}

.tab.is-active,
.filter.is-active {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}

.tab-panel {
  display: none;
}

.tab-panel.is-active {
  display: block;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.metric {
  min-height: 102px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.metric .label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.metric .value {
  margin-top: 12px;
  font-size: 26px;
  font-weight: 800;
  line-height: 1;
}

.metric .sub {
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
}

.split-layout {
  display: grid;
  grid-template-columns: 1.1fr .9fr;
  gap: 12px;
  margin-top: 12px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 14px;
}

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

.muted {
  color: var(--muted);
  font-size: 12px;
}

.bar-list,
.city-list,
.admin-list,
.participant-list {
  display: grid;
  gap: 8px;
}

.bar-item,
.city-row,
.admin-row,
.participant-row,
.holder-card,
.city-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.bar-item,
.city-row,
.admin-row,
.participant-row {
  padding: 11px;
}

.row-top,
.row-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.row-bottom {
  margin-top: 7px;
  color: var(--muted);
  font-size: 13px;
}

.progress {
  width: 100%;
  height: 7px;
  border-radius: 999px;
  overflow: hidden;
  background: #e6ebe8;
  margin-top: 8px;
}

.progress span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--teal);
}

.progress .green {
  background: var(--green);
}

.progress .amber {
  background: var(--amber);
}

.participants-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 164px;
  gap: 8px;
  margin-bottom: 10px;
}

.search-box input,
.participants-toolbar select,
.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  padding: 9px 11px;
  outline: none;
}

.search-box input:focus,
.participants-toolbar select:focus,
.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, .13);
}

.filter-row {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 10px;
}

.list-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 38px;
  color: var(--muted);
  font-size: 13px;
}

.text-button {
  min-height: 34px;
  padding: 6px 10px;
}

.participant-row {
  width: 100%;
  text-align: left;
}

.participant-main {
  min-width: 0;
}

.participant-name {
  font-weight: 800;
  overflow-wrap: anywhere;
}

.participant-meta {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.amount {
  font-weight: 800;
  white-space: nowrap;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.pill.full {
  background: var(--green-soft);
  color: var(--green);
}

.pill.partial {
  background: var(--amber-soft);
  color: var(--amber);
}

.pill.unpaid {
  background: var(--red-soft);
  color: var(--red);
}

.pill.pending {
  background: var(--teal-soft);
  color: var(--teal);
}

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

.city-card,
.holder-card {
  padding: 13px;
}

.stat-line {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
}

.stat-line strong {
  color: var(--text);
}

.admin-row {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) repeat(5, minmax(84px, .6fr));
  gap: 10px;
  align-items: center;
}

.admin-row .num {
  font-weight: 800;
}

.drawer {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: none;
  justify-content: flex-end;
  background: rgba(23, 32, 38, .32);
}

.drawer.is-open {
  display: flex;
}

.drawer-card {
  width: min(560px, 100%);
  min-height: 100%;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: calc(16px + env(safe-area-inset-top)) 16px calc(22px + env(safe-area-inset-bottom));
  overflow-y: auto;
}

.drawer-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.detail-body {
  display: grid;
  gap: 14px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.field {
  display: grid;
  gap: 5px;
}

.field.full {
  grid-column: 1 / -1;
}

.field label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.field textarea {
  min-height: 92px;
  resize: vertical;
}

.drawer-actions {
  display: flex;
  gap: 8px;
  position: sticky;
  bottom: 0;
  background: var(--surface);
  padding-top: 10px;
}

.primary-button,
.secondary-button {
  min-height: 42px;
  border-radius: 8px;
  padding: 9px 12px;
  font-weight: 800;
}

.primary-button {
  border: 1px solid var(--teal);
  background: var(--teal);
  color: #fff;
}

.secondary-button {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
}

.history-list {
  display: grid;
  gap: 8px;
}

.history-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: var(--surface-soft);
}

.toast {
  position: fixed;
  left: 14px;
  right: 14px;
  bottom: calc(14px + env(safe-area-inset-bottom));
  z-index: 20;
  display: none;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  padding: 10px 14px;
  box-shadow: var(--shadow);
  text-align: center;
}

.toast.is-visible {
  display: flex;
}

.empty {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 20px;
  color: var(--muted);
  text-align: center;
  background: rgba(255, 255, 255, .58);
}

@media (max-width: 900px) {
  .metric-grid,
  .city-grid,
  .holder-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .split-layout {
    grid-template-columns: 1fr;
  }

  .admin-row {
    grid-template-columns: minmax(0, 1fr) minmax(84px, auto);
  }

  .admin-row .optional {
    display: none;
  }
}

@media (max-width: 560px) {
  .app-shell {
    padding-left: 10px;
    padding-right: 10px;
  }

  h1 {
    font-size: 24px;
  }

  .metric-grid,
  .city-grid,
  .holder-grid,
  .form-grid,
  .participants-toolbar {
    grid-template-columns: 1fr;
  }

  .metric {
    min-height: 90px;
  }

  .row-top {
    align-items: flex-start;
  }

  .participant-row .row-top {
    flex-direction: column;
  }

  .drawer-card {
    width: 100%;
  }
}
