/* ==========================================================================
   Game ID — Layout & Components
   Fluent 2 design language. All tokens sourced from theme.css.
   Matches Figma file 00QEeirxnqT4Zg829aeDVZ
   ========================================================================== */

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  color: var(--fg-primary);
  background: var(--bg-canvas);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ---- App shell ----------------------------------------------------------- */
.app {
  display: flex;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}

/* ---- Sidebar ------------------------------------------------------------- */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-layer);
  border-right: 1px solid var(--stroke-divider);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  z-index: 10;
}

.sidebar-brand {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  padding: 0 20px;
  border-bottom: 1px solid var(--stroke-divider);
  gap: 10px;
}

.sidebar-brand .logo {
  width: 24px; height: 24px;
  border-radius: var(--r-sm);
  background: var(--brand-rest);
  display: flex; align-items: center; justify-content: center;
}

.sidebar-brand .logo svg {
  width: 14px; height: 14px;
  fill: none;
  stroke: #fff;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sidebar-brand .name {
  font-size: 14px;
  font-weight: 600;
  color: var(--fg-primary);
  letter-spacing: -0.01em;
}

/* ---- Nav ----------------------------------------------------------------- */
.nav {
  flex: 1;
  padding: 8px 10px;
  overflow-y: auto;
}

.nav-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--fg-quaternary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 4px 12px 8px;
}

.nav-divider {
  height: 1px;
  background: var(--stroke-divider);
  margin: 8px 12px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 12px;
  margin-bottom: 2px;
  color: var(--fg-secondary);
  text-decoration: none;
  border-radius: var(--r-md);
  transition: all var(--t-fast) var(--ease-standard);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border-left: 3px solid transparent;
  margin-left: -3px;
}

.nav-link:hover {
  background: var(--bg-nav-hover);
  color: var(--fg-primary);
}

.nav-link.active {
  background: var(--bg-nav-hover);
  color: var(--fg-primary);
  font-weight: 600;
  border-left-color: var(--brand-rest);
}

.nav-icon {
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--fg-tertiary);
}

.nav-item.active .nav-icon {
  color: var(--fg-primary);
}

.nav-icon svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.nav-count {
  margin-left: auto;
  font-size: 11px;
  font-weight: 600;
  color: var(--fg-tertiary);
  background: var(--bg-subtle);
  padding: 1px 8px;
  border-radius: var(--r-circular);
  min-width: 24px;
  text-align: center;
}

.nav-item.active .nav-count {
  color: var(--fg-secondary);
}

/* ---- Main area ----------------------------------------------------------- */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

/* ---- Top Bar ------------------------------------------------------------- */
.topbar {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--page-gutter);
  background: var(--bg-layer);
  border-bottom: 1px solid var(--stroke-divider);
  flex-shrink: 0;
}

.breadcrumb {
  font-size: 14px;
  font-weight: 600;
  color: var(--fg-primary);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.sync-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--fg-tertiary);
}

.sync-dot {
  width: 6px;
  height: 6px;
  border-radius: var(--r-circular);
  background: var(--status-success-fg);
}

.sync-btn {
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 600;
  color: var(--brand-rest);
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--r-sm);
  transition: background var(--t-fast);
}

.sync-btn:hover {
  background: rgba(15,108,189,0.08);
}

.topbar-search {
  width: 320px;
  position: relative;
}

.topbar-search input {
  width: 100%;
  height: 36px;
  padding: 0 12px 0 36px;
  font-family: var(--font-sans);
  font-size: 13px;
  color: var(--fg-primary);
  background: var(--bg-subtle);
  border: 1px solid var(--stroke-divider);
  border-radius: var(--r-md);
  outline: none;
  transition: border-color var(--t-fast);
}

.topbar-search input:focus {
  border-color: var(--brand-rest);
}

.topbar-search input::placeholder { color: var(--fg-quaternary); }

.topbar-search::before {
  content: "";
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 14px;
  height: 14px;
  border: 1.5px solid var(--fg-quaternary);
  border-radius: var(--r-circular);
  pointer-events: none;
}

