:root {
    --bg: #f3f5f8;
    --surface: #ffffff;
    --ink: #101828;
    --muted: #667085;
    --line: #e6e8ee;
    --line-strong: #d0d5dd;
    --brand: #3b5bdb;
    --brand-strong: #2f4ac0;
    --brand-soft: #edf2ff;
    --danger: #d92d20;
    --danger-soft: #fef3f2;
    --ok: #067647;
    --ok-soft: #ecfdf3;
    --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 10px 28px rgba(16, 24, 40, .05);
    --radius: 16px;
}

* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.4 "Segoe UI Variable", "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif; color: var(--ink); background: var(--bg); }
a { color: var(--brand); text-decoration: none; }
button, input, select, textarea { font: inherit; }

.app { min-height: 100vh; display: flex; }
.side { width: 248px; flex: 0 0 248px; background: var(--surface); border-right: 1px solid var(--line); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 12px; padding: 22px 18px 16px; color: inherit; }
.brand:hover { text-decoration: none; }
.logo { width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; background: var(--brand); color: #fff; font-weight: 700; letter-spacing: .04em; }
.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-text strong { font-size: 15px; }
.brand-text em { font-style: normal; color: var(--muted); font-size: 12px; margin-top: 2px; }
.side nav { display: flex; flex-direction: column; gap: 4px; padding: 8px 12px; }
.side nav a { display: flex; align-items: center; gap: 10px; color: #344054; border-radius: 10px; padding: 10px 12px; font-weight: 600; }
.side nav a svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: 0 0 auto; }
.side nav a:hover { background: #f2f4f7; text-decoration: none; }
.side nav a.on { background: var(--brand-soft); color: var(--brand-strong); }
.side-foot { margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 14px; margin: 12px; border: 1px solid var(--line); border-radius: 14px; background: #fbfcfe; }
.avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: #e7edff; color: var(--brand-strong); font-weight: 700; flex: 0 0 auto; }
.who { min-width: 0; flex: 1; }
.who strong, .who span { display: block; }
.who strong { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who span { color: var(--muted); font-size: 12px; }
.logout { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; color: #475467; }
.logout svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.logout:hover { background: var(--danger-soft); color: var(--danger); text-decoration: none; }

.content { flex: 1; min-width: 0; }
.topbar { padding: 14px 24px 0; }
.topbar h1 { margin: 0; font-size: 20px; line-height: 1.2; letter-spacing: -.02em; }
.topbar p { margin: 2px 0 0; color: var(--muted); line-height: 1.35; }
main { max-width: none; padding: 10px 24px 24px; }

.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-bottom: 10px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 10px 14px; }
.stat span { display: block; color: var(--muted); font-size: 13px; line-height: 1.3; }
.stat strong { display: block; margin-top: 2px; font-size: 22px; line-height: 1.1; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.home-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.home-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 10px 12px; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.home-card header { display: flex; align-items: center; gap: 8px; }
.home-no { width: 28px; height: 28px; border-radius: 8px; background: #f2f4f7; color: #475467; display: grid; place-items: center; font-size: 13px; font-weight: 700; flex: 0 0 auto; }
.home-card h2 { margin: 0; font-size: 16px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.home-card h2 a { color: inherit; }
.home-card h2 a:hover { color: var(--brand); }
.home-url { margin: 0; padding: 7px 10px; background: #f8fafc; border: 1px solid var(--line); border-radius: 10px; word-break: break-all; line-height: 1.4; }
.home-url span { display: block; margin-bottom: 1px; color: var(--muted); font-size: 12px; }
.home-lines { list-style: none; margin: 2px 0 0; padding: 0; }
.home-lines li { word-break: break-all; }
.home-lines li + li { margin-top: 2px; }
.home-progress { margin: 0; color: #344054; font-size: 13px; }
.home-foot { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: auto; padding-top: 6px; border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; line-height: 1.3; }
.home-foot strong { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }
.badge.seq { background: #f2f4f7; color: #344054; }
.badge.loop { background: var(--brand-soft); color: var(--brand-strong); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px 16px; margin-bottom: 10px; }
.url { word-break: break-all; }
h2, .section-title { font-size: 16px; font-weight: 600; line-height: 1.3; margin: 0 0 8px; letter-spacing: -.01em; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.card-head h2 { margin: 0; }
label { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 6px; font-weight: 600; margin: 0 0 3px; line-height: 1.3; color: #344054; }
input + label, select + label, textarea + label, .form-row + label { margin-top: 8px; }
.hint, .muted, .topbar p { color: var(--muted); }
.hint { font-size: 12px; font-weight: 400; }
.lead { margin: 0 0 6px; color: var(--muted); }
input[type=text], input[type=password], select, textarea { width: 100%; padding: 5px 8px; border: 1px solid var(--line-strong); border-radius: 8px; background: #fff; color: var(--ink); transition: border-color .15s, box-shadow .15s; }
textarea { min-height: 88px; resize: vertical; font-family: Consolas, "Courier New", monospace; line-height: 1.4; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(59, 91, 219, .16); }
.form-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px 12px; margin-top: 8px; align-items: end; }
form > .form-row:first-of-type { margin-top: 0; }
.form-row.thirds { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.site-form .form-row { margin-top: 8px; }
.site-form .form-row.four { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) minmax(150px, .7fr) minmax(130px, .6fr); margin-top: 0; }
.site-form .form-row.three { grid-template-columns: minmax(140px, .7fr) minmax(0, 1.5fr) minmax(0, 1fr); }
.site-form .form-row.logo-row { grid-template-columns: minmax(0, 1fr) minmax(180px, .5fr); }
.site-form .form-row.domains { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.site-form textarea { min-height: 0; }
.site-name { line-height: 1.3; }
.site-name strong, .site-name span { display: block; }
.site-name span { color: var(--muted); font-size: 12px; margin-top: 2px; }
.sites-card .card-head { margin-bottom: 0; }
.record-groups { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 10px; }
.record-groups a { border: 1px solid var(--line-strong); background: #fff; color: #344054; border-radius: 999px; padding: 6px 12px; font-weight: 600; }
.record-groups a:hover { background: #f8fafc; text-decoration: none; }
.record-groups a.on { background: var(--ink); border-color: var(--ink); color: #fff; }
.record-summary { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.record-summary .section-title { margin: 0 0 2px; }
.record-meta { display: flex; flex-wrap: wrap; gap: 2px 16px; color: var(--muted); font-size: 13px; line-height: 1.3; }
.record-meta strong { color: var(--ink); font-weight: 600; }
.record-block .section-title { margin-bottom: 6px; }
.record-block .empty { padding: 8px 0 0; text-align: left; }
.domain-table th:first-child, .domain-table td:first-child { width: 72px; }

.actions { display: flex; gap: 8px; align-items: center; margin-top: 10px; flex-wrap: wrap; }
button, .btn { display: inline-flex; align-items: center; justify-content: center; border: 1px solid transparent; border-radius: 8px; padding: 6px 12px; background: var(--brand); color: #fff; cursor: pointer; font-weight: 600; line-height: 1.2; }
button:hover, .btn:hover { background: var(--brand-strong); text-decoration: none; }
button.ghost, .btn.ghost { background: #fff; color: #344054; border-color: var(--line-strong); }
button.ghost:hover, .btn.ghost:hover { background: #f8fafc; }
button.danger, .btn.danger { background: var(--danger); }
button.danger:hover, .btn.danger:hover { background: #b42318; }
.inline { display: flex; gap: 10px; align-items: center; }
.inline input { flex: 1; min-width: 0; }
td .inline input[type=password] { flex: 0 1 180px; width: 180px; }

.badge { display: inline-flex; align-items: center; border-radius: 999px; padding: 2px 8px; background: var(--brand-soft); color: var(--brand-strong); font-size: 12px; font-weight: 600; }
.num { font-variant-numeric: tabular-nums; font-weight: 600; }
.card > table, .card > .table-wrap { margin: 6px -16px 0; }
.card > table:last-child, .card > .table-wrap:last-child { margin-bottom: -12px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: separate; border-spacing: 0; }
th, td { text-align: left; padding: 6px 12px; border-top: 1px solid var(--line); vertical-align: middle; line-height: 1.35; }
th { font-size: 12px; color: var(--muted); font-weight: 600; background: #f8fafc; }
th:first-child, td:first-child { padding-left: 16px; }
th:last-child, td:last-child { padding-right: 16px; }
tbody tr:hover td { background: #fbfcff; }
.row-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; white-space: nowrap; }
.row-actions a:not(.btn) { font-weight: 600; }
.row-actions form, td form { display: inline-flex; }
td button, td .btn { padding: 5px 10px; font-size: 12px; border-radius: 8px; background: #fff; color: #344054; border-color: var(--line-strong); font-weight: 600; }
td button:hover, td .btn:hover { background: #f8fafc; }
td button.danger { color: var(--danger); border-color: #fecdca; background: #fff; }
td button.danger:hover { background: var(--danger-soft); }
.nowrap { white-space: nowrap; }

.msg { border-radius: 10px; padding: 8px 12px; margin-bottom: 8px; border: 1px solid transparent; line-height: 1.4; }
.msg.ok { background: var(--ok-soft); color: var(--ok); border-color: #abefc6; }
.msg.err { background: var(--danger-soft); color: #b42318; border-color: #fecdca; }
.msg ul { margin: 0; padding-left: 18px; }
.toolbar { display: flex; align-items: center; justify-content: flex-end; gap: 10px; margin-bottom: 14px; }
form.toolbar { justify-content: flex-start; }
form.toolbar label { margin: 0; }
form.toolbar select { width: 220px; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.current { margin: 14px 0 0; padding: 12px 14px; background: #f8fafc; border: 1px solid var(--line); border-radius: 12px; word-break: break-all; }
.filters a { background: #fff; color: #344054; border: 1px solid var(--line-strong); border-radius: 999px; padding: 6px 12px; font-weight: 600; }
.filters a.on { background: var(--ink); border-color: var(--ink); color: #fff; }
.filters a:hover { text-decoration: none; }
.empty { padding: 10px 8px; color: var(--muted); text-align: center; }

body.auth { min-height: 100vh; background: radial-gradient(900px 420px at 0% 0%, #e0e7ff 0%, transparent 55%), radial-gradient(800px 380px at 100% 0%, #dbeafe 0%, transparent 50%), var(--bg); }
body.auth main { min-height: 100vh; max-width: none; display: flex; align-items: center; justify-content: center; padding: 32px 16px; }
.login { width: min(440px, 100%); margin: 0; padding: 32px 28px 28px; }
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.auth-brand .logo { width: 42px; height: 42px; border-radius: 13px; }
.auth-brand strong, .auth-brand span { display: block; }
.auth-brand strong { font-size: 18px; }
.auth-brand span { color: var(--muted); font-size: 13px; }
.narrow { max-width: 520px; }
.login h1 { margin: 0 0 6px; font-size: 24px; letter-spacing: -.02em; }
.login .actions button { width: 100%; padding: 11px 14px; }

@media (max-width: 1100px) {
    .home-grid { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
    .app { display: block; }
    .side { width: auto; height: auto; position: static; border-right: 0; border-bottom: 1px solid var(--line); }
    .side nav { flex-direction: row; overflow-x: auto; }
    .side nav a { white-space: nowrap; }
    .side-foot { margin-top: 0; }
    .topbar, main { padding-left: 16px; padding-right: 16px; }
    .stats, .home-grid { grid-template-columns: 1fr; }
    .form-row, .form-row.thirds, .site-form .form-row.four, .site-form .form-row.three, .site-form .form-row.logo-row, .site-form .form-row.domains { grid-template-columns: 1fr; }
    .record-summary { flex-direction: column; align-items: stretch; }
}
