:root {
  color-scheme: light;
  --ink: #1c2430;
  --muted: #667085;
  --line: #d8dee8;
  --surface: #f6f8fb;
  --panel: #ffffff;
  --accent: #1677ff;
  --accent-dark: #0d4fbd;
  --danger: #b42318;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--surface);
  color: var(--ink);
  font-family:
    Inter,
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    "Microsoft YaHei",
    sans-serif;
}

.shell {
  width: min(1280px, calc(100vw - 48px));
  margin: 0 auto;
  padding: 32px 0 48px;
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding-bottom: 24px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 13px;
}

h1 {
  margin: 0;
  font-size: 30px;
  line-height: 1.2;
  font-weight: 720;
}

button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 16px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: var(--accent);
  color: white;
  font: inherit;
  font-weight: 650;
  cursor: pointer;
}

button:hover {
  background: var(--accent-dark);
}

.secondary-button,
.row-button {
  border-color: var(--line);
  background: white;
  color: var(--ink);
}

.nav-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
  color: var(--ink);
  font-weight: 650;
  text-decoration: none;
}

.secondary-button:hover,
.row-button:hover,
.nav-button:hover {
  border-color: var(--accent);
  background: #f4f8ff;
}

.nav-button-dark {
  border-color: #111827;
  background: #111827;
  color: #ffffff;
}

.nav-button-dark:hover {
  border-color: #000000;
  background: #000000;
  color: #ffffff;
}

.row-button {
  min-height: 32px;
  padding: 0 10px;
  font-size: 12px;
}

button:disabled {
  cursor: wait;
  opacity: 0.72;
}

.button-icon {
  font-size: 16px;
}

.is-busy .button-icon {
  animation: spin 900ms linear infinite;
}

.status-band {
  display: grid;
  grid-template-columns: 160px 120px minmax(0, 1fr);
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--line);
}

.status-band > div {
  min-width: 0;
  padding: 14px 16px;
  background: var(--panel);
}

.label {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 12px;
}

.status-band strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
}

.config-section {
  display: grid;
  gap: 12px;
  margin-top: 16px;
  border-top: 1px solid var(--line);
  padding-top: 16px;
}

.config-section h3 {
  margin: 0;
  font-size: 15px;
}

.config-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.config-section label {
  min-width: 0;
}

.config-section select,
.config-section input {
  width: 100%;
  min-height: 40px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
  color: var(--ink);
  font: inherit;
  font-size: 13px;
}

.config-section input {
  font-family:
    ui-monospace,
    SFMono-Regular,
    Menlo,
    Consolas,
    monospace;
}

.config-section select:disabled,
.config-section input:disabled {
  background: #f2f4f7;
  color: var(--muted);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgb(15 23 42 / 0.45);
}

.modal-backdrop[hidden] {
  display: none;
}

.config-modal {
  width: min(720px, 100%);
  max-height: calc(100vh - 48px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 18px;
  box-shadow: 0 24px 72px rgb(15 23 42 / 0.22);
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.modal-head h2 {
  margin: 0;
  font-size: 20px;
}

.login-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: fit-content;
  min-height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  font-size: 13px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
}

.login-status-pill.is-ok {
  background: #ecfdf3;
  color: #027a48;
}

.login-status-pill.is-ok .status-dot {
  background: #12b76a;
}

.login-status-pill.is-error {
  background: #fef3f2;
  color: #b42318;
}

.login-status-pill.is-error .status-dot {
  background: #f04438;
}

.log-panel {
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.log-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}

.log-head strong {
  font-size: 13px;
}

.is-error {
  color: var(--danger);
}

.log-text {
  min-height: 76px;
  max-height: 180px;
  overflow: auto;
  white-space: pre-wrap;
  padding: 12px 16px;
  color: var(--muted);
  font-family:
    ui-monospace,
    SFMono-Regular,
    Menlo,
    Consolas,
    monospace;
  font-size: 12px;
  line-height: 1.55;
}

.log-text.has-error {
  color: var(--danger);
}

.table-wrap {
  margin-top: 20px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

table {
  width: 100%;
  min-width: 980px;
  border-collapse: collapse;
}

th,
td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  font-size: 14px;
}

th {
  position: sticky;
  top: 0;
  background: #eef3f8;
  color: #344054;
  font-size: 12px;
  font-weight: 720;
}

td:first-child,
th:first-child,
td:nth-child(4),
th:nth-child(4),
td:nth-child(5),
th:nth-child(5) {
  width: 72px;
  text-align: center;
}

td:nth-child(7),
th:nth-child(7),
td:nth-child(8),
th:nth-child(8) {
  width: 150px;
}

.title-cell {
  width: 38%;
  line-height: 1.5;
}

.path-cell {
  max-width: 360px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.detail-cell {
  min-width: 150px;
}

.detail-status,
.ai-status {
  display: block;
  margin-top: 7px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.ai-cell {
  min-width: 150px;
}

.apply-plan-panel {
  margin-top: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.plan-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.plan-head strong {
  display: block;
  max-width: 760px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 15px;
}

.plan-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  background: var(--line);
  border-bottom: 1px solid var(--line);
}

.plan-summary div {
  min-width: 0;
  padding: 12px 16px;
  background: #fbfcfe;
}

.plan-summary span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.plan-summary strong {
  display: block;
  margin-top: 3px;
  font-size: 15px;
}

.plan-operations {
  display: grid;
  gap: 1px;
  background: var(--line);
}

.plan-operation {
  display: grid;
  grid-template-columns: 130px minmax(120px, 240px) minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  padding: 12px 16px;
  background: white;
}

.plan-operation strong {
  font-size: 13px;
}

.plan-operation span {
  color: #344054;
  font-size: 13px;
  overflow-wrap: anywhere;
}

.plan-operation code {
  color: var(--muted);
  font-family:
    ui-monospace,
    SFMono-Regular,
    Menlo,
    Consolas,
    monospace;
  font-size: 12px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.empty-row td {
  padding: 40px;
  color: var(--muted);
  text-align: center;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 760px) {
  .shell {
    width: min(100vw - 28px, 1280px);
    padding-top: 22px;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .actions {
    justify-content: stretch;
  }

  button {
    justify-content: center;
    width: 100%;
  }

  .nav-button {
    width: 100%;
  }

  .status-band {
    grid-template-columns: 1fr;
  }

  .plan-head {
    align-items: stretch;
    flex-direction: column;
  }

  .plan-summary,
  .plan-operation {
    grid-template-columns: 1fr;
  }
}
