:root {
  color-scheme: dark;
  --bg: #121716;
  --surface: #1a211f;
  --inset: #151c1a;
  --raised: #232d29;
  --border: #343f3a;
  --text: #e5ede8;
  --muted: #a5b4ad;
  --accent: #b7dac8;
  --accent-hover: #cbe7d8;
  --radius: 12px;
  --rail: 218px;
  --gutter: clamp(16px, 2.8vw, 44px);
  --panel-pad: 22px;
}

* { box-sizing: border-box; }
html { scrollbar-color: #506158 var(--bg); }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.6 "Instrument Sans", "Segoe UI", "Microsoft YaHei", sans-serif;
}
::selection { background: var(--accent); color: var(--bg); }
::placeholder { color: var(--muted); opacity: 1; }
button, input, select, textarea { font: inherit; color: inherit; }
button, input, select, textarea {
  border: 1px solid var(--border);
  border-radius: 8px;
}
button, input, select { min-height: 44px; }
button {
  padding: 8px 14px;
  background: var(--raised);
  cursor: pointer;
  font-weight: 600;
}
button:hover:not(:disabled) { background: #303e37; }
button:disabled { opacity: .55; cursor: default; }
input, select, textarea { background: var(--inset); padding: 8px 11px; caret-color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
a { color: inherit; text-decoration: none; }
h1, h2, h3, p, dl { margin: 0; }
h1 { font-size: clamp(28px, 3vw, 40px); line-height: 1.18; letter-spacing: -.025em; font-weight: 650; }
h2 { font-size: 17px; line-height: 1.4; font-weight: 650; }
h3 { font-size: 15px; font-weight: 650; }
.muted, small { color: var(--muted); }
.small, small { font-size: 12px; }
.hidden { display: none !important; }
.primary { background: var(--accent); color: #17271f; border-color: transparent; }
.primary:hover:not(:disabled) { background: var(--accent-hover); }

aside {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--rail);
  padding: 32px 16px 18px;
  display: flex;
  flex-direction: column;
  background: var(--inset);
  border-right: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 12px; padding: 0 12px; margin-bottom: 36px; color: var(--accent); font-size: 26px; font-weight: 750; line-height: 1.15; }
.brand > span { color: var(--text); font-size: 15px; }
.brand b { display: block; margin-top: 3px; color: var(--muted); font-size: 11px; font-weight: 600; letter-spacing: .1em; }
.nav-label { padding-inline: 12px; margin-bottom: 8px; color: var(--muted); font-size: 11px; }
nav { display: grid; gap: 4px; }
.nav { display: flex; align-items: center; gap: 10px; text-align: left; padding-inline: 11px; color: var(--muted); background: transparent; border-color: transparent; }
.nav.active { color: var(--accent); background: #25382f; border-color: #40594d; }
.nav-icon { flex: 0 0 14px; height: 14px; position: relative; }
.overview-icon { border: 1px solid currentColor; border-radius: 3px; }
.overview-icon::before { content: ""; position: absolute; inset: 0 auto 0 4px; border-left: 1px solid currentColor; }
.manual-icon::before { content: ""; position: absolute; inset: 2px; border: 1px solid currentColor; border-radius: 2px; transform: rotate(45deg); }
.logs-icon::before { content: ""; position: absolute; inset: 3px 1px auto; height: 1px; background: currentColor; box-shadow: 0 4px currentColor, 0 8px currentColor; }
.nav i { margin-left: auto; padding-inline: 5px; border-radius: 4px; background: #34473d; font-size: 11px; font-style: normal; font-variant-numeric: tabular-nums; }
.nav-links { margin-top: 28px; }
.nav-links a { display: flex; gap: 8px; align-items: center; min-height: 40px; padding-inline: 12px; color: var(--muted); font-size: 12px; }
.nav-links a:hover { color: var(--text); }
.aside-foot { margin-top: auto; padding: 12px; color: var(--muted); font-size: 11px; }
.logout { background: transparent; color: var(--muted); font-size: 12px; }

main { margin-left: var(--rail); padding: 34px var(--gutter) 26px; max-width: 1740px; }
header { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 26px; }
header p { margin-top: 7px; }
.connection { display: grid; grid-template-columns: 8px auto; align-items: center; gap: 2px 9px; padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--inset); font-size: 12px; }
.connection small { grid-column: 2; font-size: 11px; }
.dot, .live-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: #85978d; }
.dot.online, .current:has(.tag.running) .live-dot { background: var(--accent); }
.live-dot { margin-right: 5px; vertical-align: 2px; }

.panel { margin-bottom: 20px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.section-top { display: flex; justify-content: space-between; align-items: center; gap: 12px 16px; padding: 16px var(--panel-pad); border-bottom: 1px solid var(--border); }
.section-top p { margin-top: 4px; }
.section-top button, .section-top > .tag { flex-shrink: 0; }
.launch-panel { background: var(--inset); }
.date-panel > summary { padding: 14px var(--panel-pad); color: var(--text); }
.date-panel > summary .small { margin-left: 10px; }
.date-panel[open] > summary { border-bottom: 1px solid var(--border); }
.filters.date-fields { padding-top: 14px; grid-template-columns: repeat(3, minmax(0, 1fr)) auto; }
.date-field { display: grid; gap: 4px; min-width: 0; color: var(--muted); font-size: 12px; }
.date-field button { background: var(--inset); color: var(--text); text-align: left; font-weight: 400; }
.date-field button::after { content: ""; float: right; width: 6px; height: 6px; margin-top: 5px; border: solid currentColor; border-width: 0 1px 1px 0; transform: rotate(45deg); }
.date-calendar { width: min(340px, calc(100% - 2 * var(--panel-pad))); margin: 0 var(--panel-pad) 14px; padding: 10px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--inset); }
.calendar-bar { display: flex; justify-content: space-between; align-items: center; gap: 4px; }
.calendar-bar strong { text-align: center; font-size: 13px; }
.calendar-bar button, .calendar-grid button { padding: 3px; min-height: 36px; font-size: 12px; }
.calendar-bar button { padding-inline: 8px; }
.calendar-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 3px; margin-block: 8px; text-align: center; }
.calendar-week { color: var(--muted); font-size: 12px; }
.calendar-grid button { background: transparent; border-color: transparent; }
.calendar-grid button[aria-pressed="true"] { background: var(--accent); color: var(--bg); }
.date-info { padding: 0 var(--panel-pad) 14px; }
.date-info p + p, .date-info details { margin-top: 6px; }
.date-info p:empty { display: none; }
#date-result { color: var(--accent); font-size: 13px; }
#date-result.error-text { color: #f0bcb1; }
#date-scope { white-space: pre-wrap; overflow-wrap: anywhere; }
#launch-status, #bulk-status { padding: 9px var(--panel-pad); color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
#bulk-status { border-bottom: 1px solid var(--border); }
#bulk-status:empty, #action-status:empty, #login-error:empty { padding: 0; margin: 0; border: 0; }

.scope-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 12px; }
.scope-bar > span { margin-right: auto; font-weight: 600; }
.scope-bar button, .pagination button { font-size: 12px; }
.metrics { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); margin-bottom: 20px; gap: 8px; }
.metric { min-width: 0; padding: 13px; text-align: left; background: var(--surface); border-radius: var(--radius); }
.metric-label, .metric-value, .metric-sub { display: block; }
.metric-value { margin-top: 5px; font-size: 32px; line-height: 1.15; font-weight: 600; letter-spacing: -.035em; font-variant-numeric: tabular-nums; }
.metric-sub { margin-top: 4px; color: var(--muted); font-size: 11px; font-weight: 400; }
.tag { display: inline-block; padding: 3px 7px; border-radius: 5px; color: #c6d2cc; background: #303a36; font-size: 11px; font-weight: 600; }
.tag.running { color: #b8d9ef; background: #283f4c; }
.tag.success { color: #b9dfc9; background: #2b4235; }
.tag.failed { color: #f0bcb1; background: #4b342f; }
.tag.manual { color: #efcf96; background: #463b27; }
.tag.queued { color: #c7d2db; background: #323d47; }
.current h2 small { margin-left: 5px; font-weight: 400; }
.current-grid { display: grid; grid-template-columns: 2fr 2fr 1fr 1.4fr; gap: 16px; padding: 18px var(--panel-pad); }
.current-grid > div { min-width: 0; overflow-wrap: anywhere; }
.current-grid small, .current-grid strong, .shop-code { display: block; }
.current-grid strong { margin-top: 4px; font-size: 16px; }
.current-grid .small, .shop-code { font-size: 12px; }
.shop-code { color: var(--muted); margin-top: 3px; }
.empty { padding: 32px var(--panel-pad); text-align: center; }
.empty p { margin-top: 5px; font-size: 12px; }
.empty.compact { text-align: left; padding-block: 16px; }
.banner { padding: 11px 14px; margin-bottom: 16px; border: 1px solid #74613f; border-radius: 8px; color: #efcf96; background: #352c20; overflow-wrap: anywhere; }

.task-heading { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; }
.task-total { color: var(--muted); font-size: 12px; white-space: nowrap; font-variant-numeric: tabular-nums; }
#resume-all { border-color: #74613f; color: #efcf96; background: #382f22; }
#resume-all:hover:not(:disabled) { background: #4b3e2a; }
summary { color: var(--muted); cursor: pointer; }
.filter-box summary { padding: 12px var(--panel-pad); }
.filters, .advanced-grid { display: grid; gap: 12px; align-items: end; }
.filters { padding: 0 var(--panel-pad) 16px; grid-template-columns: repeat(3, minmax(0, 1fr)) minmax(0, 1.4fr) auto; }
.filters label, #actions label, .login label { display: grid; gap: 4px; color: var(--muted); font-size: 12px; }
.filters input, .filters select { width: 100%; min-width: 0; }
.filters button { font-size: 12px; white-space: nowrap; }
.table-scroll { overflow-x: auto; border-radius: 0 0 var(--radius) var(--radius); }
table { width: 100%; min-width: 760px; border-collapse: collapse; text-align: left; font-variant-numeric: tabular-nums; }
th, td { padding: 10px 10px; font-size: 12px; }
th:first-child, td:first-child { padding-left: var(--panel-pad); }
th:last-child, td:last-child { padding-right: var(--panel-pad); text-align: right; }
th { color: var(--muted); background: var(--inset); font-weight: 550; }
td { border-top: 1px solid var(--border); vertical-align: middle; }
td strong { display: block; max-width: 26ch; overflow-wrap: anywhere; }
td small { display: block; margin-top: 3px; font-size: 11px; }
td button, .card-bottom button, .log-card button { font-size: 12px; background: transparent; white-space: nowrap; }
.step-cell span { display: block; max-width: clamp(100px, 13vw, 250px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.task-cards { display: none; }
.pagination { display: flex; justify-content: flex-end; align-items: center; gap: 12px; margin: -8px 0 20px; font-variant-numeric: tabular-nums; }
.command { display: flex; justify-content: space-between; gap: 12px 20px; padding: 12px var(--panel-pad); font-size: 12px; overflow-wrap: anywhere; }
.command + .command { border-top: 1px solid var(--border); }
.command > span { text-align: right; }
.command small { display: block; }
footer { display: flex; justify-content: space-between; gap: 12px; margin-top: 28px; color: var(--muted); font-size: 11px; }

dialog { width: min(720px, calc(100% - 32px)); max-height: 88dvh; padding: 0; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); }
dialog::backdrop { background: #080e0bc9; }
dialog .section-top { position: sticky; top: 0; z-index: 1; background: var(--surface); }
dialog .section-top h2 { min-width: 0; overflow-wrap: anywhere; }
dialog .section-top button { width: 44px; padding: 0; font-size: 23px; line-height: 1; }
#detail-body, #actions { padding: 16px var(--panel-pad); }
#detail-body dl { display: grid; grid-template-columns: minmax(76px, 100px) minmax(0, 1fr); gap: 7px 12px; margin-block: 14px 18px; font-size: 13px; }
dt { color: var(--muted); }
dd { margin: 0; overflow-wrap: anywhere; }
#detail-body h3 + p { margin-top: 5px; }
#detail-body pre { padding: 10px 12px; max-height: 220px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; background: var(--inset); border-radius: 8px; }
.attempt { padding: 10px 0; border-bottom: 1px solid var(--border); overflow-wrap: anywhere; }
.attempt p { margin-top: 3px; color: var(--muted); font-size: 12px; }
.detail-links { padding: 0 var(--panel-pad) 16px; }
.detail-links p { margin-top: 5px; }
#actions { border-top: 1px solid var(--border); background: var(--inset); }
textarea { display: block; width: 100%; min-height: 88px; margin-top: 5px; resize: vertical; }
.action-footer { display: flex; justify-content: space-between; align-items: center; gap: 8px 16px; margin-top: 12px; }
.action-footer button { flex-shrink: 0; }
#action-status { margin-top: 10px; color: var(--accent); font-size: 13px; overflow-wrap: anywhere; }

#bulk-status:is(.error-text, .command-error), #action-status:is(.error-text, .command-error) { color: #f0bcb1; }

.log-filters { grid-template-columns: repeat(2, minmax(0, 1fr)); padding-top: 16px; }
.log-advanced { grid-column: 1 / -1; border-top: 1px solid var(--border); padding-top: 10px; }
.log-advanced summary { min-height: 34px; padding-block: 5px; }
.advanced-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.advanced-grid .search-field { grid-column: span 2; }
.log-toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.log-toolbar > span { margin-right: auto; color: var(--muted); font-size: 12px; }
#log-hint { margin-bottom: 12px; }
.log-card { margin-bottom: 10px; padding: 16px var(--panel-pad); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.log-card-meta { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 4px 10px; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.log-preview { display: -webkit-box; -webkit-line-clamp: 6; -webkit-box-orient: vertical; overflow: hidden; white-space: pre-wrap; overflow-wrap: anywhere; margin: 8px 0 10px; }
.log-options { display: flex; flex-wrap: wrap; gap: 6px 18px; padding: 8px var(--panel-pad); }
.log-options label { display: flex; align-items: center; gap: 6px; min-height: 44px; }
.log-options input { min-height: 0; width: 18px; height: 18px; accent-color: var(--accent); }
.log-full { counter-reset: line; max-height: 60dvh; overflow: auto; padding: 0 var(--panel-pad) 18px; font: 13px/1.8 Consolas, "Microsoft YaHei", monospace; }
.log-line { white-space: pre; min-height: 1.8em; }
.log-full.wrap .log-line { white-space: pre-wrap; overflow-wrap: anywhere; }
.log-full.numbered .log-line { counter-increment: line; display: grid; grid-template-columns: 3ch 1fr; gap: 10px; }
.log-full.numbered.wrap .log-line { grid-template-columns: 3ch minmax(0, 1fr); }
.log-full.numbered .log-line::before { content: counter(line); text-align: right; color: var(--muted); }
#log-detail { width: min(1000px, calc(100% - 32px)); }
#log-view .pagination { margin-top: 16px; }

.login { min-height: 100dvh; display: grid; place-items: center; padding: 20px; background: radial-gradient(ellipse at 50% 0%, #21362b, transparent 68%); }
.login form { width: min(100%, 408px); padding: clamp(22px, 5vw, 38px); border: 1px solid var(--border); background: var(--surface); border-radius: var(--radius); }
.brand-icon { width: 42px; height: 42px; display: grid; place-items: center; margin-bottom: 20px; background: var(--accent); color: #17271f; border-radius: 9px; font-size: 23px; font-weight: 750; }
.login h1 { font-size: 30px; }
.login h1 + p { margin-top: 6px; }
.login label { margin: 22px 0 5px; }
.login input, .login button { width: 100%; }
.login button { margin-top: 12px; }
.login small { display: block; margin-top: 12px; }
#login-error { margin-top: 8px; color: #f0bcb1; font-size: 13px; overflow-wrap: anywhere; }

@media (max-width: 1100px) {
  :root { --rail: 176px; }
  .current-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .table-scroll { display: none; }
  .task-cards { display: block; }
  .task-card { padding: 14px var(--panel-pad); border-top: 1px solid var(--border); overflow-wrap: anywhere; }
  .card-head, .card-meta, .card-bottom { display: flex; justify-content: space-between; gap: 6px 10px; }
  .card-head { align-items: start; }
  .card-head > div { min-width: 0; }
  .card-head .tag { flex-shrink: 0; }
  .card-head small { display: block; }
  .card-step { margin: 8px 0 4px; }
  .card-meta { flex-wrap: wrap; color: var(--muted); font-size: 12px; }
  .card-bottom { align-items: center; margin-top: 6px; }
}

@media (max-width: 900px) {
  .metrics { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .filter-box .filters, .advanced-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 720px) {
  .date-panel > summary .small { display: block; margin: 4px 0 0; }
  .filters.date-fields { grid-template-columns: minmax(0, 1fr); }
  :root { --panel-pad: 15px; }
  aside { position: static; width: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 4px 12px; padding: 10px var(--gutter); border-right: 0; border-bottom: 1px solid var(--border); }
  .brand { padding: 0; margin: 0 auto 0 0; }
  .nav-label, .aside-foot { display: none; }
  .nav-links { order: 1; display: flex; width: 100%; gap: 16px; margin: 0; }
  .nav-links a { padding: 0; }
  aside nav { position: fixed; inset: auto 0 0; z-index: 2; grid-template-columns: repeat(3, minmax(0, 1fr)); padding: 6px var(--gutter) calc(6px + env(safe-area-inset-bottom)); background: var(--inset); border-top: 1px solid var(--border); }
  .nav { justify-content: center; gap: 5px; padding-inline: 4px; font-size: 12px; white-space: nowrap; }
  .nav i { margin-left: 0; }
  main { margin: 0; padding-top: 22px; padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
  header { align-items: flex-start; flex-wrap: wrap; margin-bottom: 18px; }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric:last-child { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr auto; align-items: center; }
  .metric:last-child .metric-value { grid-column: 2; grid-row: 1 / 3; margin: 0; }
  .tasks-panel .section-top { align-items: flex-start; flex-direction: column; }
  .filter-box .search-field, .advanced-grid .search-field { grid-column: 1 / -1; }
  .filters input, .filters select, #password, textarea { font-size: 16px; }
  .command { flex-wrap: wrap; }
  .command > span { text-align: left; }
  dialog, #log-detail { width: 100%; max-width: none; max-height: 92dvh; margin: auto 0 0; inset: auto 0 0; border-radius: 16px 16px 0 0; }
  #actions { padding-bottom: calc(16px + env(safe-area-inset-bottom)); }
  .action-footer { align-items: stretch; flex-direction: column; }
  .log-toolbar > span { flex-basis: 100%; }
}

@media (max-width: 380px) {
  .nav-icon { display: none; }
  .scope-bar > span { flex-basis: 100%; }
  .launch-panel .section-top { align-items: flex-start; flex-direction: column; }
}
