:root {
  --bg-0: #f6fbff;
  --bg-1: #e9f5f8;
  --ink-0: #0f172a;
  --ink-1: #334155;
  --ink-soft: #64748b;
  --line: #cbd5e1;
  --surface: rgba(255, 255, 255, 0.84);
  --surface-strong: #ffffff;
  --brand: #0f766e;
  --brand-strong: #0b5f59;
  --accent: #f97316;
  --ok: #0f9d6e;
  --warn: #d9480f;
  --danger: #b42318;
  --radius-xl: 20px;
  --radius-lg: 14px;
  --shadow: 0 18px 36px rgba(15, 23, 42, 0.08);
  --mono: "JetBrains Mono", "Cascadia Code", "Consolas", monospace;
  --sans: "Noto Sans SC", "Microsoft YaHei", "PingFang SC", sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: var(--sans);
  color: var(--ink-0);
  background: linear-gradient(170deg, var(--bg-0), var(--bg-1));
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.bg-shape {
  position: fixed;
  z-index: -1;
  border-radius: 999px;
  filter: blur(0.5px);
  pointer-events: none;
}

.shape-a {
  width: 280px;
  height: 280px;
  top: -80px;
  right: -70px;
  background: radial-gradient(circle at 35% 35%, rgba(15, 118, 110, 0.35), rgba(15, 118, 110, 0.06));
}

.shape-b {
  width: 240px;
  height: 240px;
  left: -100px;
  bottom: 8vh;
  background: radial-gradient(circle at 50% 50%, rgba(249, 115, 22, 0.25), rgba(249, 115, 22, 0.05));
}

.app-shell {
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: 18px 14px 38px;
}

.panel {
  background: var(--surface);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
}

.hidden {
  display: none !important;
}

.small-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(15, 118, 110, 0.1);
  color: var(--brand-strong);
  font-size: 12px;
  letter-spacing: 0.08em;
  font-family: var(--mono);
}

.login-panel {
  margin-top: max(10vh, 40px);
  padding: 24px 20px;
}

.login-head h1 {
  margin: 10px 0 10px;
  font-size: clamp(28px, 6vw, 36px);
  line-height: 1.08;
}

.login-head p {
  margin: 0;
  color: var(--ink-1);
  line-height: 1.6;
}

.login-form {
  margin-top: 20px;
  display: grid;
  gap: 10px;
}

.login-form label {
  font-size: 14px;
  color: var(--ink-1);
  font-weight: 600;
}

.login-form input {
  min-height: 46px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface-strong);
  font-size: 16px;
  color: var(--ink-0);
}

.login-form input:focus {
  border-color: var(--brand);
  outline: 3px solid rgba(15, 118, 110, 0.18);
}

button {
  min-height: 44px;
  border: none;
  border-radius: 12px;
  padding: 10px 16px;
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(120deg, var(--brand), #149d93);
  transition: transform 0.2s ease, box-shadow 0.25s ease, opacity 0.2s ease;
  cursor: pointer;
}

button:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 18px rgba(15, 118, 110, 0.25);
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

button:focus-visible {
  outline: 3px solid rgba(249, 115, 22, 0.35);
  outline-offset: 2px;
}

button.ghost {
  color: var(--brand-strong);
  background: rgba(15, 118, 110, 0.08);
}

.status-text {
  min-height: 24px;
  margin: 10px 0 0;
  color: var(--ink-1);
}

.status-text.error {
  color: var(--danger);
}

.dashboard-panel {
  padding: 14px;
}

.module-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.module-tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 10px 16px;
  border-radius: 999px;
  background: rgba(15, 118, 110, 0.08);
  color: var(--brand-strong);
  box-shadow: none;
}

