:root {
  color-scheme: light;
  --brand: #e5b77b;
  --brand-strong: #cd9758;
  --accent: #6db7d9;

  --bg: #f2f4f8;
  --bg-soft: #ffffff;
  --surface: #ffffffcc;
  --surface-solid: #ffffff;
  --surface-muted: #f6ebdb;

  --text: #1a2733;
  --text-muted: #536272;
  --line: #d9e1ea;
  --line-strong: #bcc8d4;

  --ok: #27b06f;
  --bad: #dc5d5d;
  --unknown: #788999;
  --resource-cpu: #2687d9;
  --resource-memory: #f7b93e;
  --resource-disk: #2f9fe4;
  --resource-good: #2eb67d;
  --resource-warn: #f6ba42;

  --link: #2b9fcd;
  --link-hover: #0f7ea8;

  --shadow-sm: 0 10px 22px rgba(26, 50, 75, 0.1);
  --shadow-lg: 0 26px 48px rgba(20, 39, 58, 0.14);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b1017;
  --bg-soft: #131d2a;
  --surface: #111a26d9;
  --surface-solid: #172231;
  --surface-muted: #243244;

  --text: #edf3f8;
  --text-muted: #9eb0c1;
  --line: #2b3c4f;
  --line-strong: #3e556f;

  --ok: #57d89a;
  --bad: #ff8f8f;
  --unknown: #c5b8a6;
  --resource-cpu: #4aa9ff;
  --resource-memory: #ffc85b;
  --resource-disk: #5bc0ff;
  --resource-good: #42cf98;
  --resource-warn: #ffc85b;

  --link: #86d9ff;
  --link-hover: #b7ecff;

  --shadow-sm: 0 10px 22px rgba(2, 8, 15, 0.45);
  --shadow-lg: 0 28px 54px rgba(1, 6, 12, 0.6);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  background:
    radial-gradient(90rem 44rem at -8% -12%, color-mix(in srgb, var(--brand) 60%, transparent), transparent 60%),
    radial-gradient(60rem 32rem at 100% 0%, color-mix(in srgb, var(--accent) 35%, transparent), transparent 66%),
    linear-gradient(150deg, var(--bg-soft), var(--bg));
  color: var(--text);
  font-family: "DM Sans", "Segoe UI", sans-serif;
  line-height: 1.45;
}

h1,
h2,
h3,
h4 {
  font-family: Outfit, "DM Sans", sans-serif;
  letter-spacing: -0.02em;
  margin: 0;
}

a {
  color: inherit;
}

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

.side-nav {
  position: sticky;
  top: 0;
  align-self: start;
  min-height: 100vh;
  border-right: 1px solid var(--line);
  padding: 1.1rem;
  background: color-mix(in srgb, var(--surface-solid) 92%, transparent);
  backdrop-filter: blur(12px);
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
}

.side-brand {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  text-decoration: none;
  padding: 0.65rem;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: linear-gradient(145deg, color-mix(in srgb, var(--surface-muted) 65%, var(--surface-solid)), var(--surface-solid));
}

.brand-logo {
  width: 44px;
  height: 44px;
  object-fit: contain;
  border-radius: 14px;
  box-shadow: var(--shadow-sm);
}

.side-brand span {
  display: grid;
  line-height: 1.18;
}

.side-brand strong {
  font-size: 1rem;
}

.side-brand small {
  color: var(--text-muted);
  font-size: 0.78rem;
}

.side-links {
  display: grid;
  gap: 0.45rem;
}

.side-links a {
  text-decoration: none;
  color: var(--text-muted);
  padding: 0.62rem 0.75rem;
  border: 1px solid transparent;
  border-radius: 12px;
  font-weight: 700;
  transition: all 0.16s ease;
}

.side-links a:hover,
.side-links a:focus-visible {
  color: var(--text);
  border-color: var(--line-strong);
  background: color-mix(in srgb, var(--brand) 16%, transparent);
}

