:root {
  color-scheme: light;
  --ink: #1b2430;
  --muted: #5d6b7c;
  --line: #d5dde6;
  --page: #e8edf2;
  --card: #fff;
  --navy: #12324d;
  --navy-2: #1b4f78;
  --green: #146c43;
  --green-bg: #e7f6ee;
  --blue: #1d4e89;
  --blue-bg: #e8f1fb;
  --amber: #8a4b08;
  --amber-bg: #fbf3e6;
  --red: #9b2c2c;
  --red-bg: #fdecec;
  --gray-bg: #eef2f6;
  font-family: "Segoe UI", sans-serif;
  font-size: 14px;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--page); color: var(--ink); }
button, input { font: inherit; }
button { border: 1px solid var(--line); background: var(--card); color: var(--ink); border-radius: 4px; padding: 7px 12px; cursor: pointer; }
button.primary { background: var(--navy); border-color: var(--navy); color: white; }
button.danger { color: var(--red); }
button:disabled { opacity: 0.55; cursor: not-allowed; }
h2 { margin: 0; font-size: 15px; }
a { color: var(--blue); }

.appbar {
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 20px;
  background: var(--navy);
  color: white;
}
.brand { display: flex; flex-direction: column; line-height: 1.2; }
.brand span, #env { color: #c5d4e4; font-size: 12px; }
main { width: min(1180px, calc(100% - 28px)); margin: 16px auto 32px; }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 12px; }
.stat { background: var(--card); border: 1px solid var(--line); padding: 10px 12px; }
.stat b { display: block; font-size: 22px; line-height: 1.1; }
.stat span { color: var(--muted); font-size: 12px; }

.panel { background: var(--card); border: 1px solid var(--line); }
.toolbar, .panel-head, .detail-bar, .dialog-actions {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.toolbar, .panel-head { padding: 10px 12px; border-bottom: 1px solid var(--line); }
.toolbar input { flex: 1; min-width: 220px; border: 1px solid var(--line); border-radius: 4px; padding: 7px 10px; }
.filters { display: flex; }
.filters button { border-radius: 0; margin-left: -1px; }
.filters button.on { background: #e8f1fb; border-color: #b9d0ea; color: var(--blue); }

.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; color: var(--muted); font-weight: 650; background: #f7f9fb; }
#rows tr { cursor: pointer; }
#rows tr:hover { background: #f5f8fb; }
.course-links { display: flex; flex-direction: column; gap: 2px; }
.course-links a, .course-links span { cursor: pointer; }

.badge { display: inline-block; padding: 2px 7px; border-radius: 3px; font-size: 12px; font-weight: 650; white-space: nowrap; }
.badge.created, .badge.built { background: var(--green-bg); color: var(--green); }
.badge.exists { background: var(--blue-bg); color: var(--blue); }
.badge.planned, .badge.pending { background: var(--gray-bg); color: #3e4c5e; }
.badge.blocked, .badge.failed { background: var(--red-bg); color: var(--red); }
.badge.warn { background: var(--amber-bg); color: var(--amber); }

.empty { margin: 0; padding: 16px 12px; color: var(--muted); }
.banner { margin: 0 0 12px; padding: 10px 12px; background: var(--amber-bg); color: var(--amber); border: 1px solid #efd7b2; }
.banner.bad { background: var(--red-bg); color: var(--red); border-color: #f3c7c7; }
.banner.good { background: var(--green-bg); color: var(--green); border-color: #bfe5d0; }

.detail-bar { margin-bottom: 12px; }
.detail-title { display: flex; flex-direction: column; flex: 1; }
.detail-title span { color: var(--muted); }
.split { display: grid; grid-template-columns: 280px 1fr; gap: 12px; margin-top: 12px; }
.split .panel, #plan-panel { padding: 12px; }
#plan-panel { margin-top: 12px; }
.file-list, .slots { list-style: none; margin: 8px 0 12px; padding: 0; }
.file-list li, .slots li { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.plan-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 10px; }
.line { display: grid; grid-template-columns: minmax(150px, 210px) 1fr; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.facts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.facts span { background: var(--gray-bg); padding: 3px 8px; font-size: 12px; }

dialog { border: 1px solid var(--line); padding: 0; width: min(560px, calc(100% - 24px)); }
dialog form { padding: 16px; }
dialog h2 { margin-bottom: 8px; }
.hint { margin: 0 0 12px; color: var(--muted); }
.file-picker { display: inline-block; margin-bottom: 8px; }
.file-picker input { display: block; }
.dialog-actions { justify-content: flex-end; margin-top: 12px; }
.slots .ok { color: var(--green); }
.slots .miss { color: var(--red); }
.slots .opt { color: var(--muted); }

@media (max-width: 800px) {
  .stats, .split, .plan-grid { grid-template-columns: 1fr; }
  .appbar { height: auto; padding: 10px 14px; align-items: flex-start; }
}
