:root {
  --bg: #ffffff;
  --bg-soft: #f7f7f8;
  --card: #ffffff;
  --text: #1a1a1a;
  --muted: #6e6e73;
  --border: #e5e5e7;
  --accent: #111111;
  --accent-dark: #000000;
  --danger: #d64545;
}
* { box-sizing: border-box; }
html, body { overflow-x: clip; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}
.wrap { max-width: 1080px; margin: 0 auto; padding: 0 20px; }
header.top {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 0; border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; font-size: 20px; text-decoration: none; color: var(--text); }
.brand span { color: var(--accent); }
nav a { color: var(--muted); text-decoration: none; margin-left: 18px; font-size: 14px; }
nav a:hover { color: var(--text); }
.hero { text-align: center; padding: 72px 0 48px; }
.hero h1 { font-size: 40px; margin: 0 0 12px; letter-spacing: -0.5px; }
.hero p { color: var(--muted); font-size: 18px; margin: 0; }
.grid {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px; padding: 24px 0 72px;
}
@media (max-width: 900px) { .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } .hero h1 { font-size: 30px; } }
.card {
  background: var(--card); border: 1px solid var(--border); border-radius: 14px;
  padding: 22px; text-decoration: none; color: var(--text);
  transition: transform .15s ease, box-shadow .15s ease;
}
a.card:hover { transform: translateY(-3px); box-shadow: 0 8px 24px rgba(0,0,0,.08); }
.card h3 { margin: 0 0 6px; font-size: 17px; }
.card p { margin: 0; color: var(--muted); font-size: 14px; }
.card .go { display: inline-block; margin-top: 12px; color: var(--accent); font-size: 14px; font-weight: 600; }
footer { border-top: 1px solid var(--border); padding: 24px 0 40px; color: var(--muted); font-size: 13px; text-align: center; }
footer a { color: var(--muted); }