.topbar-search::after {
  content: "";
  position: absolute;
  left: 22px;
  top: calc(50% - 3px);
  width: 5px;
  height: 5px;
  border-right: 1.5px solid var(--fg-quaternary);
  border-top: 1.5px solid var(--fg-quaternary);
  transform: rotate(45deg);
  pointer-events: none;
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--r-circular);
  background: var(--brand-rest);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}

/* ---- Content ------------------------------------------------------------- */
.content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  background: var(--bg-canvas);
}

.page {
  max-width: var(--page-max);
  margin: 0 auto;
  padding: var(--page-gutter);
  padding-bottom: 64px;
}

.page-header {
  margin-bottom: 20px;
}

.page-title {
  font-size: 20px;
  font-weight: 600;
  color: var(--fg-primary);
  letter-spacing: -0.01em;
}

.page-subtitle {
  font-size: 13px;
  color: var(--fg-tertiary);
  margin-top: 2px;
}

/* ---- Loading ------------------------------------------------------------- */
.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 60vh;
  gap: 16px;
  color: var(--fg-tertiary);
  font-size: 14px;
}

.spinner {
  width: 32px; height: 32px;
  border: 2.5px solid var(--stroke-subtle);
  border-top-color: var(--brand-rest);
  border-radius: var(--r-circular);
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Filter bar (horizontal chips) --------------------------------------- */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
}

.chip-select {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 600;
  color: var(--fg-primary);
  background: var(--bg-chip);
  border: 1px solid var(--stroke-divider);
  border-radius: var(--r-circular);
  cursor: pointer;
  transition: all var(--t-fast) var(--ease-standard);
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 10 10' fill='none'%3E%3Cpath d='M2 4l3 3 3-3' stroke='%23949494' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  padding-right: 24px;
}

.chip-select:hover {
  border-color: var(--stroke-subtle);
}

.chip-select:focus {
  border-color: var(--brand-rest);
}

.sort-chip {
  margin-left: auto;
}

.filter-spacer {
  flex: 1;
}

/* ---- Cards --------------------------------------------------------------- */
.card {
  background: var(--bg-layer);
  border: 1px solid var(--stroke-divider);
  border-radius: var(--r-lg);
  transition: border-color var(--t-fast) var(--ease-standard);
}

.card-interactive:hover {
  border-color: var(--stroke-subtle);
}

/* ---- Section ------------------------------------------------------------- */
.section {
  margin-bottom: 28px;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.section-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--fg-primary);
}

/* ---- KPI ----------------------------------------------------------------- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.kpi-card {
  background: var(--bg-layer);
  border: 1px solid var(--stroke-divider);
  border-radius: var(--r-lg);
  padding: 20px;
  display: flex;
  align-items: flex-start;
  gap: 14px;
}

.kpi-icon {
  width: 36px; height: 36px;
  border-radius: var(--r-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.kpi-icon.brand { background: rgba(15,108,189,0.12); }
.kpi-icon.success { background: rgba(16,124,16,0.10); }
.kpi-icon.caution { background: rgba(131,91,0,0.10); }
.kpi-icon.info { background: rgba(15,108,189,0.10); }
.kpi-icon.danger { background: rgba(209,52,56,0.10); }

.kpi-body { flex: 1; min-width: 0; }
.kpi-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--fg-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 4px;
}
.kpi-value {
  font-size: 24px;
  font-weight: 600;
  color: var(--fg-primary);
  letter-spacing: -0.02em;
  line-height: 1.2;
}
.kpi-sub {
  font-size: 12px;
  color: var(--fg-tertiary);
  margin-top: 4px;
}

/* ---- Table --------------------------------------------------------------- */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--stroke-divider);
  border-radius: var(--r-lg);
  background: var(--bg-layer);
}

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

th {
  text-align: left;
  padding: 10px 16px;
  font-size: 12px;
  font-weight: 600;
  color: var(--fg-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  border-bottom: 1px solid var(--stroke-divider);
  white-space: nowrap;
  user-select: none;
}

td {
  padding: 10px 16px;
  border-bottom: 1px solid var(--stroke-divider);
  color: var(--fg-secondary);
  vertical-align: middle;
}

tr:last-child td { border-bottom: none; }

tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--bg-layer-hover); }

/* ---- Empty state --------------------------------------------------------- */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 64px 32px;
  text-align: center;
}

.empty-state-icon {
  font-size: 40px;
  margin-bottom: 16px;
  opacity: 0.6;
}

