/* MGH Portal — shared premium UI (glassy, iOS-flavoured, mobile-first).
   One stylesheet for both surfaces; every value is a token so a theme tweak is a one-line change. */

:root {
  --bg: #f2f4f8;
  --bg-glow-a: rgba(255, 122, 176, 0.35);
  --bg-glow-b: rgba(94, 155, 255, 0.28);
  --surface: rgba(255, 255, 255, 0.72);
  --surface-solid: #ffffff;
  --surface-2: rgba(255, 255, 255, 0.55);
  --border: rgba(15, 23, 42, 0.08);
  --text: #10142a;
  --text-dim: #5c6480;
  --brand: #b8206b;
  --brand-2: #7a1f6a;
  --accent: #1f7ae0;
  --ok: #12855b;
  --ok-bg: rgba(18, 133, 91, 0.12);
  --warn: #a8620a;
  --warn-bg: rgba(206, 133, 12, 0.14);
  --bad: #b3261e;
  --bad-bg: rgba(179, 38, 30, 0.1);
  --radius: 20px;
  --radius-sm: 14px;
  --shadow: 0 10px 30px rgba(16, 20, 42, 0.1);
  --shadow-sm: 0 4px 14px rgba(16, 20, 42, 0.08);
  --tap: 46px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  background-image: radial-gradient(circle at 12% 8%, var(--bg-glow-a), transparent 42%),
    radial-gradient(circle at 88% 4%, var(--bg-glow-b), transparent 45%),
    radial-gradient(circle at 50% 100%, rgba(255, 199, 224, 0.35), transparent 55%);
  background-attachment: fixed;
  font-size: 16px;
  line-height: 1.45;
  padding-bottom: env(safe-area-inset-bottom);
}

a {
  color: var(--brand);
}

.wrap {
  max-width: 720px;
  margin: 0 auto;
  padding: 16px 14px 96px;
}

.wrap.wide {
  max-width: 1080px;
}

/* ---------------------------------------------------------------- top bar */

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  margin: -16px -14px 14px;
  backdrop-filter: blur(18px) saturate(160%);
  -webkit-backdrop-filter: blur(18px) saturate(160%);
  background: rgba(255, 255, 255, 0.62);
  border-bottom: 1px solid var(--border);
}

.topbar img {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  object-fit: cover;
  background: #fff;
}

.topbar h1 {
  font-size: 1rem;
  margin: 0;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.topbar .sub {
  font-size: 0.75rem;
  color: var(--text-dim);
}

.spacer {
  flex: 1;
}

/* ---------------------------------------------------------------- cards */

.card {
  background: var(--surface);
  backdrop-filter: blur(20px) saturate(150%);
  -webkit-backdrop-filter: blur(20px) saturate(150%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 14px;
  animation: rise 0.42s cubic-bezier(0.19, 1, 0.22, 1) both;
}

.card.tight {
  padding: 12px 14px;
}

.card h2 {
  margin: 0 0 4px;
  font-size: 0.95rem;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.card h3 {
  margin: 14px 0 8px;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
}

.muted {
  color: var(--text-dim);
  font-size: 0.84rem;
}

.hero {
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-2) 100%);
  color: #fff;
  border: none;
}

.hero .muted,
.hero .label {
  color: rgba(255, 255, 255, 0.82);
}

.hero .amount {
  font-size: 2.1rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  margin: 6px 0 2px;
}

.label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
}

/* ---------------------------------------------------------------- rows + grid */

.grid {
  display: grid;
  gap: 10px;
}

.grid.cols-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid.cols-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.row:last-child {
  border-bottom: none;
}

.row .grow {
  flex: 1;
  min-width: 0;
}

.row .title {
  font-weight: 600;
  font-size: 0.95rem;
}

.row .meta {
  font-size: 0.78rem;
  color: var(--text-dim);
}

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

.amount-line {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  font-size: 0.92rem;
}

.amount-line.total {
  border-top: 1px solid var(--border);
  margin-top: 6px;
  padding-top: 10px;
  font-weight: 700;
  font-size: 1.02rem;
}

/* ---------------------------------------------------------------- chips */

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 650;
  letter-spacing: 0.02em;
  background: var(--surface-2);
  color: var(--text-dim);
  border: 1px solid var(--border);
  white-space: nowrap;
}

.chip.ok {
  background: var(--ok-bg);
  color: var(--ok);
  border-color: transparent;
}

.chip.warn {
  background: var(--warn-bg);
  color: var(--warn);
  border-color: transparent;
}

