:root {
  --bg: #eaf4ff;
  --surface: #ffffff;
  --surface-2: #f5f9ff;
  --ink: #0c2a5a;
  --muted: #58709a;
  --line: #c8dbf4;
  --brand: #2d78cf;
  --brand-strong: #1e62ad;
  --danger: #c24141;
  --ok: #159447;
  --shadow: 0 20px 46px rgba(45, 120, 207, 0.14);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  min-height: 40px;
  border: 0;
  border-radius: 9px;
  padding: 0 16px;
  background: var(--brand);
  color: #fff;
  cursor: pointer;
  font-weight: 800;
}

button:hover {
  background: var(--brand-strong);
}

button.secondary {
  background: #e8f1fc;
  color: var(--ink);
}

button.danger {
  background: #f8e3e3;
  color: var(--danger);
}

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 9px 11px;
  background: #fff;
  color: var(--ink);
}

textarea {
  resize: vertical;
}

label {
  display: grid;
  gap: 7px;
  color: var(--ink);
  font-size: 0.86rem;
  font-weight: 800;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(1.7rem, 3vw, 2.35rem);
}

h2 {
  margin-bottom: 0;
  font-size: 1.28rem;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--brand);
  font-size: 0.74rem;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  padding: 28px clamp(18px, 4vw, 42px);
  background: #fff;
  border-bottom: 1px solid var(--line);
  box-shadow: 0 12px 28px rgba(45, 120, 207, 0.08);
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sync-status {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  max-width: 280px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #f7fbff;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.layout {
  width: min(1220px, 100%);
  margin: 0 auto;
  padding: 24px clamp(14px, 3vw, 28px) 44px;
}

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

.controls {
  display: grid;
  grid-template-columns: 160px 220px 1fr;
  gap: 14px;
  align-items: end;
  padding: 16px;
  margin-bottom: 16px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.metric {
  min-height: 92px;
  padding: 16px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 800;
}

.metric strong {
  display: block;
  margin-top: 10px;
  font-size: 1.38rem;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
}

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

.form-grid .wide {
  grid-column: 1 / -1;
}

.form-grid button[type="submit"] {
  grid-column: 1 / -1;
}

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

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.toolbar button.active {
  background: var(--brand);
  color: #fff;
}

.bill-list {
  display: grid;
  gap: 0;
  padding: 0 16px 16px;
}

.bill-row {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) 150px auto;
  gap: 14px;
  align-items: center;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}

.bill-row:first-child {
  border-top: 0;
}

.bill-row.paid .bill-main strong {
  color: var(--ok);
}

.bill-main {
  display: grid;
  gap: 3px;
}

.bill-main strong {
  color: #050b18;
  font-size: 1.08rem;
}

.bill-main span,
.bill-main small {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 700;
}

.bill-value input {
  text-align: right;
  font-weight: 800;
}

.bill-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.pay-button.is-paid {
  background: var(--ok);
  color: #fff;
}

.empty {
  color: var(--muted);
  padding: 18px;
  text-align: center;
}

.auth-gate {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  align-items: center;
  justify-items: start;
  padding: min(9vw, 64px);
  background: var(--bg);
}

.auth-card {
  width: min(390px, 100%);
  display: grid;
  gap: 14px;
  padding: 34px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
}

.login-mark {
  width: 48px;
  height: 48px;
  border-radius: 13px;
  background: var(--brand);
  box-shadow: inset 0 0 0 6px rgba(255, 255, 255, 0.22);
}

.auth-card h1 {
  margin: 12px 0 0;
  color: var(--ink);
  font-size: 1.9rem;
  line-height: 1.08;
}

.auth-card p {
  margin-bottom: 10px;
  color: var(--muted);
  font-weight: 700;
}

.auth-card button {
  margin-top: 2px;
  min-height: 48px;
  box-shadow: 0 12px 24px rgba(45, 120, 207, 0.2);
}

.message {
  min-height: 20px;
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.hidden {
  display: none !important;
}

@media (max-width: 900px) {
  .topbar,
  .top-actions,
  .section-head {
    align-items: stretch;
    flex-direction: column;
  }

  .controls,
  .summary-grid,
  .form-grid,
  .bill-row {
    grid-template-columns: 1fr;
  }

  .bill-actions {
    justify-content: stretch;
  }

  .bill-actions button {
    flex: 1;
  }
}
