:root{
  --bg: #0b1020;
  --bg2:#0e1630;
  --text:#e8eeff;
  --muted:#a9b4da;
  --border: rgba(255,255,255,.10);
  --shadow: 0 20px 50px rgba(0,0,0,.35);

  --primary:#6ea8ff;
  --danger:#ff5b7a;

  --ok:#3ddc97;
  --mismatch:#ffb020;
  --warn:#7aa6ff;
  --error:#ff5b7a;

  --radius: 18px;
  color-scheme: dark;
}

:root[data-theme="light"]{
  --bg: #f5f7ff;
  --bg2:#eef2ff;
  --text:#111827;
  --muted:#5b6478;
  --border: rgba(17,24,39,.12);
  --shadow: 0 18px 40px rgba(17,24,39,.12);

  --primary:#2f6cff;
  --danger:#e11d48;

  --ok:#16a34a;
  --mismatch:#f59e0b;
  --warn:#2563eb;
  --error:#e11d48;

  color-scheme: light;
}

*{ box-sizing: border-box; }
html,body{ height:100%; }

body{
  margin:0;
  background: radial-gradient(1200px 700px at 10% 10%, var(--bg2), transparent 60%),
              radial-gradient(900px 600px at 90% 0%, rgba(110,168,255,.18), transparent 55%),
              radial-gradient(900px 600px at 0% 100%, rgba(61,220,151,.10), transparent 55%),
              var(--bg);
  color: var(--text);
  font-family: "Vazirmatn", ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial;
  line-height: 1.6;
}

code{
  background: rgba(255,255,255,.06);
  border: 1px solid var(--border);
  padding:.1rem .35rem;
  border-radius: 10px;
}

.ltr{ direction:ltr; unicode-bidi: plaintext; }

/* Topbar */
.topbar{
  position: sticky;
  top:0;
  z-index: 30;
  display:flex;
  align-items:center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  background: rgba(10,16,32,.72);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
:root[data-theme="light"] .topbar{ background: rgba(245,247,255,.72); }

.brand{ display:flex; align-items:center; gap: 12px; }
.logo{
  width: 44px;
  height: 44px;
  border-radius: 16px;
  display:grid;
  place-items:center;
  font-weight: 800;
  background: linear-gradient(135deg, rgba(110,168,255,.28), rgba(61,220,151,.20));
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.brand-text .title{ font-weight: 800; font-size: 1.05rem; }
.brand-text .subtitle{ color: var(--muted); font-size: .85rem; margin-top: 2px; }

.top-actions{ display:flex; align-items:center; gap: 10px; }

.ipcard{
  display:flex;
  align-items:center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,.05);
}
:root[data-theme="light"] .ipcard{ background: rgba(17,24,39,.03); }
.ipcard-label{ color: var(--muted); font-size: .82rem; }
.ipcard-value{ font-weight: 700; }

.wrap{ max-width: 1100px; margin: 18px auto 40px; padding: 0 14px; }

/* Alerts */
.alerts{ margin: 10px 0 16px; display:flex; flex-direction:column; gap: 10px; }
.alert{
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid var(--border);
}
.alert-danger{ background: rgba(255, 91, 122, .10); }
.alert-info{ background: rgba(110,168,255,.10); }

/* Cards */
.card{
  border: 1px solid var(--border);
  background: rgba(255,255,255,.04);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow:hidden;
}
:root[data-theme="light"] .card{ background: rgba(255,255,255,.85); }

.card-head{
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--border);
}
.card-title{ font-weight: 800; font-size: 1rem; }
.card-sub{ margin-top: 4px; color: var(--muted); font-size: .86rem; }
.dot{ margin: 0 8px; opacity: .7; }

/* Hero center */
.hero{ display:flex; justify-content:center; }
.hero-card{ width: min(900px, 100%); }
.hero-head{ text-align:center; }
.hero-form{ padding: 16px; }
.hero-grid{
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
@media (max-width: 760px){
  .hero-grid{ grid-template-columns: 1fr; }
}

/* Form */
.form{ display:flex; flex-direction:column; gap: 12px; }

.field{ display:flex; flex-direction:column; gap: 6px; }
.field-row{ display:flex; flex-direction:column; gap: 4px; }
.field-label{ font-weight: 700; }
.field-hint{ color: var(--muted); font-size: .82rem; }

.input{
  width: 100%;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: rgba(0,0,0,.14);
  color: var(--text);
  padding: 12px 12px;
  outline: none;
}
:root[data-theme="light"] .input{ background: rgba(17,24,39,.04); }
.input:focus{
  border-color: rgba(110,168,255,.55);
  box-shadow: 0 0 0 4px rgba(110,168,255,.18);
}

/* Segmented */
.segmented{
  display:flex;
  flex-wrap: wrap;
  gap: 8px;
}
.seg{
  position: relative;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  padding: 10px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,.04);
  cursor:pointer;
  user-select:none;
  font-weight: 800;
  font-size: .88rem;
}
.seg input{ position:absolute; inset:0; opacity:0; cursor:pointer; }
.seg:has(input:checked){
  background: rgba(110,168,255,.22);
  border-color: rgba(110,168,255,.55);
}

/* Buttons */
.btn{
  border: 1px solid var(--border);
  background: rgba(255,255,255,.06);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 14px;
  cursor:pointer;
  font-weight: 800;
  display:inline-flex;
  align-items:center;
  gap: 8px;
}
.btn:disabled{ opacity:.55; cursor:not-allowed; }
.btn:hover{ transform: translateY(-1px); }
.btn:active{ transform: translateY(0); }

