:root {
  color-scheme: light;
  --bg: #f4f6f7;
  --surface: #ffffff;
  --ink: #17201d;
  --muted: #66706c;
  --line: #dce2df;
  --line-strong: #c8d0cc;
  --green: #176b4d;
  --green-soft: #e4f2eb;
  --blue: #245c9d;
  --blue-soft: #e8f0fa;
  --amber: #986313;
  --amber-soft: #fff1d7;
  --red: #a8423c;
  --red-soft: #fae8e6;
  --shadow: 0 8px 28px rgba(23, 32, 29, 0.08);
  font-family: Inter, "Segoe UI", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body { margin: 0; color: var(--ink); background: var(--bg); font-size: 14px; letter-spacing: 0; }
button, input, select, textarea { font: inherit; letter-spacing: 0; }
a { color: inherit; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 228px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 24px 16px 18px; background: #18211e; color: #eef3f0; display: flex; flex-direction: column; }
.brand { display: flex; align-items: center; gap: 11px; color: inherit; text-decoration: none; padding: 0 8px 24px; border-bottom: 1px solid rgba(255,255,255,.11); }
.brand-mark { width: 38px; height: 38px; display: grid; place-items: center; background: #c9f0dc; color: #134d39; border-radius: 6px; font-size: 19px; font-weight: 800; }
.brand-copy { display: flex; flex-direction: column; min-width: 0; }
.brand-copy strong { font-size: 15px; }
.brand-copy small { margin-top: 3px; color: #9eaaa5; font-size: 11px; }
.nav-list { display: grid; gap: 4px; margin-top: 22px; }
.nav-item { height: 42px; display: flex; align-items: center; gap: 11px; padding: 0 12px; border-radius: 6px; color: #b9c3bf; text-decoration: none; }
.nav-item:hover { background: rgba(255,255,255,.06); color: white; }
.nav-item.is-active { background: #2b3934; color: white; }
.nav-icon { width: 18px; text-align: center; font-size: 17px; }
.sidebar-footer { margin-top: auto; display: flex; align-items: center; gap: 8px; padding: 14px 10px 2px; color: #aab5b0; font-size: 12px; }
.environment-dot { width: 8px; height: 8px; border-radius: 50%; background: #75c99f; }
.environment-dot.is-sample { background: #e2aa51; }

.main-content { width: min(1180px, 100%); margin: 0 auto; padding: 36px 42px 56px; }
.page-header { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; margin-bottom: 28px; }
.page-header.compact { align-items: center; padding-bottom: 24px; border-bottom: 1px solid var(--line); }
.eyebrow { margin: 0 0 7px; color: var(--green); font-weight: 700; font-size: 12px; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 6px; font-size: 30px; line-height: 1.2; letter-spacing: 0; }
h2 { margin-bottom: 4px; font-size: 17px; letter-spacing: 0; }
.page-subtitle, .section-heading p { margin: 0; color: var(--muted); }
.header-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 9px; }
.button { min-height: 38px; display: inline-flex; align-items: center; justify-content: center; padding: 0 15px; border-radius: 6px; border: 1px solid transparent; font-weight: 650; text-decoration: none; cursor: pointer; white-space: nowrap; }
.button:disabled { cursor: not-allowed; opacity: .55; }
.button-primary { background: var(--green); color: white; }
.button-primary:hover:not(:disabled) { background: #105a40; }
.button-secondary { background: var(--surface); color: var(--ink); border-color: var(--line-strong); }
.button-secondary:hover:not(:disabled) { border-color: #9ba7a1; }

.status-strip { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); padding: 20px 22px; display: flex; justify-content: space-between; gap: 24px; }
.status-main { display: flex; align-items: center; gap: 12px; min-width: 180px; }
.status-main div { display: flex; flex-direction: column; gap: 4px; }
.status-main span:last-child { color: var(--muted); font-size: 12px; }
.status-indicator { width: 12px; height: 12px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 5px var(--green-soft); }
.status-indicator.is-running { background: var(--blue); box-shadow: 0 0 0 5px var(--blue-soft); }
.status-indicator.is-paused { background: var(--amber); box-shadow: 0 0 0 5px var(--amber-soft); }
.status-indicator.is-error { background: var(--red); box-shadow: 0 0 0 5px var(--red-soft); }
.status-meta { margin: 0; display: grid; grid-template-columns: repeat(4, minmax(90px, 1fr)); gap: 22px; }
.status-meta div { display: flex; flex-direction: column; gap: 5px; }
.status-meta dt { color: var(--muted); font-size: 12px; }
.status-meta dd { margin: 0; font-weight: 700; }

.metric-grid { margin: 26px 0 4px; display: grid; grid-template-columns: repeat(5, minmax(0,1fr)); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.metric { padding: 22px 18px; border-right: 1px solid var(--line); }
.metric:first-child { padding-left: 0; }
.metric:last-child { border-right: 0; }
.metric span { display: block; color: var(--muted); font-size: 12px; margin-bottom: 6px; }
.metric strong { font-size: 25px; }
.text-success { color: var(--green); }
.text-warning { color: var(--amber); }
.text-blue { color: var(--blue); }

.content-section { margin-top: 34px; }
.content-section.no-top-gap { margin-top: 0; }
.section-heading { display: flex; justify-content: space-between; align-items: end; gap: 20px; margin-bottom: 14px; }
.text-link { color: var(--blue); font-weight: 650; text-decoration: none; }
.query-list { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.query-row { min-height: 66px; display: grid; grid-template-columns: 56px minmax(0,1fr) 56px; gap: 12px; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.query-row:last-child { border-bottom: 0; }
.query-row div { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.query-row strong { overflow-wrap: anywhere; }
.query-row small, .query-status { color: var(--muted); }
.market-badge { display: inline-flex; align-items: center; justify-content: center; height: 25px; border-radius: 5px; background: var(--blue-soft); color: var(--blue); font-size: 12px; font-weight: 700; }

.table-wrap { width: 100%; overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; }
table { width: 100%; min-width: 720px; border-collapse: collapse; }
th, td { padding: 13px 15px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { color: var(--muted); background: #f8faf9; font-size: 12px; font-weight: 650; }
tbody tr:last-child td { border-bottom: 0; }
td a { color: var(--blue); text-decoration: none; font-weight: 650; }
.error-cell { max-width: 280px; color: var(--red); overflow-wrap: anywhere; }

.status-badge, .result-badge { display: inline-flex; align-items: center; min-height: 24px; padding: 3px 8px; border-radius: 5px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.status-成功, .result-待处理 { color: var(--green); background: var(--green-soft); }
.status-运行中 { color: var(--blue); background: var(--blue-soft); }
.status-失败, .status-中断 { color: var(--red); background: var(--red-soft); }
.result-待复查 { color: var(--amber); background: var(--amber-soft); }
.result-排除, .result-重复 { color: #5f6864; background: #edf0ef; }

.empty-state { min-height: 160px; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 7px; color: var(--muted); background: var(--surface); border: 1px dashed var(--line-strong); border-radius: 8px; }
.empty-state strong { color: var(--ink); }
.filter-bar { display: flex; gap: 6px; margin-bottom: 16px; overflow-x: auto; }
.filter-button { height: 34px; padding: 0 13px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--muted); cursor: pointer; white-space: nowrap; }
.filter-button.is-active { color: white; background: var(--ink); border-color: var(--ink); }
.result-list { display: grid; gap: 9px; }
.result-item { display: flex; justify-content: space-between; gap: 22px; padding: 17px 18px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; }
.result-main { min-width: 0; }
.result-title-line { display: flex; align-items: center; gap: 10px; }
.result-title-line a { color: var(--ink); font-size: 15px; font-weight: 750; text-decoration: none; overflow-wrap: anywhere; }
.result-main p { margin: 9px 0; color: var(--muted); line-height: 1.55; }
.result-meta { display: flex; flex-wrap: wrap; gap: 8px 18px; color: var(--muted); font-size: 12px; }
.result-meta span:last-child { max-width: 660px; overflow-wrap: anywhere; }
.score-block { width: 64px; flex: 0 0 64px; display: flex; flex-direction: column; align-items: end; gap: 4px; }
.score-block span { color: var(--muted); font-size: 11px; }
.score-block strong { font-size: 23px; }

.settings-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 28px; }
.setting-group { padding-top: 2px; }
.setting-group h2 { padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.definition-list { margin: 0; }
.definition-list div { display: flex; justify-content: space-between; gap: 20px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.definition-list dt { color: var(--muted); }
.definition-list dd { margin: 0; font-weight: 650; text-align: right; }
.verification-status-list { max-width: 860px; }
.verification-summary { padding: 9px 11px; border-left: 3px solid var(--green); background: var(--green-soft); color: #245542 !important; }
.inline-warning { margin: 13px 0 0; color: var(--red); }
.tag-cloud { display: flex; flex-wrap: wrap; gap: 8px; }
.tag-cloud span { padding: 7px 10px; border-radius: 5px; background: var(--green-soft); color: var(--green); font-weight: 650; }
.tag-cloud.muted span { background: #e9edeb; color: #4f5a55; }

.toast { position: fixed; right: 22px; bottom: 22px; max-width: min(360px, calc(100vw - 44px)); padding: 12px 15px; border-radius: 6px; color: white; background: var(--ink); box-shadow: var(--shadow); opacity: 0; pointer-events: none; transform: translateY(8px); transition: .18s ease; }
.toast.is-visible { opacity: 1; transform: translateY(0); }
.toast.is-error { background: var(--red); }

.button-small { min-height: 32px; padding: 0 10px; font-size: 12px; }
.button-link { padding: 0; border: 0; background: none; cursor: pointer; }
.icon-command { width: 34px; height: 34px; display: inline-grid; place-items: center; border: 1px solid var(--line-strong); border-radius: 6px; background: var(--surface); color: var(--ink); cursor: pointer; font-size: 17px; }
.icon-command:hover { border-color: #8f9d96; }
.icon-command.danger { color: var(--red); }
.notice-bar { display: flex; gap: 12px; align-items: flex-start; margin: -10px 0 24px; padding: 13px 15px; border-left: 3px solid var(--blue); background: var(--blue-soft); color: #234566; }
.notice-bar.is-sample { border-color: var(--amber); background: var(--amber-soft); color: #72501b; }
.notice-bar strong { white-space: nowrap; }
.version-chip { padding: 7px 10px; border-radius: 5px; background: var(--green-soft); color: var(--green); font-weight: 700; }
.run-progress { margin-top: 22px; display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 10px 18px; align-items: center; padding: 15px 17px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; }
.run-progress div { display: flex; justify-content: space-between; gap: 16px; }
.run-progress progress { width: 100%; height: 8px; accent-color: var(--blue); }
.run-progress .button { grid-column: 2; grid-row: 1 / span 2; }
.query-row:has(.query-feedback) { grid-template-columns: 56px minmax(0,1fr) auto; }
.query-feedback { display: flex !important; flex-direction: row !important; gap: 4px !important; }
.query-feedback button { min-width: 42px; height: 28px; border: 1px solid var(--line); border-radius: 5px; background: #f8faf9; color: var(--muted); cursor: pointer; }
.query-feedback button.is-selected { color: var(--green); border-color: #99c9b4; background: var(--green-soft); }
.table-subline { display: block; margin-top: 5px; color: var(--muted); white-space: nowrap; }

.plan-list { display: grid; gap: 9px; }
.plan-row { display: grid; grid-template-columns: 26px minmax(0,1fr) auto; gap: 13px; align-items: center; padding: 17px 18px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; }
.plan-state { align-self: start; padding-top: 8px; }
.plan-copy { min-width: 0; }
.plan-copy p { margin: 7px 0 5px; color: var(--muted); }
.plan-copy small { color: var(--muted); }
.row-actions { display: flex; align-items: center; gap: 6px; }
.drawer-backdrop { position: fixed; inset: 0; z-index: 20; background: rgba(18, 27, 23, .36); }
.side-drawer { position: fixed; z-index: 21; top: 0; right: 0; width: min(620px, 94vw); height: 100vh; overflow-y: auto; padding: 26px 28px; background: var(--surface); box-shadow: -12px 0 36px rgba(23, 32, 29, .15); transform: translateX(102%); transition: transform .2s ease; }
.side-drawer.is-open { transform: translateX(0); }
.drawer-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 24px; padding-bottom: 15px; border-bottom: 1px solid var(--line); }
.drawer-header h2 { font-size: 22px; }
.drawer-actions, .form-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 22px; }
.field { display: grid; gap: 7px; margin-bottom: 17px; }
.field > span { font-weight: 700; }
.field input, .field textarea, .field select { width: 100%; min-height: 40px; padding: 9px 11px; border: 1px solid var(--line-strong); border-radius: 6px; color: var(--ink); background: var(--surface); resize: vertical; }
.field input:focus, .field textarea:focus, .field select:focus { outline: 2px solid #b9dbca; border-color: var(--green); }
.field small { color: var(--muted); }
.segmented-control { display: grid; grid-template-columns: repeat(6, minmax(0,1fr)); border: 1px solid var(--line-strong); border-radius: 6px; overflow: hidden; }
.segmented-control button { min-height: 38px; padding: 0 7px; border: 0; border-right: 1px solid var(--line); background: var(--surface); color: var(--muted); cursor: pointer; white-space: nowrap; }
.segmented-control button:last-child { border-right: 0; }
.segmented-control button.is-active { color: white; background: var(--ink); }
.toggle-line { display: flex; align-items: center; gap: 9px; font-weight: 700; }
.toggle-line input { width: 18px; height: 18px; accent-color: var(--green); }
.occurrence-preview { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line); }
.occurrence-preview ol { columns: 2; margin: 0; padding-left: 24px; color: var(--muted); line-height: 1.9; }

.rules-layout { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 22px; }
.settings-panel { padding: 19px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; }
.two-column-fields { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 14px; }
.count-control { display: grid; grid-template-columns: minmax(100px,1fr) auto minmax(100px,1fr) auto; gap: 10px; align-items: center; }
.count-control .field { margin: 0; }
.search-depth { margin-top: 18px; }
.version-list { border-top: 1px solid var(--line); }
.version-list div { display: flex; justify-content: space-between; gap: 20px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.version-list span { color: var(--muted); }
.safety-steps { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.safety-steps div { min-height: 90px; display: flex; align-items: center; gap: 12px; padding: 16px; background: var(--surface); }
.safety-steps strong { width: 30px; height: 30px; display: grid; place-items: center; flex: 0 0 30px; border-radius: 50%; background: var(--green-soft); color: var(--green); }

.notification-signal { display: grid; grid-template-columns: auto minmax(220px, .9fr) minmax(420px, 1.5fr); align-items: center; gap: 18px; padding: 19px 22px; background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--green); border-radius: 8px; box-shadow: var(--shadow); }
.notification-signal.is-sample { border-left-color: var(--amber); }
.notification-signal.is-paused { border-left-color: var(--amber); }
.notification-signal.is-error { border-left-color: var(--red); }
.signal-mark { width: 30px; height: 38px; display: flex; align-items: center; justify-content: center; gap: 3px; color: var(--green); }
.notification-signal.is-sample .signal-mark, .notification-signal.is-paused .signal-mark { color: var(--amber); }
.notification-signal.is-error .signal-mark { color: var(--red); }
.signal-mark span { width: 4px; border-radius: 2px; background: currentColor; }
.signal-mark span:nth-child(1) { height: 16px; }
.signal-mark span:nth-child(2) { height: 32px; }
.signal-mark span:nth-child(3) { height: 23px; }
.signal-copy h2 { margin-bottom: 5px; }
.signal-copy p { margin: 0; color: var(--muted); line-height: 1.5; }
.notification-stats { margin: 0; display: grid; grid-template-columns: 110px 110px minmax(160px, 1fr); }
.notification-stats div { min-width: 0; padding: 3px 16px; border-left: 1px solid var(--line); }
.notification-stats dt { margin-bottom: 6px; color: var(--muted); font-size: 12px; }
.notification-stats dd { margin: 0; font-weight: 750; overflow-wrap: anywhere; }
.notification-history table { min-width: 880px; }
.delivery-line { display: block; margin: 2px 0; white-space: nowrap; }
.muted-text, .privacy-note { color: var(--muted); }
.notice-status-已发送 { color: var(--green); background: var(--green-soft); }
.notice-status-部分发送, .notice-status-结果未知, .notice-status-等待发送 { color: var(--amber); background: var(--amber-soft); }
.notice-status-发送失败, .notice-status-推送配置不完整, .notice-status-手机管理未启用 { color: var(--red); background: var(--red-soft); }
.device-list { display: grid; gap: 9px; }
.device-row { display: grid; grid-template-columns: minmax(150px, .8fr) minmax(230px, 1.2fr) 150px auto; gap: 14px; align-items: end; padding: 17px 18px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; }
.device-row .field { margin: 0; }
.device-state { min-height: 40px; display: flex; flex-direction: column; justify-content: center; align-items: flex-start; gap: 5px; }
.device-state small { color: var(--muted); }
.device-actions { min-height: 40px; display: flex; align-items: center; justify-content: flex-end; gap: 9px; }
.danger-link { color: var(--red); }
.compact-empty { min-height: 116px; }
.add-device-panel { margin-top: 14px; padding: 0 18px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; }
.add-device-panel summary { padding: 16px 0; font-weight: 750; cursor: pointer; }
.add-device-panel[open] summary { border-bottom: 1px solid var(--line); }
.add-device-form { display: grid; grid-template-columns: minmax(160px, .8fr) minmax(260px, 1.4fr) auto; gap: 14px; align-items: end; padding: 18px 0; }
.add-device-form .field { margin: 0; }
.privacy-note { margin: 12px 1px 0; font-size: 12px; }

@media (max-width: 920px) {
  .app-shell { grid-template-columns: 78px minmax(0,1fr); }
  .sidebar { padding-inline: 10px; }
  .brand { justify-content: center; padding-inline: 0; }
  .brand-copy, .nav-item span:last-child, .sidebar-footer span:last-child { display: none; }
  .nav-item { justify-content: center; padding: 0; }
  .main-content { padding: 30px 26px 50px; }
  .status-strip { align-items: flex-start; }
  .status-meta { grid-template-columns: repeat(2,minmax(90px,1fr)); }
  .metric-grid { grid-template-columns: repeat(3,minmax(0,1fr)); }
  .metric:nth-child(3) { border-right: 0; }
  .notification-signal { grid-template-columns: auto minmax(0,1fr); }
  .notification-stats { grid-column: 1 / -1; }
  .device-row { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .device-actions { justify-content: flex-start; }
}

@media (max-width: 620px) {
  .app-shell { display: block; }
  .sidebar { position: sticky; z-index: 5; width: 100%; height: 64px; padding: 8px 12px; flex-direction: row; align-items: center; box-shadow: 0 4px 16px rgba(23,32,29,.16); }
  .brand { width: 42px; padding: 0; border: 0; }
  .brand-mark { width: 36px; height: 36px; }
  .nav-list { margin: 0 0 0 8px; display: flex; flex: 1; justify-content: space-around; }
  .nav-item { width: 42px; height: 42px; }
  .sidebar-footer { display: none; }
  .main-content { padding: 24px 16px 38px; }
  .page-header, .page-header.compact { align-items: flex-start; flex-direction: column; gap: 17px; }
  h1 { font-size: 25px; }
  .header-actions { width: 100%; justify-content: flex-start; }
  .header-actions .button { flex: 1 1 110px; }
  .status-strip { flex-direction: column; }
  .status-meta { width: 100%; gap: 16px; }
  .metric-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .metric, .metric:first-child { padding: 17px 12px; border-right: 1px solid var(--line); }
  .metric:nth-child(2n) { border-right: 0; }
  .query-row { grid-template-columns: 48px minmax(0,1fr); }
  .query-status { display: none; }
  .result-item { gap: 10px; padding: 15px; }
  .result-title-line { align-items: flex-start; flex-direction: column; gap: 7px; }
  .result-meta { display: grid; gap: 5px; }
  .score-block { width: 48px; flex-basis: 48px; }
  .settings-grid { grid-template-columns: 1fr; gap: 30px; }
  .rules-layout { grid-template-columns: 1fr; }
  .plan-row { grid-template-columns: 22px minmax(0,1fr); }
  .row-actions { grid-column: 2; flex-wrap: wrap; }
  .notification-signal { padding: 17px 15px; }
  .notification-stats { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .notification-stats div { padding: 7px 11px; }
  .notification-stats div:last-child { grid-column: 1 / -1; border-top: 1px solid var(--line); }
  .device-row, .add-device-form { grid-template-columns: 1fr; }
  .device-actions { flex-wrap: wrap; }
}

@media (max-width: 620px) {
  .sidebar { position: fixed; top: auto; bottom: 0; height: 58px; padding: 7px 8px; }
  .brand { display: none; }
  .nav-list { margin: 0; width: 100%; }
  .nav-item { flex: 1 1 0; min-width: 0; }
  .main-content { padding-bottom: 86px; }
  .notice-bar { flex-direction: column; gap: 4px; }
  .notice-bar strong { white-space: normal; }
  .query-row:has(.query-feedback) { grid-template-columns: 48px minmax(0,1fr); }
  .query-feedback { grid-column: 2; flex-wrap: wrap; }
  .side-drawer { width: 100vw; padding: 20px 16px 86px; }
  .segmented-control { grid-template-columns: repeat(3,1fr); }
  .segmented-control button:nth-child(3) { border-right: 0; }
  .segmented-control button:nth-child(-n+3) { border-bottom: 1px solid var(--line); }
  .two-column-fields { grid-template-columns: 1fr; }
  .count-control { grid-template-columns: 1fr auto 1fr; }
  .count-control strong { grid-column: 1 / -1; }
  .occurrence-preview ol { columns: 1; }
  .safety-steps { grid-template-columns: 1fr; }
}
