:root {
  --bg-0: #061522;
  --bg-1: #081b2e;
  --bg-2: #0b223b;
  --bg-3: #0f2b49;
  --bg-4: #123457;

  --panel: rgba(11, 27, 46, 0.86);
  --panel-2: rgba(13, 39, 68, 0.88);
  --panel-3: rgba(16, 47, 81, 0.92);

  --border: rgba(128, 173, 220, 0.16);
  --border-strong: rgba(148, 191, 236, 0.28);

  --text: #eaf4ff;
  --text-soft: #bfd2e8;
  --text-muted: #8faecc;

  --accent: #6cc1ff;
  --accent-2: #7be6c6;
  --accent-3: #95d0ff;

  --good: #67d39a;
  --warn: #e7c25c;
  --bad: #ef7676;

  --shadow-xl: 0 22px 60px rgba(0, 0, 0, 0.34);
  --shadow-lg: 0 14px 36px rgba(0, 0, 0, 0.28);
  --shadow-md: 0 10px 24px rgba(0, 0, 0, 0.22);

  --radius-xl: 26px;
  --radius-lg: 20px;
  --radius-md: 16px;
  --radius-sm: 12px;

  --sidebar-w: 320px;
  --content-max: 1800px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at top left, rgba(69, 138, 204, 0.16), transparent 28%),
    radial-gradient(circle at top right, rgba(80, 173, 210, 0.12), transparent 24%),
    linear-gradient(180deg, var(--bg-0), var(--bg-1) 24%, var(--bg-2) 58%, #08192a 100%);
  color: var(--text);
  font-family:
    Inter,
    "Segoe UI",
    Roboto,
    Ubuntu,
    "Helvetica Neue",
    Arial,
    sans-serif;
}

body {
  position: relative;
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(transparent 0, rgba(255,255,255,0.012) 1px, transparent 1px),
    linear-gradient(90deg, transparent 0, rgba(255,255,255,0.012) 1px, transparent 1px);
  background-size: 28px 28px;
  mask-image: linear-gradient(180deg, rgba(0,0,0,0.28), rgba(0,0,0,0.04));
  opacity: 0.25;
}

a {
  color: inherit;
  text-decoration: none;
}

.shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 100vh;
}

/* =========================
   SIDEBAR
   ========================= */

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  padding: 22px 18px 26px;
  background:
    linear-gradient(180deg, rgba(6, 19, 34, 0.92), rgba(8, 25, 44, 0.96));
  border-right: 1px solid rgba(132, 171, 214, 0.12);
  backdrop-filter: blur(14px);
  box-shadow: inset -1px 0 0 rgba(255,255,255,0.025);
}

.sidebar::-webkit-scrollbar {
  width: 10px;
}

.sidebar::-webkit-scrollbar-thumb {
  background: rgba(118, 155, 197, 0.24);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: padding-box;
}

.brand-wrap {
  display: grid;
  gap: 14px;
  margin-bottom: 22px;
}

.brand {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
  padding: 16px;
  border-radius: var(--radius-lg);
  background:
    linear-gradient(180deg, rgba(16, 47, 81, 0.88), rgba(11, 33, 57, 0.94));
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.brand:hover {
  transform: translateY(-1px);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-lg);
}

.brand-badge {
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  border-radius: 18px;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: #06213b;
  background: linear-gradient(135deg, #7bd4ff, #89f0cf);
  box-shadow:
    0 10px 22px rgba(77, 174, 223, 0.26),
    inset 0 1px 0 rgba(255,255,255,0.4);
}

.brand-content h1 {
  margin: 0 0 6px;
  font-size: 15px;
  line-height: 1.2;
  letter-spacing: 0.03em;
  font-weight: 800;
  color: var(--text);
}

.brand-content p {
  margin: 0;
  color: var(--text-soft);
  font-size: 12.5px;
  line-height: 1.45;
}

.nav-title {
  margin: 18px 6px 10px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-muted);
}

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