.module-tab.is-active {
  color: #fff;
  background: linear-gradient(120deg, var(--brand), #149d93);
  box-shadow: 0 10px 18px rgba(15, 118, 110, 0.22);
}

.module-panel {
  margin-top: 14px;
  display: grid;
  gap: 14px;
}

.hero-card {
  display: grid;
  gap: 16px;
  padding: 18px;
  background: linear-gradient(140deg, rgba(15, 118, 110, 0.12), rgba(255, 255, 255, 0.8));
  border-radius: var(--radius-lg);
  border: 1px solid rgba(15, 118, 110, 0.16);
}

.hero-card h2 {
  margin: 10px 0 8px;
  font-size: clamp(25px, 5vw, 34px);
}

.hero-card p {
  margin: 0;
  color: var(--ink-1);
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.sync-text {
  font-family: var(--mono);
  color: var(--ink-soft);
  font-size: 12px;
}

.kpi-grid {
  display: grid;
  gap: 10px;
  margin-top: 14px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.kpi-card {
  padding: 14px 12px;
  background: var(--surface-strong);
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.3);
}

.kpi-card h3 {
  margin: 0 0 6px;
  font-size: 13px;
  color: var(--ink-1);
}

.kpi-number {
  margin: 0;
  font-size: 26px;
  font-family: var(--mono);
  letter-spacing: 0.02em;
}

.kpi-alert {
  border-color: rgba(217, 72, 15, 0.32);
}

.owner-toolbar {
  margin-top: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(148, 163, 184, 0.25);
}

.owner-toolbar label {
  font-size: 13px;
  color: var(--ink-1);
  font-weight: 600;
}

.owner-toolbar select {
  min-height: 40px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
  padding: 8px 10px;
  font-size: 14px;
  color: var(--ink-0);
}

.content-grid {
  margin-top: 14px;
  display: grid;
  gap: 12px;
}

.content-card {
  padding: 14px;
  border-radius: var(--radius-lg);
  background: var(--surface-strong);
  border: 1px solid rgba(148, 163, 184, 0.24);
}

.card-title-row h3 {
  margin: 0;
  font-size: 18px;
}

.card-title-row p {
  margin: 6px 0 0;
  color: var(--ink-soft);
  font-size: 13px;
}

.device-list,
.alert-list {
  margin-top: 12px;
  display: grid;
  gap: 10px;
}

.empty-state {
  padding: 12px;
  border-radius: 10px;
  border: 1px dashed rgba(148, 163, 184, 0.5);
  color: var(--ink-soft);
  font-size: 14px;
}

.device-card {
  border: 1px solid rgba(148, 163, 184, 0.3);
  border-radius: 12px;
  background: #fff;
  overflow: hidden;
}

.device-head {
  display: grid;
  gap: 8px;
  padding: 12px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.22);
}

.device-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

.device-title-main {
  display: inline-flex;
  align-items: center;
  min-width: 0;
  gap: 8px;
}

.status-dot {
  flex: 0 0 auto;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #cbd5e1;
}

.status-dot.online {
  background: var(--ok);
  box-shadow: 0 0 0 6px rgba(15, 157, 110, 0.12);
}

.device-name {
  margin: 0;
  min-width: 0;
  font-size: 16px;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.hardware-metrics {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  margin-left: auto;
  gap: 6px;
}

.hardware-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 4px 8px;
  border: 0;
  border-radius: 999px;
  background: rgba(37, 99, 235, 0.08);
  color: #1d4ed8;
  font-size: 11px;
  font-family: var(--mono);
  white-space: nowrap;
}

.hardware-pill.warn {
  background: rgba(217, 72, 15, 0.12);
  color: var(--warn);
}

.hardware-detail-btn {
  cursor: pointer;
}

.hardware-detail-btn:hover {
  filter: brightness(0.96);
}

.hardware-detail-btn:focus-visible {
  outline: 2px solid rgba(217, 72, 15, 0.35);
  outline-offset: 2px;
}

.device-owner {
  margin: 0;
  color: var(--ink-soft);
  font-size: 13px;
}

.metric-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(15, 118, 110, 0.1);
  color: var(--brand-strong);
  font-size: 12px;
  font-family: var(--mono);
}

.tag.warn {
  background: rgba(217, 72, 15, 0.12);
  color: var(--warn);
}

.tag-link {
  text-decoration: none;
  cursor: pointer;
}

.tag-link:hover {
  filter: brightness(0.96);
}

.tag-link:focus-visible {
  outline: 2px solid rgba(217, 72, 15, 0.35);
  outline-offset: 2px;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 0;
  table-layout: fixed;
}

thead th {
  text-align: left;
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-soft);
  border-bottom: 1px solid rgba(148, 163, 184, 0.25);
  padding: 6px 8px;
  white-space: normal;
  word-break: break-word;
}

tbody td {
  font-size: 13px;
  color: var(--ink-1);
  border-bottom: 1px solid rgba(226, 232, 240, 0.7);
  padding: 6px 8px;
  white-space: normal;
  word-break: break-word;
}

