:root {
  --bg: #f5f7f6;
  --surface: #ffffff;
  --surface-soft: #f0f4f2;
  --sidebar: #18211f;
  --sidebar-soft: #24302d;
  --text: #17201e;
  --muted: #66736f;
  --line: #dfe6e3;
  --line-strong: #cbd6d2;
  --green: #147d64;
  --green-dark: #0f654f;
  --green-soft: #e5f5ef;
  --blue: #2867a8;
  --blue-soft: #eaf2fb;
  --amber: #a7600c;
  --amber-soft: #fff3dc;
  --red: #b42318;
  --red-soft: #fff0ee;
  --shadow: 0 16px 44px rgba(24, 33, 31, 0.18);
  --radius: 6px;
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  font-size: 14px;
  letter-spacing: 0;
}

button, input, select, textarea { font: inherit; letter-spacing: 0; }
button, select { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.55; pointer-events: none; }

svg { width: 18px; height: 18px; stroke-width: 1.8; }

.auth-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px 20px;
  background: #18211f;
}

.auth-panel {
  width: min(420px, 100%);
  padding: 30px;
  border: 1px solid #354742;
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 18px 48px rgba(4, 12, 10, 0.28);
}

.auth-brand { display: flex; align-items: center; gap: 11px; }
.auth-brand strong, .auth-brand span { display: block; }
.auth-brand strong { font-size: 15px; }
.auth-brand span { margin-top: 2px; color: var(--muted); font-size: 11px; }
.auth-heading { margin: 32px 0 24px; }
.auth-heading h1 { margin-top: 5px; font-size: 24px; }
.auth-heading p { margin-top: 8px; color: var(--muted); font-size: 12px; line-height: 1.6; }
.auth-form { display: grid; gap: 16px; }
.auth-submit { width: 100%; margin-top: 4px; }
.auth-submit:disabled { background: #78968c; color: #f4f7f6; opacity: 1; }
.form-error { padding: 10px 12px; border-left: 3px solid var(--red); background: var(--red-soft); color: var(--red); font-size: 12px; line-height: 1.5; }

.app-shell {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr);
  grid-template-areas: "rail workspace";
  min-height: 100vh;
}

