:root {
  --brand: #1b365d;
  --brand-deep: #12253f;
  --brand-soft: #e3e8f2;
  --sidebar-bg: #1b365d;
  --sidebar-bg-deep: #1e3f6e;
  --sidebar-text: rgba(255, 255, 255, 0.92);
  --sidebar-text-dim: rgba(255, 255, 255, 0.6);
  --sidebar-active: rgba(255, 255, 255, 0.14);
  --ink: #1f2430;
  --muted: #6b7280;
  --bg: #f6f7f9;
  --card: #ffffff;
  --line: #e6e8ee;
  --accent: #1f8ea3;
  --accent-soft: #e1f4f6;
  --danger: #f97316;
  --success: #1f9d5d;
  --shadow: 0 18px 36px rgba(31, 36, 48, 0.08);
  --shadow-soft: 0 8px 20px rgba(31, 36, 48, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
    Arial, sans-serif;
  font-size: 12px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: none;
}

.app {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 248px 1fr;
  min-height: 100vh;
  transition: grid-template-columns 0.2s ease;
}

.app.sidebar-collapsed {
  grid-template-columns: 0 1fr;
}

.app.sidebar-collapsed .sidebar {
  width: 0;
  min-width: 0;
  padding: 0;
  border: 0;
  opacity: 0;
}

.sidebar-overlay {
  display: none;
}

.sidebar {
  background: linear-gradient(180deg, var(--sidebar-bg) 0%, var(--sidebar-bg-deep) 100%);
  border-right: 1px solid var(--sidebar-bg);
  padding: 18px 14px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow: hidden;
  overflow-y: auto;
  white-space: nowrap;
  transition: transform 0.2s ease, width 0.2s ease, padding 0.2s ease, opacity 0.15s ease;
}

.sidebar small {
  color: var(--sidebar-text-dim) !important;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  font-weight: 600;
  font-size: 13.5px;
  color: #ffffff;
}

.brand-mark {
  width: 44px;
  height: 44px;
  min-width: 44px;
  border-radius: 13px;
  background: var(--brand);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  box-shadow: var(--shadow-soft);
}

.brand-mark span {
  font-weight: 800;
  font-size: 13px;
  line-height: 1;
  color: #ffffff;
}

.sidebar-toggle {
  width: 32px;
  height: 32px;
  min-width: 32px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: #ffffff;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  cursor: pointer;
}

.sidebar-toggle:hover {
  border-color: var(--brand);
  background: var(--brand-soft);
}

.sidebar-toggle span {
  width: 14px;
  height: 2px;
  border-radius: 2px;
  background: var(--ink);
}

.nav-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--sidebar-text-dim);
  margin: 0 0 4px 10px;
}

.nav-link {
  padding: 7px 10px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--sidebar-text);
  transition: all 0.2s ease;
}

.nav-link:hover,
.nav-link.active {
  background: var(--sidebar-active);
  color: #ffffff;
}

.nav-badge {
  margin-left: auto;
  font-size: 10.5px;
  padding: 3px 8px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.16);
  color: #ffffff;
}

.content {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  justify-content: space-between;
  padding: 16px 28px;
  background: rgba(255, 255, 255, 0.86);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 2;
  flex-wrap: wrap;
}

.topbar h1 {
  margin: 0;
  font-size: 16.5px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-left: auto;
}

.session-info {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.community-switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding-right: 10px;
  margin-right: 4px;
  border-right: 1px solid var(--line);
}

.community-label {
  font-size: 11px;
  color: var(--muted);
}

.community-name {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--ink);
}

.timer-label {
  font-size: 11px;
  color: var(--muted);
}

.timer-badge {
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand-deep);
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 0.04em;
}

.btn {
  padding: 8px 14px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--ink);
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s ease;
  cursor: pointer;
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-soft);
}

.btn-primary {
  background: var(--brand);
  border-color: var(--brand);
  color: #ffffff;
}

.btn-outline {
  border-color: var(--brand);
  color: #1f1f1f;
}

.main {
  padding: 24px 32px 44px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  min-width: 0;
}

.hero {
  background: var(--card);
  border-radius: 18px;
  padding: 24px;
  box-shadow: var(--shadow);
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 24px;
  align-items: center;
}

