﻿:root {
  --bg: #eef4f1;
  --surface: #ffffff;
  --surface-soft: #f4f8f6;
  --ink: #1b2723;
  --muted: #5d6d67;
  --brand: #1f6f52;
  --brand-soft: #daf0e6;
  --accent: #ba5d2a;
  --ok: #1f8b4c;
  --warn: #c18a05;
  --line: #d8e4de;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(21, 45, 36, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Manrope", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 10% 20%, #dfeee7 0%, transparent 35%),
    radial-gradient(circle at 85% 10%, #f4e3d8 0%, transparent 30%),
    var(--bg);
}

h1,
h2,
p {
  margin: 0;
}

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

.sidebar {
  background: linear-gradient(160deg, #10352a 0%, #1f6f52 100%);
  color: #ecf7f2;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  border-right: 1px solid rgba(255, 255, 255, 0.2);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0.4rem;
}

.brand-mark {
  height: 44px;
  width: 44px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.16);
  display: grid;
  place-items: center;
  font-weight: 800;
}

.brand-title {
  font-family: "DM Serif Display", serif;
  font-size: 1.15rem;
}

.brand-subtitle {
  font-size: 0.78rem;
  opacity: 0.86;
}

.menu {
  display: grid;
  gap: 0.45rem;
}

.menu-item {
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: #e5f3ed;
  text-align: left;
  padding: 0.72rem 0.85rem;
  font-weight: 600;
  cursor: pointer;
}

.menu-item:hover,
.menu-item.active {
  background: rgba(255, 255, 255, 0.14);
}

.sidebar-foot {
  margin-top: auto;
  font-size: 0.85rem;
  opacity: 0.9;
}

.main-area {
  padding: 1.2rem;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  margin-bottom: 1rem;
}

.topbar-left {
  display: flex;
  gap: 0.8rem;
  align-items: center;
}

#viewTitle {
  font-size: 1.6rem;
  font-family: "DM Serif Display", serif;
}

#viewSubtitle {
  color: var(--muted);
  font-size: 0.9rem;
}

.topbar-right {
  display: flex;
  gap: 0.7rem;
  align-items: center;
}

.icon-btn,
.primary-btn {
  border: 0;
  border-radius: 12px;
  padding: 0.62rem 0.85rem;
  font-weight: 700;
  cursor: pointer;
}

.icon-btn {
  background: var(--surface-soft);
}

.primary-btn {
  background: var(--brand);
  color: #fff;
}

.search-wrap {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.3rem 0.6rem;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  color: var(--muted);
}

.search-wrap input,
.toolbar input,
.toolbar select,
.settings-grid input,
.settings-grid select {
  border: 0;
  outline: none;
  background: transparent;
  font: inherit;
  color: inherit;
}

.content-view {
  display: none;
  animation: fade 0.24s ease;
}

.content-view.active {
  display: block;
}

@keyframes fade {
  from {
    opacity: 0;
    transform: translateY(5px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(170px, 1fr));
  gap: 0.8rem;
  margin-bottom: 0.8rem;
}

.kpi {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 0.85rem;
}

.kpi p {
  color: var(--muted);
  font-size: 0.85rem;
}

.kpi h3 {
  margin-top: 0.35rem;
  font-size: 1.45rem;
}

.two-col {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 0.8rem;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem;
  margin-top: 0.8rem;
}

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

.panel-head h2 {
  font-size: 1.02rem;
}

.badge {
  font-size: 0.72rem;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  color: var(--muted);
  border-radius: 999px;
  padding: 0.25rem 0.55rem;
  font-weight: 700;
}

.badge.warning {
  color: #8c5c00;
  background: #fff6de;
  border-color: #ffe1a0;
}

.badge.success {
  color: #0e6c39;
  background: #dbf4e5;
  border-color: #9ad8b4;
}

#dataSourceBadge[data-source="api"] {
  color: #0e6c39;
  background: #dbf4e5;
  border-color: #9ad8b4;
}

#dataSourceBadge[data-source="mixed"] {
  color: #8c5c00;
  background: #fff6de;
  border-color: #ffe1a0;
}

.sparkline {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  align-items: end;
  gap: 0.25rem;
  height: 170px;
}

.sparkline div {
  border-radius: 7px 7px 0 0;
  background: linear-gradient(180deg, #2f9b73, #1f6f52);
}

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

.list li,
.cards article {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-soft);
  padding: 0.72rem;
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 0.65rem;
}

.toolbar {
  display: flex;
  gap: 0.55rem;
  margin-bottom: 0.75rem;
}

.crud-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(140px, 1fr));
  gap: 0.45rem;
  margin-bottom: 0.75rem;
}

.crud-form input,
.crud-form select {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-soft);
  padding: 0.5rem 0.6rem;
  font: inherit;
}

.crud-form .primary-btn,
.crud-form .icon-btn {
  align-self: stretch;
}

.checkline {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.88rem;
}

.action-btn {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  padding: 0.3rem 0.45rem;
  font-size: 0.76rem;
  font-weight: 700;
  cursor: pointer;
}

.action-btn.delete {
  color: #9a2f2f;
  border-color: #e7b7b7;
  background: #fff5f5;
}

.toolbar input,
.toolbar select {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-soft);
  padding: 0.5rem 0.6rem;
}

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

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

th,
td {
  text-align: left;
  padding: 0.55rem;
  border-bottom: 1px solid var(--line);
  font-size: 0.9rem;
}

th {
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.split-grid {
  display: grid;
  grid-template-columns: 1fr 1.5fr;
  gap: 0.8rem;
}

.fund-row {
  margin-bottom: 0.8rem;
}

.fund-row .meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  margin-bottom: 0.24rem;
}

.bar {
  height: 10px;
  border-radius: 999px;
  background: #dcebe4;
  overflow: hidden;
}

.bar span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #2c916a, #57b888);
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(200px, 1fr));
  gap: 0.8rem;
}

.settings-grid label {
  display: grid;
  gap: 0.35rem;
  font-size: 0.9rem;
}

.settings-grid input,
.settings-grid select {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-soft);
  padding: 0.5rem 0.6rem;
}

.api-field {
  grid-column: 1 / -1;
}

.settings-actions {
  display: flex;
  gap: 0.5rem;
  align-items: end;
}

.muted-note {
  margin-top: 0.8rem;
  color: var(--muted);
  font-size: 0.85rem;
}

#menuToggle {
  display: none;
}

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

  .sidebar {
    position: fixed;
    left: -100%;
    top: 0;
    bottom: 0;
    z-index: 20;
    width: 260px;
    transition: left 0.24s ease;
  }

  .sidebar.show {
    left: 0;
  }

  .main-area {
    padding: 1rem;
  }

  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .topbar-right {
    width: 100%;
    flex-wrap: wrap;
  }

  .kpi-grid {
    grid-template-columns: repeat(2, minmax(120px, 1fr));
  }

  .two-col,
  .split-grid,
  .settings-grid,
  .crud-form {
    grid-template-columns: 1fr;
  }

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

  #menuToggle {
    display: inline-block;
  }
}
