:root {
    --bg: #f4f7f5;
    --panel: #ffffff;
    --text: #17251c;
    --text-2: #3d4f44;
    --muted: #71827a;
    --line: #e1e8e3;
    --line-2: #eef3ef;
    --brand: #20a53a;
    --brand-dark: #17862d;
    --brand-soft: #e8f6ec;
    --brand-ink: #12602a;
    --ok: #178a34;
    --ok-soft: #e6f6ea;
    --fail: #c8403f;
    --fail-soft: #fdecec;
    --pending: #b3780a;
    --pending-soft: #fff4d9;
    --info: #2c6fd6;
    --info-soft: #e9f0fc;
    --side-bg: #0e2015;
    --side-bg-2: #163a24;
    --side-band: #15311f;
    --side-line: rgba(255, 255, 255, 0.14);
    --side-text: #c9dccf;
    --side-muted: #7fa08b;
    --radius: 14px;
    --radius-sm: 10px;
    --shadow: 0 8px 24px rgba(19, 46, 29, 0.06);
    --shadow-lg: 0 24px 60px rgba(19, 46, 29, 0.14);
    --ring: 0 0 0 3px rgba(32, 165, 58, 0.22);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
    font-size: 14px;
    background: var(--bg);
    color: var(--text);
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--brand-dark); text-decoration: none; }
a:hover { text-decoration: underline; }
code {
    font-family: ui-monospace, "Cascadia Code", Consolas, "Courier New", monospace;
    background: var(--line-2);
    border: 1px solid var(--line);
    padding: 0.1em 0.4em;
    border-radius: 6px;
    font-size: 0.9em;
}
h1, h2, h3 { font-weight: 700; letter-spacing: -0.01em; }

/* ---------- icons ---------- */
.ico {
    width: 1em;
    height: 1em;
    font-size: 16px;
    flex: 0 0 auto;
    vertical-align: -0.16em;
}
.ico-lg { font-size: 20px; }
.ico-xl { font-size: 26px; }
.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- app shell ---------- */
.app {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 236px minmax(0, 1fr);
}

