:root {
  color-scheme: light;
  font-family: "Aptos", "Segoe UI", ui-sans-serif, sans-serif;
  background: #070a0f;
  color: #e8edf5;
  --sidebar: #070b12;
  --sidebar-muted: #8fa1bb;
  --surface: rgba(13, 19, 30, 0.82);
  --surface-alt: rgba(255, 255, 255, 0.045);
  --line: rgba(139, 157, 184, 0.22);
  --text-muted: #96a6bc;
  --hub-accent: #1f8a70;
  --accent: #77e5c5;
  --accent-dark: #47b99a;
  --danger: #ff6b6b;
  --warning: #ffc857;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.34);
  --viewport-width: 1440px;
  --viewport-height: 900px;
  --render-viewport-height: 900px;
  --viewport-scale: 1;
  --scaled-viewport-width: 1440px;
  --scaled-viewport-height: 900px;
}

* {
  box-sizing: border-box;
}

*[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow-x: hidden;
  overflow-y: hidden;
}

button,
input,
a {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: 282px minmax(0, 1fr);
  width: 100%;
  height: 100vh;
  min-height: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 78% 0%, rgba(119, 229, 197, 0.13), transparent 32rem),
    radial-gradient(circle at 14% 100%, rgba(92, 124, 250, 0.12), transparent 30rem),
    linear-gradient(90deg, var(--sidebar) 0 282px, #070a0f 282px);
}

body.preview-focus .app-shell {
  grid-template-columns: 1fr;
  height: 100vh;
  overflow: hidden;
}

body.preview-focus {
  overflow: hidden;
}

body.preview-focus .sidebar,
body.preview-focus .topbar,
body.preview-focus .details-panel {
  display: none;
}

body.preview-focus .workspace {
  padding: 0;
  overflow: hidden;
}

body.preview-focus .content-grid {
  grid-template-columns: 1fr;
  gap: 0;
}

body.preview-focus .preview-panel {
  border: 0;
  border-radius: 0;
  box-shadow: none;
  height: 100vh;
  min-height: 100vh;
}

body.preview-focus .preview-panel .panel-header {
  flex: 0 0 auto;
  min-height: 74px;
  padding: 12px 68px 12px 16px;
  background: #ffffff;
}

body.preview-focus #focusPreviewButton {
  color: #ffffff;
  background: rgba(23, 32, 47, 0.86);
  border-color: rgba(255, 255, 255, 0.24);
}

body.preview-focus .preview-stage,
body.preview-focus .device-frame {
  width: 100%;
}

body.preview-focus .preview-stage,
body.preview-focus .device-frame {
  min-height: calc(100vh - 74px);
  height: calc(100vh - 74px);
}

body.preview-focus .device-frame {
  padding: 0;
  overflow: hidden;
}

body.preview-focus iframe {
  box-shadow: 0 18px 48px rgba(17, 24, 39, 0.24);
}

.sidebar {
  height: 100vh;
  border-right: 1px solid rgba(139, 157, 184, 0.18);
  background:
    linear-gradient(180deg, rgba(14, 21, 34, 0.98), rgba(7, 11, 18, 0.98)),
    var(--sidebar);
  color: #fff;
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 24px 18px;
  min-height: 0;
  overflow: hidden;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  position: relative;
}

.brand-mark {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  border: 1px solid rgba(119, 229, 197, 0.34);
  background:
    linear-gradient(135deg, rgba(119, 229, 197, 0.22), rgba(92, 124, 250, 0.22)),
    #101827;
  color: #baf7e4;
  box-shadow: 0 0 28px rgba(119, 229, 197, 0.18);
  font-weight: 800;
}

.brand h1,
.brand p,
.topbar h2,
.topbar p,
.panel-header h3,
.panel-header p,
.metric-panel p,
.helper-block p {
  margin: 0;
}

.brand h1 {
  font-size: 20px;
  line-height: 1.1;
}

.brand p {
  color: var(--sidebar-muted);
  font-size: 13px;
  margin-top: 4px;
}

.sidebar-icon-button {
  min-height: 34px;
  margin-left: auto;
  padding: 0 10px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  color: #ffffff;
  background: rgba(255, 255, 255, 0.08);
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
}

.stats-sidebar {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 22px 16px;
  background: var(--sidebar);
  color: #ffffff;
  overflow: auto;
}

