/* Game News BD Dashboard — Material Design 3 (m3.material.io).
   A light, token-based M3 theme. No build step, no component library. */

:root {
  /* ── M3 color roles (light scheme, blue primary) ── */
  --primary: #415f91;
  --on-primary: #ffffff;
  --primary-container: #d6e3ff;
  --on-primary-container: #001b3e;
  --secondary: #565f71;
  --secondary-container: #dae2f9;
  --on-secondary-container: #131c2b;
  --tertiary: #6b5778;
  --tertiary-container: #f2daff;
  --on-tertiary-container: #251431;
  --error: #ba1a1a;
  --error-container: #ffdad6;
  --on-error-container: #410002;

  --surface: #f9f9ff;
  --surface-dim: #d8d9e0;
  --surface-bright: #f9f9ff;
  --surface-container-lowest: #ffffff;
  --surface-container-low: #f2f3fa;
  --surface-container: #eceef4;
  --surface-container-high: #e7e8ee;
  --surface-container-highest: #e1e2e9;
  --on-surface: #191c20;
  --on-surface-variant: #43474e;
  --outline: #73777f;
  --outline-variant: #c3c6cf;
  --inverse-surface: #2e3036;
  --inverse-on-surface: #eff0f7;

  /* tonal accents for status/role badges */
  --green: #146c2e; --green-c: #c6efc5;
  --amber: #855300; --amber-c: #ffddb3;
  --sky: #00497d; --sky-c: #cfe5ff;
  --violet: #5c3f8a; --violet-c: #e9ddff;
  --rose: #8c1d35; --rose-c: #ffd9dd;
  --slate: #3f4759; --slate-c: #dbe2f9;
  --teal: #00504b; --teal-c: #9df2e8;

  /* shape (M3 corner scale) */
  --r-xs: 4px; --r-sm: 8px; --r-md: 12px; --r-lg: 16px; --r-xl: 28px; --r-full: 999px;

  /* elevation */
  --e1: 0 1px 2px rgba(0,0,0,.30), 0 1px 3px 1px rgba(0,0,0,.15);
  --e2: 0 1px 2px rgba(0,0,0,.30), 0 2px 6px 2px rgba(0,0,0,.15);
  --e3: 0 4px 8px 3px rgba(0,0,0,.15), 0 1px 3px rgba(0,0,0,.30);

  font-family: "Roboto", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--surface);
  color: var(--on-surface);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
.material-symbols-outlined { font-size: 20px; line-height: 1; user-select: none; }
.hidden { display: none !important; }
.mono { font-variant-numeric: tabular-nums; }

/* ── Top app bar ── */
.appbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 12px 24px;
  background: var(--surface-container);
  border-bottom: 1px solid var(--outline-variant);
}
.appbar-lead { display: flex; align-items: center; gap: 14px; min-width: 0; }
.appbar-icon {
  font-size: 26px; color: var(--on-primary);
  background: var(--primary); border-radius: var(--r-md);
  width: 44px; height: 44px; display: grid; place-items: center; flex: none;
}
.appbar-titles h1 {
  margin: 0; font-family: "Roboto Flex", Roboto, sans-serif;
  font-size: 22px; font-weight: 700; letter-spacing: 0; color: var(--on-surface);
}
.appbar-titles p { margin: 0; font-size: 12px; color: var(--on-surface-variant); }
.appbar-stats { display: flex; gap: 8px; }
.stat {
  background: var(--surface-container-high); border-radius: var(--r-md);
  padding: 6px 16px; min-width: 78px; text-align: center;
}
.stat-v { display: block; font-size: 20px; font-weight: 700; color: var(--primary); font-variant-numeric: tabular-nums; }
.stat-l { display: block; font-size: 11px; color: var(--on-surface-variant); letter-spacing: .2px; }

