@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=Noto+Sans+SC:wght@400;500;600;700&display=swap');

:root {
  --ink: #1b1d29;
  --muted: #73778a;
  --line: #e8eaf2;
  --panel: #ffffff;
  --canvas: #f6f7fb;
  --primary: #5d5ce2;
  --primary-dark: #4746bb;
  --primary-soft: #eeedff;
  --success: #2dba91;
  --danger: #ec6b7b;
  --shadow: 0 18px 55px rgba(44, 48, 87, .08);
  --radius: 18px;
  font-family: 'DM Sans', 'Noto Sans SC', sans-serif;
  color: var(--ink);
  background: var(--canvas);
  font-synthesis: none;
}

:root[data-theme="dark"] {
  --ink: #f4f5ff;
  --muted: #a5a8bb;
  --line: #30334a;
  --panel: #202238;
  --canvas: #151729;
  --primary-soft: #2d2d5b;
  --shadow: 0 18px 55px rgba(0, 0, 0, .22);
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; background: var(--canvas); }
button, input, textarea, select { font: inherit; }
button { border: 0; cursor: pointer; }
a { color: inherit; text-decoration: none; }
.boot-screen { min-height: 100vh; display: grid; place-items: center; color: var(--muted); gap: 12px; align-content: center; }
.brand-mark { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 12px; background: var(--primary); color: white; font-weight: 700; font-size: 21px; }
.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 18% 10%, #eeedff 0, transparent 34%), var(--canvas); }
.login-card { width: min(420px, 100%); padding: 32px; background: var(--panel); border: 1px solid var(--line); border-radius: 22px; box-shadow: var(--shadow); }
.login-card > .brand-mark { margin-bottom: 24px; }
.login-card h1 { margin: 0; font-size: 25px; letter-spacing: -.04em; }
.login-card > p { color: var(--muted); font-size: 12px; line-height: 1.7; margin: 9px 0 23px; }
.login-card form { display: grid; gap: 15px; }
.login-error { min-height: 16px; color: var(--danger); font-size: 11px; }
.login-back { margin-top: 10px; }

