:root {
  --bg: #f2f5fd;
  --surface: #ffffff;
  --surface-soft: #f7f9ff;
  --text: #182033;
  --muted: #70798d;
  --primary: #2c73e8;
  --primary-dark: #1f5fc7;
  --secondary: #16aa72;
  --primary-text: #ffffff;
  --line: #e3e8f2;
  --success: #159868;
  --warning: #e2982d;
  --danger: #d54d58;
  --gradient: linear-gradient(125deg, #2c73e8 0%, #2286c5 46%, #16aa72 100%);
  --gradient-soft: linear-gradient(135deg, #eaf2ff 0%, #eafbf4 100%);
  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 16px;
  --shadow-sm: 0 6px 20px rgba(35, 66, 121, 0.07);
  --shadow: 0 16px 44px rgba(35, 66, 121, 0.11);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  min-height: 100dvh;
  background:
    radial-gradient(circle at 8% 2%, rgba(44, 115, 232, 0.08), transparent 28%),
    radial-gradient(circle at 96% 18%, rgba(22, 170, 114, 0.07), transparent 25%),
    var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid rgba(44, 115, 232, 0.2);
  outline-offset: 2px;
}
.hidden { display: none !important; }

.app-shell {
  max-width: 720px;
  min-height: 100dvh;
  margin: 0 auto;
  padding: env(safe-area-inset-top) 18px calc(100px + env(safe-area-inset-bottom));
}

.topbar {
  position: relative;
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) 44px;
  align-items: center;
  gap: 12px;
  padding: 18px 2px 17px;
}
.topbar::after {
  position: absolute;
  right: 2px;
  bottom: 0;
  left: 2px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--line) 12%, var(--line) 88%, transparent);
  content: "";
}
.brand-mark {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border: 3px solid rgba(255, 255, 255, 0.78);
  border-radius: 18px;
  background: var(--gradient);
  box-shadow: 0 10px 24px rgba(39, 111, 201, 0.25);
}
.brand-mark svg { width: 31px; height: 31px; fill: none; stroke: #fff; stroke-linecap: round; stroke-linejoin: round; stroke-width: 2; }
.brand-mark .brand-heart { fill: rgba(255, 255, 255, 0.96); stroke-width: 1.25; }
.brand-copy { min-width: 0; }
.brand-copy h1 { margin: 0; overflow: hidden; font-size: 21px; line-height: 1.1; text-overflow: ellipsis; white-space: nowrap; }
.eyebrow { margin: 0 0 4px; color: var(--primary); font-size: 10px; font-weight: 850; letter-spacing: 0.15em; }
.brand-subtitle { margin: 4px 0 0; overflow: hidden; color: var(--muted); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.icon-button {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: rgba(255, 255, 255, 0.86);
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}
.icon-button svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.9; }
.icon-button:active { transform: scale(0.96); }

h1, h2, h3, p { margin-top: 0; }
h2 { font-size: 20px; line-height: 1.25; }
h3 { font-size: 15px; }

.page-intro { display: flex; align-items: flex-start; gap: 12px; margin: 20px 3px 14px; }
.page-icon {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 13px;
  background: var(--gradient-soft);
  font-size: 20px;
}
.page-intro h2 { margin: 0 0 4px; font-size: 21px; }
.page-intro p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.45; }

.status-hero, .hero {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-xl);
  color: #fff;
  background: var(--gradient);
  box-shadow: 0 18px 42px rgba(38, 113, 188, 0.22);
}
.status-hero { display: grid; grid-template-columns: 1fr auto; gap: 18px; align-items: center; padding: 24px; }
.status-hero::before, .hero::before {
  position: absolute;
  right: -52px;
  bottom: -76px;
  width: 190px;
  height: 190px;
  border: 34px solid rgba(255, 255, 255, 0.08);
  border-radius: 50%;
  content: "";
}
.status-hero::after, .hero::after {
  position: absolute;
  top: -35px;
  right: 72px;
  width: 80px;
  height: 80px;
  border: 18px solid rgba(255, 255, 255, 0.06);
  border-radius: 50%;
  content: "";
}
.status-hero > *, .hero > * { position: relative; z-index: 1; }
.hero-kicker { margin: 0 0 7px; color: rgba(255, 255, 255, 0.76); font-size: 10px; font-weight: 850; letter-spacing: 0.14em; }
.status-hero h2, .hero h2 { margin: 0 0 8px; font-size: clamp(23px, 6vw, 29px); }
.status-hero p, .hero p { margin: 0; color: rgba(255, 255, 255, 0.82); font-size: 13px; line-height: 1.55; }
.hero { padding: 26px 24px; }
.hero-icon {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  border: 1px solid rgba(255, 255, 255, 0.26);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.16);
  font-size: 31px;
  backdrop-filter: blur(6px);
}

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 13px 0 24px; }
.stat {
  min-width: 0;
  padding: 15px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.91);
  box-shadow: var(--shadow-sm);
}
.stat strong { display: block; margin-bottom: 3px; font-size: 23px; line-height: 1; }
.stat span { display: block; overflow: hidden; color: var(--muted); font-size: 11px; line-height: 1.25; text-overflow: ellipsis; white-space: nowrap; }
.stat:nth-child(1) strong { color: var(--primary); }
.stat:nth-child(2) strong { color: var(--success); }
.stat:nth-child(3) strong { color: #7a5dd8; }

.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 22px 3px 11px; }
.section-head h2 { margin: 0; font-size: 18px; }
.section-head button { padding: 5px; border: 0; background: transparent; color: var(--primary); font-size: 13px; font-weight: 750; }
.section-caption { margin: -5px 3px 12px; color: var(--muted); font-size: 12px; line-height: 1.5; }