/* ---------- admin console (OpenAI-style) ---------- */
.console { display: flex; min-height: 100vh; }
.side {
  width: 250px; flex-shrink: 0; background: #fff;
  border-right: 1px solid var(--border);
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column;
  padding: 26px 14px 18px;
}
.side .brand { padding: 0 12px; margin-bottom: 30px; font-size: 19px; }
.side nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.side nav a {
  padding: 9px 12px; border-radius: 8px; color: var(--muted);
  text-decoration: none; font-size: 14px; font-weight: 500;
  transition: background .12s ease, color .12s ease;
}
.side nav a:hover { background: var(--bg-soft); color: var(--text); }
.side nav a.active { background: #ececec; color: var(--text); }
.side-foot { display: flex; flex-direction: column; gap: 2px; }
.side-link {
  padding: 9px 12px; border-radius: 8px; color: var(--muted);
  text-decoration: none; font-size: 14px; font-weight: 500;
  background: none; border: 0; text-align: left; cursor: pointer;
  font-family: inherit;
}
.side-link:hover { background: var(--bg-soft); color: var(--text); }
.main { flex: 1; min-width: 0; background: #fafafa; }
.main-inner { max-width: 1060px; margin: 0 auto; padding: 44px 36px 90px; }
.main.centered { display: flex; align-items: center; justify-content: center; }
.main.centered .main-inner { width: 100%; max-width: 420px; padding: 24px; }
.page-head { margin: 0 0 26px; }
.page-head h1 {
  margin: 0 0 6px; font-size: 30px; font-weight: 650;
  letter-spacing: -0.02em;
}
.login-box {
  background: #fff; border: 1px solid var(--border); border-radius: 16px;
  padding: 36px 34px; box-shadow: 0 1px 3px rgba(0,0,0,.05);
}
.login-box h2 {
  margin: 0 0 8px; font-size: 22px; font-weight: 650;
  letter-spacing: -0.015em;
}
.login-box .muted { margin: 0 0 18px; }
.login-box input {
  width: 100%; padding: 12px 14px; font-size: 15px;
  border: 1px solid var(--border); border-radius: 10px; margin-bottom: 12px;
  font-family: inherit; transition: border-color .12s ease, box-shadow .12s ease;
}
.login-box input:focus {
  outline: none; border-color: #111;
  box-shadow: 0 0 0 3px rgba(0,0,0,.06);
}
.login-box .btn { width: 100%; padding: 12px; font-size: 15px; }
.btn {
  display: inline-block; background: #111; color: #fff; border: 0;
  padding: 12px 22px; font-size: 15px; border-radius: 10px; cursor: pointer;
  font-weight: 600; font-family: inherit;
  transition: background .12s ease, transform .06s ease;
}
.btn:hover { background: #000; }
.btn:active { transform: scale(.985); }
.btn:disabled { opacity: .5; cursor: default; }
.err { color: var(--danger); font-size: 14px; min-height: 22px; margin: 10px 0 0; }
.stat-cards {
  display: grid; grid-template-columns: repeat(4, minmax(0,1fr));
  gap: 14px; margin: 0 0 8px;
}
.stat {
  background: #fff; border: 1px solid var(--border); border-radius: 14px;
  padding: 20px 20px 18px;
}
.stat .k {
  color: var(--muted); font-size: 12.5px; font-weight: 550;
  text-transform: uppercase; letter-spacing: .04em;
}
.stat .v {
  font-size: 30px; font-weight: 650; margin-top: 8px;
  letter-spacing: -0.02em; font-variant-numeric: tabular-nums;
}
section { margin-top: 44px; }
h2.sec {
  margin: 0 0 4px; font-size: 19px; font-weight: 650;
  letter-spacing: -0.015em;
}
section > .muted { margin: 0 0 14px; }
.muted { color: var(--muted); font-size: 13.5px; }
table.data {
  width: 100%; border-collapse: collapse; font-size: 14px;
  background: #fff; border: 1px solid var(--border); border-radius: 14px;
  overflow: hidden;
}
table.data th, table.data td {
  text-align: left; padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
table.data thead th {
  color: var(--muted); font-weight: 600; font-size: 12.5px;
  text-transform: uppercase; letter-spacing: .04em;
  background: #fafafa; border-bottom: 1px solid var(--border);
}
table.data tbody tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover td { background: #fafafa; }
table.data td.num, table.data th.num {
  text-align: right; font-variant-numeric: tabular-nums;
}
table.data td .muted { font-size: 13.5px; }
.url-cell {
  max-width: 260px; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; color: var(--muted);
}
@media (max-width: 860px) {
  .side {
    position: static; width: 100%; height: auto;
    border-right: 0; border-bottom: 1px solid var(--border);
    padding: 14px;
  }
  .side .brand { margin-bottom: 10px; }
  .side nav { flex-direction: row; overflow-x: auto; }
  .side nav a { white-space: nowrap; }
  .side-foot { flex-direction: row; }
  .console { flex-direction: column; }
  .main-inner { padding: 28px 18px 70px; }
  .stat-cards { grid-template-columns: repeat(2, minmax(0,1fr)); }
}

/* ---------- console v2: groups, settings, charts ---------- */
.side-group-title {
  font-size: 12px; font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: .06em;
  padding: 16px 12px 6px;
}
.lang-seg {
  display: flex; background: var(--bg-soft); border-radius: 10px;
  padding: 3px; margin: 0 0 8px;
}
.lang-seg button {
  flex: 1; border: 0; background: none; border-radius: 8px;
  padding: 7px 0; font-size: 13px; font-weight: 600; color: var(--muted);
  cursor: pointer; font-family: inherit;
}
.lang-seg button.on { background: #fff; color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.set-card {
  background: #fff; border: 1px solid var(--border); border-radius: 14px;
  overflow: hidden; max-width: 720px;
}
.set-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 18px 22px;
  border-bottom: 1px solid var(--border);
}
.set-row:last-child { border-bottom: 0; }
.set-label { font-size: 15px; font-weight: 550; }
.set-val { font-size: 14px; color: var(--muted); }
.seg {
  display: flex; background: var(--bg-soft); border-radius: 10px; padding: 3px;
}
.seg button {
  border: 0; background: none; border-radius: 8px;
  padding: 8px 18px; font-size: 14px; font-weight: 600; color: var(--muted);
  cursor: pointer; font-family: inherit;
}
.seg button.on { background: #fff; color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.chart {
  display: flex; align-items: flex-end; gap: 4px;
  height: 160px; background: #fff;
  border: 1px solid var(--border); border-radius: 14px;
  padding: 18px 18px 10px;
}
.chart .bar {
  flex: 1; min-width: 0; background: #111; border-radius: 3px 3px 0 0;
  opacity: .85;
}
.chart .bar:hover { opacity: 1; }
.chart-x {
  display: flex; justify-content: space-between;
  font-size: 12px; color: var(--muted); padding: 6px 4px 0;
}
a.row-link { color: var(--text); text-decoration: none; font-weight: 600; }
a.row-link:hover { text-decoration: underline; }

/* focus polish: replace default blue outline */
a:focus-visible, button:focus-visible, input:focus-visible {
  outline: 2px solid #111;
  outline-offset: 2px;
  border-radius: 6px;
}
.side nav a:focus-visible, .side-link:focus-visible { outline-offset: -2px; }

/* defensive: never let inputs inherit dark UA/autofill styling */
.login-box input {
  background: #fff !important;
  color: #111 !important;
  -webkit-text-fill-color: #111;
}
.login-box input::placeholder { color: #999; opacity: 1; }
.login-box input:-webkit-autofill {
  -webkit-box-shadow: 0 0 0 40px #fff inset;
  -webkit-text-fill-color: #111;
}
