@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;600;800;900&display=swap');

/* Ziko - Mobile-first visual system */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --c-bg: #ffffff;
  --c-surface: #ffffff;
  --c-surface-2: #fcfcfc;
  --c-text: #212529;
  --c-muted: #6c757d;
  --c-border: #ececec;
  --c-brand: #8b0000;
  --c-brand-strong: #600000;
  --c-brand-grad: linear-gradient(135deg, #8b0000 0%, #600000 100%);
  --c-warn: #fbbf24;
  --c-danger: #f87171;
  --c-good: #34d399;
  --radius-lg: 24px;
  --radius-md: 16px;
  --shadow: 0 18px 36px rgba(33, 37, 41, 0.08);
  --shadow-soft: 0 10px 22px rgba(33, 37, 41, 0.06);
  --glass-blur: blur(24px);
}

html {
  font-family: "Outfit", sans-serif;
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

body {
  position: relative;
  min-height: 100dvh;
  color: var(--c-text);
  background:
    radial-gradient(circle at 14% 12%, rgba(255, 255, 255, 1) 0%, rgba(255, 255, 255, 0.95) 28%, transparent 66%),
    radial-gradient(circle at 84% 18%, rgba(255, 255, 255, 0.98) 0%, rgba(255, 255, 255, 0.88) 34%, transparent 70%),
    linear-gradient(180deg, #ffffff 0%, #ffffff 62%, #fdfdfd 100%);
  padding-top: env(safe-area-inset-top);
  padding-right: env(safe-area-inset-right);
  padding-bottom: env(safe-area-inset-bottom);
  padding-left: env(safe-area-inset-left);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    radial-gradient(circle at 6% 12%, rgba(255, 255, 255, 0.86) 0 1.2px, transparent 2px),
    radial-gradient(circle at 22% 26%, rgba(255, 255, 255, 0.8) 0 1.1px, transparent 1.9px),
    radial-gradient(circle at 38% 14%, rgba(255, 255, 255, 0.78) 0 1.1px, transparent 1.9px),
    radial-gradient(circle at 54% 22%, rgba(255, 255, 255, 0.76) 0 1.2px, transparent 2px),
    radial-gradient(circle at 72% 18%, rgba(255, 255, 255, 0.74) 0 1.1px, transparent 1.9px),
    radial-gradient(circle at 88% 30%, rgba(255, 255, 255, 0.72) 0 1.15px, transparent 2px),
    radial-gradient(circle at 14% 62%, rgba(255, 255, 255, 0.76) 0 1.2px, transparent 2px),
    radial-gradient(circle at 34% 72%, rgba(255, 255, 255, 0.7) 0 1.1px, transparent 1.9px),
    radial-gradient(circle at 58% 66%, rgba(255, 255, 255, 0.68) 0 1.2px, transparent 2px),
    radial-gradient(circle at 78% 74%, rgba(255, 255, 255, 0.64) 0 1.1px, transparent 1.9px);
  opacity: 0.75;
  z-index: 0;
  animation: sparkleDrift 7.5s ease-in-out infinite alternate;
}

@keyframes sparkleDrift {
  0% {
    opacity: 0.68;
    filter: brightness(1);
  }
  100% {
    opacity: 0.84;
    filter: brightness(1.04);
  }
}

img {
  display: block;
  max-width: 100%;
}

button, input {
  font: inherit;
}

input {
  border: 1px solid var(--c-border);
  border-radius: 12px;
  padding: 0.75rem 1rem;
  width: 100%;
  background: #ffffff;
  color: var(--c-text);
  transition: all 0.3s ease;
}

input:focus-visible {
  outline: none;
  border-color: var(--c-brand);
  box-shadow: 0 0 0 3px rgba(139, 0, 0, 0.15);
}

.btn {
  border: none;
  border-radius: 10px;
  padding: 0.58rem 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.12s ease, opacity 0.15s ease, background 0.15s ease;
}

.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  background: var(--c-brand-grad);
  color: #fff;
  border: none;
  box-shadow: 0 10px 22px rgba(139, 0, 0, 0.16);
}

.btn-primary:hover,
.btn-primary:focus-visible {
  background: linear-gradient(135deg, #a60000 0%, #700000 100%);
  box-shadow: 0 12px 24px rgba(139, 0, 0, 0.22);
  transform: translateY(-2px);
}

.btn-ghost {
  background: transparent;
  color: var(--c-muted);
}

.btn-danger {
  background: #fee2e2;
  color: var(--c-danger);
}

.btn-inline {
  padding: 0.4rem 0.58rem;
  font-size: 0.82rem;
}

.install-banner {
  position: fixed;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 1rem);
  left: 1rem;
  right: 1rem;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-soft);
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.8rem;
  z-index: 120;
  transform: translateY(calc(100% + 1.5rem));
  opacity: 0;
  pointer-events: none;
  transition: transform 0.35s ease, opacity 0.25s ease;
}