.stats-sidebar__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.stats-sidebar__header h2 {
  margin: 4px 0 0;
  font-size: 22px;
}

.stats-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.stats-tab {
  min-height: 34px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  color: #dbe5f4;
  background: rgba(255, 255, 255, 0.07);
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
}

.stats-tab.active {
  color: #ffffff;
  background: var(--accent);
}

.stats-view {
  display: none;
  gap: 10px;
}

.stats-view.active {
  display: grid;
}

.sidebar-metric {
  padding: 13px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.07);
}

.sidebar-metric span {
  display: block;
  color: var(--sidebar-muted);
  font-size: 11px;
  font-weight: 850;
  text-transform: uppercase;
}

.sidebar-metric strong {
  display: block;
  margin-top: 6px;
  overflow: hidden;
  color: #ffffff;
  font-size: 22px;
  line-height: 1.05;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-metric p {
  margin: 7px 0 0;
  color: #b5c2d5;
  font-size: 12px;
  line-height: 1.35;
}

.sidebar-tools {
  display: grid;
  gap: 12px;
}

.search-field {
  display: grid;
  gap: 7px;
  color: var(--sidebar-muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0;
}

.search-field input {
  width: 100%;
  min-height: 42px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  padding: 0 12px;
  outline: none;
}

.search-field input::placeholder {
  color: #a8b4c7;
}

.project-list {
  display: grid;
  gap: 8px;
  overflow: auto;
  padding-right: 4px;
}

.project-item {
  width: 100%;
  border: 1px solid rgba(139, 157, 184, 0.13);
  border-left: 4px solid transparent;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.035);
  color: #fff;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  padding: 12px;
  text-align: left;
  cursor: pointer;
}

.project-item:hover,
.project-item.active {
  background:
    linear-gradient(145deg, rgba(119, 229, 197, 0.16), rgba(92, 124, 250, 0.1)),
    rgba(255, 255, 255, 0.06);
  border-color: rgba(119, 229, 197, 0.28);
  border-left-color: var(--project-accent, var(--accent));
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.24);
}

.project-name {
  font-weight: 750;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.project-meta {
  color: var(--sidebar-muted);
  font-size: 12px;
  margin-top: 4px;
}

.project-actions {
  display: flex;
  align-items: start;
  gap: 6px;
  justify-items: end;
}

.project-stats-button {
  width: 26px;
  height: 24px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.075);
  color: #ffffff;
  cursor: pointer;
  display: grid;
  grid-template-columns: repeat(3, 3px);
  gap: 2px;
  align-items: end;
  justify-content: center;
  padding: 4px;
}

.project-stats-button span {
  display: block;
  width: 3px;
  border-radius: 2px;
  background: currentColor;
}

.project-stats-button span:nth-child(1) {
  height: 7px;
}

.project-stats-button span:nth-child(2) {
  height: 12px;
}

.project-stats-button span:nth-child(3) {
  height: 9px;
}

.project-stats-button:hover {
  background: var(--project-accent, var(--accent));
}

.status-dot {
  align-self: start;
  width: 20px;
  height: 20px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 50%;
  background: #6f7c90;
  box-shadow: 0 0 0 5px rgba(111, 124, 144, 0.12);
}

.status-dot.is-action {
  cursor: pointer;
}

.status-dot.stopped {
  background: #6f7c90;
}

.status-dot.stopped.is-action:hover {
  background: #ffffff;
}

.status-dot.running {
  background: #77e5c5;
  box-shadow: 0 0 0 5px rgba(119, 229, 197, 0.13), 0 0 20px rgba(119, 229, 197, 0.48);
}

.status-dot.partial {
  background: var(--warning);
  box-shadow: 0 0 0 5px rgba(255, 200, 87, 0.15), 0 0 20px rgba(255, 200, 87, 0.38);
}

.workspace {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  min-width: 0;
  min-height: 0;
  height: 100vh;
  overflow: hidden;
  background:
    radial-gradient(circle at 82% 0%, rgba(119, 229, 197, 0.1), transparent 28rem),
    #070a0f;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(13, 19, 30, 0.76);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.eyebrow {
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0;
}

.topbar h2 {
  font-size: 24px;
  line-height: 1.1;
  margin-top: 5px;
  color: #ffffff;
}

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

