:root {
  --bg0: #0f1412;
  --bg1: #171e1a;
  --ink: #e8efe9;
  --muted: #8a9a90;
  --line: #2a3530;
  --accent: #3dba7a;
  --accent-ink: #062214;
  --a: #5ec8ff;
  --b: #3dba7a;
  --acc: #e0b15b;
  --mono: "JetBrains Mono", ui-monospace, monospace;
  --sans: "DM Sans", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--sans);
  color: var(--ink);
  background: var(--bg0);
  line-height: 1.45;
}

.bg {
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(900px 480px at 12% -10%, rgba(61,186,122,.16), transparent 60%),
    radial-gradient(700px 420px at 100% 0%, rgba(90,140,120,.1), transparent 55%),
    linear-gradient(180deg, #121816, var(--bg0) 40%);
}

.top {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 18px 28px; border-bottom: 1px solid var(--line);
  backdrop-filter: blur(8px);
}
.brand { display: flex; gap: 12px; align-items: center; }
.brand .mark {
  width: 28px; height: 28px; border-radius: 8px;
  background: linear-gradient(135deg, #3dba7a, #1f6b48);
  box-shadow: 0 0 0 1px rgba(61,186,122,.35);
}
.brand strong { display: block; font-size: 15px; letter-spacing: .02em; }
.brand em { display: block; font-style: normal; color: var(--muted); font-size: 12px; }

nav { display: flex; gap: 6px; flex-wrap: wrap; }
.tab {
  appearance: none; border: 1px solid transparent; background: transparent;
  color: var(--muted); font: 500 13px/1 var(--sans);
  padding: 8px 12px; border-radius: 8px; cursor: pointer;
}
.tab:hover { color: var(--ink); }
.tab.on { color: var(--ink); border-color: var(--line); background: var(--bg1); }

main { max-width: 1040px; margin: 0 auto; padding: 36px 20px 64px; }
.panel { display: none; animation: in .25s ease; }
.panel.on { display: block; }
@keyframes in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

h1 { font-size: 28px; font-weight: 600; margin: 0 0 8px; letter-spacing: -.02em; }
h2 { font-size: 15px; font-weight: 600; margin: 0 0 12px; color: var(--muted); }
.lead { color: var(--muted); margin: 0 0 28px; font-size: 14px; }
.lead code, footer code {
  font-family: var(--mono); font-size: 12px;
  background: rgba(255,255,255,.04); padding: 2px 6px; border-radius: 4px;
}

.form { display: grid; gap: 16px; max-width: 720px; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 720px) { .row { grid-template-columns: 1fr; } }

label > span {
  display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px;
}
input[type=text], input[type=password], select {
  width: 100%; appearance: none;
  background: var(--bg1); color: var(--ink);
  border: 1px solid var(--line); border-radius: 10px;
  padding: 11px 12px; font: 400 14px/1.2 var(--sans);
}
input:focus, select:focus { outline: none; border-color: rgba(61,186,122,.55); }
.country-box { display: grid; gap: 8px; }
.field-label { font-size: 12px; color: var(--muted); }
.combo { position: relative; }
.combo-trigger {
  width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 10px;
  appearance: none; cursor: pointer; text-align: left;
  background: var(--bg1); color: var(--ink);
  border: 1px solid var(--line); border-radius: 10px;
  padding: 11px 12px; font: 400 14px/1.2 var(--sans);
}
.combo-trigger:hover { border-color: rgba(61,186,122,.4); }
.combo.open .combo-trigger { border-color: rgba(61,186,122,.55); }
.combo-trigger .chev { color: var(--muted); flex: 0 0 auto; transition: transform .15s ease; }
.combo.open .combo-trigger .chev { transform: rotate(180deg); }
.combo-trigger #countryTriggerText { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.combo-trigger #countryTriggerText.is-placeholder { color: var(--muted); }

.combo-panel {
  position: absolute; z-index: 30; left: 0; right: 0; top: calc(100% + 6px);
  background: #121816; border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 16px 40px rgba(0,0,0,.45); padding: 10px;
  display: grid; gap: 8px;
}
.combo-panel[hidden] { display: none; }
#countrySearch {
  width: 100%; appearance: none;
  background: var(--bg1); color: var(--ink);
  border: 1px solid var(--line); border-radius: 8px;
  padding: 10px 11px; font: 400 13px/1.2 var(--sans);
}
#countrySearch:focus { outline: none; border-color: rgba(61,186,122,.55); }
.combo-list {
  max-height: 260px; overflow: auto; display: grid; gap: 2px;
  border-radius: 8px;
}
.combo-item {
  appearance: none; border: 0; background: transparent; color: var(--ink);
  text-align: left; padding: 10px 11px; border-radius: 8px; cursor: pointer;
  font: 400 13px/1.35 var(--sans);
}
.combo-item:hover, .combo-item.active { background: rgba(61,186,122,.12); }
.combo-item .code { color: var(--muted); font-family: var(--mono); font-size: 11px; margin-left: 6px; }
.combo-item .hint { display: block; color: var(--muted); font-size: 11px; margin-top: 2px; font-family: var(--mono); }
.combo-empty { padding: 16px 11px; color: var(--muted); font-size: 13px; text-align: center; }
.country-meta { font-size: 12px; color: var(--muted); padding: 0 2px 2px; }

.drop {
  display: flex; align-items: center; justify-content: center; text-align: center;
  min-height: 140px; border: 1px dashed #3a4a41; border-radius: 14px;
  background: rgba(255,255,255,.02); cursor: pointer; padding: 20px;
  transition: border-color .15s, background .15s;
}
.drop:hover, .drop.drag {
  border-color: rgba(61,186,122,.6); background: rgba(61,186,122,.05);
}
.drop strong { display: block; font-size: 15px; margin-bottom: 4px; }
.drop span { color: var(--muted); font-size: 12px; }
.icon-drop { min-height: 96px; }
.icon-row { display: flex; align-items: center; gap: 14px; text-align: left; }
#iconPreview {
  width: 56px; height: 56px; border-radius: 12px; object-fit: cover;
  background: #0c100e; border: 1px solid var(--line); flex: 0 0 auto;
}

