/* ============================================================
   Cloudflare Dashboard recreation — design system
   ============================================================ */
:root {
  --orange: #f48120;
  --orange-hover: #d96b10;
  --orange-active: #c05e0d;
  --orange-soft: #fff4e8;
  --blue: #0051c3;
  --blue-hover: #0041a1;
  --blue-soft: #e8f1fd;
  --focus: #056de8;
  --ink: #1d1d1d;
  --text: #333333;
  --text-2: #545454;
  --muted: #757575;
  --faint: #9c9c9c;
  --border: #dddddd;
  --border-soft: #e8e8e8;
  --bg: #f6f6f6;
  --surface: #ffffff;
  --green: #23794e;
  --green-soft: #e4f4eb;
  --red: #bc0f3a;
  --red-soft: #fdebf0;
  --amber: #a26c00;
  --amber-soft: #fdf3dd;
  --purple: #6b4fbb;
  --purple-soft: #efeafa;
  --mono: "SF Mono", "Monaco", "Inconsolata", "Fira Mono", "Droid Sans Mono", "Source Code Pro", monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
  --topbar-h: 60px;
  --sidebar-w: 232px;
  --radius: 5px;
  --shadow-1: 0 1px 2px rgba(0,0,0,.06);
  --shadow-2: 0 4px 16px rgba(0,0,0,.12), 0 1px 3px rgba(0,0,0,.08);
  --shadow-3: 0 12px 40px rgba(0,0,0,.18), 0 2px 8px rgba(0,0,0,.10);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
h1, h2, h3, h4 { margin: 0; color: var(--ink); font-weight: 600; }
h1 { font-size: 22px; letter-spacing: -0.01em; }
h2 { font-size: 17px; }
h3 { font-size: 14.5px; }
p { margin: 0 0 8px; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
a.plain { color: inherit; }
a.plain:hover { text-decoration: none; }
button { font-family: inherit; }
code, .mono { font-family: var(--mono); font-size: 12.5px; }
::selection { background: #ffe1c2; }

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 1px;
  border-radius: 3px;
}

/* Scrollbars */
* { scrollbar-width: thin; scrollbar-color: #c9c9c9 transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: #c9c9c9; border-radius: 6px; border: 2px solid transparent; background-clip: content-box; }
*::-webkit-scrollbar-track { background: transparent; }

/* ============================================================
   Top navigation
   ============================================================ */
.topbar {
  position: fixed; top: 0; left: 0; right: 0;
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 16px;
  gap: 12px;
  z-index: 200;
}
.topbar .logo {
  display: flex; align-items: center; gap: 8px;
  flex: none;
}
.topbar .logo svg { display: block; }
.topbar .logo .wordmark { font-weight: 700; font-size: 16.5px; color: var(--ink); letter-spacing: -0.01em; }
.topbar .logo:hover .wordmark { text-decoration: none; }

.ctx-switcher {
  display: flex; align-items: center; gap: 4px;
  min-width: 0;
}
.ctx-btn {
  display: flex; align-items: center; gap: 6px;
  border: 0; background: transparent;
  font-size: 13.5px; font-weight: 600; color: var(--ink);
  padding: 6px 8px; border-radius: var(--radius);
  cursor: pointer; max-width: 220px;
}
.ctx-btn span.label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ctx-btn:hover { background: #f0f0f0; }
.ctx-btn .caret { color: var(--muted); flex: none; transition: transform .15s; }
.ctx-btn[aria-expanded="true"] .caret { transform: rotate(180deg); }
.ctx-sep { color: var(--faint); font-size: 13px; user-select: none; }

.topbar-search {
  flex: 1 1 auto; display: flex; justify-content: center; min-width: 0;
}
.search-box {
  display: flex; align-items: center; gap: 8px;
  width: 100%; max-width: 420px;
  background: #f3f3f3;
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 7px 12px;
  color: var(--muted);
  cursor: pointer;
  font-size: 13.5px;
}
.search-box:hover { background: #ececec; }
.search-box .kbd {
  margin-left: auto;
  font-family: var(--sans);
  font-size: 11px; color: var(--muted);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 4px; padding: 1px 6px;
}

.topbar-actions { display: flex; align-items: center; gap: 2px; flex: none; }
.icon-btn {
  position: relative;
  display: flex; align-items: center; justify-content: center;
  width: 36px; height: 36px;
  border: 0; background: transparent; border-radius: var(--radius);
  color: var(--text-2); cursor: pointer;
}
.icon-btn:hover { background: #f0f0f0; color: var(--ink); }
.icon-btn .dot {
  position: absolute; top: 6px; right: 7px;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--orange); border: 2px solid var(--surface);
}
.avatar-btn {
  width: 32px; height: 32px; border-radius: 50%;
  background: linear-gradient(135deg, #2c5cb8, #0051c3);
  color: #fff; font-weight: 600; font-size: 13px;
  display: flex; align-items: center; justify-content: center;
  border: 0; cursor: pointer; margin-left: 6px;
}
.avatar-btn:hover { box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--blue-soft); }

.hamburger { display: none; }

/* Dropdown menus */
.menu {
  position: fixed;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 7px;
  box-shadow: var(--shadow-2);
  min-width: 240px;
  padding: 6px;
  z-index: 400;
  animation: menu-in .12s ease-out;
}
@keyframes menu-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.menu .menu-head {
  padding: 8px 10px 6px; font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .06em; color: var(--muted);
}
.menu .menu-search {
  width: 100%; margin: 2px 0 6px; padding: 7px 10px;
  border: 1px solid var(--border); border-radius: var(--radius); font-size: 13.5px;
}
.menu-item {
  display: flex; align-items: center; gap: 9px;
  width: 100%; text-align: left;
  padding: 8px 10px; border: 0; background: transparent;
  font-size: 13.5px; color: var(--text); cursor: pointer;
  border-radius: 5px;
}
.menu-item:hover { background: #f2f2f2; }
.menu-item .sub { display: block; font-size: 12px; color: var(--muted); font-weight: 400; }
.menu-item.current { background: var(--blue-soft); color: var(--ink); font-weight: 600; }
.menu-item.danger { color: var(--red); }
.menu-item svg { flex: none; color: var(--muted); }
.menu-sep { height: 1px; background: var(--border-soft); margin: 6px 4px; }
.menu .menu-list { max-height: 320px; overflow-y: auto; }

/* Notifications */
.notif-panel { width: 380px; max-width: calc(100vw - 24px); }
.notif-item {
  display: flex; gap: 10px; padding: 10px;
  border-radius: 6px; cursor: pointer;
}
.notif-item:hover { background: #f5f5f5; }
.notif-item .n-icon { flex: none; width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; }
.notif-item .n-body { font-size: 13px; min-width: 0; }
.notif-item .n-title { font-weight: 600; color: var(--ink); }
.notif-item .n-time { color: var(--muted); font-size: 12px; margin-top: 2px; }
.notif-item.unread { background: var(--orange-soft); }
.notif-item.unread:hover { background: #ffedd9; }

/* ============================================================
   Layout
   ============================================================ */
.shell { display: flex; padding-top: var(--topbar-h); min-height: 100vh; }
.sidebar {
  position: fixed; top: var(--topbar-h); bottom: 0; left: 0;
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  z-index: 100;
  display: flex; flex-direction: column;
}
.sidebar-scroll { flex: 1; overflow-y: auto; padding: 10px 0 16px; }
.main {
  flex: 1;
  margin-left: var(--sidebar-w);
  min-width: 0;
  padding: 24px 28px 64px;
}
.main.no-sidebar { margin-left: 0; }
.page-inner { max-width: 1180px; margin: 0 auto; }

/* Sidebar nav */
.side-section { margin: 2px 10px; }
.side-back {
  display: flex; align-items: center; gap: 6px;
  margin: 2px 10px 8px; padding: 7px 10px;
  font-size: 13px; font-weight: 600; color: var(--blue);
  border-radius: var(--radius);
}
.side-back:hover { background: #f0f0f0; text-decoration: none; }
.side-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%;
  padding: 7px 10px;
  border: 0; background: transparent;
  font-size: 13.5px; color: var(--text);
  cursor: pointer; text-align: left;
  border-radius: var(--radius);
  position: relative;
}
.side-item:hover { background: #f2f2f2; }
.side-item svg { flex: none; color: var(--text-2); }
.side-item .expander { margin-left: auto; color: var(--muted); transition: transform .18s; }
.side-item.open > .expander { transform: rotate(90deg); }
.side-item.active {
  background: #ececec;
  font-weight: 600; color: var(--ink);
}
.side-item.active::before {
  content: ""; position: absolute; left: -10px; top: 6px; bottom: 6px;
  width: 3px; border-radius: 0 2px 2px 0; background: var(--orange);
}
.side-children { overflow: hidden; max-height: 0; transition: max-height .22s ease; }
.side-children.open { max-height: 600px; }
.side-children .side-item { padding-left: 38px; font-size: 13px; }
.side-zone-name {
  padding: 12px 10px 10px;
  border-bottom: 1px solid var(--border-soft);
  margin-bottom: 8px;
}
.side-zone-name .z-label { font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 700; }
.side-zone-name .z-name { font-size: 15px; font-weight: 700; color: var(--ink); margin-top: 2px; word-break: break-all; }
.side-foot { border-top: 1px solid var(--border-soft); padding: 10px; }

/* ============================================================
   Page headers / breadcrumbs
   ============================================================ */
.breadcrumb { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); margin-bottom: 6px; flex-wrap: wrap; }
.breadcrumb a { color: var(--muted); }
.breadcrumb a:hover { color: var(--blue); }
.breadcrumb .sep { color: var(--faint); }
.breadcrumb .current { color: var(--ink); font-weight: 600; }
.page-head { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head .titles { min-width: 0; flex: 1; }
.page-head h1 { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.page-head .subtitle { color: var(--muted); margin-top: 4px; font-size: 13.5px; max-width: 720px; }
.page-head .actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ============================================================
   Buttons
   ============================================================ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  font-size: 13.5px; font-weight: 600;
  border-radius: var(--radius);
  padding: 8px 16px;
  border: 1px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: background .12s, box-shadow .12s, border-color .12s;
  line-height: 1.3;
}
.btn-primary { background: var(--orange); color: #fff; }
.btn-primary:hover { background: var(--orange-hover); }
.btn-primary:active { background: var(--orange-active); }
.btn-primary:disabled { background: #f6b97f; cursor: not-allowed; }
.btn-secondary { background: var(--surface); border-color: var(--border); color: var(--text); box-shadow: var(--shadow-1); }
.btn-secondary:hover { background: #f5f5f5; border-color: #c9c9c9; }
.btn-tertiary { background: transparent; color: var(--blue); padding: 8px 10px; }
.btn-tertiary:hover { background: var(--blue-soft); }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { background: #a10c33; }
.btn-sm { padding: 5px 10px; font-size: 12.5px; }
.btn .spinner { width: 14px; height: 14px; }

/* ============================================================
   Cards
   ============================================================ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 7px;
  box-shadow: var(--shadow-1);
}
.card + .card { margin-top: 16px; }
.card-head {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-soft);
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}
.card-head h2, .card-head h3 { flex: 1; min-width: 0; }
.card-head .desc { width: 100%; color: var(--muted); font-size: 13px; margin-top: 2px; }
.card-body { padding: 20px; }
.card-body.flush { padding: 0; }
.card-foot {
  padding: 14px 20px; border-top: 1px solid var(--border-soft);
  display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px;
}

/* ============================================================
   Tables
   ============================================================ */
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl thead th {
  text-align: left;
  font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
  color: var(--muted);
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: #fafafa;
  white-space: nowrap;
}
.tbl tbody td {
  padding: 11px 16px;
  border-bottom: 1px solid var(--border-soft);
  vertical-align: middle;
}
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tbody tr { transition: background .1s; }
.tbl tbody tr:hover { background: #fafbfd; }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl .truncate-cell { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tbl .empty-row td { text-align: center; padding: 48px 16px; color: var(--muted); }

/* Status chips */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 600;
  padding: 2px 9px; border-radius: 999px;
  white-space: nowrap;
}
.chip::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.chip-green { background: var(--green-soft); color: var(--green); }
.chip-amber { background: var(--amber-soft); color: var(--amber); }
.chip-red { background: var(--red-soft); color: var(--red); }
.chip-gray { background: #eeeeee; color: var(--text-2); }
.chip-blue { background: var(--blue-soft); color: var(--blue); }
.chip.no-dot::before { display: none; }

.badge {
  display: inline-flex; align-items: center;
  font-size: 10.5px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase;
  padding: 2px 7px; border-radius: 4px;
  background: var(--purple-soft); color: var(--purple);
  white-space: nowrap;
}
.badge.ent { background: #eef0f6; color: #3d4b8f; }

/* ============================================================
   Forms
   ============================================================ */
.field { margin-bottom: 14px; }
.field label, .flabel {
  display: block; font-size: 12.5px; font-weight: 600; color: var(--text);
  margin-bottom: 5px;
}
.field .hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.input, select.input, textarea.input {
  width: 100%;
  font-family: inherit; font-size: 13.5px; color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 11px;
  transition: border-color .12s, box-shadow .12s;
}
.input:hover { border-color: #bdbdbd; }
.input:focus {
  outline: none;
  border-color: var(--focus);
  box-shadow: 0 0 0 3px rgba(5,109,232,.18);
}
.input::placeholder { color: var(--faint); }
.input.error { border-color: var(--red); }
.input.error:focus { box-shadow: 0 0 0 3px rgba(188,15,58,.15); }
.field .err-msg { display: flex; align-items: center; gap: 5px; color: var(--red); font-size: 12px; margin-top: 5px; font-weight: 500; }
select.input { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath fill='%23757575' d='M5 6L0 0h10z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 11px center; padding-right: 30px; cursor: pointer; }
.input-row { display: flex; gap: 10px; }
.input-row > * { flex: 1; min-width: 0; }
.input-group { display: flex; }
.input-group .input { border-radius: var(--radius) 0 0 var(--radius); }
.input-group .input-suffix {
  display: flex; align-items: center;
  padding: 0 11px; font-size: 13px; color: var(--muted);
  background: #f5f5f5; border: 1px solid var(--border); border-left: 0;
  border-radius: 0 var(--radius) var(--radius) 0; white-space: nowrap;
}
.inline-edit {
  background: transparent; border: 1px solid transparent; border-radius: 4px;
  font: inherit; color: inherit; padding: 2px 5px; width: 100%;
}
.inline-edit:hover { border-color: var(--border); }
.inline-edit:focus { outline: none; border-color: var(--focus); background: #fff; box-shadow: 0 0 0 3px rgba(5,109,232,.15); }

/* Toggle switch */
.toggle {
  position: relative; display: inline-flex; align-items: center;
  width: 38px; height: 21px; flex: none;
  cursor: pointer;
}
.toggle input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.toggle .track {
  position: absolute; inset: 0;
  background: #cfcfcf; border-radius: 999px;
  transition: background .18s;
}
.toggle .thumb {
  position: absolute; top: 2.5px; left: 3px;
  width: 16px; height: 16px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.3);
  transition: transform .18s cubic-bezier(.2,.8,.3,1.1);
}
.toggle input:checked ~ .track { background: var(--green); }
.toggle input:checked ~ .thumb { transform: translateX(16px); }
.toggle input:focus-visible ~ .track { box-shadow: 0 0 0 3px rgba(5,109,232,.35); }
.toggle.disabled { opacity: .5; cursor: not-allowed; }
.toggle.disabled input { cursor: not-allowed; }
.toggle.saving .thumb { animation: pulse .8s infinite alternate; }
@keyframes pulse { from { opacity: 1; } to { opacity: .45; } }

/* Setting rows (Speed / Network / Caching) */
.setting-row {
  display: flex; align-items: flex-start; gap: 14px;
  padding: 15px 20px;
  border-bottom: 1px solid var(--border-soft);
}
.setting-row:last-child { border-bottom: 0; }
.setting-row .s-body { flex: 1; min-width: 0; }
.setting-row .s-title { font-weight: 600; color: var(--ink); font-size: 13.5px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.setting-row .s-desc { color: var(--muted); font-size: 12.5px; margin-top: 3px; max-width: 640px; }
.setting-row .s-desc a { font-size: 12.5px; }
.setting-row .s-control { flex: none; padding-top: 1px; }
.setting-row.gated { background: #fdfdfd; }
.saved-flash { animation: saved-flash 1.4s ease-out; }
@keyframes saved-flash { 0% { background: var(--green-soft); } 100% { background: transparent; } }

/* Radio cards (SSL/TLS) */
.radio-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; }
.radio-card {
  position: relative;
  border: 1.5px solid var(--border);
  border-radius: 7px;
  padding: 16px;
  cursor: pointer;
  background: var(--surface);
  transition: border-color .14s, box-shadow .14s, background .14s;
}
.radio-card:hover { border-color: #b5b5b5; box-shadow: var(--shadow-1); }
.radio-card.selected {
  border-color: var(--blue);
  background: #f5f9ff;
  box-shadow: 0 0 0 1px var(--blue);
}
.radio-card .rc-head { display: flex; align-items: center; gap: 9px; margin-bottom: 8px; }
.radio-card .rc-title { font-weight: 700; color: var(--ink); font-size: 14.5px; }
.radio-card .rc-desc { font-size: 12.5px; color: var(--text-2); }
.radio-card .rc-diagram { margin-top: 12px; }
.radio-card.disabled { opacity: .55; cursor: not-allowed; }
.radio-dot {
  width: 17px; height: 17px; border-radius: 50%;
  border: 1.5px solid #bdbdbd; flex: none;
  display: flex; align-items: center; justify-content: center;
  background: #fff;
}
.radio-card.selected .radio-dot { border-color: var(--blue); }
.radio-card.selected .radio-dot::after { content: ""; width: 9px; height: 9px; border-radius: 50%; background: var(--blue); }

/* Tabs */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 20px; overflow-x: auto; }
.tab {
  border: 0; background: transparent;
  padding: 10px 14px;
  font-size: 13.5px; font-weight: 600; color: var(--text-2);
  cursor: pointer; white-space: nowrap;
  border-bottom: 2.5px solid transparent;
  margin-bottom: -1px;
}
.tab:hover { color: var(--ink); background: #f5f5f5; border-radius: 5px 5px 0 0; }
.tab.active { color: var(--ink); border-bottom-color: var(--orange); }
.tab .count {
  display: inline-block; margin-left: 6px;
  background: #eeeeee; color: var(--text-2);
  font-size: 11px; font-weight: 700;
  padding: 1px 7px; border-radius: 999px;
}
.tab.active .count { background: var(--orange-soft); color: var(--orange-hover); }

/* Stat cards */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin-bottom: 16px; }
.stat-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 7px; padding: 14px 16px;
  box-shadow: var(--shadow-1);
  cursor: default;
}
.stat-card .s-label { font-size: 12px; font-weight: 600; color: var(--muted); display: flex; align-items: center; gap: 5px; }
.stat-card .s-value { font-size: 24px; font-weight: 700; color: var(--ink); margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat-card .s-delta { font-size: 12px; margin-top: 2px; display: flex; align-items: center; gap: 4px; }
.stat-card .s-delta.up { color: var(--green); }
.stat-card .s-delta.down { color: var(--red); }
.stat-card .s-delta .vs { color: var(--muted); }

/* Chart */
.chart-card { position: relative; }
.chart-canvas { width: 100%; display: block; }
.chart-legend { display: flex; gap: 18px; flex-wrap: wrap; padding: 0 20px 14px; font-size: 12.5px; color: var(--text-2); }
.chart-legend .lg { display: flex; align-items: center; gap: 6px; }
.chart-legend .swatch { width: 10px; height: 10px; border-radius: 3px; }
.chart-tooltip {
  position: absolute; pointer-events: none;
  background: #fff; border: 1px solid var(--border);
  border-radius: 6px; box-shadow: var(--shadow-2);
  padding: 9px 12px; font-size: 12.5px;
  opacity: 0; transition: opacity .1s;
  z-index: 10; min-width: 150px;
}
.chart-tooltip .tt-label { font-weight: 700; color: var(--ink); margin-bottom: 4px; }
.chart-tooltip .tt-row { display: flex; align-items: center; gap: 6px; margin-top: 2px; }
.chart-tooltip .tt-val { margin-left: auto; font-weight: 600; font-variant-numeric: tabular-nums; }

/* Proxy cloud button */
.cloud-btn {
  border: 1px solid transparent; background: transparent; cursor: pointer;
  padding: 5px 7px; border-radius: 5px; display: inline-flex;
  transition: transform .12s, background .12s, border-color .12s;
}
.cloud-btn svg { width: 20px; height: 20px; }
.cloud-btn:hover { background: #f0f0f0; border-color: var(--border); transform: scale(1.08); }
.cloud-btn:active { transform: scale(.94); }
.cloud-btn:disabled { cursor: not-allowed; opacity: .6; }

/* Toasts */
#toast-root {
  position: fixed; top: calc(var(--topbar-h) + 14px); right: 16px;
  display: flex; flex-direction: column; gap: 10px;
  z-index: 600; pointer-events: none;
}
.toast {
  pointer-events: auto;
  display: flex; align-items: flex-start; gap: 10px;
  background: #fff;
  border: 1px solid var(--border);
  border-left: 4px solid var(--green);
  border-radius: 7px;
  box-shadow: var(--shadow-2);
  padding: 12px 14px;
  width: 360px; max-width: calc(100vw - 32px);
  animation: toast-in .22s cubic-bezier(.2,.9,.3,1.15);
}
.toast.leaving { animation: toast-out .18s ease-in forwards; }
.toast.error { border-left-color: var(--red); }
.toast.info { border-left-color: var(--blue); }
.toast .t-icon { flex: none; margin-top: 1px; }
.toast .t-body { flex: 1; font-size: 13.5px; min-width: 0; }
.toast .t-title { font-weight: 700; color: var(--ink); }
.toast .t-msg { color: var(--text-2); word-break: break-word; }
.toast .t-close { border: 0; background: none; color: var(--muted); cursor: pointer; padding: 2px; border-radius: 4px; }
.toast .t-close:hover { background: #f0f0f0; color: var(--ink); }
@keyframes toast-in { from { opacity: 0; transform: translateX(30px); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateX(30px); } }

/* Modals */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(20, 20, 20, .45);
  z-index: 500;
  display: flex; align-items: flex-start; justify-content: center;
  padding: 8vh 16px 16px;
  overflow-y: auto;
  animation: fade-in .15s;
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: #fff; border-radius: 9px;
  box-shadow: var(--shadow-3);
  width: 560px; max-width: 100%;
  animation: modal-in .18s cubic-bezier(.2,.9,.3,1.1);
}
.modal.wide { width: 760px; }
@keyframes modal-in { from { opacity: 0; transform: translateY(12px) scale(.985); } to { opacity: 1; transform: none; } }
.modal-head {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 22px 0;
}
.modal-head h2 { flex: 1; font-size: 17px; }
.modal-body { padding: 14px 22px 20px; }
.modal-foot {
  display: flex; justify-content: flex-end; gap: 10px;
  padding: 14px 22px;
  border-top: 1px solid var(--border-soft);
  background: #fafafa; border-radius: 0 0 9px 9px;
}
.modal .danger-icon { color: var(--red); flex: none; }

/* Skeleton shimmer */
.skeleton {
  position: relative; overflow: hidden;
  background: #e9e9e9; border-radius: 4px;
}
.skeleton::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.75), transparent);
  animation: shimmer 1.25s infinite;
  transform: translateX(-100%);
}
@keyframes shimmer { to { transform: translateX(100%); } }
.sk-line { height: 13px; margin: 8px 0; }
.sk-card { height: 110px; border-radius: 7px; }

/* Empty states */
.empty-state {
  text-align: center; padding: 52px 24px;
  color: var(--muted);
}
.empty-state .es-icon {
  width: 56px; height: 56px; margin: 0 auto 14px;
  border-radius: 50%; background: #f2f2f2;
  display: flex; align-items: center; justify-content: center;
  color: var(--faint);
}
.empty-state h3 { margin-bottom: 6px; }
.empty-state p { max-width: 420px; margin: 0 auto 16px; font-size: 13px; }

/* Callouts */
.callout {
  display: flex; gap: 10px;
  border: 1px solid var(--border);
  border-left: 4px solid var(--blue);
  border-radius: 6px;
  padding: 12px 14px;
  background: #f7faff;
  font-size: 13px;
  margin-bottom: 16px;
}
.callout.warning { border-left-color: #f2a93b; background: #fffcf5; }
.callout.error { border-left-color: var(--red); background: #fff9fa; }
.callout .c-icon { flex: none; margin-top: 1px; }
.callout .c-body { flex: 1; min-width: 0; }
.callout .c-title { font-weight: 700; color: var(--ink); margin-bottom: 2px; }
.callout .c-close { border: 0; background: none; cursor: pointer; color: var(--muted); padding: 2px; border-radius: 4px; align-self: flex-start; }
.callout .c-close:hover { background: rgba(0,0,0,.06); }

/* Copy button + tooltip */
.copy-btn {
  display: inline-flex; align-items: center; justify-content: center;
  border: 0; background: transparent; color: var(--muted);
  cursor: pointer; padding: 4px; border-radius: 4px;
  position: relative;
}
.copy-btn:hover { background: #f0f0f0; color: var(--ink); }
[data-tooltip] { position: relative; }
[data-tooltip]:hover::after {
  content: attr(data-tooltip);
  position: absolute; bottom: calc(100% + 6px); left: 50%;
  transform: translateX(-50%);
  background: #1d1d1d; color: #fff;
  font-size: 11.5px; font-weight: 500;
  padding: 4px 8px; border-radius: 4px;
  white-space: nowrap; z-index: 50;
  pointer-events: none;
  animation: fade-in .12s;
}

/* Filter bar */
.filter-bar { display: flex; gap: 10px; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--border-soft); flex-wrap: wrap; }
.filter-bar .input { width: auto; }
.filter-bar .search-filter { flex: 1; min-width: 180px; max-width: 320px; }

/* Pagination */
.pagination {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 16px; justify-content: flex-end;
  font-size: 13px; color: var(--muted);
  flex-wrap: wrap;
}
.pagination .pg-info { margin-right: auto; }
.page-btn {
  border: 1px solid var(--border); background: #fff;
  min-width: 30px; height: 30px; padding: 0 8px;
  border-radius: 5px; cursor: pointer;
  font-size: 13px; color: var(--text); font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center;
}
.page-btn:hover:not(:disabled) { background: #f3f3f3; }
.page-btn.current { background: var(--ink); color: #fff; border-color: var(--ink); cursor: default; }
.page-btn:disabled { opacity: .4; cursor: not-allowed; }

/* Expression preview (rules) */
.expr-preview {
  background: #1e2430;
  color: #d7e0f4;
  font-family: var(--mono); font-size: 12.5px;
  border-radius: 7px;
  padding: 13px 16px;
  overflow-x: auto;
  white-space: pre-wrap; word-break: break-all;
  line-height: 1.6;
}
.expr-preview .k { color: #8ab4ff; }       /* keyword */
.expr-preview .f { color: #7fd6a4; }       /* field */
.expr-preview .s { color: #f4c07a; }       /* string */
.expr-preview .op { color: #ff9d7a; }      /* operator */
.expr-label { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 0 0 6px; }

/* DNS quick ref popover */
.dns-quickref {
  border: 1px solid var(--border); border-radius: 7px;
  background: #fdfdf6;
  padding: 14px 16px; font-size: 12.5px;
  margin-bottom: 16px;
}
.dns-quickref h4 { font-size: 13px; margin-bottom: 6px; }
.dns-quickref dl { display: grid; grid-template-columns: 110px 1fr; gap: 4px 12px; margin: 0; }
.dns-quickref dt { font-weight: 700; color: var(--ink); }
.dns-quickref dd { margin: 0; color: var(--text-2); }

/* Add record inline form */
.record-form {
  background: #fafbfd;
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 16px;
  margin: 0 16px 16px;
}
.record-form .rf-grid {
  display: grid;
  grid-template-columns: 130px 1.2fr 1.6fr auto auto;
  gap: 10px; align-items: start;
}
.record-form .rf-grid.two { grid-template-columns: 130px 1.2fr 1fr 1fr; }
.proxy-toggle-wrap { display: flex; align-items: center; gap: 7px; padding-top: 6px; font-size: 12.5px; color: var(--text-2); }

/* Help panel */
.help-panel {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: 400px; max-width: 92vw;
  background: #fff; box-shadow: var(--shadow-3);
  z-index: 450;
  transform: translateX(100%);
  transition: transform .25s cubic-bezier(.2,.8,.3,1);
  display: flex; flex-direction: column;
}
.help-panel.open { transform: none; }
.help-head {
  padding: 18px 20px; border-bottom: 1px solid var(--border-soft);
  display: flex; align-items: center; gap: 10px;
}
.help-head h2 { flex: 1; font-size: 16px; }
.help-body { flex: 1; overflow-y: auto; padding: 18px 20px; }
.help-link {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 10px 12px; border-radius: 6px; color: var(--text);
}
.help-link:hover { background: #f4f4f4; text-decoration: none; }
.help-link .hl-icon { color: var(--blue); flex: none; margin-top: 1px; }
.help-link .hl-title { font-weight: 600; font-size: 13.5px; color: var(--ink); }
.help-link .hl-sub { font-size: 12px; color: var(--muted); }
.help-backdrop {
  position: fixed; inset: 0; z-index: 440;
  background: rgba(0,0,0,.15);
  animation: fade-in .2s;
}

/* Search overlay */
.search-overlay {
  position: fixed; inset: 0; z-index: 550;
  background: rgba(20,20,20,.4);
  display: flex; align-items: flex-start; justify-content: center;
  padding-top: 12vh;
  animation: fade-in .14s;
}
.search-modal {
  background: #fff; border-radius: 10px;
  width: 620px; max-width: calc(100vw - 32px);
  box-shadow: var(--shadow-3);
  overflow: hidden;
  animation: modal-in .16s;
}
.search-input-row {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 18px; border-bottom: 1px solid var(--border-soft);
}
.search-input-row input {
  flex: 1; border: 0; outline: none; font-size: 16px; color: var(--ink);
}
.search-input-row .esc {
  font-size: 11px; color: var(--muted); border: 1px solid var(--border);
  border-radius: 4px; padding: 2px 6px;
}
.search-results { max-height: 380px; overflow-y: auto; padding: 8px; }
.search-result {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 12px; border-radius: 6px; cursor: pointer;
}
.search-result:hover, .search-result.selected { background: var(--blue-soft); }
.search-result .sr-icon { color: var(--muted); flex: none; }
.search-result .sr-name { font-weight: 600; font-size: 13.5px; color: var(--ink); }
.search-result .sr-path { font-size: 12px; color: var(--muted); }
.search-results .srh { padding: 8px 12px 4px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.search-empty { padding: 36px; text-align: center; color: var(--muted); font-size: 13.5px; }

/* Spinner */
.spinner {
  width: 16px; height: 16px; flex: none;
  border: 2px solid rgba(0,0,0,.12);
  border-top-color: var(--orange);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
.spinner.on-dark { border-color: rgba(255,255,255,.35); border-top-color: #fff; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-inline { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; padding: 24px; justify-content: center; }

/* Quick actions bar (zone overview) */
.quick-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* Two-col layout helpers */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-2 > .card { margin-top: 0; }
@media (max-width: 900px) { .grid-2 { grid-template-columns: 1fr; } }

.kv { display: grid; grid-template-columns: 190px 1fr; gap: 7px 14px; font-size: 13.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; color: var(--ink); display: flex; align-items: center; gap: 6px; min-width: 0; }
.kv dd .mono { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Zone overview analytics mini-chart cards */
.metric-row { display: flex; gap: 24px; flex-wrap: wrap; }
.metric { min-width: 120px; }
.metric .m-label { font-size: 12px; color: var(--muted); font-weight: 600; }
.metric .m-value { font-size: 20px; font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; }

/* SSL diagram */
.ssl-diagram { display: flex; align-items: center; gap: 4px; }
.ssl-diagram .node {
  width: 26px; height: 26px; border-radius: 50%;
  background: #ececec; display: flex; align-items: center; justify-content: center;
  color: var(--text-2); flex: none;
}
.ssl-diagram .link { flex: 1; height: 3px; border-radius: 2px; position: relative; min-width: 22px; }
.ssl-diagram .link.secure { background: var(--green); }
.ssl-diagram .link.insecure { background: #d8d8d8; }
.ssl-diagram .link .lock { position: absolute; top: -8px; left: 50%; transform: translateX(-50%); }

/* Narrow viewport */
.sidebar-backdrop { display: none; }
@media (max-width: 1080px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform .22s ease;
    box-shadow: none;
  }
  body.nav-open .sidebar { transform: none; box-shadow: var(--shadow-3); }
  .main { margin-left: 0; }
  .hamburger { display: inline-flex; }
  .sidebar-backdrop {
    display: block; position: fixed; inset: 0; z-index: 90;
    background: rgba(0,0,0,.25);
    opacity: 0; pointer-events: none; transition: opacity .2s;
  }
  body.nav-open .sidebar-backdrop { opacity: 1; pointer-events: auto; }
}
@media (max-width: 720px) {
  .topbar { padding: 0 10px; gap: 6px; }
  .topbar .wordmark { display: none; }
  .search-box .search-text { display: none; }
  .search-box { max-width: 44px; }
  .search-box .kbd { display: none; }
  .main { padding: 16px 14px 48px; }
  .record-form .rf-grid { grid-template-columns: 1fr 1fr; }
  .ctx-btn { max-width: 120px; }
}

/* Print-ish utility */
.flex { display: flex; align-items: center; gap: 8px; }
.grow { flex: 1; min-width: 0; }
.mt8 { margin-top: 8px; } .mt16 { margin-top: 16px; } .mt24 { margin-top: 24px; }
.mb8 { margin-bottom: 8px; } .mb16 { margin-bottom: 16px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.hidden { display: none !important; }
