/* =====================================================================
   PayWe — design system (tokens + components)
   ===================================================================== */
:root {
  /* Color palette */
  --color-bg: #fdf6f0;
  --color-surface: #ffffff;
  --color-surface-alt: #f7efe7;
  --color-text: #1a2233;
  --color-text-muted: #7a6a63;
  --color-border: #efe1d5;

  --color-primary: #f4733f;
  --color-primary-dark: #e05a2a;
  --color-primary-contrast: #ffffff;

  --color-owed: #2fb872;      /* green = someone owes you */
  --color-owe: #e08a00;       /* orange = you owe */
  --color-danger: #d64545;
  --color-danger-dark: #b63535;

  /* Category accent palette */
  --cat-dining: #e05252;
  --cat-petrol: #8a6bff;
  --cat-accommodation: #2f6fed;
  --cat-transport: #0f9bb8;
  --cat-groceries: #2fb872;
  --cat-activities: #e08a00;
  --cat-other: #697386;

  /* Spacing scale */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;

  /* Type ramp */
  --text-xs: 12px;
  --text-sm: 13px;
  --text-base: 15px;
  --text-md: 17px;
  --text-lg: 20px;
  --text-xl: 26px;

  /* Radii */
  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 18px;
  --radius-full: 999px;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.06);
  --shadow: 0 2px 8px rgba(16, 24, 40, 0.08);
  --shadow-lg: 0 8px 24px rgba(16, 24, 40, 0.12);

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--font);
  background: var(--color-bg);
  color: var(--color-text);
  font-size: var(--text-base);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: none; }

/* ---------------------------------------------------------------------
   Layout
   --------------------------------------------------------------------- */
.shell {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 var(--space-4);
}

.shell--narrow { max-width: 460px; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: linear-gradient(180deg, #fff7f0, var(--color-surface));
  border-bottom: 1px solid var(--color-border);
}
.topbar__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
}
.topbar__title {
  font-size: var(--text-md);
  font-weight: 800;
}
.topbar__title a { color: var(--color-text); display: inline-flex; align-items: center; gap: 8px; }
.topbar__logo { width: 24px; height: 24px; border-radius: 7px; flex-shrink: 0; }
.beta-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .5px;
  background: #fdf0dd;
  color: #e08a00;
  border: 1px solid #f3d9ac;
}
.topbar__actions { display: flex; gap: var(--space-2); align-items: center; }

.page { padding: var(--space-5) 0 var(--space-7); }
.page__title {
  font-size: var(--text-xl);
  font-weight: 800;
  margin: 0 0 var(--space-2);
}
.page__subtitle { color: var(--color-text-muted); font-size: var(--text-sm); margin: 0 0 var(--space-5); }

/* ---------------------------------------------------------------------
   Brand hero (auth screens)
   --------------------------------------------------------------------- */
.brand {
  text-align: center;
  padding: var(--space-6) var(--space-4);
  background: linear-gradient(160deg, #fff7f0, #ffe9db);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-5);
}
.brand__logo { width: 64px; height: 64px; border-radius: 18px; box-shadow: var(--shadow); }
.brand__name { font-size: var(--text-xl); font-weight: 800; margin: var(--space-3) 0 var(--space-1); }
.brand__tagline { color: var(--color-text-muted); margin: 0 0 var(--space-4); }
.brand__points { display: flex; justify-content: center; gap: var(--space-3); flex-wrap: wrap; }
.brand__point {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: var(--text-sm);
  font-weight: 600;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  padding: 4px 12px;
}

/* ---------------------------------------------------------------------
   Components
   --------------------------------------------------------------------- */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: var(--space-4);
}
.card + .card { margin-top: var(--space-3); }

