:root {
  color-scheme: light;
  --bg: #f4f7fb;
  --surface: #ffffff;
  --surface-muted: #fbfcfe;
  --line: #e2e7ef;
  --input-line: #cbd7e5;
  --text: #1b1b1b;
  --muted: #6f7f90;
  --primary: #2c64ae;
  --primary-deep: #245493;
  --accent: #d92b2b;
  --green: #2f765f;
  --amber: #a66a16;
  --red: #af2525;
  --shadow: 0 10px 30px rgba(32, 69, 119, .07);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  min-width: 320px;
  color: var(--text);
  background: var(--bg);
  font: 14px/1.6 "Microsoft YaHei", "Noto Sans SC", Arial, sans-serif;
}

button, input { font: inherit; }
button { cursor: pointer; }

.shell {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
  padding: 0 0 70px;
}

.shell:has(#login-panel:not([hidden])) {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding-bottom: 0;
}

.shell:has(#login-panel:not([hidden])) .topbar { display: none; }

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 30px;
  padding: 44px 0 28px;
  border-bottom: 1px solid var(--line);
}

.kicker, .eyebrow {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 0 0 10px;
  color: var(--green);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0;
}

.signal {
  display: inline-block;
  width: 27px;
  height: 2px;
  margin: 0;
  border-radius: 0;
  background: currentColor;
  box-shadow: none;
}

h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 7px; font-size: 30px; line-height: 1.25; letter-spacing: 0; }
h2 { margin-bottom: 0; font-size: 22px; line-height: 1.35; letter-spacing: 0; }

.subtitle, .muted, .footnote { color: var(--muted); }
.subtitle { margin-bottom: 0; }

.topbar-actions, .token-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar-actions { flex-shrink: 0; }

.button {
  min-height: 40px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: 0;
  font-weight: 700;
  transition: background-color .15s ease, border-color .15s ease, color .15s ease;
}

.button-primary, .button-dark {
  border-color: var(--primary);
  color: #fff;
  background: var(--primary);
}

.button-primary:hover, .button-dark:hover { border-color: var(--primary-deep); background: var(--primary-deep); }
.button-outline { border-color: var(--primary); color: var(--primary); background: transparent; }
.button-outline:hover { background: #edf4fc; }
.button:disabled { opacity: .6; cursor: wait; }
.button:focus-visible, input:focus-visible { outline: 0; box-shadow: 0 0 0 3px rgba(43, 98, 173, .14); }

.login-panel {
  width: min(100%, 450px);
  margin: 0 auto;
  padding: 42px;
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: 0 18px 48px rgba(32, 69, 119, .14);
}

.login-panel h2 { margin-bottom: 8px; font-size: 29px; }
.login-panel > div > .muted { margin-bottom: 0; }
.token-form { display: grid; gap: 9px; margin-top: 26px; }
.token-form label { color: #536374; font-size: 13px; font-weight: 700; }
.token-row { align-items: stretch; }

.token-form input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--input-line);
  border-radius: 0;
  padding: 0 12px;
  color: var(--text);
  background: var(--surface);
}

.token-form input:focus { border-color: var(--primary); outline: 0; }
.error { min-height: 21px; margin: 0; color: var(--red); font-size: 13px; }

.alert-strip {
  margin: 24px 0;
  padding: 12px 14px;
  border-left: 3px solid var(--amber);
  color: var(--amber);
  background: #fff8e9;
}

.admin-tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  border-bottom: 1px solid var(--line);
}

.admin-tabs button {
  flex: 0 0 auto;
  border: 0;
  border-bottom: 3px solid transparent;
  padding: 14px 18px;
  color: #667789;
  background: transparent;
  font-weight: 700;
}

.admin-tabs button:hover, .admin-tabs button.is-active {
  border-bottom-color: var(--accent);
  color: var(--primary);
  background: var(--surface);
}

.admin-tabs span {
  min-width: 18px;
  margin-left: 4px;
  padding: 1px 6px;
  border-radius: 12px;
  color: #fff;
  background: var(--accent);
  font-size: 11px;
}
.admin-tabs span:empty { display: none; }

.admin-panel { display: none; padding: 30px 0 0; }
.admin-panel.is-active { display: block; }
.admin-panel > .summary-grid { margin-top: 0; }
.admin-panel-heading { display: flex; justify-content: space-between; align-items: end; gap: 20px; margin-bottom: 22px; }
.admin-panel-heading h2 { margin: 0; font-size: 29px; }
.admin-panel-heading p { margin: 7px 0 0; color: var(--muted); }

