:root {
  --bg-1: #070b13;
  --bg-2: #0f1828;
  --ink-dark: #e8eef8;
  --soft-dark: #93a7c3;
  --line-dark: rgba(148, 163, 184, 0.14);
  --glow: rgba(56, 217, 255, 0.2);
  --bg-light: #f6f8fb;
  --card: #ffffff;
  --ink: #13242c;
  --soft: #4f636b;
  --line: rgba(19, 36, 44, 0.12);
  --brand: #0a7a68;
  --brand-deep: #05594b;
  --shadow: 0 14px 30px rgba(18, 36, 40, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
  min-height: 100vh;
  font-family: "IBM Plex Sans", sans-serif;
}

/* Login page: match nexo.hk homepage style */
body[data-page="login"] {
  color: var(--ink-dark);
  background:
    radial-gradient(circle at 15% 20%, rgba(56, 217, 255, 0.14), transparent 40%),
    radial-gradient(circle at 85% 80%, rgba(56, 217, 255, 0.1), transparent 45%),
    linear-gradient(160deg, var(--bg-1), var(--bg-2));
}

body[data-page="login"]::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(var(--line-dark) 1px, transparent 1px),
    linear-gradient(90deg, var(--line-dark) 1px, transparent 1px);
  background-size: 42px 42px;
  opacity: 0.18;
  pointer-events: none;
  animation: grid-drift 28s linear infinite;
}

body[data-page="login"]::after {
  content: "";
  position: fixed;
  inset: -20%;
  pointer-events: none;
  background:
    radial-gradient(circle at 20% 30%, rgba(56, 217, 255, 0.16), transparent 38%),
    radial-gradient(circle at 80% 70%, rgba(56, 217, 255, 0.14), transparent 40%);
  filter: blur(24px);
  animation: glow-move 16s ease-in-out infinite alternate;
}

