/* Gratia app. Three display modes share one layout; only the colour variables change. */

:root,
[data-theme="dark"] {
  --bg: #040A12;
  --haze: rgba(31, 78, 120, 0.6);
  --grid: rgba(79, 216, 255, 0.045);
  --panel: #091626;
  --inset: #06101C;
  --line: #163A52;
  --input-line: #3A7391;
  --text: #DCEBF5;
  --muted: #8FB3C9;
  --primary: #4FD8FF;
  --primary-soft: rgba(79, 216, 255, 0.12);
  --glow: rgba(79, 216, 255, 0.3);
  --accent: #C9A227;
  --accent-text: #C9A227;
  --on-accent: #040A12;
  --alert: #FF8A4C;
  --alert-soft: rgba(255, 138, 76, 0.1);
  --laser: none;
  color-scheme: dark;
}

[data-theme="light"] {
  --bg: #EAF3FF;
  --haze: rgba(0, 184, 230, 0.3);
  --grid: rgba(11, 99, 229, 0.09);
  --panel: #FFFFFF;
  --inset: #F2F8FF;
  --line: #9CC3F5;
  --input-line: #5B8FD9;
  --text: #071A33;
  --muted: #3E5B7D;
  --primary: #0B63E5;
  --primary-soft: rgba(11, 99, 229, 0.1);
  --glow: rgba(11, 99, 229, 0.18);
  --accent: #F2A900;
  --accent-text: #8F5E00;
  --on-accent: #071A33;
  --alert: #C2390A;
  --alert-soft: rgba(255, 90, 31, 0.1);
  --laser: linear-gradient(90deg, #0B63E5, #00B8E6, #F2A900, #FF5A1F);
  color-scheme: light;
}

[data-theme="riddim"] {
  --bg: #07010F;
  --haze: rgba(122, 28, 201, 0.6);
  --grid: rgba(255, 61, 242, 0.06);
  --panel: #12051F;
  --inset: #0B0216;
  --line: #4A1A7A;
  --input-line: #8A4FD0;
  --text: #F4E9FF;
  --muted: #C3A6E6;
  --primary: #FF3DF2;
  --primary-soft: rgba(255, 61, 242, 0.14);
  --glow: rgba(255, 61, 242, 0.4);
  --accent: #B6FF2E;
  --accent-text: #B6FF2E;
  --on-accent: #07010F;
  --alert: #FF6A3D;
  --alert-soft: rgba(255, 106, 61, 0.12);
  --laser: linear-gradient(90deg, #FF3DF2, #8A5CFF, #19E3FF, #B6FF2E, #FF6A3D, #FF3DF2);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background:
    linear-gradient(var(--grid) 1px, transparent 1px) 0 0 / 40px 40px,
    linear-gradient(90deg, var(--grid) 1px, transparent 1px) 0 0 / 40px 40px,
    radial-gradient(520px 340px at 50% 0%, var(--haze), transparent 75%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 16px;
  line-height: 1.4;
  font-variant-numeric: tabular-nums;
}

.shell {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: calc(env(safe-area-inset-top, 0px) + 14px) 16px 0;
}

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.wordmark {
  font-family: 'Rajdhani', system-ui, sans-serif;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.34em;
  color: var(--accent-text);
}

.who {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: 'Rajdhani', system-ui, sans-serif;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--primary);
}
.who[hidden] { display: none; }

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--primary);
  box-shadow: 0 0 8px var(--primary);
  animation: pulse 2.4s ease-in-out infinite;
}

.laser { height: 4px; background: var(--laser); background-size: 200% 100%; }
[data-theme="riddim"] .laser { animation: slide 3s linear infinite; box-shadow: 0 0 18px var(--glow); }

@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }
@keyframes slide { to { background-position: -200% 0; } }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

.banner {
  margin: 12px 0 0;
  padding: 10px 12px;
  border: 1px solid var(--accent);
  color: var(--accent-text);
  font-size: 14px;
  font-weight: 600;
}

main { flex: 1; padding: 16px 0 24px; }

.panel {
  padding: 18px 16px 20px;
  border: 1px solid var(--line);
  background:
    linear-gradient(var(--primary), var(--primary)) top left / 22px 2px no-repeat,
    linear-gradient(var(--primary), var(--primary)) top left / 2px 22px no-repeat,
    linear-gradient(var(--primary), var(--primary)) bottom right / 22px 2px no-repeat,
    linear-gradient(var(--primary), var(--primary)) bottom right / 2px 22px no-repeat,
    var(--panel);
  box-shadow: 0 0 24px var(--primary-soft);
}
.panel[hidden] { display: none; }

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

h1 {
  margin: 0 0 14px;
  font-family: 'Rajdhani', system-ui, sans-serif;
  font-size: 28px;
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  outline: none;
}

form { display: flex; flex-direction: column; gap: 14px; }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; margin: 0; padding: 0; border: 0; }
.field[hidden] { display: none; }

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