.checks { display: flex; flex-wrap: wrap; gap: 14px 20px; }
.check {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--muted); cursor: pointer;
}
.check input { accent-color: var(--accent); }

.btn {
  appearance: none; border: 0; border-radius: 10px;
  font: 600 14px/1 var(--sans); padding: 12px 16px; cursor: pointer;
  width: fit-content;
}
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.primary:disabled { opacity: .5; cursor: wait; }
.btn.ghost {
  background: transparent; color: var(--ink);
  border: 1px solid var(--line); padding: 10px 12px;
}
.btn.ghost:hover { border-color: rgba(61,186,122,.45); }

.out {
  margin-top: 20px; padding: 14px 16px; border-radius: 12px;
  background: #0c100e; border: 1px solid var(--line);
  color: #b7d0c0; font: 400 12px/1.55 var(--mono);
  white-space: pre-wrap; word-break: break-all; max-height: 360px; overflow: auto;
  max-width: 720px;
}

.stats-head {
  display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  align-items: flex-start; margin-bottom: 8px;
}
.stats-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.stats-actions select { width: auto; min-width: 160px; }

.kpi {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px;
  margin: 8px 0 24px;
}
@media (max-width: 800px) { .kpi { grid-template-columns: 1fr; } }
.kpi .card {
  background: var(--bg1); border: 1px solid var(--line); border-radius: 14px;
  padding: 16px 18px;
}
.kpi .card span { display: block; color: var(--muted); font-size: 12px; margin-bottom: 8px; }
.kpi .card b { font-size: 28px; font-weight: 600; letter-spacing: -.02em; }
.kpi .card small { display: block; margin-top: 6px; color: var(--muted); font-size: 12px; }

.chart-wrap {
  background: var(--bg1); border: 1px solid var(--line); border-radius: 14px;
  padding: 16px 18px 14px; margin-bottom: 24px;
}
.bars {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 10px;
  align-items: end; height: 160px; margin: 8px 0 10px;
}
.bar-col { display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.bar-stack { display: flex; align-items: flex-end; gap: 3px; height: 100%; width: 100%; justify-content: center; }
.bar-stack i {
  display: block; width: 10px; border-radius: 4px 4px 2px 2px; min-height: 2px;
}
.bar-stack i.a { background: var(--a); }
.bar-stack i.b { background: var(--b); }
.bar-stack i.acc { background: var(--acc); }
.bar-col em { font-style: normal; font-size: 10px; color: var(--muted); font-family: var(--mono); }

.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); }
.legend i {
  display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px;
}
.legend i.a { background: var(--a); }
.legend i.b { background: var(--b); }
.legend i.acc { background: var(--acc); }