.primary-button,
.secondary-button,
.danger-button,
.ghost-button,
.icon-button {
  min-height: 36px;
  border-radius: 999px;
  border: 1px solid transparent;
  padding: 0 12px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
}

.primary-button {
  background: var(--accent);
  color: #fff;
}

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

.secondary-button {
  border-color: rgba(139, 157, 184, 0.28);
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
}

.danger-button {
  background: rgba(255, 255, 255, 0.06);
  color: var(--danger);
  border-color: rgba(255, 107, 107, 0.36);
}

.danger-button:hover {
  color: #ffffff;
  background: var(--danger);
  border-color: var(--danger);
}

.ghost-button,
.icon-button {
  color: #e8edf5;
  background: rgba(255, 255, 255, 0.06);
  border-color: var(--line);
}

.sidebar .ghost-button {
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.14);
}

.ghost-button.is-loading {
  gap: 8px;
  cursor: wait;
  opacity: 0.82;
}

.ghost-button.is-loading::before {
  content: '';
  width: 14px;
  height: 14px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}

.project-list.is-refreshing {
  opacity: 0.72;
  pointer-events: none;
}

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

.small {
  min-height: 32px;
  padding: 0 10px;
  font-size: 13px;
}

.chart-panel {
  min-width: 0;
  min-height: 260px;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.chart-panel--wide {
  min-width: 0;
}

.chart-frame,
.d3-chart {
  flex: 1;
  min-height: 184px;
  padding: 14px 16px 16px;
}

.chart-frame canvas {
  width: 100% !important;
  height: 184px !important;
}

.d3-chart svg {
  display: block;
  width: 100%;
  height: 184px;
}

.d3-axis-label {
  fill: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
}

.d3-bar-label {
  fill: #17202f;
  font-size: 12px;
  font-weight: 800;
}

.d3-empty-state {
  height: 184px;
  display: grid;
  place-items: center;
  color: var(--text-muted);
  font-size: 14px;
  text-align: center;
}

.metric-panel,
.preview-panel,
.details-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.metric-panel {
  padding: 16px;
  border-top: 4px solid color-mix(in srgb, var(--accent) 64%, #ffffff);
}

.metric-label {
  display: block;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0;
  margin-bottom: 8px;
}

.metric-panel strong {
  display: block;
  font-size: 24px;
  line-height: 1.1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.metric-panel p {
  color: var(--text-muted);
  margin-top: 8px;
  font-size: 14px;
  line-height: 1.4;
}

.admin-switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 10px 12px 0;
  padding: 10px 0 0;
  border-top: 1px solid var(--line);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 800;
}

.admin-action {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text-muted);
  background: #ffffff;
  font-size: 13px;
  font-weight: 800;
}

.admin-switch {
  position: relative;
  flex: 0 0 auto;
  width: 42px;
  height: 24px;
  padding: 2px;
  border: 0;
  border-radius: 999px;
  background: #cfd7e3;
  box-shadow: inset 0 1px 4px rgba(17, 24, 39, 0.22);
  cursor: pointer;
  transition: background-color 180ms ease, opacity 180ms ease;
}

.admin-switch span {
  display: block;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 2px 7px rgba(17, 24, 39, 0.26);
  transition: transform 180ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.admin-switch.is-on {
  background: #34c759;
}

.admin-switch.is-on span {
  transform: translateX(18px);
}

.admin-switch.is-missing {
  opacity: 0.58;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
  min-height: 0;
  overflow: hidden;
}

.preview-panel {
  height: calc(100vh - 98px);
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.panel-header {
  min-height: 62px;
  padding: 12px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.preview-panel .panel-header {
  align-items: flex-start;
}

.panel-header h3 {
  font-size: 16px;
  margin-top: 4px;
}

.compact {
  min-height: 70px;
}

.preview-toolbar {
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
}

.resolution-control,
.size-input {
  display: grid;
  gap: 5px;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0;
}

.resolution-control select,
.size-input input,
#viewportPreset,
#viewportWidth,
#viewportHeight {
  min-height: 40px;
  border: 1px solid rgba(119, 229, 197, 0.48) !important;
  border-radius: 8px !important;
  background: #0d1725 !important;
  color: #f5f7ff !important;
  padding: 0 10px !important;
  outline: none !important;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04) !important;
  -webkit-appearance: none;
  appearance: none;
}

.resolution-control select:focus,
.size-input input:focus,
#viewportPreset:focus,
#viewportWidth:focus,
#viewportHeight:focus {
  border-color: rgba(119, 229, 197, 0.8) !important;
  box-shadow: 0 0 0 3px rgba(119, 229, 197, 0.18) !important;
}

.resolution-control select option,
#viewportPreset option {
  background: #0d1725;
  color: #f5f7ff;
}