.hero h2 {
  margin: 0 0 8px 0;
  font-size: 19px;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.hero p {
  margin: 0;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.55;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.stat-card {
  background: #ffffff;
  border-radius: 14px;
  padding: 16px;
  box-shadow: var(--shadow-soft);
}

.stat-card h3 {
  margin: 0 0 8px 0;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 700;
  color: var(--muted);
}

.stat-value {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.card {
  background: var(--card);
  border-radius: 16px;
  padding: 16px;
  box-shadow: var(--shadow-soft);
  border: 1px solid transparent;
  transition: all 0.2s ease;
}

.card:hover {
  border-color: var(--brand);
  transform: translateY(-2px);
}

.card h4 {
  margin: 0 0 6px 0;
  font-size: 13.5px;
  font-weight: 600;
}

.card p {
  margin: 0;
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.5;
}

.list-group {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.module-list {
  background: var(--card);
  border-radius: 16px;
  padding: 18px;
  box-shadow: var(--shadow-soft);
}

.module-list h3 {
  margin: 0 0 12px 0;
  font-size: 13.5px;
  font-weight: 600;
}

.module-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
  color: var(--ink);
}

.module-item:last-child {
  border-bottom: none;
}

.dot {
  width: 6px;
  height: 6px;
  min-width: 6px;
  border-radius: 50%;
  background: var(--brand);
}

.section {
  background: var(--card);
  border-radius: 18px;
  padding: 20px 22px;
  box-shadow: var(--shadow);
  min-width: 0;
}

.section h2 {
  margin: 0 0 14px 0;
  font-size: 14.5px;
  font-weight: 600;
  letter-spacing: -0.005em;
}

.table {
  width: 100%;
  border-collapse: collapse;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--line);
}

.table th,
.table td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-size: 11.5px;
}

.table th {
  background: #f6f7fb;
  color: var(--muted);
  font-weight: 600;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.table tr:last-child td {
  border-bottom: none;
}

.badge {
  display: inline-flex;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 600;
  background: var(--brand-soft);
}

.badge.success {
  background: rgba(31, 157, 93, 0.12);
  color: var(--success);
}

.badge.warning {
  background: rgba(249, 115, 22, 0.12);
  color: var(--danger);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-field label {
  font-size: 11px;
  color: var(--muted);
}

input,
select,
textarea {
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  font-family: inherit;
  font-size: 13px;
  background: #ffffff;
}

textarea {
  min-height: 110px;
  resize: vertical;
}

input[type="file"] {
  padding: 8px 12px;
  cursor: pointer;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(18, 23, 32, 0.55);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 1000;
}

.modal-overlay.open {
  display: flex;
}

.modal {
  background: var(--card);
  border-radius: 20px;
  box-shadow: var(--shadow);
  width: 100%;
  max-width: 640px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  padding: 20px 24px;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  background: var(--card);
}

.modal-header h3 {
  margin: 0 0 4px 0;
}

.modal-header p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.modal-close {
  border: none;
  background: transparent;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  color: var(--muted);
  padding: 4px;
}

.modal-body {
  padding: 20px 24px 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.modal-body .stat-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.modal-body .stat-card.accent-success .stat-value {
  color: var(--success);
}

.modal-body .stat-card.accent-danger .stat-value {
  color: var(--danger);
}

.modal-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 20px;
  font-size: 13px;
}

.modal-meta div span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 2px;
}

@media (max-width: 640px) {
  .modal-body .stat-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .modal-meta {
    grid-template-columns: 1fr;
  }
}

.form-actions {
  display: flex;
  gap: 12px;
  margin-top: 16px;
}

.notice {
  padding: 12px 14px;
  border-radius: 12px;
  background: #fdf6e3;
  border: 1px solid #f0dfa8;
  color: #7a5c00;
  font-size: 11.5px;
  line-height: 1.5;
}

.split {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 18px;
}

.kpi {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.kpi.kpi-compact {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.kpi.kpi-compact .kpi-card {
  padding: 18px 18px;
  border-radius: 16px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow-soft);
}

.kpi.kpi-compact .kpi-card span {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 700;
  color: #63708a;
}

.kpi.kpi-compact .kpi-card strong {
  font-size: 17px;
  letter-spacing: -0.01em;
}

.kpi-card.kpi-hero {
  position: relative;
  overflow: hidden;
}

.kpi-card.kpi-hero::before {
  content: "";
  position: absolute;
  inset: 0;
  border-left: 4px solid var(--brand);
}

.kpi-card.kpi-hero .kpi-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-size: 18px;
  color: #ffffff;
  margin-left: auto;
}

.kpi-card.kpi-hero .kpi-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.kpi-card.kpi-hero .kpi-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 600;
}

.kpi-card.kpi-hero.kpi-blue::before {
  border-left-color: #4F46E5;
}

.kpi-card.kpi-hero.kpi-blue .kpi-icon {
  background: #4F46E5;
}

.kpi-card.kpi-hero.kpi-blue .kpi-tag {
  background: rgba(79, 70, 229, 0.12);
  color: #4F46E5;
}

.kpi-card.kpi-hero.kpi-cyan::before {
  border-left-color: #06B6D4;
}

.kpi-card.kpi-hero.kpi-cyan .kpi-icon {
  background: #06B6D4;
}

.kpi-card.kpi-hero.kpi-cyan .kpi-tag {
  background: rgba(6, 182, 212, 0.12);
  color: #06B6D4;
}

.kpi-card.kpi-hero.kpi-amber::before {
  border-left-color: #F59E0B;
}

.kpi-card.kpi-hero.kpi-amber .kpi-icon {
  background: #F59E0B;
}

.kpi-card.kpi-hero.kpi-amber .kpi-tag {
  background: rgba(245, 158, 11, 0.15);
  color: #B45309;
}

.kpi-card.kpi-hero.kpi-green::before {
  border-left-color: #10B981;
}

.kpi-card.kpi-hero.kpi-green .kpi-icon {
  background: #10B981;
}

.kpi-card.kpi-hero.kpi-green .kpi-tag {
  background: rgba(16, 185, 129, 0.14);
  color: #047857;
}

.kpi-card {
  padding: 14px;
  border-radius: 16px;
  background: #ffffff;
  border: 1px solid var(--line);
}

.kpi-card span {
  color: var(--muted);
  font-size: 11px;
}

.kpi-card strong {
  display: block;
  margin-top: 6px;
  font-size: 16.5px;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 18px;
}

.carousel {
  position: relative;
  width: 100%;
  max-width: 100%;
  overflow: hidden;
}

.carousel-track {
  display: flex;
  gap: 18px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  padding: 4px 46px 8px;
  align-items: stretch;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.carousel-track::-webkit-scrollbar {
  height: 8px;
}

.carousel-track::-webkit-scrollbar-thumb {
  background: rgba(1, 134, 191, 0.3);
  border-radius: 999px;
}

.carousel-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: #ffffff;
  box-shadow: var(--shadow-soft);
  cursor: pointer;
  display: grid;
  place-items: center;
  color: var(--ink);
  font-size: 18px;
  z-index: 1;
}

.carousel-btn.prev {
  left: 6px;
}

.carousel-btn.next {
  right: 6px;
}

.gallery-card {
  background: #ffffff;
  border-radius: 18px;
  padding: 14px;
  box-shadow: var(--shadow-soft);
  border: 1px solid var(--line);
  flex: 0 0 clamp(220px, 24vw, 320px);
  max-width: 320px;
  scroll-snap-align: start;
}

.gallery-card img {
  width: 100%;
  border-radius: 14px;
  display: block;
}

.gallery-card h4 {
  margin: 12px 0 6px 0;
  font-size: 14px;
}

.gallery-card p {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
}

.embed-wrap {
  display: flex;
  justify-content: center;
  width: 100%;
}

.embed-frame {
  width: min(1100px, 100%);
  height: 1600px;
  border: 0;
  border-radius: 18px;
  box-shadow: var(--shadow-soft);
  background: #ffffff;
}

.chart-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}