.install-banner.visible {
  transform: translateY(0);
  opacity: 1;
  pointer-events: auto;
}

.install-banner__icon img {
  border-radius: 10px;
}

.install-banner__text {
  flex: 1;
  min-width: 0;
}

.install-banner__text strong {
  display: block;
  font-size: 0.9rem;
}

.install-banner__text span {
  color: var(--c-muted);
  font-size: 0.78rem;
}

.install-banner__actions {
  display: flex;
}

.ios-guide {
  position: fixed;
  left: 1rem;
  right: 1rem;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 1rem);
  z-index: 130;
  opacity: 0;
  pointer-events: none;
  transform: translateY(calc(100% + 1.5rem));
  transition: transform 0.35s ease, opacity 0.25s ease;
}

.ios-guide.visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.ios-guide__sheet {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  align-items: center;
  text-align: center;
}

.ios-guide__sheet img {
  width: 58px;
  height: 58px;
  border-radius: 14px;
}

.ios-guide__sheet h2 {
  font-size: 1.03rem;
}

.ios-guide__sheet p,
.ios-guide__sheet li {
  color: var(--c-muted);
  font-size: 0.87rem;
}

.ios-guide__sheet ol {
  text-align: left;
  width: 100%;
  padding-left: 1.2rem;
}

#app {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.install-banner.visible ~ #app {
  padding-bottom: 6.5rem;
}

.ios-guide.visible ~ #app {
  padding-bottom: 15rem;
}

.app-header {
  background:
    radial-gradient(ellipse 65% 55% at 8% 15%, rgba(139, 0, 0, 0.22) 0%, transparent 65%),
    radial-gradient(ellipse 40% 50% at 97% 15%, rgba(139, 0, 0, 0.18) 0%, transparent 65%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.99) 0%, rgba(255, 255, 255, 0.97) 100%);
  border-bottom-left-radius: 42px 30px;
  border-bottom-right-radius: 78px 48px;
  color: var(--c-text);
  padding: 1.1rem 1rem 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 0.95rem;
  box-shadow: 0 18px 38px rgba(33, 37, 41, 0.08);
  position: relative;
  overflow: hidden;
}

.app-header::before {
  content: "";
  position: absolute;
  left: -4%;
  right: 10%;
  bottom: -32px;
  height: 72px;
  border-radius: 0 0 999px 999px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 12px 24px rgba(33, 37, 41, 0.05);
  pointer-events: none;
}

.app-header::after {
  content: "";
  position: absolute;
  inset: auto -15% -20% 45%;
  height: 140px;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.95) 0%, transparent 72%);
  pointer-events: none;
}

.header-top-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.9rem;
  position: relative;
  z-index: 1;
}

.brand-lockup {
  min-width: 0;
  display: grid;
  gap: 0.15rem;
}

.app-logo {
  margin: 0;
  line-height: 0.9;
  display: flex;
  align-items: flex-end;
}

.logo-mark {
  font-size: clamp(3rem, 14vw, 3.6rem);
  font-weight: 900;
  color: var(--c-brand);
  letter-spacing: -0.08em;
}

