:root {
  color-scheme: light;
  --bg: #f5f5f7;
  --bg-elevated: rgba(255, 255, 255, 0.82);
  --bg-solid: #ffffff;
  --text: #111114;
  --text-soft: #565963;
  --text-muted: #767a84;
  --border: rgba(10, 10, 12, 0.1);
  --border-strong: rgba(10, 10, 12, 0.16);
  --accent: #007aff;
  --accent-strong: #0066d6;
  --accent-soft: rgba(0, 122, 255, 0.11);
  --green: #2f8f55;
  --green-soft: rgba(47, 143, 85, 0.12);
  --orange: #b35b00;
  --orange-soft: rgba(255, 149, 0, 0.14);
  --red: #c42b1c;
  --red-soft: rgba(255, 59, 48, 0.12);
  --shadow: 0 18px 60px rgba(20, 23, 31, 0.1);
  --shadow-soft: 0 8px 28px rgba(20, 23, 31, 0.08);
  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 16px;
  --radius-sm: 12px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #050507;
  --bg-elevated: rgba(28, 28, 31, 0.78);
  --bg-solid: #151518;
  --text: #f5f5f7;
  --text-soft: #c6c8ce;
  --text-muted: #91949d;
  --border: rgba(255, 255, 255, 0.12);
  --border-strong: rgba(255, 255, 255, 0.2);
  --accent: #0a84ff;
  --accent-strong: #409cff;
  --accent-soft: rgba(10, 132, 255, 0.18);
  --green: #5bd27d;
  --green-soft: rgba(91, 210, 125, 0.14);
  --orange: #ffb14a;
  --orange-soft: rgba(255, 177, 74, 0.16);
  --red: #ff6961;
  --red-soft: rgba(255, 105, 97, 0.16);
  --shadow: 0 22px 70px rgba(0, 0, 0, 0.44);
  --shadow-soft: 0 10px 34px rgba(0, 0, 0, 0.36);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-height: 100%;
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background: linear-gradient(180deg, var(--bg), var(--bg));
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Segoe UI", sans-serif;
  line-height: 1.5;
  letter-spacing: 0;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(1180px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 18px 18px calc(18px + var(--safe-bottom));
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 0 18px;
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
  min-width: 0;
}

.brand-mark {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  border-radius: 14px;
  color: white;
  background: linear-gradient(135deg, var(--accent), #34c759);
  font-size: 18px;
  font-weight: 800;
  box-shadow: var(--shadow-soft);
}

.brand-copy {
  display: grid;
  min-width: 0;
}

.brand-copy strong {
  font-size: 17px;
  line-height: 1.2;
}

.brand-copy span {
  color: var(--text-muted);
  font-size: 13px;
  white-space: nowrap;
}

.topbar-actions {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
}

.data-chip {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-soft);
  background: var(--bg-elevated);
  font-size: 13px;
  white-space: nowrap;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text);
  background: var(--bg-elevated);
  box-shadow: var(--shadow-soft);
}

.theme-icon {
  position: relative;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background: var(--text);
}

:root[data-theme="dark"] .theme-icon {
  background: transparent;
  box-shadow: inset -5px 0 0 0 var(--text);
  border: 1px solid var(--text);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(340px, 0.86fr) minmax(0, 1.14fr);
  gap: 18px;
  align-items: start;
}

.search-panel {
  position: sticky;
  top: 78px;
  padding: 12px 4px;
}

.result-panel {
  min-height: 620px;
  padding: 0;
}

.panel-heading {
  display: grid;
  gap: 8px;
  margin-bottom: 20px;
}

.eyebrow {
  margin: 0;
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

.panel-heading h1 {
  margin-bottom: 0;
  font-size: clamp(27px, 3.5vw, 42px);
  line-height: 1.08;
  letter-spacing: 0;
}

.segmented-control {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  margin-bottom: 18px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: rgba(127, 127, 127, 0.11);
}

.segment {
  min-height: 42px;
  border: 0;
  border-radius: 12px;
  color: var(--text-soft);
  background: transparent;
  font-size: 15px;
  font-weight: 700;
}

.segment.is-active {
  color: var(--text);
  background: var(--bg-solid);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
}

.mode-panel {
  display: grid;
  gap: 10px;
}

.mode-panel[hidden] {
  display: none;
}

.field-label {
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
}

.search-box {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

.autocomplete {
  position: relative;
  min-width: 0;
}

.search-box input {
  width: 100%;
  min-height: 54px;
  padding: 0 16px;
  border: 1px solid var(--border);
  border-radius: 16px;
  color: var(--text);
  background: var(--bg-solid);
  outline: none;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.search-box input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.suggestion-panel {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  z-index: 30;
  max-height: 310px;
  overflow: auto;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--bg-solid);
  box-shadow: var(--shadow);
}

.suggestion-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  min-height: 42px;
  padding: 9px 10px;
  border: 0;
  border-radius: 12px;
  color: var(--text);
  background: transparent;
  text-align: left;
}

.suggestion-option:hover,
.suggestion-option.is-active {
  background: var(--accent-soft);
}

.suggestion-option span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.suggestion-option small {
  flex: 0 0 auto;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 800;
}

.primary-button {
  min-width: 84px;
  min-height: 54px;
  padding: 0 18px;
  border: 0;
  border-radius: 16px;
  color: white;
  background: var(--accent);
  font-weight: 800;
  box-shadow: 0 12px 24px rgba(0, 122, 255, 0.24);
}

.primary-button:hover {
  background: var(--accent-strong);
}

.field-hint {
  margin-bottom: 2px;
  color: var(--text-muted);
  font-size: 13px;
}

.notice-card {
  display: grid;
  gap: 4px;
  margin-top: 18px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--bg-solid);
  color: var(--text-soft);
  font-size: 13px;
}

