:root {
  --blue: #3264ff;
  --blue-weak: #eef4ff;
  --ink: #1f2937;
  --muted: #697386;
  --line: #e7ebf2;
  --bg: #f5f7fb;
  --panel: #ffffff;
  --ok: #25a244;
  --warn: #d97706;
  --bad: #d93025;
  --shadow: 0 18px 45px rgba(20, 36, 69, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--bg);
  font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
  font-size: 14px;
}

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

button {
  cursor: pointer;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: linear-gradient(180deg, #eef5ff 0%, #f7f9fd 100%);
}

.login-card {
  width: min(440px, 100%);
  padding: 30px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 22px;
}

.brand-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  color: #fff;
  background: var(--blue);
  border-radius: 8px;
  font-weight: 700;
}

.login-title {
  font-size: 22px;
  font-weight: 700;
}

.login-sub {
  margin-top: 4px;
  color: var(--muted);
}

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

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

label {
  display: grid;
  gap: 7px;
  color: #475569;
}

input,
select,
textarea {
  width: 100%;
  min-height: 36px;
  padding: 8px 10px;
  color: var(--ink);
  background: #fff;
  border: 1px solid #d9dee8;
  border-radius: 6px;
  outline: none;
}

textarea {
  min-height: 72px;
  resize: vertical;
}

.import-textarea {
  min-height: 260px;
  font-family: Consolas, Monaco, monospace;
  line-height: 1.5;
}

.import-result {
  margin-top: 14px;
  max-height: 260px;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(50, 100, 255, 0.1);
}

.primary-btn,
.secondary-btn,
.ghost-btn,
.icon-btn {
  min-height: 34px;
  padding: 0 14px;
  border-radius: 6px;
  border: 1px solid transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  white-space: nowrap;
}

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

.secondary-btn {
  color: #244166;
  background: #fff;
  border-color: #d9dee8;
}

.ghost-btn {
  color: var(--blue);
  background: transparent;
}

.icon-btn {
  width: 34px;
  padding: 0;
  color: #64748b;
  background: #fff;
  border-color: #d9dee8;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-rows: 48px 1fr;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 16px;
  color: #fff;
  background: #3974ff;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 250px;
  font-weight: 700;
}

.brand .brand-mark {
  width: 26px;
  height: 26px;
  border: 1px solid rgba(255, 255, 255, 0.5);
  background: rgba(255, 255, 255, 0.18);
}

.top-nav {
  display: flex;
  align-items: center;
  gap: 4px;
}

.top-nav button {
  height: 32px;
  padding: 0 12px;
  color: rgba(255, 255, 255, 0.86);
  background: transparent;
  border: 0;
  border-radius: 6px;
}

.top-nav button.active {
  color: #fff;
  background: rgba(255, 255, 255, 0.18);
}

.top-spacer {
  flex: 1;
}

.layout {
  min-height: 0;
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
}

.sidebar {
  padding: 14px 12px;
  background: #eef3fb;
  border-right: 1px solid #dce4f2;
}

.side-title {
  padding: 8px 12px;
  color: #7b879b;
  font-size: 12px;
}

.side-item {
  width: 100%;
  height: 38px;
  padding: 0 12px;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: #26364d;
  background: transparent;
  border: 0;
  border-radius: 6px;
}

.side-item.active {
  color: var(--blue);
  background: #dfe8ff;
}

.side-badge {
  color: #8a96aa;
}

.main {
  min-width: 0;
  padding: 16px;
  overflow: auto;
}

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

.toolbar {
  min-height: 54px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.toolbar h1 {
  margin: 0;
  font-size: 18px;
}

.toolbar-spacer {
  flex: 1;
}

.search {
  width: min(380px, 34vw);
}

.content {
  margin-top: 12px;
}

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

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

th,
td {
  height: 52px;
  padding: 8px 12px;
  border-bottom: 1px solid #edf0f5;
  text-align: left;
  vertical-align: middle;
}

th {
  height: 42px;
  color: #7b879b;
  background: #fbfcfe;
  font-weight: 500;
}

tr:last-child td {
  border-bottom: 0;
}

.name-cell {
  display: flex;
  align-items: center;
  gap: 10px;
}

.platform-icon {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  color: #fff;
  background: #ff6534;
  border-radius: 6px;
  font-weight: 700;
}

.platform-icon.device {
  background: #3b82f6;
}

.platform-icon.user {
  background: #10b981;
}

.title-line {
  color: #165dff;
  font-weight: 500;
}

.sub-line {
  margin-top: 3px;
  color: #7b879b;
  font-size: 12px;
}

.mono {
  font-family: Consolas, Monaco, monospace;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: #64748b;
}

.status::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.status.ok {
  color: var(--ok);
}

.status.warn {
  color: var(--warn);
}

.status.bad {
  color: var(--bad);
}

.actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  flex-wrap: wrap;
}

.secret-box {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto auto;
  align-items: center;
  gap: 6px;
}

.secret-box input {
  min-height: 34px;
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
}

.vault-tip {
  margin-top: 10px;
  padding: 10px 12px;
  color: #64748b;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.vault-form {
  align-items: end;
}

.empty {
  min-height: 260px;
  display: grid;
  place-items: center;
  color: #7b879b;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.metric {
  padding: 16px;
}

.metric-value {
  margin-top: 12px;
  font-size: 28px;
  font-weight: 700;
}

.metric-label {
  color: #7b879b;
}

.device-health-strip {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.health-card {
  min-height: 70px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.health-card span {
  color: #697386;
  min-width: 0;
}

.health-card strong {
  font-size: 24px;
}

.health-card.ok strong {
  color: var(--ok);
}

.health-card.bad strong {
  color: var(--bad);
}

.health-card.warn strong {
  color: var(--warn);
}

.health-card.muted strong {
  color: #64748b;
}

.split-grid {
  margin-top: 12px;
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(360px, 0.7fr);
  gap: 12px;
}

.card-title {
  padding: 14px 16px;
  font-weight: 700;
  border-bottom: 1px solid var(--line);
}

.list {
  padding: 8px 0;
}

.list-item {
  padding: 10px 16px;
  border-bottom: 1px solid #edf0f5;
}

.list-item:last-child {
  border-bottom: 0;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 28px;
  background: rgba(15, 23, 42, 0.42);
}

.modal-backdrop.show {
  display: flex;
}

.modal {
  width: min(760px, 100%);
  max-height: calc(100vh - 56px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  background: #fff;
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.modal.small {
  width: min(520px, 100%);
}

.modal-header,
.modal-footer {
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--line);
}

.modal-header {
  font-weight: 700;
}

.modal-footer {
  justify-content: flex-end;
  border-top: 1px solid var(--line);
  border-bottom: 0;
}

.modal-body {
  padding: 18px;
  overflow: auto;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 30;
  max-width: 420px;
  padding: 11px 14px;
  color: #fff;
  background: #1f2937;
  border-radius: 6px;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: 0.16s ease;
}

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

.toast.error {
  background: var(--bad);
}

@media (max-width: 980px) {
  .layout {
    grid-template-columns: 64px minmax(0, 1fr);
  }

  .sidebar {
    padding: 8px;
  }

  .side-title,
  .side-item span:first-child {
    display: none;
  }

  .side-item {
    justify-content: center;
  }

  .dashboard-grid,
  .device-health-strip,
  .split-grid {
    grid-template-columns: 1fr;
  }

  .top-nav {
    display: none;
  }
}