/* Shared chrome */
.app-shell { min-height: 100vh; display: flex; }
.side-nav { width: 248px; flex: 0 0 248px; background: var(--panel); border-right: 1px solid var(--line); padding: 22px 15px; display: flex; flex-direction: column; }
.brand { display: flex; align-items: center; gap: 11px; padding: 4px 12px 28px; }
.brand .brand-mark { width: 34px; height: 34px; font-size: 18px; border-radius: 11px; }
.brand-copy strong { display: block; font-size: 16px; letter-spacing: -.02em; }
.brand-copy span { display: block; font-size: 11px; color: #9a9eae; margin-top: 2px; }
.nav-label { padding: 0 13px; margin: 9px 0 8px; color: #a4a7b5; font-size: 10px; text-transform: uppercase; letter-spacing: .09em; font-weight: 700; }
.nav-item { width: 100%; display: flex; align-items: center; gap: 11px; padding: 11px 13px; border-radius: 12px; color: #72768a; margin: 3px 0; background: transparent; text-align: left; font-size: 13px; }
.nav-item svg { width: 17px; height: 17px; stroke: currentColor; fill: none; stroke-width: 1.8; }
.nav-item:hover { background: #f6f6ff; color: var(--primary); }
.nav-item.active { background: var(--primary-soft); color: var(--primary-dark); font-weight: 600; }
.nav-footer { margin-top: auto; padding: 15px 10px 3px; border-top: 1px solid var(--line); }
.nav-footer .mini-profile { display: flex; align-items: center; gap: 9px; }
.avatar { border-radius: 50%; object-fit: cover; background: #e9eaff; display: grid; place-items: center; color: var(--primary); font-weight: 700; }
.avatar.sm { width: 32px; height: 32px; font-size: 12px; }
.avatar.md { width: 74px; height: 74px; font-size: 23px; }
.mini-profile strong { display: block; font-size: 12px; }
.mini-profile span { display: block; font-size: 10px; color: var(--muted); margin-top: 2px; }

.main { flex: 1; min-width: 0; }
.topbar { height: 72px; background: color-mix(in srgb, var(--panel) 90%, transparent); backdrop-filter: blur(18px); border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; padding: 0 34px; position: sticky; top: 0; z-index: 4; }
.crumbs { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--muted); }
.crumbs strong { color: var(--ink); font-weight: 600; }
.crumb-sep { color: #bfc2ce; }
.top-actions { display: flex; align-items: center; gap: 12px; }
.icon-btn { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 10px; background: transparent; color: #8c90a0; }
.icon-btn:hover { background: #f4f4fb; color: var(--primary); }
.icon-btn svg { width: 17px; height: 17px; stroke: currentColor; fill: none; stroke-width: 1.8; }
.content { padding: 30px 34px 42px; max-width: 1420px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; margin-bottom: 25px; }
.eyebrow { color: var(--primary); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; font-weight: 700; margin-bottom: 7px; }
.page-head h1 { font-size: 27px; line-height: 1.2; margin: 0; letter-spacing: -.035em; }
.page-head p { margin: 8px 0 0; color: var(--muted); font-size: 13px; }
.head-actions { display: flex; gap: 10px; align-items: center; }
.btn { border-radius: 10px; height: 38px; padding: 0 15px; font-size: 12px; font-weight: 600; display: inline-flex; gap: 7px; align-items: center; justify-content: center; transition: .18s ease; }
.btn svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.btn.primary { color: #fff; background: var(--primary); box-shadow: 0 8px 17px rgba(93,92,226,.22); }
.btn.primary:hover { background: var(--primary-dark); transform: translateY(-1px); }
.btn.ghost { color: #6d7181; background: var(--panel); border: 1px solid var(--line); }
.btn.ghost:hover { color: var(--primary); border-color: #cac9ff; }
.btn.danger { color: var(--danger); background: #fff1f3; }
.btn.small { height: 32px; padding: 0 11px; font-size: 11px; }
.btn.full { width: 100%; }

.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 15px; margin-bottom: 18px; }
.stat-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: 0 7px 22px rgba(44,48,87,.025); }
.stat-top { display: flex; justify-content: space-between; align-items: center; color: var(--muted); font-size: 12px; }
.stat-icon { width: 31px; height: 31px; border-radius: 10px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); }
.stat-icon svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.stat-value { font-size: 28px; letter-spacing: -.04em; font-weight: 700; margin-top: 15px; }
.stat-foot { font-size: 11px; color: var(--muted); margin-top: 5px; }
.stat-foot b { color: var(--success); font-weight: 600; }

.grid-2 { display: grid; grid-template-columns: minmax(0, 1.18fr) minmax(320px, .82fr); gap: 18px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 7px 22px rgba(44,48,87,.025); }
.card-head { display: flex; justify-content: space-between; align-items: center; padding: 18px 20px 15px; border-bottom: 1px solid #f0f1f6; }
.card-head h2 { font-size: 15px; margin: 0; letter-spacing: -.015em; }
.card-head span { color: var(--muted); font-size: 11px; }
.card-body { padding: 18px 20px; }
.profile-card { min-height: 291px; }
.profile-preview { border-radius: 14px; padding: 21px; background: linear-gradient(130deg, #f1efff 0%, #f7f8ff 47%, #ecf8f5 100%); display: flex; align-items: center; gap: 18px; position: relative; overflow: hidden; }
.profile-preview:after { content: ''; width: 160px; height: 160px; position: absolute; right: -65px; top: -70px; border-radius: 50%; background: rgba(255,255,255,.55); }
.profile-copy { position: relative; z-index: 1; }
.profile-copy h3 { margin: 0; font-size: 20px; letter-spacing: -.035em; }
.profile-copy p { color: #6d7086; margin: 6px 0 0; font-size: 12px; line-height: 1.55; max-width: 420px; }
.profile-chips { display: flex; gap: 6px; margin-top: 10px; }
.chip { background: rgba(255,255,255,.75); border: 1px solid rgba(255,255,255,.9); color: #666a7a; border-radius: 999px; padding: 4px 8px; font-size: 10px; }
.profile-url { margin-top: 17px; color: var(--primary); font-size: 12px; font-weight: 600; }
.quick-list { display: grid; gap: 11px; }
.quick-row { display: flex; justify-content: space-between; align-items: center; padding: 12px 13px; background: #fafaff; border: 1px solid #ededfa; border-radius: 11px; }
.quick-row .left { display: flex; gap: 10px; align-items: center; min-width: 0; }
.link-icon { width: 31px; height: 31px; flex: 0 0 31px; display: grid; place-items: center; border-radius: 9px; color: var(--primary); background: #ececff; font-weight: 700; font-size: 12px; }
.quick-row strong { font-size: 12px; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.quick-row small { color: #9b9eac; font-size: 10px; display: block; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 230px; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 3px #e2f7f0; }

.section-stack { display: grid; gap: 18px; margin-top: 18px; }
.field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 15px; }
.field { display: grid; gap: 7px; }
.field.full-span { grid-column: 1 / -1; }
.field label { color: #65697a; font-weight: 600; font-size: 11px; }
.field input, .field textarea, .field select { width: 100%; border: 1px solid #e4e6ef; border-radius: 10px; padding: 10px 11px; outline: none; color: var(--ink); background: color-mix(in srgb, var(--panel) 92%, var(--canvas)); font-size: 12px; transition: .18s; }
.field textarea { min-height: 86px; resize: vertical; line-height: 1.55; }
.field input:focus, .field textarea:focus, .field select:focus { border-color: #aaa9ff; box-shadow: 0 0 0 3px #f0efff; background: #fff; }
.field .hint { color: #9b9eac; font-size: 10px; }
.form-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 17px; }
.custom-settings { margin-top: 22px; padding-top: 20px; border-top: 1px solid var(--line); }
.custom-settings h3 { margin: 0 0 14px; font-size: 14px; }
.color-row { display: flex; gap: 9px; flex-wrap: wrap; }
.color-swatch { width: 29px; height: 29px; border-radius: 9px; border: 2px solid #fff; box-shadow: 0 0 0 1px #e1e3ec; padding: 0; }
.color-swatch.active { box-shadow: 0 0 0 2px var(--primary), 0 0 0 4px #ececff; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 670px; }
th { text-align: left; color: #9b9eac; font-weight: 600; font-size: 10px; letter-spacing: .04em; padding: 0 20px 11px; white-space: nowrap; }
td { padding: 13px 20px; border-top: 1px solid #f0f1f6; font-size: 12px; vertical-align: middle; }
.row-title { display: flex; gap: 10px; align-items: center; }
.row-title strong { font-size: 12px; display: block; }
.row-title span { color: #999cac; font-size: 10px; display: block; margin-top: 3px; max-width: 390px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.table-actions { display: flex; justify-content: flex-end; gap: 5px; }
.table-actions .icon-btn { width: 28px; height: 28px; }
.badge { display: inline-flex; align-items: center; border-radius: 999px; padding: 4px 8px; font-size: 10px; font-weight: 600; }
.badge.on { color: #258b6e; background: #e5f8f2; }
.badge.off { color: #a1a3ae; background: #f0f1f5; }
.status-button { cursor: pointer; border: 0; }
.status-button:hover { filter: brightness(.96); transform: translateY(-1px); }
.empty-state { text-align: center; color: var(--muted); padding: 40px 20px; font-size: 12px; }

/* Public page */
.public-shell { min-height: 100vh; background: var(--canvas); padding: 28px; }
.public-top { max-width: 1080px; margin: 0 auto 18px; display: flex; justify-content: space-between; align-items: center; }
.public-top .brand { padding: 0; }
.public-top .brand-copy span { color: #858998; }
.public-top .btn { background: #fff; }
.public-grid { max-width: 1080px; margin: 0 auto; display: grid; grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr); gap: 18px; align-items: start; }
.public-shell .public-top .btn, .public-shell .about-panel { display: none; }
.public-shell .public-grid { grid-template-columns: minmax(0, 650px); max-width: 650px; }
.public-shell .public-hero { min-height: auto; }
.public-hero { min-height: 690px; border-radius: 26px; padding: 35px 30px 28px; color: #fff; position: relative; overflow: hidden; background: linear-gradient(145deg, #232542 0%, #45448f 53%, #6f6fd2 100%); box-shadow: 0 22px 60px rgba(39,41,91,.23); }
.public-hero:before, .public-hero:after { content: ''; position: absolute; border-radius: 50%; border: 1px solid rgba(255,255,255,.15); pointer-events: none; }
.public-hero:before { width: 360px; height: 360px; right: -190px; top: -130px; }
.public-hero:after { width: 240px; height: 240px; left: -130px; bottom: 50px; }
.hero-inner { position: relative; z-index: 1; }
.public-hero.layout-center { text-align: center; }
.public-hero.layout-center .intro { margin-left: auto; margin-right: auto; }
.public-hero.layout-center .public-links { text-align: left; }
.public-hero.layout-right { text-align: right; }
.public-hero.layout-right .intro { margin-left: auto; }
.public-hero.layout-right .public-links { text-align: left; }
.public-avatar { width: 92px; height: 92px; border: 3px solid rgba(255,255,255,.48); box-shadow: 0 10px 25px rgba(20,20,60,.22); margin-bottom: 20px; }
.public-hero h1 { font-size: 34px; margin: 0; letter-spacing: -.05em; }
.public-hero .intro { color: rgba(255,255,255,.76); font-size: 13px; line-height: 1.75; margin: 10px 0 0; max-width: 330px; white-space: pre-line; }
.public-url { font-size: 11px; color: rgba(255,255,255,.55); margin-top: 14px; }
.public-links { margin-top: 31px; display: grid; gap: 11px; }
.public-link { display: flex; align-items: center; gap: 12px; padding: 14px 15px; border-radius: 15px; color: #272943; background: rgba(255,255,255,.95); transition: .18s ease; box-shadow: 0 9px 20px rgba(16,17,54,.1); }
.public-link:hover { transform: translateY(-2px); background: #fff; box-shadow: 0 13px 26px rgba(16,17,54,.18); }
.public-link .link-icon { background: #eeedff; }
.public-link .link-copy { flex: 1; min-width: 0; }
.public-link strong { display: block; font-size: 13px; }
.public-link span { display: block; color: #9295a5; font-size: 10px; margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.public-link .arrow { color: #a1a3b5; font-size: 18px; }
.public-footer { text-align: center; color: rgba(255,255,255,.54); font-size: 10px; margin-top: 30px; }
.about-panel { background: #fff; border: 1px solid var(--line); border-radius: 26px; padding: 25px; box-shadow: var(--shadow); }
.about-panel h2 { margin: 0; font-size: 17px; letter-spacing: -.03em; }
.about-panel > p { color: var(--muted); line-height: 1.7; font-size: 12px; margin: 8px 0 21px; }
.about-section { border-top: 1px solid #f0f1f6; padding-top: 18px; margin-top: 17px; }
.about-section h3 { font-size: 12px; margin: 0 0 11px; }
.about-section p, .about-section li { color: var(--muted); font-size: 11px; line-height: 1.7; }
.about-section ul { margin: 0; padding-left: 17px; }
.mini-stat { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.mini-stat div { background: #fafaff; border-radius: 12px; padding: 12px; }
.mini-stat strong { display: block; font-size: 17px; }
.mini-stat span { font-size: 10px; color: var(--muted); margin-top: 4px; display: block; }

/* Modal + toast */
.modal-backdrop { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 20px; background: rgba(24,26,49,.38); backdrop-filter: blur(6px); }
.modal { width: min(520px, 100%); background: #fff; border-radius: 19px; box-shadow: 0 24px 70px rgba(24,26,49,.22); overflow: hidden; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 19px 21px 15px; border-bottom: 1px solid #f0f1f6; }
.modal-head h2 { margin: 0; font-size: 15px; }
.modal-body { padding: 19px 21px; }
.toast { position: fixed; z-index: 30; right: 24px; bottom: 24px; background: #22243a; color: white; border-radius: 10px; padding: 11px 15px; font-size: 12px; box-shadow: 0 14px 26px rgba(26,27,51,.22); animation: toast-in .22s ease-out; }
@keyframes toast-in { from { transform: translateY(10px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

@media (max-width: 1060px) {
  .public-grid { grid-template-columns: 1fr; max-width: 650px; }
  .public-hero { min-height: auto; }
  .about-panel { display: none; }
  .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 830px) {
  .side-nav { width: 70px; flex-basis: 70px; padding: 18px 9px; }
  .brand { justify-content: center; padding: 4px 0 24px; }
  .brand-copy, .nav-label, .nav-item span, .nav-footer .mini-profile > div { display: none; }
  .nav-item { justify-content: center; padding: 11px; }
  .nav-footer { padding: 15px 0 3px; }
  .nav-footer .mini-profile { justify-content: center; }
  .topbar { padding: 0 21px; }
  .content { padding: 24px 21px 35px; }
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 560px) {
  .topbar { height: 62px; }
  .crumbs { font-size: 12px; }
  .content { padding: 20px 14px 28px; }
  .page-head { display: block; }
  .head-actions { margin-top: 15px; }
  .head-actions .btn { flex: 1; }
  .stats-grid { gap: 10px; }
  .stat-card { padding: 14px; }
  .stat-value { font-size: 23px; }
  .field-grid { grid-template-columns: 1fr; }
  .field.full-span { grid-column: auto; }
  .public-shell { padding: 15px; }
  .public-top { margin-bottom: 13px; }
  .public-top .brand { display: flex; }
  .public-hero { border-radius: 22px; padding: 28px 20px 23px; }
  .public-hero h1 { font-size: 29px; }
  .about-panel { display: none; }
}
