:root {
  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --brand: #4f46e5;
  --brand-dark: #3730a3;
  --surface: #ffffff;
  --text: #172033;
  --muted: #64748b;
  --line: #dbe2ea;
  --danger: #b42318;
}

* { box-sizing: border-box; }

html, body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #f6f7fb;
}

button, a { -webkit-tap-highlight-color: transparent; }
button { font: inherit; }

.appFrame {
  display: none;
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  background: #f6f7fb;
}

.loading {
  position: fixed;
  inset: 0;
  display: grid;
  place-content: center;
  color: #475569;
  font-size: 18px;
}

.dot { animation: pulse 1.2s infinite; }
.dot:nth-child(2) { animation-delay: .2s; }
.dot:nth-child(3) { animation-delay: .4s; }

@keyframes pulse {
  0%, 80%, 100% { opacity: .25; }
  40% { opacity: 1; }
}

.fallbackLink {
  display: none;
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: calc(92px + env(safe-area-inset-bottom));
  z-index: 30;
  padding: 12px 14px;
  border: 1px solid #fed7aa;
  border-radius: 14px;
  color: #9a3412;
  text-align: center;
  font-size: 13px;
  background: #fff7ed;
  box-shadow: 0 10px 30px rgba(15, 23, 42, .12);
}

.fallbackLink a { color: #9a3412; font-weight: 700; }

.networkBanner {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 60;
  padding: calc(9px + env(safe-area-inset-top)) 16px 9px;
  color: #7c2d12;
  text-align: center;
  font-size: 13px;
  font-weight: 700;
  background: #ffedd5;
  box-shadow: 0 2px 12px rgba(15, 23, 42, .12);
}

.networkBanner.show { display: block; }

.notificationFab {
  position: fixed;
  right: 14px;
  bottom: calc(14px + env(safe-area-inset-bottom));
  z-index: 50;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 44px;
  padding: 10px 14px;
  border: 0;
  border-radius: 999px;
  color: #fff;
  font-weight: 800;
  background: var(--brand);
  box-shadow: 0 10px 30px rgba(79, 70, 229, .35);
  cursor: pointer;
}

.notificationFab.enabled { background: #087443; }
.notificationFab.problem { background: #9a3412; }

.notificationPanel {
  position: fixed;
  right: 14px;
  bottom: calc(70px + env(safe-area-inset-bottom));
  z-index: 55;
  width: min(390px, calc(100vw - 28px));
  max-height: min(630px, calc(100vh - 100px));
  overflow: auto;
  padding: 18px;
  border: 1px solid rgba(148, 163, 184, .35);
  border-radius: 20px;
  color: var(--text);
  background: rgba(255, 255, 255, .98);
  box-shadow: 0 22px 70px rgba(15, 23, 42, .25);
  backdrop-filter: blur(12px);
}

.notificationPanel[hidden] { display: none; }

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

.panelHeader h1 {
  margin: 6px 0 0;
  font-size: 20px;
}

.pwaBadge {
  display: inline-block;
  padding: 4px 7px;
  border-radius: 999px;
  color: var(--brand-dark);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .08em;
  background: #e0e7ff;
}

.iconButton {
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: #475569;
  font-size: 24px;
  line-height: 1;
  background: #fff;
  cursor: pointer;
}

.panelStatus {
  margin: 16px 0;
  padding: 12px;
  border-radius: 12px;
  color: #334155;
  font-size: 14px;
  line-height: 1.5;
  background: #f1f5f9;
}

.panelStatus.success { color: #065f46; background: #d1fae5; }
.panelStatus.warning { color: #92400e; background: #fef3c7; }
.panelStatus.error { color: #991b1b; background: #fee2e2; }

.iosGuide {
  margin-bottom: 16px;
  padding: 13px 14px;
  border: 1px solid #c7d2fe;
  border-radius: 14px;
  color: #312e81;
  background: #eef2ff;
}

.iosGuide ol {
  margin: 8px 0 0;
  padding-left: 20px;
  font-size: 13px;
  line-height: 1.55;
}

.panelActions { display: grid; gap: 9px; }

.panelActions button {
  min-height: 46px;
  padding: 11px 14px;
  border-radius: 12px;
  font-weight: 800;
  cursor: pointer;
}

.panelActions button:disabled { opacity: .55; cursor: wait; }
.primaryButton { border: 0; color: #fff; background: var(--brand); }
.secondaryButton { border: 1px solid #a5b4fc; color: var(--brand-dark); background: #eef2ff; }
.dangerButton { border: 1px solid #fecaca; color: var(--danger); background: #fff; }

.privacyNote {
  margin: 15px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

@media (max-width: 520px) {
  .notificationPanel {
    left: 10px;
    right: 10px;
    bottom: calc(66px + env(safe-area-inset-bottom));
    width: auto;
  }

  .notificationFab {
    right: 10px;
    bottom: calc(10px + env(safe-area-inset-bottom));
  }
}
