:root {
  --bg: #0b0e14;
  --panel: #121722;
  --panel-2: #171d2a;
  --border: #273043;
  --text: #eef2f8;
  --muted: #93a0b6;
  --primary: #6f7cff;
  --primary-2: #8994ff;
  --success: #35c58b;
  --danger: #ff647c;
  --warning: #f5b94c;
  --shadow: 0 18px 55px rgba(0, 0, 0, .24);
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at 10% 0%, rgba(111,124,255,.16), transparent 30rem),
    radial-gradient(circle at 90% 10%, rgba(53,197,139,.08), transparent 28rem),
    var(--bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

a { color: inherit; text-decoration: none; }
button, input, textarea { font: inherit; }
button { cursor: pointer; }
code {
  color: #b7c0d3;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .86rem;
  overflow-wrap: anywhere;
}

.page-shell { width: min(1260px, calc(100% - 32px)); margin: 0 auto; }
.topbar {
  min-height: 78px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  border-bottom: 1px solid rgba(255,255,255,.07);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 13px;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, var(--primary), #5360de);
  box-shadow: 0 12px 30px rgba(111,124,255,.3);
  font-weight: 800;
}
.brand strong, .brand small { display: block; }
.brand small { color: var(--muted); margin-top: 2px; font-size: .75rem; }
.nav-actions { display: flex; gap: 10px; align-items: center; }
.nav-actions form { margin: 0; }
.content { padding: 46px 0 28px; min-height: calc(100vh - 140px); }
.footer { color: var(--muted); font-size: .8rem; padding: 22px 0 34px; text-align: center; }

h1, h2, p { margin-top: 0; }
h1 { font-size: clamp(2rem, 4vw, 3.25rem); line-height: 1.08; margin-bottom: 12px; letter-spacing: -.04em; }
h2 { letter-spacing: -.02em; }
.muted { color: var(--muted); }
.eyebrow { color: var(--primary-2); font-size: .75rem; font-weight: 800; letter-spacing: .16em; margin-bottom: 12px; }

.button {
  border: 1px solid transparent;
  border-radius: 11px;
  min-height: 42px;
  padding: 0 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--text);
  background: transparent;
  font-weight: 700;
  transition: .18s ease;
}
.button:hover { transform: translateY(-1px); }
.button.primary { background: var(--primary); border-color: var(--primary); box-shadow: 0 10px 26px rgba(111,124,255,.18); }
.button.primary:hover { background: var(--primary-2); }
.button.ghost { background: rgba(255,255,255,.025); border-color: var(--border); }
.button.ghost:hover { background: var(--panel-2); }
.button.subtle { color: var(--muted); }
.button.danger { color: #ff9aaa; border-color: rgba(255,100,124,.3); }
.button.danger:hover { background: rgba(255,100,124,.09); }
.button.small { min-height: 36px; padding: 0 12px; font-size: .86rem; }
.button.wide { width: 100%; }

.hero-row, .form-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 30px;
}
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}
.stat {
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: rgba(18,23,34,.72);
  box-shadow: var(--shadow);
}
.stat span { color: var(--muted); font-size: .84rem; }
.stat strong { display: block; font-size: 2rem; margin-top: 8px; }
.stat.alive strong { color: var(--success); }
.stat.invalid strong { color: var(--danger); }
.stat.warning strong { color: var(--warning); }

