:root {
  --bg: #f6f7fb;
  --panel: #ffffff;
  --text: #172033;
  --muted: #687188;
  --line: #dfe4ee;
  --primary: #146c63;
  --primary-dark: #0d4c46;
  --accent: #e6b450;
  --bad: #c0392b;
  --warn: #9a6b00;
  --ok: #167a44;
  --shadow: 0 18px 45px rgba(31, 38, 62, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    linear-gradient(135deg, rgba(20, 108, 99, 0.09), transparent 30%),
    linear-gradient(315deg, rgba(230, 180, 80, 0.13), transparent 28%),
    var(--bg);
}

button,
input,
textarea,
select {
  font: inherit;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
  padding: 0 clamp(16px, 4vw, 48px);
  border-bottom: 1px solid rgba(223, 228, 238, 0.82);
  background: rgba(246, 247, 251, 0.86);
  backdrop-filter: blur(18px);
}

.brand {
  color: var(--text);
  font-size: 18px;
  font-weight: 800;
  text-decoration: none;
}

nav {
  display: flex;
  align-items: center;
  gap: 18px;
}

nav a,
.link-button {
  border: 0;
  padding: 0;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  font-weight: 650;
  text-decoration: none;
}

.shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 56px;
}

.hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 174px;
  margin-bottom: 22px;
  gap: 24px;
}

.hero.compact {
  min-height: 112px;
}

.hero h1 {
  max-width: 720px;
  margin: 8px 0 0;
  font-size: clamp(28px, 4vw, 48px);
  line-height: 1.12;
  letter-spacing: 0;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.eyebrow {
  margin: 0;
  color: var(--primary);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.hero-art {
  position: relative;
  flex: 0 0 min(270px, 32vw);
  aspect-ratio: 4 / 3;
}

.hero-art span {
  position: absolute;
  display: block;
  border: 1px solid rgba(20, 108, 99, 0.25);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.76);
  box-shadow: var(--shadow);
}

.hero-art span:nth-child(1) {
  inset: 14% 8% 14% 18%;
}

.hero-art span:nth-child(2) {
  inset: 26% 24% 34% 4%;
  background: rgba(230, 180, 80, 0.2);
}

.hero-art span:nth-child(3) {
  inset: 42% 3% 18% 48%;
  background: rgba(20, 108, 99, 0.16);
}

.grid,
.admin-grid {
  display: grid;
  grid-template-columns: minmax(320px, 0.92fr) minmax(420px, 1.08fr);
  gap: 18px;
}

.recharge-layout {
  display: grid;
  grid-template-columns: minmax(320px, 760px);
}

.query-layout {
  display: grid;
  grid-template-columns: minmax(320px, 0.85fr) minmax(420px, 1.15fr);
  gap: 18px;
}

.admin-grid {
  grid-template-columns: 360px minmax(0, 1fr);
}

.panel {
  min-width: 0;
  padding: 22px;
  border: 1px solid rgba(223, 228, 238, 0.92);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 12px 32px rgba(31, 38, 62, 0.08);
}

.wide {
  min-width: 0;
}

.full {
  grid-column: 1 / -1;
}

.login-panel {
  max-width: 460px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

h2 {
  margin: 4px 0 0;
  font-size: 22px;
  letter-spacing: 0;
}

label {
  display: grid;
  gap: 8px;
  margin: 14px 0;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.guide {
  display: grid;
  gap: 10px;
  margin: 0 0 18px;
  padding: 0;
  list-style: none;
}

.guide li {
  display: grid;
  grid-template-columns: 30px 1fr;
  gap: 10px;
  align-items: start;
  border: 1px solid rgba(223, 228, 238, 0.9);
  border-radius: 8px;
  padding: 10px;
  background: #fafbfe;
}

.guide span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 999px;
  color: #fff;
  background: var(--primary);
  font-size: 13px;
  font-weight: 850;
}

.guide p {
  margin: 4px 0 0;
  color: var(--text);
  line-height: 1.55;
  font-size: 14px;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 12px;
  color: var(--text);
  background: #fff;
  outline: none;
}

textarea {
  resize: vertical;
  min-height: 110px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(20, 108, 99, 0.12);
}

input:disabled,
textarea:disabled,
button:disabled {
  opacity: 0.58;
  cursor: not-allowed;
}

button {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  padding: 0 16px;
  cursor: pointer;
  font-weight: 800;
}

.primary {
  color: #fff;
  background: var(--primary);
}

.primary:hover {
  background: var(--primary-dark);
}

.secondary {
  border: 1px solid var(--line);
  color: var(--text);
  background: #fff;
}

.button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  border-radius: 8px;
  padding: 0 12px;
  font-weight: 800;
  text-decoration: none;
  white-space: nowrap;
}

.token-action {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 16px 0 10px;
  border: 1px solid rgba(20, 108, 99, 0.18);
  border-radius: 8px;
  padding: 12px;
  background: rgba(20, 108, 99, 0.06);
}

.token-action div {
  display: grid;
  gap: 4px;
}

.token-action strong {
  font-size: 14px;
}

.token-action small {
  color: var(--muted);
  line-height: 1.4;
}

.switch-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 12px 0;
  color: var(--text);
  font-weight: 750;
}

