/* ============================================================
   LitMatch Proxy UI — bright, modern light theme
   Typeface: Plus Jakarta Sans (everything)
   NOTE: all original selectors/class names preserved — JS depends on them.
   ============================================================ */

:root {
  /* Surfaces */
  --bg: #eef1f8;
  --surface: #ffffff;
  --surface-2: #f4f6fc;     /* insets / chips */

  /* Ink */
  --text: #131a2b;
  --muted: #66718a;
  --faint: #9aa3b6;

  /* Brand / accent */
  --accent: #4f46e5;        /* indigo */
  --accent-600: #4035c4;
  --accent-soft: #ecebfe;

  /* Gem accents */
  --diamond: #0ea5e9;       /* Kim cương */
  --diamond-soft: #e2f4fd;
  --star: #f59e0b;          /* Sao */
  --star-soft: #fdf1da;

  /* Status */
  --ok: #0ea66b;
  --ok-soft: #e3f6ee;
  --fail: #e11d48;
  --fail-soft: #fde7ec;

  /* Lines & elevation */
  --border: #e6eaf3;
  --border-strong: #d7dded;
  --ring: rgba(79, 70, 229, .16);
  --shadow-sm: 0 1px 2px rgba(20, 27, 45, .04), 0 2px 4px rgba(20, 27, 45, .05);
  --shadow-md: 0 8px 20px rgba(22, 30, 54, .08), 0 2px 6px rgba(22, 30, 54, .05);
  --shadow-lg: 0 20px 44px rgba(26, 34, 62, .14), 0 6px 14px rgba(26, 34, 62, .07);

  --radius: 16px;
  --radius-sm: 11px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background-color: var(--bg);
  background-image:
    radial-gradient(55rem 55rem at 10% -12%, rgba(79, 70, 229, .12), transparent 55%),
    radial-gradient(45rem 45rem at 102% -4%, rgba(14, 165, 233, .12), transparent 52%),
    radial-gradient(42rem 42rem at 52% 118%, rgba(245, 158, 11, .09), transparent 52%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

code, input, select, button, textarea { font-family: inherit; }
::selection { background: var(--accent-soft); color: var(--accent-600); }

/* ---------- Nav ---------- */
.nav {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 6px;
  padding: 13px clamp(16px, 4vw, 40px);
  background: rgba(255, 255, 255, .72);
  backdrop-filter: saturate(170%) blur(14px);
  -webkit-backdrop-filter: saturate(170%) blur(14px);
  border-bottom: 1px solid var(--border);
}
.nav .brand {
  display: inline-flex; align-items: center; gap: 10px;
  font-weight: 800; font-size: 16px; letter-spacing: -.02em; margin-right: 14px;
}
.nav .brand::before {
  content: ""; width: 18px; height: 18px; border-radius: 7px;
  background: conic-gradient(from 210deg, var(--accent), var(--diamond), var(--star), var(--accent));
  box-shadow: 0 3px 9px rgba(79, 70, 229, .42);
}
.nav a {
  color: var(--muted); text-decoration: none; font-weight: 600; font-size: 14px;
  padding: 8px 14px; border-radius: 999px; transition: color .18s ease, background .18s ease;
}
.nav a:hover { color: var(--text); background: var(--surface-2); }
.nav a.active { color: var(--accent); background: var(--accent-soft); }

/* ---------- Layout ---------- */
main {
  max-width: 1080px; margin: clamp(20px, 4vw, 40px) auto;
  padding: 0 clamp(16px, 4vw, 40px); animation: rise .5s ease both;
}
h1 { margin: 0; font-size: clamp(21px, 3vw, 27px); font-weight: 800; letter-spacing: -.025em; }
h2 { font-weight: 800; letter-spacing: -.02em; }
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; }

.muted { color: var(--muted); font-size: 13px; }
.error { color: var(--fail); font-size: 13.5px; font-weight: 500; }

/* ---------- Controls ---------- */
input, select { font: inherit; }
input, select {
  width: 100%; padding: 11px 13px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  transition: border-color .15s ease, box-shadow .15s ease;
}
input::placeholder { color: var(--faint); }
input:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--ring); }

button {
  font: inherit; cursor: pointer; font-weight: 700; letter-spacing: -.01em;
  padding: 11px 18px; border-radius: var(--radius-sm); border: 1px solid transparent;
  background: linear-gradient(180deg, #5a51ea, var(--accent)); color: #fff;
  box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255, 255, 255, .2);
  transition: transform .12s ease, box-shadow .18s ease, background .18s ease, opacity .18s ease;
}
button:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); background: linear-gradient(180deg, #5048e3, var(--accent-600)); }
button:active { transform: translateY(0); box-shadow: var(--shadow-sm); }
button:disabled { opacity: .45; cursor: not-allowed; transform: none; box-shadow: none; }

button.copy, button.retry {
  background: var(--surface); color: var(--muted); border-color: var(--border-strong);
  box-shadow: none; padding: 6px 12px; font-size: 12.5px; font-weight: 600; border-radius: 999px;
}
button.copy:hover, button.retry:hover {
  color: var(--accent); border-color: var(--accent); background: var(--accent-soft); transform: translateY(-1px);
}

/* ---------- Gate ---------- */
.gate {
  display: flex; flex-direction: column; gap: 14px; align-items: stretch;
  max-width: 400px; margin: clamp(44px, 9vh, 92px) auto; padding: 28px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-lg); animation: rise .5s ease both;
}
.gate h2 { margin: 0; font-size: 19px; display: flex; align-items: center; gap: 10px; }
.gate h2::before { content: "🔑"; font-size: 18px; }
.gate input { width: 100%; }

