:root {
  --bg: #edf2fb;
  --bg-gradient-1: #f8faff;
  --bg-gradient-2: #e6eeff;
  --surface: #ffffff;
  --surface-muted: #f4f7ff;
  --text: #1a2431;
  --text-soft: #5f6f88;
  --primary: #1553ab;
  --primary-soft: #dce9ff;
  --success: #1f8f5f;
  --warning: #a66b0a;
  --danger: #bf3c3c;
  --shadow: 0 16px 34px rgba(19, 57, 122, 0.14);
  --radius-lg: 22px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --bottom-nav-height: min(10vh, 82px);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  height: 100%;
  overscroll-behavior-y: none;
}

body {
  font-family: "SF Pro Text", "Avenir Next", "Segoe UI", "Helvetica Neue", sans-serif;
  color: var(--text);
  min-height: 100svh;
  background:
    radial-gradient(circle at 10% 10%, var(--bg-gradient-1), transparent 44%),
    radial-gradient(circle at 90% 0%, var(--bg-gradient-2), transparent 38%),
    var(--bg);
}

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

.app-shell {
  min-height: 100svh;
  min-height: 100dvh;
  padding: 14px 14px calc(var(--bottom-nav-height) + 22px);
}

.app-header {
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(21, 83, 171, 0.12);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  position: sticky;
  top: max(10px, env(safe-area-inset-top));
  z-index: 5;
}

.header-title {
  margin: 0;
  font-size: 1.25rem;
  line-height: 1.2;
  letter-spacing: 0.01em;
}

.header-subtitle {
  margin: 6px 0 0;
  color: var(--text-soft);
  font-size: 0.84rem;
}

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

.status-pill {
  font-size: 0.76rem;
  padding: 6px 10px;
  border-radius: 999px;
  background: #eef4ff;
  color: #204b87;
  border: 1px solid rgba(32, 75, 135, 0.14);
}

.status-pill.offline {
  background: #fff2e8;
  color: #a85a17;
  border-color: rgba(168, 90, 23, 0.22);
}

.app-main {
  margin-top: 14px;
}

.card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 16px;
  border: 1px solid rgba(12, 58, 132, 0.1);
  box-shadow: var(--shadow);
}

.install-hint {
  margin-bottom: 10px;
  border-radius: var(--radius-sm);
  background: #fff7e6;
  color: #7f5613;
  border: 1px solid rgba(127, 86, 19, 0.24);
  padding: 9px 12px;
  font-size: 0.82rem;
}

.hidden {
  display: none !important;
}

.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: var(--bottom-nav-height);
  padding: 8px 10px max(8px, env(safe-area-inset-bottom));
  background: rgba(255, 255, 255, 0.96);
  border-top: 1px solid rgba(22, 80, 160, 0.15);
  backdrop-filter: blur(12px);
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 7px;
  z-index: 20;
}

.nav-item {
  border: 0;
  background: transparent;
  border-radius: 14px;
  color: #4d5f7f;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.2s ease, color 0.2s ease;
  min-width: 0;
}

.nav-item:active {
  transform: scale(0.98);
}

.nav-item svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
}

.nav-item span {
  font-size: 0.72rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-item.active {
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 600;
}

.primary-btn,
.secondary-btn,
.ghost-btn,
.icon-btn {
  border: 0;
  border-radius: 12px;
  cursor: pointer;
  transition: filter 0.2s ease, transform 0.12s ease;
}

.primary-btn,
.secondary-btn,
.ghost-btn {
  padding: 10px 14px;
}

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

.secondary-btn {
  background: #eaf2ff;
  color: #1c4e97;
}

.ghost-btn {
  background: #f3f6fc;
  color: #304e78;
}

.icon-btn {
  width: 38px;
  height: 38px;
  background: #eaf2ff;
  color: #1d4f97;
  font-size: 1.3rem;
  display: grid;
  place-items: center;
}

.primary-btn:hover,
.secondary-btn:hover,
.ghost-btn:hover,
.icon-btn:hover {
  filter: brightness(0.97);
}

.primary-btn:active,
.secondary-btn:active,
.ghost-btn:active,
.icon-btn:active {
  transform: scale(0.98);
}

.balance-layout {
  display: grid;
  gap: 12px;
}

.balance-total {
  padding: 18px;
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, #104287 0%, #1d61bb 100%);
  color: #f7fbff;
  box-shadow: var(--shadow);
}

.balance-label {
  margin: 0;
  opacity: 0.88;
  letter-spacing: 0.03em;
  font-size: 0.8rem;
  text-transform: uppercase;
}

.balance-amount {
  margin: 8px 0 0;
  font-size: clamp(1.9rem, 5vw, 2.4rem);
  line-height: 1.1;
}

.balance-meta {
  margin: 8px 0 0;
  font-size: 0.82rem;
  opacity: 0.92;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 9px;
}

.metric-item {
  background: var(--surface);
  border-radius: var(--radius-md);
  border: 1px solid rgba(21, 83, 171, 0.11);
  padding: 12px;
}

.metric-item h3 {
  margin: 0;
  font-size: 0.8rem;
  color: var(--text-soft);
  font-weight: 600;
}

.metric-item p {
  margin: 6px 0 0;
  font-size: 1rem;
  font-weight: 700;
}

.status-line {
  font-size: 0.82rem;
  margin: 10px 0 0;
  color: var(--text-soft);
}

.calendar-shell {
  --calendar-scale: 1;
  display: grid;
  gap: 12px;
}

.calendar-toolbar {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 14px;
  border: 1px solid rgba(14, 71, 148, 0.11);
  box-shadow: var(--shadow);
  display: grid;
  gap: 10px;
}

.month-navigation {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.month-heading {
  margin: 0;
  font-size: 1.15rem;
}

.month-special {
  color: #2f4f7d;
  font-size: 0.86rem;
  margin-top: 5px;
}

.month-note-label {
  display: grid;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--text-soft);
}

.month-note-label input {
  border: 1px solid rgba(25, 91, 184, 0.22);
  border-radius: 10px;
  padding: 9px 10px;
  background: #fbfdff;
}

.zoom-controls {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
}

.zoom-controls span {
  min-width: 48px;
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-soft);
}

