:root {
  --ink: #17212b;
  --muted: #66727f;
  --line: #d9dedc;
  --paper: #fbfaf7;
  --canvas: #f3f0ea;
  --nav: #17324d;
  --nav-2: #214565;
  --green: #2f7d6b;
  --green-2: #dceee8;
  --terracotta: #d9825b;
  --gold: #e1b85c;
  --red: #b94f4f;
  --blue: #3b6d91;
  --shadow: 0 18px 48px rgba(34, 47, 62, 0.12);
  --radius: 8px;
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.45;
  letter-spacing: 0;
}

button,
input,
select,
textarea {
  font: inherit;
  letter-spacing: 0;
}

button {
  cursor: pointer;
}

a {
  color: var(--blue);
}

.boot {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.boot-card {
  display: grid;
  gap: 14px;
  justify-items: center;
  color: var(--nav);
}

.auth-page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(280px, 0.9fr) minmax(320px, 1.1fr);
  background: var(--paper);
}

.auth-visual {
  min-height: 100vh;
  padding: 42px;
  display: grid;
  align-content: space-between;
  color: #fff;
  background:
    linear-gradient(rgba(23, 50, 77, 0.82), rgba(23, 50, 77, 0.68)),
    url("https://images.unsplash.com/photo-1500530855697-b586d89ba3ee?auto=format&fit=crop&w=1400&q=80") center / cover;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-height: 48px;
  font-weight: 800;
}

.brand-mark img {
  width: 44px;
  height: 44px;
}

.auth-title {
  max-width: 520px;
}

.auth-title h1 {
  margin: 0 0 14px;
  font-size: clamp(2.1rem, 5vw, 4.2rem);
  line-height: 1;
}

.auth-title p {
  margin: 0;
  color: rgba(255, 255, 255, 0.86);
  font-size: 1.05rem;
}

.auth-panel {
  display: grid;
  place-items: center;
  padding: 40px 22px;
}

.auth-card {
  width: min(100%, 440px);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
}

.auth-card h2,
.panel h2,
.section-title h2 {
  margin: 0;
}

.auth-card p,
.muted {
  color: var(--muted);
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 260px 1fr;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 22px 16px;
  color: #fff;
  background: var(--nav);
}

.sidebar .brand-mark {
  padding: 4px 8px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.14);
}

.nav-list {
  display: grid;
  gap: 6px;
}

.nav-button,
.sidebar-bottom button {
  width: 100%;
  min-height: 42px;
  border: 0;
  border-radius: var(--radius);
  color: rgba(255, 255, 255, 0.82);
  background: transparent;
  text-align: left;
  padding: 10px 12px;
}

.nav-button.active,
.nav-button:hover,
.sidebar-bottom button:hover {
  color: #fff;
  background: var(--nav-2);
}

.sidebar-bottom {
  margin-top: auto;
  display: grid;
  gap: 10px;
}

.user-pill {
  padding: 12px;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.08);
}

.user-pill strong,
.user-pill span {
  display: block;
  overflow-wrap: anywhere;
}

.user-pill span {
  color: rgba(255, 255, 255, 0.72);
  font-size: 0.88rem;
}

.main {
  min-width: 0;
  padding: 24px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

.topbar h1 {
  margin: 0;
  font-size: clamp(1.6rem, 3vw, 2.4rem);
  line-height: 1.1;
}

.status-chip,
.chip {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 4px 10px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  font-size: 0.86rem;
  white-space: nowrap;
}

.best-chip {
  color: #235442;
  border-color: #9bcbb9;
  background: #e5f4ed;
}

.status-chip.offline {
  color: #7a4f08;
  border-color: #e7cc8f;
  background: #fff5d8;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 380px);
  gap: 18px;
  align-items: start;
}

.panel {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 10px 30px rgba(34, 47, 62, 0.06);
  padding: 18px;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.section-title p {
  margin: 4px 0 0;
  color: var(--muted);
}

.trip-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}

.trip-card {
  width: 100%;
  min-height: 210px;
  display: grid;
  align-content: space-between;
  gap: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  color: inherit;
  background: #fff;
  text-align: left;
  box-shadow: 0 8px 24px rgba(34, 47, 62, 0.08);
}

.trip-card:hover {
  transform: translateY(-1px);
  border-color: #b8c1c0;
}

.trip-cover {
  height: 7px;
  width: 74px;
  border-radius: 999px;
}

.trip-card h3 {
  margin: 0 0 5px;
  font-size: 1.25rem;
}

.trip-card p {
  margin: 0;
  color: var(--muted);
}

.metric-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.metric {
  min-width: 0;
  border-radius: var(--radius);
  background: #f1f4f2;
  padding: 10px;
}

.metric strong {
  display: block;
  font-size: 1.1rem;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
}

.empty-state {
  min-height: 250px;
  display: grid;
  place-items: center;
  padding: 28px;
  color: var(--muted);
  border: 1px dashed #b8c1c0;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.55);
  text-align: center;
}

.empty-state.compact {
  min-height: 92px;
}

.budget-currency-group {
  display: grid;
  gap: 12px;
}

.budget-currency-group + .budget-currency-group {
  margin-top: 24px;
}

.budget-subtitle {
  margin-bottom: 0;
}

.budget-subtitle h3 {
  margin: 0;
  font-size: 1.05rem;
}

.form-grid {
  display: grid;
  gap: 12px;
}

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

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

.field {
  display: grid;
  gap: 6px;
}

.field span,
.field label,
.checkbox-line {
  color: #3f4c58;
  font-size: 0.9rem;
  font-weight: 650;
}

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid #cfd7d4;
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
  padding: 9px 11px;
}

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