.nav-group {
  border-radius: 18px;
  background: rgba(14, 35, 58, 0.52);
  border: 1px solid rgba(132, 171, 214, 0.08);
  overflow: hidden;
}

.nav-item {
  display: grid;
  gap: 4px;
  padding: 14px 14px 13px;
  color: var(--text);
  transition: background 0.18s ease, border-color 0.18s ease;
}

.nav-item:hover {
  background: rgba(255,255,255,0.025);
}

.nav-item.active {
  background:
    linear-gradient(180deg, rgba(23, 60, 100, 0.96), rgba(15, 43, 73, 0.96));
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.035);
}

.nav-item-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 14px;
  font-weight: 750;
}

.nav-item-sub {
  color: var(--text-soft);
  font-size: 12.5px;
  line-height: 1.4;
}

.nav-item-ext,
.nav-caret {
  color: var(--text-muted);
  transition: transform 0.18s ease;
}

.nav-group.open .nav-caret {
  transform: rotate(0deg);
}

.submenu {
  display: none;
  padding: 0 10px 10px;
  gap: 8px;
}

.nav-group.open .submenu {
  display: grid;
}

.submenu-item {
  padding: 11px 12px;
  border-radius: 13px;
  color: var(--text-soft);
  background: rgba(255,255,255,0.025);
  border: 1px solid rgba(132, 171, 214, 0.08);
  font-size: 13px;
  transition: transform 0.16s ease, border-color 0.16s ease, color 0.16s ease;
}

.submenu-item:hover {
  transform: translateX(2px);
  color: var(--text);
  border-color: rgba(136, 197, 255, 0.22);
}

/* =========================
   CONTENT
   ========================= */

.content {
  min-width: 0;
  padding: 22px 28px 36px;
}

.top-strip,
.hero,
.grid {
  width: min(100%, var(--content-max));
  margin: 0 auto;
}

.top-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
  padding: 16px 18px;
  border-radius: 22px;
  background:
    linear-gradient(180deg, rgba(13, 37, 63, 0.92), rgba(9, 27, 46, 0.94));
  border: 1px solid rgba(132, 171, 214, 0.14);
  box-shadow: var(--shadow-lg);
}

.top-strip-left {
  display: flex;
  align-items: center;
  min-width: max-content;
}

.top-strip-label {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.top-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.top-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 10px 14px;
  border-radius: 14px;
  background:
    linear-gradient(180deg, rgba(16, 48, 82, 0.82), rgba(11, 34, 58, 0.94));
  border: 1px solid rgba(132, 171, 214, 0.14);
  color: var(--text);
  font-size: 13px;
  font-weight: 750;
  box-shadow: var(--shadow-md);
  transition: transform 0.18s ease, border-color 0.18s ease, filter 0.18s ease, box-shadow 0.18s ease;
}

.top-action-btn:hover {
  transform: translateY(-1px);
  border-color: rgba(140, 202, 255, 0.3);
  filter: brightness(1.05);
  box-shadow: var(--shadow-lg);
}

.top-action-btn-accent {
  background:
    linear-gradient(135deg, rgba(58, 119, 190, 0.95), rgba(51, 148, 128, 0.88));
  border-color: rgba(137, 219, 255, 0.25);
}

.hero {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 18px;
  margin-bottom: 18px;
}

.card {
  position: relative;
  border-radius: var(--radius-xl);
  background:
    linear-gradient(180deg, rgba(12, 34, 57, 0.94), rgba(10, 28, 47, 0.94));
  border: 1px solid var(--border);
  box-shadow: var(--shadow-xl);
  overflow: hidden;
  isolation: isolate;
}

.card::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(135deg, rgba(134, 206, 255, 0.06), transparent 34%),
    radial-gradient(circle at 85% 15%, rgba(133, 243, 212, 0.06), transparent 18%);
  pointer-events: none;
}

.card-inner {
  position: relative;
  z-index: 1;
  padding: 22px 24px;
}

