:root {
  --bg: #080d1d;
  --bg-soft: #0d142b;
  --card: #151e3a;
  --card-2: #0d1630;
  --line: #31466f;
  --line-soft: #202f53;
  --text: #f6f7ff;
  --muted: #aab7d3;
  --muted-2: #7f8dad;
  --accent: #8da8ff;
  --accent-strong: #6f8eff;
  --success: #6fe0ac;
  --danger: #ff7d8d;
  --warning: #ffd37a;
  --radius: 20px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  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%; background: var(--bg); color: var(--text); }
body { overflow-x: hidden; }
button, input { font: inherit; }
button { color: inherit; }
.hidden { display: none !important; }

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 10% -5%, rgba(89, 91, 255, .16), transparent 30%),
    radial-gradient(circle at 95% 25%, rgba(64, 110, 255, .09), transparent 35%);
}

.access-gate {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.gate-card {
  width: min(420px, 100%);
  padding: 32px 24px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: linear-gradient(155deg, rgba(26, 37, 72, .96), rgba(10, 16, 35, .98));
  text-align: center;
  box-shadow: 0 24px 80px rgba(0,0,0,.42);
}
.gate-card h1 { margin: 18px 0 8px; font-size: 25px; }
.gate-card p { color: var(--muted); line-height: 1.45; }

.app-shell { width: min(100%, 920px); margin: 0 auto; min-height: 100vh; position: relative; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: calc(14px + var(--safe-top)) 16px 12px;
  background: rgba(8, 13, 29, .88);
  border-bottom: 1px solid rgba(49, 70, 111, .55);
  backdrop-filter: blur(18px);
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-mark {
  width: 54px; height: 54px; border-radius: 18px;
  display: grid; place-items: center;
  font-weight: 900; letter-spacing: -.05em;
  color: #aebcff;
  background: #11182e;
  border: 1px solid #4a3f8a;
  box-shadow: inset 0 0 20px rgba(76, 77, 210, .12);
}
.brand-mark.small { width: 46px; height: 46px; border-radius: 16px; }
.brand-title { font-size: 20px; font-weight: 850; line-height: 1.1; letter-spacing: -.02em; }
.brand-subtitle { margin-top: 4px; color: var(--muted-2); font-size: 12px; }
.icon-button {
  flex: 0 0 auto; width: 44px; height: 44px;
  display: grid; place-items: center;
  border-radius: 14px; border: 1px solid var(--line-soft);
  background: #0a1125; font-size: 23px; cursor: pointer;
}
.icon-button:active { transform: scale(.96); }

.tabs {
  position: sticky; top: calc(73px + var(--safe-top)); z-index: 19;
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px;
  margin: 10px 14px 0; padding: 5px;
  border: 1px solid var(--line-soft); border-radius: 16px;
  background: rgba(12, 19, 41, .92); backdrop-filter: blur(14px);
}
.tab { border: 0; border-radius: 12px; padding: 10px 6px; color: var(--muted); background: transparent; cursor: pointer; font-size: 13px; }
.tab.active { color: var(--text); background: #202d50; box-shadow: inset 0 0 0 1px rgba(126, 151, 226, .24); }

.content { padding: 16px 14px calc(34px + var(--safe-bottom)); }
.view { display: none; }
.view.active { display: block; }
.section-heading { display: flex; justify-content: space-between; align-items: end; margin: 3px 1px 14px; }
.section-heading h2 { margin: 0; font-size: 22px; letter-spacing: -.025em; }
.section-heading p { margin: 5px 0 0; color: var(--muted); font-size: 13px; }

.stats-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; margin-bottom: 13px; }
.stat-card {
  min-height: 102px; padding: 14px;
  border: 1px solid var(--line-soft); border-radius: 18px;
  background: linear-gradient(145deg, #151f3e, #10182f);
}
.stat-card.wide { grid-column: span 2; min-height: 85px; }
.stat-label { color: var(--muted); font-size: 12px; line-height: 1.25; }
.stat-value { margin-top: 11px; font-size: 27px; font-weight: 900; letter-spacing: -.04em; }
.stat-note { margin-top: 5px; color: var(--muted-2); font-size: 11px; }
.stat-card.danger .stat-value { color: var(--danger); }
.stat-card.success .stat-value { color: var(--success); }

.panel {
  margin-top: 12px; padding: 13px;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: rgba(21, 30, 58, .92);
}
.panel-title-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 7px; }
.panel h3 { margin: 0; font-size: 17px; }
.text-button { border: 0; background: transparent; color: var(--accent); padding: 8px; cursor: pointer; }

.list { display: grid; gap: 7px; }
.list.roomy { gap: 9px; }
.list-item {
  width: 100%; display: flex; align-items: center; gap: 11px;
  padding: 11px; border: 1px solid transparent; border-radius: 15px;
  background: var(--card-2); text-align: left; cursor: pointer;
}
.list-item:hover { border-color: var(--line-soft); }
.list-item:active { transform: scale(.992); }
.avatar {
  flex: 0 0 auto; width: 42px; height: 42px; border-radius: 14px;
  display: grid; place-items: center; background: #202b50; color: #bdc9ff;
  font-size: 13px; font-weight: 900;
}
.item-main { min-width: 0; flex: 1; }
.item-title { font-weight: 790; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-subtitle { color: var(--muted); font-size: 12px; margin-top: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-meta { color: var(--muted-2); font-size: 11px; margin-top: 4px; }
.chevron { color: var(--muted-2); font-size: 20px; }
.badge { display: inline-flex; padding: 4px 7px; border-radius: 8px; font-size: 10px; font-weight: 750; background: #253258; color: #c3cff5; }
.badge.danger { color: #ffd3d8; background: rgba(171, 49, 72, .34); }
.badge.success { color: #c7ffe3; background: rgba(41, 126, 91, .34); }

.search-box {
  display: flex; align-items: center; gap: 9px;
  padding: 0 12px; height: 48px; margin-bottom: 12px;
  border: 1px solid var(--line-soft); border-radius: 15px; background: #0c142c;
  color: var(--muted-2);
}
.search-box input { width: 100%; min-width: 0; border: 0; outline: 0; color: var(--text); background: transparent; }
.search-box input::placeholder { color: var(--muted-2); }

.filter-row { display: flex; gap: 7px; overflow-x: auto; padding: 1px 1px 10px; scrollbar-width: none; }
.filter-row::-webkit-scrollbar { display: none; }
.filter { flex: 0 0 auto; border: 1px solid var(--line-soft); border-radius: 999px; background: #0d1530; color: var(--muted); padding: 8px 12px; font-size: 12px; cursor: pointer; }
.filter.active { color: var(--text); border-color: #657dbd; background: #233158; }
.timeline { display: grid; gap: 9px; }
.event-card { position: relative; padding: 13px 13px 13px 17px; border: 1px solid var(--line-soft); border-radius: 17px; background: var(--card); cursor: pointer; }
.event-card::before { content: ""; position: absolute; left: 0; top: 15px; bottom: 15px; width: 3px; border-radius: 0 4px 4px 0; background: var(--accent); }
.event-card.error::before { background: var(--danger); }
.event-card.success::before { background: var(--success); }
.event-title { font-size: 14px; font-weight: 820; }
.event-details { margin-top: 5px; color: var(--muted); font-size: 12px; }
.event-time { margin-top: 7px; color: var(--muted-2); font-size: 11px; }

.primary-button, .secondary-button {
  border: 1px solid transparent; border-radius: 14px; padding: 12px 16px; cursor: pointer; font-weight: 750;
}
.primary-button { background: var(--accent-strong); color: #fff; }
.secondary-button { width: 100%; margin-top: 12px; background: #17213f; border-color: var(--line-soft); }
.empty { padding: 26px 12px; text-align: center; color: var(--muted); font-size: 13px; }
.loader { padding: 28px; text-align: center; color: var(--muted); }

.drawer-backdrop { position: fixed; z-index: 90; inset: 0; background: rgba(1, 4, 13, .66); backdrop-filter: blur(3px); }
.detail-drawer {
  position: fixed; z-index: 100; left: 50%; bottom: 0;
  width: min(100%, 760px); max-height: calc(100vh - 34px);
  transform: translate(-50%, 110%); transition: transform .24s ease;
  border: 1px solid var(--line); border-bottom: 0; border-radius: 26px 26px 0 0;
  background: #0b1125; box-shadow: 0 -20px 80px rgba(0,0,0,.55);
  overflow: hidden;
}
.detail-drawer.open { transform: translate(-50%, 0); }
.drawer-handle { width: 46px; height: 5px; border-radius: 99px; background: #5b6e9a; margin: 8px auto 3px; }
.drawer-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; padding: 10px 15px 12px; border-bottom: 1px solid var(--line-soft); }
.drawer-header h2 { margin: 0; font-size: 21px; line-height: 1.2; }
.drawer-header p { margin: 5px 0 0; color: var(--muted); font-size: 12px; }
.drawer-body { max-height: calc(100vh - 125px); overflow-y: auto; padding: 13px 14px calc(24px + var(--safe-bottom)); }
.detail-section { margin-bottom: 11px; padding: 13px; border: 1px solid var(--line); border-radius: 19px; background: var(--card); }
.detail-section h3 { margin: 0 0 10px; font-size: 16px; }
.detail-grid { border: 1px solid var(--line-soft); border-radius: 14px; overflow: hidden; }
.detail-row { display: grid; grid-template-columns: minmax(105px, .9fr) minmax(0, 1.25fr); gap: 10px; padding: 10px; background: #0e1730; border-bottom: 1px solid rgba(32,47,83,.7); }
.detail-row:nth-child(even) { background: #101a35; }
.detail-row:last-child { border-bottom: 0; }
.detail-label { color: var(--muted); font-size: 12px; line-height: 1.25; }
.detail-value { color: var(--text); font-size: 12px; line-height: 1.35; text-align: right; overflow-wrap: anywhere; }
.detail-value.strong { font-weight: 800; font-size: 13px; }
.raw-json { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; font: 11px/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; color: #c6d1ec; }
.summary-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 8px; margin-bottom: 11px; }
.summary-box { padding: 12px; border-radius: 14px; background: #0e1730; }
.summary-box span { display: block; color: var(--muted); font-size: 10px; }
.summary-box strong { display: block; margin-top: 7px; font-size: 18px; }

.toast { position: fixed; z-index: 120; left: 50%; bottom: calc(18px + var(--safe-bottom)); transform: translateX(-50%); max-width: calc(100% - 32px); padding: 11px 15px; border-radius: 13px; background: #27365d; box-shadow: 0 10px 40px rgba(0,0,0,.4); font-size: 13px; }

@media (min-width: 640px) {
  .content { padding-inline: 20px; }
  .topbar { padding-inline: 22px; }
  .tabs { margin-inline: 20px; }
  .stats-grid { grid-template-columns: repeat(4, minmax(0,1fr)); }
  .stat-card.wide { grid-column: span 2; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; }
}
