:root {
  --bg: #0a0d12;
  --surface: #10151d;
  --surface-2: #151b25;
  --surface-3: #1a2230;
  --border: rgba(255,255,255,.075);
  --border-strong: rgba(255,255,255,.12);
  --text: #f4f7fb;
  --muted: #8e99aa;
  --muted-2: #657083;
  --accent: #6d7cff;
  --accent-hover: #7d8aff;
  --accent-soft: rgba(109,124,255,.14);
  --success: #4bd6a0;
  --success-soft: rgba(75,214,160,.12);
  --warning: #f3bd62;
  --warning-soft: rgba(243,189,98,.12);
  --danger: #ff6b79;
  --danger-soft: rgba(255,107,121,.12);
  --shadow: 0 24px 60px rgba(0,0,0,.28);
  --radius: 14px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family:
    Inter,
    "SF Pro Display",
    "SF Pro Text",
    "PingFang SC",
    "Microsoft YaHei",
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    sans-serif;
}

body {
  min-width: 1080px;
}

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

button {
  color: inherit;
}

button,
select {
  cursor: pointer;
}

.shell {
  display: grid;
  grid-template-columns: 236px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 20;
  width: 236px;
  display: flex;
  flex-direction: column;
  padding: 22px 16px 18px;
  background:
    linear-gradient(180deg, rgba(255,255,255,.018), transparent 30%),
    #0c1017;
  border-right: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 2px 8px 25px;
}

.brand-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 11px;
  background: linear-gradient(145deg, #8490ff, #5968ed);
  box-shadow: 0 8px 24px rgba(91,105,238,.24);
  color: #fff;
  font-size: 18px;
  font-weight: 800;
}

.brand-name {
  font-size: 15px;
  line-height: 1.2;
  font-weight: 720;
  letter-spacing: .01em;
}

.brand-sub {
  margin-top: 4px;
  color: var(--muted-2);
  font-size: 10px;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.nav-item {
  width: 100%;
  height: 42px;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  text-align: left;
  transition: .16s ease;
}

.nav-item:hover {
  background: rgba(255,255,255,.035);
  color: var(--text);
}

.nav-item.active {
  background: var(--accent-soft);
  border-color: rgba(109,124,255,.16);
  color: #dfe3ff;
}

.nav-icon {
  width: 19px;
  color: currentColor;
  font-size: 17px;
  text-align: center;
}

.sidebar-footer {
  margin-top: auto;
}

.server-state {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 5px 13px;
  padding: 12px 10px;
  border-top: 1px solid var(--border);
}

.server-state strong {
  display: block;
  margin-bottom: 3px;
  color: #dfe4ed;
  font-size: 11px;
  font-weight: 650;
}

.server-state small {
  display: block;
  color: var(--muted-2);
  font-size: 10px;
}

.state-dot {
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 4px rgba(75,214,160,.08);
}

.ghost-button {
  width: 100%;
  height: 38px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: rgba(255,255,255,.025);
  color: var(--muted);
  font-size: 11px;
}

.ghost-button:hover {
  background: rgba(255,255,255,.05);
  color: var(--text);
}

.main {
  grid-column: 2;
  min-width: 0;
  padding: 29px 34px 48px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 27px;
}

.topbar h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 720;
  letter-spacing: -.02em;
}

.topbar p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 11px;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 9px;
}

.primary-button,
.secondary-button,
.danger-button,
.text-button {
  border-radius: 9px;
  transition: .15s ease;
}

.primary-button,
.secondary-button,
.danger-button {
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid transparent;
  font-size: 11px;
  font-weight: 650;
}

.primary-button {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 8px 24px rgba(109,124,255,.17);
}

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

.secondary-button {
  border-color: var(--border-strong);
  background: var(--surface-2);
  color: #dce1ea;
}

.secondary-button:hover {
  background: var(--surface-3);
}

.danger-button {
  border-color: rgba(255,107,121,.22);
  background: var(--danger-soft);
  color: #ff98a3;
}

.danger-button:hover {
  background: rgba(255,107,121,.18);
}

