﻿:root {
  --bg: #f4f7fb;
  --card: #ffffff;
  --text: #06122b;
  --muted: #5d6b85;
  --line: #e5ecf5;
  --blue: #2563eb;
  --green: #16a34a;
  --purple: #7c3aed;
  --red: #ef4444;
  --orange: #f59e0b;
  --dark: #061424;
  --dark2: #0b2330;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Arial, "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
}

.app-shell {
  display: flex;
  min-height: 100vh;
  background: var(--bg);
}

/* Sidebar */
.sidebar {
  width: 260px;
  min-width: 260px;
  background: linear-gradient(180deg, #17204a 0%, #07111f 100%);
  color: #eaf2ff;
  padding: 24px 18px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 30px;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 12px;
  background: linear-gradient(135deg, #7c3aed, #06b6d4);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
}

.brand strong {
  display: block;
  font-size: 18px;
  color: #ffffff;
}

.brand small {
  display: block;
  margin-top: 3px;
  font-size: 12px;
  color: #9fb2cf;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.nav-group-title {
  margin: 16px 8px 6px;
  font-size: 12px;
  color: #91a4c3;
  font-weight: 700;
}

.nav a {
  color: #dbeafe;
  text-decoration: none;
  padding: 11px 12px;
  border-radius: 12px;
  font-size: 15px;
}

.nav a:hover,
.nav a.active {
  background: #2563eb;
  color: #fff;
}

/* Main */
.main {
  flex: 1;
  padding: 28px 34px 40px;
  background: var(--bg);
  min-width: 0;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  margin-bottom: 24px;
}

.topbar h1 {
  margin: 0;
  font-size: 34px;
  font-weight: 900;
  color: var(--text);
}

.topbar p {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 15px;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 14px;
  white-space: nowrap;
}

.top-actions button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  padding: 9px 14px;
  border-radius: 10px;
  cursor: pointer;
}

/* Stats */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 22px;
}

.stat-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 18px 20px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.06);
}

.stat-card span {
  display: block;
  font-size: 13px;
  color: var(--muted);
  font-weight: 700;
}

.stat-card strong {
  display: block;
  font-size: 32px;
  margin: 8px 0;
  font-weight: 900;
}

.stat-card small {
  color: var(--muted);
}

.stat-card.blue strong { color: var(--blue); }
.stat-card.green strong { color: var(--green); }
.stat-card.purple strong { color: var(--purple); }
.stat-card.red strong { color: var(--red); }

/* Panels */
.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 22px;
  margin-bottom: 22px;
  box-shadow: 0 12px 34px rgba(15, 23, 42, 0.06);
}

.panel-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
}

.panel-title h2 {
  margin: 0;
  font-size: 22px;
  font-weight: 900;
}

.panel-title span {
  color: var(--muted);
  font-size: 14px;
}

/* Country cards */
.country-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}

.country-card {
  display: flex !important;
  align-items: center !important;
  gap: 16px !important;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 16px;
  min-height: 96px;
  overflow: hidden;
}

.country-icon {
  width: 70px !important;
  min-width: 70px !important;
  height: 56px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  overflow: hidden !important;
}

.region-flag,
.country-card img {
  width: 64px !important;
  height: 44px !important;
  max-width: 64px !important;
  max-height: 44px !important;
  object-fit: cover !important;
  border-radius: 10px !important;
  display: block !important;
  flex-shrink: 0 !important;
}

.region-int,
.region-fallback {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  background: linear-gradient(135deg, #2563eb, #7c3aed);
  color: #fff;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
}

.country-info {
  min-width: 0;
  writing-mode: horizontal-tb !important;
}

.country-info strong {
  display: block;
  font-size: 18px;
  font-weight: 900;
  white-space: nowrap;
}

.country-info span {
  display: block;
  margin-top: 5px;
  color: var(--muted);
}

.country-info small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
}

/* Platform cards */
.platform-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}

.platform-card {
  display: flex !important;
  align-items: center !important;
  gap: 16px !important;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 16px;
  min-height: 96px;
  overflow: hidden;
}

