:root {
  color-scheme: dark;
  --bg: #080f1f;
  --panel: #101a2c;
  --panel-2: #0d1727;
  --text: #e8f2ff;
  --muted: #9fb1c7;
  --line: #24344f;
  --accent: #5aa7ff;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --shadow: 0 20px 45px rgb(0 0 0 / 0.22);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: radial-gradient(circle at top left, rgb(90 167 255 / 0.16), transparent 32rem), var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.hidden {
  display: none !important;
}

.page-loading {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  color: var(--text);
}

.loading-spinner {
  width: 22px;
  height: 22px;
  border: 3px solid color-mix(in srgb, var(--accent) 20%, var(--line));
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: loading-spin 0.8s linear infinite;
}

@keyframes loading-spin {
  to {
    transform: rotate(360deg);
  }
}

button,
input,
select {
  font: inherit;
}

button,
.button {
  min-height: 40px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--accent);
  color: #06101f;
  font-weight: 800;
  cursor: pointer;
}

button.secondary {
  background: var(--panel-2);
  color: var(--text);
}

.pt-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 18px;
  align-items: center;
  padding: 12px 18px;
  background: rgb(8 15 31 / 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
}

.pt-brand a {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-size: 20px;
  text-decoration: none;
}

.pt-logo {
  display: grid;
  width: 54px;
  height: 28px;
  place-items: center;
  border-radius: 8px;
  background: #ffffff;
  color: #080f1f;
  font-size: 13px;
  font-weight: 950;
}

.pt-nav {
  display: flex;
  gap: 8px;
  overflow-x: auto;
}

.pt-nav button {
  flex: 0 0 auto;
  min-height: 34px;
  padding: 8px 12px;
  background: var(--panel-2);
  color: var(--text);
}

.pt-nav button.active {
  border-color: var(--accent);
  background: rgb(90 167 255 / 0.18);
  color: #dff0ff;
}

.pt-user {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.2;
}

.pt-user a {
  color: var(--accent);
  font-weight: 800;
}

main {
  width: min(100%, 1720px);
  margin: 0 auto;
  padding: 18px;
}

.pt-view {
  display: none;
}

.pt-view.active {
  display: grid;
  gap: 18px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(28px, 4vw, 46px);
}

h2 {
  font-size: 20px;
}

.hero-card,
.card,
.table-card {
  background: linear-gradient(180deg, rgb(255 255 255 / 0.04), transparent), var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
}

.hero-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 28px;
}

.hero-card p,
.pagehead p,
.card p,
.small {
  color: var(--muted);
}

.hero-actions,
.bigactions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

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

.stat-card {
  display: grid;
  justify-items: start;
  min-height: 130px;
  padding: 18px;
  background: var(--panel);
  color: var(--text);
  text-align: left;
}

.stat-card strong {
  font-size: 44px;
  line-height: 1;
}

.stat-card span {
  color: var(--muted);
}

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

.stat-card.available strong {
  color: var(--accent);
}

.stat-card.dangerstat strong {
  color: var(--danger);
}

.dashboard-panels {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(320px, 1fr);
  gap: 18px;
}

.card {
  padding: 18px;
}

.welcome-card .bigactions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 16px;
}

.welcome-card button {
  min-height: 64px;
}

.status-guide {
  display: grid;
  gap: 9px;
  margin-top: 12px;
}

.status-guide > div {
  display: grid;
  grid-template-columns: 110px 1fr;
  align-items: center;
}

.status {
  display: inline-flex;
  justify-content: center;
  min-width: 84px;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 900;
}

.status.available {
  background: #123a5d;
  color: #b8e4ff;
}

.status.in-use,
.status.active,
.status.confirmed {
  background: #16623e;
  color: #c9ffdf;
}

.status.faulty {
  background: #7f1d1d;
  color: #ffe1e1;
}

.status.reserved,
.status.proposed,
.status.standby {
  background: #9a630f;
  color: #fff0c8;
}

.pagehead {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
}

.search {
  display: grid;
  grid-template-columns: 1fr 120px;
  gap: 10px;
}

