@import url("https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700;800&display=swap");

:root {
  --bg: #f4f5f9;
  --sidebar: #ffffff;
  --ink: #2c2e33;
  --muted: #8a8d98;
  --line: #e7e8ee;
  --accent: #7b5cff;
  --accent-2: #b06bff;
  --danger: #e74c6f;
  --ok: #1bcfb4;
  --card: #ffffff;
  --shadow: 0 8px 24px rgba(56, 51, 84, 0.08);
  --font: "Nunito", "Segoe UI", sans-serif;
  --mono: "Cascadia Mono", Consolas, monospace;
  --sidebar-w: 250px;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body.app-body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
}

.layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--sidebar);
  border-right: 1px solid var(--line);
  padding: 22px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
}
.brand-block {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px 20px;
}
.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: block;
  flex-shrink: 0;
  object-fit: cover;
}
.brand-name {
  font-weight: 800;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
}
.brand-sub {
  color: var(--muted);
  font-size: 0.75rem;
}

.side-user {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 12px;
  border-radius: 14px;
  background: #f7f6ff;
  margin-bottom: 18px;
}
.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #ffbf96, #fe7096);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 700;
}
.side-user strong { display: block; font-size: 0.92rem; }
.side-user span { color: var(--muted); font-size: 0.78rem; }

.side-nav {
  display: grid;
  gap: 4px;
}
.side-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: #5a5d68;
  padding: 11px 12px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 0.92rem;
}
.side-nav a:hover { background: #f3f1ff; color: var(--accent); }
.side-nav a.active {
  background: linear-gradient(90deg, rgba(123,92,255,.12), transparent);
  color: var(--accent);
}
.nav-ico {
  width: 18px;
  text-align: center;
  opacity: 0.85;
}

.main {
  padding: 18px 22px 40px;
  min-width: 0;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 18px;
}
.topbar h1 {
  margin: 0;
  font-size: 1.45rem;
  font-weight: 800;
}
.topbar .muted { color: var(--muted); font-size: 0.88rem; margin-top: 2px; }
.top-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.flash {
  padding: 12px 14px;
  border-radius: 12px;
  margin: 0 0 14px;
  font-weight: 600;
}
.flash.running { background: #fff6e8; color: #a05a00; border: 1px solid #ffe0ad; }
.flash.ok { background: #e8fbf6; color: #0f8f7a; border: 1px solid #b8f0e3; }
.flash.error { background: #ffe9ef; color: var(--danger); border: 1px solid #ffc2d0; }

.metric-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 16px;
}
.metric-card {
  border-radius: 16px;
  padding: 18px 18px 16px;
  color: #fff;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
  min-height: 118px;
}
.metric-card::after {
  content: "";
  position: absolute;
  right: -20px;
  bottom: -30px;
  width: 110px;
  height: 110px;
  border-radius: 50%;
  background: rgba(255,255,255,.12);
}
.metric-card.g1 { background: linear-gradient(135deg, #ffbf96, #fe7096); }
.metric-card.g2 { background: linear-gradient(135deg, #90caf9, #047edf 99%); }
.metric-card.g3 { background: linear-gradient(135deg, #84d9d2, #07cdae); }
.metric-card.g4 { background: linear-gradient(135deg, #b6a4ff, #7b5cff); }
.metric-card.g5 { background: linear-gradient(135deg, #f6e384, #f2a654); }
.metric-card.g6 { background: linear-gradient(135deg, #f8a5c2, #e84393); }
.metric-card span {
  display: block;
  opacity: 0.92;
  font-size: 0.86rem;
  font-weight: 600;
}
.metric-card strong {
  display: block;
  margin-top: 8px;
  font-size: 1.8rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}
.metric-card small {
  display: block;
  margin-top: 8px;
  opacity: 0.9;
  font-size: 0.8rem;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}
.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 16px;
}

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 18px;
  margin-bottom: 16px;
}
.panel h2 {
  margin: 0 0 14px;
  font-size: 1.05rem;
  font-weight: 800;
}
.panel h2 small { color: var(--muted); font-weight: 600; }
.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.panel-head h2 { margin: 0; }

.chart-wrap {
  position: relative;
  height: 280px;
}
.chart-wrap.sm { height: 220px; }

.hint { color: var(--muted); font-size: 0.9rem; }

label {
  display: grid;
  gap: 6px;
  font-size: 0.86rem;
  color: var(--muted);
  font-weight: 600;
}
input[type="text"], input[type="password"], input[type="number"], input[type="date"], select {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  font: inherit;
  color: var(--ink);
  background: #fff;
  min-width: 160px;
}
button, .button-link {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 10px;
  padding: 10px 14px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}
button.primary, .button-link.primary {
  background: linear-gradient(90deg, #7b5cff, #b06bff);
  color: #fff;
  border-color: transparent;
}
button.ghost { background: transparent; }
button.danger { color: var(--danger); }

.add-form, .inline, .row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: end;
  margin-bottom: 14px;
}
.stack-form {
  display: grid;
  gap: 12px;
  max-width: 520px;
}
.stack-form input { width: 100%; min-width: 0; }
.check {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 22px;
}

.table-wrap { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}
th, td {
  text-align: left;
  padding: 11px 8px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
th { color: var(--muted); font-weight: 700; }
.mono { font-family: var(--mono); font-size: 0.8rem; color: var(--muted); }
.meta { color: var(--muted); font-size: 0.8rem; margin-top: 4px; }
.err-cell {
  max-width: 360px;
  white-space: pre-wrap;
  word-break: break-word;
  color: #8a2a3d;
  font-size: 0.85rem;
}
.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid var(--line);
  font-size: 0.75rem;
  font-weight: 700;
  background: #fff;
}
.badge.ok { background: #e8fbf6; color: #0f8f7a; border-color: #b8f0e3; }
.badge.bad { background: #ffe9ef; color: var(--danger); border-color: #ffc2d0; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
}
.post-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  background: #fff;
}
.post-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}
.post-card a { color: var(--accent); font-weight: 700; }

.list-rank {
  display: grid;
  gap: 10px;
}
.list-rank .item {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  background: #f7f8fc;
  font-weight: 600;
}
.list-rank .item span { color: var(--muted); }

.health-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 6px;
  background: #1bcfb4;
}
.health-dot.bad { background: #e74c6f; }
.health-dot.off { background: #c5c7d0; }

.auth-body {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 24px;
  background:
    radial-gradient(900px 400px at 10% 0%, #efe8ff, transparent 55%),
    radial-gradient(700px 300px at 90% 10%, #ffe6f0, transparent 50%),
    var(--bg);
  font-family: var(--font);
}
.auth-card {
  width: min(420px, 100%);
  padding: 28px;
  background: #fff;
  border-radius: 18px;
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
}
.auth-brand { margin-bottom: 8px; }
.auth-brand img { display: block; }
.brand-tag {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.8rem;
}
.auth-card h1 { margin: 8px 0 16px; }
.auth-card form { display: grid; gap: 14px; }

@media (max-width: 1100px) {
  .metric-grid, .grid-2, .grid-3 { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar {
    position: relative;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .side-nav { grid-template-columns: repeat(3, 1fr); }
  input[type="text"], input[type="password"], input[type="number"], input[type="date"], select {
    min-width: 0;
    width: 100%;
  }
}