thead th:nth-child(1),
tbody td:nth-child(1) {
  width: 34%;
}

thead th:nth-child(2),
tbody td:nth-child(2),
thead th:nth-child(3),
tbody td:nth-child(3),
thead th:nth-child(4),
tbody td:nth-child(4) {
  width: 22%;
}

tbody tr:last-child td {
  border-bottom: none;
}

.alert-item {
  border: 1px solid rgba(148, 163, 184, 0.26);
  border-radius: 12px;
  background: #fff;
  padding: 12px;
}

.latest-alert-wrap {
  border-style: dashed;
  border-color: rgba(15, 118, 110, 0.35);
}

.alert-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.history-toggle-btn {
  min-height: 34px;
  font-size: 12px;
  padding: 6px 10px;
}

.alert-summary-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.summary-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(15, 118, 110, 0.08);
  color: var(--brand-strong);
  font-size: 12px;
  font-weight: 700;
}

.summary-pill.warn {
  background: rgba(217, 72, 15, 0.12);
  color: var(--warn);
}

.latest-alert .alert-item {
  margin: 0;
}

.history-panel {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px dashed rgba(148, 163, 184, 0.4);
}

.alert-history-title {
  margin: 0 0 8px;
  font-size: 13px;
  color: var(--ink-soft);
}

.alert-history-list {
  display: grid;
  gap: 8px;
}

.alert-item.unacked {
  border-color: rgba(180, 35, 24, 0.34);
  box-shadow: 0 0 0 2px rgba(180, 35, 24, 0.08);
  animation: pulse-border 2s ease-in-out infinite;
}

.alert-item.focus-pulse {
  border-color: rgba(15, 118, 110, 0.42);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.16);
}

.alert-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: baseline;
}

.alert-head-main {
  min-width: 0;
}

.alert-device-badge {
  display: inline-flex;
  align-items: center;
  margin-bottom: 6px;
  padding: 4px 9px;
  border-radius: 999px;
  background: rgba(15, 118, 110, 0.1);
  color: var(--brand-strong);
  font-size: 12px;
  font-weight: 700;
}

.alert-title {
  margin: 0;
  font-size: 15px;
  font-weight: 800;
}

.alert-time {
  font-size: 12px;
  color: var(--ink-soft);
  font-family: var(--mono);
}

.alert-meta,
.alert-content {
  margin: 8px 0 0;
  font-size: 13px;
  color: var(--ink-1);
  line-height: 1.5;
}

.alert-meta {
  color: var(--ink-soft);
}

.alert-actions {
  margin-top: 10px;
}

.alert-tip {
  margin: 8px 0 0;
  color: var(--warn);
  font-size: 12px;
  line-height: 1.5;
}

.alert-actions button {
  min-height: 38px;
  padding: 8px 12px;
  font-size: 13px;
  background: linear-gradient(120deg, var(--accent), #fb8c36);
}

.reveal {
  animation: reveal-up 0.35s ease both;
}

@keyframes reveal-up {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pulse-border {
  0%,
  100% {
    box-shadow: 0 0 0 2px rgba(180, 35, 24, 0.08);
  }
  50% {
    box-shadow: 0 0 0 5px rgba(180, 35, 24, 0.12);
  }
}

@media (min-width: 980px) {
  .content-grid {
    grid-template-columns: 1.2fr 0.8fr;
    align-items: start;
  }
}

@media (max-width: 768px) {
  .app-shell {
    padding: 12px 10px 22px;
  }

  .dashboard-panel {
    padding: 10px;
  }

  .hero-card {
    padding: 14px;
  }

  .module-nav {
    gap: 8px;
  }

  .module-tab {
    flex: 1 1 calc(50% - 8px);
    justify-content: center;
  }

  .kpi-grid {
    grid-template-columns: 1fr;
  }

  .kpi-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
  }

  .kpi-number {
    font-size: 24px;
  }

  .hardware-metrics {
    width: 100%;
  }

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

  thead th,
  tbody td {
    padding: 5px 6px;
    font-size: 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}

.admin-panel {
  margin: 0;
}

.license-admin-layout {
  display: grid;
  grid-template-columns: minmax(260px, 320px) minmax(0, 1fr);
  gap: 16px;
  margin-top: 14px;
}

.license-form {
  display: grid;
  gap: 10px;
}

.license-form label {
  font-size: 14px;
  color: var(--ink-1);
  font-weight: 600;
}

.license-form input,
.license-form textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-strong);
  color: var(--ink-0);
  padding: 10px 12px;
  font-size: 14px;
}

