body.app-shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  overflow: hidden;
  background: #f8f9fa;
}

/* White tab bar — same style as 履歴MAP tabs */
.app-tabs {
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 200;
  display: flex;
  justify-content: center;
  background: #ffffff;
  border-bottom: 1px solid #e5e8eb;
  box-shadow: none;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.app-tabs-inner {
  display: flex;
  justify-content: center;
  width: 100%;
  max-width: 960px;
}

.app-tabs .tab-btn {
  flex: 1 1 0;
  min-width: 0;
  white-space: nowrap;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0.9rem 0.75rem;
  color: #7f8c8d;
  background: transparent;
  border: none;
  border-bottom: 3px solid transparent;
  border-radius: 0;
  cursor: pointer;
}

.app-tabs .tab-btn:hover {
  color: #c0392b;
  background: transparent;
}

.app-tabs .tab-btn.active {
  color: #c0392b;
  border-bottom-color: #c0392b;
  background: transparent;
}

.app-tabs .tab-btn:focus-visible {
  outline: 2px solid #c0392b;
  outline-offset: -2px;
}

.app-main {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 0;
}

.app-main > .panel {
  flex: 1;
  min-height: 0;
}

.app-main > .panel.active {
  display: flex;
  flex-direction: column;
}

.panel-fill {
  padding: 0;
}

.panel-padded {
  padding: 1rem 1.25rem 1.5rem;
  overflow: auto;
  max-width: 960px;
  width: 100%;
  margin: 0 auto;
  box-sizing: border-box;
}

.realtime-frame {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
  background: #eef2f6;
  flex: 1;
  min-height: calc(100dvh - 52px - 36px);
}

#panel-history.active {
  flex: 1;
  min-height: 0;
  padding: 0.65rem 1rem 0.75rem;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

#panel-history .panel-header,
#panel-history #eq-stats,
#panel-history #alerts-updated,
#panel-history #import-progress {
  flex-shrink: 0;
}

#panel-history .panel-header {
  margin-bottom: 0.35rem;
}

#panel-history .meta-text {
  margin: 0.15rem 0;
  font-size: 0.75rem;
  line-height: 1.35;
}

#panel-history .alerts-workspace {
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

#panel-history .map-legend,
#panel-history .map-toolbar {
  flex-shrink: 0;
  margin-bottom: 0.35rem;
}

@media (max-width: 640px) {
  .app-tabs .tab-btn {
    flex: 1 0 auto;
    min-width: 5.5rem;
    font-size: 0.8rem;
    padding: 0.8rem 0.5rem;
  }

  #panel-history.active {
    overflow: auto;
  }
}

@media (min-width: 900px) {
  .app-main {
    padding: 0;
  }

  #panel-history.active {
    flex: 1;
    min-height: 0;
    overflow: hidden;
  }

  #panel-history .alerts-workspace {
    flex: 1;
    min-height: 0;
  }
}