.hero-title {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  margin-bottom: 12px;
  border-radius: 999px;
  background: rgba(103, 176, 255, 0.12);
  border: 1px solid rgba(118, 188, 255, 0.18);
  color: var(--accent-3);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.hero h3 {
  margin: 0 0 10px;
  font-size: 26px;
  line-height: 1.15;
  letter-spacing: 0.01em;
  color: var(--text);
}

.hero p {
  margin: 0;
  font-size: 14.5px;
  line-height: 1.65;
  color: var(--text-soft);
}

.stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.stat {
  padding: 14px;
  border-radius: 16px;
  background:
    linear-gradient(180deg, rgba(17, 47, 79, 0.82), rgba(12, 34, 57, 0.96));
  border: 1px solid rgba(137, 176, 221, 0.12);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.025);
}

.stat-label {
  margin-bottom: 8px;
  font-size: 12px;
  line-height: 1;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
}

.stat-value {
  font-size: 16px;
  line-height: 1.3;
  color: var(--text);
  font-weight: 800;
  word-break: break-word;
}

.grid {
  display: grid;
  gap: 18px;
}

.panel {
  min-height: 260px;
}

.hidden {
  display: none !important;
}

.toolbar {
  position: relative;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 22px 0;
}

.toolbar-right {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.section-title {
  margin: 0 0 6px;
  font-size: 21px;
  line-height: 1.15;
  color: var(--text);
  font-weight: 800;
  letter-spacing: 0.01em;
}

.section-sub {
  margin: 0;
  color: var(--text-soft);
  font-size: 13.5px;
  line-height: 1.5;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(61, 104, 150, 0.18);
  border: 1px solid rgba(140, 191, 240, 0.18);
  color: var(--text-soft);
  font-size: 12.5px;
  font-weight: 700;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.03);
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--good);
  box-shadow:
    0 0 0 4px rgba(103, 211, 154, 0.14),
    0 0 18px rgba(103, 211, 154, 0.4);
  animation: livePulse 1.8s infinite ease-in-out;
}

@keyframes livePulse {
  0% { transform: scale(1); opacity: 0.95; }
  50% { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(1); opacity: 0.95; }
}

.plot-wrap,
.image-wrap,
.archive-wrap {
  position: relative;
  padding: 18px 22px 22px;
}

.plot-wrap > div,
.image-wrap,
.archive-wrap {
  min-height: 200px;
}

#live-plot {
  width: 100%;
  min-height: 520px;
  border-radius: 20px;
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(9, 25, 44, 0.86), rgba(11, 31, 54, 0.92));
  border: 1px solid rgba(140, 173, 220, 0.14);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.03);
}

/* =========================
   SEISMOGRAM PANEL
   ========================= */

.image-wrap {
  border-top: 1px solid rgba(255,255,255,0.03);
}

.seismo-shell {
  display: grid;
  gap: 14px;
}

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

.seismo-meta,
.seismo-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.seismo-frame {
  position: relative;
  border-radius: 22px;
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(7, 24, 41, 0.82), rgba(11, 33, 57, 0.92));
  border: 1px solid rgba(140,173,220,0.16);
  box-shadow: var(--shadow-lg);
  padding: 10px;
  min-height: 320px;
}

.seismo-stage {
  position: relative;
  min-height: 300px;
  display: grid;
  place-items: center;
}

.seismo-image {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 16px;
  background: rgba(5, 18, 31, 0.5);
  opacity: 1;
  transition:
    opacity 0.28s ease-in-out,
    transform 0.28s ease-in-out,
    filter 0.28s ease-in-out;
  will-change: opacity, transform;
}

.seismo-image.is-loading {
  opacity: 0.38;
  filter: saturate(0.9);
}

.seismo-image.is-swapping {
  opacity: 0.82;
}

.seismo-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 10px;
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-muted);
  padding: 0 4px;
}

#seismo-new-badge {
  box-shadow:
    0 0 0 1px rgba(255,255,255,0.08),
    0 10px 20px rgba(0,0,0,0.18);
}

/* =========================
   ARCHIVE TABLE
   ========================= */

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

