:root {
  /* Brand accent = the sea/sky blue from the logo's water (teal was off-brand). */
  --primary: #0369a1;
  --primary-dark: #075985;
  --ink: #1f2937;
  --ink-soft: #6b7280;
  --line: #e5e7eb;
  --bg: #ffffff;
  --bg-soft: #f8fafc;
  --red: #dc2626;
  --amber: #f59e0b;
  --amber-ink: #431407;
  --green: #15803d;
  /* Sunset accents from the logo — decorative only, never status meaning. */
  --sunset-1: #ff6b5a;
  --sunset-2: #ff9e43;
  --sunset-3: #ffd166;
  --bar-h: 1.25rem;
  --radius: 10px;
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  min-height: 100%;
  /* Warm sand backdrop + a faint Nana's Place watermark, painted on the root
     so it sits behind every page (content cards stay opaque for readability). */
  background-color: #fff9f2;
  background-image:
    url("/img/watermark.png"),
    linear-gradient(180deg, #fffaf4 0%, #fdf1e6 100%);
  background-repeat: no-repeat;
  background-position: center 40%, center;
  background-size: min(78vw, 30rem) auto, auto;
  background-attachment: fixed;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: transparent;
}

/* The page itself never scrolls — <main> is the scroll container. The fixed
   bottom ribbon and header therefore never resize or shift when a scrollbar
   comes and goes. (Login page keeps its own centered layout.) */
body:not(.login-body) {
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

button {
  font: inherit;
  cursor: pointer;
}

/* ---------- Top bar ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg);
  padding: 0.5rem 0.75rem 0.4rem;
  box-shadow: 0 1px 6px rgba(15, 23, 42, 0.05);
}

/* Sunset underline lifted from the logo — the header's brand tie-in. */
.topbar::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--sunset-1), var(--sunset-2) 55%, var(--sunset-3));
}

.topbar-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.app-title {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 1.05rem;
  font-weight: 700;
  margin: 0;
  color: var(--primary-dark);
  white-space: nowrap;
}

.brand-logo {
  width: 1.85rem;
  height: 1.85rem;
  flex-shrink: 0;
  object-fit: contain;
}

.month-nav {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin-top: 0.35rem;
}

.month-title {
  font-size: 1.05rem;
  font-weight: 600;
  margin: 0;
  min-width: 9.5rem;
  text-align: center;
}