.side-links a.active {
  color: #2a1d0f;
  border-color: color-mix(in srgb, var(--brand) 72%, var(--line));
  background: linear-gradient(135deg, color-mix(in srgb, var(--brand) 92%, #fff7e7), color-mix(in srgb, var(--brand) 65%, #efd1aa));
  box-shadow: 0 10px 18px rgba(128, 84, 38, 0.2);
}

:root[data-theme="dark"] .side-links a.active {
  color: #221809;
}

.side-actions {
  margin-top: auto;
  display: grid;
  gap: 0.5rem;
}

.wide {
  width: 100%;
}

.workspace {
  min-width: 0;
  padding: 1.1rem;
}

.workspace-header {
  margin-bottom: 1rem;
}

.workspace-title {
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 1rem 1.1rem;
  background: linear-gradient(145deg, color-mix(in srgb, var(--surface-solid) 88%, transparent), color-mix(in srgb, var(--surface-muted) 45%, var(--surface-solid)));
  box-shadow: var(--shadow-sm);
}

.workspace-kicker {
  margin: 0;
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--brand-strong);
}

.workspace-title h1 {
  margin: 0.35rem 0;
  font-size: clamp(1.45rem, 1.1rem + 1.2vw, 2.1rem);
}

.workspace-title p {
  margin: 0;
  color: var(--text-muted);
}

.container {
  max-width: none;
  width: 100%;
  margin: 0;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  backdrop-filter: blur(8px);
  box-shadow: var(--shadow-sm);
  padding: 0.95rem;
  margin-bottom: 0.95rem;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.7rem;
  margin-bottom: 0.7rem;
}

.panel-head p {
  margin: 0.25rem 0 0;
}

.filter-panel {
  background:
    linear-gradient(140deg, color-mix(in srgb, var(--surface-solid) 88%, transparent), color-mix(in srgb, var(--surface-muted) 58%, var(--surface-solid)));
}

.metric-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.75rem;
  margin-bottom: 0.95rem;
}

.metric-strip.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.metric-strip.five {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.client-insight-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.75rem;
  margin-bottom: 0.95rem;
}

.client-insight {
  margin-bottom: 0;
  padding: 0.82rem 0.92rem;
}

.client-insight-value {
  display: block;
  margin-top: 0.36rem;
  font-size: 1.42rem;
  font-weight: 800;
  line-height: 1.1;
}

.client-insight-value.time {
  font-size: 1rem;
  font-weight: 700;
}

.client-insight .muted {
  margin-top: 0.32rem;
  font-size: 0.82rem;
}

.metric-card {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 0.86rem 0.95rem;
  background:
    radial-gradient(65rem 24rem at 0 0, color-mix(in srgb, var(--brand) 22%, transparent), transparent 65%),
    linear-gradient(145deg, var(--surface-solid), color-mix(in srgb, var(--surface-muted) 52%, var(--surface-solid)));
  box-shadow: var(--shadow-sm);
}

.metric-label {
  display: block;
  font-size: 0.77rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.metric-value {
  display: block;
  margin-top: 0.4rem;
  font-size: clamp(1.4rem, 1rem + 1.2vw, 2.15rem);
  font-weight: 800;
  line-height: 1;
}

.bento-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 0.95rem;
}

.bento-grid > .panel {
  margin-bottom: 0;
}

.wide-panel {
  grid-column: span 12;
}

.chart-panel {
  grid-column: span 12;
  min-height: 420px;
}

.table-panel {
  grid-column: span 6;
}

.resources-overview-panel {
  margin-top: 0.95rem;
}

.resources-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.8rem;
}

.resource-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.8rem 0.75rem 0.72rem;
  background:
    radial-gradient(55rem 26rem at 0 0, color-mix(in srgb, var(--surface-muted) 45%, transparent), transparent 68%),
    linear-gradient(145deg, var(--surface-solid), color-mix(in srgb, var(--surface-muted) 40%, var(--surface-solid)));
}

