:root {
  --page-swipe-ms: 340ms;
  --page-swipe-distance: 34px;
  --bg: #dfe4e2;
  --surface: #f7f7f8;
  --surface-strong: #ffffff;
  --text: #101114;
  --muted: #74767b;
  --line: #dddde0;
  --accent: #ea8000;
  --accent-soft: #f6e4cd;
  --footer-bg: #e9dcc7;
  --danger: #d04444;
  --success: #178a62;
  --shadow-soft: 0 10px 28px rgba(16, 17, 20, 0.08);
}

html.dark {
  --bg: #15181d;
  --surface: #1f232a;
  --surface-strong: #262b34;
  --text: #f2f4f8;
  --muted: #a8adb8;
  --line: #333a46;
  --accent: #ea8000;
  --accent-soft: #3c2a16;
  --footer-bg: #2a2520;
  --danger: #ea6666;
  --success: #39b98a;
  --shadow-soft: 0 14px 32px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

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

body {
  font-family: 'Manrope', 'Avenir Next', 'Segoe UI', sans-serif;
  color: var(--text);
  background: var(--bg);
  transition: background 0.5s ease;
}

a {
  color: inherit;
  text-decoration: none;
}

html.theme-transition *,
html.theme-transition *::before,
html.theme-transition *::after {
  transition:
    background 0.5s ease,
    background-color 0.5s ease,
    color 0s linear,
    border-color 0.5s ease,
    box-shadow 0.5s ease,
    fill 0.5s ease,
    stroke 0.5s ease,
    opacity 0.5s ease,
    transform 0.5s ease,
    clip-path 0.5s ease,
    filter 0.5s ease;
}

.page-shell {
  width: min(560px, 100vw);
  margin: 0 auto;
  padding: 10px 14px calc(112px + env(safe-area-inset-bottom));
}

.content-shell {
  display: grid;
  gap: 14px;
  will-change: transform, opacity, filter;
  transition:
    transform var(--page-swipe-ms) cubic-bezier(0.22, 1, 0.36, 1),
    opacity var(--page-swipe-ms) ease,
    filter var(--page-swipe-ms) ease;
}

html.page-enter .content-shell {
  opacity: 0.01;
  filter: blur(3px);
}

html.page-enter.page-enter-from-right .content-shell {
  transform: translateX(var(--page-swipe-distance));
}

html.page-enter.page-enter-from-left .content-shell {
  transform: translateX(calc(var(--page-swipe-distance) * -1));
}

html.page-enter.page-enter-active .content-shell {
  transform: translateX(0);
  opacity: 1;
  filter: blur(0);
}

html.page-leave .content-shell {
  opacity: 0;
  filter: blur(3px);
}

html.page-leave.page-leave-to-left .content-shell {
  transform: translateX(calc(var(--page-swipe-distance) * -1));
}

html.page-leave.page-leave-to-right .content-shell {
  transform: translateX(var(--page-swipe-distance));
}

.footer-nav-wrap {
  position: fixed;
  left: 50%;
  bottom: calc(12px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  width: min(560px, calc(100vw - 20px));
  z-index: 60;
  pointer-events: none;
  padding: 0 12px;
}

.footer-nav {
  --footer-nav-pad-y: 8px;
  --footer-nav-pad-x: 8px;
  --footer-nav-gap: 6px;
  pointer-events: auto;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--footer-nav-gap);
  align-items: center;
  padding: var(--footer-nav-pad-y) var(--footer-nav-pad-x);
  border-radius: 999px;
  background: var(--footer-bg);
  box-shadow: var(--shadow-soft);
  position: relative;
  overflow: hidden;
}

.footer-nav-indicator {
  position: absolute;
  top: var(--footer-nav-pad-y);
  left: 0;
  height: calc(100% - (var(--footer-nav-pad-y) * 2));
  width: 0;
  border-radius: 999px;
  background: var(--accent);
  z-index: 0;
  pointer-events: none;
  transition: transform 0.34s cubic-bezier(0.22, 1, 0.36, 1);
}

.footer-nav-item {
  display: grid;
  justify-items: center;
  gap: 3px;
  border-radius: 999px;
  padding: 8px 4px;
  color: var(--text);
  min-height: 62px;
  position: relative;
  z-index: 1;
  transition: none;
}

.footer-nav-item.active {
  color: #fff;
}

html.dark .footer-nav-item {
  color: #000;
}

html.dark .footer-nav-item.active {
  color: #fff;
}

.footer-nav-icon {
  width: 29px;
  height: 29px;
  object-fit: contain;
}

.footer-nav-item.active .footer-nav-icon {
  filter: brightness(0) invert(1);
}

.footer-nav-label {
  font-size: 11px;
  line-height: 1;
  font-weight: 700;
  transition: none;
}

.home-header {
  position: sticky;
  top: 0;
  z-index: 40;
  padding: 8px 0 10px;
  background: linear-gradient(180deg, var(--bg), rgba(223, 228, 226, 0.88) 80%, rgba(223, 228, 226, 0));
}

html.dark .home-header {
  background: linear-gradient(180deg, var(--bg), rgba(21, 24, 29, 0.9) 80%, rgba(21, 24, 29, 0));
}

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

.balance-pill {
  background: var(--accent);
  color: #fff;
  border-radius: 999px;
  padding: 7px 17px;
  display: inline-flex;
  align-items: baseline;
  gap: 0;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  letter-spacing: 0.01em;
}

.money-symbol,
.money-minor,
.money-separator {
  font-size: clamp(0.95rem, 4.1vw, 1.55rem);
  font-weight: 500;
}

.money-major {
  font-size: clamp(1.35rem, 6vw, 2.2rem);
  font-weight: 500;
}

.home-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.round-icon-btn {
  width: 54px;
  height: 54px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  cursor: pointer;
  background: var(--accent);
}

.round-icon-btn img {
  width: 26px;
  height: 26px;
  object-fit: contain;
  filter: brightness(0) invert(1);
}

.theme-toggle-round {
  position: relative;
  overflow: hidden;
}

.theme-toggle-round .theme-icon {
  position: absolute;
  inset: 0;
  margin: auto;
  width: 26px;
  height: 26px;
  object-fit: contain;
  filter: none;
  will-change: transform, opacity, clip-path;
  transition:
    transform 0.5s cubic-bezier(0.22, 1, 0.36, 1),
    opacity 0.5s cubic-bezier(0.22, 1, 0.36, 1),
    clip-path 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}

.theme-toggle-round .theme-icon-sun {
  opacity: 1;
  transform: translate(0, 0) scale(1) rotate(0deg);
  clip-path: circle(78% at 50% 50%);
}

.theme-toggle-round .theme-icon-moon {
  opacity: 0;
  transform: translate(6px, -6px) scale(0.68) rotate(-95deg);
  clip-path: circle(24% at 82% 18%);
}

html.dark .theme-toggle-round .theme-icon-sun {
  opacity: 0;
  transform: translate(-6px, 6px) scale(0.68) rotate(95deg);
  clip-path: circle(24% at 18% 82%);
}

html.dark .theme-toggle-round .theme-icon-moon {
  opacity: 1;
  transform: translate(0, 0) scale(1) rotate(0deg);
  clip-path: circle(78% at 50% 50%);
}

.home-search {
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  transition: max-height 0.22s ease, opacity 0.2s ease, margin-top 0.2s ease;
}

.home-header.search-open .home-search {
  max-height: 280px;
  opacity: 1;
  margin-top: 10px;
}

.home-search-grid {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow-soft);
  padding: 10px;
  display: grid;
  gap: 8px;
}

