:root {
  --bg1: #f2f0ff;
  --bg2: #fdf1f8;
  --card: #ffffff;
  --line: #e7e3f3;
  --line2: #f1eef8;
  --ink: #1d1a36;
  --muted: #6c6889;
  --soft: #f6f4fc;
  --r: 5px;
  --grad: linear-gradient(120deg, #4f7cff 0%, #8b5cf6 52%, #e04fb3 100%);
  --blue: #4f7cff;
  --purple: #8b5cf6;
  --pink: #e04fb3;
  --ok: #138a4a;
  --ok-bg: #e6f6ed;
  --warn: #b45f06;
  --warn-bg: #fdf1e1;
  --bad: #c4282d;
  --bad-bg: #fde8e9;
  --shadow: 0 1px 2px rgba(40, 30, 90, .05), 0 4px 14px rgba(40, 30, 90, .05);
  font-family: "Segoe UI", "Noto Sans Arabic", Tahoma, system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  min-height: 100vh;
  color: var(--ink);
  background: linear-gradient(180deg, var(--bg1) 0%, var(--bg2) 100%) fixed;
  font-size: 14px;
  line-height: 1.55;
}
a { color: var(--purple); text-decoration: none; }
a:hover { text-decoration: underline; }
code, .mono { font-family: Consolas, "Cascadia Mono", monospace; direction: ltr; unicode-bidi: embed; }
[hidden] { display: none !important; }

/* ---------- top bar */
.top {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 18px;
  padding: 10px 22px;
  background: rgba(255, 255, 255, .92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); }
.brand:hover { text-decoration: none; }
.logo {
  width: 34px; height: 34px; border-radius: 6px;
  display: grid; place-items: center;
  background: var(--grad); color: #fff; font-weight: 700; font-size: 18px;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-text b { font-size: 15px; letter-spacing: .5px; }
.brand-text small { color: var(--muted); font-size: 11px; }
#nav { display: flex; gap: 2px; flex: 1; overflow-x: auto; scrollbar-width: none; }
#nav a {
  white-space: nowrap; padding: 7px 12px; border-radius: var(--r);
  color: var(--muted); font-weight: 600; position: relative;
}
#nav a:hover { background: var(--soft); color: var(--ink); text-decoration: none; }
#nav a.on { color: var(--ink); }
#nav a.on::after {
  content: ""; position: absolute; inset-inline: 10px; bottom: 1px; height: 3px; border-radius: 2px; background: var(--grad);
}
.who { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }

main { max-width: 1240px; margin: 0 auto; padding: 22px 22px 60px; }
.loading { padding: 50px; text-align: center; color: var(--muted); }