.platform-logo-wrap {
  width: 70px;
  min-width: 70px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.platform-logo-img,
.platform-card img {
  width: 56px !important;
  height: 56px !important;
  max-width: 56px !important;
  max-height: 56px !important;
  object-fit: contain !important;
  border-radius: 14px;
  display: block !important;
}

.platform-fallback {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  background: #e2e8f0;
  color: #0f172a;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
}

.platform-info {
  min-width: 0;
  writing-mode: horizontal-tb !important;
}

.platform-info strong {
  display: block;
  font-size: 18px;
  font-weight: 900;
  white-space: nowrap;
}

.platform-info span {
  display: block;
  margin-top: 5px;
  color: var(--muted);
}

.platform-info small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
}

/* Bottom panels */
.dashboard-bottom {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 22px;
}

.trend-bars {
  height: 220px;
  display: flex;
  align-items: end;
  gap: 18px;
  padding: 20px;
  border-radius: 16px;
  background: #f8fafc;
}

.trend-bar {
  flex: 1;
  min-height: 30px;
  border-radius: 12px 12px 0 0;
  background: linear-gradient(180deg, #2563eb, #7c3aed);
  position: relative;
}

.trend-bar span {
  position: absolute;
  bottom: -24px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 12px;
  color: var(--muted);
}

.todo-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.todo-list li {
  display: flex;
  justify-content: space-between;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
}

.todo-list strong {
  color: var(--text);
}

/* Toolbar and table */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 16px;
  margin-bottom: 18px;
}

input,
select {
  border: 1px solid #cfd8e3;
  background: #fff;
  border-radius: 12px;
  padding: 10px 12px;
  min-width: 180px;
}

.table-wrap {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  overflow: hidden;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th {
  background: #f8fafc;
  text-align: left;
  color: #334155;
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

td {
  padding: 13px 14px;
  border-bottom: 1px solid #edf2f7;
}

tr:hover td {
  background: #f8fbff;
}

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 800;
}

.badge.ok {
  background: #dcfce7;
  color: #15803d;
}

.badge.wait {
  background: #f1f5f9;
  color: #475569;
}

.badge.warn {
  background: #ffedd5;
  color: #c2410c;
}

.badge.bad {
  background: #fee2e2;
  color: #dc2626;
}

.table-footer {
  padding: 14px;
  color: var(--muted);
  font-size: 13px;
}

.error-box {
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fecaca;
  padding: 18px;
  border-radius: 14px;
}

/* Responsive */
@media (max-width: 1280px) {
  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

  .dashboard-bottom {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .app-shell {
    display: block;
  }

  .sidebar {
    position: relative;
    width: 100%;
    height: auto;
  }

  .main {
    padding: 20px;
  }

  .stats-grid,
  .country-grid,
  .platform-grid {
    grid-template-columns: 1fr;
  }

  .topbar {
    display: block;
  }

  .top-actions {
    margin-top: 16px;
  }
}

/* ===== BunnyEra brand logo ===== */
.brand-logo {
  width: 46px !important;
  height: 46px !important;
  border-radius: 15px !important;
  object-fit: cover !important;
  display: block !important;
  box-shadow: 0 0 18px rgba(25, 211, 255, 0.35);
}

/* ===== FIX: brand logo size must not stretch sidebar ===== */
.brand {
  display: flex !important;
  align-items: center !important;
  gap: 12px !important;
  margin-bottom: 30px !important;
}

.brand img,
.brand-logo {
  width: 46px !important;
  height: 46px !important;
  min-width: 46px !important;
  max-width: 46px !important;
  min-height: 46px !important;
  max-height: 46px !important;
  object-fit: cover !important;
  border-radius: 14px !important;
  display: block !important;
  flex: 0 0 46px !important;
  box-shadow: 0 0 18px rgba(25, 211, 255, 0.35) !important;
}

.sidebar img {
  max-width: 46px !important;
}

.brand > div {
  min-width: 0 !important;
}

.brand strong {
  white-space: nowrap !important;
}
