.app-page {
  margin: 0;
  background: #f7f9fc;
  color: #0f172a;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 224px 1fr;
}

.app-sidebar {
  background: #ffffff;
  border-right: 1px solid #edf2f7;
  padding: 0.95rem 0.8rem;
  display: grid;
  align-content: start;
  gap: 0.85rem;
}

.app-brand {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  color: #0f172a;
}

.app-brand-logo {
  display: block;
  width: clamp(128px, 15vw, 160px);
  height: auto;
}

.app-menu {
  display: grid;
  gap: 0.18rem;
}

.app-menu a {
  border-radius: 0.45rem;
  padding: 0.48rem 0.58rem;
  text-decoration: none;
  color: #64748b;
  font-size: 0.74rem;
  font-weight: 600;
}

.app-menu a:hover,
.app-menu a.active {
  color: #1d4ed8;
  background: #eff6ff;
}

.back-site {
  text-decoration: none;
  color: #94a3b8;
  font-size: 0.68rem;
}

.app-main {
  padding: 1rem;
}

.app-topbar {
  background: #ffffff;
  border: 1px solid #edf2f7;
  border-radius: 0.62rem;
  padding: 0.8rem 0.9rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.8rem;
  margin-bottom: 0.72rem;
}

.app-topbar h1 {
  margin: 0;
  font-size: 1.5rem;
  letter-spacing: -0.02em;
}

.app-topbar p {
  margin: 0.22rem 0 0;
  color: #64748b;
  font-size: 0.74rem;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.38rem;
}

.app-chip-row {
  display: inline-flex;
  gap: 0.35rem;
  margin-right: 0.2rem;
}

.app-chip {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  color: #475569;
  font-size: 0.67rem;
  border-radius: 999px;
  padding: 0.2rem 0.45rem;
  font-weight: 600;
}

.ghost-btn,
.primary-btn {
  border: 1px solid #d7e1ee;
  background: #ffffff;
  color: #334155;
  font-size: 0.67rem;
  font-weight: 700;
  border-radius: 0.35rem;
  padding: 0.37rem 0.55rem;
  cursor: pointer;
}

.primary-btn {
  background: #2563eb;
  color: #ffffff;
  border-color: #2563eb;
}

.avatar {
  width: 1.65rem;
  height: 1.65rem;
  border-radius: 999px;
  background: #dbeafe;
  color: #1d4ed8;
  display: inline-grid;
  place-items: center;
  font-size: 0.61rem;
  font-weight: 700;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.62rem;
}

.metric-card,
.panel {
  background: #ffffff;
  border: 1px solid #edf2f7;
  border-radius: 0.62rem;
  padding: 0.72rem;
}

.metric-card h2 {
  margin: 0;
  color: #64748b;
  font-size: 0.66rem;
  font-weight: 600;
}

.metric-value {
  margin: 0.36rem 0 0.45rem;
  font-size: 1.45rem;
  font-weight: 800;
  line-height: 1;
}

.metric-value span {
  color: #22c55e;
  font-size: 0.74rem;
  font-weight: 700;
}

.sparkline {
  height: 32px;
  border-radius: 0.4rem;
  border: 1px solid #edf2f7;
}

.sparkline.up {
  background:
    linear-gradient(180deg, rgba(59, 130, 246, 0.22), rgba(59, 130, 246, 0.04)),
    repeating-linear-gradient(to right, transparent, transparent 12px, rgba(255, 255, 255, 0.5) 12px, rgba(255, 255, 255, 0.5) 13px);
}

.sparkline.flat {
  background:
    linear-gradient(180deg, rgba(16, 185, 129, 0.18), rgba(16, 185, 129, 0.03)),
    repeating-linear-gradient(to right, transparent, transparent 12px, rgba(255, 255, 255, 0.5) 12px, rgba(255, 255, 255, 0.5) 13px);
}

.keywords-panel {
  margin-top: 0.62rem;
}

.panel-head {
  margin-bottom: 0.45rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.panel h2 {
  margin: 0;
  font-size: 0.86rem;
}

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

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 0.46rem 0.32rem;
  border-bottom: 1px solid #f1f5f9;
  text-align: left;
  font-size: 0.7rem;
  white-space: nowrap;
}

th {
  color: #94a3b8;
  font-weight: 700;
  font-size: 0.62rem;
}

.up { color: #16a34a; font-weight: 700; }
.down { color: #ef4444; font-weight: 700; }
.flat { color: #64748b; }

.insight-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.62rem;
  margin-top: 0.62rem;
}

.chart-line {
  height: 170px;
  border-radius: 0.5rem;
  border: 1px solid #edf2f7;
  background:
    linear-gradient(180deg, rgba(59, 130, 246, 0.2), rgba(59, 130, 246, 0.02)),
    repeating-linear-gradient(to right, #e2e8f0 0 1px, transparent 1px 34px),
    repeating-linear-gradient(to bottom, #e2e8f0 0 1px, transparent 1px 26px);
}

.donut-wrap {
  display: flex;
  align-items: center;
  gap: 0.8rem;
}

.donut {
  width: 116px;
  height: 116px;
  border-radius: 50%;
  background: conic-gradient(#22c55e 0 36%, #3b82f6 36% 82%, #ef4444 82% 100%);
  position: relative;
}

.donut::after {
  content: "";
  position: absolute;
  inset: 20px;
  border-radius: 50%;
  background: #ffffff;
}

.donut-wrap ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.36rem;
  font-size: 0.72rem;
  color: #334155;
}

.dot {
  width: 0.56rem;
  height: 0.56rem;
  border-radius: 999px;
  display: inline-block;
  margin-right: 0.33rem;
}

.dot.green { background: #22c55e; }
.dot.blue { background: #3b82f6; }
.dot.red { background: #ef4444; }

.list {
  list-style: none;
  margin: 0.55rem 0 0;
  padding: 0;
  display: grid;
  gap: 0.42rem;
}

.list li {
  padding-bottom: 0.42rem;
  border-bottom: 1px solid #f1f5f9;
}

.list strong {
  font-size: 0.7rem;
}

.list span {
  display: block;
  margin-top: 0.1rem;
  color: #94a3b8;
  font-size: 0.64rem;
}

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

  .app-sidebar {
    border-right: 0;
    border-bottom: 1px solid #edf2f7;
  }

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

@media (max-width: 760px) {
  .app-topbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .topbar-actions {
    flex-wrap: wrap;
  }

  .app-chip-row {
    width: 100%;
  }

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