input,
select {
  min-height: 44px;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-2);
  color: var(--text);
}

.compact-filter {
  display: grid;
  gap: 6px;
  width: min(100%, 360px);
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.table-card {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.clickrow {
  cursor: pointer;
}

.clickrow:hover td {
  background: #1a2944;
}

.click-card {
  cursor: pointer;
  transition: border-color 0.12s ease, transform 0.12s ease;
}

.click-card:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}

.faulty-row td {
  background: rgb(191 24 50 / 0.28);
}

.selected-row td {
  background: rgb(90 167 255 / 0.18);
}

.colour {
  display: inline-flex;
  min-width: 68px;
  justify-content: center;
  padding: 6px 9px;
  border-radius: 9px;
  color: #ffffff;
  font-weight: 900;
}

.colour.blue { background: #0c4ba8; }
.colour.orange { background: #ff8a00; color: #111; }
.colour.green { background: #176e3b; }
.colour.brown { background: #67401f; }
.colour.red { background: #a8152c; }
.colour.violet { background: #6c36b8; }
.colour.aqua { background: #008c9a; }

.path-grid,
.search-results {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 16px;
}

.search-card ul {
  margin: 12px 0 0;
  padding-left: 18px;
  color: var(--muted);
}

.result-list {
  display: grid;
  gap: 8px;
  list-style: none;
  padding-left: 0 !important;
}

.result-button {
  width: 100%;
  justify-content: flex-start;
  background: var(--panel-2);
  color: var(--text);
  text-align: left;
}

.device-detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(300px, 0.6fr);
  gap: 16px;
}

.detail-card {
  align-content: start;
}

.detail-list {
  display: grid;
  gap: 10px;
  margin: 12px 0 0;
}

.detail-list div {
  display: grid;
  grid-template-columns: 130px 1fr;
  gap: 12px;
  align-items: start;
}

.detail-list dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.detail-list dd {
  margin: 0;
  color: var(--text);
  font-weight: 750;
}

.detail-actions {
  display: grid;
  grid-template-columns: 1fr;
  margin-top: 12px;
}

.back-button {
  width: max-content;
  margin-bottom: 12px;
}

.subpath-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.flowchart {
  display: flex;
  align-items: center;
  gap: 10px;
  overflow-x: auto;
}

.flow-node {
  min-width: 150px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel-2);
}

.flow-node.core-colour-card {
  color: #ffffff;
  font-weight: 900;
}

.flow-node.core-colour-card small,
.flow-node.core-colour-card strong {
  color: inherit;
}

.flow-node.core-colour-card.blue { background: #0c4ba8; }
.flow-node.core-colour-card.orange { background: #ff8a00; color: #111; }
.flow-node.core-colour-card.green { background: #176e3b; }
.flow-node.core-colour-card.brown { background: #67401f; }
.flow-node.core-colour-card.red { background: #a8152c; }
.flow-node.core-colour-card.violet { background: #6c36b8; }
.flow-node.core-colour-card.aqua { background: #008c9a; }

.flow-node small {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.flow-arrow {
  color: var(--accent);
  font-size: 24px;
  font-weight: 950;
}

@media (max-width: 900px) {
  .pt-header {
    grid-template-columns: 1fr;
  }

  .pt-user span {
    display: none;
  }

  main {
    padding: 12px;
  }

  .hero-card,
  .pagehead {
    display: grid;
  }

  .stats-grid,
  .dashboard-panels,
  .device-detail-grid,
  .welcome-card .bigactions,
  .search,
  .path-grid,
  .search-results {
    grid-template-columns: 1fr;
  }
}

/* Shared softer corner treatment. */
button,
input,
select,
.button,
.pt-nav button,
.status-pill {
  border-radius: 12px;
}

.page-loading,
.pt-logo,
.hero-card,
.pagehead,
.panel,
.card,
.stat-card,
.welcome-card,
.search-result,
.detail-card,
.path-card,
.flow-node {
  border-radius: 16px;
}

.avatar,
.device-icon,
.core-dot {
  border-radius: 14px;
}
