:root {
  color-scheme: light;
  --bg: #f4f6f5;
  --panel: #ffffff;
  --panel-soft: #f8faf9;
  --ink: #17201f;
  --muted: #667270;
  --line: #d8dfdc;
  --teal: #0f766e;
  --teal-dark: #115e59;
  --blue: #2f5f9e;
  --amber: #a96716;
  --green: #257443;
  --red: #a33a32;
  --shadow: 0 18px 38px rgba(23, 32, 31, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--bg);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 22px;
  line-height: 1.15;
}

h2 {
  font-size: clamp(24px, 3vw, 34px);
  line-height: 1.12;
}

h3 {
  font-size: 16px;
  line-height: 1.3;
}

.eyebrow {
  margin-bottom: 5px;
  color: var(--teal-dark);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

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

.login-box {
  width: min(100%, 420px);
  display: grid;
  gap: 16px;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.login-box label {
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.login-box input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--ink);
  background: #ffffff;
  font: inherit;
}

.login-box input:focus {
  outline: 3px solid rgba(15, 118, 110, 0.18);
  border-color: var(--teal);
}

.form-error {
  color: var(--red);
  font-size: 14px;
  font-weight: 700;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 24px;
  border-right: 1px solid var(--line);
  background: #ffffff;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: #ffffff;
  background: var(--teal-dark);
  font-size: 20px;
  font-weight: 850;
}

.tabs {
  display: grid;
  gap: 8px;
}

.tab {
  width: 100%;
  min-height: 58px;
  display: grid;
  justify-items: start;
  gap: 3px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--muted);
  background: transparent;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.tab span {
  color: var(--ink);
  font-weight: 800;
}

.tab small {
  font-size: 12px;
}

.tab:hover {
  border-color: var(--line);
  background: var(--panel-soft);
}

.tab.active {
  border-color: #b9d9d4;
  background: #e8f5f2;
}

.tab.active span {
  color: var(--teal-dark);
}

.button {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 13px;
  color: var(--ink);
  background: #ffffff;
  font: inherit;
  font-size: 14px;
  font-weight: 750;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
}

.button:hover {
  border-color: #a8b6b2;
}

.button.primary {
  color: #ffffff;
  border-color: var(--teal);
  background: var(--teal);
}

.button.ghost {
  color: var(--teal-dark);
  background: #eef7f5;
}

.button.full,
.logout {
  width: 100%;
}

.logout {
  margin-top: auto;
}

.content {
  min-width: 0;
  padding: 28px clamp(18px, 4vw, 42px) 52px;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(320px, 0.8fr);
  gap: 20px;
  align-items: stretch;
  margin-bottom: 22px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.hero p {
  max-width: 720px;
  margin-top: 10px;
  color: var(--muted);
  line-height: 1.6;
}

.hero-stats {
  display: grid;
  gap: 10px;
}

.hero-stats div {
  min-width: 0;
  display: grid;
  gap: 4px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.hero-stats span,
.muted-text,
.sync-badge,
.device-card span,
.status-card span,
dt {
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.hero-stats strong {
  overflow-wrap: anywhere;
  font-size: 14px;
}

.panel {
  display: none;
}

.panel.active {
  display: grid;
  gap: 20px;
}

.panel-heading,
.section-title {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
}

.section-title {
  margin-top: 8px;
}

.section-title p {
  color: var(--muted);
  font-size: 14px;
}

.route-grid,
.device-grid,
.mirror-grid,
.client-grid,
.link-list,
.trouble-grid,
.dns-grid,
.address-grid,
.status-grid,
.command-list {
  display: grid;
  gap: 14px;
}

.route-grid {
  grid-template-columns: repeat(auto-fit, minmax(245px, 1fr));
}

.route-card,
.download-card,
.client-card,
.link-card,
.notice,
.table-card,
.status-card,
.command-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.route-card {
  display: grid;
  gap: 14px;
  padding: 20px;
}

.route-card.recommended {
  border-top: 4px solid var(--teal);
}

.route-card p,
.client-card p,
.notice p {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.58;
}

.card-topline,
.action-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.card-topline {
  justify-content: space-between;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.pill {
  min-height: 26px;
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 12px;
  font-weight: 850;
}

.pill.green {
  color: var(--green);
  background: #e6f4ea;
}

.pill.amber {
  color: var(--amber);
  background: #fff3dc;
}

.pill.gray {
  color: #586461;
  background: #edf1ef;
}

.pill.blue {
  color: var(--blue);
  background: #e8effb;
}

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

.device-card {
  display: grid;
  gap: 8px;
  min-height: 132px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.device-card strong {
  line-height: 1.35;
}

.device-card a {
  align-self: end;
  color: var(--teal-dark);
  font-size: 14px;
  font-weight: 800;
  text-decoration: none;
}

.sync-badge {
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  border: 1px solid #b9d9d4;
  border-radius: 999px;
  padding: 5px 12px;
  color: var(--teal-dark);
  background: #e8f5f2;
}

.sync-badge.warning {
  color: var(--amber);
  border-color: #e8c889;
  background: #fff7e7;
}

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

.download-card header,
.link-card header,
.client-card header,
.command-card header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.download-card header p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.asset-list {
  display: grid;
  gap: 9px;
  padding: 14px 16px;
}

.asset-link {
  min-height: 44px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 11px;
  color: var(--ink);
  background: var(--panel-soft);
  text-decoration: none;
}

.asset-link:hover {
  border-color: #a8b6b2;
}

.asset-link span {
  overflow-wrap: anywhere;
  font-size: 13px;
  font-weight: 750;
}

.asset-link small {
  color: var(--muted);
  font-size: 12px;
}

.empty-state {
  display: grid;
  gap: 8px;
  padding: 18px;
  border: 1px dashed #d4b36f;
  border-radius: 8px;
  color: #6d4912;
  background: #fff8e7;
}

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

.client-card {
  display: grid;
}

.client-card > p,
.client-card dl,
.client-card .button {
  margin: 14px 16px 0;
}

.client-card .button {
  width: fit-content;
  margin-bottom: 16px;
}

.client-card header span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

dl {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr);
  gap: 9px 12px;
}

dd {
  margin: 0;
  overflow-wrap: anywhere;
  color: #34413f;
  font-size: 13px;
  line-height: 1.45;
}

.link-list,
.command-list {
  grid-template-columns: 1fr;
}

.link-card header p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.secret,
.codebox {
  display: block;
  min-height: 56px;
  margin: 0;
  padding: 14px 16px;
  overflow-x: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: #17302d;
  background: var(--panel-soft);
  border: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 13px;
  line-height: 1.5;
}

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

.notice,
.table-card {
  display: grid;
  gap: 10px;
  padding: 16px;
  border-top: 4px solid var(--blue);
}

.notice.good {
  border-top-color: var(--green);
}

.notice.warning {
  border-top-color: var(--amber);
}

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

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

.address {
  min-height: 40px;
  display: flex;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 13px;
  overflow-wrap: anywhere;
}

.status-card {
  display: grid;
  gap: 8px;
  padding: 16px;
}

.status-card span {
  width: fit-content;
  border-radius: 999px;
  padding: 4px 9px;
  color: var(--green);
  background: #e6f4ea;
}

.status-card p {
  color: var(--muted);
  font-size: 14px;
}

.command-card header h3 {
  min-width: 0;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  transform: translateY(20px);
  opacity: 0;
  pointer-events: none;
  border-radius: 8px;
  padding: 10px 14px;
  color: #ffffff;
  background: var(--teal-dark);
  box-shadow: var(--shadow);
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.visible {
  transform: translateY(0);
  opacity: 1;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

@media (max-width: 1040px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    padding: 16px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .tabs {
    grid-template-columns: repeat(5, minmax(140px, 1fr));
    overflow-x: auto;
  }

  .logout {
    width: fit-content;
    margin-top: 0;
  }

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

@media (max-width: 760px) {
  h1 {
    font-size: 20px;
  }

  h2 {
    font-size: 25px;
  }

  .content {
    padding: 18px 14px 36px;
  }

  .brand {
    align-items: flex-start;
  }

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

  .tab {
    min-width: 0;
  }

  .tab:last-child {
    grid-column: 1 / -1;
  }

  .hero,
  .route-card {
    padding: 18px;
  }

  .panel-heading,
  .section-title,
  .download-card header,
  .link-card header,
  .client-card header,
  .command-card header {
    align-items: stretch;
    flex-direction: column;
  }

  .route-grid,
  .device-grid,
  .mirror-grid,
  .client-grid,
  .trouble-grid,
  .dns-grid,
  .address-grid,
  .status-grid {
    grid-template-columns: 1fr;
  }

  .action-row .button {
    flex: 1 1 140px;
  }

  .asset-link {
    grid-template-columns: 1fr;
  }

  .button {
    white-space: normal;
  }
}