/* Internal monitor pages: white dashboard style */
body:not([data-page="login"]) {
  color: var(--ink);
  background:
    radial-gradient(circle at 8% 10%, rgba(10, 122, 104, 0.12), transparent 44%),
    radial-gradient(circle at 88% 6%, rgba(218, 127, 0, 0.09), transparent 38%),
    linear-gradient(120deg, var(--bg-light), #ffffff);
}

.bg-layer {
  position: fixed;
  inset: 0;
  z-index: -1;
}

.wrap {
  width: 100%;
  padding: 18px;
  max-width: 1400px;
  margin: 0 auto;
}

.page {
  width: 100%;
  max-width: none;
  margin: 0 auto;
  display: grid;
  gap: 1rem;
  animation: rise 500ms ease;
}

@keyframes rise {
  from {
    transform: translateY(12px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.center {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}

.hero {
  position: relative;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.content {
  max-width: 980px;
  text-align: center;
  display: grid;
  justify-items: center;
  gap: 18px;
  animation: rise 0.7s ease-out both;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 6;
}

.site-header {
  width: 100%;
  max-width: none;
  margin: 0 auto;
  padding: 1.25rem 1.2rem;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.8rem;
  align-items: center;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 6;
}

.brand {
  font-family: "Space Grotesk", sans-serif;
  font-weight: 700;
  letter-spacing: 0.03em;
}

body[data-page="login"] .brand {
  color: var(--soft-dark);
  text-transform: uppercase;
  font-size: 0.8rem;
  letter-spacing: 0.24em;
}

.brand-tag {
  display: inline-block;
  margin-bottom: 6px;
  font-size: 12px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--soft-dark);
}

nav {
  min-width: 0;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}

nav a {
  text-decoration: none;
  color: var(--soft);
  padding: 8px 10px;
  border-radius: 10px;
  white-space: nowrap;
}

nav a.active,
nav a:hover {
  background: rgba(10, 122, 104, 0.12);
  color: var(--brand-deep);
}

.nav-link {
  text-decoration: none;
  color: var(--soft);
  font-size: 0.92rem;
  padding: 0.5rem 0.72rem;
  border-radius: 999px;
}

.nav-link.active,
.nav-link:hover {
  color: var(--brand-deep);
  background: rgba(10, 122, 104, 0.12);
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
  box-shadow: var(--shadow);
}

body[data-page="login"] .card {
  background: rgba(12, 22, 38, 0.72);
  border: 0;
  box-shadow: none;
  backdrop-filter: blur(8px);
  text-align: center;
  display: grid;
  justify-items: center;
  gap: 12px;
  padding: 28px 24px;
}

.narrow {
  width: min(100%, 560px);
}

h1,
h2,
h3 {
  margin: 0 0 10px;
  font-family: "Space Grotesk", sans-serif;
}

.muted {
  color: var(--soft);
}

body[data-page="login"] .muted {
  color: var(--soft-dark);
  font-size: clamp(22px, 2.2vw, 42px);
  line-height: 1.6;
  margin: 0;
}

body[data-page="login"] .btn {
  min-width: 188px;
  height: 48px;
  font-size: 16px;
  line-height: normal;
  padding: 0 20px;
}

body[data-page="login"] #login-status {
  min-height: 28px;
  font-size: 14px;
  line-height: 1.5;
}

.slogan {
  margin: 0;
  font-family: "Space Grotesk", sans-serif;
  font-weight: 700;
  font-size: clamp(26px, 4.9vw, 72px);
  line-height: 1.06;
  letter-spacing: -0.02em;
}

.sub {
  margin: 0;
  max-width: 620px;
  color: var(--soft-dark);
  font-size: clamp(14px, 2vw, 18px);
  line-height: normal;
}

.subtle-note {
  margin: 4px 0 0;
  color: var(--soft-dark);
  font-size: 14px;
  line-height: 1.5;
  min-height: 22px;
}

.btn {
  background: linear-gradient(135deg, var(--brand), var(--brand-deep));
  color: #fff;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 10px 14px;
  cursor: pointer;
  font-weight: 600;
}

body[data-page="login"] .btn {
  background: linear-gradient(120deg, rgba(56, 217, 255, 0.26), rgba(56, 217, 255, 0.1));
  color: #d9f7ff;
  border-color: rgba(56, 217, 255, 0.5);
}

.btn.ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--ink);
}

.grid {
  display: grid;
  gap: 14px;
}

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

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

.kpi {
  font-size: clamp(24px, 2.2vw, 34px);
  font-weight: 700;
  font-family: "Space Grotesk", sans-serif;
}

.list a {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  text-decoration: none;
  color: var(--ink);
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  margin-bottom: 10px;
  background: #fff;
}

.panel {
  min-width: 0;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  border-radius: 16px;
  padding: 1.1rem;
}

.list a:hover {
  background: rgba(10, 122, 104, 0.07);
}

.table {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}

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

.table th,
.table td {
  border-bottom: 1px solid var(--line);
  padding: 10px 11px;
  text-align: left;
  white-space: nowrap;
  font-size: 13px;
}

.table th {
  color: var(--ink);
  background: #f2f6f8;
  position: sticky;
  top: 0;
  z-index: 1;
}

.userbox {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

#user-email {
  color: var(--soft);
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

canvas {
  width: 100% !important;
  height: auto !important;
  min-height: 240px;
  max-height: 300px;
}

@keyframes glow-move {
  from {
    transform: translate3d(-1.2%, -1%, 0) scale(1);
    opacity: 0.82;
  }
  to {
    transform: translate3d(1.4%, 1.2%, 0) scale(1.06);
    opacity: 1;
  }
}

@keyframes grid-drift {
  from {
    transform: translateY(0);
  }
  to {
    transform: translateY(42px);
  }
}

@media (max-width: 980px) {
  .kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .two {
    grid-template-columns: 1fr;
  }
  .topbar {
    flex-wrap: wrap;
    align-items: flex-start;
  }
  .site-header {
    grid-template-columns: 1fr;
    gap: 0.55rem;
  }
  nav {
    width: 100%;
    justify-content: flex-start;
  }
}

@media (max-width: 680px) {
  .wrap {
    padding: 12px;
  }
  .kpis {
    grid-template-columns: 1fr;
  }
  .card {
    padding: 13px;
  }
  .btn {
    width: 100%;
    justify-content: center;
  }
  body[data-page="login"] .btn {
    min-width: 0;
    width: 188px;
    font-size: 16px;
  }
  .slogan {
    font-size: clamp(26px, 9vw, 40px);
    line-height: 1.06;
  }
  .sub {
    font-size: clamp(14px, 4.5vw, 18px);
  }
  .userbox {
    width: 100%;
    justify-content: space-between;
  }
  #user-email {
    max-width: 58vw;
  }
  canvas {
    min-height: 210px;
  }
}