.text-button {
  padding: 6px 8px;
  border: 0;
  background: transparent;
  color: #9da7ff;
  font-size: 11px;
}

.text-button:hover {
  background: var(--accent-soft);
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 13px;
  margin-bottom: 17px;
}

.stat-card {
  position: relative;
  min-height: 130px;
  overflow: hidden;
  padding: 19px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background:
    linear-gradient(145deg, rgba(255,255,255,.022), transparent 60%),
    var(--surface);
}

.stat-card::after {
  content: "";
  position: absolute;
  top: -45px;
  right: -45px;
  width: 105px;
  height: 105px;
  border-radius: 50%;
  background: rgba(109,124,255,.06);
  filter: blur(3px);
}

.stat-card span {
  position: relative;
  z-index: 1;
  display: block;
  color: var(--muted);
  font-size: 11px;
}

.stat-card strong {
  position: relative;
  z-index: 1;
  display: block;
  margin: 13px 0 9px;
  font-size: 29px;
  line-height: 1;
  font-weight: 720;
  letter-spacing: -.04em;
}

.stat-card small {
  position: relative;
  z-index: 1;
  color: var(--muted-2);
  font-size: 10px;
}

.panel {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 1px 0 rgba(255,255,255,.015) inset;
}

.panel-head {
  min-height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 0 18px;
  border-bottom: 1px solid var(--border);
}

.panel-head h2 {
  margin: 0;
  font-size: 13px;
  font-weight: 680;
}

.panel-head p {
  margin: 5px 0 0;
  color: var(--muted-2);
  font-size: 10px;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 13px;
}

.search-box {
  height: 40px;
  flex: 1;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
}

.search-box span {
  color: var(--muted-2);
  font-size: 16px;
}

.search-box input {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-size: 11px;
}

.search-box input::placeholder {
  color: #596273;
}

.toolbar select {
  height: 40px;
  min-width: 126px;
  padding: 0 31px 0 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  outline: 0;
  background: var(--surface);
  color: #d9dee8;
  font-size: 11px;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: auto;
}

.data-table th {
  height: 42px;
  padding: 0 14px;
  border-bottom: 1px solid var(--border);
  background: rgba(255,255,255,.012);
  color: var(--muted-2);
  font-size: 9px;
  font-weight: 650;
  letter-spacing: .04em;
  text-align: left;
  white-space: nowrap;
}

.data-table td {
  height: 58px;
  padding: 8px 14px;
  border-bottom: 1px solid rgba(255,255,255,.045);
  color: #dce1e9;
  font-size: 10.5px;
  vertical-align: middle;
}

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

.data-table tbody tr {
  transition: background .12s ease;
}

.data-table tbody tr:hover {
  background: rgba(255,255,255,.018);
}

.license-key {
  color: #f2f4fa;
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 10px;
  font-weight: 650;
  letter-spacing: .015em;
}

.customer-name {
  display: block;
  color: #edf0f5;
  font-weight: 620;
}

.customer-note {
  display: block;
  max-width: 220px;
  margin-top: 4px;
  overflow: hidden;
  color: var(--muted-2);
  font-size: 9px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 23px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 9px;
  font-weight: 680;
}

.badge.active {
  background: var(--success-soft);
  color: var(--success);
}

.badge.suspended {
  background: var(--warning-soft);
  color: var(--warning);
}

.badge.revoked,
.badge.expired {
  background: var(--danger-soft);
  color: var(--danger);
}

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

.icon-button {
  min-width: 30px;
  height: 30px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255,255,255,.02);
  color: var(--muted);
  font-size: 9px;
}

.icon-button:hover {
  background: rgba(255,255,255,.055);
  color: var(--text);
}

.empty-panel {
  min-height: 330px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 35px;
  text-align: center;
}

.empty-icon {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  margin-bottom: 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface-2);
  color: #8995a8;
  font-size: 21px;
}

.empty-panel h2 {
  margin: 0 0 8px;
  font-size: 14px;
}