.card, .state-card {
  border: 1px solid rgba(224, 230, 242, 0.94);
  border-radius: var(--radius-xl);
  background: rgba(255, 255, 255, 0.95);
  box-shadow: var(--shadow);
}
.card { padding: 18px; }
.state-card { margin-top: 24px; padding: 32px 24px; text-align: center; }
.state-card h2 { margin-bottom: 8px; }
.state-card p { color: var(--muted); line-height: 1.55; }
.loading-state { margin-top: 20vh; }
.spinner {
  width: 36px;
  height: 36px;
  margin: 0 auto 20px;
  border: 3px solid var(--line);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.welcome-panel { padding: 29px 22px 26px; }
.welcome-illustration {
  display: grid;
  place-items: center;
  width: 92px;
  height: 92px;
  margin: 0 auto 20px;
  border: 8px solid rgba(255, 255, 255, 0.8);
  border-radius: 31px;
  background: var(--gradient-soft);
  box-shadow: 0 12px 30px rgba(35, 96, 171, 0.14);
  font-size: 42px;
  transform: rotate(-3deg);
}
.welcome-panel h2 { font-size: 25px; }
.welcome-note { max-width: 390px; margin: 0 auto 22px; }
.welcome-panel form { text-align: left; }

.member-list, .stack { display: grid; gap: 10px; }
.member-card {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.avatar {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 17px;
  background: var(--gradient-soft);
  color: var(--primary-dark);
  font-weight: 850;
}
.member-card h3 { margin: 0 0 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.member-card p { margin: 0; color: var(--muted); font-size: 12px; }
.status-dot { display: inline-block; width: 8px; height: 8px; margin-right: 5px; border-radius: 50%; background: #aab1bf; }
.status-dot.online { background: var(--success); box-shadow: 0 0 0 4px rgba(21, 152, 104, 0.13); }
.pill { flex: 0 0 auto; padding: 6px 9px; border-radius: 999px; background: #edf3ff; color: var(--primary); font-size: 10px; font-weight: 800; }

.quick-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.quick-action {
  min-height: 112px;
  padding: 17px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--text);
  text-align: left;
  box-shadow: var(--shadow-sm);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.quick-action:active { transform: translateY(1px) scale(0.985); }
.quick-action .action-icon {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  margin-bottom: 13px;
  border-radius: 13px;
  background: var(--gradient-soft);
  color: var(--primary);
  font-size: 21px;
}
.quick-action strong { display: block; margin-bottom: 4px; font-size: 14px; }
.quick-action small { display: block; color: var(--muted); font-size: 11px; line-height: 1.35; }

.info-banner {
  display: flex;
  gap: 11px;
  margin-bottom: 14px;
  padding: 14px 15px;
  border: 1px solid #dfe9ff;
  border-radius: var(--radius-md);
  background: #eef4ff;
  color: #496078;
  font-size: 12px;
  line-height: 1.5;
}
.info-banner strong { color: var(--text); }
.info-banner .info-icon { flex: 0 0 auto; font-size: 18px; }

.bottom-nav {
  position: fixed;
  z-index: 1000;
  bottom: 0;
  left: 50%;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  width: min(100%, 720px);
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 24px 24px 0 0;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 -10px 30px rgba(29, 52, 94, 0.1);
  backdrop-filter: blur(16px);
}
.nav-item {
  display: grid;
  gap: 4px;
  place-items: center;
  min-height: 58px;
  padding: 5px;
  border: 0;
  border-radius: 17px;
  background: transparent;
  color: #828a9c;
  font-size: 10px;
  font-weight: 750;
}
.nav-item svg { width: 23px; height: 23px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.8; }
.nav-item.active { background: var(--gradient-soft); color: var(--primary); }

#map {
  width: 100%;
  height: min(57vh, 500px);
  border: 5px solid var(--surface);
  border-radius: var(--radius-xl);
  background: #dfe8f0;
  box-shadow: var(--shadow);
}
.map-legend { display: flex; flex-wrap: wrap; gap: 14px; padding: 12px 5px; color: var(--muted); font-size: 12px; }
.leaflet-container { font-family: inherit; }
.custom-marker {
  display: grid;
  place-items: center;
  width: 38px !important;
  height: 38px !important;
  border: 3px solid white;
  border-radius: 50% 50% 50% 8px;
  transform: rotate(-45deg);
  background: var(--gradient);
  color: white;
  box-shadow: 0 7px 17px rgba(20, 59, 106, 0.3);
}
.custom-marker span { transform: rotate(45deg); font-weight: 850; }

.list-row { display: grid; grid-template-columns: 52px minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 15px 0; border-bottom: 1px solid var(--line); }
.list-row:last-child { border-bottom: 0; }
.time-box { padding: 10px 6px; border-radius: 14px; background: var(--gradient-soft); color: var(--primary); text-align: center; font-size: 12px; font-weight: 850; }
.list-row h3, .list-row p { margin: 0; }
.list-row p { margin-top: 4px; color: var(--muted); font-size: 12px; }
.toggle-button { padding: 8px 10px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-soft); color: var(--primary); font-size: 11px; font-weight: 750; }
.inactive { opacity: 0.52; }

.primary-button, .secondary-button { width: 100%; min-height: 51px; padding: 12px 18px; border-radius: 15px; font-weight: 800; }
.primary-button { border: 0; background: var(--gradient); color: var(--primary-text); box-shadow: 0 10px 24px rgba(37, 117, 190, 0.2); }
.secondary-button { border: 1px solid var(--line); background: var(--surface); color: var(--text); }
.primary-button:active, .secondary-button:active { transform: scale(0.99); }
.button-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.invite-card { padding: 17px; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--shadow-sm); }
.invite-card h3 { margin-bottom: 6px; }
.invite-card p { min-height: 38px; color: var(--muted); font-size: 12px; line-height: 1.48; }

.modal { width: min(calc(100% - 28px), 520px); max-height: 88dvh; padding: 0; border: 0; border-radius: var(--radius-xl); background: var(--surface); color: var(--text); box-shadow: 0 24px 80px rgba(17, 30, 59, 0.3); }
.modal::backdrop { background: rgba(16, 26, 48, 0.58); backdrop-filter: blur(5px); }
.modal form { display: grid; gap: 15px; max-height: 88dvh; padding: 23px; overflow-y: auto; }
.modal-head { display: flex; align-items: center; justify-content: space-between; }
.modal-head h2 { margin: 0; }
.modal-head button { border: 0; background: transparent; color: var(--muted); font-size: 28px; }
label, legend { color: var(--muted); font-size: 12px; font-weight: 750; }
input, select, textarea { width: 100%; margin-top: 7px; padding: 14px; border: 1px solid var(--line); border-radius: 14px; outline: 0; background: var(--surface-soft); color: var(--text); }
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(44, 115, 232, 0.12); }
fieldset { margin: 0; padding: 0; border: 0; }
.day-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; margin-top: 8px; }
.day-grid label { display: grid; place-items: center; height: 38px; border: 1px solid var(--line); border-radius: 10px; color: var(--text); }
.day-grid input { position: absolute; width: 0; opacity: 0; }
.day-grid label:has(input:checked) { border-color: var(--primary); background: var(--primary); color: var(--primary-text); }
.field-row { display: grid; grid-template-columns: 2fr 1fr; gap: 10px; }

