:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --text: #1c2330;
  --muted: #667085;
  --line: #e2e5ea;
  --accent: #0e6b74;
  --accent-text: #ffffff;
  --ok: #1f7a3f;
  --ok-bg: #e5f4ea;
  --warn: #8a5a00;
  --warn-bg: #fff3d6;
  --bad: #b42318;
  --bad-bg: #fde8e7;
  --info: #175cd3;
  --info-bg: #e6efff;
  --chip: #eef0f3;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12161c;
    --panel: #1b2129;
    --text: #e6e9ee;
    --muted: #98a2b3;
    --line: #2c3440;
    --accent: #2aa3ae;
    --accent-text: #0b1014;
    --ok: #5fd08a;
    --ok-bg: #173323;
    --warn: #f5c056;
    --warn-bg: #3a2f14;
    --bad: #f97066;
    --bad-bg: #3d1a17;
    --info: #84adff;
    --info-bg: #1a2a47;
    --chip: #262e39;
    --shadow: none;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
button, input, select { font: inherit; color: inherit; }
a { color: var(--accent); }

header.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px; background: var(--panel); border-bottom: 1px solid var(--line);
}
header.top h1 { font-size: 18px; margin: 0; letter-spacing: .3px; }
header.top .spacer { flex: 1; }

main { max-width: 1000px; margin: 0 auto; padding: 16px; }

.btn {
  border: 1px solid var(--line); background: var(--panel); border-radius: 8px;
  padding: 7px 12px; cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: var(--muted); }
a.btn { text-decoration: none; color: var(--text); display: inline-block; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.danger { color: var(--bad); }
.btn.small { padding: 4px 9px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: default; }

.summary { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 14px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; box-shadow: var(--shadow); }
.stat .n { font-size: 22px; font-weight: 600; }
.stat .l { color: var(--muted); font-size: 13px; }

.toolbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; margin-bottom: 14px;
}
.toolbar .sel { color: var(--muted); margin-right: auto; }

.banner { border-radius: 10px; padding: 10px 12px; margin-bottom: 12px; background: var(--warn-bg); color: var(--warn); }

.group { margin-bottom: 18px; }
.group-head { display: flex; align-items: center; gap: 8px; margin: 0 2px 6px; }
.group-head h2 { font-size: 14px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); margin: 0; }

.box {
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px; margin-bottom: 8px; box-shadow: var(--shadow);
}
.box-row { display: flex; align-items: center; gap: 10px; padding: 10px 12px; cursor: pointer; }
.box-row input[type=checkbox] { width: 18px; height: 18px; flex: none; }
.box-main { flex: 1; min-width: 0; }
.box-name { font-weight: 600; }
.box-sub { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.chip { font-size: 12px; padding: 2px 8px; border-radius: 99px; background: var(--chip); white-space: nowrap; }
.chip.ok { background: var(--ok-bg); color: var(--ok); }
.chip.warn { background: var(--warn-bg); color: var(--warn); }
.chip.bad { background: var(--bad-bg); color: var(--bad); }
.chip.info { background: var(--info-bg); color: var(--info); }
.chip.tag { background: transparent; border: 1px solid var(--line); color: var(--muted); }

.box-detail { border-top: 1px solid var(--line); padding: 10px 12px 12px; display: none; }
.box.open .box-detail { display: block; }
.box-detail h3 { font-size: 13px; color: var(--muted); margin: 10px 0 4px; font-weight: 600; }
.box-detail h3:first-child { margin-top: 0; }
.pkg { font: 12.5px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; overflow-x: auto; white-space: pre; margin: 0; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-top: 20px; box-shadow: var(--shadow); }
.panel h2 { font-size: 15px; margin: 0 0 8px; }
.task { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-top: 1px solid var(--line); font-size: 14px; }
.task:first-of-type { border-top: 0; }
.task .what { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.task .when { color: var(--muted); font-size: 13px; white-space: nowrap; }
.empty { color: var(--muted); padding: 10px 0; }

dialog { border: 1px solid var(--line); border-radius: 12px; background: var(--panel); color: var(--text); padding: 0; width: min(560px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(0, 0, 0, .45); }
dialog.wide { width: min(900px, calc(100vw - 32px)); }
.dlg-head { display: flex; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.dlg-head h2 { font-size: 16px; margin: 0; flex: 1; }
.dlg-body { padding: 14px; }
.dlg-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 14px; border-top: 1px solid var(--line); }
label.f { display: block; margin-bottom: 10px; font-size: 14px; }
label.f span { display: block; color: var(--muted); margin-bottom: 3px; }
label.f input[type=text], label.f input[type=password], label.f input:not([type]) {
  width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg);
}
label.c { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.hint { color: var(--muted); font-size: 13px; }
.err { color: var(--bad); font-size: 14px; min-height: 1em; }
pre.log { margin: 0; max-height: 65vh; overflow: auto; font: 12px/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; white-space: pre-wrap; word-break: break-word; }

.toast {
  position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 50;
  background: var(--text); color: var(--bg); padding: 9px 14px; border-radius: 8px; max-width: calc(100vw - 32px);
}

.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 22px; width: min(360px, 100%); }
.login h1 { margin: 0 0 14px; font-size: 20px; }

@media (max-width: 640px) {
  .summary { grid-template-columns: repeat(2, 1fr); }
  .box-row { flex-wrap: wrap; }
  .chips { width: 100%; justify-content: flex-start; padding-left: 28px; }
  header.top .hide-sm { display: none; }
}