/* ---------- Route 1: cards ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 18px; margin-top: 22px; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow-sm); animation: cardIn .35s ease both;
  transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
}
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); border-color: var(--border-strong); }
.card-head { border-bottom: 1px solid var(--border); padding-bottom: 14px; margin-bottom: 14px; }
.agent-id { font-weight: 800; font-size: 17px; letter-spacing: -.02em; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.zone {
  color: var(--accent); font-weight: 700; font-size: 10.5px; letter-spacing: .04em; text-transform: uppercase;
  background: var(--accent-soft); padding: 3px 9px; border-radius: 999px;
}
.secret { display: flex; align-items: center; gap: 8px; margin-top: 12px; }
.secret code {
  flex: 1; font-size: 11.5px; letter-spacing: .02em; word-break: break-all; color: var(--muted);
  background: var(--surface-2); border: 1px solid var(--border); padding: 7px 10px; border-radius: 8px;
}

.card-body.loading, .card-body.error {
  display: flex; align-items: center; gap: 10px; padding: 8px 0; font-size: 14px; color: var(--muted);
}
.card-body.loading::before {
  content: ""; width: 16px; height: 16px; border-radius: 50%; flex: none;
  border: 2px solid var(--border-strong); border-top-color: var(--accent); animation: spin .7s linear infinite;
}
.card-body.error { color: var(--fail); justify-content: space-between; }

.bal { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 6px 0; font-size: 14px; }
.bal span { color: var(--muted); display: inline-flex; align-items: center; }
.bal b { font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }

/* Hero balances: Kim cương (1st row) + Sao (2nd row) get gem colours */
.card-body .bal:nth-child(1) span::before,
.card-body .bal:nth-child(2) span::before {
  content: ""; width: 8px; height: 8px; border-radius: 50%; margin-right: 9px;
}
.card-body .bal:nth-child(1) span::before { background: var(--diamond); box-shadow: 0 0 0 3px var(--diamond-soft); }
.card-body .bal:nth-child(2) span::before { background: var(--star); box-shadow: 0 0 0 3px var(--star-soft); }
.card-body .bal:nth-child(1) b { color: var(--diamond); font-size: 17px; }
.card-body .bal:nth-child(2) b { color: var(--star); font-size: 17px; }
.card-body .bal:nth-child(2) { margin-bottom: 8px; padding-bottom: 12px; border-bottom: 1px dashed var(--border); }

/* ---------- Route 2: form ---------- */
.form {
  display: flex; flex-direction: column; gap: 18px; max-width: 520px; margin-top: 22px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 24px; box-shadow: var(--shadow-md);
}
.form > label, fieldset > label {
  display: flex; flex-direction: column; gap: 7px; font-weight: 600; font-size: 13.5px; color: var(--text);
}
.form .row { flex-direction: row; display: flex; gap: 10px; }
.form .row input { flex: 1; }
.form .row button { white-space: nowrap; }

fieldset {
  border: 1px solid var(--border); border-radius: var(--radius-sm); margin: 0; padding: 18px;
  display: flex; flex-direction: column; gap: 16px; background: var(--surface-2);
  transition: opacity .2s ease;
}
fieldset[disabled] { opacity: .5; }

.target-card {
  display: flex; align-items: center; gap: 14px; padding: 14px;
  background: linear-gradient(180deg, var(--accent-soft), var(--surface));
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm); animation: cardIn .3s ease both;
}
.target-card .avatar { width: 48px; height: 48px; border-radius: 50%; object-fit: cover; border: 2px solid #fff; box-shadow: var(--shadow-sm); }
.target-card b { font-weight: 800; letter-spacing: -.01em; }

.result {
  margin-top: 18px; padding: 16px 18px; border-radius: var(--radius-sm); line-height: 1.45;
  border: 1px solid var(--border); background: var(--surface); box-shadow: var(--shadow-sm);
  animation: rise .3s ease both;
}
.result b { font-weight: 800; }
.result .muted { color: inherit; opacity: .72; }
.result.ok { border-color: rgba(14, 166, 107, .35); background: var(--ok-soft); color: #075e40; }
.result.fail { border-color: rgba(225, 29, 72, .30); background: var(--fail-soft); color: #9f1239; }

/* ---------- Motion ---------- */
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes cardIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
