:root {
  --bg: #f3f6f8;
  --surface: #ffffff;
  --panel: #fbfdff;
  --ink: #1f2a37;
  --muted: #667085;
  --line: #d8e1ea;
  --dark: #15212b;
  --brand: #176b87;
  --brand-2: #2bb3a3;
  --green: #15803d;
  --red: #b42318;
  --amber: #b7791f;
  --blue: #2563eb;
  --shadow: 0 14px 35px rgba(16, 24, 40, .08);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: linear-gradient(135deg, rgba(23,107,135,.12), rgba(43,179,163,.1)), var(--bg);
}
.login-panel {
  width: min(470px, 100%);
  padding: 30px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}
.logo-row { display: flex; align-items: center; gap: 12px; }
.logo-mark {
  width: 44px; height: 44px;
  display: grid; place-items: center;
  border-radius: 8px;
  color: white;
  background: var(--brand);
  font-weight: 900;
}
.logo-row h1, .logo-row p { margin: 0; }
.logo-row h1 { font-size: 22px; }
.logo-row p, .side-logo span, .topbar p, .panel-head span, small { color: var(--muted); font-size: 12px; }
.form-stack, .dialog-form { display: grid; gap: 14px; }
.form-stack { margin-top: 26px; }
.login-switch {
  display: flex;
  gap: 8px;
  margin-top: 22px;
}
.login-switch button { flex: 1; }
label { display: grid; gap: 6px; color: var(--muted); font-size: 12px; font-weight: 800; text-transform: uppercase; }
input, select, textarea {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 10px;
  color: var(--ink);
  background: white;
}
textarea { min-height: 92px; resize: vertical; text-transform: none; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(23,107,135,.16); border-color: var(--brand); }

.primary-btn, .ghost-btn, .danger-btn, .nav-item, .action-btn, .tab, .front-primary {
  min-height: 36px;
  border-radius: 6px;
  border: 1px solid transparent;
  padding: 8px 11px;
  font-weight: 850;
  font-size: 12px;
  letter-spacing: 0;
}
.primary-btn { background: var(--brand); color: white; }
.ghost-btn { background: white; color: var(--ink); border-color: var(--line); }
.danger-btn { background: #fff1f0; color: var(--red); border-color: #ffd2cc; }
.small { min-height: 30px; padding: 6px 9px; }

.shell { min-height: 100vh; display: grid; grid-template-columns: 280px minmax(0, 1fr); }
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  background: var(--dark);
  color: white;
  padding: 18px 14px;
  overflow: hidden;
}
.side-logo { padding: 6px 6px 16px; }
.side-logo .logo-mark { background: var(--brand-2); }
.side-logo strong { display: block; }
.nav-list {
  display: grid;
  gap: 5px;
  max-height: calc(100vh - 96px);
  overflow-y: auto;
  padding: 4px 4px 10px 0;
}
.nav-list::-webkit-scrollbar { width: 6px; }
.nav-list::-webkit-scrollbar-thumb { background: rgba(255,255,255,.18); border-radius: 99px; }
.nav-item {
  width: 100%;
  min-height: 38px;
  background: transparent;
  color: #dce7ee;
  text-align: left;
  padding: 9px 12px;
}
.nav-item:hover,
.nav-item.active {
  background: rgba(255,255,255,.11);
  color: white;
  box-shadow: inset 3px 0 0 var(--brand-2);
}