.activity-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 28px;
  padding: 14px 12px 8px;
  box-shadow: var(--shadow-soft);
}

.activity-card h2 {
  margin: 0 0 8px;
  font-size: 2rem;
  line-height: 1;
  font-weight: 500;
}

.activity-list {
  display: grid;
  margin-bottom: 8px;
}

.activity-date-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin: 10px 0 2px;
}

.activity-date-label {
  font-size: 15px;
  line-height: 1;
  color: var(--muted);
  font-weight: 800;
  letter-spacing: 0.02em;
}

.activity-date-total {
  font-size: 16px;
  line-height: 1;
  color: var(--muted);
  font-weight: 800;
}

.activity-row {
  display: grid;
  grid-template-columns: 52px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 8px 2px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}

.activity-row:last-child {
  border-bottom: 0;
}

.activity-row:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 8px;
}

.activity-icon-wrap {
  width: 46px;
  height: 46px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.activity-icon {
  width: 46px;
  height: 46px;
  object-fit: cover;
}

.activity-icon-fallback {
  width: 46px;
  height: 46px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--text);
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.activity-main {
  min-width: 0;
}

.activity-title {
  font-size: 17px;
  line-height: 1.28;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding-bottom: 1px;
}

.activity-subtitle {
  margin-top: 1px;
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.activity-status-icon {
  width: 0.95em;
  height: 0.95em;
  margin-left: 0;
  vertical-align: -0.08em;
  object-fit: contain;
}

.activity-amount {
  font-size: 20px;
  line-height: 1;
  font-weight: 700;
  letter-spacing: 0.01em;
  padding-left: 8px;
  display: inline-flex;
  align-items: baseline;
  gap: 0;
  font-variant-numeric: tabular-nums;
}

.activity-amount .amount-major {
  font-size: 20px;
  font-weight: 700;
}

.activity-amount .amount-separator,
.activity-amount .amount-minor {
  font-size: 13px;
  font-weight: 700;
}

.activity-amount.part-paid {
  color: var(--accent);
}

.activity-paid {
  font-weight: 600;
}

.card {
  border-radius: 22px;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-soft);
}

.panel {
  padding: 14px;
}

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

.split {
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr;
}

.grid-2,
.grid-3 {
  display: grid;
  gap: 10px;
  grid-template-columns: 1fr;
}

h1,
h2,
h3 {
  margin: 0;
}

input,
select,
textarea,
button {
  font: inherit;
}

label {
  display: grid;
  gap: 5px;
  font-size: 13px;
  color: var(--muted);
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-strong);
  color: var(--text);
  padding: 10px 11px;
}