.account-list { display: grid; gap: 16px; }
.account-row-card, .panel {
  background: linear-gradient(180deg, rgba(23,29,42,.94), rgba(18,23,34,.94));
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow);
}
.account-row-card { padding: 20px 22px; }
.account-row-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; }
.account-identity { min-width: 0; }
.account-title-line { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.account-title-line h2 { margin: 0; font-size: 1.2rem; }
.account-meta-line { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 8px; color: var(--muted); font-size: .88rem; }
.dot-sep { opacity: .5; }
.chip { display: inline-flex; border-radius: 999px; padding: 4px 8px; font-size: .7rem; font-weight: 800; }
.muted-chip { color: var(--muted); background: rgba(147,160,182,.12); }
.type-pill { display: inline-flex; align-items: center; border-radius: 999px; padding: 5px 10px; font-size: .72rem; font-weight: 900; letter-spacing: .01em; }
.type-standard { color: #9fd0ff; background: rgba(62,134,255,.16); }
.type-free { color: #88e7c2; background: rgba(53,197,139,.14); }
.type-upgraded { color: #ffd285; background: rgba(255,166,0,.15); }
.type-payg { color: #d1b0ff; background: rgba(155,99,255,.18); }
.type-unknown { color: var(--muted); background: rgba(147,160,182,.12); }
.status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: .72rem;
  font-weight: 900;
  letter-spacing: .04em;
  border: 1px solid currentColor;
}
.status-alive { color: var(--success); background: rgba(53,197,139,.08); }
.status-invalid, .status-error { color: var(--danger); background: rgba(255,100,124,.08); }
.status-forbidden, .status-degraded { color: var(--warning); background: rgba(245,185,76,.08); }
.status-unknown { color: var(--muted); background: rgba(147,160,182,.08); }
.account-row-summary {
  margin-top: 16px;
  padding: 13px 14px;
  color: #c7cfdd;
  border-radius: 12px;
  background: rgba(8,11,17,.48);
  border: 1px solid rgba(255,255,255,.05);
  line-height: 1.55;
  font-size: .88rem;
  overflow-wrap: anywhere;
}
.metrics-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-top: 16px;
}
.metric-box {
  min-width: 0;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(255,255,255,.03);
  border: 1px solid rgba(255,255,255,.05);
}
.metric-box span { display: block; color: var(--muted); font-size: .74rem; margin-bottom: 4px; }
.metric-box strong { display: block; font-size: .95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.metric-box.wide strong { white-space: normal; }
.regions { margin-top: 14px; color: var(--muted); font-size: .82rem; }
.regions summary { cursor: pointer; }
.regions p { margin: 8px 0 0; line-height: 1.5; overflow-wrap: anywhere; }
.card-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 18px; }
.card-actions form { margin: 0; }
.card-actions-row { justify-content: flex-start; }
.inline-select-note { color: var(--muted); font-size: .84rem; padding: 12px 13px; border: 1px dashed var(--border); border-radius: 11px; background: rgba(255,255,255,.02); min-height: 45px; display: flex; align-items: center; }
.flash, .inline-error {
  padding: 14px 16px;
  border-radius: 12px;
  margin-bottom: 20px;
  line-height: 1.5;
}
.flash { border: 1px solid var(--border); background: var(--panel); }
.flash.success { border-color: rgba(53,197,139,.35); color: #8ce3c0; }
.flash.warning { border-color: rgba(245,185,76,.35); color: #ffd98e; }
.inline-error { border: 1px solid rgba(255,100,124,.35); background: rgba(255,100,124,.08); color: #ff9aaa; }

.login-wrap { min-height: calc(100vh - 210px); display: grid; place-items: center; }
.login-card {
  width: min(440px, 100%);
  padding: 34px;
  border: 1px solid var(--border);
  border-radius: 22px;
  background: rgba(18,23,34,.9);
  box-shadow: var(--shadow);
}
.stack-form { display: grid; gap: 17px; margin-top: 26px; }
label { display: grid; gap: 8px; color: #dce2ec; font-weight: 700; font-size: .88rem; }
label em { color: var(--muted); font-style: normal; font-weight: 500; }
label small { color: var(--muted); font-weight: 400; line-height: 1.5; }
input, textarea {
  width: 100%;
  color: var(--text);
  background: #0e131d;
  border: 1px solid var(--border);
  border-radius: 11px;
  outline: none;
  padding: 12px 13px;
  transition: border-color .18s, box-shadow .18s;
}
input { min-height: 45px; }
textarea { resize: vertical; line-height: 1.5; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .85rem; }
input:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(111,124,255,.12); }
.form-panel { padding: 26px; display: grid; gap: 20px; }
.field-grid { display: grid; gap: 18px; }
.field-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.check-row { display: flex; align-items: center; gap: 10px; }
.check-row input { width: 18px; min-height: 18px; accent-color: var(--primary); }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; padding-top: 4px; }

.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; min-width: 900px; }
th, td { padding: 15px 16px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
th { color: var(--muted); font-size: .76rem; text-transform: uppercase; letter-spacing: .06em; }
td { font-size: .86rem; line-height: 1.5; }
tr:last-child td { border-bottom: 0; }
.nowrap { white-space: nowrap; }
.empty-cell { text-align: center; color: var(--muted); padding: 40px; }

.empty-state {
  min-height: 340px;
  border: 1px dashed var(--border);
  border-radius: 20px;
  display: grid;
  place-items: center;
  align-content: center;
  text-align: center;
  padding: 30px;
}
.empty-icon { width: 56px; height: 56px; border-radius: 18px; background: rgba(111,124,255,.14); color: var(--primary-2); display: grid; place-items: center; font-size: 2rem; margin-bottom: 18px; }
.empty-state p { color: var(--muted); max-width: 520px; }

@media (max-width: 860px) {
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metrics-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hero-row, .form-header { align-items: flex-start; flex-direction: column; }
  .account-row-top { flex-direction: column; }
}

@media (max-width: 560px) {
  .page-shell { width: min(100% - 20px, 1260px); }
  .topbar { min-height: 68px; }
  .brand small { display: none; }
  .nav-actions .button { padding: 0 11px; }
  .content { padding-top: 30px; }
  .stats-grid, .field-grid.two, .details-grid, .metrics-strip { grid-template-columns: 1fr; }
  .account-row-card, .form-panel, .login-card { padding: 18px; }
  .card-actions .button, .card-actions form { flex: 1; }
  .card-actions form .button { width: 100%; }
}

select {
  width: 100%;
  min-height: 45px;
  color: var(--text);
  background: #0e131d;
  border: 1px solid var(--border);
  border-radius: 11px;
  outline: none;
  padding: 10px 13px;
}
select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(111,124,255,.12); }
.status-ready { color: var(--primary-2); background: rgba(111,124,255,.08); }
.status-summary { display: grid; justify-items: end; gap: 8px; }
.status-summary small { color: var(--muted); }
.split-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; margin-bottom: 18px; align-items: start; }
.section-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.section-head h2 { margin-bottom: 6px; }
.section-head p { margin-bottom: 0; font-size: .84rem; line-height: 1.5; }
.inner-form { display: grid; gap: 18px; }
.align-end { align-self: end; min-height: 45px; }
.message-box.compact { min-height: auto; margin: 0; }
.empty-mini { min-height: 280px; display: grid; place-items: center; text-align: center; color: var(--muted); border: 1px dashed var(--border); border-radius: 14px; padding: 24px; }
.empty-mini p { margin: 0; max-width: 380px; line-height: 1.6; }
.dns-panel { overflow: hidden; }
.table-heading { padding: 22px 24px 2px; }
.dns-type { color: var(--primary-2); background: rgba(111,124,255,.08); }
.dns-panel form { margin: 0; }

@media (max-width: 980px) {
  .split-grid { grid-template-columns: 1fr; }
  .nav-actions .button.subtle { display: none; }
}

/* Cloudflare compact manager v1.3 */
.cf-manager { overflow: hidden; }
.cf-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 26px 28px 20px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.cf-title-row h2 { margin: 0 0 7px; font-size: 1.2rem; }
.cf-title-row p { margin: 0; font-size: .84rem; }
.cf-health { display: grid; justify-items: end; gap: 7px; }
.cf-health small { color: var(--muted); font-size: .76rem; }
.cf-toolbar {
  margin: 20px 28px;
  padding: 15px 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(255,255,255,.025);
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto;
  align-items: center;
  gap: 14px 18px;
}
.cf-zone-form { display: flex; align-items: center; gap: 9px; min-width: 0; }
.inline-field { display: flex; align-items: center; gap: 10px; min-width: 0; }
.inline-field > span { white-space: nowrap; color: var(--muted); font-size: .8rem; }
.inline-field select { width: min(300px, 100%); min-width: 220px; min-height: 38px; padding: 7px 12px; border-radius: 7px; }
.cf-toolbar-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.inline-action-form { margin: 0; }
.cf-toolbar .button { min-height: 38px; border-radius: 7px; padding: 0 13px; font-size: .82rem; box-shadow: none; }
.cf-toolbar .button[disabled], .icon-button[disabled] { opacity: .45; cursor: not-allowed; transform: none; }
.button.coral { background: #ff7d6b; border-color: #ff7d6b; color: #fff; }
.button.success { background: #39c96b; border-color: #39c96b; color: #fff; }
.button.blue { background: #4595ef; border-color: #4595ef; color: #fff; }
.button.coral:hover { background: #ff907f; }
.button.success:hover { background: #4bd77b; }
.button.blue:hover { background: #5ba4f3; }
.button svg, .icon-button svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.button-plus { font-size: 1.05rem; line-height: 1; }
.cf-search-form {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.compact-input { display: flex; align-items: center; gap: 8px; font-size: .8rem; color: var(--muted); }
.compact-input > span { white-space: nowrap; }
.compact-input input { min-height: 38px; width: 180px; border-radius: 7px; padding: 8px 11px; }
.cf-table-wrap { overflow: auto; border-top: 1px solid var(--border); }
.cf-table { min-width: 860px; }
.cf-table th, .cf-table td { padding: 12px 20px; vertical-align: middle; }
.cf-table th { text-transform: none; font-size: .74rem; letter-spacing: 0; color: #8693aa; background: rgba(5,8,13,.22); }
.cf-table tbody tr { transition: background .15s ease; }
.cf-table tbody tr:hover { background: rgba(255,255,255,.025); }
.cf-table td { color: #e3e8f2; }
.record-type-badge {
  min-width: 36px;
  padding: 4px 9px;
  display: inline-flex;
  justify-content: center;
  border-radius: 5px;
  color: #62b0ff;
  background: rgba(69,149,239,.16);
  font-size: .72rem;
  font-weight: 800;
}
.record-name, .record-value { overflow-wrap: anywhere; }
.proxy-badge {
  min-width: 53px;
  display: inline-flex;
  justify-content: center;
  border-radius: 999px;
  padding: 4px 11px;
  font-size: .72rem;
  font-weight: 800;
}
.proxy-badge.dns-only { color: #25bd54; background: rgba(37,189,84,.13); }
.proxy-badge.proxy-on { color: #f7a93a; background: rgba(247,169,58,.14); }
.row-actions { display: flex; align-items: center; gap: 7px; }
.row-actions form { margin: 0; }
.icon-button {
  width: 34px;
  height: 34px;
  display: inline-grid;
  place-items: center;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 7px;
  color: #fff;
  cursor: pointer;
}
.icon-button.edit { background: #4595ef; }
.icon-button.delete { background: #ff5f6d; }
.icon-button.neutral { color: var(--muted); background: rgba(255,255,255,.035); border-color: var(--border); }
.icon-button:hover { filter: brightness(1.1); }

.app-dialog {
  width: min(620px, calc(100% - 28px));
  max-height: calc(100vh - 36px);
  padding: 0;
  color: var(--text);
  background: transparent;
  border: 0;
  overflow: visible;
}
.app-dialog::backdrop { background: rgba(2,5,9,.72); backdrop-filter: blur(3px); }
.dialog-card {
  border: 1px solid #374151;
  border-radius: 14px;
  background: #20252c;
  box-shadow: 0 30px 80px rgba(0,0,0,.46);
  overflow: hidden;
}
.dialog-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 24px 26px 18px;
  border-bottom: 1px solid rgba(255,255,255,.1);
}
.dialog-head h2 { margin: 0 0 6px; font-size: 1.16rem; }
.dialog-head p { margin: 0; font-size: .82rem; }
.dialog-close {
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 8px;
  color: var(--muted);
  background: rgba(255,255,255,.04);
  font-size: 1.35rem;
}
.dialog-body { display: grid; gap: 18px; padding: 22px 26px; max-height: 62vh; overflow: auto; }
.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 9px;
  padding: 16px 26px 22px;
  border-top: 1px solid rgba(255,255,255,.08);
}
.dialog-actions .button { min-height: 39px; border-radius: 7px; }
.toggle-row {
  min-height: 45px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.toggle-row input[type="checkbox"] {
  appearance: none;
  width: 42px;
  height: 24px;
  min-height: 24px;
  border: 0;
  border-radius: 999px;
  padding: 0;
  background: #4b5563;
  position: relative;
  cursor: pointer;
}
.toggle-row input[type="checkbox"]::after {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  left: 3px;
  top: 3px;
  border-radius: 50%;
  background: white;
  transition: transform .18s ease;
}
.toggle-row input[type="checkbox"]:checked { background: #3bc96b; }
.toggle-row input[type="checkbox"]:checked::after { transform: translateX(18px); }
.dns-dialog-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.full-span { grid-column: 1 / -1; }

@media (max-width: 980px) {
  .cf-toolbar { grid-template-columns: 1fr; }
  .cf-toolbar-actions { justify-content: flex-start; }
}
@media (max-width: 650px) {
  .cf-title-row { padding: 20px 18px 16px; }
  .cf-toolbar { margin: 14px 12px; padding: 12px; }
  .cf-zone-form, .inline-field { width: 100%; }
  .inline-field select { min-width: 0; flex: 1; }
  .cf-toolbar-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); width: 100%; }
  .cf-toolbar-actions .button, .cf-toolbar-actions form, .cf-toolbar-actions form .button { width: 100%; }
  .cf-search-form { display: grid; grid-template-columns: 1fr 1fr; width: 100%; }
  .compact-input { display: grid; }
  .compact-input input { width: 100%; }
  .dns-dialog-grid { grid-template-columns: 1fr; }
  .full-span { grid-column: auto; }
  .dialog-head, .dialog-body, .dialog-actions { padding-left: 18px; padding-right: 18px; }
}