.nav-btn {
  border: 1px solid #d6e6f2;
  background: linear-gradient(180deg, #ffffff, #eef6fc);
  border-radius: 9px;
  width: 2.1rem;
  height: 2.1rem;
  font-size: 1.25rem;
  line-height: 1;
  color: var(--primary-dark);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

.nav-btn:hover,
.today-btn:hover,
.ghost-btn:hover {
  background: linear-gradient(180deg, #ffffff, #e3f0f9);
}

.today-btn {
  border: 1px solid #d6e6f2;
  background: linear-gradient(180deg, #ffffff, #eef6fc);
  border-radius: 9px;
  padding: 0.35rem 0.7rem;
  font-size: 0.85rem;
  color: var(--primary-dark);
  font-weight: 600;
  margin-left: auto;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

.ghost-btn {
  border: 1px solid var(--line);
  background: var(--bg);
  border-radius: 8px;
  padding: 0.35rem 0.7rem;
  font-size: 0.85rem;
  color: var(--ink-soft);
  text-decoration: none;
}

/* Whose-device chip: lives next to the app title, tap to (re)name. */
.device-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  min-width: 0;
  max-width: 11rem;
  margin-right: auto; /* hug the title; Sign out stays on the right */
  border: 1px solid var(--line);
  background: var(--bg);
  border-radius: 999px;
  padding: 0.28rem 0.65rem;
  font-size: 0.8rem;
  color: var(--ink-soft);
}

.device-chip svg {
  flex-shrink: 0;
  width: 0.8rem;
  height: 0.8rem;
}

.device-chip span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* No name yet → make the chip read as an invitation, not a label. */
.device-chip.unnamed {
  border: 1px dashed var(--primary);
  color: var(--primary);
  font-weight: 600;
}

.hidden {
  display: none !important;
}

/* ---------- Tab bar: fixed to the bottom on phones (thumb reach), ----------
   ---------- inline segmented pills on wide screens                ---------- */

.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 25;
  display: flex;
  align-items: stretch;
  height: calc(4rem + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  /* Frutiger-Aero glass ribbon with a concave notch that cradles the add
     button. Opaque enough — and edged with a real border — that list cards
     scrolling underneath can't muddy it. */
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.93), rgba(224, 244, 255, 0.97));
  backdrop-filter: blur(14px) saturate(1.4);
  -webkit-backdrop-filter: blur(14px) saturate(1.4);
  border-top: 1px solid rgba(43, 107, 143, 0.32);
  box-shadow: 0 -6px 22px rgba(3, 105, 161, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.85);
  -webkit-mask: radial-gradient(circle 2.45rem at 50% 0, transparent 2.44rem, #000 2.45rem);
  mask: radial-gradient(circle 2.45rem at 50% 0, transparent 2.44rem, #000 2.45rem);
}

.tab-group {
  flex: 1;
  display: flex;
  align-items: stretch;
}

.tab-gap {
  flex: 0 0 4.8rem;
}

.tab {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.15rem;
  padding: 0.45rem 0 0.4rem;
  border: none;
  background: none;
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--ink-soft);
}

.tab-ico {
  font-size: 1.2rem;
  line-height: 1;
}

.tab-ico svg {
  display: block;
  width: 1.2em;
  height: 1.2em;
  stroke: currentColor;
}

.tab.active {
  color: var(--primary-dark);
  font-weight: 700;
}

.badge {
  position: absolute;
  top: 2px;
  left: calc(50% + 10px);
  background: var(--red);
  color: #fff;
  border-radius: 999px;
  font-size: 0.65rem;
  font-weight: 700;
  line-height: 1;
  padding: 0.15rem 0.3rem;
  min-width: 0.9rem;
  text-align: center;
}

/* ---------- Calendar ---------- */

main {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  /* Reserve the scrollbar gutter so content never jumps sideways, and skin
     the bar itself to match the water theme instead of the OS default. */
  scrollbar-gutter: stable;
  scrollbar-width: thin;
  scrollbar-color: rgba(3, 105, 161, 0.45) transparent;
  /* clear the bottom tab bar + floating button */
  padding: 0.75rem 0.75rem calc(8.5rem + env(safe-area-inset-bottom, 0px));
}

main > section {
  max-width: 68rem;
  margin: 0 auto;
}

.calendar {
  border: 1px solid #dcebf4;
  border-radius: var(--radius);
  overflow: hidden;
  background: linear-gradient(180deg, #ffffff, #f4fbff);
  box-shadow: 0 6px 18px rgba(3, 105, 161, 0.07);
}

.weekday-head {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  background: linear-gradient(180deg, #e9f7ff, #d5edfb);
  border-bottom: 1px solid #c3e3f5;
}

.weekday-head div {
  text-align: center;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 0.4rem 0;
  color: #2b6b8f;
}

.week {
  position: relative;
}

.day-cells {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
}

.day-cell {
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 0.2rem 0.25rem;
  cursor: pointer;
}

.day-cell:nth-child(7n) {
  border-right: none;
}

.week:last-child .day-cell {
  border-bottom: none;
}

.day-cell.outside {
  background: var(--bg-soft);
}

.day-cell.outside .day-num {
  color: #b6bcc6;
}

.day-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.5rem;
  height: 1.5rem;
  border-radius: 999px;
  font-size: 0.8rem;
  color: var(--ink-soft);
}

.day-num.is-today {
  background: radial-gradient(circle at 50% 32%, #56b8ea, var(--primary));
  color: #fff;
  font-weight: 700;
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.7), 0 1px 3px rgba(3, 105, 161, 0.4);
}

.bars {
  position: relative;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  row-gap: 2px;
  /* padding, not margin: a top margin would collapse through .week and
     let the bars overlap the day numbers */
  padding-top: 1.9rem;
  padding-bottom: 0.3rem;
  pointer-events: none;
}

.bar {
  pointer-events: auto;
  border: none;
  margin: 0 3px;
  padding: 0 0.35rem;
  height: var(--bar-h);
  border-radius: 5px;
  font-size: 0.7rem;
  font-weight: 600;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #fff;
  min-width: 0;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.28);
}

.bar:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 1px;
}

.bar-not_paid {
  background: var(--red);
}

.bar-deposit {
  background: var(--amber);
  color: var(--amber-ink);
}

.bar-paid {
  background: var(--green);
}

.bar.cont-left {
  margin-left: 0;
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
}

.bar.cont-right {
  margin-right: 0;
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}

/* Fingers need bigger targets than mouse pointers (WCAG 2.5.8: ≥24px). */
@media (pointer: coarse) {
  :root {
    --bar-h: 1.6rem;
  }

  .bars {
    row-gap: 3px;
  }
}

/* ---------- Legend ---------- */

.legend {
  display: flex;
  gap: 1rem;
  justify-content: center;
  font-size: 0.8rem;
  color: var(--ink-soft);
  margin: 0.75rem 0 0;
  flex-wrap: wrap;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.dot {
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 3px;
  display: inline-block;
}

.dot-not_paid { background: var(--red); }
.dot-deposit { background: var(--amber); }
.dot-paid { background: var(--green); }

/* ---------- Docked add button (glossy logo + plus badge) ---------- */

.fab {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(1.9rem + env(safe-area-inset-bottom, 0px));
  z-index: 26;
  width: 4.15rem;
  height: 4.15rem;
  padding: 0;
  border: none;
  border-radius: 999px;
  background: radial-gradient(circle at 50% 30%, #ffffff, #eaf5fd 68%, #d6ebf8);
  box-shadow:
    0 10px 22px rgba(3, 105, 161, 0.38),
    inset 0 2px 2px rgba(255, 255, 255, 0.95),
    inset 0 -5px 10px rgba(3, 105, 161, 0.14);
  display: grid;
  place-items: center;
}

.fab:hover {
  background: radial-gradient(circle at 50% 30%, #ffffff, #e2f1fb 68%, #c9e4f6);
}

.fab:active {
  transform: translateX(-50%) scale(0.96);
}

.fab-logo {
  width: 3.25rem;
  height: 3.25rem;
  border-radius: 999px;
  object-fit: cover;
  pointer-events: none;
}

.fab-plus {
  position: absolute;
  top: 0.02rem;
  right: 0.02rem;
  width: 1.55rem;
  height: 1.55rem;
  border-radius: 999px;
  border: 2px solid #fff;
  background: linear-gradient(180deg, #45ace2, var(--primary));
  color: #fff;
  display: grid;
  place-items: center;
  box-shadow: 0 2px 5px rgba(3, 105, 161, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

.fab-plus svg {
  width: 0.85rem;
  height: 0.85rem;
}

/* ---------- Dialogs & forms ---------- */

.dialog {
  border: none;
  border-radius: 14px;
  padding: 0;
  width: min(26rem, calc(100vw - 2rem));
  background: var(--bg);
  color: var(--ink);
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.3);
}

.dialog::backdrop {
  background: rgba(15, 23, 42, 0.45);
}

.dialog form,
.details {
  padding: 1.1rem 1.2rem 1.2rem;
}

.dialog h3 {
  margin: 0 0 0.75rem;
  font-size: 1.15rem;
}

.dialog label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--ink-soft);
  margin: 0.7rem 0 0.25rem;
}

.dialog input,
.dialog select {
  width: 100%;
  padding: 0.55rem 0.6rem;
  border: 1px solid #cfe1ee;
  border-radius: 9px;
  font: inherit;
  font-size: 0.95rem;
  background: linear-gradient(180deg, #f7fbfe, #ffffff);
  color: var(--ink);
  box-shadow: inset 0 1px 2px rgba(3, 105, 161, 0.06);
}

.dialog input:focus,
.dialog select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(3, 105, 161, 0.18), inset 0 1px 2px rgba(3, 105, 161, 0.06);
}

.date-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
}

/* ---------- Custom date picker ---------- */

.dp-field {
  position: relative;
}

.dp-trigger {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.55rem 0.6rem;
  border: 1px solid #cfe1ee;
  border-radius: 9px;
  font: inherit;
  font-size: 0.95rem;
  text-align: left;
  background: linear-gradient(180deg, #f7fbfe, #ffffff);
  color: var(--ink);
  box-shadow: inset 0 1px 2px rgba(3, 105, 161, 0.06);
}

.dp-trigger.is-empty .dp-trigger-text {
  color: var(--ink-soft);
}

.dp-trigger-text {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dp-trigger-icon {
  display: inline-flex;
  color: var(--primary);
}

.dp-trigger-icon svg {
  width: 1.05rem;
  height: 1.05rem;
}

.dp-field.dp-open .dp-trigger,
.dp-trigger:focus-visible {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(3, 105, 161, 0.18), inset 0 1px 2px rgba(3, 105, 161, 0.06);
}

.dp-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(15, 23, 42, 0.45);
}

.dp-pop {
  position: fixed;
  z-index: 41;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(26rem, calc(100vw - 2rem));
  max-height: calc(100vh - 2rem);
  overflow-y: auto;
  padding: 0.9rem 1rem 1.1rem;
  background: var(--bg);
  border: 1px solid #cfe1ee;
  border-radius: 14px;
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.3);
}

.dp-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.7rem;
}

.dp-heading {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--ink);
}

.dp-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  flex-shrink: 0;
  border: 1px solid var(--line);
  background: var(--bg);
  border-radius: 8px;
  color: var(--ink-soft);
}

.dp-close:hover {
  background: linear-gradient(180deg, #ffffff, #e3f0f9);
  color: var(--ink);
}

.dp-close svg {
  width: 1.05rem;
  height: 1.05rem;
}

.dp-head {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  margin-bottom: 0.5rem;
}

.dp-nav {
  border: 1px solid #d6e6f2;
  background: linear-gradient(180deg, #ffffff, #eef6fc);
  border-radius: 8px;
  width: 2rem;
  height: 2rem;
  font-size: 1.15rem;
  line-height: 1;
  color: var(--primary-dark);
}

.dp-nav:hover {
  background: linear-gradient(180deg, #ffffff, #e3f0f9);
}

.dp-title {
  flex: 1;
  text-align: center;
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--primary-dark);
}

.dp-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}

.dp-weekday {
  text-align: center;
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: #2b6b8f;
  padding-bottom: 0.2rem;
}

.dp-day {
  aspect-ratio: 1;
  border: none;
  border-radius: 8px;
  background: transparent;
  font-size: 0.9rem;
  color: var(--ink);
}

.dp-day:hover:not(:disabled) {
  background: #e9f7ff;
}

.dp-day.dp-outside {
  color: #b6bcc6;
}

.dp-day.dp-today {
  font-weight: 700;
  box-shadow: inset 0 0 0 1.5px var(--primary);
}

.dp-day.dp-selected {
  background: radial-gradient(circle at 50% 32%, #56b8ea, var(--primary));
  color: #fff;
  font-weight: 700;
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.7), 0 1px 3px rgba(3, 105, 161, 0.4);
}

.dp-day.dp-disabled {
  color: #cdd3db;
  cursor: default;
}

.dp-day:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: -2px;
}

.field-error {
  color: var(--red);
  font-size: 0.78rem;
  margin: 0.2rem 0 0;
  min-height: 0;
}

.field-error:empty {
  display: none;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 0.5rem;
  margin-top: 1.1rem;
}

.spacer {
  flex: 1;
}

.primary-btn {
  background: linear-gradient(180deg, #3ea7dd 0%, var(--primary) 55%, var(--primary-dark) 100%);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 0.58rem 1.1rem;
  font-weight: 700;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.55), 0 2px 7px rgba(3, 105, 161, 0.3);
}

.primary-btn:hover {
  background: linear-gradient(180deg, #2f97cf, var(--primary-dark));
}

.primary-btn:disabled,
.danger-btn:disabled {
  opacity: 0.6;
  cursor: default;
}

.danger-btn {
  background: #fff;
  color: var(--red);
  border: 1px solid var(--red);
  border-radius: 8px;
  padding: 0.5rem 0.9rem;
  font-weight: 600;
}

.danger-btn:hover {
  background: #fef2f2;
}

/* ---------- Confirm dialog ---------- */

.confirm {
  padding: 1.3rem 1.3rem 1.15rem;
  text-align: center;
}

.confirm-icon {
  width: 3rem;
  height: 3rem;
  margin: 0 auto 0.7rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: #e0f2fe;
  color: var(--primary);
}

.confirm-icon.danger {
  background: #fee2e2;
  color: var(--red);
}

.confirm-icon svg {
  width: 1.55rem;
  height: 1.55rem;
}

.confirm h3 {
  margin: 0 0 0.35rem;
}

.confirm-msg {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.92rem;
  line-height: 1.45;
}

.confirm .dialog-actions {
  justify-content: center;
  margin-top: 1.25rem;
}

.confirm .dialog-actions button {
  min-width: 7rem;
  min-height: 2.6rem;
}

/* A destructive confirm gets a solid red button — clearer than the outline
   .danger-btn used for the inline delete affordance. */
.confirm .dialog-actions .danger-btn {
  background: var(--red);
  color: #fff;
  border-color: var(--red);
}

.confirm .dialog-actions .danger-btn:hover {
  background: #b91c1c;
}

/* ---------- Details dialog ---------- */

.status-chip {
  display: inline-block;
  border-radius: 999px;
  padding: 0.2rem 0.7rem;
  font-size: 0.8rem;
  font-weight: 700;
  margin: 0 0 0.5rem;
}

.chip-not_paid { background: #fee2e2; color: #991b1b; }
.chip-deposit { background: #fef3c7; color: #92400e; }
.chip-paid { background: #dcfce7; color: #166534; }

.details-list {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.35rem 0.9rem;
  margin: 0.5rem 0 0;
  font-size: 0.92rem;
}

.details-list dt {
  color: var(--ink-soft);
  font-weight: 600;
}

.details-list dd {
  margin: 0;
}

/* ---------- Outstanding payments view ---------- */

.view-title {
  font-size: 1.05rem;
  font-weight: 700;
  text-align: center;
  margin: 0.5rem 0 0;
}

.view-sub {
  text-align: center;
  color: var(--ink-soft);
  font-size: 0.83rem;
  margin: 0.2rem 0 0.75rem;
}

.pay-group {
  max-width: 34rem;
  margin: 0 auto 1.1rem;
}

.group-title {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin: 0.9rem 0.15rem 0.5rem;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: #2b6b8f;
}

/* Watery fade-out rule after each heading — quiet section separators. */
.group-title::after {
  content: "";
  flex: 1;
  height: 2px;
  border-radius: 2px;
  background: linear-gradient(90deg, rgba(86, 184, 234, 0.55), rgba(86, 184, 234, 0));
}

.group-sub {
  margin: -0.25rem 0.15rem 0.5rem;
  font-size: 0.78rem;
  color: var(--ink-soft);
}

/* The chase-up section wears the sunset palette so it reads "overdue" at a
   glance without shouting red. */
.pay-group-followup .group-title {
  color: #b4552f;
}

.pay-group-followup .group-title::after {
  background: linear-gradient(90deg, rgba(255, 158, 67, 0.6), rgba(255, 158, 67, 0));
}

.outstanding-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.outstanding-row {
  display: flex;
  align-items: stretch;
  border: 1px solid #dcebf4;
  border-radius: 14px;
  background: linear-gradient(180deg, #ffffff, #f4fbff);
  box-shadow: 0 4px 14px rgba(3, 105, 161, 0.08), inset 0 1px 0 rgba(255, 255, 255, 0.9);
  overflow: hidden;
}

.pay-group-followup .outstanding-row {
  border-color: #f2d8c6;
  background: linear-gradient(180deg, #fffdfb, #fdf3ea);
  box-shadow: 0 4px 14px rgba(214, 116, 61, 0.09), inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

/* Just marked paid: calm green glass while the Undo window is open. */
.outstanding-row.is-done {
  border-color: #bfe3cd;
  background: linear-gradient(180deg, #f4fcf6, #e4f7eb);
}

.row-main {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.65rem 0.5rem 0.65rem 0.75rem;
  border: none;
  background: none;
  text-align: left;
  font: inherit;
  color: inherit;
}

.row-main:hover {
  background: rgba(224, 244, 255, 0.45);
}

/* Inset rings: the row card's overflow:hidden would clip an outset ring */
.row-main:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: -2px;
}

.mini-btn:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: -2px;
}

.row-glyph {
  flex-shrink: 0;
  width: 2rem;
  height: 2rem;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  border: 1px solid rgba(255, 255, 255, 0.7);
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.85), 0 1px 2px rgba(15, 23, 42, 0.08);
}

.row-info {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.row-name {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.row-meta {
  font-size: 0.8rem;
  color: var(--ink-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.row-meta .done-note {
  color: var(--green);
  font-weight: 600;
}

/* Fixed-width, right-aligned, tabular digits: every peso amount in the list
   lines up down the column no matter the row. */
.row-price {
  margin-left: auto;
  flex-shrink: 0;
  min-width: 4.4rem;
  text-align: right;
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--primary-dark);
  font-variant-numeric: tabular-nums;
}

/* Fixed-width action rail so one-button and two-button rows align. */
.row-actions {
  flex: 0 0 6.5rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.5rem 0.6rem;
  border-left: 1px solid #dcebf4;
  background: rgba(255, 255, 255, 0.55);
}

.pay-group-followup .row-actions {
  border-left-color: #f2d8c6;
}

.outstanding-row.is-done .row-actions {
  border-left-color: #bfe3cd;
}

.mini-btn {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.35rem 0.6rem;
  font-size: 0.78rem;
  font-weight: 600;
  min-height: 2rem;
  white-space: nowrap;
}

.mini-btn.pay {
  background: linear-gradient(180deg, #3fb46a, var(--green));
  border-color: #12703a;
  color: #fff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4), 0 1px 3px rgba(21, 128, 61, 0.3);
}

.mini-btn.pay:hover {
  background: linear-gradient(180deg, #34a25e, #166534);
}

.mini-btn.dep {
  background: linear-gradient(180deg, #fef6d4, #fde68a);
  border-color: #fbd964;
  color: var(--amber-ink);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

.mini-btn.dep:hover {
  background: linear-gradient(180deg, #fdeeb0, #fbd964);
}

/* Armed = one more tap saves. A halo ring + darker glass makes it obvious. */
.mini-btn.armed {
  font-weight: 700;
}

.mini-btn.pay.armed {
  background: linear-gradient(180deg, #2f9d5c, #0e5c30);
  box-shadow: 0 0 0 3px rgba(21, 128, 61, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.35);
}

.mini-btn.dep.armed {
  background: linear-gradient(180deg, #fbd964, #f2ae2a);
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

.mini-btn.undo {
  background: linear-gradient(180deg, #eef8ff, #cfe9fa);
  border-color: #9ccbe6;
  color: var(--primary-dark);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.mini-btn.undo:hover {
  background: linear-gradient(180deg, #e2f2fd, #bfe1f6);
}

.empty-state {
  text-align: center;
  color: var(--ink-soft);
  margin-top: 2.5rem;
  font-size: 0.95rem;
}

/* ---------- Activity log view (owner only) ---------- */

.activity-tools {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  margin: 0 0 0.9rem;
}

.activity-list {
  list-style: none;
  margin: 0 auto;
  padding: 0;
  max-width: 34rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.activity-row {
  display: flex;
  gap: 0.6rem;
  align-items: flex-start;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg);
  padding: 0.6rem 0.75rem;
}

.act-icon {
  flex-shrink: 0;
  color: var(--ink-soft);
}

.act-icon svg {
  display: block;
  width: 1.2rem;
  height: 1.2rem;
  margin-top: 0.15rem;
  stroke: currentColor;
}

.act-created .act-icon { color: var(--green); }
.act-updated .act-icon { color: var(--primary); }
.act-deleted .act-icon { color: var(--red); }
.act-signed_in .act-icon { color: var(--primary); }
.act-login_failed .act-icon { color: var(--red); }
.act-device_renamed .act-icon { color: var(--ink-soft); }
.act-owner_unlocked .act-icon { color: var(--green); }
.act-owner_unlock_failed .act-icon { color: var(--red); }
.act-owner_code_requested .act-icon { color: var(--primary); }
.act-owner_code_refused .act-icon { color: var(--red); }
.act-audit_exported .act-icon { color: var(--primary); }

.act-body {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.act-title {
  font-weight: 600;
  font-size: 0.92rem;
  overflow-wrap: anywhere;
}

.act-line {
  font-size: 0.83rem;
  color: var(--ink);
  overflow-wrap: anywhere;
}

.act-meta {
  font-size: 0.76rem;
  color: var(--ink-soft);
  margin-top: 0.15rem;
  overflow-wrap: anywhere;
}

.act-login_failed .act-title,
.act-owner_unlock_failed .act-title,
.act-owner_code_refused .act-title {
  color: var(--red);
}

.load-more-wrap {
  text-align: center;
  margin: 0.75rem 0 0;
}

.dialog-sub {
  margin-top: -0.35rem;
}


/* ---------- Toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(8rem + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  border-radius: 999px;
  padding: 0.55rem 1.1rem;
  font-size: 0.88rem;
  z-index: 30;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.25);
  max-width: calc(100vw - 2rem);
}

/* ---------- Login page ---------- */

.login-body {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(170deg, #fff3e0 0%, #ffe0d3 55%, #ffcbc0 100%);
  padding: 1rem;
}

.login-card {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 1.75rem 1.5rem;
  width: min(22rem, 100%);
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
  text-align: center;
}

.login-logo {
  display: block;
  width: 7rem;
  height: 7rem;
  margin: 0 auto 0.5rem;
  object-fit: contain;
}

.login-title {
  justify-content: center;
  font-size: 1.35rem;
}

.login-sub {
  color: var(--ink-soft);
  margin: 0.25rem 0 1rem;
  font-size: 0.9rem;
}

.login-card form {
  text-align: left;
}

.login-card label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--ink-soft);
  margin: 0.7rem 0 0.25rem;
}

.login-card input {
  width: 100%;
  padding: 0.6rem 0.65rem;
  border: 1px solid #cfe1ee;
  border-radius: 9px;
  font: inherit;
  background: linear-gradient(180deg, #f7fbfe, #ffffff);
  box-shadow: inset 0 1px 2px rgba(3, 105, 161, 0.06);
}

.login-card input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(3, 105, 161, 0.18), inset 0 1px 2px rgba(3, 105, 161, 0.06);
}

.login-btn {
  width: 100%;
  margin-top: 1rem;
  padding: 0.65rem;
}

/* ---------- Larger screens ---------- */

@media (min-width: 700px) {
  :root {
    --bar-h: 1.35rem;
  }

  .topbar {
    padding: 0.6rem 1.25rem;
  }

  .month-nav {
    max-width: 68rem;
    margin: 0.4rem auto 0;
  }

  /* Tab bar joins the header as segmented pills (drop the mobile glass ribbon) */
  .tabbar {
    position: static;
    height: auto;
    border-top: none;
    background: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    box-shadow: none;
    -webkit-mask: none;
    mask: none;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 0.5rem;
    padding-bottom: 0;
  }

  .tab-group {
    display: contents;
  }

  .tab-gap {
    display: none;
  }

  .tab {
    flex: 0 0 auto;
    flex-direction: row;
    gap: 0.4rem;
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 0.4rem 1rem;
    font-size: 0.85rem;
  }

  .tab:hover {
    background: var(--bg-soft);
  }

  .tab.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
  }

  .tab-ico {
    font-size: 1rem;
  }

  .badge {
    position: static;
    margin-left: 0.1rem;
  }

  main {
    padding-bottom: 5.5rem;
  }

  .fab {
    left: auto;
    right: 1.25rem;
    bottom: 1.25rem;
    transform: none;
  }

  .fab:active {
    transform: scale(0.96);
  }

  .toast {
    bottom: 2rem;
  }

  .bars {
    min-height: 5rem;
  }

  .bar {
    font-size: 0.78rem;
  }

  .day-cell {
    padding: 0.3rem 0.4rem;
  }
}