/* ── Primary tabs ── */
.tabs {
  position: sticky; top: 69px; z-index: 19;
  display: flex; gap: 4px; padding: 0 16px;
  background: var(--surface-container);
  border-bottom: 1px solid var(--outline-variant);
}
.tab {
  appearance: none; border: 0; background: transparent; cursor: pointer;
  display: inline-flex; align-items: center; gap: 8px;
  padding: 14px 16px 12px; font: inherit; font-weight: 500; font-size: 14px;
  color: var(--on-surface-variant);
  border-bottom: 3px solid transparent; margin-bottom: -1px;
  transition: color .15s, background .15s; border-radius: var(--r-sm) var(--r-sm) 0 0;
}
.tab:hover { background: color-mix(in srgb, var(--on-surface) 6%, transparent); color: var(--on-surface); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab .material-symbols-outlined { font-size: 20px; }
.badge-count {
  font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: var(--r-full);
  background: var(--secondary-container); color: var(--on-secondary-container); margin-left: 2px;
}
.tab.active .badge-count { background: var(--primary-container); color: var(--on-primary-container); }

/* ── Layout ── */
.wrap { max-width: 1280px; margin: 0 auto; padding: 20px 24px 64px; }

/* ── Filters ── */
.filters { margin-bottom: 18px; display: flex; flex-direction: column; gap: 14px; }
.searchbar {
  display: flex; align-items: center; gap: 12px;
  background: var(--surface-container-high); border-radius: var(--r-xl);
  padding: 0 18px; height: 52px;
}
.searchbar .material-symbols-outlined { color: var(--on-surface-variant); }
.searchbar input {
  flex: 1; border: 0; background: transparent; outline: none;
  font: inherit; font-size: 15px; color: var(--on-surface);
}
.searchbar input::placeholder { color: var(--on-surface-variant); }

.selects { display: flex; flex-wrap: wrap; gap: 10px; }
.select { position: relative; display: flex; flex-direction: column; min-width: 130px; flex: 1 1 130px; max-width: 200px; }
.select > span {
  position: absolute; top: -7px; left: 10px; padding: 0 5px; z-index: 1;
  font-size: 11px; color: var(--on-surface-variant); background: var(--surface);
}
.select select, .select input[type="date"] {
  appearance: none; width: 100%; height: 46px; padding: 0 32px 0 13px;
  border: 1px solid var(--outline-variant); border-radius: var(--r-xs);
  background: var(--surface); color: var(--on-surface); font: inherit; font-size: 14px;
  cursor: pointer; outline: none;
}
.select select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%2343474e' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 8px center; }
.select select:focus, .select input:focus { border-color: var(--primary); border-width: 2px; padding-left: 12px; }

/* ── Chips (filter chips) ── */
.chips { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.chip {
  appearance: none; cursor: pointer; font: inherit; font-size: 13px; font-weight: 500;
  display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 14px;
  border: 1px solid var(--outline); border-radius: var(--r-sm);
  background: transparent; color: var(--on-surface-variant); transition: all .15s;
}
.chip:hover { background: color-mix(in srgb, var(--on-surface) 8%, transparent); }
.chip .chk { font-size: 18px; width: 0; overflow: hidden; opacity: 0; transition: width .15s, opacity .15s; margin-left: -6px; }
.chip.selected {
  background: var(--secondary-container); color: var(--on-secondary-container);
  border-color: transparent;
}
.chip.selected .chk { width: 18px; opacity: 1; margin-left: 0; }
.chip.ghost { border-color: var(--outline-variant); color: var(--primary); }
.chip.ghost .material-symbols-outlined { font-size: 18px; }

/* ── Results ── */
.results {
  background: var(--surface-container-lowest); border: 1px solid var(--outline-variant);
  border-radius: var(--r-lg); overflow: hidden;
}
.results-bar {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  padding: 14px 20px; border-bottom: 1px solid var(--outline-variant);
}
.count { font-size: 14px; color: var(--on-surface); }
.count b { font-weight: 700; }
.active-filters { font-size: 12px; color: var(--on-surface-variant); text-align: right; }

/* sortable column header chips (compact) */
.sortbar { display: flex; gap: 6px; flex-wrap: wrap; padding: 10px 20px 0; }
.sortbtn { appearance: none; cursor: pointer; border: 1px solid var(--outline-variant); background: var(--surface); color: var(--on-surface-variant); border-radius: var(--r-full); height: 30px; padding: 0 12px; font: inherit; font-size: 12px; font-weight: 500; display: inline-flex; align-items: center; gap: 3px; }
.sortbtn.on { background: var(--secondary-container); color: var(--on-secondary-container); border-color: transparent; }
.sortbtn .material-symbols-outlined { font-size: 16px; }

/* list */
.list { display: flex; flex-direction: column; }
.row {
  display: grid; align-items: center; gap: 14px; padding: 13px 20px;
  border-bottom: 1px solid var(--surface-container-high); cursor: pointer;
  transition: background .12s;
}
.row:last-child { border-bottom: 0; }
.row:hover { background: var(--surface-container-low); }
.row-game { grid-template-columns: minmax(0,2.4fr) minmax(0,1.7fr) minmax(0,1fr) auto auto auto; }
.row-company { grid-template-columns: minmax(0,2.2fr) auto minmax(0,1fr) auto auto; }

.cell-main { min-width: 0; }
.cell-title { font-size: 15px; font-weight: 500; color: var(--on-surface); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.cell-sub { font-size: 12.5px; color: var(--on-surface-variant); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cell-sub.en { font-style: italic; }
.cell-region { font-size: 13px; color: var(--on-surface-variant); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.muted { color: var(--on-surface-variant); }

/* source-count pill */
.sources {
  display: inline-flex; align-items: center; gap: 5px; white-space: nowrap;
  background: var(--surface-container-high); color: var(--on-surface-variant);
  border-radius: var(--r-full); padding: 3px 10px; font-size: 12px; font-weight: 500;
}
.sources .material-symbols-outlined { font-size: 15px; }
.sources.multi { background: var(--primary-container); color: var(--on-primary-container); }

/* badges */
.badge {
  display: inline-flex; align-items: center; gap: 5px; white-space: nowrap;
  font-size: 12px; font-weight: 500; padding: 3px 10px; border-radius: var(--r-sm);
  background: var(--slate-c); color: var(--slate);
}
.badge .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.b-green { background: var(--green-c); color: var(--green); }
.b-amber { background: var(--amber-c); color: var(--amber); }
.b-sky { background: var(--sky-c); color: var(--sky); }
.b-violet { background: var(--violet-c); color: var(--violet); }
.b-rose { background: var(--rose-c); color: var(--rose); }
.b-slate { background: var(--slate-c); color: var(--slate); }
.b-teal { background: var(--teal-c); color: var(--teal); }

/* trust meter */
.trust { display: inline-flex; align-items: center; gap: 2px; }
.trust i { width: 5px; height: 14px; border-radius: 2px; background: var(--outline-variant); }
.trust .n { font-size: 12px; font-weight: 600; color: var(--on-surface-variant); margin-left: 5px; font-variant-numeric: tabular-nums; }
.trust.t5 i:nth-child(-n+5), .trust.t4 i:nth-child(-n+4), .trust.t3 i:nth-child(-n+3),
.trust.t2 i:nth-child(-n+2), .trust.t1 i:nth-child(-n+1) { background: var(--primary); }

.num { font-size: 15px; font-weight: 700; color: var(--on-surface); font-variant-numeric: tabular-nums; text-align: right; }

/* pager */
.pager { display: flex; align-items: center; justify-content: space-between; padding: 12px 20px; border-top: 1px solid var(--outline-variant); }
.pageinfo { font-size: 13px; color: var(--on-surface-variant); }
.pager-btns { display: flex; gap: 6px; }
.icon-btn {
  appearance: none; cursor: pointer; border: 0; background: transparent;
  width: 40px; height: 40px; border-radius: var(--r-full); display: grid; place-items: center;
  color: var(--on-surface-variant); transition: background .12s;
}
.icon-btn:hover:not(:disabled) { background: color-mix(in srgb, var(--on-surface) 8%, transparent); }
.icon-btn:disabled { opacity: .35; cursor: default; }

/* empty / skeleton */
.state { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 56px 20px; color: var(--on-surface-variant); text-align: center; }
.state .material-symbols-outlined { font-size: 44px; opacity: .5; }
.skel { padding: 15px 20px; border-bottom: 1px solid var(--surface-container-high); }
.skel span { display: block; height: 14px; border-radius: var(--r-xs); background: linear-gradient(90deg, var(--surface-container) 25%, var(--surface-container-high) 50%, var(--surface-container) 75%); background-size: 200% 100%; animation: sh 1.3s infinite; }
@keyframes sh { to { background-position: -200% 0; } }

/* ── Detail side sheet ── */
.scrim { position: fixed; inset: 0; background: rgba(0,0,0,.32); opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 40; }
.scrim.open { opacity: 1; pointer-events: auto; }
.sheet {
  position: fixed; top: 0; right: 0; height: 100dvh; width: min(480px, 100%);
  background: var(--surface-container-low); box-shadow: var(--e3);
  transform: translateX(102%); transition: transform .26s cubic-bezier(.2,0,0,1);
  z-index: 41; display: flex; flex-direction: column;
  border-top-left-radius: var(--r-xl); border-bottom-left-radius: var(--r-xl); overflow: hidden;
}
.sheet.open { transform: none; }
.sheet-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 22px 22px 14px; }
.sheet-head h2 { margin: 0; font-family: "Roboto Flex", Roboto; font-size: 21px; font-weight: 700; line-height: 1.2; }
.sheet-head .subtitle { font-size: 13px; color: var(--on-surface-variant); font-style: italic; margin-top: 2px; }
.badgerow { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.sheet-body { overflow-y: auto; padding: 0 22px 30px; }

.sectlabel { font-size: 12px; font-weight: 700; letter-spacing: .5px; text-transform: uppercase; color: var(--primary); margin: 22px 0 10px; }
.kv { display: grid; grid-template-columns: 116px 1fr; gap: 7px 14px; margin: 0; }
.kv dt { font-size: 13px; color: var(--on-surface-variant); }
.kv dd { margin: 0; font-size: 13.5px; color: var(--on-surface); }
.note { background: var(--surface-container); border-radius: var(--r-md); padding: 12px 14px; font-size: 13px; color: var(--on-surface); white-space: pre-wrap; }

.btn {
  appearance: none; cursor: pointer; font: inherit; font-size: 14px; font-weight: 500;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 22px; border-radius: var(--r-full); border: 1px solid var(--outline);
  background: transparent; color: var(--primary); transition: background .12s; text-decoration: none;
}
.btn:hover { background: color-mix(in srgb, var(--primary) 8%, transparent); }
.btn.filled { background: var(--primary); color: var(--on-primary); border-color: transparent; }
.btn.filled:hover { background: color-mix(in srgb, var(--primary) 90%, black); }
.btn.tonal { background: var(--secondary-container); color: var(--on-secondary-container); border-color: transparent; }
.btn .material-symbols-outlined { font-size: 18px; }

/* source / game item lists inside the sheet */
.items { display: flex; flex-direction: column; gap: 8px; }
.item {
  display: flex; align-items: center; gap: 12px; padding: 11px 13px;
  background: var(--surface-container); border-radius: var(--r-md);
}
.item.click { cursor: pointer; transition: background .12s; }
.item.click:hover { background: var(--surface-container-high); }
.item .meta { flex: 1; min-width: 0; }
.item .meta .s { font-size: 13.5px; font-weight: 500; color: var(--on-surface); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .meta .d { font-size: 12px; color: var(--on-surface-variant); }
.item .ext { flex: none; color: var(--on-surface-variant); text-decoration: none; display: grid; place-items: center; }
.item .ext:hover { color: var(--primary); }

/* ── Responsive ── */
@media (max-width: 900px) {
  .appbar-stats { display: none; }
  .row-game { grid-template-columns: minmax(0,1fr) auto auto; }
  .row-game .cell-devpub, .row-game .cell-region { display: none; }
  .row-company { grid-template-columns: minmax(0,1fr) auto auto; }
  .row-company .cell-region { display: none; }
}
@media (max-width: 600px) {
  .appbar, .wrap { padding-left: 14px; padding-right: 14px; }
  .tabs { top: 65px; }
  .tab-label { font-size: 13px; }
  .select { max-width: none; }
}
