:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --panel-2: #f0f4f8;
  --text: #17202a;
  --muted: #627083;
  --line: #d9e0e8;
  --line-strong: #b8c4d2;
  --accent: #1f6feb;
  --accent-strong: #1558c0;
  --green: #20875a;
  --orange: #b76d14;
  --red: #bf3434;
  --cyan: #147f8f;
  --shadow: 0 18px 48px rgba(32, 43, 56, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  min-height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, "Segoe UI", Arial, "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.45;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
.import-button {
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: 7px;
  padding: 0 14px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  white-space: nowrap;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

.primary {
  background: var(--accent);
  color: #fff;
}

.primary:hover {
  background: var(--accent-strong);
}

.secondary,
.import-button {
  background: #e8eef6;
  color: #1f3248;
  border-color: #cfdae7;
}

.secondary:hover,
.import-button:hover {
  background: #dce6f2;
}

.ghost {
  background: transparent;
  color: #2d3b4e;
  border-color: var(--line);
}

.ghost:hover {
  background: #eef2f6;
}

.danger {
  background: #fff1f1;
  border-color: #f0bbbb;
  color: var(--red);
}

.danger:hover {
  background: #ffe6e6;
}

.full {
  width: 100%;
}

.hidden {
  display: none !important;
}

.app-shell {
  min-height: 100vh;
}

.unlock-panel {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(280px, 560px) minmax(320px, 420px);
  gap: 48px;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
}

.unlock-copy h1,
.topbar h1 {
  margin: 0;
  font-size: 34px;
  line-height: 1.1;
  letter-spacing: 0;
}

.unlock-copy p {
  max-width: 560px;
  color: var(--muted);
  font-size: 16px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--cyan);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.unlock-form,
.filters,
.records,
.service-dialog form {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.unlock-form {
  padding: 24px;
}

label {
  display: grid;
  gap: 7px;
  color: #314155;
  font-weight: 650;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: #fff;
  color: var(--text);
  min-height: 38px;
  padding: 8px 10px;
  outline: none;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(31, 111, 235, 0.12);
}

.unlock-form label + label,
.unlock-form .form-row {
  margin-top: 16px;
}

.unlock-form button {
  width: 100%;
  margin-top: 18px;
}

.hint {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
  color: var(--muted);
}

.check-row input {
  width: 16px;
  min-height: 16px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 22px 28px 18px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

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

.import-button {
  position: relative;
  overflow: hidden;
}

.import-button input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

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

.metric {
  background: #fff;
  padding: 18px 28px;
}

.metric span {
  display: block;
  color: var(--accent);
  font-size: 28px;
  font-weight: 800;
  line-height: 1;
}

.metric strong {
  display: block;
  margin-top: 7px;
  color: var(--muted);
  font-size: 13px;
}

.workspace {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 18px;
  padding: 18px;
  align-items: start;
}

.filters {
  padding: 16px;
  box-shadow: none;
  position: sticky;
  top: 18px;
}

.filters label + label,
.filters .check-row,
.filters button {
  margin-top: 14px;
}

.records {
  min-height: 460px;
  box-shadow: none;
  overflow: hidden;
}

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

.save-state {
  margin-left: 10px;
  color: var(--muted);
  font-size: 12px;
}

.save-state.dirty {
  color: var(--orange);
}

.save-state.error {
  color: var(--red);
}

.service-list {
  display: grid;
}

.service-card {
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.service-main {
  display: grid;
  grid-template-columns: minmax(240px, 1.5fr) minmax(160px, 0.8fr) minmax(170px, 0.9fr) minmax(170px, 1fr) auto;
  gap: 14px;
  align-items: center;
  padding: 15px 16px;
}

.service-title {
  min-width: 0;
}

.service-title h3 {
  margin: 0;
  font-size: 16px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.service-title a,
.detail-grid a {
  color: var(--accent);
  text-decoration: none;
  overflow-wrap: anywhere;
}

.service-title a:hover,
.detail-grid a:hover {
  text-decoration: underline;
}

.subline {
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.field-block {
  min-width: 0;
}

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

.field-block strong,
.field-block code {
  display: block;
  color: #243246;
  font-weight: 650;
  overflow-wrap: anywhere;
}

code {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 12px;
}

.badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  border-radius: 999px;
  padding: 2px 8px;
  background: #edf2f7;
  color: #334155;
  font-size: 12px;
  font-weight: 650;
}

.status-running {
  background: #e8f6ef;
  color: var(--green);
}

.status-maintenance,
.status-pending {
  background: #fff4df;
  color: var(--orange);
}

.status-stopped,
.status-error {
  background: #fff0f0;
  color: var(--red);
}

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

.small-button {
  min-height: 32px;
  padding: 0 10px;
  border-color: var(--line);
  background: #fff;
  color: #2f4055;
}

.small-button:hover {
  background: #eef2f6;
}

.service-detail {
  display: none;
  border-top: 1px solid var(--line);
  padding: 15px 16px 18px;
  background: #fbfcfd;
}

.service-card.open .service-detail {
  display: block;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.detail-grid div {
  min-width: 0;
}

.detail-grid span,
.notes-block span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 4px;
}

.detail-grid strong,
.detail-grid code,
.notes-block p {
  margin: 0;
  overflow-wrap: anywhere;
}

.notes-block {
  margin-top: 14px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.notes-block p {
  white-space: pre-wrap;
}

.password-value {
  display: inline-block;
  max-width: 100%;
}

.empty-state {
  padding: 52px 18px;
  text-align: center;
}

.empty-state h2 {
  margin: 0 0 8px;
  font-size: 20px;
}

.empty-state p {
  margin: 0 0 18px;
  color: var(--muted);
}

.service-dialog {
  width: min(980px, calc(100vw - 28px));
  border: 0;
  padding: 0;
  background: transparent;
}

.service-dialog::backdrop {
  background: rgba(13, 24, 38, 0.45);
}

.service-dialog form {
  max-height: calc(100vh - 36px);
  overflow: auto;
}

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

.dialog-head h2 {
  margin: 0;
  font-size: 22px;
}

.dialog-actions {
  border-top: 1px solid var(--line);
  border-bottom: 0;
  background: #fbfcfd;
}

.dialog-actions span {
  flex: 1;
}

.icon-button {
  width: 34px;
  min-height: 34px;
  padding: 0;
  border-radius: 50%;
  font-size: 24px;
  line-height: 1;
  background: #eef2f6;
  color: #2e3d50;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 15px;
  padding: 18px;
}

.form-grid .wide {
  grid-column: 1 / -1;
}

.toast {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 20;
  max-width: min(380px, calc(100vw - 32px));
  background: #1f2937;
  color: #fff;
  border-radius: 7px;
  padding: 12px 14px;
  box-shadow: var(--shadow);
  transform: translateY(-12px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

@media (max-width: 1080px) {
  .service-main {
    grid-template-columns: minmax(220px, 1.3fr) minmax(150px, 0.8fr) minmax(150px, 0.8fr) auto;
  }

  .service-main .field-block:nth-of-type(3) {
    display: none;
  }

  .detail-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 860px) {
  .unlock-panel,
  .workspace {
    grid-template-columns: 1fr;
  }

  .unlock-panel {
    gap: 24px;
    align-items: start;
    padding-top: 48px;
  }

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

  .topbar-actions {
    justify-content: flex-start;
  }

  .summary-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .filters {
    position: static;
  }

  .service-main {
    grid-template-columns: 1fr;
  }

  .row-actions {
    justify-content: flex-start;
  }

  .form-grid,
  .detail-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .topbar,
  .metric {
    padding-left: 16px;
    padding-right: 16px;
  }

  .workspace {
    padding: 12px;
  }

  .summary-strip {
    grid-template-columns: 1fr;
  }

  .topbar-actions > *,
  .records-head button {
    width: 100%;
  }

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

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

  .dialog-actions span {
    display: none;
  }

  .dialog-actions button {
    width: 100%;
  }
}