.empty-panel p {
  max-width: 360px;
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.7;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 30px;
  background: rgba(3,5,8,.72);
  backdrop-filter: blur(8px);
}

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

.modal {
  width: min(620px, 92vw);
  max-height: 88vh;
  overflow-y: auto;
  border: 1px solid var(--border-strong);
  border-radius: 16px;
  background: #111720;
  box-shadow: var(--shadow);
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding: 20px 21px 17px;
  border-bottom: 1px solid var(--border);
}

.modal-header h2 {
  margin: 0;
  font-size: 15px;
}

.modal-header p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 10px;
}

.modal-close {
  width: 30px;
  height: 30px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
}

.modal-close:hover {
  background: rgba(255,255,255,.04);
  color: var(--text);
}

.modal-body {
  padding: 19px 21px 21px;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

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

.form-field label {
  color: #aeb6c4;
  font-size: 10px;
  font-weight: 620;
}

.form-field input,
.form-field select,
.form-field textarea {
  width: 100%;
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  outline: none;
  background: #0d1219;
  color: var(--text);
  font-size: 11px;
  transition: border-color .15s ease;
}

.form-field input,
.form-field select {
  height: 40px;
  padding: 0 11px;
}

.form-field textarea {
  min-height: 82px;
  resize: vertical;
  padding: 10px 11px;
  line-height: 1.55;
}

.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus {
  border-color: rgba(109,124,255,.65);
}

.form-help {
  color: var(--muted-2);
  font-size: 9px;
  line-height: 1.5;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 20px;
  padding-top: 17px;
  border-top: 1px solid var(--border);
}

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

.detail-item {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(255,255,255,.018);
}

.detail-item span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted-2);
  font-size: 9px;
}

.detail-item strong {
  display: block;
  overflow-wrap: anywhere;
  color: #e9edf4;
  font-size: 10.5px;
  font-weight: 620;
}

.section-title {
  margin: 20px 0 10px;
  color: #dce1e9;
  font-size: 11px;
  font-weight: 680;
}

.device-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.device-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(255,255,255,.016);
}

.device-card strong {
  display: block;
  margin-bottom: 4px;
  font-size: 10.5px;
}

.device-card small {
  display: block;
  color: var(--muted-2);
  font-size: 9px;
}

.toast-host {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 200;
  display: flex;
  width: 320px;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 12px 14px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: #161d28;
  box-shadow: 0 15px 35px rgba(0,0,0,.28);
  color: #e8ecf2;
  font-size: 10px;
  line-height: 1.5;
  animation: toast-in .18s ease;
}

.toast.success {
  border-color: rgba(75,214,160,.25);
}

.toast.error {
  border-color: rgba(255,107,121,.28);
}

.loading,
.empty-state,
.error-state {
  min-height: 150px;
  display: grid;
  place-items: center;
  padding: 25px;
  color: var(--muted);
  font-size: 10px;
  text-align: center;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(7px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 1280px) {
  .stats-grid {
    grid-template-columns: repeat(2, minmax(0,1fr));
  }
}

@media (max-width: 1120px) {
  .main {
    padding-left: 25px;
    padding-right: 25px;
  }
}

/* ===== LumaFlow Admin Login ===== */

.login-screen {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  min-width: 100vw;
  min-height: 100vh;
  padding: 30px;
  background:
    radial-gradient(circle at 50% 15%, rgba(109,124,255,.12), transparent 32%),
    radial-gradient(circle at 80% 80%, rgba(109,124,255,.045), transparent 30%),
    #080b10;
}

.login-screen.hidden {
  display: none;
}

.login-screen::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: .22;
  background-image:
    linear-gradient(rgba(255,255,255,.018) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.018) 1px, transparent 1px);
  background-size: 38px 38px;
  mask-image: linear-gradient(to bottom, rgba(0,0,0,.75), transparent 80%);
}