.resource-card h3 {
  font-size: 1rem;
  margin-bottom: 0.22rem;
}

.resource-gauge {
  --value: 0;
  --gauge-color: var(--resource-cpu);
  position: relative;
  width: 100%;
  max-width: 240px;
  aspect-ratio: 2 / 1;
  margin: 0 auto;
  transition: opacity 0.2s ease;
}

.resource-gauge-svg {
  display: block;
  width: 100%;
  height: 100%;
}

.resource-gauge-track {
  fill: none;
  stroke: color-mix(in srgb, var(--line-strong) 68%, var(--surface-muted));
  stroke-width: 7;
  stroke-linecap: round;
  opacity: 0.95;
}

.resource-gauge-value-arc {
  fill: none;
  stroke: var(--gauge-color);
  stroke-width: 7;
  stroke-linecap: round;
  stroke-dasharray: 0 100;
  transition: stroke 0.25s ease;
}

.resource-gauge.is-empty .resource-gauge-value-arc {
  stroke: color-mix(in srgb, var(--line-strong) 70%, var(--surface-muted));
}

.resource-gauge-value {
  position: absolute;
  left: 50%;
  top: 67%;
  transform: translate(-50%, -50%);
  font-size: clamp(1.65rem, 1.15rem + 1.2vw, 2.25rem);
  font-weight: 800;
  line-height: 1;
  color: var(--text);
  transition: color 0.25s ease;
}

.resource-gauge-detail {
  margin: 0.2rem 0 0;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.84rem;
  font-weight: 600;
}

.chart-wrap {
  position: relative;
  height: 320px;
  width: 100%;
}

.range-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.42rem;
}

.range-group {
  margin-bottom: 0.6rem;
}

.filters,
.inline-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  align-items: end;
}

.panel > .filters {
  margin-bottom: 0.95rem;
}

.field-inline {
  display: grid;
  gap: 0.35rem;
  min-width: 220px;
}

.field-inline.is-hidden {
  display: none;
}

.filters label,
.inline-form label {
  color: var(--text-muted);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

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

input,
select,
textarea {
  min-height: 40px;
  border: 1px solid var(--line-strong);
  border-radius: 11px;
  padding: 0.55rem 0.72rem;
  background: var(--surface-solid);
  color: var(--text);
}

textarea {
  resize: vertical;
  min-height: 96px;
}

input::placeholder {
  color: color-mix(in srgb, var(--text-muted) 80%, transparent);
}

input:focus,
select:focus,
button:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--brand) 72%, transparent);
  outline-offset: 1px;
}

