/* ==========================================================================
   Moyako Data Hub — stylesheet.
   Design tokens inherited from the Moyako Games platform (dark + light
   themes; wooden dropped — games-gated). Fresh component layer: the Games
   CSS bundle is game-chrome-heavy (700KB); tokens carry the brand, this
   file carries only what the Hub uses. See doc/DESIGN-RULES.md.
   ========================================================================== */

:root, [data-theme="dark"] {
  --bg-gradient: linear-gradient(135deg, #1A1E2A 0%, #232838 25%, #1E2330 50%, #272D3E 75%, #1A1E2A 100%);
  --bg: #1A1E2A;
  --surface: #232838;
  --surface-2: #2A3042;
  --line: #39415A;
  --line-soft: #2E3547;
  --text: #ECEFF4;
  --text-muted: #9AA3B7;
  --text-faint: #6B7490;
  --green: #4CAF50;
  --green-soft: rgba(76, 175, 80, .14);
  --orange: #FF9800;
  --orange-soft: rgba(255, 152, 0, .12);
  --red: #E5534B;
  --red-soft: rgba(229, 83, 75, .12);
  --shadow: 0 4px 16px rgba(0, 0, 0, .35);
}
[data-theme="light"] {
  --bg-gradient: linear-gradient(135deg, #F5F7FA 0%, #EDF0F5 50%, #F5F7FA 100%);
  --bg: #F5F7FA;
  --surface: #FFFFFF;
  --surface-2: #EFF2F7;
  --line: #C9D0DE;
  --line-soft: #DDE2EC;
  --text: #22283A;
  --text-muted: #5A6376;
  --text-faint: #8B93A6;
  --green: #2E7D32;
  --green-soft: rgba(46, 125, 50, .10);
  --orange: #E65100;
  --orange-soft: rgba(230, 81, 0, .10);
  --red: #C62828;
  --red-soft: rgba(198, 40, 40, .10);
  --shadow: 0 4px 14px rgba(30, 40, 70, .12);
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body {
  margin: 0;
  background: var(--bg-gradient);
  background-attachment: fixed;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  line-height: 1.55;
  min-height: 100vh;
}
main.page { max-width: 1120px; margin: 0 auto; padding: 24px 20px 80px; }
h1, h2, h3, h4 { line-height: 1.2; text-wrap: balance; margin: 0 0 .4em; }
h1 { font-size: 2rem; } h2 { font-size: 1.4rem; } h3 { font-size: 1.1rem; }
p { max-width: 72ch; }
a { color: var(--green); }
code, .mono { font-family: ui-monospace, Consolas, 'Cascadia Mono', monospace; font-variant-numeric: tabular-nums; }
.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); font-size: .85em; }
.center { text-align: center; }

/* ---- top bar ---- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 16px;
  padding: 10px 20px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line-soft);
}
.topbar .brand { font-weight: 700; font-size: 1.05rem; color: var(--text); text-decoration: none; display: flex; align-items: center; gap: 8px; }
.topbar .brand .logo { color: var(--green); }
.topbar nav { display: flex; gap: 4px; flex: 1; }
.topbar nav a {
  color: var(--text-muted); text-decoration: none; font-size: .9rem;
  padding: 6px 10px; border-radius: 6px;
}
.topbar nav a:hover { color: var(--text); background: var(--surface); }
.topbar nav a.active { color: var(--text); background: var(--surface); }
.topbar .actions { display: flex; gap: 8px; align-items: center; }
@media (max-width: 720px) {
  .topbar { flex-wrap: wrap; padding: 10px 12px; gap: 8px; }
  .topbar nav { order: 3; width: 100%; overflow-x: auto; }
}

/* ---- buttons ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--line); border-radius: 6px;
  background: var(--surface); color: var(--text);
  font-size: .9rem; font-weight: 600; font-family: inherit;
  padding: 8px 16px; cursor: pointer; text-decoration: none;
  transition: background .12s, border-color .12s;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--green); border-color: var(--green); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.warn { background: var(--orange-soft); border-color: var(--orange); color: var(--orange); }
.btn.danger { background: var(--red-soft); border-color: var(--red); color: var(--red); }
.btn.ghost { background: transparent; }
.btn.small { padding: 4px 10px; font-size: .8rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---- forms ---- */
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 14px; }
.field label { font-size: .82rem; font-weight: 600; color: var(--text-muted); }
.field .hint { font-size: .75rem; color: var(--text-faint); }
input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="url"], select, textarea {
  background: var(--surface); color: var(--text);
  border: 1px solid var(--line); border-radius: 6px;
  padding: 9px 12px; font-size: .95rem; font-family: inherit;
  width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--green); outline-offset: 0; border-color: transparent; }
