:root {
  --bg: #f4f6fb;
  --panel: #ffffff;
  --ink: #1f2733;
  --ink-soft: #5b6675;
  --muted: #8a94a6;
  --line: #e6eaf2;
  --brand: #2f6bff;
  --brand-dark: #1f51d6;
  --ok: #1f9d64;
  --ok-bg: #e5f6ee;
  --err: #d64545;
  --err-bg: #fbe9e9;
  --warn: #c47f1a;
  --warn-bg: #fbf1dd;
  --run: #2f6bff;
  --run-bg: #e6efff;
  --wait-bg: #eef1f6;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(20, 30, 55, .06), 0 6px 18px rgba(20, 30, 55, .05);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
    "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "微软雅黑", sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; font-weight: 650; }
code { font-family: var(--mono); background: #eef1f6; padding: 1px 5px; border-radius: 4px; font-size: .92em; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.wrap { white-space: normal; word-break: break-word; overflow-wrap: anywhere; }
.nowrap { white-space: nowrap; }
.center { text-align: center; }
.empty { padding: 18px 4px; }

/* ------------------------------------------------------------------ layout */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 220px; flex-shrink: 0; background: #10192e; color: #c5cede;
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 20px 20px 14px; }
.brand-mark { font-size: 22px; }
.brand-name { font-weight: 700; font-size: 16px; color: #fff; letter-spacing: .3px; }
.nav { display: flex; flex-direction: column; padding: 6px 10px; gap: 2px; flex: 1; overflow-y: auto; }
.nav-item { color: #b8c2d6; padding: 9px 14px; border-radius: 8px; font-size: 13.5px; }
.nav-item:hover { background: #1b2740; color: #fff; text-decoration: none; }
.nav-item.active { background: var(--brand); color: #fff; }
.nav-group { color: #64708c; font-size: 11px; text-transform: uppercase; letter-spacing: .8px; padding: 14px 14px 4px; }
.sidebar-foot { padding: 12px 20px; color: #56617c; font-size: 12px; border-top: 1px solid #1b2740; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 26px; background: var(--panel); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.topbar-title { font-size: 16px; font-weight: 650; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.user-chip { background: #eef1f6; color: var(--ink-soft); padding: 4px 12px; border-radius: 999px; font-size: 12.5px; }
.content { padding: 22px 26px 40px; max-width: 1180px; width: 100%; }

/* ------------------------------------------------------------------ cards */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; margin-bottom: 18px; }
.card.narrow { max-width: 520px; }
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.card-head h2 { font-size: 15px; }
.cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 18px; }
.stat { text-align: center; padding: 22px 12px; }
.stat-num { font-size: 30px; font-weight: 700; color: var(--brand); }
.stat-label { color: var(--muted); margin-top: 4px; font-size: 13px; }
.grid-2 { display: grid; grid-template-columns: 1.3fr 1fr; gap: 18px; align-items: start; }
.grid-log { display: grid; grid-template-columns: 300px 1fr; gap: 18px; align-items: start; }
.page-intro { color: var(--ink-soft); margin-bottom: 16px; background: #eef3ff; border: 1px solid #d9e4ff; padding: 12px 16px; border-radius: var(--radius); }
.page-intro p { margin: 0; }

/* ------------------------------------------------------------------ tables */
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th, .table td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table thead th { color: var(--ink-soft); font-weight: 600; background: #fafbfe; font-size: 12.5px; }
.table tbody tr:hover { background: #fafbff; }
.table-compact th, .table-compact td { padding: 7px 10px; font-size: 12.8px; }
/* 横向滚动容器：表格取自然宽度、至少占满容器，超出则可横向滚动查看完整字段 */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-scroll > .table { width: auto; min-width: 100%; }

/* 冻结前三列（类型/代码/名称），横向滚动时始终可见 */
.sticky-table .sticky-col { position: sticky; z-index: 2; background: #fff; }
.sticky-table thead .sticky-col { z-index: 4; background: #fafbfe; }
.sticky-table .sticky-0 { left: 0;      width: 46px;  min-width: 46px; }
.sticky-table .sticky-1 { left: 46px;   width: 68px;  min-width: 68px; }
.sticky-table .sticky-2 { left: 114px;  width: 120px; min-width: 120px;
  box-shadow: 6px 0 6px -4px rgba(20, 30, 55, .12); }
.sticky-table tbody tr:hover .sticky-col { background: #fafbff; }
/* 综合强度% 渐变底色单元格 */
.strength-cell { font-weight: 650; color: #1f2733; text-align: center; }
.table-kv th { width: 190px; color: var(--ink-soft); font-weight: 600; background: #fafbfe; }
.table-edit td { vertical-align: middle; }
.table-edit input[type="text"], .table-edit input[type="number"], .table-edit select { width: 100%; }

/* ------------------------------------------------------------------ badges/tags */
.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge-ok { background: var(--ok-bg); color: var(--ok); }
.badge-err { background: var(--err-bg); color: var(--err); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-run { background: var(--run-bg); color: var(--run); }
.badge-wait { background: var(--wait-bg); color: var(--ink-soft); }
.tag { display: inline-block; background: #eef1f6; color: var(--ink-soft); padding: 2px 10px; border-radius: 6px; font-size: 12px; }

/* ------------------------------------------------------------------ buttons */
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid transparent; border-radius: 8px; padding: 8px 16px; font-size: 13.5px; font-family: inherit; cursor: pointer; background: #eef1f6; color: var(--ink); transition: .15s; text-decoration: none; }
.btn:hover { text-decoration: none; filter: brightness(.98); }
.btn-sm { padding: 5px 11px; font-size: 12.5px; }
.btn-block { width: 100%; justify-content: center; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); }
.btn-secondary { background: #e7ecf6; color: var(--ink); border-color: #d9e0ee; }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--ink-soft); }
.btn-ghost:hover { background: #f3f5fa; }
.btn-ghost.danger { color: var(--err); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.inline-form { display: inline; }
.form-actions { display: flex; gap: 10px; margin-top: 16px; }
.form-actions.space-between { justify-content: space-between; }
.actions-cell { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; }

/* ------------------------------------------------------------------ forms */
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.field > span { font-size: 13px; color: var(--ink-soft); font-weight: 600; }
.field-inline { max-width: 260px; }
input[type="text"], input[type="password"], input[type="number"], input[type="time"],
input[type="datetime-local"], select, textarea {
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font-size: 13.5px;
  font-family: inherit; color: var(--ink); background: #fff; outline: none; transition: .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(47,107,255,.12); }
.hint { color: var(--muted); font-size: 11.5px; font-weight: 400; }
.hint em { font-style: normal; color: #a0a8b8; }

/* switch */
.switch { position: relative; display: inline-block; width: 40px; height: 22px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; inset: 0; background: #cbd3e0; border-radius: 999px; transition: .2s; cursor: pointer; }
.slider:before { content: ""; position: absolute; height: 16px; width: 16px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; }
.switch input:checked + .slider { background: var(--brand); }
.switch input:checked + .slider:before { transform: translateX(18px); }

/* ------------------------------------------------------------------ settings */
.settings-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px 24px; }
.setting { border-bottom: 1px dashed var(--line); padding-bottom: 12px; }
.setting-label { display: flex; justify-content: space-between; align-items: baseline; gap: 6px 10px; margin-bottom: 6px; flex-wrap: wrap; }
.setting-label label { font-weight: 600; color: var(--ink); }
.setting-label .hint { flex: 1 1 auto; min-width: 0; text-align: right; }
.setting-input { display: flex; align-items: center; gap: 10px; }
.setting-input input, .setting-input select { width: 100%; }
.setting-bool .setting-input { width: auto; }
.setting-desc { margin-top: 6px; }

/* ------------------------------------------------------------------ indicators */
.indicator-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.indicator { margin-bottom: 0; }
.indicator.is-off { opacity: .62; }
.indicator-head { display: flex; gap: 12px; align-items: flex-start; }
.indicator-title h3 { font-size: 14.5px; }
.param-row { display: flex; flex-wrap: wrap; gap: 12px; margin: 12px 0 6px; }
.param-row .field { margin-bottom: 0; min-width: 96px; flex: 1; }
.param-row .field input { width: 100%; }
.indicator-foot { border-top: 1px solid var(--line); padding-top: 8px; margin-top: 8px; }

/* ------------------------------------------------------------------ schedules */
.sched-grid { display: grid; grid-template-columns: 1fr 240px; gap: 16px; }
.sched-form .trigger-fields { margin: 6px 0 8px; padding: 12px; background: #fafbfe; border: 1px solid var(--line); border-radius: 8px; }
.hidden { display: none; }
.weekday-picker { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.chip-check { position: relative; }
.chip-check input { position: absolute; opacity: 0; }
.chip-check span { display: inline-block; padding: 6px 12px; border: 1px solid var(--line); border-radius: 999px; font-size: 13px; cursor: pointer; color: var(--ink-soft); }
.chip-check input:checked + span { background: var(--brand); color: #fff; border-color: var(--brand); }
.sched-list { list-style: none; margin: 0; padding: 0; }
.sched-list li { padding: 10px 0; border-bottom: 1px solid var(--line); }
.sched-main { display: flex; align-items: center; gap: 8px; }
.sched-meta { display: flex; gap: 12px; margin-top: 4px; margin-left: 18px; flex-wrap: wrap; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.dot.on { background: var(--ok); }
.dot.off { background: #cbd3e0; }
.sched-name { font-weight: 600; }

/* ------------------------------------------------------------------ progress / logs */
.progress-wrap { margin: 14px 0; }
.progress-bar { height: 8px; background: #e6eaf2; border-radius: 999px; overflow: hidden; }
.progress-fill { height: 100%; width: 0; background: var(--brand); transition: width .4s; }
.logbox { background: #0f1830; color: #cdd6ea; padding: 14px 16px; border-radius: 8px; font-family: var(--mono); font-size: 12.5px; line-height: 1.65; white-space: pre-wrap; word-break: break-word; max-height: 360px; overflow: auto; margin: 0; }
.logbox.tall { max-height: 620px; }
.meta-list { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 14px 0 0; }
.meta-list dt { color: var(--muted); font-size: 12px; }
.meta-list dd { margin: 2px 0 0; font-weight: 600; }
.run-head-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.run-head-actions { display: flex; gap: 8px; }

/* file list */
.file-list { list-style: none; margin: 0; padding: 0; }
.file-list li a { display: flex; justify-content: space-between; gap: 8px; padding: 8px 10px; border-radius: 8px; color: var(--ink); }
.file-list li a:hover { background: #f3f5fa; text-decoration: none; }
.file-list li.active a { background: var(--run-bg); color: var(--brand); }

/* ------------------------------------------------------------------ pagination */
.pagination { display: flex; align-items: center; justify-content: center; gap: 14px; margin-top: 16px; }
.page-btn { padding: 6px 14px; border: 1px solid var(--line); border-radius: 8px; color: var(--ink-soft); font-size: 13px; }
.page-btn:hover { background: #f3f5fa; text-decoration: none; }
.page-btn.disabled { opacity: .45; pointer-events: none; }
.page-info { color: var(--muted); font-size: 13px; }

/* ------------------------------------------------------------------ flash */
.flash-stack { margin-bottom: 16px; display: flex; flex-direction: column; gap: 8px; }
.flash { padding: 10px 14px; border-radius: 8px; font-size: 13.5px; border: 1px solid transparent; }
.flash-success { background: var(--ok-bg); color: var(--ok); border-color: #bfe6d2; }
.flash-error { background: var(--err-bg); color: var(--err); border-color: #f1c9c9; }
.flash-info { background: #e9f0ff; color: var(--brand-dark); border-color: #cfe0ff; }

/* ------------------------------------------------------------------ login */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: linear-gradient(135deg, #14213d, #24427c); }
.login-card { background: #fff; width: 360px; max-width: 92vw; border-radius: 14px; padding: 30px 30px 24px; box-shadow: 0 20px 60px rgba(0,0,0,.28); }
.login-head { text-align: center; margin-bottom: 18px; }
.login-head .brand-mark { font-size: 34px; }
.login-head h1 { font-size: 19px; margin: 8px 0 2px; }
.login-form { display: flex; flex-direction: column; gap: 4px; }
.login-hint { text-align: center; margin: 14px 0 0; font-size: 12px; }

/* ------------------------------------------------------------------ screener */
.universe-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.pick-card { display: flex; gap: 10px; align-items: flex-start; border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; cursor: pointer; transition: .15s; }
.pick-card:hover { border-color: var(--brand); background: #fafbff; }
.pick-card input { margin-top: 3px; }
.pick-body { display: flex; flex-direction: column; gap: 2px; }
.pick-card input:checked ~ .pick-body strong { color: var(--brand); }

.preset-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 12px; }
.preset-card { display: flex; gap: 10px; border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; cursor: pointer; transition: .15s; }
.preset-card:hover { border-color: var(--brand); }
.preset-card.selected { border-color: var(--brand); background: #f2f6ff; box-shadow: inset 0 0 0 1px var(--brand); }
.preset-card input { margin-top: 3px; }
.preset-title { font-weight: 650; }
.preset-uses { color: #5b6675; margin-top: 6px; }

.screen-meta { display: flex; flex-wrap: wrap; gap: 8px; }
.screen-meta .tag.badge-ok { background: var(--ok-bg); color: var(--ok); }
.screen-meta .tag.badge-warn { background: var(--warn-bg); color: var(--warn); }

.sched-grid { grid-template-columns: 1fr 210px 210px; }

/* ------------------------------------------------------------------ responsive */
@media (max-width: 900px) {
  .sidebar { width: 74px; }
  .brand-name, .sidebar-foot { display: none; }
  .nav-group { font-size: 10px; padding: 10px 4px 2px; text-align: center; letter-spacing: 0; }
  .nav-item { text-align: center; padding: 9px 4px; font-size: 11.5px; }
  .cards, .settings-grid, .indicator-grid { grid-template-columns: 1fr; }
  .grid-2, .grid-log, .sched-grid { grid-template-columns: 1fr; }
  .meta-list { grid-template-columns: 1fr; }
  .content { padding: 16px; }
}

@media (max-width: 560px) {
  .topbar { flex-wrap: wrap; gap: 8px; padding: 12px 16px; }
  .topbar-title { font-size: 15px; }
  .topbar-right { width: 100%; justify-content: space-between; }
  .user-chip { max-width: 42vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .universe-grid, .preset-list { grid-template-columns: 1fr; }
  .form-actions { flex-wrap: wrap; }
}