.sidebar {
    background: var(--side-bg);
    color: var(--side-text);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    border-right: 1px solid #dde5df;
}
/* 顶部品牌区：单独一块深色底 + 清晰分割线，和下方菜单区分开 */
.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px 18px;
    background: var(--side-band);
    border-bottom: 1px solid var(--side-line);
}
.brand-logo {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    display: grid;
    place-items: center;
    background: var(--brand);
    color: #fff;
    flex: 0 0 auto;
}
.brand-logo .ico { font-size: 20px; }
.brand strong { display: block; font-size: 15px; color: #fff; line-height: 1.25; }
.brand span { display: block; color: var(--side-muted); font-size: 12px; margin-top: 2px; }

.nav-label {
    padding: 18px 20px 8px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.12em;
    color: var(--side-muted);
}
.sidebar nav { padding: 0 12px; display: flex; flex-direction: column; gap: 4px; }
.sidebar nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--side-text);
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    text-decoration: none;
    font-weight: 500;
    transition: background 0.15s ease, color 0.15s ease;
}
.sidebar nav a .ico { font-size: 18px; color: var(--side-muted); transition: color 0.15s ease; }
.sidebar nav a:hover { background: rgba(255, 255, 255, 0.06); color: #fff; }
.sidebar nav a:hover .ico { color: #fff; }
.sidebar nav a.active {
    background: var(--brand);
    color: #fff;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(32, 165, 58, 0.35);
}
.sidebar nav a.active .ico { color: #fff; }

.side-foot {
    margin-top: auto;
    padding: 14px 16px;
    background: var(--side-band);
    border-top: 1px solid var(--side-line);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    font-size: 13px;
}
.user-chip {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    color: var(--side-text);
}
.user-chip .avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    display: grid;
    place-items: center;
    flex: 0 0 auto;
}
.user-chip .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-foot a.logout {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--side-muted);
    padding: 6px 8px;
    border-radius: 8px;
}
.side-foot a.logout:hover { background: rgba(255, 255, 255, 0.07); color: #fff; text-decoration: none; }

.main { min-width: 0; }
.topbar {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding: 26px 32px 0;
}
.topbar h1 {
    margin: 0;
    font-size: 22px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.topbar h1 .ico { font-size: 22px; color: var(--brand-dark); }
.topbar .subtitle { margin: 4px 0 0; color: var(--muted); }
.pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 999px;
    font-size: 12.5px;
    font-weight: 600;
    border: 1px solid transparent;
    white-space: nowrap;
}
.pill-ok { background: var(--ok-soft); color: var(--ok); border-color: #cdebd5; }
.pill-warn { background: var(--pending-soft); color: var(--pending); border-color: #f2dfae; }
a.pill:hover { text-decoration: none; filter: brightness(0.97); }

.content { padding: 20px 32px 48px; max-width: 1280px; }

/* ---------- cards ---------- */
.card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 22px;
    box-shadow: var(--shadow);
}
.content > .card + .card { margin-top: 16px; }
.card.narrow { max-width: 680px; }
.card-head {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 18px;
}
.card-icon {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    background: var(--brand-soft);
    color: var(--brand-dark);
    flex: 0 0 auto;
}
.card-icon .ico { font-size: 20px; }
.card-icon.info { background: var(--info-soft); color: var(--info); }
.card-icon.warn { background: var(--pending-soft); color: var(--pending); }
.card-head h2 { margin: 0; font-size: 17px; }
.card-head p { margin: 4px 0 0; color: var(--muted); }

/* 两栏：等宽、顶对齐、等高，两张卡片上下边缘齐平 */
.grid-2 {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 20px;
    align-items: stretch;
}
.grid-2.wide-left { grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); }
.grid-2 > .card { display: flex; flex-direction: column; margin-top: 0; }
/* 让表单撑满卡片剩余高度，多行输入框跟着拉伸 */
.card > form.fill { display: flex; flex-direction: column; flex: 1; }
.card > form.fill textarea { flex: 1; min-height: 200px; }
.card > .table-wrap.fill { flex: 1; }

/* ---------- forms ---------- */
label {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 14px 0 6px;
    font-weight: 600;
    color: var(--text-2);
}
label .ico { color: var(--muted); }
label:first-child { margin-top: 0; }
input[type="text"],
input[type="password"],
select,
textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    font: inherit;
    color: var(--text);
    background: #fff;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: var(--ring);
}
textarea {
    resize: vertical;
    min-height: 240px;
    font-family: ui-monospace, "Cascadia Code", Consolas, "Courier New", monospace;
    font-size: 13px;
    line-height: 1.7;
}
.field-hint { color: var(--muted); font-size: 12.5px; margin-top: 6px; }
.stack .btn { margin-top: 16px; }

/* ---------- buttons ---------- */
.btn, button.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    border: 1px solid transparent;
    background: var(--brand);
    color: #fff;
    border-radius: var(--radius-sm);
    padding: 10px 16px;
    font: inherit;
    font-weight: 600;
    line-height: 1.2;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
    transition: background 0.15s ease, border-color 0.15s ease, transform 0.05s ease;
}
.btn:hover { background: var(--brand-dark); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn.btn-ghost {
    background: #fff;
    color: var(--text-2);
    border-color: var(--line);
}
.btn.btn-ghost:hover { background: var(--line-2); border-color: #d2dcd5; }
.btn.btn-soft { background: var(--brand-soft); color: var(--brand-ink); }
.btn.btn-soft:hover { background: #d9efdf; }
.btn.btn-small { padding: 6px 10px; font-size: 12.5px; border-radius: 8px; }
.btn.btn-small .ico { font-size: 14px; }
.btn.btn-block { width: 100%; }
.btn-row { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; }
.btn-row .btn { margin-top: 0; }

/* ---------- misc text ---------- */
.muted { color: var(--muted); }
.small { font-size: 12.5px; margin-top: 4px; }
.nowrap { white-space: nowrap; }
.mono { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: 12.5px; }
.with-ico { display: inline-flex; align-items: center; gap: 6px; }

/* ---------- alerts ---------- */
.alert {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    margin-bottom: 16px;
    border: 1px solid transparent;
}
.alert .ico { font-size: 18px; margin-top: 1px; }
.alert-ok { background: var(--ok-soft); color: #145a29; border-color: #cdebd5; }
.alert-error { background: var(--fail-soft); color: #8a2222; border-color: #f5cfcf; }
.alert-info { background: var(--info-soft); color: #1f4f9c; border-color: #cfdcf7; }
.alert-warn { background: var(--pending-soft); color: #7a5205; border-color: #f2dfae; }

/* ---------- badges ---------- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    border-radius: 999px;
    padding: 3px 9px 3px 7px;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.4;
    white-space: nowrap;
}
.badge .ico { font-size: 13px; }
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-fail { background: var(--fail-soft); color: var(--fail); }
.badge-pending { background: var(--pending-soft); color: var(--pending); }
.chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 2px 8px;
    border-radius: 6px;
    background: var(--line-2);
    color: var(--text-2);
    font-size: 12.5px;
    font-weight: 600;
}
.chip .ico { font-size: 13px; color: var(--muted); }

/* ---------- toolbar ---------- */
.toolbar {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
    align-items: center;
}
.toolbar form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.toolbar input, .toolbar select { width: auto; min-width: 160px; }
.toolbar .btn { margin-top: 0; }
.search {
    position: relative;
    display: inline-flex;
    align-items: center;
}
.search .ico { position: absolute; left: 10px; color: var(--muted); pointer-events: none; }
.search input { padding-left: 32px; min-width: 240px; }

/* 分段切换栏：点一下即切换，无需筛选按钮；里面也可以放自动提交的下拉框 */
.segmented {
    display: inline-flex;
    align-items: stretch;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: #fff;
    overflow: hidden;
}
.segmented > a,
.segmented > select {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 14px;
    margin: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: var(--text-2);
    font: inherit;
    font-weight: 600;
    font-size: 13.5px;
    line-height: 1.4;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}
.segmented > * + * { border-left: 1px solid var(--line); }
.segmented > a .ico { font-size: 14px; color: var(--muted); }
.segmented > a:hover { background: var(--line-2); text-decoration: none; }
.segmented > a.active { background: var(--brand); color: #fff; }
.segmented > a.active .ico { color: #fff; }
.segmented > a b { font-weight: 600; opacity: 0.6; font-size: 12px; }
.segmented > a.active b { opacity: 0.85; }
.segmented > select { min-width: 140px; box-shadow: none; }
.segmented > select:focus { box-shadow: none; outline: none; background: var(--line-2); }

.inline-edit { display: flex; gap: 8px; align-items: center; }
.inline-edit input { min-width: 240px; }
.ops { display: flex; flex-wrap: wrap; gap: 6px; }
.ops .btn { margin-top: 0; }

/* ---------- table ---------- */
.table-wrap { overflow: auto; padding: 0; }
table { width: 100%; border-collapse: collapse; }
th, td {
    padding: 13px 16px;
    border-bottom: 1px solid var(--line-2);
    text-align: left;
    vertical-align: middle;
}
th {
    background: #f8fbf9;
    font-size: 12px;
    font-weight: 600;
    color: var(--muted);
    letter-spacing: 0.02em;
    white-space: nowrap;
}
th:first-child { border-top-left-radius: var(--radius); }
th:last-child { border-top-right-radius: var(--radius); }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #fafcfb; }
td .primary { display: flex; align-items: center; gap: 8px; font-weight: 600; }
td .primary .ico { color: var(--brand-dark); }
td .sub { color: var(--muted); font-size: 12.5px; margin-top: 3px; }
.empty {
    text-align: center;
    padding: 44px 20px !important;
    color: var(--muted);
}
.empty .ico { font-size: 34px; color: #b8c8be; display: block; margin: 0 auto 8px; }
.empty a { font-weight: 600; }

/* ---------- stats ---------- */
.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}
.stat {
    display: flex;
    align-items: center;
    gap: 14px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 14px 16px;
    box-shadow: var(--shadow);
}
.stat-icon {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    background: var(--brand-soft);
    color: var(--brand-dark);
    flex: 0 0 auto;
}
.stat-icon .ico { font-size: 20px; }
.stat.ok .stat-icon { background: var(--ok-soft); color: var(--ok); }
.stat.fail .stat-icon { background: var(--fail-soft); color: var(--fail); }
.stat.pending .stat-icon { background: var(--pending-soft); color: var(--pending); }
.stat.info .stat-icon { background: var(--info-soft); color: var(--info); }
.stat span { display: block; color: var(--muted); font-size: 12.5px; }
.stat strong { font-size: 22px; line-height: 1.2; }
a.stat { color: inherit; transition: border-color 0.15s ease, transform 0.1s ease; }
a.stat:hover { text-decoration: none; border-color: #c9d7ce; transform: translateY(-1px); }

/* ---------- batch results ---------- */
.running {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--info-soft);
    color: #1f4f9c;
    border: 1px solid #cfdcf7;
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    margin-bottom: 16px;
}
.running .ico { font-size: 18px; }
.running.done { background: var(--ok-soft); color: #145a29; border-color: #cdebd5; }
.running.done .spin { animation: none; }
.result-list { display: flex; flex-direction: column; gap: 12px; }
.result-item {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 16px 18px;
    box-shadow: var(--shadow);
}
.result-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.result-head .domain { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 15px; }
.result-head .domain .ico { color: var(--brand-dark); }
.result-head .target { display: flex; align-items: center; gap: 6px; color: var(--muted); margin-top: 3px; word-break: break-all; }
.steps-log { list-style: none; margin: 12px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.steps-log li {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 7px 10px;
    border-radius: 8px;
    background: #f8fbf9;
}
.steps-log li .ico { margin-top: 3px; }
.steps-log li.ok .ico { color: var(--ok); }
.steps-log li.fail { background: var(--fail-soft); }
.steps-log li.fail .ico { color: var(--fail); }
.steps-log em {
    font-style: normal;
    font-weight: 700;
    min-width: 62px;
    color: var(--text-2);
}
.steps-log li.fail em { color: var(--fail); }
.steps-log li span { word-break: break-all; }

/* ---------- tips ---------- */
.tips {
    margin-top: 20px;
    background: #f8fbf9;
    border: 1px dashed var(--line);
    border-radius: var(--radius-sm);
    padding: 14px 16px;
}
.tips h3 { margin: 0 0 8px; font-size: 14px; display: flex; align-items: center; gap: 6px; }
.tips h3 .ico { color: var(--pending); }
.tips ul { margin: 0; padding-left: 18px; color: var(--muted); }
.tips li { margin: 4px 0; }
.steps { color: var(--text-2); padding-left: 20px; margin: 0 0 16px; }
.steps li { margin: 6px 0; }

/* ---------- auth pages ---------- */
.auth-body {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background:
        radial-gradient(900px 500px at 10% -10%, rgba(46, 194, 83, 0.25), transparent 60%),
        radial-gradient(700px 400px at 100% 0%, rgba(32, 165, 58, 0.18), transparent 60%),
        linear-gradient(180deg, var(--side-bg) 0%, var(--side-bg-2) 55%, var(--bg) 55%);
}
.auth-card {
    width: min(440px, 100%);
    background: #fff;
    border-radius: 18px;
    padding: 30px 30px 26px;
    box-shadow: var(--shadow-lg);
}
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.auth-brand .brand-logo { width: 46px; height: 46px; }
.auth-brand h1 { margin: 0; font-size: 20px; }
.auth-brand p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.auth-card .btn { width: 100%; margin-top: 18px; }
.auth-foot { margin-top: 16px; color: var(--muted); font-size: 12.5px; text-align: center; }

/* ---------- responsive ---------- */
@media (max-width: 960px) {
    .app { grid-template-columns: 1fr; }
    .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 14px; border-right: 0; border-bottom: 1px solid var(--side-line); }
    .brand { border: 0; background: transparent; padding: 4px 6px 4px 0; margin-right: 8px; border-right: 1px solid var(--side-line); padding-right: 16px; }
    .nav-label { display: none; }
    .sidebar nav { flex-direction: row; flex-wrap: wrap; padding: 0; }
    .sidebar nav a { padding: 8px 10px; }
    .sidebar nav a.active { box-shadow: none; }
    .side-foot { margin-top: 0; margin-left: auto; padding: 4px 0; border: 0; background: transparent; }
    .grid-2 { grid-template-columns: 1fr; }
    .content, .topbar { padding-left: 16px; padding-right: 16px; }
    .topbar { flex-direction: column; }
    .inline-edit { flex-wrap: wrap; }
    .inline-edit input { min-width: 180px; }
    .search input { min-width: 180px; }
}