.checkline { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 10px; font-size: .88rem; color: var(--text-muted); }
.checkline input { margin-top: 3px; }
.form-card { background: var(--surface); border: 1px solid var(--line-soft); border-radius: 10px; padding: 24px; max-width: 460px; margin: 40px auto; box-shadow: var(--shadow); }
.form-card.wide { max-width: 640px; }
.error-box { background: var(--red-soft); border: 1px solid var(--red); color: var(--text); border-radius: 6px; padding: 10px 14px; font-size: .88rem; margin-bottom: 12px; display: none; }
.error-box.show { display: block; }
.ok-box { background: var(--green-soft); border: 1px solid var(--green); color: var(--text); border-radius: 6px; padding: 10px 14px; font-size: .88rem; margin-bottom: 12px; display: none; }
.ok-box.show { display: block; }

/* ---- cards & tiles ---- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.tile {
  background: var(--surface); border: 1px solid var(--line-soft); border-radius: 10px;
  padding: 16px; display: flex; flex-direction: column; gap: 8px;
  transition: border-color .12s, transform .12s;
}
a.tile { text-decoration: none; color: inherit; }
a.tile:hover { border-color: var(--green); transform: translateY(-2px); }
.tile .tile-head { display: flex; align-items: center; gap: 10px; }
.tile .tile-logo { font-size: 1.4rem; }
.tile h3 { margin: 0; font-size: 1rem; }
.tile .tile-sub { font-size: .8rem; color: var(--text-muted); }
.tile .tile-desc { font-size: .84rem; color: var(--text-muted); flex: 1; }
.tile .tile-foot { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.price { font-family: ui-monospace, Consolas, monospace; font-weight: 700; color: var(--text); }
.price.free { color: var(--green); }

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  border: 1px solid var(--line); border-radius: 20px;
  padding: 1px 10px; font-size: .7rem; color: var(--text-muted); white-space: nowrap;
}
.badge.green { border-color: var(--green); color: var(--green); background: var(--green-soft); }
.badge.orange { border-color: var(--orange); color: var(--orange); background: var(--orange-soft); }
.badge.red { border-color: var(--red); color: var(--red); background: var(--red-soft); }

/* ---- panels / layout ---- */
.panel { background: var(--surface); border: 1px solid var(--line-soft); border-radius: 10px; padding: 20px; }
.panel + .panel { margin-top: 16px; }
.split { display: flex; gap: 24px; align-items: flex-start; }
.split > .side { width: 300px; flex: 0 0 auto; }
.split > .main { flex: 1; min-width: 0; }
@media (max-width: 860px) { .split { flex-direction: column; } .split > .side { width: 100%; } }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.kpi { background: var(--surface); border: 1px solid var(--line-soft); border-radius: 10px; padding: 14px 16px; }
.kpi .kpi-label { font-size: .7rem; letter-spacing: .1em; text-transform: uppercase; color: var(--text-faint); font-weight: 700; }
.kpi .kpi-value { font-size: 1.5rem; font-weight: 700; font-variant-numeric: tabular-nums; }

/* ---- tables ---- */
.tablewrap { overflow-x: auto; border: 1px solid var(--line-soft); border-radius: 8px; }
table.data { border-collapse: collapse; width: 100%; font-size: .85rem; }
table.data th {
  text-align: left; font-size: .7rem; letter-spacing: .08em; text-transform: uppercase;
  color: var(--text-faint); font-weight: 700; position: sticky; top: 0; background: var(--surface-2);
}
table.data th, table.data td { padding: 8px 12px; border-bottom: 1px solid var(--line-soft); white-space: nowrap; }
table.data tr:last-child td { border-bottom: 0; }
table.data td { font-variant-numeric: tabular-nums; }