.chart-card {
  background: #ffffff;
  border-radius: 16px;
  border: 1px solid var(--line);
  padding: 16px;
  box-shadow: var(--shadow-soft);
}

.chart-card h4 {
  margin: 0 0 12px 0;
  font-size: 13px;
}

.chart-placeholder {
  height: 180px;
  border-radius: 12px;
  border: 1px dashed var(--line);
  background: linear-gradient(135deg, #f8fbfd 0%, #eef5f8 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 11px;
}

.chart-canvas {
  height: 260px;
  position: relative;
}

.chart-canvas--square {
  height: auto;
  aspect-ratio: 1 / 1;
  max-width: 280px;
  margin: 0 auto;
}

.chart-canvas canvas {
  width: 100% !important;
  height: 100% !important;
}

.narrow-container {
  width: min(1100px, 100%);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.stagger > * {
  opacity: 0;
  transform: translateY(12px);
  animation: floatIn 0.5s ease forwards;
  animation-delay: calc(var(--i) * 0.08s);
}

@keyframes floatIn {
  from {
    opacity: 0;
    transform: translateY(18px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 1100px) {
  .hero {
    grid-template-columns: 1fr;
  }

  .card-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .list-group {
    grid-template-columns: 1fr;
  }

  .kpi.kpi-compact {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 900px) {
  .app {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 248px;
    z-index: 30;
    transform: translateX(-280px);
    box-shadow: var(--shadow);
    visibility: hidden;
    transition: transform 0.2s ease, visibility 0s linear 0.2s;
  }

  .app.sidebar-open .sidebar {
    transform: translateX(0);
    visibility: visible;
    transition: transform 0.2s ease, visibility 0s linear 0s;
  }

  .app.sidebar-collapsed {
    grid-template-columns: 1fr;
  }

  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 20, 30, 0.45);
    z-index: 20;
  }

  .app.sidebar-open .sidebar-overlay {
    display: block;
  }

  .topbar {
    padding: 14px 18px;
  }

  .main {
    padding: 18px 16px 36px;
  }
}

@media (max-width: 720px) {
  .topbar {
    padding: 14px 16px;
  }

  .top-actions {
    width: 100%;
  }

  .session-info {
    width: 100%;
    flex-wrap: wrap;
    justify-content: flex-start;
  }

  .stat-grid,
  .card-grid,
  .form-grid,
  .split,
  .kpi,
  .kpi.kpi-compact,
  .chart-grid {
    grid-template-columns: 1fr;
  }

  .hero {
    padding: 20px;
  }
}
