:root {
  --bg: #0e1320;
  --bg2: #151c2e;
  --panel: #1a2236;
  --panel2: #212c44;
  --line: #2c3a57;
  --ink: #e8edf7;
  --muted: #93a1bd;
  --accent: #5b8cff;
  --accent2: #38d6c4;
  --safe: #34d399;
  --low: #8bd450;
  --medium: #f7b955;
  --high: #fc6b6b;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  --radius: 14px;
  font-synthesis: none;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: radial-gradient(1200px 600px at 70% -10%, #1d2742 0%, var(--bg) 55%) fixed;
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.wrap { max-width: 1280px; margin: 0 auto; padding: 0 20px; }

/* Header */
.topbar {
  border-bottom: 1px solid var(--line);
  background: rgba(14, 19, 32, 0.7);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar .wrap {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding-top: 16px; padding-bottom: 16px; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 14px; }
.logo { font-size: 34px; line-height: 1; }
h1 { font-size: 20px; margin: 0; letter-spacing: 0.2px; }
.tagline { margin: 2px 0 0; color: var(--muted); font-size: 13px; max-width: 640px; }
.privacy {
  font-size: 12px; color: var(--accent2);
  border: 1px solid rgba(56, 214, 196, 0.35);
  background: rgba(56, 214, 196, 0.08);
  padding: 6px 12px; border-radius: 999px; white-space: nowrap;
}

/* Layout */
.layout {
  display: grid; grid-template-columns: minmax(0, 0.92fr) minmax(0, 1.08fr);
  gap: 22px; padding-top: 24px; padding-bottom: 32px; align-items: start;
}
.panel {
  background: linear-gradient(180deg, var(--panel) 0%, var(--bg2) 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}
.input-panel { position: sticky; top: 86px; }

.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
h2 { font-size: 16px; margin: 0; }
.presets { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }

select, input[type="text"], input[type="number"] {
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--ink);
  border-radius: 9px;
  padding: 8px 10px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
}
select:focus, input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(91, 140, 255, 0.18); }

.controls { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.buffer-field { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.buffer-field input { width: 64px; }

.btn {
  border: 1px solid var(--line);
  background: var(--panel2);
  color: var(--ink);
  border-radius: 9px;
  padding: 8px 14px;
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
  transition: transform 0.05s ease, border-color 0.15s ease, background 0.15s ease;
}
.btn:hover { border-color: var(--accent); }
.btn:active { transform: translateY(1px); }
.btn.ghost { background: transparent; }
.btn.ghost.danger { color: var(--high); border-color: rgba(252, 107, 107, 0.4); }
.btn.primary { background: linear-gradient(135deg, var(--accent), #6f5bff); border-color: transparent; font-weight: 600; }

/* Rows */
.table-head, .row {
  display: grid;
  grid-template-columns: 1.3fr 1.5fr 0.7fr 1.2fr 32px;
  gap: 8px; align-items: center;
}
.table-head { font-size: 11px; color: var(--muted); padding: 0 4px 8px; text-transform: uppercase; letter-spacing: 0.4px; }
.rows { display: flex; flex-direction: column; gap: 8px; }
.row { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 8px; }
.row.invalid { border-color: rgba(252, 107, 107, 0.6); }
.row input, .row select { width: 100%; }
.row .cron-input { font-family: "SF Mono", ui-monospace, Menlo, monospace; letter-spacing: 0.3px; }
.row .del {
  border: none; background: transparent; color: var(--muted);
  cursor: pointer; font-size: 17px; line-height: 1; padding: 4px;
}
.row .del:hover { color: var(--high); }
.row-error { grid-column: 1 / -1; color: var(--high); font-size: 11px; padding: 2px 4px 0; }

.resource-legend { margin-top: 16px; display: flex; flex-wrap: wrap; gap: 6px; }
.res-chip {
  font-size: 11px; color: var(--muted);
  border: 1px solid var(--line); border-radius: 999px; padding: 3px 9px;
  display: inline-flex; gap: 5px; align-items: center;
}
.res-dot { width: 8px; height: 8px; border-radius: 50%; }

/* Result */
.verdict {
  border-radius: 12px; padding: 14px 16px; font-size: 14px; font-weight: 600;
  margin-bottom: 16px; border: 1px solid var(--line);
  display: flex; gap: 10px; align-items: center;
}
.verdict.safe { background: rgba(52, 211, 153, 0.1); border-color: rgba(52, 211, 153, 0.4); color: #9bf0cf; }
.verdict.low { background: rgba(139, 212, 80, 0.1); border-color: rgba(139, 212, 80, 0.4); color: #cdebab; }
.verdict.medium { background: rgba(247, 185, 85, 0.1); border-color: rgba(247, 185, 85, 0.4); color: #f7d59b; }
.verdict.high { background: rgba(252, 107, 107, 0.12); border-color: rgba(252, 107, 107, 0.45); color: #ffb3b3; }

.stat-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 20px; }
.stat { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 12px; text-align: center; }
.stat .num { font-size: 24px; font-weight: 700; }
.stat .lbl { font-size: 11px; color: var(--muted); margin-top: 2px; }

.section-title { font-size: 14px; margin: 22px 0 10px; display: flex; align-items: baseline; gap: 10px; }
.section-title small { color: var(--muted); font-size: 11px; font-weight: 400; }

/* Timeline */
.timeline { display: flex; flex-direction: column; gap: 6px; }
.tl-axis { display: flex; justify-content: space-between; font-size: 10px; color: var(--muted); padding: 0 2px; margin-bottom: 2px; }
.tl-row { display: grid; grid-template-columns: 130px 1fr; gap: 10px; align-items: center; }
.tl-name { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tl-track { position: relative; height: 18px; background: var(--bg); border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.tl-grid { position: absolute; top: 0; bottom: 0; width: 1px; background: rgba(255,255,255,0.05); }
.tl-block { position: absolute; top: 2px; bottom: 2px; border-radius: 3px; min-width: 2px; }
.tl-block.conflict { outline: 1.5px solid var(--high); outline-offset: -1px; }
.tl-empty { color: var(--muted); font-size: 12px; padding: 8px 0; }

/* Conflicts */
.conflicts, .suggestions { display: flex; flex-direction: column; gap: 10px; }
.conflict-card, .suggestion-card {
  background: var(--bg); border: 1px solid var(--line); border-radius: 11px; padding: 13px 14px;
}
.conflict-card { border-left: 3px solid var(--high); }
.cc-head { display: flex; justify-content: space-between; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }
.cc-when { font-weight: 700; font-size: 14px; }
.cc-meta { font-size: 11px; color: var(--muted); }
.cc-badge { font-size: 11px; padding: 2px 8px; border-radius: 999px; background: rgba(252,107,107,0.15); color: #ffb3b3; }
.cc-tasks { display: flex; flex-wrap: wrap; gap: 6px; }
.cc-task { font-size: 12px; background: var(--panel2); border: 1px solid var(--line); border-radius: 7px; padding: 4px 9px; }

.suggestion-card { border-left: 3px solid var(--accent2); }
.sug-line { font-size: 13px; margin: 3px 0; }
.sug-keep { color: var(--safe); }
.sug-move { color: var(--medium); }
.mono { font-family: "SF Mono", ui-monospace, Menlo, monospace; }
.arrow { color: var(--accent); margin: 0 4px; }

/* Task risks */
.task-risks { display: flex; flex-direction: column; gap: 6px; }
.tr-row {
  display: grid; grid-template-columns: 18px 1.4fr 1.2fr 0.8fr 0.9fr; gap: 8px;
  align-items: center; font-size: 12px; padding: 8px 10px;
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px;
}
.tr-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tr-cron { color: var(--muted); font-family: "SF Mono", ui-monospace, Menlo, monospace; font-size: 11px; }
.tr-res { color: var(--muted); }
.risk-pill { font-size: 11px; padding: 2px 9px; border-radius: 999px; text-align: center; font-weight: 600; }
.risk-safe { background: rgba(52,211,153,0.15); color: #9bf0cf; }
.risk-low { background: rgba(139,212,80,0.15); color: #cdebab; }
.risk-medium { background: rgba(247,185,85,0.15); color: #f7d59b; }
.risk-high { background: rgba(252,107,107,0.15); color: #ffb3b3; }
.dot { width: 10px; height: 10px; border-radius: 50%; }
.tr-warn { color: var(--medium); font-size: 11px; grid-column: 2 / -1; }

.export-bar { margin-top: 22px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.copy-hint { font-size: 12px; color: var(--accent2); }

.footer { padding: 24px 20px 40px; color: var(--muted); font-size: 12px; }
.footer code { background: var(--panel2); padding: 1px 5px; border-radius: 4px; }
.loop-note { margin-top: 6px; opacity: 0.75; }

/* Responsive */
@media (max-width: 920px) {
  .layout { grid-template-columns: 1fr; }
  .input-panel { position: static; }
  .stat-row { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 560px) {
  .table-head { display: none; }
  .row { grid-template-columns: 1fr 1fr; grid-template-areas: "name name" "cron cron" "dur res" "act act"; }
  .row .c-name-i { grid-area: name; }
  .row .c-cron-i { grid-area: cron; }
  .row .c-dur-i { grid-area: dur; }
  .row .c-res-i { grid-area: res; }
  .row .del { grid-area: act; justify-self: end; }
  .tl-row { grid-template-columns: 90px 1fr; }
  .tr-row { grid-template-columns: 14px 1fr auto; }
  .tr-cron, .tr-res { display: none; }
}