.btn {
  min-height: 40px;
  border-radius: 11px;
  padding: 0.55rem 0.88rem;
  border: 1px solid transparent;
  background: linear-gradient(145deg, color-mix(in srgb, var(--brand) 90%, #fff8ea), color-mix(in srgb, var(--brand) 68%, #f1d0a4));
  color: #2f2316;
  font-weight: 800;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.14s ease, filter 0.14s ease;
}

.btn:hover,
.btn:focus-visible {
  transform: translateY(-1px);
  filter: brightness(1.04);
}

.btn.ghost {
  background: color-mix(in srgb, var(--surface-solid) 84%, transparent);
  color: var(--text);
  border-color: var(--line-strong);
}

.btn.subtle {
  background: transparent;
  color: var(--text-muted);
  border-color: var(--line-strong);
}

.range-buttons .btn.active {
  background: linear-gradient(145deg, color-mix(in srgb, var(--brand) 84%, #fff5e6), color-mix(in srgb, var(--brand) 64%, #eec38e));
  border-color: color-mix(in srgb, var(--brand) 70%, var(--line-strong));
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 14px;
}

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

thead {
  background: color-mix(in srgb, var(--surface-muted) 64%, var(--surface-solid));
}

th,
td {
  white-space: nowrap;
  text-align: left;
  border-bottom: 1px solid var(--line);
  padding: 0.62rem 0.62rem;
  font-size: 0.93rem;
}

.compact-monitor-table th,
.compact-monitor-table td {
  padding: 0.42rem 0.52rem;
  font-size: 0.83rem;
  vertical-align: middle;
}

.incident-compact-table th,
.incident-compact-table td {
  padding: 0.46rem 0.58rem;
  font-size: 0.86rem;
  line-height: 1.28;
  vertical-align: top;
}

.incident-compact-table td .muted {
  font-size: 0.79rem;
  line-height: 1.2;
}

.node-col {
  min-width: 280px;
}

.compact-node-name {
  font-size: 0.93rem;
}

.inline-maint {
  margin-left: 0.35rem;
}

.compact-meta {
  display: block;
  color: var(--text-muted);
  font-size: 0.72rem;
  line-height: 1.25;
  margin-top: 0.1rem;
}

.compact-time {
  font-size: 0.78rem;
}

.metric-bar {
  position: relative;
  width: 110px;
  height: 7px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--line) 75%, var(--surface-solid));
  overflow: hidden;
}

.metric-bar > span {
  display: block;
  height: 100%;
}

.metric-cpu > span {
  background: #4fa3ff;
}

.metric-disk > span {
  background: #f39c4a;
}

.metric-stacked {
  display: flex;
}

.metric-stacked > span {
  height: 100%;
}

.metric-stacked .segment-ram {
  background: #22a06b;
}

.metric-stacked .segment-swap {
  background: #8675ff;
}

.metric-rx > span {
  background: #1fa2ff;
}

.metric-tx > span {
  background: #935df7;
}

.compact-actions .btn {
  min-height: 30px;
  padding: 0.3rem 0.58rem;
  border-radius: 9px;
  font-size: 0.78rem;
}

.metric-cell {
  cursor: default;
}

.network-cell {
  min-width: 130px;
}

.metric-duo {
  display: grid;
  gap: 3px;
}

.row-menu {
  position: relative;
}

.row-menu > summary {
  list-style: none;
  cursor: pointer;
}

.row-menu > summary::-webkit-details-marker {
  display: none;
}

.row-menu[open] > summary {
  border-color: color-mix(in srgb, var(--brand) 70%, var(--line-strong));
}

.row-menu-list {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  z-index: 20;
  min-width: 172px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-solid);
  box-shadow: var(--shadow-sm);
  padding: 0.35rem;
  display: grid;
  gap: 0.32rem;
}

.row-menu-list .btn {
  width: 100%;
}

[data-tooltip] {
  cursor: default;
}

.app-tooltip {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 2000;
  pointer-events: none;
  max-width: 340px;
  padding: 0.42rem 0.55rem;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: color-mix(in srgb, var(--surface-solid) 96%, #ffffff);
  color: var(--text);
  box-shadow: var(--shadow-sm);
  font-size: 0.75rem;
  line-height: 1.35;
  opacity: 0;
  transform: translate(-9999px, -9999px);
  transition: opacity 0.12s ease;
}

.app-tooltip.visible {
  opacity: 1;
}

.service-create-form {
  display: grid;
  gap: 0.55rem;
}

.service-create-grid {
  display: grid;
  gap: 0.55rem;
}

.service-create-grid-6 {
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

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

.service-create-actions {
  display: flex;
  justify-content: flex-start;
}

tbody tr:nth-child(even) {
  background: color-mix(in srgb, var(--surface-muted) 40%, transparent);
}

tbody tr:hover {
  background: color-mix(in srgb, var(--brand) 14%, transparent);
}

.server-link {
  color: var(--link);
  text-decoration: none;
  font-weight: 800;
  border-bottom: 1px solid color-mix(in srgb, var(--link) 44%, transparent);
}

.server-link:hover,
.server-link:focus-visible {
  color: var(--link-hover);
  border-bottom-color: color-mix(in srgb, var(--link-hover) 52%, transparent);
}

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  border: 1px solid;
  padding: 0.22rem 0.52rem;
  font-size: 0.75rem;
  font-weight: 800;
}

.pill.online {
  color: var(--ok);
  border-color: color-mix(in srgb, var(--ok) 42%, var(--line));
  background: color-mix(in srgb, var(--ok) 16%, transparent);
}

.pill.offline {
  color: var(--bad);
  border-color: color-mix(in srgb, var(--bad) 42%, var(--line));
  background: color-mix(in srgb, var(--bad) 16%, transparent);
}

.pill.unknown {
  color: var(--unknown);
  border-color: color-mix(in srgb, var(--unknown) 34%, var(--line));
  background: color-mix(in srgb, var(--unknown) 14%, transparent);
}

.pill.info {
  color: #3f87d6;
  border-color: color-mix(in srgb, #3f87d6 40%, var(--line));
  background: color-mix(in srgb, #3f87d6 16%, transparent);
}

.pill.warning {
  color: #b87b1f;
  border-color: color-mix(in srgb, #b87b1f 42%, var(--line));
  background: color-mix(in srgb, #b87b1f 16%, transparent);
}

.pill.maintenance {
  color: #a16206;
  border-color: color-mix(in srgb, #a16206 42%, var(--line));
  background: color-mix(in srgb, #f59e0b 18%, transparent);
}

.pill.critical {
  color: var(--bad);
  border-color: color-mix(in srgb, var(--bad) 42%, var(--line));
  background: color-mix(in srgb, var(--bad) 16%, transparent);
}

.pill.edge {
  color: #7a5a25;
  border-color: color-mix(in srgb, #7a5a25 38%, var(--line));
  background: color-mix(in srgb, var(--brand) 24%, transparent);
}

.detail-hero {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.8rem;
}

.detail-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

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

.phase-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-bottom: 0.55rem;
}

.phase-chip {
  display: inline-flex;
  align-items: center;
  padding: 0.28rem 0.56rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  border: 1px solid var(--line);
  color: var(--text-muted);
  background: color-mix(in srgb, var(--surface-muted) 72%, var(--surface-solid));
}

.phase-chip.done {
  color: var(--text);
  border-color: color-mix(in srgb, var(--line-strong) 68%, var(--line));
}

.phase-chip.active {
  border-color: color-mix(in srgb, var(--brand) 55%, var(--line));
  background: color-mix(in srgb, var(--brand) 18%, var(--surface-muted));
}

.kv {
  list-style: none;
  padding: 0;
  margin: 0;
}

.kv li {
  display: flex;
  justify-content: space-between;
  gap: 0.85rem;
  border-bottom: 1px dashed var(--line);
  padding: 0.44rem 0;
}

.kv span {
  color: var(--text-muted);
  font-weight: 600;
}

.kv strong {
  text-align: right;
}

.node-health-summary {
  margin-bottom: 0.85rem;
}

.notice {
  margin-bottom: 0.9rem;
  border: 1px solid color-mix(in srgb, var(--brand) 62%, var(--line));
  border-radius: 12px;
  padding: 0.72rem 0.84rem;
  background: color-mix(in srgb, var(--brand) 18%, transparent);
}

.maintenance-banner {
  border-color: color-mix(in srgb, #f59e0b 56%, var(--line));
  background:
    linear-gradient(
      140deg,
      color-mix(in srgb, #f59e0b 18%, var(--surface-solid)),
      color-mix(in srgb, #f59e0b 10%, var(--surface-muted))
    );
}

.maintenance-banner-title {
  margin: 0;
  font-size: 0.88rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #8a5400;
}

.maintenance-banner-note {
  margin: 0.35rem 0 0;
  color: var(--text);
}

.maintenance-icon {
  display: inline-block;
  margin-right: 0.38rem;
  font-weight: 900;
}

.maintenance-card {
  border: 1px solid color-mix(in srgb, #f59e0b 50%, var(--line));
  border-radius: 12px;
  background: color-mix(in srgb, #f59e0b 8%, var(--surface-muted));
  padding: 0.58rem;
}

.maintenance-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
}

.maintenance-card-head h3 {
  font-size: 1rem;
}

.maintenance-card-fields {
  margin-top: 0.55rem;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.48rem;
}

.maintenance-card-fields[hidden] {
  display: none;
}

.chart-inline-meta {
  margin: 0.5rem 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.9rem;
  color: var(--text-muted);
  font-size: 0.95rem;
  line-height: 1.35;
  font-weight: 600;
}

.chart-inline-meta strong {
  color: var(--text);
  font-size: 0.96rem;
  font-weight: 800;
}

.maintenance-toggle-inline {
  min-width: 180px;
}

.maintenance-extra-fields {
  min-width: 300px;
}

.settings-field.is-disabled {
  opacity: 0.5;
}

.api-key-create-panel {
  overflow: hidden;
}

.api-key-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
  gap: 0.85rem;
  align-items: start;
}

.api-key-form {
  display: grid;
  gap: 0.55rem;
}

.api-key-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding-top: 0.15rem;
}

.api-key-help {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: color-mix(in srgb, var(--surface-muted) 76%, var(--surface-solid));
  padding: 0.7rem 0.8rem;
}

.api-key-help h3 {
  margin-bottom: 0.28rem;
}

.api-scope-list {
  margin: 0.35rem 0 0.45rem;
  padding-left: 1rem;
}

.api-scope-list li {
  margin-bottom: 0.28rem;
}

.api-key-created {
  display: inline-block;
  margin-top: 0.38rem;
  max-width: 100%;
  word-break: break-all;
}

.clickable-row {
  cursor: pointer;
}

.clickable-row:hover td,
.clickable-row:focus-visible td {
  background: color-mix(in srgb, var(--brand) 10%, transparent);
}

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

.error {
  color: var(--bad);
  font-weight: 700;
}

code {
  font-family: "JetBrains Mono", "SFMono-Regular", Consolas, monospace;
  font-size: 0.9em;
  background: color-mix(in srgb, var(--surface-muted) 65%, var(--surface-solid));
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.08rem 0.28rem;
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1rem;
}

.login-layout {
  width: min(980px, 100%);
  min-height: min(560px, calc(100vh - 2.5rem));
  display: grid;
  grid-template-columns: 0.9fr 1fr;
  border-radius: 24px;
  overflow: hidden;
  border: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
  background: var(--surface-solid);
}

.login-brand-panel {
  padding: 1.75rem;
  background:
    radial-gradient(60rem 24rem at 0 0, color-mix(in srgb, var(--brand) 62%, transparent), transparent 62%),
    radial-gradient(45rem 20rem at 100% 100%, color-mix(in srgb, var(--accent) 44%, transparent), transparent 68%),
    linear-gradient(145deg, color-mix(in srgb, var(--surface-muted) 78%, var(--surface-solid)), var(--surface-solid));
  display: grid;
  align-content: center;
  justify-items: start;
  gap: 0.7rem;
}

.login-logo {
  width: 132px;
  height: 132px;
  object-fit: contain;
  border-radius: 20px;
  box-shadow: var(--shadow-sm);
}

.login-brand-name {
  margin: 0;
  font-size: clamp(1.5rem, 1.1rem + 0.9vw, 2rem);
  font-weight: 800;
  letter-spacing: 0.01em;
  color: var(--text);
  line-height: 1.08;
}

.login-form-panel {
  padding: 1.75rem;
  display: grid;
  align-content: center;
}

.login-form-panel h2 {
  margin-bottom: 0.35rem;
}

.login-form-panel form {
  margin-top: 0.8rem;
  display: grid;
  gap: 0.5rem;
}

.login-form-panel label {
  color: var(--text-muted);
  font-size: 0.84rem;
  font-weight: 700;
}

.settings-form {
  display: grid;
  gap: 0.55rem;
}

.settings-section {
  padding: 0.6rem 0.65rem;
}

.settings-section-head {
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  cursor: pointer;
  user-select: none;
  margin-bottom: 0.3rem;
}

.settings-section-head::-webkit-details-marker {
  display: none;
}

.settings-section-head h2 {
  font-size: 1rem;
}

.settings-section-head p {
  margin: 0.1rem 0 0;
}

.settings-section:not([open]) .settings-grid {
  display: none;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.45rem 0.6rem;
}

.settings-field {
  display: grid;
  gap: 0.18rem;
  padding: 0.45rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-muted);
}

.settings-field label {
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.settings-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.55rem;
}

.settings-toggle-row label {
  margin: 0;
}

.toggle-control {
  position: relative;
  width: 46px;
  min-width: 46px;
  height: 26px;
  display: inline-flex;
  align-items: center;
  cursor: pointer;
}

.toggle-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  opacity: 0;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  cursor: pointer;
  z-index: 2;
}

.toggle-track {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: color-mix(in srgb, var(--unknown) 35%, var(--surface-solid));
  border: 1px solid var(--line-strong);
  transition: background 0.16s ease, border-color 0.16s ease;
}

.toggle-track::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  border-radius: 999px;
  background: var(--surface-solid);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  transition: transform 0.16s ease;
}

.toggle-input:checked + .toggle-track {
  background: color-mix(in srgb, var(--ok) 45%, var(--surface-solid));
  border-color: color-mix(in srgb, var(--ok) 60%, var(--line-strong));
}

.toggle-input:checked + .toggle-track::after {
  transform: translateX(20px);
}

.toggle-input:focus-visible + .toggle-track {
  outline: 2px solid color-mix(in srgb, var(--brand) 72%, transparent);
  outline-offset: 2px;
}

.settings-meta {
  margin: 0;
  font-size: 0.68rem;
}

.settings-actions .row-actions {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.settings-actions {
  position: sticky;
  bottom: 0.45rem;
  z-index: 8;
  backdrop-filter: blur(8px);
}

.chart-panel.is-loading .chart-wrap::after {
  content: "Loading...";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-weight: 700;
  color: var(--text-muted);
  background: color-mix(in srgb, var(--surface-solid) 84%, transparent);
}

@media (max-width: 1220px) {
  .layout {
    grid-template-columns: 235px minmax(0, 1fr);
  }

  .wide-panel {
    grid-column: span 12;
  }

  .chart-panel {
    grid-column: span 12;
  }

  .table-panel {
    grid-column: span 6;
  }

  .service-create-grid-6 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

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

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

  .side-nav {
    position: static;
    min-height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .side-actions {
    margin-top: 0;
  }

  .workspace {
    padding-top: 0.85rem;
  }

  .metric-strip,
  .metric-strip.three,
  .metric-strip.five,
  .client-insight-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .chart-panel,
  .table-panel {
    grid-column: span 12;
  }

  .resources-grid {
    grid-template-columns: 1fr;
  }

  .detail-grid {
    grid-template-columns: 1fr;
  }

  .settings-grid {
    grid-template-columns: 1fr;
  }

  .maintenance-card-fields {
    grid-template-columns: 1fr;
  }

  .service-create-grid-6,
  .service-create-grid-4 {
    grid-template-columns: 1fr;
  }

  .login-layout {
    grid-template-columns: 1fr;
  }

  .api-key-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 620px) {
  .workspace,
  .side-nav {
    padding: 0.75rem;
  }

  .panel,
  .workspace-title {
    border-radius: 14px;
  }

  .metric-strip,
  .metric-strip.three,
  .metric-strip.five,
  .client-insight-grid {
    grid-template-columns: 1fr;
  }

  .chart-wrap {
    height: 300px;
  }

  .filters,
  .inline-form {
    flex-direction: column;
    align-items: stretch;
  }

  .field-inline {
    min-width: 0;
  }

  .btn,
  input,
  select {
    width: 100%;
  }

  .detail-hero {
    flex-direction: column;
    align-items: flex-start;
  }
}