.license-form textarea {
  min-height: 88px;
  resize: vertical;
}

.license-form-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.license-form-actions {
  display: flex;
  gap: 10px;
}

.license-table-wrap {
  min-width: 0;
}

.license-table-head {
  margin-bottom: 10px;
}

.license-table-head h4 {
  margin: 0 0 4px;
}

.license-table-head p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 13px;
}

.license-list {
  overflow: visible;
}

.license-card-list {
  display: grid;
  gap: 10px;
}

.license-list-item {
  padding: 14px;
  border: 1px solid rgba(203, 213, 225, 0.8);
  border-radius: 14px;
  background: #fff;
  display: grid;
  gap: 12px;
}

.license-list-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.license-customer-block,
.license-status-block {
  display: grid;
  gap: 6px;
}

.license-customer-block {
  min-width: 0;
  flex: 1 1 220px;
}

.license-status-block {
  flex: 0 0 auto;
  align-items: flex-start;
}

.license-customer-label {
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 700;
}

.license-customer-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--ink-0);
  overflow-wrap: anywhere;
}

.license-status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.license-status-badge.ok {
  color: var(--ok);
  background: rgba(15, 157, 110, 0.1);
}

.license-status-badge.warn {
  color: var(--warn);
  background: rgba(217, 72, 15, 0.12);
}

.license-status-badge.danger {
  color: var(--danger);
  background: rgba(180, 35, 24, 0.1);
}

.license-status-badge.muted {
  color: var(--ink-soft);
  background: rgba(148, 163, 184, 0.14);
}

.license-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.small-btn {
  min-height: 34px;
  padding: 6px 10px;
  font-size: 12px;
}

.danger-btn {
  color: var(--danger) !important;
  background: rgba(180, 35, 24, 0.08) !important;
}

.warn-btn {
  color: var(--warn) !important;
  background: rgba(217, 72, 15, 0.1) !important;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px 12px;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(4px);
}

.modal-card {
  width: min(900px, 100%);
  max-height: min(88vh, 820px);
  overflow: hidden;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 28px 60px rgba(15, 23, 42, 0.22);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 18px 14px;
  border-bottom: 1px solid rgba(203, 213, 225, 0.85);
}

.modal-head h3 {
  margin: 0;
}

.modal-head p {
  margin: 6px 0 0;
  color: var(--ink-soft);
  font-size: 13px;
}

.modal-close-btn {
  min-height: 38px;
}

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

.license-detail-grid {
  display: grid;
  gap: 14px;
}

.license-detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.license-detail-section {
  padding: 14px;
  border: 1px solid rgba(203, 213, 225, 0.8);
  border-radius: 14px;
  background: #fff;
}

.license-detail-section h4 {
  margin: 0 0 10px;
}

.license-detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.license-detail-meta span {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 6px 10px;
  border-radius: 10px;
  background: rgba(15, 118, 110, 0.08);
  color: var(--ink-1);
  font-size: 13px;
  line-height: 1.4;
}

.license-notes {
  white-space: pre-wrap;
  color: var(--ink-1);
  line-height: 1.6;
}

.license-device-list {
  display: grid;
  gap: 10px;
}

.license-device-card {
  border: 1px solid rgba(148, 163, 184, 0.28);
  border-radius: 12px;
  padding: 12px;
  background: rgba(248, 250, 252, 0.9);
}

.license-device-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.license-device-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-1);
}

.license-device-code {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--brand-strong);
  word-break: break-all;
}

.license-device-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

@media (max-width: 900px) {
  .license-admin-layout {
    grid-template-columns: 1fr;
  }

  .license-form-row {
    grid-template-columns: 1fr;
  }

  .modal-card {
    max-height: 92vh;
  }
}

@media (max-width: 640px) {
  .license-list-item {
    padding: 12px;
  }

  .license-list-head {
    flex-direction: column;
    align-items: flex-start;
  }

  .modal-head,
  .modal-body {
    padding: 14px;
  }

  .license-device-card-head {
    flex-direction: column;
    align-items: flex-start;
  }
}