label, legend, .label {
  padding: 0;
  font-family: 'Rajdhani', system-ui, sans-serif;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--primary);
}

input[type="text"], input[type="password"], input[type="date"], select {
  width: 100%;
  min-width: 0;
  height: 48px;
  padding: 0 12px;
  border: 1px solid var(--input-line);
  border-radius: 0;
  background: var(--inset);
  color: var(--text);
  font: inherit;
  font-size: 16px;
  -webkit-appearance: none;
  appearance: none;
}
select {
  padding-right: 34px;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--primary) 50%),
    linear-gradient(135deg, var(--primary) 50%, transparent 50%);
  background-position: calc(100% - 18px) 21px, calc(100% - 12px) 21px;
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
}
input::placeholder { color: var(--muted); opacity: 1; }
input.big {
  height: 58px;
  font-family: 'Rajdhani', system-ui, sans-serif;
  font-size: 30px;
  font-weight: 700;
  border-color: var(--primary);
  box-shadow: 0 0 14px var(--primary-soft);
}
input[type="password"].big { letter-spacing: 0.3em; }

:is(input, select, button):focus-visible, label:has(input:focus-visible) > span {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
[aria-invalid="true"] { border-color: var(--alert) !important; }

.segmented { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.segmented.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.segmented label { display: block; position: relative; }
.segmented input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.segmented span {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  border: 1px solid var(--input-line);
  background: var(--inset);
  color: var(--text);
  font-size: 15px;
  letter-spacing: 0.1em;
}
.segmented input:checked + span {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary);
  box-shadow: 0 0 12px var(--glow);
}

.check { display: flex; align-items: center; gap: 10px; min-height: 44px; text-transform: none; letter-spacing: 0; font-family: inherit; font-size: 15px; font-weight: 400; color: var(--text); }
.check input { width: 22px; height: 22px; accent-color: var(--primary); }

button { font: inherit; color: inherit; cursor: pointer; border-radius: 0; }
button:disabled { opacity: 0.55; cursor: default; }

.primary, .secondary {
  min-height: 52px;
  padding: 0 16px;
  border: 1px solid var(--primary);
  background: var(--primary-soft);
  color: var(--primary);
  font-family: 'Rajdhani', system-ui, sans-serif;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}
.primary.gold {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--on-accent);
  box-shadow: 0 0 18px var(--glow);
}
.secondary { border-color: var(--input-line); background: transparent; color: var(--text); }
.primary.busy::before {
  content: '';
  display: inline-block;
  width: 16px;
  height: 16px;
  margin-right: 10px;
  vertical-align: -2px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.dashed {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 48px;
  border: 1px dashed var(--primary);
  background: var(--primary-soft);
  color: var(--primary);
  font-family: 'Rajdhani', system-ui, sans-serif;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.dashed[hidden] { display: none; }

.link {
  min-height: 44px;
  padding: 0 4px;
  border: 0;
  background: none;
  color: var(--primary);
  font-weight: 600;
  text-decoration: underline;
}

svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }

.receipt { display: flex; align-items: center; gap: 12px; padding: 8px 10px; border: 1px solid var(--input-line); background: var(--inset); }
.receipt[hidden] { display: none; }
.receipt img { width: 56px; height: 56px; object-fit: cover; border: 1px solid var(--line); }
.receipt img[hidden] { display: none; }
.receipt span { flex: 1; min-width: 0; font-size: 14px; overflow-wrap: anywhere; }

.hint { margin: 0; font-size: 13px; color: var(--muted); }
.error { margin: 0; font-size: 14px; font-weight: 600; color: var(--alert); }
.error[hidden] { display: none; }
#form-error, #signin-error { padding: 10px 12px; border: 1px solid var(--alert); background: var(--alert-soft); }

.saved {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  padding: 10px 12px;
  border: 1px solid var(--accent);
  color: var(--accent-text);
  font-weight: 600;
}
.saved[hidden] { display: none; }

.list { list-style: none; margin: 8px 0 0; padding: 0; }
.list li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.list .vendor { font-weight: 600; overflow-wrap: anywhere; }
.list .amount { font-family: 'Rajdhani', system-ui, sans-serif; font-size: 20px; font-weight: 700; text-align: right; }
.list .meta { grid-column: 1 / -1; font-size: 13px; color: var(--muted); }

.tabs {
  position: sticky;
  bottom: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin: 0 -16px;
  padding: 0 8px env(safe-area-inset-bottom, 0px);
  border-top: 1px solid var(--line);
  background: var(--panel);
}
.tabs[hidden] { display: none; }
.tabs button {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 58px;
  border: 0;
  border-top: 3px solid transparent;
  background: none;
  color: var(--muted);
  font-family: 'Rajdhani', system-ui, sans-serif;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.tabs button[aria-current="page"] { border-top-color: var(--accent); color: var(--primary); }

.visually-hidden { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