.resolution-control select {
  width: 190px;
}

.size-input input {
  width: 82px;
}

.preview-stage {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  background:
    linear-gradient(90deg, rgba(139, 157, 184, 0.08) 1px, transparent 1px),
    linear-gradient(0deg, rgba(139, 157, 184, 0.08) 1px, transparent 1px),
    radial-gradient(circle at center, rgba(119, 229, 197, 0.06), transparent 32rem),
    #090f18;
  background-size: 34px 34px, 34px 34px, auto, auto;
  position: relative;
}

.empty-preview {
  height: 100%;
  flex: 1;
  display: grid;
  place-content: center;
  gap: 8px;
  text-align: center;
  padding: 40px;
  background: transparent;
}

.empty-preview h3 {
  margin: 0;
  font-size: 24px;
  color: #ffffff;
}

.empty-preview p {
  margin: 0 auto;
  max-width: 520px;
  color: var(--text-muted);
  line-height: 1.55;
}

.device-frame {
  width: 100%;
  height: 100%;
  overflow-x: hidden;
  overflow-y: hidden;
  display: grid;
  place-items: start center;
  padding: 18px;
}

.device-frame.browser {
  padding: 0;
  background: #ffffff;
  place-items: start center;
  overflow-x: hidden;
  overflow-y: hidden;
}

.device-frame.browser iframe {
  box-shadow: none;
}

.viewport-shell {
  width: var(--scaled-viewport-width);
  height: var(--scaled-viewport-height);
  flex: none;
  overflow: hidden;
}

iframe {
  display: block;
  width: var(--viewport-width);
  height: var(--viewport-height);
  max-width: none;
  border: 0;
  background: #fff;
  box-shadow: 0 18px 48px rgba(17, 24, 39, 0.24);
  transform: scale(var(--viewport-scale));
  transform-origin: top left;
}

.details-panel {
  overflow-x: hidden;
  overflow-y: auto;
  display: grid;
  grid-template-columns: 1fr;
  min-width: 0;
  max-height: calc(100vh - 116px);
  scrollbar-width: thin;
}

.details-panel .panel-header,
.details-panel .details-list,
.details-panel .logs-block {
  grid-column: 1 / -1;
}

.details-panel .details-list div {
  border-right: 0;
}

.details-list {
  display: grid;
  gap: 0;
  margin: 0;
  padding: 0;
}

.details-list div {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.details-list dt {
  color: var(--text-muted);
  font-size: 12px;
  text-transform: uppercase;
  font-weight: 800;
  letter-spacing: 0;
}

.details-list dd {
  margin: 7px 0 0;
  color: #e8edf5;
  font-size: 14px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.capability-badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  margin: 0 6px 6px 0;
  padding: 0 9px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 13%, #ffffff);
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 800;
}

.capability-badge.warning {
  background: #fff3d7;
  color: #8a560f;
}

.capability-badge.muted {
  background: #eef1f6;
  color: var(--text-muted);
}

.document-block {
  padding: 12px;
  border-bottom: 1px solid var(--line);
}

.document-block h4 {
  margin: 0 0 8px;
  font-size: 15px;
  color: #ffffff;
}

.document-block p {
  margin: 0;
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.5;
}

.helper-block {
  padding: 16px;
  background: rgba(119, 229, 197, 0.08);
  border-bottom: 1px solid rgba(119, 229, 197, 0.18);
}

.helper-block h4,
.logs-header h4 {
  margin: 0 0 8px;
  font-size: 15px;
}

.helper-block p {
  color: #b8d8cf;
  line-height: 1.5;
  font-size: 14px;
}

.traffic-list {
  display: grid;
  gap: 8px;
}

.stats-sidebar .traffic-list {
  color: #17202f;
}

.compact-list .traffic-row {
  grid-template-columns: minmax(0, 1fr) auto;
}

.compact-list .traffic-row span:last-child {
  display: none;
}

.traffic-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 12px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: inherit;
  text-decoration: none;
  background: var(--surface-alt);
  transition: border-color 0.2s, transform 0.2s;
}