.split {
  display: grid; grid-template-columns: 1.6fr .9fr; gap: 18px;
}
@media (max-width: 900px) { .split { grid-template-columns: 1fr; } }

.table-wrap {
  overflow: auto; border: 1px solid var(--line); border-radius: 12px; background: var(--bg1);
}
table { width: 100%; border-collapse: collapse; font-size: 12px; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-weight: 500; background: rgba(0,0,0,.15); }
td { font-family: var(--mono); color: #c5d8cb; }
tr:last-child td { border-bottom: 0; }
.ok { color: var(--accent); }
.no { color: var(--muted); }

.clist { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: 12px; background: var(--bg1); }
.clist li {
  display: flex; justify-content: space-between; gap: 10px;
  padding: 10px 12px; border-bottom: 1px solid var(--line); font-size: 13px;
}
.clist li:last-child { border-bottom: 0; }
.clist .muted { color: var(--muted); font-family: var(--mono); font-size: 12px; overflow: hidden; text-overflow: ellipsis; }

footer {
  border-top: 1px solid var(--line); padding: 16px 28px;
  color: var(--muted); font-size: 12px;
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
}

.login-body { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card {
  width: min(420px, 100%);
  background: rgba(23,30,26,.92);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 28px 24px 24px;
  box-shadow: 0 24px 60px rgba(0,0,0,.35);
}
.login-brand { margin-bottom: 18px; }
.login-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.login-actions .btn { flex: 1; justify-content: center; text-align: center; }
.top-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.top-right .who { font-size: 12px; color: var(--muted); }
.top-right a.btn { text-decoration: none; display: inline-flex; align-items: center; }

.result-card {
  margin-top: 20px; padding: 18px; border-radius: 14px;
  background: var(--bg1); border: 1px solid rgba(61,186,122,.35);
  max-width: 920px;
}
.result-card h3 { margin: 0 0 12px; font-size: 16px; }
.result-grid {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 14px;
}
@media (max-width: 800px) { .result-grid { grid-template-columns: 1fr 1fr; } }
.result-grid span, .result-links span {
  display: block; color: var(--muted); font-size: 12px; margin-bottom: 4px;
}
.result-grid b { font-size: 13px; font-weight: 600; word-break: break-all; }
.result-links { display: grid; gap: 10px; }
.result-links .link, table .link {
  color: var(--accent); word-break: break-all; font-family: var(--mono); font-size: 12px;
}
.muted-note { margin: 12px 0 0; color: var(--muted); font-size: 12px; }
td.clip { max-width: 220px; }
.btn-del, .btn-copy { padding: 6px 10px !important; font-size: 12px !important; white-space: nowrap; }
.btn-copy.copied { color: var(--accent); border-color: rgba(61,186,122,.5); }

.qr-thumb {
  appearance: none; border: 1px solid var(--line); background: #fff;
  border-radius: 8px; padding: 4px; cursor: zoom-in; line-height: 0;
  display: inline-flex; vertical-align: middle;
}
.qr-thumb:hover { border-color: rgba(61,186,122,.55); }
.qr-thumb .qr-box,
.qr-thumb .qr-box img,
.qr-thumb .qr-box canvas,
.qr-thumb .qr-box table {
  width: 44px !important; height: 44px !important;
  display: block;
}
.qr-thumb .qr-box table { border-collapse: collapse; }
.dl-cell { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.qr-modal {
  position: fixed; inset: 0; z-index: 80;
  display: grid; place-items: center; padding: 24px;
}
.qr-modal[hidden] { display: none !important; }
.qr-modal-backdrop {
  position: absolute; inset: 0; background: rgba(0,0,0,.62);
  backdrop-filter: blur(2px);
}
.qr-modal-card {
  position: relative; z-index: 1;
  background: #fff; color: #111; border-radius: 16px;
  padding: 22px 22px 16px; text-align: center;
  box-shadow: 0 24px 60px rgba(0,0,0,.45);
}
.qr-modal-host {
  width: 280px; height: 280px; margin: 0 auto;
  display: grid; place-items: center;
}
.qr-modal-host img,
.qr-modal-host canvas,
.qr-modal-host table {
  width: 280px !important; height: 280px !important;
}
#qrModalHint { margin: 12px 0 0; font-size: 13px; color: #666; }