input:focus,
select:focus,
textarea:focus {
  outline: 3px solid rgba(47, 125, 107, 0.18);
  border-color: var(--green);
}

.checkbox-line {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.checkbox-line input {
  width: 18px;
  min-height: 18px;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.btn {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid #cbd5d2;
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
  padding: 9px 13px;
  text-decoration: none;
  font-weight: 720;
}

.btn.primary {
  border-color: var(--green);
  background: var(--green);
  color: #fff;
}

.btn.dark {
  border-color: var(--nav);
  background: var(--nav);
  color: #fff;
}

.btn.danger {
  border-color: #e8c0c0;
  color: var(--red);
}

.btn.ghost {
  background: transparent;
}

.btn.icon {
  min-width: 42px;
  width: 42px;
  padding: 0;
}

.btn:hover {
  filter: brightness(0.98);
}

.trip-header {
  display: grid;
  gap: 16px;
  margin-bottom: 16px;
  padding: 20px;
  color: #fff;
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--nav), #2f7d6b);
  overflow: hidden;
}

.trip-header-top {
  display: flex;
  justify-content: space-between;
  gap: 16px;
}

.trip-header h1 {
  margin: 8px 0 8px;
  font-size: clamp(1.8rem, 4vw, 3rem);
  line-height: 1.05;
}

.trip-header p {
  margin: 0;
  color: rgba(255, 255, 255, 0.82);
}

.trip-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 0 0 8px;
  margin-bottom: 16px;
}

.tab-button {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  padding: 9px 14px;
  font-weight: 720;
}

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

.overview-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.overview-card {
  min-height: 116px;
  display: grid;
  gap: 8px;
  align-content: start;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  padding: 14px;
}

.overview-card strong {
  font-size: 1.6rem;
  line-height: 1;
}

.amount-stack {
  display: grid;
  gap: 6px;
}

.amount-stack strong {
  min-width: 0;
  overflow-wrap: anywhere;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 370px);
  gap: 16px;
  align-items: start;
}

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

.list-item {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  padding: 12px;
}

.list-item.done {
  opacity: 0.65;
}

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

.item-head h3,
.item-head strong {
  margin: 0;
}

.item-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.split-list,
.document-list,
.member-list {
  display: grid;
  gap: 10px;
}

.map-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 340px);
  gap: 16px;
}

#map {
  min-height: 560px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #dfe7e2;
  overflow: hidden;
}

.map-fallback {
  min-height: 560px;
  display: grid;
  place-items: center;
  padding: 24px;
  color: var(--muted);
  text-align: center;
}

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

.table-wrap + .section-title {
  margin-top: 18px;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

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

th {
  color: #3f4c58;
  background: #f1f4f2;
}

tr:last-child td {
  border-bottom: 0;
}

.member-options {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.small {
  font-size: 0.88rem;
}

.danger-text {
  color: var(--red);
}

#toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 50;
  display: grid;
  gap: 8px;
}

.toast {
  max-width: min(420px, calc(100vw - 36px));
  border-radius: var(--radius);
  background: var(--ink);
  color: #fff;
  padding: 12px 14px;
  box-shadow: var(--shadow);
}

.toast.error {
  background: var(--red);
}

.hide {
  display: none !important;
}

@media (max-width: 1080px) {
  .dashboard-grid,
  .content-grid,
  .map-shell {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 760px) {
  .auth-page {
    grid-template-columns: 1fr;
  }

  .auth-visual {
    min-height: 340px;
    padding: 26px;
  }

  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
  }

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

  .main {
    padding: 16px;
  }

  .topbar,
  .trip-header-top,
  .section-title,
  .item-head {
    align-items: stretch;
    flex-direction: column;
  }

  .form-grid.two,
  .form-grid.three,
  .overview-grid,
  .metric-row {
    grid-template-columns: 1fr;
  }

  #map,
  .map-fallback {
    min-height: 380px;
  }
}