.log-workspace {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  min-height: 620px;
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.log-list-column { min-width: 0; border-right: 1px solid var(--line); background: var(--surface-muted); }
.log-filters { display: flex; flex-wrap: wrap; gap: 7px; padding: 14px 15px; border-bottom: 1px solid var(--line); }
.filter-button { border: 1px solid var(--input-line); padding: 7px 11px; color: #667789; background: var(--surface); font: inherit; font-size: 12px; }
.filter-button:hover, .filter-button.is-active { border-color: var(--primary); color: var(--primary); background: #edf4fc; }
.log-list { max-height: 560px; overflow-y: auto; }
.log-list button { display: grid; width: 100%; gap: 4px; border: 0; border-left: 3px solid transparent; padding: 15px 17px; color: var(--text); background: transparent; text-align: left; }
.log-list button:hover, .log-list button.is-active { border-left-color: var(--accent); background: #edf4fc; }
.log-list button strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.log-list button span, .log-list button time { color: #718295; font-size: 12px; }
.log-list .empty { padding: 28px 18px; }
.log-detail { display: grid; align-content: start; gap: 17px; min-width: 0; margin: 0; padding: 30px 34px; }
.log-detail-heading { display: flex; justify-content: space-between; align-items: start; gap: 18px; padding-bottom: 18px; border-bottom: 1px solid var(--line); }
.log-detail-heading h3 { margin: 4px 0 0; font-size: 23px; }
.log-detail-heading time { color: #8492a1; font-size: 12px; white-space: nowrap; }
.log-detail label { display: grid; gap: 7px; color: #536374; font-size: 13px; font-weight: 700; }
.log-detail input, .log-detail textarea, .log-detail select { width: 100%; border: 1px solid var(--input-line); padding: 10px 12px; color: var(--text); background: var(--surface); font: inherit; resize: vertical; }
.log-detail textarea[readonly] { background: #f8fafc; color: #4f6071; }
.log-detail input:focus, .log-detail textarea:focus, .log-detail select:focus { border-color: var(--primary); outline: 0; box-shadow: 0 0 0 3px rgba(43, 98, 173, .12); }
.log-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; margin: 0; }
.log-fields div { min-width: 0; padding: 10px 0; border-bottom: 1px solid #e6ebf1; }
.log-fields dt { color: #8492a1; font-size: 12px; }
.log-fields dd { overflow-wrap: anywhere; margin: 4px 0 0; font-size: 14px; }
.log-fields .wide { grid-column: 1 / -1; }
.admin-actions { display: flex; flex-wrap: wrap; gap: 10px; padding-top: 18px; border-top: 1px solid var(--line); }

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin: 30px 0 14px;
}

.summary, .panel {
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.summary {
  min-height: 126px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 18px;
}

.summary span, .summary small { color: var(--muted); }
.summary strong { font-size: 28px; line-height: 1.2; letter-spacing: 0; }
.summary strong.ok { color: var(--green); }
.summary strong.warn { color: var(--amber); }
.summary strong.bad { color: var(--red); }

.panel { margin-top: 14px; padding: 26px 28px; }
.panel-heading { display: flex; justify-content: space-between; align-items: start; gap: 20px; margin-bottom: 20px; }
.panel-heading .eyebrow { margin-bottom: 7px; color: #8492a1; }

.badge {
  padding: 3px 9px;
  border: 1px solid #b8c8be;
  border-radius: 12px;
  color: var(--green);
  background: #eff7f2;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.table-wrap { overflow-x: auto; }
table { width: 100%; min-width: 720px; border-collapse: collapse; }
th, td { padding: 13px 10px; border-top: 1px solid var(--line); text-align: left; white-space: nowrap; }
th { color: #718295; font-size: 11px; font-weight: 700; letter-spacing: 0; text-transform: uppercase; }
tbody tr:hover { background: #f8fbff; }
td strong { display: block; }
td small { display: block; color: var(--muted); font-size: 12px; }

.state { display: inline-flex; align-items: center; gap: 6px; }
.state::before { width: 7px; height: 7px; border-radius: 50%; background: var(--red); content: ""; }
.state.online::before { background: var(--green); }
.state.warn::before { background: var(--amber); }

.lower-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.resource-list { display: grid; gap: 0; }
.resource { display: flex; justify-content: space-between; gap: 16px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.resource:first-child { padding-top: 0; }
.resource:last-child { border-bottom: 0; padding-bottom: 0; }
.resource span { color: var(--muted); }
.resource strong { color: #33475c; text-align: right; font-variant-numeric: tabular-nums; }

.empty { color: var(--muted); text-align: center; }
.footnote { margin: 24px 0 0; font-size: 12px; }

@media (max-width: 850px) {
  .shell { width: min(100% - 28px, 680px); }
  .topbar { align-items: start; flex-direction: column; }
  .topbar-actions { justify-content: flex-start; flex-wrap: wrap; width: 100%; }
  .topbar-actions .muted { flex-basis: 100%; }
  .summary-grid { grid-template-columns: repeat(2, 1fr); }
  .lower-grid { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  .admin-panel-heading { align-items: start; flex-direction: column; }
  .log-workspace { grid-template-columns: 1fr; }
  .log-list-column { border-right: 0; border-bottom: 1px solid var(--line); }
  .log-list { max-height: 280px; }
  .log-detail { padding: 25px 20px; }
  .log-fields { grid-template-columns: 1fr; }
  .log-fields .wide { grid-column: auto; }
}

@media (max-width: 520px) {
  .shell:has(#login-panel:not([hidden])) { display: block; padding-top: 22px; }
  .login-panel { padding: 28px 22px; }
  .login-panel h2 { font-size: 25px; }
  .topbar { padding-top: 28px; }
  .panel { padding: 22px 18px; }
}

@media (max-width: 460px) {
  .summary-grid { grid-template-columns: 1fr; }
  .summary { min-height: 100px; }
  .token-row { align-items: stretch; }
  .token-row .button { flex: 0 0 auto; padding: 0 13px; }
}

.icon-button { width: 40px; height: 40px; padding: 0; display: inline-flex; align-items: center; justify-content: center; flex: 0 0 40px; }
.icon-button svg { width: 18px; height: 18px; }
.activity-summary { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 20px; padding: 20px 0; border-bottom: 1px solid var(--line); }
.activity-summary div { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.activity-summary span { color: var(--muted); }
.activity-summary strong { font-size: 22px; color: var(--green); }
.activity-heading { display: flex; justify-content: space-between; align-items: center; gap: 20px; margin-bottom: 20px; }
.activity-heading h2 { font-size: 22px; }
.activity-toolbar { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; margin-bottom: 18px; }
.activity-toolbar label { display: grid; gap: 5px; min-width: 130px; flex: 1 1 130px; color: var(--muted); font-size: 12px; }
.activity-toolbar label:first-child { flex: 2 1 220px; }
.activity-toolbar input, .activity-toolbar select { width: 100%; min-width: 0; height: 40px; padding: 0 10px; border: 1px solid var(--input-line); color: var(--text); background: var(--surface); font: inherit; font-size: 14px; border-radius: 0; }
.activity-toolbar input:focus-visible, .activity-toolbar select:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.activity-table { background: var(--surface); border: 1px solid var(--line); }
.activity-table table { min-width: 960px; }
.activity-table td { max-width: 250px; overflow: hidden; text-overflow: ellipsis; }
.activity-table td small { max-width: 230px; overflow: hidden; text-overflow: ellipsis; }
.activity-table .table-actions { display: flex; gap: 6px; }
.activity-table .icon-button { width: 32px; height: 32px; min-height: 32px; flex-basis: 32px; border-color: var(--line); }
.activity-pagination { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 16px; }
.activity-pagination > div { display: flex; gap: 8px; align-items: center; }
.activity-error { min-height: 22px; margin-bottom: 10px; color: var(--red); }
.activity-dialog { width: min(800px, calc(100% - 32px)); max-height: calc(100dvh - 40px); margin: auto; padding: 24px; border: 1px solid var(--line); color: var(--text); background: var(--surface); border-radius: 4px; overflow-y: auto; }
.activity-dialog::backdrop { background: rgba(20, 25, 30, .4); }
.detail-heading { display: flex; align-items: center; justify-content: space-between; gap: 15px; border-bottom: 1px solid var(--line); padding-bottom: 18px; margin-bottom: 20px; }
.detail-heading h2 { font-size: 22px; overflow-wrap: anywhere; }
.detail-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 24px; margin: 0 0 22px; }
.detail-fields dt { color: var(--muted); font-size: 12px; }
.detail-fields dd { margin: 5px 0 0; overflow-wrap: anywhere; }
.detail-roster { margin-top: 16px; }
.detail-roster table { min-width: 450px; }
.detail-links { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 20px; }
.activity-pill { display: inline-block; padding: 3px 8px; border: 1px solid var(--line); border-radius: 3px; font-size: 12px; color: var(--green); background: #f1f7f3; }
.activity-pill.issued, .activity-pill.preparing, .activity-pill.starting, .activity-pill.unknown { color: var(--amber); background: #fff8e9; }
.activity-pill.offline { color: var(--red); background: #fff3f3; }
@media (max-width: 760px) {
  .activity-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
  .activity-heading { align-items: start; flex-direction: column; gap: 8px; }
  .activity-pagination { flex-wrap: wrap; }
  .detail-fields { grid-template-columns: minmax(0, 1fr); }
  .activity-dialog { padding: 20px; }
}