.archive-wrap table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  overflow: hidden;
  border-radius: 18px;
  border: 1px solid rgba(132, 171, 214, 0.14);
  background:
    linear-gradient(180deg, rgba(14, 36, 60, 0.88), rgba(11, 31, 53, 0.94));
  box-shadow: var(--shadow-lg);
}

.archive-wrap thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 14px 14px;
  text-align: left;
  background:
    linear-gradient(180deg, rgba(20, 58, 96, 0.98), rgba(16, 46, 75, 0.98));
  color: var(--text);
  font-size: 12.5px;
  font-weight: 800;
  letter-spacing: 0.04em;
  border-bottom: 1px solid rgba(132, 171, 214, 0.14);
}

.archive-wrap tbody td {
  padding: 13px 14px;
  font-size: 13px;
  color: var(--text-soft);
  border-bottom: 1px solid rgba(132, 171, 214, 0.08);
}

.archive-wrap tbody tr:nth-child(odd) td {
  background: rgba(255,255,255,0.012);
}

.archive-wrap tbody tr:hover td {
  background: rgba(108, 193, 255, 0.055);
}

.file-link {
  color: var(--accent-3);
  font-weight: 700;
}

.file-link:hover {
  color: #dff4ff;
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* =========================
   EMPTY / ERROR STATES
   ========================= */

.empty {
  display: grid;
  place-items: center;
  width: 100%;
  min-height: 180px;
  padding: 22px;
  border-radius: 18px;
  color: var(--text-soft);
  text-align: center;
  background:
    linear-gradient(180deg, rgba(14, 35, 58, 0.76), rgba(11, 31, 53, 0.9));
  border: 1px dashed rgba(140, 173, 220, 0.18);
  font-size: 14px;
  line-height: 1.6;
}

/* =========================
   PLOTLY OVERRIDES
   ========================= */

.js-plotly-plot .plotly .main-svg {
  border-radius: 18px;
}

.modebar {
  background: rgba(7, 24, 41, 0.36) !important;
  border-radius: 999px !important;
  padding: 4px !important;
  backdrop-filter: blur(8px);
}

.modebar-btn svg {
  fill: #cfe4ff !important;
}

/* =========================
   RESPONSIVE
   ========================= */

@media (max-width: 1400px) {
  .hero {
    grid-template-columns: 1fr;
  }

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

  .top-strip {
    flex-direction: column;
    align-items: stretch;
  }

  .top-actions {
    justify-content: flex-start;
  }
}

@media (max-width: 1120px) {
  .shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: relative;
    height: auto;
    border-right: none;
    border-bottom: 1px solid rgba(132, 171, 214, 0.12);
  }

  .content {
    padding-top: 18px;
  }
}

@media (max-width: 840px) {
  .content {
    padding: 18px 14px 26px;
  }

  .sidebar {
    padding: 16px 12px 18px;
  }

  .card-inner {
    padding: 18px;
  }

  .toolbar {
    padding: 18px 18px 0;
  }

  .plot-wrap,
  .image-wrap,
  .archive-wrap {
    padding: 16px 18px 18px;
  }

  .hero h3 {
    font-size: 22px;
  }

  .section-title {
    font-size: 18px;
  }

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

  #live-plot {
    min-height: 420px;
  }

  .archive-wrap table,
  .archive-wrap thead,
  .archive-wrap tbody,
  .archive-wrap tr,
  .archive-wrap td,
  .archive-wrap th {
    font-size: 12px;
  }
}

@media (max-width: 560px) {
  .brand {
    grid-template-columns: 1fr;
    text-align: center;
  }

  .brand-badge {
    margin: 0 auto;
  }

  .stats {
    grid-template-columns: 1fr;
  }

  .toolbar,
  .toolbar-right,
  .seismo-topbar,
  .seismo-footer {
    flex-direction: column;
    align-items: stretch;
  }

  .pill {
    width: 100%;
    justify-content: center;
  }

  .section-title {
    font-size: 17px;
  }

  .section-sub,
  .hero p {
    font-size: 13px;
  }

  .top-action-btn {
    width: 100%;
  }
}