/* ---- tabs ---- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line-soft); margin-bottom: 16px; overflow-x: auto; }
.tabs button {
  background: none; border: none; border-bottom: 2px solid transparent;
  color: var(--text-muted); font-size: .9rem; font-weight: 600; font-family: inherit;
  padding: 8px 14px; cursor: pointer; white-space: nowrap;
}
.tabs button.active { color: var(--text); border-bottom-color: var(--green); }

/* ---- modal ---- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(10, 12, 20, .7); z-index: 100;
  display: none; align-items: center; justify-content: center; padding: 20px;
}
.modal-backdrop.show { display: flex; }
.modal {
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  max-width: 560px; width: 100%; max-height: 85vh; overflow-y: auto; padding: 24px;
  box-shadow: var(--shadow);
}

/* ---- toast ---- */
#toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--surface-2); color: var(--text); border: 1px solid var(--line);
  border-radius: 8px; padding: 10px 20px; font-size: .9rem; z-index: 200;
  opacity: 0; pointer-events: none; transition: opacity .2s;
}
#toast.show { opacity: 1; }

/* ---- empty states ---- */
.empty {
  border: 1.5px dashed var(--line); border-radius: 10px; padding: 40px 24px;
  text-align: center; color: var(--text-muted);
}

/* ---- footer ---- */
footer.site {
  border-top: 1px solid var(--line-soft); margin-top: 60px; padding: 24px 20px;
  font-size: .8rem; color: var(--text-faint);
  display: flex; flex-wrap: wrap; gap: 8px 20px; justify-content: center;
}
footer.site a { color: var(--text-muted); text-decoration: none; }
footer.site a:hover { color: var(--text); }

/* ---- landing specifics ---- */
.hero { display: flex; gap: 32px; align-items: center; padding: 40px 0 24px; }
.hero .hero-copy { flex: 1; }
.hero .hero-demo { flex: 1.2; min-width: 0; }
.hero h1 { font-size: 2.4rem; }
@media (max-width: 860px) { .hero { flex-direction: column; } .hero h1 { font-size: 1.7rem; } }
.demo-frame {
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  padding: 14px; box-shadow: var(--shadow);
}
.strips { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; margin: 40px 0; }

/* ---- workbench ---- */
.wb { display: grid; grid-template-columns: 240px 1fr 240px; gap: 14px; align-items: start; }
@media (max-width: 1000px) { .wb { grid-template-columns: 1fr; } }
.wb .wb-panel { background: var(--surface); border: 1px solid var(--line-soft); border-radius: 10px; padding: 12px; }
.wb .field-pill {
  display: block; width: 100%; text-align: left;
  background: var(--surface-2); border: 1px solid var(--line-soft); border-radius: 6px;
  color: var(--text); font-size: .82rem; font-family: inherit;
  padding: 6px 10px; margin-bottom: 6px; cursor: grab;
}
.wb .field-pill:hover { border-color: var(--green); }
.wb .drop {
  border: 1.5px dashed var(--line); border-radius: 6px; min-height: 38px;
  padding: 6px; margin-bottom: 10px; font-size: .78rem; color: var(--text-faint);
}
.wb .drop.over { border-color: var(--green); background: var(--green-soft); }
.wb .drop .chip {
  display: inline-flex; gap: 6px; align-items: center;
  background: var(--green-soft); border: 1px solid var(--green); border-radius: 14px;
  color: var(--text); font-size: .76rem; padding: 2px 10px; margin: 2px;
}
.wb .drop .chip button { background: none; border: none; color: var(--text-muted); cursor: pointer; padding: 0; font-size: .9em; }
.wb canvas { width: 100%; background: var(--surface-2); border-radius: 8px; }

/* honest focus states everywhere */
a:focus-visible, button:focus-visible, .btn:focus-visible, .tile:focus-visible {
  outline: 2px solid var(--green); outline-offset: 2px;
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
