:root {
  --bg: #070b10;
  --surface: rgba(12, 18, 26, 0.88);
  --surface-2: rgba(16, 25, 35, 0.94);
  --surface-3: rgba(22, 32, 44, 0.92);
  --text: #eef7ff;
  --muted: #91a6b8;
  --line: rgba(148, 163, 184, 0.18);
  --line-strong: rgba(125, 211, 252, 0.34);
  --cyan: #38bdf8;
  --green: #22c55e;
  --amber: #f59e0b;
  --rose: #f43f5e;
  --violet: #a78bfa;
  --shadow: 0 18px 56px rgba(0, 0, 0, 0.42);
}

* { box-sizing: border-box; }

html { min-height: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Segoe UI", "Microsoft YaHei", system-ui, sans-serif;
  color: var(--text);
  background:
    linear-gradient(120deg, rgba(56, 189, 248, 0.12), transparent 34%),
    linear-gradient(250deg, rgba(245, 158, 11, 0.12), transparent 30%),
    linear-gradient(180deg, #0a1119 0%, var(--bg) 58%, #05070b 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(148, 163, 184, 0.055) 1px, transparent 1px),
    linear-gradient(90deg, rgba(148, 163, 184, 0.045) 1px, transparent 1px);
  background-size: 36px 36px;
  mask-image: linear-gradient(to bottom, #000 0%, rgba(0, 0, 0, 0.72) 42%, transparent 100%);
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(255,255,255,0.03), transparent 38%);
}

.shell {
  position: relative;
  z-index: 1;
  min-height: 100vh;
}

.topbar {
  max-width: 1360px;
  margin: 0 auto;
  padding: 18px 18px 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.topbar__brand { min-width: 0; }

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.brand__mark {
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background:
    linear-gradient(145deg, rgba(56, 189, 248, 0.28), rgba(167, 139, 250, 0.18)),
    rgba(7, 11, 16, 0.9);
  color: #fff;
  font-size: 30px;
  font-weight: 900;
  box-shadow: 0 0 34px rgba(56, 189, 248, 0.22);
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--cyan);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 { margin: 0; }

h1 {
  font-size: clamp(28px, 4vw, 46px);
  line-height: 1;
  letter-spacing: 0;
}

h2 {
  font-size: 1.08rem;
  line-height: 1.25;
}

.userbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(8, 13, 20, 0.72);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.24);
  backdrop-filter: blur(14px);
}

.userbar__dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: var(--green);
  box-shadow: 0 0 12px rgba(34, 197, 94, 0.8);
}

.wrap {
  max-width: 1360px;
  margin: 0 auto;
  padding: 8px 18px 28px;
}

.dashboard {
  display: grid;
  grid-template-columns: minmax(560px, 1fr) 360px;
  grid-template-areas:
    "issue side"
    "mydata side"
    "table table";
  gap: 16px;
}

.issue-panel { grid-area: issue; }
.mydata-panel { grid-area: mydata; }
.side-stack { grid-area: side; display: grid; gap: 16px; align-content: start; }
.table-panel { grid-area: table; }

.panel {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.045), transparent 36%),
    var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.panel::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 2px;
  background: linear-gradient(90deg, var(--cyan), var(--green), var(--amber), var(--violet));
  opacity: 0.78;
}

.panel {
  padding: 16px;
  margin-bottom: 16px;
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  flex: 0 0 auto;
  border: 1px solid rgba(34, 197, 94, 0.34);
  background: rgba(34, 197, 94, 0.1);
  border-radius: 999px;
  padding: 7px 10px;
  color: #b8ffd0;
  font-size: 12px;
  font-weight: 800;
}

.status-pill::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
}

.login-layout {
  min-height: min(520px, calc(100vh - 120px));
  display: grid;
  grid-template-columns: minmax(280px, 1fr) minmax(320px, 430px);
  align-items: center;
  gap: 34px;
  padding: 28px;
  background:
    linear-gradient(135deg, rgba(56, 189, 248, 0.16), rgba(167, 139, 250, 0.10) 42%, rgba(245, 158, 11, 0.11)),
    rgba(9, 14, 22, 0.9);
}

.login-copy h2 {
  font-size: clamp(28px, 5vw, 58px);
  line-height: 1.02;
  margin-bottom: 14px;
}

.login-copy p:last-of-type {
  max-width: 560px;
  color: var(--muted);
  margin: 0;
  line-height: 1.8;
}

.login-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 18px;
}

.login-badges span {
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: #cfeaff;
  background: rgba(255, 255, 255, 0.045);
  font-size: 12px;
}

.form-stack,
.form-grid {
  display: grid;
  gap: 12px;
}