.login-card {
  position: relative;
  z-index: 1;
  width: 390px;
  padding: 29px;
  border: 1px solid rgba(255,255,255,.09);
  border-radius: 18px;
  background:
    linear-gradient(145deg, rgba(255,255,255,.035), transparent 45%),
    rgba(16,21,29,.96);
  box-shadow:
    0 30px 90px rgba(0,0,0,.42),
    0 1px 0 rgba(255,255,255,.035) inset;
}

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

.login-copy {
  margin-bottom: 24px;
}

.login-copy h1 {
  margin: 0;
  font-size: 21px;
  font-weight: 720;
  letter-spacing: -.025em;
}

.login-copy p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 10.5px;
  line-height: 1.6;
}

.login-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.login-field label {
  color: #b4bdca;
  font-size: 10px;
  font-weight: 620;
}

.login-field input {
  width: 100%;
  height: 43px;
  padding: 0 12px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  outline: none;
  background: #0b1017;
  color: var(--text);
  font-size: 11px;
  transition:
    border-color .15s ease,
    box-shadow .15s ease;
}

.login-field input::placeholder {
  color: #596273;
}

.login-field input:focus {
  border-color: rgba(109,124,255,.7);
  box-shadow: 0 0 0 3px rgba(109,124,255,.09);
}

.login-error {
  margin-top: 10px;
  padding: 9px 10px;
  border: 1px solid rgba(255,107,121,.2);
  border-radius: 8px;
  background: var(--danger-soft);
  color: #ff98a3;
  font-size: 9.5px;
  line-height: 1.5;
}

.login-error.hidden {
  display: none;
}

.login-button {
  width: 100%;
  height: 43px;
  margin-top: 14px;
  border: 0;
  border-radius: 10px;
  background: linear-gradient(135deg, #7483ff, #6271f1);
  box-shadow: 0 10px 28px rgba(98,113,241,.2);
  color: #fff;
  font-size: 11px;
  font-weight: 680;
  transition:
    transform .15s ease,
    filter .15s ease;
}

.login-button:hover {
  filter: brightness(1.07);
}

.login-button:active {
  transform: translateY(1px);
}

.login-button:disabled {
  cursor: wait;
  opacity: .6;
}

.login-security {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 20px;
  padding-top: 17px;
  border-top: 1px solid var(--border);
  color: var(--muted-2);
  font-size: 9px;
}

.login-security .state-dot {
  width: 6px;
  height: 6px;
}

/* 后台身份尚未确认时，避免管理内容短暂闪现 */
body.admin-auth-pending #app > .shell {
  visibility: hidden;
}

/* ===== Brand logo image ===== */
.brand-logo {
  overflow: hidden;
  padding: 0;
  background: transparent;
  box-shadow: none;
}

.brand-logo-img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  border-radius: 11px;
}

.login-brand .brand-logo {
  width: 46px;
  height: 46px;
  border-radius: 13px;
}

.sidebar .brand-logo {
  width: 38px;
  height: 38px;
  border-radius: 11px;
}

/* ===== Global Device Management ===== */

#deviceLicenseFilter {
  min-width: 280px;
}

.devices-data-table td:first-child {
  min-width: 190px;
}

.devices-data-table td:nth-child(2) {
  min-width: 235px;
}

.device-hash {
  font-family: "SFMono-Regular", Consolas, monospace;
}

.badge.disabled {
  background: var(--danger-soft);
  color: var(--danger);
}

.badge.unbound {
  background: rgba(148, 163, 184, .10);
  color: #9ca7b8;
}

.license-link {
  display: block;
  max-width: 230px;
  padding: 0;
  overflow: hidden;
  border: 0;
  outline: 0;
  background: transparent;
  color: #dfe5ff;
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 10px;
  font-weight: 650;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
}

.license-link:hover {
  color: #8998ff;
  text-decoration: underline;
}

.danger-outline {
  border-color: rgba(255,107,121,.22);
  color: #ff9aa5;
}

.danger-outline:hover {
  border-color: rgba(255,107,121,.4);
  background: rgba(255,107,121,.08);
  color: #ffb3bb;
}

.muted-action {
  color: var(--muted-2);
  font-size: 10px;
}