/* ---------- headings */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head h1 { margin: 0; font-size: 22px; }
.grad-text { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- cards */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r);
  box-shadow: var(--shadow); padding: 16px 18px; margin-bottom: 16px;
}
.card > h2, .card-head h2 { margin: 0 0 12px; font-size: 15px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.card-head h2 { margin: 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 900px) { .grid2 { grid-template-columns: 1fr; } }

/* ---------- tiles */
.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
@media (max-width: 900px) { .tiles { grid-template-columns: repeat(2, 1fr); } }
.tile {
  display: block; padding: 14px 16px; border-radius: var(--r); color: #fff;
  background: var(--grad); box-shadow: var(--shadow); position: relative; overflow: hidden;
}
.tile:nth-child(2) { background: linear-gradient(120deg, #6a6cff, #a65bf0 60%, #e04fb3); }
.tile:nth-child(3) { background: linear-gradient(120deg, #8b5cf6, #c552cf 60%, #ef6aa8); }
.tile:nth-child(4) { background: linear-gradient(120deg, #4f9dff, #6e6cf6 60%, #a05cf0); }
.tile:hover { text-decoration: none; filter: brightness(1.04); }
.tile .t-label { font-size: 12px; opacity: .9; }
.tile .t-value { font-size: 26px; font-weight: 700; line-height: 1.2; margin: 4px 0 2px; direction: ltr; text-align: right; }
.tile .t-sub { font-size: 12px; opacity: .88; }

/* ---------- alerts */
.alerts { display: flex; flex-direction: column; gap: 8px; }
.alert {
  display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: var(--r);
  border: 1px solid var(--line); background: var(--soft); color: var(--ink);
}
.alert:hover { text-decoration: none; filter: brightness(.99); }
.alert .dot { margin-top: 6px; }
.alert b { display: block; font-size: 13.5px; }
.alert span.d { color: var(--muted); font-size: 12.5px; }
.alert.bad { background: var(--bad-bg); border-color: #f6c9cb; }
.alert.warn { background: var(--warn-bg); border-color: #f3d9b4; }
.alert.ok { background: var(--ok-bg); border-color: #bfe6cf; }

/* ---------- tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 8px 10px; text-align: right; border-bottom: 1px solid var(--line2); vertical-align: middle; }
th { font-size: 12px; color: var(--muted); font-weight: 600; background: #faf9fe; white-space: nowrap; }
tbody tr:hover td { background: #fbfaff; }
tr.click { cursor: pointer; }
td.num, th.num { text-align: left; direction: ltr; }
td .mono { font-size: 12.5px; }
.empty { padding: 24px; text-align: center; color: var(--muted); }

/* ---------- badges & dots */
.badge {
  display: inline-block; padding: 1px 8px; border-radius: 4px; font-size: 12px; font-weight: 600;
  background: var(--soft); color: var(--muted); border: 1px solid var(--line); white-space: nowrap;
}
.badge.ok { background: var(--ok-bg); color: var(--ok); border-color: #c4e8d3; }
.badge.warn { background: var(--warn-bg); color: var(--warn); border-color: #f3dbb9; }
.badge.bad { background: var(--bad-bg); color: var(--bad); border-color: #f5c7c9; }
.badge.grad { background: var(--grad); color: #fff; border-color: transparent; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; background: #b9b5cc; flex: none; }
.dot.up { background: #1fb463; box-shadow: 0 0 0 3px #d9f4e5; }
.dot.down { background: #e0383e; box-shadow: 0 0 0 3px #fbdcdd; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 4px;
  background: var(--soft); border: 1px solid var(--line); font-size: 12.5px; color: var(--ink);
}
.chip.on { background: var(--grad); color: #fff; border-color: transparent; }
button.chip { cursor: pointer; font: inherit; font-size: 12.5px; }

/* ---------- buttons & forms */
.btn {
  font: inherit; font-weight: 600; font-size: 13px; cursor: pointer;
  padding: 7px 14px; border-radius: var(--r); border: 1px solid var(--line);
  background: #fff; color: var(--ink); white-space: nowrap;
}
.btn:hover { background: var(--soft); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.primary { background: var(--grad); color: #fff; border-color: transparent; }
.btn.primary:hover { filter: brightness(1.05); }
.btn.danger { background: var(--bad); color: #fff; border-color: transparent; }
.btn.ghost { background: transparent; }
.btn.sm { padding: 4px 10px; font-size: 12px; }
.btn.icon { padding: 3px 9px; }

input, select, textarea {
  font: inherit; color: var(--ink); background: #fff;
  border: 1px solid var(--line); border-radius: 4px; padding: 7px 9px; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid #c9b8fb; border-color: var(--purple); }
textarea { min-height: 90px; resize: vertical; }
input.ltr, textarea.ltr { direction: ltr; text-align: left; }
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; }
.field > span { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0 14px; }
@media (max-width: 700px) { .form-grid { grid-template-columns: 1fr; } }
.check { display: flex; gap: 8px; align-items: center; font-size: 13px; }
.check input { width: auto; }
.hint { color: var(--muted); font-size: 12.5px; }
ol.steps { margin: 0 0 12px; padding-inline-start: 20px; color: var(--ink); }
ol.steps li { margin-bottom: 4px; }

/* ---------- DNS editor */
table.dns td { padding: 4px 5px; }
table.dns input, table.dns select { padding: 5px 7px; font-size: 13px; }
table.dns .c-type { width: 105px; }
table.dns .c-host { width: 170px; }
table.dns .c-ttl { width: 95px; }
table.dns .c-mx { width: 70px; }
table.dns .c-del { width: 40px; }
table.dns tr.new td { background: #f3fbf6; }
table.dns tr.dirty td { background: #fffaf0; }
.diff-list { display: flex; flex-direction: column; gap: 4px; margin: 6px 0 12px; }
.diff-row { padding: 6px 9px; border-radius: 4px; font-size: 13px; direction: ltr; text-align: left; font-family: Consolas, monospace; word-break: break-all; }
.diff-row.add { background: var(--ok-bg); color: var(--ok); }
.diff-row.del { background: var(--bad-bg); color: var(--bad); }
.diff-row.chg { background: var(--warn-bg); color: var(--warn); }

/* ---------- map */
.map-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 14px; }
.map-card { margin: 0; }
.map-card .m-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.map-card .m-head b { font-size: 14.5px; }
.map-card .m-ip { color: var(--muted); font-size: 12.5px; }
.map-card ul { list-style: none; margin: 0; padding: 0; }
.map-card li { display: flex; justify-content: space-between; gap: 8px; padding: 4px 0; border-bottom: 1px dashed var(--line2); font-size: 13px; }
.map-card li:last-child { border-bottom: 0; }

/* ---------- modal & toast */
#modal {
  position: fixed; inset: 0; z-index: 50; background: rgba(29, 26, 54, .38);
  display: grid; place-items: center; padding: 16px;
}
.modal-card {
  width: min(640px, 100%); max-height: 90vh; overflow: auto;
  background: #fff; border-radius: var(--r); box-shadow: 0 20px 60px rgba(29, 26, 54, .25);
}
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; font-size: 16px; }
.modal-head .x { border: 0; background: none; font-size: 22px; cursor: pointer; color: var(--muted); }
.modal-body { padding: 16px 18px; }
.modal-actions { display: flex; justify-content: flex-start; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--line); background: #faf9fe; }
#toast { position: fixed; bottom: 18px; left: 18px; z-index: 60; display: flex; flex-direction: column; gap: 8px; }
.toast {
  padding: 10px 14px; border-radius: var(--r); background: var(--ink); color: #fff; font-size: 13.5px;
  box-shadow: var(--shadow); max-width: 420px;
}
.toast.bad { background: var(--bad); }
.toast.ok { background: #19744a; }

/* ---------- auth */
.auth-wrap { min-height: 80vh; display: grid; place-items: center; }
.auth-card { width: min(400px, 100%); }
.auth-card .brand { justify-content: center; margin-bottom: 16px; }
.qr { display: block; margin: 10px auto; border: 1px solid var(--line); border-radius: 4px; }
.secret { text-align: center; font-size: 13px; word-break: break-all; padding: 6px; background: var(--soft); border-radius: 4px; }

details pre { white-space: pre-wrap; word-break: break-all; font-size: 12px; background: var(--soft); padding: 8px; border-radius: 4px; direction: ltr; text-align: left; max-height: 260px; overflow: auto; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; font-size: 13.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.muted { color: var(--muted); }
.right { margin-inline-start: auto; }