.traffic-row:hover {
  border-color: color-mix(in srgb, var(--accent) 35%, var(--line));
  transform: translateY(-1px);
}

.traffic-row strong,
.traffic-row small {
  display: block;
}

.traffic-row small {
  color: var(--text-muted);
  font-size: 12px;
  margin-top: 2px;
}

.logs-block {
  display: flex;
  flex-direction: column;
  min-height: 260px;
  flex: 0 0 auto;
  overflow: visible;
}

.logs-header {
  padding: 14px 16px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

pre {
  flex: 0 0 auto;
  min-height: 160px;
  max-height: 320px;
  margin: 0;
  padding: 14px 16px 18px;
  overflow-x: hidden;
  overflow-y: auto;
  background: #111827;
  color: #d7e1f2;
  font-size: 12px;
  line-height: 1.55;
  white-space: pre-wrap;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(15, 23, 42, 0.58);
  backdrop-filter: blur(3px);
}

.project-stats-modal {
  width: min(1080px, 100%);
  height: min(820px, calc(100vh - 48px));
  max-height: calc(100vh - 48px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f5f7fb;
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.32);
}

.modal-tabs {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: #ffffff;
}

.modal-tab {
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: #17202f;
  background: #ffffff;
  cursor: pointer;
  font-weight: 800;
}

.modal-tab.active {
  color: #ffffff;
  border-color: var(--accent);
  background: var(--accent);
}

.project-stats-content {
  flex: 1;
  min-height: 0;
  overflow: auto;
  background: #f5f7fb;
}

.project-stats-view {
  display: none;
}

.project-stats-view.active {
  display: block;
}

.modal-header {
  flex: 0 0 auto;
  position: sticky;
  top: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
  background: #ffffff;
}

.modal-header h2 {
  margin: 4px 0 0;
  font-size: 24px;
}

.modal-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.modal-metrics article {
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-top: 4px solid var(--accent);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 10px 24px rgba(26, 39, 59, 0.07);
}

.modal-metrics span {
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 850;
  text-transform: uppercase;
}

.modal-metrics strong {
  display: block;
  margin-top: 6px;
  overflow: hidden;
  font-size: 22px;
  line-height: 1.05;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.modal-panel {
  min-width: 0;
  overflow: hidden;
}

.modal-panel h3 {
  margin: 0;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: #ffffff;
  font-size: 17px;
}

.analysis-widgets {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(260px, 0.65fr);
  gap: 12px;
  padding: 0 16px 16px;
  border-bottom: 1px solid var(--line);
}

.widget-wide {
  grid-column: 1 / -1;
}

.modal-chart-card,
.modal-data-card {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 10px 24px rgba(26, 39, 59, 0.07);
  overflow: hidden;
}

.modal-chart-card h4,
.modal-data-card h4 {
  margin: 0;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: #ffffff;
  font-size: 14px;
}

.modal-chart-frame {
  height: 230px;
  padding: 14px;
}

.modal-chart-frame canvas {
  width: 100% !important;
  height: 202px !important;
}

.analysis-list {
  margin: 0;
  background: #ffffff;
}

.analysis-list div {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  gap: 16px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}

.analysis-list dt {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 850;
  text-transform: uppercase;
}

.analysis-list dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.modal-panel pre {
  max-height: none;
  min-height: 390px;
}

.insight-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  padding: 16px;
}

.insight-card {
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--text-muted);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 10px 24px rgba(26, 39, 59, 0.07);
}

.insight-card.good {
  border-left-color: var(--accent);
}

.insight-card.warning {
  border-left-color: var(--warning);
}

.insight-card.muted {
  border-left-color: #9aa7ba;
}

.insight-card span,
.signal-row span {
  display: block;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 850;
  text-transform: uppercase;
}

