:root {
  color-scheme: light;
  --bg: #f5f7fa;
  --panel: #ffffff;
  --line: #d9e0e8;
  --line-soft: #e8edf3;
  --text: #182230;
  --muted: #667085;
  --primary: #1769e0;
  --primary-hover: #1158c2;
  --primary-soft: #e8f1ff;
  --success: #12a150;
  --warning: #e99216;
  --danger: #d92d20;
  --danger-soft: #fff1f0;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  letter-spacing: 0;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; background: var(--bg); color: var(--text); }
button, input { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible { outline: 2px solid #84adff; outline-offset: 2px; }
[hidden] { display: none !important; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, .98);
}
.brand, .account, .target-title, .page-head, .job-title { display: flex; align-items: center; }
.brand { gap: 10px; font-size: 18px; }
.brand-mark, .app-tile {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  border-radius: 7px;
  color: #fff;
  background: var(--primary);
  font-weight: 750;
}
.domain { padding-left: 10px; border-left: 1px solid var(--line); color: var(--muted); font-size: 13px; font-weight: 450; }
.account { gap: 10px; color: #344054; font-size: 13px; }
.avatar { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: #d5dae2; font-weight: 650; }
.text-button { border: 0; padding: 4px; background: transparent; color: var(--muted); }
.text-button:hover { color: var(--danger); }

.shell { min-height: calc(100vh - 52px); }
.sidebar {
  position: fixed;
  left: 0;
  top: 52px;
  bottom: 0;
  z-index: 20;
  width: 188px;
  padding: 12px 10px;
  border-right: 1px solid var(--line);
  background: var(--panel);
}
.nav-item {
  width: 100%;
  min-height: 40px;
  margin-bottom: 4px;
  border: 0;
  border-radius: 6px;
  padding: 0 14px;
  text-align: left;
  background: transparent;
  color: #344054;
  font-weight: 600;
}
.nav-item:hover { background: #f2f5f9; }
.nav-item.active { background: var(--primary-soft); color: var(--primary); }

.workspace { margin-left: 188px; padding: 20px 18px 40px; transition: margin-right .18s ease; }
body.drawer-open .workspace { margin-right: 390px; }
.page-head { min-height: 62px; justify-content: space-between; gap: 16px; }
.page-head h1 { margin: 0 0 6px; font-size: 22px; line-height: 1.2; font-weight: 700; }
.page-head p { margin: 0; color: var(--muted); font-size: 13px; }
.button {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 13px;
  background: var(--panel);
  color: #344054;
  font-weight: 600;
}
.button:hover { border-color: #aab5c3; background: #f8fafc; }
.button.primary { border-color: var(--primary); background: var(--primary); color: #fff; }
.button.primary:hover { border-color: var(--primary-hover); background: var(--primary-hover); }
.button:disabled { cursor: not-allowed; opacity: .55; }
.button.full { width: 100%; min-height: 42px; }

.infra-strip {
  min-height: 64px;
  display: flex;
  align-items: stretch;
  margin: 8px 0 14px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel);
  overflow: hidden;
}
.infra-item { min-width: 145px; flex: 1 1 0; display: flex; align-items: center; gap: 9px; padding: 10px 14px; border-right: 1px solid var(--line-soft); }
.infra-item:last-child { border-right: 0; }
.infra-copy { min-width: 0; }
.infra-copy strong { display: block; margin-bottom: 3px; font-size: 13px; white-space: nowrap; }
.infra-copy span { display: block; color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.infra-symbol { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 6px; background: #edf2f7; color: #344054; font-size: 11px; font-weight: 750; }
.status-dot { display: inline-block; width: 8px; height: 8px; margin-right: 7px; border-radius: 50%; background: #98a2b3; }
.status-dot.healthy, .status-dot.success { background: var(--success); }
.status-dot.degraded { background: var(--warning); }
.status-dot.unhealthy, .status-dot.missing, .status-dot.failed { background: var(--danger); }

.table-wrap { border: 1px solid var(--line); border-radius: 7px; background: var(--panel); overflow: auto; }
.service-table { width: 100%; min-width: 760px; border-collapse: collapse; table-layout: fixed; }
.service-table th { height: 42px; padding: 0 12px; background: #f1f4f8; color: #344054; text-align: left; font-size: 12px; font-weight: 700; }
.service-table td { height: 46px; padding: 8px 12px; border-top: 1px solid var(--line-soft); vertical-align: middle; }
.service-table th:nth-child(1) { width: 15%; }
.service-table th:nth-child(2) { width: 15%; }
.service-table th:nth-child(3) { width: 14%; }
.service-table th:nth-child(4) { width: 16%; }
.service-table th:nth-child(5) { width: 17%; }
.service-table th:nth-child(6) { width: 15%; }
.service-table th:nth-child(7) { width: 88px; }
.mobile-group { display: none; }
.app-name { display: flex; align-items: center; gap: 9px; font-size: 15px; }
.app-initial { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 6px; color: #fff; background: #326ee8; font-size: 12px; }
.app-initial.ai-ppt { background: #7a55d9; }
.app-cell { vertical-align: middle !important; background: #fbfcfe; border-right: 1px solid var(--line-soft); text-align: center; }
.app-cell .app-name { justify-content: center; }
.env-cell { background: #fbfcfe; border-right: 1px solid var(--line-soft); text-align: center; }
.environment-name, .environment-health { display: flex; align-items: center; gap: 6px; }
.environment-name, .environment-health { justify-content: center; }
.environment-name { margin-bottom: 7px; }
.environment-name strong { font-size: 14px; }
.environment-name span, .environment-health { color: var(--muted); font-size: 11px; }
.environment-health .status-dot { width: 6px; height: 6px; margin-right: 0; }
.service-row.env-start > td:not(.app-cell) { border-top-color: var(--line); }
.service-row.app-start > td { border-top-color: var(--line); }
.service-name { padding-left: 12px; font-weight: 600; }
.service-label { display: block; }
.version { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; color: #475467; }
.version-trigger { max-width: 100%; display: inline-flex; align-items: center; gap: 6px; border: 0; border-radius: 5px; padding: 3px 5px; margin: -3px -5px; background: transparent; color: inherit; text-align: left; }
.version-trigger:hover, .version-trigger:focus-visible, .version-trigger[aria-expanded="true"] { background: var(--primary-soft); }
.version-digest { color: #98a2b3; font: 10px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.version-info { display: inline-grid; place-items: center; width: 15px; height: 15px; border: 1px solid #b8c2cf; border-radius: 50%; color: #667085; font: 700 10px/1 ui-sans-serif, sans-serif; }
.image-popover { position: fixed; z-index: 90; width: min(390px, calc(100vw - 24px)); padding: 13px 14px; border: 1px solid #cfd7e2; border-radius: 8px; background: #fff; box-shadow: 0 12px 30px rgba(16, 24, 40, .18); }
.image-popover > strong { display: block; margin-bottom: 9px; font-size: 13px; }
.image-detail-row { display: grid; grid-template-columns: 82px minmax(0, 1fr); gap: 8px; padding: 4px 0; }
.image-detail-row small { color: var(--muted); font-size: 11px; }
.image-detail-row code { color: #344054; font: 11px/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; overflow-wrap: anywhere; }
.state-detail { color: var(--muted); font-size: 12px; }
.deploy-trigger { min-height: 32px; padding: 6px 12px; border: 1px solid var(--primary); border-radius: 6px; background: var(--primary); color: #fff; font-size: 13px; }
.deploy-trigger:hover { background: var(--primary-hover); }
.empty { padding: 30px !important; color: var(--muted); text-align: center; }

.drawer {
  position: fixed;
  z-index: 40;
  top: 52px;
  right: 0;
  bottom: 0;
  width: 390px;
  border-left: 1px solid var(--line);
  background: var(--panel);
  transform: translateX(100%);
  transition: transform .18s ease;
  overflow-y: auto;
}
body.drawer-open .drawer { transform: translateX(0); }
.drawer-head { height: 64px; display: flex; align-items: center; justify-content: space-between; padding: 0 18px; border-bottom: 1px solid var(--line); }
.drawer-head h2 { margin: 0; font-size: 17px; }
.close-button { width: 34px; height: 34px; border: 0; background: transparent; color: var(--muted); font-size: 24px; }
#deployForm { display: grid; gap: 15px; padding: 18px; }
.target-title { gap: 11px; padding-bottom: 2px; }
.target-title strong { font-size: 16px; }
.target-title p { margin: 4px 0 0; color: var(--muted); }
.production-warning { display: grid; gap: 4px; padding: 12px; border: 1px solid #f5c1bd; border-radius: 7px; background: var(--danger-soft); color: #7a271a; }
.production-warning strong { color: var(--danger); }
.production-warning span { font-size: 13px; line-height: 1.5; }
#deployForm label { display: grid; gap: 7px; color: #344054; font-size: 13px; font-weight: 600; }
#deployForm input { width: 100%; min-height: 42px; border: 1px solid #cfd7e2; border-radius: 6px; padding: 9px 11px; color: var(--text); background: #fff; }
#deployForm input:disabled { background: #f2f4f7; color: #667085; }
#deployForm small { color: var(--muted); font-weight: 450; line-height: 1.45; }
.required { color: var(--danger); }
.job-panel { margin: 4px 18px 24px; padding-top: 16px; border-top: 1px solid var(--line); }
.job-title { justify-content: space-between; }
.job-title h3 { margin: 0 0 12px; font-size: 14px; }
#jobStatus { color: var(--muted); font-size: 12px; }
#jobOutput { min-height: 150px; max-height: 300px; margin: 0; padding: 13px; border-radius: 6px; overflow: auto; background: #1f2937; color: #dce6f2; font: 12px/1.65 ui-monospace, SFMono-Regular, Menlo, monospace; white-space: pre-wrap; overflow-wrap: anywhere; }

.settings-copy { max-width: 680px; padding: 20px; border: 1px solid var(--line); border-radius: 7px; background: var(--panel); }
.settings-copy h2 { margin: 0 0 10px; font-size: 16px; }
.settings-copy p { margin: 0; color: var(--muted); line-height: 1.7; }
.toast { position: fixed; left: 50%; bottom: 24px; z-index: 80; max-width: min(520px, calc(100vw - 32px)); padding: 10px 14px; border-radius: 6px; background: #202a38; color: #fff; opacity: 0; pointer-events: none; transform: translate(-50%, 8px); transition: .18s ease; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: #8b211a; }

.login-page { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-box { width: min(380px, 100%); display: grid; gap: 16px; padding: 26px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); }
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 6px; }
.login-brand h1 { margin: 0; font-size: 21px; }
.login-brand p { margin: 3px 0 0; color: var(--muted); }
.login-box label { display: grid; gap: 7px; color: #344054; font-size: 13px; font-weight: 600; }
.login-box input { min-height: 42px; border: 1px solid #cfd7e2; border-radius: 6px; padding: 9px 11px; }
.login-message { padding: 10px 12px; border: 1px solid #f5c1bd; border-radius: 6px; background: var(--danger-soft); color: #7a271a; }

@media (max-width: 1040px) {
  .domain, #clock { display: none; }
  body.drawer-open .workspace { margin-right: 0; }
  .drawer { width: min(430px, 100vw); box-shadow: -12px 0 28px rgba(16, 24, 40, .12); }
  .infra-strip { flex-wrap: wrap; }
  .infra-item { min-width: 180px; border-bottom: 1px solid var(--line-soft); }
}

@media (max-width: 720px) {
  .topbar { padding: 0 12px; }
  .account > span:not(.avatar) { display: none; }
  .sidebar { position: static; width: auto; height: 48px; display: flex; gap: 4px; padding: 6px 10px; border-right: 0; border-bottom: 1px solid var(--line); overflow-x: auto; }
  .nav-item { width: auto; min-width: max-content; min-height: 34px; margin: 0; padding: 0 12px; }
  .workspace { margin-left: 0; padding: 14px 10px 30px; }
  .infra-item { min-width: 50%; }
  .page-head h1 { font-size: 20px; }
  #servicesView .service-table { min-width: 0; table-layout: fixed; }
  #servicesView .app-col, #servicesView .env-col, #servicesView .started-col,
  #servicesView .app-cell, #servicesView .env-cell, #servicesView .started-cell { display: none; }
  #servicesView .service-col { width: 27%; }
  #servicesView .version-col { width: 20%; }
  #servicesView .status-col { width: 34%; }
  #servicesView .action-col { width: 19%; }
  .mobile-group { display: block; margin-bottom: 5px; }
  .mobile-group strong, .mobile-group span { display: block; }
  .mobile-group span { margin-top: 3px; color: var(--muted); font-size: 11px; font-weight: 450; }
  .service-name { padding-left: 12px !important; }
  #servicesView .service-table td { padding-left: 8px; padding-right: 8px; }
  .version-trigger { display: grid; gap: 2px; }
  .version-info { display: none; }
  .state-detail { font-size: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .deploy-trigger { min-width: 54px; padding: 6px 8px; }
}
