:root {
  color-scheme: dark;
  --bg: #111315;
  --panel: #1b1e21;
  --panel-2: #23272b;
  --line: #30353a;
  --text: #f4f6f8;
  --muted: #8f979f;
  --blue: #73bcff;
  --blue-dark: #174a73;
  --danger: #ff6b6b;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
button, input, select { font: inherit; }
button, select, input { border: 1px solid var(--line); border-radius: 9px; }
button { padding: 8px 12px; background: #2a2e32; color: var(--text); cursor: pointer; }
button:hover { border-color: #58616a; }
button.active, button.primary { background: var(--blue); color: #07121b; border-color: var(--blue); font-weight: 700; }
button.danger { background: #7f272b; border-color: #a43b40; color: #fff; }
button.danger:hover { background: #9a3035; border-color: var(--danger); }
button:disabled { cursor: not-allowed; opacity: .45; }
button.compact { width: fit-content; margin-top: 8px; }
input, select { width: 100%; padding: 9px 11px; color: var(--text); background: #282c30; }
h1, h2, h3, p { margin-top: 0; }
h1 { font-size: 22px; margin-bottom: 5px; }
h2 { font-size: 18px; margin-bottom: 4px; }
h3 { font-size: 16px; margin-bottom: 6px; }
small, .muted { color: var(--muted); }
.hidden { display: none !important; }
.login-view { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: min(390px, 100%); padding: 32px; border: 1px solid var(--line); border-radius: 18px; background: var(--panel); box-shadow: 0 24px 80px #0008; display: grid; gap: 15px; }
.login-card h1 { margin: 2px 0 -10px; }
.login-card p { color: var(--muted); margin-bottom: 8px; }
.login-card label, #add-form > label { display: grid; gap: 7px; font-size: 13px; font-weight: 600; }
.logo { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 11px; background: var(--blue); color: #07121b; font-weight: 900; font-size: 22px; }
.logo.small { width: 34px; height: 34px; font-size: 18px; }
.error { color: var(--danger); min-height: 18px; font-size: 13px; }
.app-view { min-height: 100vh; display: grid; grid-template-columns: 190px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; border-right: 1px solid var(--line); padding: 22px 14px; display: flex; flex-direction: column; }
.brand { display: flex; align-items: center; gap: 10px; margin: 0 6px 30px; }
.brand > span:last-child { display: grid; }
.brand small { font-size: 11px; }
nav { display: grid; gap: 7px; }
.nav { text-align: left; border-color: transparent; background: transparent; }
.nav.active { color: var(--text); background: var(--panel-2); border-color: var(--line); }
.logout { margin-top: auto; background: transparent; color: var(--muted); }
.content { min-width: 0; padding: 24px 28px 42px; }
.toolbar, .section-line, .card-title { display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.toolbar { margin-bottom: 30px; }
.toolbar-controls { width: min(520px, 55%); display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; }
.section-line { margin-bottom: 14px; align-items: flex-end; }
.periods, .segmented { display: flex; gap: 7px; flex-wrap: wrap; }
.periods button, .segmented button { padding: 6px 10px; color: var(--muted); }
.periods button.active, .segmented button.active { color: #07121b; }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 22px; }
.stats article, .panel { padding: 15px 17px; background: var(--panel); border: 1px solid #252a2e; border-radius: 14px; }
.stats article { display: grid; gap: 4px; }
.stats span { color: var(--muted); font-size: 13px; }
.stats strong { font-size: 22px; }
.online-stat > span { display: flex; align-items: center; gap: 7px; }
.online-stat i { width: 8px; height: 8px; border-radius: 50%; background: #52d889; box-shadow: 0 0 0 4px #52d88918; }
.activity-grid { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(270px, .65fr); gap: 24px; margin-bottom: 28px; }
.chart-card, .countries-card { min-width: 0; }
.legend { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); margin-bottom: 10px; }
.legend i { width: 9px; height: 9px; background: var(--blue); border-radius: 50%; }
.chart { min-height: 230px; border-bottom: 1px solid var(--line); position: relative; }
.chart svg { display: block; width: 100%; height: 230px; overflow: visible; }
.chart-empty { height: 230px; display: grid; place-items: center; color: var(--muted); background: linear-gradient(180deg, transparent, #ffffff03); }
.country-row, .bar-row { display: grid; grid-template-columns: 110px minmax(0, 1fr) auto; align-items: center; gap: 10px; margin: 13px 0; }
.track { height: 8px; border-radius: 99px; background: #2b3034; overflow: hidden; }
.fill { height: 100%; min-width: 2px; border-radius: inherit; background: var(--blue); }
.platform-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 34px; }
.platform-row { display: grid; grid-template-columns: 105px minmax(0, 1fr) auto; align-items: center; gap: 10px; margin: 13px 0; }
.link-button { padding: 4px 0; border: 0; background: transparent; color: var(--muted); }
.analytics-head { margin-bottom: 22px; }
.analytics-filters { margin-bottom: 18px; }
.analytics-layout { display: grid; grid-template-columns: minmax(0, .9fr) minmax(480px, 1.1fr); gap: 34px; align-items: start; }
.bar-list { margin-top: 25px; }
.table-wrap { width: 100%; overflow: auto; margin-top: 14px; }
table { width: 100%; border-collapse: collapse; min-width: 520px; }
th, td { padding: 12px 10px; border-bottom: 1px solid var(--line); text-align: left; }
th { color: var(--muted); font-size: 12px; }
td { font-size: 14px; }
th:not(:first-child), td:not(:first-child) { text-align: right; }
.panel { max-width: 900px; margin-bottom: 16px; }
.status { padding: 5px 9px; border-radius: 99px; background: var(--blue-dark); color: var(--blue); font-size: 12px; }
.key-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 18px; }
.key-grid label { display: grid; gap: 7px; font-size: 13px; font-weight: 600; }
.copy-row { display: flex; gap: 7px; }
.copy-row input { min-width: 0; }
.settings { display: grid; gap: 13px; }
.settings label, fieldset label { display: flex; align-items: center; gap: 9px; }
.settings input, fieldset input { width: auto; }
.endpoint { margin-top: 16px; }
.app-list { display: grid; gap: 8px; margin-top: 14px; }
.app-item { display: flex; justify-content: space-between; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.app-item:last-child { border-bottom: 0; }
.apps-panel { max-width: none; }
.apps-table { min-width: 900px; }
.apps-table td:first-child { min-width: 210px; }
.apps-table td:last-child { width: 1%; white-space: nowrap; }
.apps-table code, .delete-warning code { color: var(--blue); }
.event-format { display: inline-block; padding: 4px 8px; border-radius: 99px; background: #282d31; color: var(--muted); font-size: 12px; white-space: nowrap; }
.event-format.banner { background: #243a30; color: #76d5a1; }
.event-format.interstitial { background: #3c3022; color: #e8b66f; }
.event-format.rewarded { background: #25364a; color: #81c1ff; }
.app-environment { display: inline-block; margin-top: 5px; padding: 3px 7px; border-radius: 99px; background: #282d31; color: var(--muted); font-size: 11px; }
.delete-warning { display: grid; gap: 7px; padding: 13px; border: 1px solid #6c3033; border-radius: 10px; background: #3b2022; }
.delete-warning span { color: #e6b8ba; font-size: 13px; }
.loading { position: fixed; top: 14px; left: 50%; z-index: 20; padding: 8px 14px; background: var(--blue); color: #07121b; border-radius: 99px; font-weight: 700; }
dialog { width: min(520px, calc(100% - 30px)); padding: 0; border: 1px solid var(--line); border-radius: 16px; background: var(--panel); color: var(--text); box-shadow: 0 30px 100px #000b; }
dialog::backdrop { background: #000a; }
#add-form { padding: 22px; display: grid; gap: 17px; }
#delete-form { padding: 22px; display: grid; gap: 17px; }
.icon-button { padding: 2px 9px; font-size: 22px; background: transparent; border: 0; }
fieldset { display: flex; gap: 18px; border: 1px solid var(--line); border-radius: 10px; padding: 12px; }
legend { color: var(--muted); padding: 0 5px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }
#toast { position: fixed; right: 22px; bottom: 22px; z-index: 50; transform: translateY(90px); opacity: 0; padding: 11px 15px; border-radius: 10px; background: var(--blue); color: #07121b; font-weight: 700; transition: .2s; }
#toast.show { transform: translateY(0); opacity: 1; }
@media (max-width: 1050px) {
  .activity-grid, .analytics-layout { grid-template-columns: 1fr; }
  .countries-card { max-width: none; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 780px) {
  .app-view { grid-template-columns: 1fr; }
  .sidebar { position: static; width: 100%; height: auto; padding: 12px; flex-direction: row; align-items: center; gap: 10px; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .brand { margin: 0 10px 0 0; }
  nav { display: flex; }
  .logout { margin: 0 0 0 auto; }
  .content { padding: 18px 14px 35px; }
  .toolbar { align-items: flex-start; flex-direction: column; }
  .toolbar-controls { width: 100%; }
  .platform-grid, .key-grid { grid-template-columns: 1fr; }
}
@media (max-width: 520px) {
  .toolbar-controls { grid-template-columns: 1fr; }
  .stats { grid-template-columns: 1fr; }
  .section-line { align-items: flex-start; flex-direction: column; }
  .periods { width: 100%; overflow-x: auto; flex-wrap: nowrap; }
  .periods button { white-space: nowrap; }
  .platform-row, .country-row, .bar-row { grid-template-columns: 90px minmax(0, 1fr) auto; }
  fieldset { flex-direction: column; }
}
