:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-alt: #f8fafb;
  --text: #17202a;
  --muted: #687480;
  --line: #dfe4e8;
  --line-strong: #cbd3d9;
  --blue: #2563a9;
  --blue-soft: #e8f1fa;
  --green: #147a55;
  --green-soft: #e4f4ed;
  --amber: #a15c08;
  --amber-soft: #fff1d6;
  --red: #b42333;
  --red-soft: #fdebed;
  --shadow: 0 12px 36px rgba(23, 32, 42, 0.14);
  font-family: Inter, "Noto Sans SC", "Microsoft YaHei", system-ui, sans-serif;
  font-size: 15px;
  letter-spacing: 0;
}

* { box-sizing: border-box; letter-spacing: 0; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); }
body { min-width: 320px; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled, input:disabled, select:disabled { cursor: not-allowed; opacity: 0.55; }
[hidden] { display: none !important; }

.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: #eef2f5;
}

.login-form {
  width: min(380px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow: var(--shadow);
  padding: 34px;
}

.login-mark, .brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 6px;
  color: #fff;
  background: #233443;
}

.login-mark { margin-bottom: 24px; }
.login-mark svg, .brand-mark svg { width: 22px; height: 22px; }
.login-form h1 { margin: 0; font-size: 1.55rem; line-height: 1.25; }
.login-status { color: var(--muted); margin: 7px 0 24px; }
.login-form label, .modal-body label { display: block; font-size: 0.82rem; font-weight: 650; color: #3f4b55; margin-bottom: 7px; }
.password-field, .search-field { position: relative; display: flex; align-items: center; }
.password-field svg, .search-field svg { position: absolute; left: 11px; width: 17px; height: 17px; color: var(--muted); pointer-events: none; }
.password-field input, .search-field input { width: 100%; padding: 10px 12px 10px 38px; border: 1px solid var(--line-strong); border-radius: 5px; background: #fff; outline: none; }
.password-field input:focus, .search-field input:focus, input:focus, select:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(37, 99, 169, 0.12); outline: none; }
.login-button { width: 100%; margin-top: 18px; justify-content: center; }
.form-error { min-height: 20px; color: var(--red); font-size: 0.85rem; margin: 12px 0 0; }

.topbar {
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-mark { width: 36px; height: 36px; }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 1rem; }
.brand small { margin-top: 2px; color: var(--muted); font-size: 0.75rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 45vw; }
.topbar-actions { display: flex; align-items: center; gap: 6px; }
.demo-badge { padding: 4px 8px; border-radius: 4px; font-size: 0.74rem; background: var(--amber-soft); color: var(--amber); font-weight: 650; }

.icon-button {
  width: 36px;
  height: 36px;
  display: inline-grid;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 5px;
  background: transparent;
  color: #4a5762;
}
.icon-button:hover { background: #edf1f4; border-color: var(--line); color: var(--text); }
.icon-button:focus-visible, .button:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.icon-button svg { width: 18px; height: 18px; }
.icon-button.small { width: 32px; height: 32px; }

main { padding-bottom: 48px; }
.system-strip {
  display: grid;
  grid-template-columns: repeat(5, minmax(140px, 1fr));
  max-width: 1440px;
  margin: 0 auto;
  padding: 22px 28px;
  gap: 0;
}
.metric { display: flex; align-items: center; gap: 11px; min-height: 48px; padding: 0 22px; border-right: 1px solid var(--line); }
.metric:first-child { padding-left: 0; }
.metric:last-child { border-right: 0; }
.metric-icon { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 5px; flex: 0 0 auto; }
.metric-icon svg { width: 18px; height: 18px; }
.metric-icon.green { background: var(--green-soft); color: var(--green); }
.metric-icon.blue { background: var(--blue-soft); color: var(--blue); }
.metric-icon.amber { background: var(--amber-soft); color: var(--amber); }
.metric-icon.neutral { background: #e9edf0; color: #4f5b65; }
.metric strong, .metric small { display: block; white-space: nowrap; }
.metric strong { font-size: 1.02rem; font-variant-numeric: tabular-nums; }
.metric small { color: var(--muted); font-size: 0.75rem; margin-top: 3px; }

.service-workspace { max-width: 1440px; margin: 0 auto; padding: 0 28px; }
.workspace-toolbar { min-height: 54px; display: flex; align-items: center; gap: 14px; border-bottom: 1px solid var(--line); }
.segmented-control { display: inline-flex; align-items: center; background: #e7ebee; padding: 3px; border-radius: 5px; }
.segmented-control button { border: 0; background: transparent; border-radius: 4px; padding: 6px 12px; font-size: 0.8rem; color: #56636d; }
.segmented-control button.active { background: #fff; color: var(--text); box-shadow: 0 1px 3px rgba(23, 32, 42, 0.12); font-weight: 650; }
.search-field { width: 220px; margin-left: auto; }
.search-field input { padding-top: 7px; padding-bottom: 7px; font-size: 0.82rem; }
.last-updated { color: var(--muted); font-size: 0.75rem; min-width: 100px; text-align: right; }

.service-table { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.service-head, .service-row {
  display: grid;
  grid-template-columns: minmax(210px, 1.45fr) minmax(105px, 0.75fr) minmax(120px, 0.8fr) 110px minmax(145px, 0.9fr) 190px;
  align-items: center;
  column-gap: 16px;
}
.service-head { min-height: 42px; padding: 0 18px; background: var(--surface-alt); border-bottom: 1px solid var(--line); color: var(--muted); font-size: 0.72rem; font-weight: 650; }
.service-row { min-height: 72px; padding: 10px 18px; border-bottom: 1px solid var(--line); transition: background 120ms ease; }
.service-row:last-child { border-bottom: 0; }
.service-row:hover { background: #fbfcfd; }
.service-identity { display: flex; align-items: center; gap: 11px; min-width: 0; }
.service-symbol { width: 34px; height: 34px; border-radius: 5px; background: #e9edf0; color: #3e4c57; display: grid; place-items: center; flex: 0 0 auto; }
.service-symbol svg { width: 17px; height: 17px; }
.service-name, .service-unit { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.service-name { font-weight: 680; font-size: 0.9rem; }
.service-unit { color: var(--muted); font-size: 0.72rem; margin-top: 3px; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }
.group-label { display: inline-block; color: #5d6871; font-size: 0.68rem; margin-left: 6px; font-weight: 500; }
.status-cell { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
.status-badge { display: inline-flex; align-items: center; gap: 6px; border-radius: 4px; padding: 4px 7px; font-size: 0.73rem; font-weight: 680; }
.status-badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status-badge.running { color: var(--green); background: var(--green-soft); }
.status-badge.inactive { color: #68737c; background: #edf0f2; }
.status-badge.failed { color: var(--red); background: var(--red-soft); }
.substate { color: var(--muted); font-size: 0.68rem; }
.process-value strong, .process-value small { display: block; }
.process-value strong { font-size: 0.8rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.process-value small { font-size: 0.69rem; color: var(--muted); margin-top: 3px; }

.toggle { position: relative; display: inline-flex; align-items: center; gap: 7px; font-size: 0.72rem; color: var(--muted); }
.toggle input { position: absolute; opacity: 0; pointer-events: none; }
.toggle-track { width: 34px; height: 19px; border-radius: 10px; background: #b7c0c7; position: relative; transition: background 120ms ease; }
.toggle-track::after { content: ""; position: absolute; width: 15px; height: 15px; left: 2px; top: 2px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: transform 120ms ease; }
.toggle input:checked + .toggle-track { background: var(--green); }
.toggle input:checked + .toggle-track::after { transform: translateX(15px); }
.toggle input:focus-visible + .toggle-track { outline: 2px solid var(--blue); outline-offset: 2px; }

.schedule-button { display: inline-flex; align-items: center; gap: 7px; min-height: 30px; border: 1px solid var(--line); background: #fff; border-radius: 5px; padding: 4px 8px; font-size: 0.74rem; color: #47545e; }
.schedule-button:hover { border-color: var(--blue); color: var(--blue); }
.schedule-button svg { width: 15px; height: 15px; }
.schedule-button.configured { color: var(--amber); background: #fffaf0; border-color: #efd6a4; }
.action-group { display: flex; justify-content: flex-end; gap: 5px; }
.action-button { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 5px; border: 1px solid var(--line); background: #fff; color: #4c5963; }
.action-button:hover { background: #edf3f8; color: var(--blue); border-color: #bfd0df; }
.action-button.stop:hover { color: var(--red); background: var(--red-soft); border-color: #f1bec4; }
.action-button svg { width: 15px; height: 15px; }
.align-right { text-align: right; }
.empty-state { min-height: 180px; display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--muted); gap: 10px; }
.empty-state svg { width: 28px; height: 28px; }

.button { min-height: 36px; display: inline-flex; align-items: center; gap: 7px; border-radius: 5px; padding: 7px 14px; border: 1px solid transparent; font-weight: 650; font-size: 0.82rem; }
.button svg { width: 16px; height: 16px; }
.button.primary { color: #fff; background: var(--blue); border-color: var(--blue); }
.button.primary:hover { background: #1e548e; }
.button.secondary { background: #fff; border-color: var(--line-strong); color: #45515b; }
.button.secondary:hover { background: #eef2f4; }
.button.danger { color: #fff; background: var(--red); border-color: var(--red); }
.button.danger-ghost { color: var(--red); background: #fff; border-color: #efc0c5; }

.log-drawer { position: fixed; top: 0; right: 0; width: min(720px, 92vw); height: 100vh; background: #111820; color: #dbe5ec; z-index: 60; transform: translateX(101%); transition: transform 180ms ease; display: flex; flex-direction: column; box-shadow: -16px 0 40px rgba(10, 15, 20, 0.24); }
.log-drawer.open { transform: translateX(0); }
.drawer-backdrop { position: fixed; inset: 0; background: rgba(18, 25, 31, 0.38); z-index: 50; }
.drawer-header { height: 72px; padding: 0 18px 0 22px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid #2a3640; }
.drawer-header h2 { margin: 2px 0 0; font-size: 1rem; }
.drawer-header .icon-button { color: #b8c4cd; }
.eyebrow { color: var(--muted); font-size: 0.68rem; text-transform: uppercase; }
.drawer-header .eyebrow { color: #81909c; }
.log-toolbar { min-height: 48px; display: flex; align-items: center; gap: 14px; padding: 7px 20px; border-bottom: 1px solid #2a3640; background: #151e26; }
.log-toolbar select { height: 31px; border: 1px solid #3c4954; color: #dbe5ec; background: #1a252e; border-radius: 4px; padding: 0 8px; }
.checkbox-label { display: inline-flex; align-items: center; gap: 6px; color: #aab7c0; font-size: 0.76rem; }
.log-toolbar .icon-button { margin-left: auto; color: #b8c4cd; }
.log-output { flex: 1; margin: 0; padding: 18px 20px 32px; overflow: auto; white-space: pre-wrap; word-break: break-word; font: 12px/1.55 ui-monospace, SFMono-Regular, Consolas, monospace; color: #cbd6de; background: #111820; }

.modal { width: min(470px, calc(100vw - 28px)); border: 1px solid var(--line); border-radius: 6px; padding: 0; color: var(--text); box-shadow: var(--shadow); }
.modal::backdrop { background: rgba(18, 25, 31, 0.42); }
.modal-header { min-height: 64px; display: flex; align-items: center; justify-content: space-between; padding: 12px 15px 12px 20px; border-bottom: 1px solid var(--line); }
.modal-header h2 { margin: 2px 0 0; font-size: 1rem; }
.modal-body { padding: 20px; }
.modal-body input, .modal-body select { width: 100%; min-height: 38px; border: 1px solid var(--line-strong); border-radius: 5px; padding: 7px 10px; background: #fff; }
.form-grid { display: grid; grid-template-columns: 120px 1fr; align-items: center; gap: 14px; }
.form-grid label { margin: 0; }
.field-note { color: var(--muted); font-size: 0.75rem; margin: 9px 0 0; min-height: 18px; }
.modal-footer { min-height: 62px; display: flex; justify-content: flex-end; align-items: center; gap: 8px; padding: 12px 20px; background: var(--surface-alt); border-top: 1px solid var(--line); }
.modal-footer.split { justify-content: space-between; }
.modal-footer.split > div { display: flex; gap: 8px; }
.modal-footer.centered { justify-content: center; background: transparent; border: 0; padding-bottom: 22px; }
.confirm-modal { text-align: center; width: min(400px, calc(100vw - 28px)); }
.confirm-modal form { padding-top: 25px; }
.confirm-modal h2 { font-size: 1.05rem; margin: 12px 20px 7px; }
.confirm-modal p { margin: 0 28px 16px; color: var(--muted); font-size: 0.84rem; line-height: 1.5; }
.confirm-icon { width: 42px; height: 42px; display: grid; place-items: center; margin: 0 auto; border-radius: 50%; background: var(--amber-soft); color: var(--amber); }
.confirm-icon svg { width: 20px; height: 20px; }

.toast-region { position: fixed; right: 20px; bottom: 20px; z-index: 100; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast { min-width: 240px; max-width: 380px; padding: 11px 13px; background: #202b34; color: #fff; border-radius: 5px; box-shadow: var(--shadow); font-size: 0.8rem; animation: toast-in 160ms ease; }
.toast.error { background: #8f1f2d; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }
.spin svg, svg.spin { animation: spin 850ms linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 1050px) {
  .system-strip { grid-template-columns: repeat(3, 1fr); row-gap: 16px; }
  .metric:nth-child(3) { border-right: 0; }
  .metric:nth-child(4) { padding-left: 0; }
  .service-head { display: none; }
  .service-row { grid-template-columns: minmax(210px, 1.5fr) minmax(105px, .7fr) minmax(125px, .8fr) 100px 170px; }
  .service-row .process-value { display: none; }
}

@media (max-width: 760px) {
  .topbar { padding: 0 14px; }
  .system-strip { padding: 16px 14px; grid-template-columns: repeat(2, 1fr); }
  .metric { padding: 0 12px; }
  .metric:nth-child(2), .metric:nth-child(4) { border-right: 0; }
  .metric:nth-child(3), .metric:nth-child(5) { padding-left: 0; }
  .service-workspace { padding: 0; }
  .workspace-toolbar { padding: 9px 12px; flex-wrap: wrap; }
  .segmented-control { order: 1; }
  .search-field { order: 2; margin-left: auto; width: min(190px, 46vw); }
  .last-updated { order: 3; width: 100%; text-align: left; min-width: 0; }
  .service-table { border-left: 0; border-right: 0; border-radius: 0; }
  .service-row { grid-template-columns: 1fr auto; grid-template-areas: "identity status" "schedule toggle" "actions actions"; row-gap: 11px; padding: 14px; }
  .service-identity { grid-area: identity; }
  .status-cell { grid-area: status; align-items: flex-end; }
  .service-row .toggle { grid-area: toggle; justify-self: end; }
  .service-row .schedule-button { grid-area: schedule; justify-self: start; }
  .action-group { grid-area: actions; justify-content: flex-start; border-top: 1px solid var(--line); padding-top: 10px; }
  .action-button { flex: 1; max-width: 52px; }
  .group-label { display: none; }
  .form-grid { grid-template-columns: 1fr; gap: 7px; }
  .form-grid input, .form-grid select { margin-bottom: 8px; }
  .log-drawer { width: 100vw; }
}

@media (max-width: 440px) {
  .brand small { max-width: 150px; }
  .demo-badge { display: none; }
  .system-strip { grid-template-columns: 1fr 1fr; }
  .metric { min-width: 0; padding-right: 6px; }
  .metric-icon { width: 30px; height: 30px; }
  .metric strong { font-size: 0.9rem; }
  .metric.wide { grid-column: auto; }
  .segmented-control { width: 100%; }
  .segmented-control button { flex: 1; }
  .search-field { width: 100%; margin: 0; }
  .service-name { max-width: 48vw; }
}