.logo-word {
  font-size: clamp(1.55rem, 7vw, 1.9rem);
  font-weight: 800;
  margin-left: 0.08rem;
  color: var(--c-text);
}

.app-kicker {
  font-size: 0.66rem;
  color: var(--c-muted);
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.profile-menu-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #f8e6e6 0%, #efe4df 100%);
  border: 1px solid #e1cbc0;
  border-radius: 999px;
  width: 2.6rem;
  height: 2.6rem;
  padding: 0;
  color: var(--c-brand-strong);
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.03em;
  cursor: pointer;
  transition: transform .18s, border-color .18s, box-shadow .18s;
  flex-shrink: 0;
  align-self: center;
  box-shadow: 0 8px 20px rgba(139, 0, 0, 0.13);
  margin-left: auto;
}

.profile-menu-btn:hover,
.profile-menu-btn:focus-visible,
.profile-menu-btn[aria-expanded="true"] {
  transform: translateY(-1px);
  border-color: #c89f8a;
  box-shadow: 0 10px 24px rgba(139, 0, 0, 0.2);
}

.profile-initials {
  line-height: 1;
}

.profile-menu {
  position: fixed;
  top: 5rem; /* overridden by JS to sit below actual header */
  right: 1rem;
  width: min(300px, calc(100vw - 2rem));
  /* overflow must stay visible so ::before/::after arrow shows */
  overflow: visible;
  border: none;
  background: transparent;
  box-shadow: none;
  z-index: 60;
  /* callout gap — space for the arrow */
  margin-top: 10px;
}

/* the actual rounded card */
.profile-menu__inner {
  background: #fff;
  border: 1px solid #ecd8d1;
  border-radius: 16px;
  box-shadow: 0 18px 36px rgba(33, 37, 41, 0.13);
  padding: 1rem;
  max-height: calc(100vh - 6rem);
  overflow-y: auto;
}

/* callout arrow pointing up toward the avatar button */
.profile-menu::before,
.profile-menu::after {
  content: '';
  position: absolute;
  right: var(--pm-arrow-right, 20px); /* set dynamically by JS to center on avatar */
  bottom: 100%;
  width: 0;
  height: 0;
  border-style: solid;
  pointer-events: none;
}

/* border/shadow layer of arrow */
.profile-menu::before {
  border-width: 0 11px 12px 11px;
  border-color: transparent transparent #ecd8d1 transparent;
  margin-bottom: 1px;
}

/* white fill of arrow */
.profile-menu::after {
  border-width: 0 10px 11px 10px;
  border-color: transparent transparent #fff transparent;
}

.profile-menu__head {
  display: grid;
  gap: 0.18rem;
  padding-bottom: 0.65rem;
  margin-bottom: 0.65rem;
  border-bottom: 1px solid #f0e2dc;
}

.profile-menu__head strong {
  color: var(--c-text);
  font-size: 0.95rem;
}

.profile-menu__head span {
  color: var(--c-muted);
  font-size: 0.8rem;
}

.profile-menu__actions {
  display: grid;
  gap: 0.4rem;
}

.profile-menu__btn {
  justify-content: flex-start;
  border: 1px solid var(--c-border);
  background: #fff;
  color: var(--c-text);
  font-size: 0.88rem;
  padding: 0.55rem 0.7rem;
}

.profile-menu__btn.btn-danger {
  border-color: #fecaca;
}