select {
  padding-right: 38px;
}

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

button,
.btn {
  border: 0;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 9px 12px;
  font-weight: 700;
  cursor: pointer;
}

button,
.btn.solid {
  background: var(--accent);
  color: #fff;
}

.btn.ghost {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text);
}

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

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

.alert {
  border-radius: 12px;
  border: 1px solid var(--line);
  padding: 9px 11px;
  font-size: 14px;
  font-weight: 600;
}

.alert.success {
  color: var(--success);
  border-color: rgba(23, 138, 98, 0.35);
  background: rgba(23, 138, 98, 0.12);
}

.alert.error {
  color: var(--danger);
  border-color: rgba(208, 68, 68, 0.35);
  background: rgba(208, 68, 68, 0.1);
}

.muted {
  color: var(--muted);
}

.tiny {
  font-size: 12px;
}

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

.settings-inline-notice {
  font-size: 14px;
  font-weight: 700;
  color: var(--success);
  visibility: hidden;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.settings-inline-notice.show {
  visibility: visible;
  opacity: 1;
}

.list-links {
  display: grid;
  gap: 8px;
}

.list-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px;
  background: var(--surface-strong);
}

.empty,
.empty-state {
  text-align: center;
  border: 1px dashed var(--line);
  border-radius: 16px;
  padding: 16px 12px;
  display: grid;
  gap: 10px;
  justify-items: center;
  background: rgba(255, 255, 255, 0.26);
}

.empty-state p {
  margin: 0;
  color: var(--muted);
}

html.dark .empty,
html.dark .empty-state {
  background: rgba(255, 255, 255, 0.04);
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 8px 6px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

td {
  font-size: 14px;
}

.kpi-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
}

.kpi {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px;
  background: var(--surface-strong);
}

.kpi .value {
  margin-top: 4px;
  font-size: 22px;
  line-height: 1;
  font-weight: 700;
}

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 12px;
  font-weight: 700;
}

.badge.draft {
  background: rgba(116, 118, 123, 0.22);
}

.badge.sent {
  background: rgba(234, 128, 0, 0.2);
}

.badge.part-paid {
  background: rgba(234, 128, 0, 0.26);
}

.badge.paid {
  background: rgba(23, 138, 98, 0.26);
  color: #0e6f50;
}

.badge.cancelled {
  background: rgba(208, 68, 68, 0.26);
  color: #8f2f2f;
}

html.dark .badge.paid {
  color: #9be5c9;
}

html.dark .badge.cancelled {
  color: #ffc7c7;
}

.auth-shell {
  width: min(460px, calc(100vw - 22px));
  margin: 8vh auto;
  padding: 16px;
}

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

.theme-toggle {
  width: 44px;
  height: 44px;
  border-radius: 999px;
  background: var(--surface-strong);
  border: 1px solid var(--line);
  padding: 0;
}

.theme-toggle svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.theme-toggle .icon-sun {
  display: none;
}

html.dark .theme-toggle .icon-sun {
  display: block;
}

html.dark .theme-toggle .icon-moon {
  display: none;
}

.dialog-card {
  border: 0;
  border-radius: 16px;
  width: min(420px, 92vw);
  padding: 0;
  color: var(--text);
  background: var(--surface);
}

.dialog-card::backdrop {
  background: rgba(5, 10, 18, 0.55);
}

.dialog-body {
  padding: 12px;
  display: grid;
  gap: 10px;
}

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

@media (min-width: 920px) {
  .home-header {
    margin-inline: -2px;
  }

  .activity-card {
    margin-inline: -2px;
  }

  .grid-2 {
    grid-template-columns: 1fr 1fr;
  }

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

  .job-meta-grid {
    grid-template-columns: 1.2fr 1fr 1fr;
  }

  .job-meta-grid select {
    font-size: 20px;
    line-height: 1.15;
    padding-right: 44px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .content-shell {
    transition: none;
  }
}