.switch-row input {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--primary);
  box-shadow: none;
}

.rule-box {
  display: grid;
  gap: 2px;
  margin: 16px 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fafbfe;
}

.danger {
  border: 1px solid rgba(192, 57, 43, 0.35);
  color: var(--bad);
  background: #fff;
}

.compact-button {
  min-height: 34px;
  padding: 0 10px;
  white-space: nowrap;
}

.icon-button {
  width: 36px;
  min-height: 36px;
  padding: 0;
  color: var(--muted);
  background: transparent;
  font-size: 24px;
}

.badge,
.status {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 0 10px;
  color: var(--muted);
  background: #eef1f6;
  font-size: 12px;
  font-weight: 850;
}

.badge.ok,
.status.success,
.message.ok {
  color: var(--ok);
}

.badge.bad,
.status.failed,
.message.bad {
  color: var(--bad);
}

.badge.warn,
.status.pending {
  color: var(--warn);
}

.status.unused {
  color: var(--primary);
}

.status.disabled,
.status.missing {
  color: var(--muted);
}

.message {
  min-height: 22px;
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.result {
  display: grid;
  gap: 5px;
  min-height: 84px;
  margin: 14px 0 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  color: var(--muted);
  background: #fafbfe;
}

.result strong {
  color: var(--text);
  font-size: 24px;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.table-wrap.tall {
  max-height: 520px;
}

.query-table {
  margin-top: 14px;
}

table {
  width: 100%;
  min-width: 620px;
  border-collapse: collapse;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 10px;
  text-align: left;
  vertical-align: middle;
  font-size: 14px;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  color: var(--muted);
  background: #f8f9fc;
  font-size: 12px;
}

td {
  background: #fff;
}

.inline-note {
  min-width: 180px;
  padding: 8px;
}

.actions {
  display: flex;
  gap: 8px;
}

.hidden {
  display: none !important;
}

dialog {
  width: min(760px, calc(100% - 28px));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 22px;
  box-shadow: var(--shadow);
}

dialog::backdrop {
  background: rgba(23, 32, 51, 0.42);
}

pre {
  max-height: 60vh;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fafbfe;
  white-space: pre-wrap;
  word-break: break-word;
}

.backup-panel .muted {
  color: var(--muted);
  line-height: 1.6;
}

.backup-panel button,
.backup-panel label {
  margin-top: 12px;
}

@media (max-width: 880px) {
  .hero {
    align-items: flex-start;
  }

  .hero-art {
    display: none;
  }

  .grid,
  .query-layout,
  .admin-grid {
    grid-template-columns: 1fr;
  }

  .full {
    grid-column: auto;
  }
}

@media (max-width: 560px) {
  .topbar {
    height: auto;
    min-height: 64px;
    align-items: flex-start;
    flex-direction: column;
    justify-content: center;
    gap: 10px;
    padding-top: 12px;
    padding-bottom: 12px;
  }

  nav {
    gap: 14px;
    flex-wrap: wrap;
  }

  .shell {
    width: min(100% - 20px, 1180px);
    padding-top: 18px;
  }

  .hero h1 {
    font-size: 30px;
  }

  .panel {
    padding: 16px;
  }

  .token-action {
    align-items: stretch;
    flex-direction: column;
  }

  .button-link {
    width: 100%;
  }
}