.calendar-weekdays,
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
}

.calendar-weekdays div {
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-soft);
}

.calendar-day {
  border: 1px solid rgba(18, 69, 140, 0.12);
  border-radius: 12px;
  min-height: calc(78px * var(--calendar-scale));
  background: #ffffff;
  padding: calc(7px * var(--calendar-scale));
  text-align: left;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 8px;
}

.calendar-day.muted {
  background: #f5f8ff;
  color: #7788a4;
}

.calendar-day.selected {
  border-color: #1f61be;
  box-shadow: inset 0 0 0 1px #1f61be;
}

.calendar-day.today {
  box-shadow: inset 0 0 0 1px #22a17b;
}

.day-number {
  font-size: calc(0.83rem * var(--calendar-scale));
  font-weight: 600;
}

.day-events-badge {
  align-self: flex-start;
  border-radius: 999px;
  font-size: calc(0.68rem * var(--calendar-scale));
  color: #0f4c93;
  background: #e3edff;
  padding: 3px 7px;
}

.day-details {
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid rgba(16, 73, 150, 0.12);
  box-shadow: var(--shadow);
  padding: 14px;
}

.day-details-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.day-details-title {
  margin: 0;
  font-size: 1rem;
}

.event-list {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.event-item {
  background: #f6f9ff;
  border-radius: 11px;
  padding: 10px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px;
  border: 1px solid rgba(19, 77, 156, 0.12);
}

.event-title {
  margin: 0;
  font-weight: 600;
}

.event-note {
  margin: 4px 0 0;
  color: var(--text-soft);
  font-size: 0.82rem;
}

.empty-state {
  margin: 12px 0 0;
  font-size: 0.86rem;
  color: var(--text-soft);
}

.chats-shell {
  display: grid;
  gap: 12px;
}

.sync-box {
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid rgba(20, 81, 164, 0.12);
  box-shadow: var(--shadow);
  padding: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.sync-box p {
  margin: 0;
  font-size: 0.83rem;
  color: var(--text-soft);
}

.chat-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.chat-item {
  background: #fff;
  border: 1px solid rgba(20, 81, 164, 0.1);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 10px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: center;
}

.chat-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(160deg, #ceddff, #edf3ff);
  color: #164792;
  display: grid;
  place-items: center;
  font-weight: 700;
  border: 1px solid rgba(22, 71, 146, 0.18);
}

.chat-main h3 {
  margin: 0;
  font-size: 0.94rem;
}

.chat-main p {
  margin: 4px 0 0;
  font-size: 0.8rem;
  color: var(--text-soft);
}

.chat-time {
  font-size: 0.72rem;
  color: #6d7d98;
}

.profile-shell {
  background: var(--surface);
  border: 1px solid rgba(20, 81, 164, 0.12);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 14px;
}

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

.avatar-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.avatar-frame {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  overflow: hidden;
  background: #edf2ff;
  border: 1px solid rgba(22, 71, 146, 0.2);
  display: grid;
  place-items: center;
}

.avatar-frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar-frame svg {
  width: 56px;
  height: 56px;
  fill: #4f6990;
}

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

.form-field {
  display: grid;
  gap: 5px;
  font-size: 0.83rem;
  color: var(--text-soft);
}

.form-field input,
.form-field select,
.form-field textarea {
  border: 1px solid rgba(22, 71, 146, 0.2);
  border-radius: 10px;
  padding: 9px 10px;
  background: #fbfdff;
}

.form-field input[readonly] {
  color: #5f6f88;
  background: #f5f8ff;
}

.form-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(7, 16, 34, 0.5);
  display: grid;
  place-items: center;
  padding: 16px;
}

.modal-card {
  width: min(560px, 100%);
  background: #fff;
  border-radius: 16px;
  border: 1px solid rgba(17, 66, 132, 0.18);
  box-shadow: 0 24px 50px rgba(0, 0, 0, 0.22);
  padding: 14px;
  position: relative;
}

.modal-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 50%;
  background: #f1f6ff;
  color: #2e5289;
  cursor: pointer;
}

.modal-title {
  margin: 0 0 10px;
  font-size: 1.08rem;
}

.modal-form {
  display: grid;
  gap: 10px;
}

.contacts-picker {
  max-height: 170px;
  overflow: auto;
  background: #f8fbff;
  border: 1px solid rgba(21, 83, 171, 0.13);
  border-radius: 10px;
  padding: 8px;
  display: grid;
  gap: 6px;
}

.contact-option {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.toast {
  position: fixed;
  top: max(12px, env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  background: #142f5c;
  color: #fff;
  border-radius: 999px;
  padding: 10px 14px;
  font-size: 0.82rem;
  z-index: 60;
  box-shadow: 0 10px 24px rgba(10, 28, 59, 0.28);
}

@media (max-width: 740px) {
  .metrics-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 500px) {
  .app-shell {
    padding-inline: 10px;
  }

  .app-header {
    border-radius: 16px;
  }

  .metric-item p {
    font-size: 0.95rem;
  }

  .chat-item {
    grid-template-columns: auto 1fr;
    grid-template-areas:
      "avatar main"
      "avatar time";
  }

  .chat-avatar {
    grid-area: avatar;
  }

  .chat-main {
    grid-area: main;
  }

  .chat-time {
    grid-area: time;
    justify-self: start;
  }
}