.toast { position: fixed; z-index: 2000; bottom: calc(92px + env(safe-area-inset-bottom)); left: 50%; max-width: calc(100% - 32px); padding: 12px 18px; transform: translate(-50%, 20px); border-radius: 999px; background: #17223a; color: white; box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: 0.25s ease; font-size: 13px; }
.toast.show { transform: translate(-50%, 0); opacity: 1; }
.empty { padding: 30px 16px; text-align: center; color: var(--muted); line-height: 1.5; }
.error-text { color: var(--danger) !important; }

@media (max-width: 390px) {
  .app-shell { padding-right: 14px; padding-left: 14px; }
  .topbar { grid-template-columns: 48px minmax(0, 1fr) 40px; gap: 10px; }
  .brand-mark { width: 48px; height: 48px; border-radius: 16px; }
  .brand-copy h1 { font-size: 19px; }
  .status-hero { padding: 21px; }
  .hero-icon { width: 56px; height: 56px; border-radius: 19px; font-size: 27px; }
  .member-card { grid-template-columns: 45px minmax(0, 1fr) auto; gap: 9px; padding: 11px; }
  .avatar { width: 45px; height: 45px; }
  .pill { padding: 5px 7px; font-size: 9px; }
}

@media (max-width: 340px) {
  .stats { grid-template-columns: 1fr; }
  .stat span { white-space: normal; }
  .quick-grid, .button-row, .field-row { grid-template-columns: 1fr; }
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101724;
    --surface: #182131;
    --surface-soft: #202a3c;
    --text: #edf2fa;
    --muted: #9da8ba;
    --line: #2a3548;
    --gradient-soft: linear-gradient(135deg, #1c3152 0%, #183a31 100%);
    --shadow-sm: 0 6px 20px rgba(0, 0, 0, 0.14);
    --shadow: 0 16px 44px rgba(0, 0, 0, 0.22);
  }
  .icon-button, .bottom-nav, .stat, .card, .state-card { background: rgba(24, 33, 49, 0.96); }
  .pill { background: #203353; }
  .info-banner { border-color: #293b59; background: #1b2b45; color: #b2bfd0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