.form-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  align-items: end;
}

.row {
  display: flex;
  flex-direction: column;
  gap: 7px;
  min-width: 0;
}

.row-wide { grid-column: span 2; }
.row-action { align-self: end; }
.row-action .primary { width: 100%; }

label {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid rgba(148, 163, 184, 0.24);
  border-radius: 7px;
  background: rgba(4, 8, 13, 0.82);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

input[type="date"] {
  color-scheme: dark;
}

input,
select {
  height: 40px;
  padding: 0 11px;
}

textarea {
  min-height: 96px;
  resize: vertical;
  padding: 10px 11px;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 12px;
  line-height: 1.55;
}

.side-panel textarea {
  min-height: 168px;
}

.binding-tools {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.bind-meter {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 11px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 7px;
  background: rgba(4, 8, 13, 0.62);
}

.bind-meter span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.bind-meter strong {
  color: #b8ffd0;
  font-size: 1rem;
}

#cPreview {
  min-height: 118px;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(56, 189, 248, 0.76);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.12);
  background: rgba(6, 12, 19, 0.96);
}

button {
  min-height: 38px;
  padding: 8px 13px;
  border: 1px solid rgba(148, 163, 184, 0.25);
  border-radius: 7px;
  background: rgba(21, 31, 43, 0.96);
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.12s ease, background 0.12s ease, box-shadow 0.12s ease;
}

button:hover {
  transform: translateY(-1px);
  border-color: rgba(56, 189, 248, 0.56);
  background: rgba(30, 44, 60, 0.98);
}

button:active { transform: translateY(0); }

button.primary {
  border-color: rgba(125, 211, 252, 0.4);
  background: linear-gradient(135deg, #0284c7, #16a34a 54%, #d97706);
  color: #fff;
  box-shadow: 0 10px 26px rgba(2, 132, 199, 0.22);
}

button.danger {
  border-color: rgba(244, 63, 94, 0.44);
  background: rgba(127, 29, 29, 0.86);
  color: #ffe4e6;
}

button.ghost {
  background: transparent;
}

button.copied-flash {
  background: rgba(22, 163, 74, 0.95) !important;
  border-color: rgba(134, 239, 172, 0.85) !important;
  color: #fff !important;
  box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.35);
  transform: scale(1.03);
}

button.copy-fail-flash {
  box-shadow: 0 0 0 2px rgba(244, 63, 94, 0.42);
  transform: scale(1.02);
}

.search-box {
  display: flex;
  gap: 8px;
  min-width: min(460px, 100%);
}

.search-box input { flex: 1 1 auto; }

.mydata-tools {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 140px;
  gap: 12px;
  align-items: end;
  margin-bottom: 12px;
}

.mydata-table-wrap {
  max-height: 360px;
  overflow: auto;
}

#mydataTable {
  min-width: 760px;
}

#mydataTable td {
  max-width: 320px;
}

.mydata-pager {
  margin-top: 10px;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid rgba(148, 163, 184, 0.16);
  border-radius: 8px;
  background: rgba(4, 8, 13, 0.46);
}

table {
  width: 100%;
  min-width: 920px;
  border-collapse: collapse;
  font-size: 0.86rem;
}

th,
td {
  border-bottom: 1px solid rgba(148, 163, 184, 0.14);
  padding: 10px 9px;
  text-align: left;
  vertical-align: middle;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  color: #bfeeff;
  font-size: 0.78rem;
  font-weight: 900;
  background: rgba(14, 25, 36, 0.98);
}

td {
  color: #dcecff;
  max-width: 260px;
  overflow-wrap: anywhere;
}

tbody tr:nth-child(even) td {
  background: rgba(255, 255, 255, 0.018);
}

tbody tr:hover td {
  background: rgba(56, 189, 248, 0.055);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 250px;
}

.actions button {
  min-height: 31px;
  padding: 5px 9px;
  font-size: 0.78rem;
}

.pager {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 12px;
}

#pageInfo {
  color: var(--muted);
  font-size: 0.9rem;
}

.log-panel {
  margin-top: 0;
}

.log {
  min-height: 96px;
  max-height: 220px;
  overflow: auto;
  padding: 12px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 8px;
  background: rgba(4, 8, 13, 0.84);
  color: #cfeaff;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 12px;
  line-height: 1.55;
  white-space: pre-wrap;
}

#qrMount {
  display: none;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.045), transparent 40%),
    var(--surface-2);
  box-shadow: var(--shadow);
}

#qrMount::before {
  content: "二维码";
  display: block;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

#qrMount img,
#qrMount canvas {
  display: block;
  margin: 0 auto;
  padding: 10px;
  background: #fff;
  border-radius: 6px;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 18px;
}

.modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(2, 6, 12, 0.72);
  backdrop-filter: blur(8px);
}

.modal__panel {
  position: relative;
  width: min(460px, 100%);
  max-height: min(620px, calc(100vh - 36px));
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.055), transparent 38%),
    var(--surface-2);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.58);
  padding: 16px;
}

.modal__close {
  width: 38px;
  min-height: 38px;
  padding: 0;
  font-size: 24px;
  line-height: 1;
}

.edit-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  padding: 10px 11px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 7px;
  background: rgba(4, 8, 13, 0.62);
}

.edit-summary span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.edit-summary strong {
  min-width: 0;
  color: #bfeeff;
  overflow-wrap: anywhere;
}

.modal__actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 16px;
}

.modal__actions button {
  min-height: 42px;
}

.hidden { display: none !important; }

@media (max-width: 1080px) {
  .dashboard {
    grid-template-columns: 1fr;
    grid-template-areas:
      "issue"
      "mydata"
      "side"
      "table";
  }

  .side-stack {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  #qrMount {
    grid-area: auto;
  }
}

@media (max-width: 780px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .userbar {
    width: 100%;
    justify-content: space-between;
  }

  .login-layout,
  .form-grid,
  .mydata-tools,
  .side-stack {
    grid-template-columns: 1fr;
  }

  .row-wide {
    grid-column: auto;
  }

  .section-head,
  .search-box,
  .pager {
    align-items: stretch;
    flex-direction: column;
  }

  .binding-tools {
    grid-template-columns: 1fr;
  }

  .pager {
    align-items: flex-start;
  }

  .modal {
    align-items: end;
    padding: 10px;
  }

  .modal__panel {
    width: 100%;
    max-height: calc(100vh - 20px);
  }
}

@media (max-width: 520px) {
  .topbar,
  .wrap {
    padding-left: 12px;
    padding-right: 12px;
  }

  .brand__mark {
    width: 46px;
    height: 46px;
    font-size: 25px;
  }

  .panel {
    padding: 13px;
  }

  .login-layout {
    padding: 18px;
  }

  h1 {
    font-size: 26px;
  }

  .actions {
    min-width: 210px;
  }

  .modal__actions {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  body {
    background:
      linear-gradient(180deg, rgba(56, 189, 248, 0.1), transparent 280px),
      linear-gradient(180deg, #0a1119 0%, var(--bg) 58%, #05070b 100%);
  }

  .topbar {
    padding-top: 12px;
  }

  .brand {
    width: 100%;
  }

  .brand > div {
    min-width: 0;
  }

  h1 {
    overflow-wrap: anywhere;
  }

  .login-layout {
    min-height: auto;
  }

  .login-copy h2 {
    font-size: 30px;
  }

  input,
  select,
  textarea,
  button {
    font-size: 16px;
  }

  .table-wrap {
    overflow: visible;
    border: 0;
    background: transparent;
  }

  table,
  thead,
  tbody,
  tr,
  td {
    display: block;
    width: 100%;
  }

  table {
    min-width: 0;
    border-collapse: separate;
    border-spacing: 0;
  }

  thead {
    display: none;
  }

  tbody tr {
    margin-bottom: 10px;
    border: 1px solid rgba(148, 163, 184, 0.18);
    border-radius: 8px;
    background: rgba(4, 8, 13, 0.66);
    overflow: hidden;
  }

  th,
  td {
    border-bottom: 1px solid rgba(148, 163, 184, 0.12);
  }

  td {
    min-height: 40px;
    max-width: none;
    display: grid;
    grid-template-columns: 74px minmax(0, 1fr);
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    background: transparent !important;
  }

  td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
  }

  td:last-child {
    border-bottom: 0;
  }

  td.actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    min-width: 0;
    gap: 8px;
  }

  td.actions::before {
    grid-column: 1 / -1;
  }

  .actions button {
    width: 100%;
    min-height: 38px;
    font-size: 0.88rem;
  }

  .mydata-panel .section-head {
    gap: 8px;
  }

  .mydata-tools {
    gap: 10px;
    margin-bottom: 10px;
  }

  .mydata-table-wrap {
    max-height: 430px;
    overflow: auto;
  }

  #mydataTable {
    min-width: 0;
  }

  #mydataTable td {
    max-width: none;
    grid-template-columns: 84px minmax(0, 1fr);
    align-items: start;
    overflow-wrap: anywhere;
    word-break: break-word;
  }

  #mydataTable td::before {
    line-height: 1.45;
  }

  .log {
    max-height: 180px;
  }
}