.workspace { min-width: 0; display: grid; grid-template-rows: auto 1fr; }
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 76px;
  padding: 16px 24px;
  background: white;
  border-bottom: 1px solid var(--line);
}
.topbar h2 { margin: 3px 0 0; font-size: 23px; }
.topbar p { margin: 0; font-weight: 800; color: var(--brand); }
.top-actions { display: flex; gap: 10px; align-items: center; color: var(--muted); font-size: 12px; white-space: nowrap; }
.api-status {
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 9px;
  background: #e8f5f7;
  color: var(--brand);
  font-weight: 850;
}
.api-status.warn { background: #fef3c7; color: var(--amber); }
.api-status.error { background: #fee2e2; color: var(--red); }
.api-status.ok { background: #dcfce7; color: var(--green); }

.view { display: none; padding: 22px 24px; }
.active-view { display: block; }
.metrics-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 14px; margin-bottom: 14px; }
.metric, .panel, .merchant-banner {
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 1px 2px rgba(16,24,40,.04);
}
.metric { min-height: 120px; padding: 16px; display: grid; gap: 7px; align-content: start; }
.metric span { color: var(--muted); font-size: 13px; font-weight: 850; }
.metric strong { font-size: 25px; }
.metric.warning { background: #fffaf0; border-color: rgba(183,121,31,.35); }
.two-col { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(360px, .85fr); gap: 14px; margin-top: 14px; }
.panel { padding: 14px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; }
.panel-head h3 { margin: 0; font-size: 16px; }
.filter-bar { display: grid; grid-template-columns: minmax(220px,1fr) 170px auto auto; gap: 10px; align-items: center; margin-bottom: 12px; }

.table-wrap { width: 100%; overflow: auto; border: 1px solid var(--line); border-radius: 8px; }
table { width: 100%; min-width: 760px; border-collapse: collapse; background: white; }
th, td { padding: 10px 11px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; font-size: 13px; }
th { background: #eef3f7; color: var(--muted); font-size: 12px; text-transform: uppercase; white-space: nowrap; }
tbody tr:hover { background: #f8fafc; }

.status, .tag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 850;
  white-space: nowrap;
}
.tag { border-radius: 6px; color: var(--brand); background: #e8f5f7; }
.status.active, .status.completed, .status.paid, .status.valid { color: var(--green); background: #dcfce7; }
.status.pending, .status.maintenance, .status.overdue, .status.draft { color: var(--amber); background: #fef3c7; }
.status.suspended, .status.rejected, .status.locked, .status.failed { color: var(--red); background: #fee2e2; }
.amount-positive { color: var(--green); font-weight: 850; }
.amount-negative { color: var(--red); font-weight: 850; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; }
.action-btn { min-height: 28px; padding: 5px 8px; background: white; border-color: var(--line); }
.action-btn.approve { color: var(--green); }
.action-btn.reject { color: var(--red); }

.alert-list { display: grid; gap: 10px; }
.alert {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--amber); }
.alert.danger .dot { background: var(--red); }
.alert.success .dot { background: var(--green); }
.alert strong { display: block; font-size: 13px; }
.alert span, .alert time { color: var(--muted); font-size: 12px; }

.cards-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 14px; display: grid; gap: 9px; }
.card h4 { margin: 0; }
.card ul { margin: 0; padding-left: 18px; color: var(--muted); font-size: 13px; }

.merchant-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px;
  margin-bottom: 14px;
  background: linear-gradient(135deg, #ffffff, #edf8f9);
}
.merchant-banner h3, .merchant-banner p { margin: 0; }
.merchant-banner h3 { font-size: 24px; margin-top: 4px; }
#merchantBadge { display: inline-flex; color: white; background: var(--brand); border-radius: 6px; padding: 5px 8px; font-size: 11px; font-weight: 900; }
.tag-list { display: flex; gap: 8px; flex-wrap: wrap; }
.chat-list { display: grid; gap: 10px; }
.chat-card { display: grid; grid-template-columns: 84px 1fr auto; gap: 10px; align-items: center; padding: 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); }
.chat-card strong { display: block; }
.chat-card p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.report-tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.tab { background: white; border-color: var(--line); }
.tab.active { background: var(--brand); color: white; }
.settings-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 14px; }
.settings-grid article { display: grid; gap: 12px; align-content: start; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 14px; }
.settings-grid h4 { margin: 0; font-size: 14px; }

dialog { border: 1px solid var(--line); border-radius: 8px; padding: 0; box-shadow: var(--shadow); width: min(440px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(15, 23, 42, .36); }
.dialog-form { padding: 18px; }
.dialog-form h3 { margin: 0 0 4px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }
.frontend-dialog { width: min(430px, calc(100vw - 32px)); }
.frontend-preview { background: #101820; color: white; min-height: 640px; }
.frontend-preview header { display: flex; align-items: center; justify-content: space-between; padding: 14px; border-bottom: 1px solid rgba(255,255,255,.1); }
.front-hero { padding: 28px 18px; background: linear-gradient(135deg, rgba(43,179,163,.42), rgba(23,107,135,.24)); }
.front-hero h3 { margin: 0 0 8px; font-size: 34px; }
.front-hero p { color: #dbe7ee; }
.front-primary { background: #2bb3a3; color: white; }
.front-games { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 10px; padding: 14px; }
.front-game { min-height: 98px; border-radius: 8px; padding: 12px; background: rgba(255,255,255,.1); display: grid; align-content: end; }

@media (max-width: 1120px) {
  .shell { grid-template-columns: 248px minmax(0, 1fr); }
  .sidebar { padding: 14px 10px; }
  .logo-row { gap: 10px; }
  .side-logo strong { font-size: 14px; }
  .nav-item { min-height: 36px; padding: 8px 10px; }
  .metrics-grid, .two-col, .cards-grid, .settings-grid { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: relative;
    height: auto;
    overflow: visible;
  }
  .nav-list {
    grid-auto-flow: column;
    overflow-x: auto;
    overflow-y: hidden;
    max-height: none;
  }
  .nav-item { white-space: nowrap; }
  .topbar { flex-direction: column; align-items: flex-start; }
  .top-actions { width: 100%; flex-wrap: wrap; }
  .filter-bar { grid-template-columns: 1fr; }
  .view { padding: 12px; }
}