.notice-card strong {
  color: var(--text);
}

.empty-state,
.loading-state {
  min-height: 580px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 12px;
  text-align: center;
  color: var(--text-muted);
}

.empty-state h2 {
  margin-bottom: 0;
  color: var(--text);
  font-size: 24px;
}

.empty-state p {
  max-width: 360px;
  margin-bottom: 0;
}

.empty-visual {
  width: 76px;
  height: 76px;
  border-radius: 26px;
  background:
    linear-gradient(var(--accent-soft), var(--accent-soft)) padding-box,
    linear-gradient(135deg, var(--accent), #34c759) border-box;
  border: 1px solid transparent;
  box-shadow: var(--shadow-soft);
}

.spinner {
  width: 30px;
  height: 30px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 999px;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.results {
  display: grid;
  gap: 14px;
}

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

.summary-tile,
.result-card,
.alert-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-solid);
  box-shadow: var(--shadow-soft);
}

.summary-tile {
  min-height: 108px;
  padding: 16px;
}

.summary-tile span {
  display: block;
  margin-bottom: 8px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
}

.summary-tile strong {
  display: block;
  color: var(--text);
  font-size: 21px;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.summary-tile small {
  display: block;
  margin-top: 5px;
  color: var(--text-muted);
  font-size: 12px;
}

.result-card {
  padding: 18px;
}

.result-card.primary {
  border-color: rgba(0, 122, 255, 0.28);
  background: linear-gradient(180deg, var(--accent-soft), var(--bg-solid) 68%);
}

.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.card-title {
  display: grid;
  gap: 2px;
}

.card-title span {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
}

.card-title strong {
  font-size: 22px;
  line-height: 1.25;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  color: var(--accent);
  background: var(--accent-soft);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.badge.green {
  color: var(--green);
  background: var(--green-soft);
}

.badge.orange {
  color: var(--orange);
  background: var(--orange-soft);
}

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

.detail-item {
  display: grid;
  gap: 3px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(127, 127, 127, 0.06);
}

.detail-item span {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
}

.detail-item strong,
.detail-item p {
  margin: 0;
  color: var(--text);
  overflow-wrap: anywhere;
}

.detail-item.wide {
  grid-column: 1 / -1;
}

.card-list {
  display: grid;
  gap: 10px;
}

.compact-row {
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: rgba(127, 127, 127, 0.06);
}

.compact-row-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.compact-row-title strong {
  font-size: 17px;
}

.meta-line {
  color: var(--text-soft);
  font-size: 14px;
  overflow-wrap: anywhere;
}

details {
  margin-top: 10px;
}

summary {
  color: var(--accent);
  font-size: 14px;
  font-weight: 800;
  list-style: none;
  cursor: pointer;
}

summary::-webkit-details-marker {
  display: none;
}

.details-body {
  display: grid;
  gap: 8px;
  margin-top: 10px;
  color: var(--text-soft);
  font-size: 14px;
}

.alert-card {
  display: grid;
  gap: 8px;
  padding: 18px;
}

.alert-card strong {
  color: var(--text);
}

.alert-card p,
.alert-card ul {
  margin: 0;
  color: var(--text-soft);
}

.alert-card ul {
  padding-left: 18px;
}

.alert-card.warning {
  border-color: rgba(255, 149, 0, 0.34);
  background: var(--orange-soft);
}

.alert-card.error {
  border-color: rgba(255, 59, 48, 0.34);
  background: var(--red-soft);
}

@media (max-width: 900px) {
  .app-shell {
    padding: 12px 12px calc(14px + var(--safe-bottom));
  }

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

  .search-panel {
    position: static;
    padding: 4px 0;
  }

  .result-panel {
    min-height: 420px;
  }

  .empty-state,
  .loading-state {
    min-height: 300px;
  }

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

@media (max-width: 560px) {
  .topbar {
    align-items: flex-start;
  }

  .data-chip {
    display: none;
  }

  .brand-copy span {
    white-space: normal;
  }

  .panel-heading h1 {
    font-size: 22px;
    line-height: 1.18;
  }

  .empty-state h2 {
    font-size: 18px;
  }

  .empty-visual {
    width: 58px;
    height: 58px;
    border-radius: 20px;
  }

  .summary-tile {
    min-height: 82px;
    padding: 13px;
  }

  .summary-tile strong {
    font-size: 17px;
  }

  .result-card,
  .alert-card {
    padding: 14px;
  }

  .card-title strong {
    font-size: 18px;
  }

  .compact-row-title strong {
    font-size: 15px;
  }

  .search-box {
    grid-template-columns: 1fr;
  }

  .primary-button {
    width: 100%;
  }

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

  .card-header,
  .compact-row-title {
    flex-direction: column;
    align-items: flex-start;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
  }
}