/* ── Profile menu Vizra branding ─────────────────────────────────────────── */
.profile-menu__vizra {
  display: flex;
  flex-direction: column;
  gap: 0.18rem;
  padding: 0.55rem 0.7rem 0.5rem;
  border-top: 1px solid var(--c-border);
  margin-top: 0.3rem;
  font-size: 0.73rem;
  color: #9ca3af;
}
.profile-menu__vizra a {
  color: var(--c-brand);
  text-decoration: none;
  font-weight: 600;
  cursor: pointer;
  transition: color 0.18s;
}
.profile-menu__vizra a:hover { color: #ea580c; text-decoration: underline; }
.profile-menu__vizra-line1 { color: #9ca3af; }
.profile-menu__vizra-line2 { color: #6b7280; }
.profile-menu__vizra-tagline { color: #9ca3af; font-style: italic; }

/* ── Vizra footer ─────────────────────────────────────────────────────────── */
.vizra-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.75rem 1rem 1.1rem;
  font-size: 0.72rem;
  color: #9ca3af;
  flex-wrap: wrap;
}
.vizra-footer__link {
  color: var(--c-brand);
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  transition: color 0.18s;
}
.vizra-footer__link:hover { color: #ea580c; text-decoration: underline; }
.vizra-footer__sep { color: #d1d5db; }
.vizra-footer__product {
  color: #6b7280;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: color 0.18s;
}
.vizra-footer__product:hover { color: #ea580c; text-decoration: underline; }
.vizra-footer__tagline { color: #9ca3af; font-style: italic; }

/* .profile-menu top is set dynamically by JS based on header height */

.header-bottom-row {
  display: grid;
  grid-template-columns: 118px minmax(0, 1fr) auto;
  gap: 0.55rem;
  align-items: center;
  position: relative;
  z-index: 1;
}

.header-wave {
  position: absolute;
  bottom: -14px;
  left: 0;
  right: 0;
  line-height: 0;
  z-index: 2;
  pointer-events: none;
}
.header-wave svg {
  display: block;
  width: 100%;
  height: 44px;
}
.app-subtitle {
  font-size: 0.8rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--c-muted);
  font-weight: 700;
}

.app-tagline {
  color: var(--c-muted);
  font-size: 0.77rem;
  max-width: 42ch;
}

.month-picker-wrap {
  min-width: 0;
  background: #ffffff;
  color: var(--c-text);
  border-radius: 18px;
  padding: 0.3rem 0.85rem;
  border: 1px solid rgba(139, 0, 0, 0.08);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}
.month-picker-wrap label {
  display: block;
  font-size: 0.7rem;
  margin-bottom: 0.15rem;
  color: var(--c-muted);
  font-weight: 700;
  opacity: 1;
}
.month-picker-wrap input {
  padding: 0.45rem 0;
  background: transparent;
  border: none;
  color: var(--c-brand);
  box-shadow: none;
  font-size: 1rem;
  font-weight: 800;
  width: 100%;
  min-width: 0;
}
.month-picker-wrap input::-webkit-calendar-picker-indicator {
  cursor: pointer;
}

.month-picker-shell {
  display: flex;
  align-items: center;
  justify-content: center;
}

.app-main {
  width: min(1080px, 100%);
  margin: 0 auto;
  padding: 0 0.85rem 1.15rem;
  display: flex;
  flex-direction: column;
  gap: 0.95rem;
}

.app-nav {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.25rem;
  position: sticky;
  top: 0.4rem;
  z-index: 40;
  padding: 0.15rem 0.1rem 0.25rem;
  border-bottom: 1px solid #ece5dc;
  margin-top: 0.6rem;
}

.nav-btn {
  border: none;
  border-radius: 0;
  background: transparent;
  color: var(--c-muted);
  padding: 0.6rem 0.2rem 0.72rem;
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: color 0.2s ease;
  position: relative;
}

.nav-btn::after {
  content: "";
  position: absolute;
  left: 12%;
  right: 12%;
  bottom: 0.08rem;
  height: 3px;
  border-radius: 3px;
  background: var(--c-brand-grad);
  transform: scaleX(0);
  transform-origin: center;
  transition: transform 0.22s ease;
}

.nav-btn:hover {
  color: var(--c-brand-strong);
}

.nav-btn.is-active {
  color: var(--c-brand-strong);
}

.nav-btn.is-active::after {
  transform: scaleX(1);
}

.app-view {
  display: none;
  flex-direction: column;
  gap: 0.95rem;
}

.app-view.is-active {
  display: flex;
}

.toast {
  opacity: 0;
  transition: opacity 0.2s ease, min-height 0.2s ease;
  background: rgba(16, 185, 129, 0.2); backdrop-filter: var(--glass-blur); color: #fff;
  border: 1px solid transparent;
  color: #064e3b;
  border-radius: 14px;
  padding: 0;
  font-weight: 700;
  font-size: 0.88rem;
  min-height: 0;
  overflow: hidden;
}

.toast.visible {
  opacity: 1;
  border-color: #10b981;
  background: rgba(16, 185, 129, 0.2);
  padding: 0.58rem 0.78rem;
  min-height: 2.2rem;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.7rem;
}

.metric-card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-md);
  padding: 0.95rem 0.85rem;
  box-shadow: var(--shadow);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  transition: transform 0.3s ease;
}
.metric-card:hover {
  transform: translateY(-2px);
  border-color: rgba(255,255,255,0.2);
}

.metric-card h2 {
  font-size: 0.78rem;
  color: var(--c-muted);
  font-weight: 700;
}

.metric-value {
  font-size: clamp(1rem, 5vw, 1.8rem);
  font-weight: 800;
  margin-top: 0.35rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.panel {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
}

.panel-head h2 {
  font-size: 1.18rem;
}

.panel-head p {
  color: var(--c-muted);
  font-size: 0.92rem;
  line-height: 1.5;
}

.fixed-head-tools {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  width: 100%;
  margin-top: 0.4rem;
}

.fixed-head-tools .icon-btn {
  margin-top: 0;
}

.fixed-total-pill {
  border: 1px solid var(--c-border);
  border-radius: 999px;
  background: #ffffff;
  color: var(--c-text);
  padding: 0.36rem 0.62rem;
  font-size: 0.8rem;
  font-weight: 800;
  margin-left: auto;
}

.icon-btn {
  width: 2.2rem;
  height: 2.2rem;
  border-radius: 999px;
  border: 1px solid var(--c-border);
  background: #ffffff;
  color: var(--c-brand-strong);
  font-size: 1.2rem;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: 0.4rem;
  transition: all 0.3s ease;
}
.icon-btn:hover {
  background: #f8f9fa;
  transform: scale(1.05);
}
.icon-btn[aria-expanded="true"] {
  background: var(--c-brand-grad);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 4px 12px rgba(139, 0, 0, 0.2);
}

.collapsible {
  display: none;
}

.collapsible.is-open {
  display: block;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.7rem;
}

.form-row label {
  display: grid;
  gap: 0.35rem;
  font-weight: 700;
  font-size: 0.92rem;
}

.progress-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.84rem;
  color: var(--c-muted);
  margin-bottom: 0.3rem;
}

.progress-labels strong {
  color: var(--c-text);
}

.progress-bar {
  width: 100%;
  height: 14px;
  border-radius: 999px;
  background: #e9ecef;
  overflow: hidden;
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.1);
}

.progress-fill {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, #16a34a, #15803d);
  transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 0 8px rgba(22,163,74,0.3);
}

.progress-fill.safe {
  background: linear-gradient(90deg, #16a34a, #15803d);
  box-shadow: 0 0 8px rgba(22,163,74,0.3);
}

.progress-fill.caution {
  background: linear-gradient(90deg, #eab308, #ca8a04);
  box-shadow: 0 0 8px rgba(234,179,8,0.3);
}

.progress-fill.warning {
  background: linear-gradient(90deg, #f97316, #ea580c);
  box-shadow: 0 0 8px rgba(249,115,22,0.3);
}

.progress-fill.exceeded {
  background: linear-gradient(90deg, #ef4444, #b91c1c);
  box-shadow: 0 0 8px rgba(239,68,68,0.3);
}

.alert-text {
  min-height: 1.2rem;
  margin-top: 0.45rem;
  font-size: 0.85rem;
  font-weight: 700;
}

.alert-text.caution {
  color: #ca8a04;
}

.alert-text.warning {
  color: #ea580c;
}

.alert-text.exceeded {
  color: var(--c-danger);
}

.simple-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.52rem;
}

.list-item {
  border: 1px solid var(--c-border);
  border-radius: 12px;
  padding: 0.9rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.6rem;
  background: #ffffff;
  backdrop-filter: var(--glass-blur);
  transition: all 0.2s ease;
}
.list-item:hover {
  background: #f8f9fa;
  border-color: rgba(255,255,255,0.2);
}

.list-main {
  display: grid;
  gap: 0.15rem;
}

.fixed-edit-grid {
  grid-template-columns: 1fr;
  gap: 0.45rem;
}

.fixed-edit-grid label {
  display: grid;
  gap: 0.2rem;
  font-size: 0.8rem;
  color: var(--c-muted);
}

.list-title {
  font-weight: 800;
}

.list-sub {
  font-size: 0.82rem;
  color: var(--c-muted);
}

.list-actions {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.category-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.72rem;
  align-items: start;
  grid-auto-rows: min-content;
}

.category-card {
  position: relative;
  border: 1px solid var(--c-border);
  border-radius: 16px;
  background: var(--c-surface-2);
  padding: 1rem;
  display: grid;
  gap: 0.6rem;
  align-self: start;
  height: fit-content;
  backdrop-filter: var(--glass-blur);
  box-shadow: var(--shadow);
  transition: transform 0.3s ease, border-color 0.3s ease;
}
.category-card:hover {
  border-color: rgba(255, 255, 255, 0.4);
  transform: translateY(-2px);
}

.category-body {
  display: grid;
  gap: 0.6rem;
  margin-top: 0.5rem;
  border-top: 1px solid var(--c-border);
  padding-top: 0.8rem;
}

.category-body.is-collapsed {
  display: none;
}

.category-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.55rem;
  padding-right: 3.4rem;
}

.category-toggle {
  min-width: 2.8rem;
  min-height: 2.8rem;
  padding: 0.2rem;
  border: none;
  background: #f1f3f5;
  color: var(--c-brand-strong);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: absolute;
  top: -0.8rem;
  right: -0.8rem;
  border-radius: 999px;
  z-index: 2;
  box-shadow: 0 10px 22px rgba(79, 44, 30, 0.2);
  backdrop-filter: var(--glass-blur);
  transition: all 0.3s ease;
}
.category-toggle:hover {
  background: #e9ecef;
  transform: scale(1.05);
}
.category-toggle.is-open {
  background: var(--c-brand-grad);
  color: #ffffff;
  box-shadow: 0 6px 16px rgba(166, 0, 23, 0.4);
}

.category-title {
  font-size: 1rem;
  font-weight: 800;
}

.entry-form {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.5rem;
}

.entry-line {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.48rem;
}

.entry-list {
  list-style: none;
  display: grid;
  gap: 0.4rem;
}

.entry-item {
  border-radius: 12px;
  background: #ffffff;
  border: 1px solid var(--c-border);
  padding: 0.6rem 0.8rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.4rem;
  backdrop-filter: var(--glass-blur);
}

.entry-meta {
  font-size: 0.78rem;
  color: var(--c-muted);
}

.month-summary {
  display: grid;
  gap: 0.5rem;
}

.year-analytics {
  margin-top: 0.6rem;
  border-top: 1px solid var(--c-border);
  padding-top: 0.8rem;
  display: grid;
  gap: 0.6rem;
}

.year-analytics-head {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.year-analytics-head h3 {
  font-size: 0.95rem;
}

.year-analytics-controls {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.year-analytics-controls label {
  font-size: 0.8rem;
  color: var(--c-muted);
}

#analytics-year {
  width: 88px;
  padding: 0.35rem 0.45rem;
}

.year-analytics-list {
  display: grid;
  gap: 0.45rem;
}

.year-row {
  border: 1px solid var(--c-border);
  background: #ffffff;
  border-radius: 12px;
  padding: 0.8rem;
  backdrop-filter: var(--glass-blur);
}

.year-row-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
  font-size: 0.84rem;
}

.year-bar {
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: #f1f3f5;
  overflow: hidden;
}

.year-bar-fill {
  height: 100%;
  width: 0;
  transition: width 0.3s ease;
}

.year-bar-fill.is-positive {
  background: linear-gradient(90deg, #15803d, #22c55e);
}

.year-bar-fill.is-negative {
  background: linear-gradient(90deg, #b91c1c, #ef4444);
}

.summary-row {
  display: flex;
  justify-content: space-between;
  border: 1px solid var(--c-border);
  border-radius: 12px;
  padding: 0.8rem;
  background: #ffffff;
  gap: 0.4rem;
  backdrop-filter: var(--glass-blur);
}

.empty {
  font-size: 0.86rem;
  color: var(--c-muted);
  border: 1px dashed var(--c-border);
  border-radius: 10px;
  padding: 0.62rem;
}

.share-btn {
  width: 3.15rem;
  height: 3.15rem;
  margin-top: 0;
  border-radius: 50%;
  justify-self: end;
  grid-column: auto;
  background: var(--c-brand-grad);
  color: #fff;
  border: none;
  box-shadow: 0 12px 24px rgba(139, 0, 0, 0.2);
}

.share-btn:hover,
.share-btn:focus-visible {
  background: linear-gradient(135deg, #a60000 0%, #700000 100%);
}

/* ── Currency callout dropdown ───────────────────────────── */
.currency-wrap {
  position: relative;
  width: 100%;
}

.currency-picker {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  width: 100%;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(139, 0, 0, 0.08);
  border-radius: 18px;
  padding: 0.75rem 0.85rem;
  font-size: 0.94rem;
  font-weight: 800;
  color: var(--c-text);
  cursor: pointer;
  font-family: inherit;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
  white-space: nowrap;
  justify-content: space-between;
}

.currency-caret {
  font-size: 0.6rem;
  opacity: 0.5;
  transition: transform 0.2s;
}
.currency-picker[aria-expanded="true"] .currency-caret {
  transform: rotate(180deg);
}

.currency-picker:focus-visible {
  outline: 2px solid var(--c-brand);
}

.currency-dropdown {
  position: fixed;
  background: #fff;
  border: 1px solid #ecd8d1;
  border-radius: 14px;
  box-shadow: 0 12px 32px rgba(33, 37, 41, 0.13);
  z-index: 61;
  overflow: visible;
  min-width: 130px;
}
.currency-dropdown[hidden] { display: none; }

/* callout arrow pointing up at the button */
.currency-dropdown::before,
.currency-dropdown::after {
  content: '';
  position: absolute;
  bottom: 100%;
  width: 0; height: 0;
  border-style: solid;
  pointer-events: none;
  left: var(--cd-arrow-left, 20px);
}
.currency-dropdown::before {
  border-width: 0 10px 11px 10px;
  border-color: transparent transparent #ecd8d1 transparent;
  margin-bottom: 1px;
}
.currency-dropdown::after {
  border-width: 0 9px 10px 9px;
  border-color: transparent transparent #fff transparent;
}

.currency-opt {
  display: block;
  width: 100%;
  padding: 10px 16px;
  background: none;
  border: none;
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--c-text);
  cursor: pointer;
  text-align: left;
  border-radius: 0;
}
.currency-opt:first-child { border-radius: 14px 14px 0 0; }
.currency-opt:last-child  { border-radius: 0 0 14px 14px; }
.currency-opt:hover { background: #fdf6f4; }
.currency-opt.selected { color: var(--c-brand); }

@media (max-width: 359px) {
  .app-header {
    padding-inline: 0.85rem;
  }

  .header-top-row {
    flex-direction: column;
  }

  .header-bottom-row {
    grid-template-columns: 1fr;
  }

  .share-btn {
    justify-self: start;
  }

  .metric-card,
  .panel {
    border-radius: 20px;
  }
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: radial-gradient(circle at top, rgba(139, 0, 0, 0.14), rgba(0, 0, 0, 0.45));
  backdrop-filter: blur(7px);
  -webkit-backdrop-filter: blur(7px);
  z-index: 1100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.modal-overlay.is-active {
  opacity: 1;
  pointer-events: auto;
}

.modal-content {
  background: linear-gradient(180deg, #fff 0%, #fdf7f5 100%);
  border: 1px solid rgba(139, 0, 0, 0.12);
  border-radius: 22px;
  padding: 1.35rem;
  width: 100%;
  max-width: 430px;
  box-shadow: 0 24px 56px rgba(0, 0, 0, 0.25);
  transform: translateY(18px) scale(0.98);
  transition: transform 0.22s ease;
}

.modal-overlay.is-active .modal-content {
  transform: translateY(0) scale(1);
}

.modal-title {
  font-size: 1.18rem;
  margin-bottom: 0.45rem;
  color: var(--c-brand-strong);
  font-weight: 800;
}

.modal-msg {
  font-size: 0.93rem;
  color: var(--c-muted);
  margin-bottom: 1rem;
  line-height: 1.5;
}

.modal-body {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  margin-bottom: 1.15rem;
}

.modal-field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-weight: 700;
  font-size: 0.84rem;
  color: #3f454b;
}

.modal-field input,
.modal-field select,
.modal-field textarea {
  border: 1px solid #e9d7cf;
  background: #fff;
  border-radius: 12px;
  padding: 0.68rem 0.82rem;
  font-size: inherit;
  font-family: inherit;
  color: #222;
  width: 100%;
  box-sizing: border-box;
}

.modal-field input:focus-visible,
.modal-field select:focus-visible,
.modal-field textarea:focus-visible {
  outline: none;
  border-color: var(--c-brand);
  box-shadow: 0 0 0 3px rgba(139, 0, 0, 0.12);
}

.modal-field textarea {
  resize: vertical;
  min-height: 110px;
  line-height: 1.5;
}

.modal-char-count {
  font-size: 0.78rem;
  color: var(--c-muted);
  text-align: right;
  font-weight: 400;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.65rem;
}

.modal-actions .btn {
  min-width: 102px;
}

body.modal-open {
  overflow: hidden;
}

@media (max-width: 480px) {
  .modal-content {
    border-radius: 18px;
    padding: 1.15rem;
  }

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

  .modal-actions .btn {
    flex: 1;
  }
}

@media (min-width: 700px) {
  .install-banner {
    left: 50%;
    right: auto;
    width: 520px;
    transform: translateX(-50%) translateY(calc(100% + 1.5rem));
  }

  .install-banner.visible {
    transform: translateX(-50%) translateY(0);
  }

  .ios-guide {
    left: 50%;
    right: auto;
    width: 520px;
    transform: translateX(-50%) translateY(calc(100% + 1.5rem));
  }

  .ios-guide.visible {
    transform: translateX(-50%) translateY(0);
  }

  .header-top-row {
    flex-direction: row;
    justify-content: space-between;
    align-items: flex-start;
  }

  .header-bottom-row {
    grid-template-columns: 190px minmax(0, 1fr) auto;
  }

  .share-btn {
    grid-column: auto;
  }

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

  .nav-btn {
    font-size: 0.86rem;
    padding: 0.62rem 0.25rem 0.75rem;
  }

  .app-nav {
    grid-auto-flow: initial;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    overflow-x: visible;
  }

  .form-row {
    grid-template-columns: 2fr 1fr auto;
    align-items: end;
  }

  #profile-form {
    grid-template-columns: 1fr 1fr auto;
  }

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

  .entry-form {
    grid-template-columns: 1fr;
  }

  .fixed-edit-grid {
    grid-template-columns: 1.6fr 1fr;
    align-items: end;
  }
}

@media (min-width: 1024px) {
  .app-header {
    padding: 1.3rem 2rem;
  }

  .header-top-row {
    justify-content: space-between;
    align-items: center;
  }

  .profile-menu {
    right: 2rem;
  }

  .app-subtitle {
    font-size: 0.84rem;
  }

  .app-tagline {
    font-size: 0.86rem;
  }

  .app-main {
    padding: 1.2rem 2rem 2rem;
  }

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