.chip.bad {
  background: var(--bad-bg);
  color: var(--bad);
  border-color: transparent;
}

/* ---------------------------------------------------------------- buttons */

button,
.btn {
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 620;
  min-height: var(--tap);
  padding: 0 18px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-solid);
  color: var(--text);
  cursor: pointer;
  transition: transform 0.14s ease, box-shadow 0.14s ease, opacity 0.14s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
}

button:active,
.btn:active {
  transform: scale(0.97);
}

button.primary,
.btn.primary {
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff;
  border: none;
  box-shadow: 0 8px 20px rgba(184, 32, 107, 0.28);
}

button.ghost {
  background: var(--surface-2);
}

button.small,
.btn.small {
  min-height: 36px;
  font-size: 0.82rem;
  padding: 0 12px;
}

button.danger {
  color: var(--bad);
  background: var(--bad-bg);
  border-color: transparent;
}

button.full {
  width: 100%;
}

button[disabled] {
  opacity: 0.55;
  pointer-events: none;
}

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

/* ---------------------------------------------------------------- forms */

label.field {
  display: block;
  margin: 10px 0;
}

label.field span {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-dim);
  margin-bottom: 5px;
}

input,
select,
textarea {
  font-family: inherit;
  font-size: 1rem;
  width: 100%;
  min-height: var(--tap);
  padding: 11px 13px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.9);
  color: var(--text);
  appearance: none;
}

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

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(184, 32, 107, 0.14);
}

.checkbox {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: var(--tap);
  font-size: 0.92rem;
}

.checkbox input {
  width: 22px;
  height: 22px;
  min-height: 22px;
  flex: none;
}

/* ---------------------------------------------------------------- tab bar */

.tabbar {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: max(10px, env(safe-area-inset-bottom));
  z-index: 40;
  display: flex;
  gap: 2px;
  padding: 6px;
  width: calc(100% - 24px);
  max-width: 560px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.78);
  backdrop-filter: blur(22px) saturate(170%);
  -webkit-backdrop-filter: blur(22px) saturate(170%);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  overflow-x: auto;
  scrollbar-width: none;
}

.tabbar::-webkit-scrollbar {
  display: none;
}

.tabbar button {
  flex: 1 0 auto;
  min-height: 42px;
  padding: 0 12px;
  border: none;
  background: transparent;
  font-size: 0.78rem;
  font-weight: 620;
  color: var(--text-dim);
  border-radius: 999px;
}

.tabbar button.active {
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff;
  box-shadow: 0 6px 16px rgba(184, 32, 107, 0.26);
}

/* ---------------------------------------------------------------- misc */

.toast {
  position: fixed;
  left: 50%;
  bottom: 84px;
  transform: translateX(-50%) translateY(20px);
  z-index: 60;
  max-width: 90%;
  padding: 12px 16px;
  border-radius: 16px;
  background: rgba(16, 20, 42, 0.92);
  color: #fff;
  font-size: 0.88rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease, transform 0.22s ease;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.center {
  text-align: center;
}

.skeleton {
  height: 14px;
  border-radius: 8px;
  background: linear-gradient(90deg, rgba(0, 0, 0, 0.06), rgba(0, 0, 0, 0.02), rgba(0, 0, 0, 0.06));
  background-size: 200% 100%;
  animation: shimmer 1.3s linear infinite;
  margin: 8px 0;
}

.proof {
  width: 100%;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: #fff;
  max-height: 60vh;
  object-fit: contain;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 70;
  background: rgba(12, 14, 28, 0.55);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 12px;
  animation: fade 0.2s ease both;
}

.modal .sheet {
  width: 100%;
  max-width: 640px;
  max-height: 88vh;
  overflow: auto;
  background: var(--surface-solid);
  border-radius: 26px 26px 20px 20px;
  padding: 18px;
  box-shadow: var(--shadow);
  animation: rise 0.28s cubic-bezier(0.19, 1, 0.22, 1) both;
}

.hidden {
  display: none !important;
}

.split {
  display: grid;
  gap: 14px;
}

@media (min-width: 900px) {
  .split {
    grid-template-columns: 1.25fr 1fr;
    align-items: start;
  }
  .wrap {
    padding-bottom: 40px;
  }
  .tabbar {
    position: static;
    transform: none;
    width: 100%;
    max-width: none;
    margin-bottom: 14px;
  }
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fade {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes shimmer {
  from {
    background-position: 200% 0;
  }
  to {
    background-position: -200% 0;
  }
}