.admin-rail {
  grid-area: rail;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 18px 10px 12px;
  background: var(--sidebar);
  color: #eef5f2;
}
.rail-brand {
  width: 42px;
  height: 42px;
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid #46615a;
  border-radius: var(--radius);
  background: #21312d;
  color: #70d5b5;
}
.rail-brand svg { width: 20px; height: 20px; }
.rail-nav { width: 100%; display: grid; gap: 6px; margin-top: 24px; }
.rail-nav-button {
  width: 100%;
  min-height: 54px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 5px 2px;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: #91a39d;
  font-size: 10px;
  font-weight: 700;
  text-decoration: none;
}
.rail-nav-button:hover { background: #24332f; color: #eef5f2; }
.rail-nav-button.active { background: #2c403a; color: #7bdaba; }
.rail-nav-button svg { width: 18px; height: 18px; }
.rail-session { width: 100%; display: grid; gap: 8px; margin-top: auto; padding-top: 12px; border-top: 1px solid #2f3d39; }
.rail-user { min-width: 0; text-align: center; }
.rail-user strong, .rail-user span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rail-user strong { font-size: 10px; }
.rail-user span { margin-top: 2px; color: #7f918b; font-size: 9px; }
.rail-logout { min-height: 45px; }

.brand, .mobile-brand {
  display: flex;
  align-items: center;
  gap: 11px;
}

.brand { padding: 0 6px 18px; }

.brand-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 1px solid #46615a;
  border-radius: var(--radius);
  background: #21312d;
  color: #70d5b5;
}

.brand strong, .brand span { display: block; }
.brand strong { font-size: 15px; font-weight: 700; }
.brand span { margin-top: 2px; color: #9eafa9; font-size: 12px; }

.mini-icon-button { width: 28px; height: 28px; display: grid; flex: 0 0 auto; place-items: center; padding: 0; border: 0; border-radius: 4px; background: transparent; color: #93a49e; }
.mini-icon-button svg { width: 15px; height: 15px; }
.mini-icon-button:hover { background: #2c3c38; color: white; }
.add-account-button { border: 1px solid #41554f; color: #70d5b5; }

.search-box, .record-search {
  height: 38px;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: var(--radius);
}

.search-box {
  margin-bottom: 10px;
  padding: 0 11px;
  border-color: var(--line);
  background: var(--surface-soft);
  color: var(--muted);
}

.search-box:focus-within { border-color: var(--green); box-shadow: 0 0 0 3px rgba(20, 125, 100, 0.08); }
.search-box input, .record-search input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: inherit;
}
.search-box input::placeholder { color: #87928e; }

.sidebar-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 8px 9px;
  color: #9eafa9;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}
.account-tree-heading { min-height: 34px; padding-bottom: 6px; }
.account-tree-heading .mini-icon-button { margin-right: -2px; }
.sidebar-heading-actions, .mobile-header-actions { display: flex; align-items: center; gap: 4px; }

.domain-status-filters {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  margin-bottom: 10px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
}
.domain-status-filter {
  min-width: 0;
  min-height: 30px;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 0 7px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  font-size: 10px;
  text-align: left;
}
.domain-status-filter:hover { background: #e6ece9; color: var(--text); }
.domain-status-filter.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(24, 33, 31, 0.1); }
.domain-status-filter strong { margin-left: auto; color: var(--muted); font-size: 10px; }
.domain-status-filter svg { width: 12px; height: 12px; color: #e8bb71; }
.filter-dot { width: 7px; height: 7px; flex: 0 0 auto; border-radius: 50%; }
.filter-dot.normal { background: #4fd0a7; }
.filter-dot.attention { background: #e8bb71; }

.count-badge {
  min-width: 24px;
  padding: 2px 7px;
  border-radius: 999px;
  background: #2a3a36;
  text-align: center;
}

.account-tree {
  min-height: 0;
  flex: 1;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #c7d2ce transparent;
}

.account-group { padding: 4px 0 8px; border-bottom: 1px solid var(--line); }
.account-group:last-child { border-bottom: 0; }
.account-group-header { display: flex; align-items: center; gap: 3px; }
.account-toggle {
  min-width: 0;
  min-height: 38px;
  display: flex;
  flex: 1;
  align-items: center;
  gap: 7px;
  padding: 5px 6px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--text);
  text-align: left;
}
.account-toggle:hover { background: var(--surface-soft); }
.account-toggle > svg { width: 15px; height: 15px; flex: 0 0 auto; transition: transform 0.16s ease; }
.account-group.collapsed .account-toggle > svg { transform: rotate(-90deg); }
.account-toggle-text { min-width: 0; flex: 1; }
.account-toggle-text strong, .account-toggle-text small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-toggle-text strong { font-size: 12px; }
.account-toggle-text small { margin-top: 2px; color: var(--muted); font-size: 10px; }
.account-toggle-text small + small { color: #82908b; }
.account-domains { padding-left: 8px; }
.account-group.collapsed .account-domains { display: none; }
.account-error { padding: 8px 10px 8px 30px; color: var(--red); font-size: 10px; line-height: 1.4; }

.domain-item {
  width: 100%;
  min-height: 48px;
  display: grid;
  grid-template-columns: 8px minmax(0, 1fr) 16px;
  align-items: start;
  gap: 10px;
  padding: 7px 8px;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: #34413d;
  text-align: left;
}

.domain-item:hover { background: var(--surface-soft); }
.domain-item.active { background: var(--green-soft); color: var(--green-dark); }
.domain-item .status-dot {
  width: 8px;
  height: 8px;
  margin-top: 5px;
  border-radius: 50%;
  background: #6f817b;
}
.domain-item .status-dot.normal { background: #4fd0a7; box-shadow: 0 0 0 3px rgba(79, 208, 167, 0.14); }
.domain-item .status-dot.attention { background: #e8bb71; box-shadow: 0 0 0 3px rgba(232, 187, 113, 0.13); }
.domain-item .status-dot.danger { background: #ef766d; box-shadow: 0 0 0 3px rgba(239, 118, 109, 0.13); }
.domain-item .status-dot.unknown { background: #6f817b; }
.domain-item strong, .domain-item small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.domain-item-text { min-width: 0; }
.domain-item strong { font-size: 13px; }
.domain-item small { margin-top: 4px; color: var(--muted); font-size: 11px; }
.domain-item small.domain-item-ip { color: var(--blue); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px; }
.domain-item small.domain-item-note { color: #42514c; font-size: 12px; line-height: 1.35; }
.domain-item small.domain-item-expiry { color: #7a8883; font-size: 11px; }
.domain-lock-indicator { width: 16px; height: 16px; display: grid; place-items: center; margin-top: 1px; color: #e8bb71; visibility: hidden; }
.domain-lock-indicator.locked { visibility: visible; }
.domain-lock-indicator svg { width: 15px; height: 15px; stroke-width: 2; }

.domain-list-empty { padding: 24px 10px; color: var(--muted); text-align: center; }

.domain-catalog {
  width: min(1400px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 38px 40px 60px;
}
.catalog-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; }
.catalog-header h1 { margin: 5px 0 0; font-size: 26px; }
.catalog-header p { margin: 7px 0 0; color: var(--muted); font-size: 12px; }
.catalog-toolbar {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) auto;
  align-items: center;
  gap: 14px;
  margin-top: 26px;
}
.catalog-toolbar .search-box { height: 42px; margin: 0; background: var(--surface); }
.catalog-toolbar .domain-status-filters {
  display: flex;
  margin: 0;
  white-space: nowrap;
}
.catalog-toolbar .domain-status-filter { min-width: 88px; min-height: 32px; font-size: 11px; }
.catalog-storage {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 38px;
  margin-top: 16px;
  padding: 0 4px;
  color: var(--muted);
}
.catalog-storage .secure-dot { flex: 0 0 auto; }
.catalog-storage strong { color: var(--text); font-size: 11px; }
.catalog-storage span:last-child { overflow: hidden; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.secure-dot { width: 8px; height: 8px; border-radius: 50%; background: #49c99f; }

.catalog-account-tree { display: grid; gap: 14px; margin-top: 2px; overflow: visible; }
.catalog-account-tree .account-group {
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
}
.catalog-account-tree .account-group-header { min-height: 62px; }
.catalog-account-tree .account-toggle { min-height: 62px; padding: 10px 16px; border-radius: 0; }
.catalog-account-tree .account-toggle-text {
  display: grid;
  grid-template-columns: minmax(150px, 0.8fr) minmax(240px, 1.4fr) minmax(180px, auto);
  align-items: center;
  gap: 18px;
}
.catalog-account-tree .account-toggle-text strong { font-size: 14px; }
.catalog-account-tree .account-toggle-text small { margin: 0; font-size: 11px; }
.catalog-account-tree .account-toggle-text small:last-child { text-align: right; }
.catalog-account-tree .account-domains {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0;
  padding: 0;
  background: var(--surface);
}
.catalog-account-tree .domain-item {
  min-height: 88px;
  padding: 13px 15px;
  border-top: 1px solid var(--line);
  border-right: 1px solid var(--line);
  border-radius: 0;
  background: var(--surface);
}
.catalog-account-tree .domain-item:hover { background: #f2f8f5; }
.catalog-account-tree .domain-item.active { background: var(--green-soft); }
.catalog-account-tree .domain-item strong { font-size: 14px; }
.catalog-account-tree .account-error { padding: 18px; background: var(--surface); }
.catalog-account-tree .domain-list-empty { border: 1px dashed var(--line-strong); border-radius: var(--radius); background: var(--surface); }

.workspace { grid-area: workspace; min-width: 0; }
.mobile-header { display: none; }

.state-view {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--muted);
}
.state-view strong { color: var(--text); font-size: 16px; }
.state-view > svg { width: 28px; height: 28px; color: var(--green); }
.error-state > svg { color: var(--red); }
.error-state .button { margin-top: 12px; }
.spinner {
  width: 28px;
  height: 28px;
  margin-bottom: 8px;
  border: 3px solid #dce5e2;
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.busy svg, .is-loading svg { animation: spin 0.8s linear infinite; }
.content-loading { opacity: 0.58; pointer-events: none; }

.domain-header {
  padding: 32px 38px 0;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.title-row, .section-heading, .domain-title-line, .header-actions, .section-actions {
  display: flex;
  align-items: center;
}
.title-row, .section-heading { justify-content: space-between; gap: 20px; }
.domain-title-line { gap: 12px; margin-top: 5px; }
.domain-title-link {
  min-width: 0;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: inherit;
  text-decoration: none;
}
.domain-title-link h1 { margin: 0; }
.domain-title-link svg { width: 16px; height: 16px; flex: 0 0 auto; color: var(--muted); }
.domain-title-link:hover { color: var(--green-dark); }
.domain-title-link:hover svg { color: var(--green); }
.domain-title-link:focus-visible { border-radius: 3px; outline: 3px solid rgba(20, 125, 100, 0.2); outline-offset: 3px; }
.header-actions, .section-actions { gap: 8px; }
.domain-heading-content { min-width: 0; }
.domain-note-line { display: flex; align-items: flex-start; gap: 6px; max-width: 760px; margin-top: 8px; }
.domain-note-text { color: #46544f; font-size: 14px; line-height: 1.6; white-space: pre-wrap; overflow-wrap: anywhere; }
.domain-note-text.empty { color: var(--muted); }
.note-edit-button { width: 26px; height: 26px; flex: 0 0 auto; display: grid; place-items: center; margin-top: -4px; border: 0; border-radius: 4px; background: transparent; color: var(--muted); }
.note-edit-button:hover { background: var(--surface-soft); color: var(--green); }
.note-edit-button svg { width: 15px; height: 15px; }

.edit-lock-control {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 11px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}
.edit-lock-control input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.edit-lock-control:focus-within { box-shadow: 0 0 0 3px rgba(167, 96, 12, 0.14); }
.edit-lock-track { width: 30px; height: 16px; flex: 0 0 auto; padding: 2px; border-radius: 8px; background: #a9b5b1; transition: background 0.16s ease; }
.edit-lock-track span { display: block; width: 12px; height: 12px; border-radius: 50%; background: white; box-shadow: 0 1px 2px rgba(24, 33, 31, 0.3); transition: transform 0.16s ease; }
.edit-lock-control.locked { border-color: #d8b57d; background: var(--amber-soft); color: var(--amber); }
.edit-lock-control.locked .edit-lock-track { background: var(--amber); }
.edit-lock-control.locked .edit-lock-track span { transform: translateX(14px); }
.edit-lock-control:has(input:disabled) { cursor: wait; opacity: 0.6; }

.eyebrow {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

h1, h2, p { margin: 0; }
h1 { font-size: 24px; line-height: 1.25; }
h2 { font-size: 18px; line-height: 1.3; }

.status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--green-soft);
  color: var(--green-dark);
  font-size: 11px;
  font-weight: 700;
}
.status-badge::before { content: ""; width: 6px; height: 6px; margin-right: 6px; border-radius: 50%; background: currentColor; }
.status-badge.warning { background: var(--amber-soft); color: #8a520d; }
.status-badge.danger { background: var(--red-soft); color: var(--red); }

.domain-status-notice {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr) max-content;
  align-items: center;
  gap: 10px;
  margin-top: 20px;
  padding: 13px 14px;
  border-left: 3px solid var(--red);
  background: var(--red-soft);
  color: #7f211b;
}
.domain-status-notice > svg { width: 18px; height: 18px; }
.domain-status-notice strong, .domain-status-notice span { display: block; }
.domain-status-notice strong { font-size: 12px; }
.domain-status-notice span { margin-top: 3px; color: #91433d; font-size: 12px; line-height: 1.5; }
.domain-status-notice .button { min-height: 34px; background: rgba(255, 255, 255, 0.72); color: #7f211b; border-color: #dfaaa6; font-size: 11px; }

.button, .icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-weight: 700;
}
.button { min-height: 38px; gap: 7px; padding: 0 13px; text-decoration: none; }
.icon-button { width: 38px; height: 38px; padding: 0; background: var(--surface); color: var(--text); border-color: var(--line-strong); }
.button.primary { background: var(--green); color: white; }
.button.primary:hover { background: var(--green-dark); }
.button.secondary { background: var(--surface); color: var(--text); border-color: var(--line-strong); }
.button.secondary:hover, .icon-button:hover { background: var(--surface-soft); }
.button.danger { background: var(--red); color: white; }
.button.danger:hover { background: #8f1c14; }

.domain-meta {
  display: grid;
  grid-template-columns: 1fr 1.8fr 1fr 1fr;
  margin-top: 26px;
  border-top: 1px solid var(--line);
}
.meta-item { min-width: 0; padding: 18px 20px 20px 0; }
.meta-item + .meta-item { padding-left: 22px; border-left: 1px solid var(--line); }
.meta-item span, .meta-item strong { display: block; }
.meta-item span { margin-bottom: 7px; color: var(--muted); font-size: 11px; }
.meta-item strong { overflow: hidden; color: var(--text); font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.nameserver-item strong { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.value-on { color: var(--green-dark) !important; }
.value-off { color: var(--amber) !important; }

.dns-section { padding: 30px 38px 48px; }
.section-heading p { margin-top: 5px; color: var(--muted); font-size: 12px; }
.edit-lock-notice { display: grid; grid-template-columns: 18px max-content minmax(0, 1fr); align-items: center; gap: 8px; margin-top: 18px; padding: 11px 12px; border-left: 3px solid var(--amber); background: var(--amber-soft); color: #77480d; font-size: 12px; }
.edit-lock-notice svg { width: 16px; height: 16px; }
.edit-lock-notice span { color: #8a622d; }

.record-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-top: 22px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}
.record-search { width: min(360px, 40%); padding: 0 10px; border-color: var(--line-strong); background: var(--surface); color: var(--muted); }
.record-search:focus-within { border-color: var(--green); box-shadow: 0 0 0 3px rgba(20, 125, 100, 0.1); }

.type-filters { display: flex; gap: 3px; padding: 3px; border: 1px solid var(--line); border-radius: var(--radius); background: #eaf0ed; }
.filter-button { min-height: 30px; padding: 0 10px; border: 0; border-radius: 4px; background: transparent; color: var(--muted); font-size: 11px; font-weight: 700; }
.filter-button:hover { color: var(--text); }
.filter-button.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(24, 33, 31, 0.08); }

.table-wrap { min-height: 360px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.dns-table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.dns-table th { height: 42px; padding: 0 16px; background: #f0f4f2; color: var(--muted); font-size: 11px; text-align: left; }
.dns-table th:nth-child(1) { width: 92px; }
.dns-table th:nth-child(2) { width: 23%; }
.dns-table th:nth-child(4) { width: 92px; }
.dns-table th:nth-child(5) { width: 92px; }
.dns-table td { height: 61px; padding: 10px 16px; border-top: 1px solid var(--line); vertical-align: middle; }
.dns-table tr:hover td { background: #fbfcfb; }
.record-type { display: inline-flex; min-width: 48px; justify-content: center; padding: 4px 7px; border-radius: 4px; background: var(--blue-soft); color: var(--blue); font-size: 11px; font-weight: 800; }
.record-name { overflow-wrap: anywhere; font-weight: 700; }
.record-values { display: flex; flex-direction: column; gap: 3px; }
.record-values code { display: block; overflow: hidden; color: #3b4844; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.record-values small { color: var(--muted); }
.row-actions { display: flex; justify-content: flex-end; gap: 4px; }
.table-action { width: 32px; height: 32px; display: grid; place-items: center; border: 0; border-radius: 4px; background: transparent; color: var(--muted); }
.table-action:hover { background: var(--surface-soft); color: var(--text); }
.table-action.danger-action:hover { background: var(--red-soft); color: var(--red); }
.empty-records { min-height: 315px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 7px; color: var(--muted); }
.empty-records svg { width: 28px; height: 28px; margin-bottom: 5px; }
.empty-records strong { color: var(--text); }

.modal {
  width: min(600px, calc(100vw - 32px));
  padding: 0;
  border: 0;
  border-radius: 8px;
  color: var(--text);
  box-shadow: var(--shadow);
}
.modal::backdrop { background: rgba(11, 17, 15, 0.55); }
.modal form { padding: 24px; }
.modal-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 22px; }
.modal-header h2 { margin-top: 4px; }
.modal-close { border: 0; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 17px; }
.field { display: flex; min-width: 0; flex-direction: column; gap: 7px; }
.field > span { color: #394641; font-size: 12px; font-weight: 700; }
.field input, .field select, .field textarea {
  width: 100%;
  min-height: 40px;
  padding: 9px 11px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  outline: 0;
  background: var(--surface);
  color: var(--text);
}
.field textarea { min-height: 104px; resize: vertical; line-height: 1.5; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(20, 125, 100, 0.1); }
.field input:disabled, .field select:disabled { background: var(--surface-soft); color: var(--muted); cursor: not-allowed; }
.field small { color: var(--muted); font-size: 11px; }
.full-field { grid-column: 1 / -1; }
.account-form-grid { grid-template-columns: 1fr; }
.checkbox-field { display: flex; align-items: flex-start; gap: 10px; padding: 11px 12px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface-soft); cursor: pointer; }
.checkbox-field input { width: 16px; height: 16px; margin: 2px 0 0; accent-color: var(--green); }
.checkbox-field span { min-width: 0; }
.checkbox-field strong, .checkbox-field small { display: block; }
.checkbox-field strong { font-size: 12px; }
.checkbox-field small { margin-top: 4px; color: var(--muted); font-size: 11px; line-height: 1.45; }
.compact-form-modal { width: min(500px, calc(100vw - 32px)); }

.admin-modal { width: min(760px, calc(100vw - 32px)); }
.admin-dialog-content { padding: 24px; }
.admin-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding-bottom: 15px; }
.admin-toolbar p { color: var(--muted); font-size: 12px; }
.admin-create-form { margin-bottom: 18px; padding: 18px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.inline-form-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.admin-list { border-top: 1px solid var(--line); }
.admin-row { min-height: 72px; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.admin-identity { min-width: 0; }
.admin-identity strong { display: flex; align-items: center; gap: 7px; font-size: 13px; }
.admin-identity span { display: block; margin-top: 4px; overflow: hidden; color: var(--muted); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.current-admin-badge { padding: 2px 6px; border-radius: 4px; background: var(--green-soft); color: var(--green-dark); font-size: 9px; font-weight: 800; }
.admin-actions { display: flex; align-items: center; gap: 5px; }
.admin-active-control { min-height: 32px; display: inline-flex; align-items: center; gap: 6px; padding: 0 8px; color: var(--muted); font-size: 11px; cursor: pointer; }
.admin-active-control input { width: 15px; height: 15px; accent-color: var(--green); }
.admin-empty { padding: 28px 0; color: var(--muted); text-align: center; }

.notice { display: flex; align-items: center; gap: 8px; margin-top: 16px; padding: 11px 12px; border-left: 3px solid var(--blue); background: var(--blue-soft); color: #385a7d; font-size: 12px; }
.notice svg { flex: 0 0 auto; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 24px; padding-top: 18px; border-top: 1px solid var(--line); }
.note-modal-actions .modal-action-spacer { flex: 1; }

.compact-modal { width: min(440px, calc(100vw - 32px)); text-align: center; }
.compact-modal form { padding: 28px; }
.compact-modal p { margin: 8px 0 20px; color: var(--muted); line-height: 1.6; }
.compact-modal .field { text-align: left; }
.danger-icon { width: 42px; height: 42px; display: grid; place-items: center; margin: 0 auto 13px; border-radius: 50%; background: var(--red-soft); color: var(--red); }
.danger-icon svg { width: 20px; height: 20px; }

.toast-region { position: fixed; right: 22px; bottom: 22px; z-index: 100; display: flex; width: min(380px, calc(100vw - 32px)); flex-direction: column; gap: 8px; }
.toast { display: flex; align-items: flex-start; gap: 10px; padding: 13px 14px; border: 1px solid #b9daca; border-radius: var(--radius); background: #f2fff9; box-shadow: 0 10px 26px rgba(24, 33, 31, 0.14); color: var(--green-dark); }
.toast.error { border-color: #ecc4bf; background: #fff7f5; color: var(--red); }
.toast.warning { border-color: #e4c794; background: var(--amber-soft); color: #80500f; }
.toast span { flex: 1; line-height: 1.45; }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
[hidden] { display: none !important; }

@media (max-width: 1180px) {
  .catalog-account-tree .account-domains { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .catalog-account-tree .account-toggle-text { grid-template-columns: minmax(150px, 0.8fr) minmax(220px, 1.2fr) auto; }
}

@media (max-width: 980px) {
  .app-shell { grid-template-columns: 72px minmax(0, 1fr); }
  .admin-rail { padding-left: 7px; padding-right: 7px; }
  .rail-nav-button { min-height: 50px; }
  .domain-catalog { padding: 30px 26px 50px; }
  .catalog-toolbar { grid-template-columns: 1fr; }
  .catalog-toolbar .domain-status-filters { width: fit-content; }
  .catalog-account-tree .account-toggle-text { grid-template-columns: minmax(150px, 1fr) minmax(210px, 1.3fr); gap: 5px 16px; }
  .catalog-account-tree .account-toggle-text small:last-child { grid-column: 1 / -1; text-align: left; }
  .domain-header, .dns-section { padding-left: 26px; padding-right: 26px; }
  .domain-meta { grid-template-columns: 1fr 1.5fr; }
  .meta-item:nth-child(3) { border-left: 0; }
  .meta-item:nth-child(n + 3) { border-top: 1px solid var(--line); }
  .record-toolbar { align-items: flex-start; flex-direction: column; }
  .record-search { width: 100%; }
  .type-filters { max-width: 100%; overflow-x: auto; }
}

@media (max-width: 720px) {
  .auth-view { padding: 0; background: var(--surface); }
  .auth-panel { width: 100%; min-height: 100vh; padding: 30px 22px; border: 0; border-radius: 0; box-shadow: none; }
  .auth-heading { margin-top: 42px; }
  .app-shell { display: block; }
  .admin-rail { display: none; }
  .workspace { min-height: 100vh; }
  .mobile-header { display: grid; grid-template-columns: 1fr; gap: 10px; padding: 14px 18px; background: var(--sidebar); color: white; }
  .mobile-brand-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
  .mobile-brand { color: #eef5f2; }
  .mobile-brand svg { color: #70d5b5; }
  .mobile-brand-row .mini-icon-button { border: 1px solid #41554f; color: #70d5b5; }
  .mobile-domain-toggle { min-height: 54px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 11px; border: 1px solid #41554f; border-radius: var(--radius); background: var(--sidebar-soft); color: white; text-align: left; }
  .mobile-domain-toggle span { min-width: 0; }
  .mobile-domain-toggle small, .mobile-domain-toggle strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .mobile-domain-toggle small { margin-bottom: 3px; color: #9eafa9; font-size: 10px; }
  .mobile-domain-toggle strong { font-size: 13px; }
  .mobile-domain-toggle > svg { flex: 0 0 auto; transition: transform 0.16s ease; }
  .mobile-domain-toggle[aria-expanded="true"] > svg { transform: rotate(180deg); }
  .mobile-domain-panel { max-height: 56vh; padding: 10px; border: 1px solid #354742; border-radius: var(--radius); background: #1d2926; overflow-y: auto; }
  .mobile-search-box { position: sticky; top: 0; z-index: 2; margin-bottom: 8px; border-color: #354742; background: #293733; color: #9eafa9; }
  .mobile-search-box:focus-within { border-color: #5c8278; box-shadow: none; }
  .mobile-domain-status-filters { border-color: #30423d; background: #1d2926; }
  .mobile-domain-status-filters .domain-status-filter { color: #93a49e; }
  .mobile-domain-status-filters .domain-status-filter:hover { background: #263530; color: #e8f0ed; }
  .mobile-domain-status-filters .domain-status-filter.active { background: #30423d; color: white; box-shadow: none; }
  .mobile-domain-status-filters .domain-status-filter strong { color: #b8c8c3; }
  .mobile-domain-panel .account-tree { overflow: visible; }
  .mobile-domain-panel .account-group { padding-bottom: 5px; border-color: #2b3935; }
  .mobile-domain-panel .account-toggle { color: #dbe6e2; }
  .mobile-domain-panel .account-toggle:hover { background: #202d2a; }
  .mobile-domain-panel .account-toggle-text small { color: #81938d; }
  .mobile-domain-panel .account-toggle-text small + small { color: #71847d; }
  .mobile-domain-panel .domain-item { color: #d9e4e0; }
  .mobile-domain-panel .domain-item:hover { background: #202d2a; }
  .mobile-domain-panel .domain-item.active { background: #2a3935; color: white; }
  .mobile-domain-panel .domain-item small { color: #93a49e; }
  .mobile-domain-panel .domain-item small.domain-item-note { color: #c6d3cf; }
  .mobile-domain-panel .domain-item small.domain-item-expiry { color: #8fa19b; }
  .domain-catalog { min-height: calc(100vh - 66px); padding: 24px 18px 40px; }
  .catalog-header h1 { font-size: 22px; }
  .catalog-toolbar { gap: 10px; margin-top: 20px; }
  .catalog-toolbar .domain-status-filters { width: 100%; display: grid; grid-template-columns: 1fr 1fr; }
  .catalog-toolbar .domain-status-filter { min-width: 0; }
  .catalog-storage { align-items: flex-start; flex-wrap: wrap; padding: 2px 0; }
  .catalog-storage span:last-child { width: 100%; padding-left: 18px; white-space: normal; }
  .catalog-account-tree { gap: 10px; margin-top: 8px; }
  .catalog-account-tree .account-group-header,
  .catalog-account-tree .account-toggle { min-height: 70px; }
  .catalog-account-tree .account-toggle { padding: 10px 12px; }
  .catalog-account-tree .account-toggle-text { display: block; }
  .catalog-account-tree .account-toggle-text small { margin-top: 3px; white-space: normal; }
  .catalog-account-tree .account-toggle-text small:last-child { text-align: left; }
  .catalog-account-tree .account-domains { grid-template-columns: 1fr; }
  .catalog-account-tree .domain-item { min-height: 80px; padding: 12px; }
  .state-view { min-height: calc(100vh - 132px); }
  .domain-header { padding: 22px 18px 0; }
  .dns-section { padding: 23px 18px 36px; }
  .title-row { align-items: flex-start; }
  .domain-title-line { align-items: flex-start; flex-direction: column; gap: 7px; }
  .domain-title-link { max-width: calc(100vw - 36px); }
  .domain-title-link h1 { max-width: calc(100vw - 62px); }
  .domain-note-line { max-width: calc(100vw - 36px); }
  .domain-status-notice { grid-template-columns: 18px minmax(0, 1fr); }
  .domain-status-notice .button { grid-column: 1 / -1; width: 100%; }
  h1 { max-width: calc(100vw - 110px); overflow-wrap: anywhere; font-size: 20px; }
  .header-actions .button { display: none; }
  .header-actions .back-to-domains-button { width: 38px; display: inline-flex; padding: 0; }
  .back-to-domains-button span { display: none; }
  .edit-lock-control { padding: 0 9px; }
  .edit-lock-control > span:last-child { display: none; }
  .edit-lock-notice { grid-template-columns: 18px minmax(0, 1fr); }
  .edit-lock-notice span { grid-column: 1 / -1; padding-left: 26px; }
  .domain-meta { grid-template-columns: 1fr 1fr; margin-top: 20px; }
  .meta-item { padding: 14px 12px 15px 0; }
  .meta-item + .meta-item { padding-left: 14px; }
  .meta-item:nth-child(3) { border-left: 0; }
  .meta-item:nth-child(n + 3) { border-top: 1px solid var(--line); }
  .nameserver-item strong { white-space: normal; overflow-wrap: anywhere; }
  .section-heading { align-items: flex-start; }
  .section-actions .button { width: 38px; padding: 0; }
  .section-actions .button span { display: none; }
  .record-toolbar { margin-top: 17px; }
  .type-filters { width: 100%; }
  .filter-button { flex: 0 0 auto; }
  .table-wrap { border: 0; background: transparent; overflow: visible; }
  .dns-table, .dns-table tbody { display: block; }
  .dns-table thead { display: none; }
  .dns-table tr { display: grid; grid-template-columns: 82px minmax(0, 1fr) 72px; margin-bottom: 9px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
  .dns-table td { height: auto; min-width: 0; padding: 11px 12px; border: 0; }
  .dns-table td:nth-child(1) { grid-column: 1; grid-row: 1; }
  .dns-table td:nth-child(2) { grid-column: 2; grid-row: 1; padding-left: 0; }
  .dns-table td:nth-child(3) { grid-column: 1 / -1; grid-row: 2; padding-top: 0; }
  .dns-table td:nth-child(4) { grid-column: 1 / 3; grid-row: 3; border-top: 1px solid var(--line); color: var(--muted); font-size: 11px; }
  .dns-table td:nth-child(4)::before { content: "TTL "; }
  .dns-table td:nth-child(5) { grid-column: 3; grid-row: 3; padding: 5px 8px; border-top: 1px solid var(--line); }
  .record-values code { white-space: normal; overflow-wrap: anywhere; }
  .row-actions { height: 32px; }
  .empty-records { min-height: 280px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
  .form-grid { grid-template-columns: 1fr; }
  .full-field { grid-column: auto; }
  .modal form { padding: 20px; }
  .modal-actions .button { flex: 1; }
  .note-modal-actions { flex-wrap: wrap; }
  .note-modal-actions .modal-action-spacer { display: none; }
  .note-modal-actions .button { min-width: calc(50% - 4px); }
  .admin-dialog-content { padding: 20px; }
  .admin-toolbar { align-items: flex-start; }
  .admin-toolbar .button { width: 38px; padding: 0; }
  .admin-toolbar .button span { display: none; }
  .admin-row { grid-template-columns: 1fr; gap: 9px; }
  .admin-actions { justify-content: flex-end; }
  .inline-form-actions .button { flex: 1; }
  .toast-region { right: 16px; bottom: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; }
}