.btn-primary{
  background: rgba(110,168,255,.22);
  border-color: rgba(110,168,255,.55);
}
.btn-danger{
  background: rgba(255,91,122,.12);
  border-color: rgba(255,91,122,.45);
}
.btn-ghost{
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  padding: 8px 10px;
  border-radius: 12px;
  cursor:pointer;
  font-weight: 800;
}
.btn-ghost:hover{ background: rgba(255,255,255,.06); }

.form-actions{ display:flex; gap: 10px; flex-wrap: wrap; }
.center-actions{ justify-content:center; }

.note{
  border: 1px dashed var(--border);
  border-radius: 16px;
  padding: 12px;
  background: rgba(255,255,255,.03);
}
.note-title{ font-weight: 800; }
.note-text{ color: var(--muted); font-size: .9rem; margin-top: 4px; }

/* Results */
.results{ margin-top: 14px; }

.pill{
  display:inline-flex;
  padding: 2px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,.04);
  font-weight: 800;
  direction:ltr;
  unicode-bidi: plaintext;
}

/* Progress */
.progress-wrap{ padding: 12px 16px 0; }
.segbar{
  height: 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  overflow:hidden;
  display:flex;
  background: rgba(255,255,255,.03);
}
.segbar > div{ height: 100%; width: 0%; transition: width .25s ease; }
.segbar-ok{ background: rgba(61,220,151,.9); }
.segbar-mismatch{ background: rgba(255,176,32,.9); }
.segbar-warn{ background: rgba(122,166,255,.9); }
.segbar-error{ background: rgba(255,91,122,.92); }

.legend{
  display:flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 10px;
  color: var(--muted);
  font-weight: 700;
  font-size: .86rem;
}
.legend-item{ display:flex; align-items:center; gap: 8px; }
.lg{ width: 10px; height: 10px; border-radius: 99px; display:inline-block; }
.lg.ok{ background: rgba(61,220,151,.9); }
.lg.mismatch{ background: rgba(255,176,32,.9); }
.lg.warn{ background: rgba(122,166,255,.9); }
.lg.error{ background: rgba(255,91,122,.9); }

/* Filters */
.filters-row{ padding: 8px 16px 0; }
.chips{ display:flex; flex-wrap: wrap; gap: 8px; }
.chip{
  border: 1px solid var(--border);
  background: rgba(255,255,255,.04);
  color: var(--text);
  padding: 8px 12px;
  border-radius: 999px;
  cursor:pointer;
  font-weight: 900;
  font-size: .86rem;
}
.chip.is-active{
  background: rgba(61,220,151,.14);
  border-color: rgba(61,220,151,.38);
}

/* Table */
.table-wrap{ overflow:auto; padding: 8px 16px 16px; }
.results-table{ width:100%; border-collapse: collapse; min-width: 720px; }
.results-table th, .results-table td{
  padding: 12px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.results-table th{
  text-align:right;
  color: var(--muted);
  font-size: .86rem;
  font-weight: 900;
}

.server-box{ display:flex; align-items:center; justify-content: space-between; gap: 10px; }
.server-main{ display:flex; flex-direction:column; gap: 2px; }
.server-name{ font-weight: 900; direction:ltr; unicode-bidi: plaintext; }
.server-country{ color: var(--muted); font-size: .86rem; }

.answer, .ttl{
  white-space: pre-line;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New";
  font-size: .92rem;
}

tr[data-status="ok"]{ background: rgba(61,220,151,.06); }
tr[data-status="mismatch"]{ background: rgba(255,176,32,.07); }
tr[data-status="warn"]{ background: rgba(122,166,255,.07); }
tr[data-status="error"]{ background: rgba(255,91,122,.07); }

tr.is-hidden{ display:none !important; }

.foot-hint{
  padding: 0 16px 16px;
  color: var(--muted);
  font-size: .9rem;
}

/* Mobile cards */
@media (max-width: 820px){
  .results-table{ min-width: 0; }
  .results-table thead{ display:none; }
  .results-table, .results-table tbody, .results-table tr, .results-table td{ display:block; width:100%; }
  .results-table tr{
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin: 12px 0;
    overflow:hidden;
  }
  .results-table td{
    border-bottom: 1px solid var(--border);
    padding: 12px 12px;
  }
  .results-table td:last-child{ border-bottom: none; }
  .server-box{ align-items:flex-start; }
}

/* Dialog */
.dialog{
  width: min(900px, calc(100% - 20px));
  border-radius: 18px;
  border: 1px solid var(--border);
  background: rgba(16,26,54,.96);
  color: var(--text);
  box-shadow: var(--shadow);
}
:root[data-theme="light"] .dialog{ background: rgba(255,255,255,.96); }
.dialog::backdrop{ background: rgba(0,0,0,.55); backdrop-filter: blur(2px); }

.dialog-head{
  display:flex;
  align-items:center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}
.dialog-title{ font-weight: 900; }
.dialog-body{
  margin:0;
  padding: 14px;
  max-height: 65vh;
  overflow:auto;
  direction:ltr;
  unicode-bidi: plaintext;
  background: rgba(0,0,0,.18);
}
:root[data-theme="light"] .dialog-body{ background: rgba(17,24,39,.04); }

/* Toasts */
.toasts{
  position: fixed;
  left: 14px;
  bottom: 14px;
  display:flex;
  flex-direction:column;
  gap: 10px;
  z-index: 60;
}
.toast{
  border: 1px solid var(--border);
  border-radius: 16px;
  background: rgba(255,255,255,.06);
  padding: 10px 12px;
  box-shadow: var(--shadow);
  min-width: 240px;
  max-width: 360px;
}
.toast-title{ font-weight: 900; }
.toast-text{ color: var(--muted); font-size: .9rem; margin-top: 2px; }