.list-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.list-row:active { transform: scale(0.99); }
.list-row + .list-row { margin-top: var(--space-2); }
.list-row__main { flex: 1; min-width: 0; }
.list-row__title { font-weight: 600; }
.list-row__sub { color: var(--color-text-muted); font-size: var(--text-sm); }
.list-row__end { text-align: right; flex-shrink: 0; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 10px;
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: 600;
  background: var(--color-surface-alt);
  color: var(--color-text-muted);
}
.badge--owed { background: #e5f6ec; color: var(--color-owed); }
.badge--owe { background: #fdf0dd; color: var(--color-owe); }
.badge--neutral { background: var(--color-surface-alt); color: var(--color-text-muted); }

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 10px 16px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  font-size: var(--text-base);
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s ease, transform 0.1s ease, box-shadow 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}
.button:active { transform: translateY(1px); }
.button--primary { background: var(--color-primary); color: var(--color-primary-contrast); }
.button--primary:hover { background: var(--color-primary-dark); }
.button--secondary { background: var(--color-surface); color: var(--color-text); border-color: var(--color-border); }
.button--secondary:hover { border-color: #cbd3dc; }
.button--danger { background: var(--color-danger); color: #fff; }
.button--danger:hover { background: var(--color-danger-dark); }
.button--block { width: 100%; }
.button--sm { padding: 6px 12px; font-size: var(--text-sm); }

.form-field { display: block; margin-bottom: var(--space-4); }
.form-field label {
  display: block;
  font-size: var(--text-sm);
  font-weight: 600;
  margin-bottom: var(--space-1);
  color: var(--color-text);
}
.form-field input,
.form-field select,
.form-field textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: var(--text-base);
  font-family: var(--font);
  background: var(--color-surface);
  color: var(--color-text);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(244, 115, 63, 0.2);
}
.form-field textarea { resize: vertical; min-height: 64px; }
.form-hint { color: var(--color-text-muted); font-size: var(--text-xs); margin-top: 2px; }
.form-error { color: var(--color-danger); font-size: var(--text-sm); margin-top: var(--space-1); }
.inline-error { color: var(--color-danger); font-size: var(--text-sm); }

.toast {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius);
  margin-bottom: var(--space-4);
  font-weight: 500;
}
.toast--success { background: #e5f6ec; color: var(--color-owed); }
.toast--error { background: #fdecec; color: var(--color-danger); }

.empty-state {
  text-align: center;
  padding: var(--space-7) var(--space-4);
  color: var(--color-text-muted);
}
.empty-state__icon { font-size: 40px; margin-bottom: var(--space-3); }
.empty-state__title { font-weight: 600; color: var(--color-text); }

/* Category glyphs */
.glyph { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; border-radius: var(--radius-sm); font-size: 18px; flex-shrink: 0; }
.glyph--dining { background: #fdecec; }
.glyph--petrol { background: #efeaff; }
.glyph--accommodation { background: #e8f0fd; }
.glyph--transport { background: #e2f5f9; }
.glyph--groceries { background: #e5f6ec; }
.glyph--activities { background: #fdf0dd; }
.glyph--other { background: var(--color-surface-alt); }

.amount { font-weight: 700; font-variant-numeric: tabular-nums; }
.amount--owed { color: var(--color-owed); }
.amount--owe { color: var(--color-owe); }

.section-title {
  font-size: var(--text-md);
  font-weight: 700;
  margin: var(--space-5) 0 var(--space-3);
}
.spacer { flex: 1; }
.row { display: flex; align-items: center; gap: var(--space-3); }
.muted { color: var(--color-text-muted); font-size: var(--text-sm); }

/* Skeleton / loading shimmer */
.skeleton {
  background: linear-gradient(90deg, var(--color-surface-alt) 25%, #f7f9fb 50%, var(--color-surface-alt) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.2s infinite;
  border-radius: var(--radius);
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* Inline form helpers */
.split-row { display: flex; align-items: center; gap: var(--space-2); margin-top: var(--space-2); }
.split-row input[type="number"] { width: 72px; }

/* Small screens */
@media (max-width: 480px) {
  .shell { padding: 0 var(--space-3); }
  .page { padding-top: var(--space-4); }
}