.insight-card strong {
  display: block;
  margin-top: 8px;
  overflow: hidden;
  color: #17202f;
  font-size: 24px;
  line-height: 1.05;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.insight-card p {
  margin: 8px 0 0;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.4;
}

.rank-list,
.signal-list {
  display: grid;
  gap: 8px;
  padding: 12px;
}

.rank-row {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  min-height: 42px;
  padding: 10px 12px;
  overflow: hidden;
  border: 1px solid #e5ebf3;
  border-radius: 8px;
  background: #f8fafc;
}

.rank-row span,
.rank-row strong {
  position: relative;
  z-index: 1;
}

.rank-row span {
  overflow: hidden;
  color: #17202f;
  font-weight: 750;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rank-row strong {
  color: var(--accent-dark);
}

.rank-row i {
  position: absolute;
  inset: auto 0 0 0;
  width: var(--bar);
  height: 3px;
  background: var(--accent);
}

.signal-row {
  display: grid;
  grid-template-columns: minmax(90px, 0.8fr) minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  min-height: 42px;
  padding: 10px 12px;
  border: 1px solid #e5ebf3;
  border-left: 4px solid #9aa7ba;
  border-radius: 8px;
  background: #f8fafc;
}

.signal-row.good {
  border-left-color: var(--accent);
}

.signal-row.warning {
  border-left-color: var(--warning);
}

.signal-row strong {
  overflow-wrap: anywhere;
  color: #17202f;
  font-size: 13px;
}

.empty-data {
  margin: 0;
  padding: 20px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--text-muted);
  text-align: center;
  background: #f8fafc;
}

.modal-backdrop {
  background: rgba(2, 6, 12, 0.72);
  backdrop-filter: blur(8px);
}

.project-stats-modal {
  border-color: rgba(139, 157, 184, 0.22);
  border-radius: 24px;
  background: #0b111b;
  color: #e8edf5;
  box-shadow: 0 34px 90px rgba(0, 0, 0, 0.56);
}

.modal-header,
.modal-tabs,
.modal-panel h3 {
  background: #111827;
}

.modal-tab {
  border-radius: 999px;
  color: #e8edf5;
  background: rgba(255, 255, 255, 0.055);
}

.modal-tab.active {
  color: #06100d;
  border-color: #77e5c5;
  background: #77e5c5;
}

.project-stats-content,
.analysis-list {
  background: #0b111b;
}

.modal-metrics article,
.modal-chart-card,
.modal-data-card,
.insight-card,
.rank-row,
.signal-row,
.empty-data {
  border-color: rgba(139, 157, 184, 0.2);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.045);
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.24);
}

.modal-metrics article {
  border-top-color: #77e5c5;
}

.modal-chart-card h4,
.modal-data-card h4 {
  background: rgba(255, 255, 255, 0.025);
}

.analysis-list dd,
.insight-card strong,
.rank-row span,
.signal-row strong {
  color: #e8edf5;
}

@media (max-width: 1120px) {
  .app-shell {
    grid-template-columns: 260px minmax(0, 1fr);
    background: linear-gradient(90deg, var(--sidebar) 0 260px, #070a0f 260px);
  }

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

  .details-panel {
    grid-template-columns: 1fr;
    min-height: 420px;
    max-height: none;
  }

  .details-panel .details-list {
    grid-template-columns: 1fr;
  }

  .details-panel .details-list div {
    border-right: 0;
  }

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

@media (max-width: 780px) {
  html,
  body {
    overflow-y: auto;
  }

  .app-shell {
    height: auto;
    min-height: 100vh;
    overflow: visible;
  }

  .app-shell {
    grid-template-columns: 1fr;
    background: #070a0f;
  }

  .sidebar {
    position: static;
    height: auto;
    min-height: auto;
    overflow: visible;
  }

  .project-list {
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  }

  .topbar,
  .actions,
  .preview-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .resolution-control select,
  .size-input input {
    width: 100%;
  }

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

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

  .workspace {
    height: auto;
    padding: 18px;
  }

  .preview-panel {
    height: min(760px, calc(100vh - 24px));
  }

  .modal-metrics {
    grid-template-columns: 1fr;
  }

  .insight-grid,
  .analysis-widgets {
    grid-template-columns: 1fr;
  }

  .analysis-list div,
  .signal-row {
    grid-template-columns: 1fr;
  }

  .project-stats-modal {
    height: calc(100vh - 24px);
    max-height: calc(100vh - 24px);
  }
}
