:root {
  --ink: #102820;
  --muted: #65746e;
  --line: #dfe6e2;
  --surface: #ffffff;
  --canvas: #f4f7f5;
  --green: #176b4d;
  --green-bright: #2daf7c;
  --blue: #3f6fb0;
  --amber: #b97818;
  --danger: #b63f3f;
  --shadow: 0 18px 55px rgba(21, 47, 38, 0.09);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background: var(--canvas);
  font-synthesis: none;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; min-height: 100vh; background: linear-gradient(180deg, #f9fbfa 0, var(--canvas) 420px); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); }
.page-glow { position: fixed; inset: -240px auto auto 55%; width: 600px; height: 500px; pointer-events: none; background: radial-gradient(circle, rgba(53, 171, 126, .12), transparent 66%); }

.topbar { position: relative; z-index: 2; height: 78px; padding: 0 clamp(20px, 4vw, 64px); display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid rgba(214, 226, 219, .9); background: rgba(251, 253, 252, .84); backdrop-filter: blur(14px); }
.brand { color: inherit; text-decoration: none; display: inline-flex; align-items: center; gap: 12px; }
.brand-mark { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 13px; color: white; font-weight: 800; letter-spacing: -.04em; background: linear-gradient(145deg, #194d3a, #1d7a57); box-shadow: 0 8px 18px rgba(23, 107, 77, .22); }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 15px; }
.brand small { color: #829089; font-size: 10px; letter-spacing: .13em; text-transform: uppercase; margin-top: 2px; }
.topbar-actions { display: flex; align-items: center; gap: 14px; }
.health { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; color: var(--muted); }
.health i { width: 8px; height: 8px; border-radius: 999px; background: #9ba8a2; box-shadow: 0 0 0 4px rgba(155, 168, 162, .12); }
.health.ok i { background: var(--green-bright); box-shadow: 0 0 0 4px rgba(45, 175, 124, .13); }
.health.bad i { background: var(--danger); }

main { position: relative; z-index: 1; }
.login-shell { min-height: calc(100vh - 78px); display: grid; place-items: center; padding: 32px 20px; }
.login-card { width: min(100%, 440px); padding: 42px; border: 1px solid rgba(220, 229, 224, .95); border-radius: 24px; background: rgba(255, 255, 255, .94); box-shadow: var(--shadow); }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 8px; font-size: clamp(28px, 4vw, 40px); letter-spacing: -.045em; line-height: 1.1; }
h2 { margin-bottom: 0; font-size: 22px; letter-spacing: -.025em; }
.eyebrow { margin-bottom: 9px; font-size: 10px; letter-spacing: .18em; font-weight: 800; color: var(--green); }
.muted { color: var(--muted); line-height: 1.6; }
label { display: grid; gap: 8px; color: #43534d; font-size: 13px; font-weight: 650; }
label small { color: #8b9792; font-weight: 500; }
input, select, textarea { width: 100%; color: var(--ink); border: 1px solid #d7e0dc; border-radius: 11px; background: white; outline: none; transition: border-color .15s, box-shadow .15s; }
input, select { height: 43px; padding: 0 13px; }
textarea { resize: vertical; padding: 12px 13px; }
input:focus, select:focus, textarea:focus { border-color: #56a487; box-shadow: 0 0 0 3px rgba(45, 149, 110, .11); }
.login-card form { display: grid; gap: 18px; margin-top: 28px; }
.secret-field { position: relative; }
.secret-field input { padding-right: 66px; }
.secret-field .icon-button { position: absolute; right: 5px; top: 5px; height: 33px; width: 54px; }
.form-error { min-height: 18px; margin: 0; color: var(--danger); font-size: 12px; line-height: 1.5; }

.button, .icon-button { border: 1px solid transparent; border-radius: 10px; background: none; color: var(--ink); font-weight: 700; transition: transform .12s, background .15s, border-color .15s, opacity .15s; }
.button { min-height: 40px; padding: 0 16px; }
.button:hover, .icon-button:hover { transform: translateY(-1px); }
.button:disabled, .icon-button:disabled { cursor: wait; opacity: .55; transform: none; }
.button.primary { color: #fff; background: var(--green); box-shadow: 0 7px 16px rgba(23, 107, 77, .15); }
.button.primary:hover { background: #115c41; }
.button.secondary { color: var(--green); background: #e8f5ef; border-color: #d3eadf; }
.button.quiet { border-color: #dce4e0; background: rgba(255, 255, 255, .65); }
.button.danger { color: white; background: var(--danger); }
.button.wide { width: 100%; }
.icon-button { display: inline-grid; place-items: center; height: 36px; min-width: 36px; padding: 0 8px; border-color: #dce4e0; background: #fff; font-size: 12px; }

.dashboard { width: min(1480px, calc(100% - 40px)); margin: 0 auto; padding: 48px 0 64px; }
.hero-row { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; margin-bottom: 28px; }
.hero-row .muted { margin-bottom: 0; }
.hero-actions { display: flex; gap: 10px; flex-shrink: 0; }
.sync-icon { display: inline-block; margin-right: 4px; font-size: 17px; }
.syncing .sync-icon { animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.stats { display: grid; grid-template-columns: repeat(5, 1fr); gap: 14px; }
.stat-card { position: relative; overflow: hidden; min-height: 140px; padding: 22px; border: 1px solid var(--line); border-radius: 17px; background: var(--surface); box-shadow: 0 8px 25px rgba(26, 54, 44, .035); }
.stat-card::after { content: ""; position: absolute; width: 100px; height: 100px; border-radius: 999px; right: -42px; top: -50px; opacity: .12; background: currentColor; }
.stat-card span, .stat-card small { display: block; color: var(--muted); font-size: 12px; }
.stat-card strong { display: block; margin: 10px 0 4px; font-size: 34px; letter-spacing: -.04em; }
.stat-card.green { color: var(--green); }.stat-card.blue { color: var(--blue); }.stat-card.amber { color: var(--amber); }.stat-card.violet { color: #7659a8; }.stat-card.slate { color: #65746e; }

.sync-strip { display: grid; grid-template-columns: auto repeat(4, 1fr); align-items: center; gap: 22px; margin: 14px 0; padding: 16px 20px; border: 1px solid #d9e8e1; border-radius: 14px; background: #edf7f2; }
.pulse-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--green-bright); box-shadow: 0 0 0 5px rgba(45, 175, 124, .12); }
.sync-strip span, .sync-strip strong { display: block; }
.sync-strip span { color: #70817a; font-size: 10px; letter-spacing: .05em; text-transform: uppercase; }
.sync-strip strong { margin-top: 3px; font-size: 12px; font-weight: 700; }

.registry-card { overflow: hidden; border: 1px solid var(--line); border-radius: 17px; background: var(--surface); box-shadow: 0 12px 35px rgba(26, 54, 44, .045); }
.toolbar { display: grid; grid-template-columns: minmax(240px, 1fr) repeat(3, 145px) auto; gap: 10px; padding: 16px; border-bottom: 1px solid #e6ece9; }
.search-wrap { position: relative; }
.search-wrap span { position: absolute; left: 14px; top: 9px; color: #7c8b85; font-size: 20px; }
.search-wrap input { padding-left: 42px; background: #f8faf9; }
.toolbar select { background-color: #f8faf9; }
.table-wrap { position: relative; min-height: 320px; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
th { height: 46px; padding: 0 14px; color: #72817b; background: #f8faf9; font-size: 10px; letter-spacing: .06em; text-align: left; text-transform: uppercase; white-space: nowrap; }
td { height: 65px; padding: 8px 14px; border-top: 1px solid #edf1ef; vertical-align: middle; white-space: nowrap; }
tbody tr:hover { background: #fbfdfc; }
.address-cell { display: flex; align-items: center; gap: 8px; }
.address-cell code { width: 145px; overflow: hidden; text-overflow: ellipsis; color: #26483c; font-size: 11px; }
.copy-button { min-width: 42px; height: 27px; padding: 0 9px; border: 1px solid #d8e2dd; border-radius: 8px; color: #315f4e; background: #f5f9f7; font-size: 10px; font-weight: 750; white-space: nowrap; }
.copy-button:hover { border-color: #91b6a6; color: #145d42; background: #eaf5f0; }
.level { display: inline-grid; place-items: center; min-width: 31px; height: 27px; border-radius: 8px; color: #1a634a; background: #e8f5ef; font-weight: 800; }
.level.current { color: #315d97; background: #eaf1fa; }
.level.unknown { color: #7e8b86; background: #edf1ef; }
.level-cell small { display: block; margin-top: 3px; color: #93a09a; font-size: 9px; }
.badge { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 9px; border-radius: 999px; font-size: 10px; font-weight: 750; }
.badge::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.badge.active { color: #16704e; background: #e8f6f0; }.badge.pending { color: #376da8; background: #ebf2fa; }.badge.expired { color: #a26914; background: #fbf2e4; }.badge.paused { color: #70539e; background: #f0ebf8; }.badge.removed { color: #9a4d4d; background: #f9eaea; }
.source { color: #61726b; }
.row-actions { display: flex; justify-content: flex-end; gap: 5px; }
.row-actions button { height: 30px; border: 1px solid #e0e7e3; border-radius: 8px; background: #fff; color: #5b6c65; font-size: 11px; }
.row-actions button:hover { border-color: #9bb9ac; color: var(--green); }
.row-actions .remove:hover { color: var(--danger); border-color: #ddb1b1; }
.empty { position: absolute; inset: 46px 0 0; display: grid; place-content: center; text-align: center; color: var(--muted); }
.empty span { font-size: 40px; color: #a3b3ac; }.empty strong { color: #53645d; }.empty p { margin: 4px 0 0; font-size: 12px; }
.table-loading { position: absolute; inset: 46px 0 0; display: grid; place-items: center; color: var(--muted); background: rgba(255,255,255,.76); backdrop-filter: blur(2px); }
.pagination { min-height: 58px; padding: 10px 16px; display: flex; align-items: center; justify-content: space-between; border-top: 1px solid #e8eeeb; color: var(--muted); font-size: 12px; }
.pagination > div { display: flex; align-items: center; gap: 10px; }

dialog { width: min(calc(100% - 32px), 590px); padding: 0; border: 0; border-radius: 20px; background: transparent; box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(12, 31, 24, .46); backdrop-filter: blur(5px); }
.dialog-card { display: grid; gap: 20px; margin: 0; padding: 26px; background: white; }
.dialog-card > header { display: flex; justify-content: space-between; align-items: flex-start; }
.dialog-close { width: 34px; height: 34px; border: 1px solid #dfe6e2; border-radius: 9px; background: white; color: #65746e; font-size: 20px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid .full { grid-column: 1 / -1; }
.dialog-card > footer { display: flex; justify-content: flex-end; gap: 9px; padding-top: 4px; }
.dialog-card.compact code { display: block; overflow-wrap: anywhere; padding: 12px; border-radius: 9px; color: #315448; background: #f1f6f3; font-size: 11px; }
.dialog-card.compact > p { margin-bottom: 0; color: var(--muted); line-height: 1.55; }
.danger-text { color: var(--danger); }
#audit-dialog { width: min(calc(100% - 32px), 720px); overflow: hidden; background: #fff; }
.audit-card { width: 100%; height: min(720px, calc(100vh - 48px)); min-height: 420px; grid-template-rows: auto minmax(0, 1fr) auto; gap: 0; padding: 0; overflow: hidden; border: 1px solid #dbe4df; border-radius: 20px; background: #fff; box-shadow: 0 24px 70px rgba(12, 31, 24, .22); }
.audit-card > header { padding: 24px 26px 20px; border-bottom: 1px solid var(--line); background: #fff; }
.audit-list { min-height: 0; overflow-y: auto; display: block; padding: 0 26px; background: #fff; scrollbar-gutter: stable; }
.audit-list[aria-busy="true"] { opacity: .62; }
.audit-item { padding: 17px 2px; border-bottom: 1px solid #e4ebe7; background: #fff; }
.audit-item:last-child { border-bottom: 0; }
.audit-item > div { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 16px; }
.audit-item strong { color: #173d30; font-size: 13px; }
.audit-item time { color: #52655d; font-size: 11px; font-weight: 650; white-space: nowrap; }
.audit-item code { display: block; margin-top: 7px; color: #315448; font-size: 11px; overflow-wrap: anywhere; }
.audit-item .audit-address { display: flex; grid-template-columns: none; align-items: center; justify-content: space-between; gap: 12px; margin-top: 7px; }
.audit-item .audit-address code { min-width: 0; flex: 1; margin-top: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.audit-item p { margin: 6px 0 0; color: #6a7973; font-size: 11px; line-height: 1.45; }
.audit-empty { display: grid; min-height: 220px; place-items: center; color: var(--muted); font-size: 13px; }
.audit-pagination { min-height: 62px; padding: 10px 26px; display: flex; align-items: center; justify-content: space-between; gap: 16px; border-top: 1px solid var(--line); background: #f8faf9; color: #53645d; font-size: 12px; }
.audit-pagination > div { display: flex; align-items: center; gap: 10px; }
.toast-region { position: fixed; z-index: 20; right: 20px; bottom: 20px; display: grid; gap: 8px; }
.toast { max-width: 360px; padding: 13px 16px; border: 1px solid #cfe0d8; border-radius: 11px; color: #24483b; background: white; box-shadow: 0 12px 35px rgba(20, 47, 37, .14); font-size: 12px; animation: toast-in .18s ease-out; }
.toast.error { color: #8f3434; border-color: #edc7c7; }
@keyframes toast-in { from { opacity: 0; transform: translateY(7px); } }

@media (max-width: 980px) {
  .stats { grid-template-columns: repeat(3, 1fr); }
  .sync-strip { grid-template-columns: auto repeat(2, 1fr); }
  .toolbar { grid-template-columns: repeat(4, 1fr); }.search-wrap { grid-column: 1 / -1; }
}
@media (max-width: 640px) {
  .topbar { padding: 0 16px; }.health span { display: none; }.dashboard { width: min(100% - 24px, 1480px); padding-top: 30px; }
  .hero-row { align-items: flex-start; flex-direction: column; }.hero-actions { width: 100%; }.hero-actions .button { flex: 1; }
  .stats { grid-template-columns: 1fr 1fr; gap: 9px; }.stat-card { min-height: 122px; padding: 17px; }.stat-card:last-child { grid-column: 1 / -1; }.stat-card strong { font-size: 29px; }
  .sync-strip { grid-template-columns: auto 1fr; }.sync-strip > div:nth-child(n+4) { display: none; }
  .toolbar { grid-template-columns: 1fr 1fr; }.toolbar .button { grid-column: 1 / -1; }
  .login-card { padding: 28px 22px; }.form-grid { grid-template-columns: 1fr; }.form-grid .full { grid-column: auto; }
  .audit-card { height: min(680px, calc(100vh - 24px)); min-height: 360px; }.audit-card > header, .audit-list { padding-left: 18px; padding-right: 18px; }.audit-pagination { padding-left: 18px; padding-right: 18px; }.audit-item > div { grid-template-columns: 1fr; gap: 4px; }.audit-item time { white-space: normal; }
}