.empty-state-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--fg-primary);
  margin-bottom: 8px;
}

.empty-state-body {
  font-size: 13px;
  color: var(--fg-tertiary);
  max-width: 400px;
}

/* ---- Buttons ------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 36px;
  padding: 0 20px;
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 600;
  border-radius: var(--r-md);
  cursor: pointer;
  transition: all var(--t-fast) var(--ease-standard);
  border: 1px solid transparent;
  text-decoration: none;
}

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

.btn-primary:hover {
  background: var(--brand-hover);
  border-color: var(--brand-hover);
}

.btn-secondary {
  background: transparent;
  color: var(--fg-primary);
  border-color: var(--stroke-default);
}

.btn-secondary:hover {
  background: var(--bg-nav-hover);
  border-color: var(--stroke-strong);
}

/* ---- Badges -------------------------------------------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  font-size: 11px;
  font-weight: 600;
  border-radius: var(--r-circular);
  white-space: nowrap;
}

.badge-brand { background: rgba(15,108,189,0.12); color: var(--brand-hover); }
.badge-success { background: rgba(16,124,16,0.10); color: var(--status-success-fg); }
.badge-caution { background: rgba(131,91,0,0.10); color: var(--status-caution-fg); }
.badge-danger  { background: rgba(209,52,56,0.10); color: var(--status-danger-fg); }
.badge-neutral { background: var(--bg-chip); color: var(--fg-tertiary); }

/* ---- Confidence pips ----------------------------------------------------- */
.conf-pip {
  display: inline-flex;
  gap: 3px;
}

.conf-pip-dot {
  width: 8px; height: 8px;
  border-radius: var(--r-circular);
}

.conf-pip-dot.filled-high { background: var(--conf-high); }
.conf-pip-dot.filled-medium { background: var(--conf-medium); }
.conf-pip-dot.filled-low { background: var(--conf-low); }
.conf-pip-dot.empty { background: var(--conf-empty); }

/* ---- Bar chart ----------------------------------------------------------- */
.bar-chart { list-style: none; }

.bar-item {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

.bar-label {
  font-size: 12px;
  color: var(--fg-secondary);
  width: 110px;
  flex-shrink: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bar-track {
  flex: 1;
  height: 6px;
  background: var(--bg-subtle);
  border-radius: var(--r-circular);
  overflow: hidden;
  min-width: 0;
}

.bar-fill {
  height: 100%;
  background: var(--brand-rest);
  border-radius: var(--r-circular);
  transition: width var(--t-normal) var(--ease-decelerate);
  min-width: 0;
}

.bar-value {
  font-size: 12px;
  font-weight: 600;
  color: var(--fg-tertiary);
  width: 36px;
  text-align: right;
  flex-shrink: 0;
}

/* ---- Data list ----------------------------------------------------------- */
.data-list { list-style: none; }

.data-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--stroke-divider);
  font-size: 13px;
}

.data-list li:last-child { border-bottom: none; }
.data-list li span:first-child { color: var(--fg-secondary); }
.data-list li span:last-child { color: var(--fg-primary); font-weight: 500; }

/* ---- Misc ---------------------------------------------------------------- */
.text-primary   { color: var(--fg-primary); }
.text-secondary { color: var(--fg-secondary); }
.text-tertiary  { color: var(--fg-tertiary); }
.text-quaternary { color: var(--fg-quaternary); }
.text-brand     { color: var(--brand-rest); }
.text-success   { color: var(--status-success-fg); }
.text-caution   { color: var(--status-caution-fg); }
.text-danger    { color: var(--status-danger-fg); }
.text-mono      { font-family: var(--font-mono); font-size: 12px; }
.text-muted     { color: var(--fg-tertiary); }

.divider {
  height: 1px;
  background: var(--stroke-divider);
  margin: 16px 0;
}

/* ---- Scrollbar ----------------------------------------------------------- */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); border-radius: var(--r-circular); }
::-webkit-scrollbar-thumb:hover { background: var(--scrollbar-thumb-hover); }

/* ---- Focus --------------------------------------------------------------- */
:focus-visible {
  outline: 2px solid var(--stroke-focus-outer);
  outline-offset: 1px;
}

/* ---- Reduced motion ------------------------------------------------------ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
