:root {
  --bg: #f3f5f8;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --danger: #dc2626;
  --border: #d1d5db;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: radial-gradient(circle at top, #e7efff 0%, var(--bg) 42%);
  min-height: 100vh;
}

.page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.card {
  width: 100%;
  max-width: 420px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  box-shadow: 0 10px 40px rgba(15, 23, 42, 0.08);
}

h1 {
  margin: 0 0 8px 0;
  font-size: 20px;
}

.title-with-icon {
  display: flex;
  align-items: center;
  gap: 10px;
}

.title-with-icon i {
  color: var(--primary);
  font-size: 16px;
}

.subtitle {
  margin: 0 0 20px 0;
  color: var(--muted);
  font-size: 13px;
}

label {
  display: block;
  margin-bottom: 8px;
  font-weight: 600;
  font-size: 13px;
}

.field {
  margin-bottom: 16px;
}

.input-with-icon {
  position: relative;
}

.input-with-icon i {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}

input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 11px 12px 11px 38px;
  font-size: 13px;
}

input:focus {
  outline: none;
  border-color: var(--primary);
}

.input-with-icon:focus-within i {
  color: var(--primary);
}

button {
  width: 100%;
  border: 0;
  border-radius: 8px;
  padding: 11px 14px;
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  background: var(--primary);
  cursor: pointer;
}

button:hover {
  background: var(--primary-hover);
}

button:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

.action-row {
  display: flex;
  gap: 10px;
}

.action-row button {
  flex: 1;
}

.btn-secondary {
  background: #475569;
}

.btn-secondary:hover {
  background: #334155;
}

.status-message {
  min-height: 20px;
  margin-top: 12px;
  font-size: 12px;
}

.status-message.error {
  color: var(--danger);
}

.status-message.info {
  color: var(--muted);
}

.main {
  max-width: 860px;
  margin: 40px auto;
  padding: 0 24px;
}

body[data-page] {
  background: linear-gradient(145deg, #e2e8f0 0%, #f8fafc 52%, #dbeafe 100%);
}

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

.sidebar {
  background: linear-gradient(180deg, #f8fafc 0%, #eef2ff 100%);
  color: #334155;
  border-right: 1px solid #dbe2ee;
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.sidebar-top {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.logo-frame {
  min-height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.logo-frame img {
  max-width: 100%;
  max-height: 52px;
  object-fit: contain;
}

.tenant-meta {
  background: #e2e8f0;
  border-radius: 10px;
  padding: 10px 12px;
}

.tenant-label {
  color: #64748b;
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.tenant-value {
  font-size: 15px;
  font-weight: 700;
  color: #0f172a;
  margin-top: 2px;
}

.menu {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.menu-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  color: #475569;
  text-decoration: none;
  font-weight: 600;
  font-size: 13px;
  transition: background-color 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.menu-link:hover {
  color: #0f172a;
  background: #e2e8f0;
  transform: translateX(2px);
}

.menu-link.active {
  color: #ffffff;
  background: linear-gradient(90deg, #2563eb, #1d4ed8);
  box-shadow: 0 8px 24px rgba(37, 99, 235, 0.35);
}

.menu-link i {
  width: 20px;
  text-align: center;
}

.logout-btn {
  margin-top: auto;
  width: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: #fee2e2;
  border: 1px solid #fecaca;
  color: #b91c1c;
  font-size: 13px;
}

.logout-btn:hover {
  background: rgba(239, 68, 68, 0.3);
}

.content {
  padding: 28px clamp(20px, 4vw, 48px);
}

.content-header h1 {
  margin: 0;
  font-size: clamp(22px, 2.8vw, 28px);
}

.content-header p {
  margin: 8px 0 0;
  color: #475569;
  font-size: 13px;
}

.panel {
  margin-top: 20px;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid #cbd5e1;
  border-radius: 14px;
  padding: 20px;
  box-shadow: 0 14px 34px rgba(15, 23, 42, 0.08);
}

.panel h2 {
  margin-top: 0;
  font-size: 17px;
}

.panel p {
  font-size: 13px;
}

.hidden {
  display: none !important;
}

.content-header-inline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.header-actions {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.auto-refresh-switch {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 999px;
  background: #ffffff;
  color: #334155;
  font-size: 12px;
  cursor: pointer;
  margin-bottom: 0;
}

.auto-refresh-switch input {
  opacity: 0;
  pointer-events: none;
  width: 0;
  height: 0;
  margin: 0;
}

.switch-track {
  width: 34px;
  height: 20px;
  border-radius: 999px;
  background: #cbd5e1;
  position: relative;
  transition: background 0.2s ease;
}

.switch-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 999px;
  background: #ffffff;
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.25);
  transition: transform 0.2s ease;
}

.auto-refresh-switch input:checked + .switch-track {
  background: #2563eb;
}

.auto-refresh-switch input:checked + .switch-track .switch-thumb {
  transform: translateX(14px);
}

.switch-label {
  line-height: 1.2;
}

.btn-refresh {
  width: auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
}

.metrics-grid {
  margin-top: 18px;
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.metric-card {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid #cbd5e1;
  border-radius: 14px;
  padding: 14px;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.06);
  position: relative;
  overflow: hidden;
  opacity: 0;
  transform: translateY(10px);
  animation: section-fade-in 0.35s ease forwards;
}

.metric-card.loading::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(110deg, transparent 8%, rgba(226, 232, 240, 0.35) 18%, transparent 33%);
  transform: translateX(-100%);
  animation: shimmer 1.2s linear infinite;
  pointer-events: none;
}

.metric-title {
  color: #475569;
  font-weight: 600;
  font-size: 12px;
  margin-bottom: 6px;
}

.metric-number {
  font-size: clamp(24px, 2vw, 30px);
  font-weight: 700;
  line-height: 1.1;
}

.metric-breakdown {
  list-style: none;
  padding: 0;
  margin: 10px 0 0;
  display: grid;
  gap: 4px;
}

.metric-breakdown li {
  display: grid;
  grid-template-columns: max-content auto;
  gap: 6px;
  color: #334155;
  font-size: 12px;
  align-items: center;
  justify-content: start;
}

.metric-breakdown li span {
  white-space: nowrap;
}

.metric-breakdown li strong {
  font-weight: 700;
  color: #0f172a;
}

.metric-breakdown .muted {
  color: #64748b;
}

.metric-loading {
  margin-top: 10px;
  color: #64748b;
  font-size: 12px;
  display: none;
}

.metric-card.loading .metric-loading {
  display: block;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.panel-head h2 {
  margin: 0;
}

.ap-upgrade-inline {
  margin-top: 12px;
  display: flex;
  align-items: stretch;
  gap: 10px;
}

.ap-upgrade-row {
  margin-top: 0;
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1px solid #dbe2ee;
  border-radius: 10px;
  background: #f8fbff;
  overflow-x: auto;
}

.ap-upgrade-title {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #1e40af;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.ap-upgrade-tools {
  margin-top: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
  overflow-x: visible;
  white-space: nowrap;
  max-width: 100%;
}

.ap-upgrade-tools select {
  min-width: 260px;
  max-width: 420px;
}

.ap-device-actions {
  margin-top: 0;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  flex-shrink: 0;
}

.ap-device-actions .tm-action-btn {
  margin-right: 0;
}

.ap-upgrade-tools .tm-action-btn {
  margin-right: 0;
}

.filters-row {
  margin-top: 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: end;
}

.filter-item {
  min-width: 150px;
}

.filter-item.grow {
  flex: 1;
  min-width: 220px;
}

.filters-row label {
  font-size: 12px;
  margin-bottom: 6px;
}

select {
  width: 100%;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #ffffff;
  color: #1f2937;
  padding: 9px 10px;
  font-size: 13px;
}

.filters-row input {
  padding: 9px 10px;
}

.list-loading {
  margin-top: 14px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #475569;
  font-size: 13px;
}

.empty-state {
  margin-top: 14px;
  color: #64748b;
  font-size: 13px;
}

.tenant-sections {
  margin-top: 14px;
  display: grid;
  gap: 14px;
}

.tenant-section {
  border: 1px solid #dbe2ee;
  border-radius: 12px;
  overflow: hidden;
  background: #ffffff;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.05);
  opacity: 0;
  transform: translateY(8px);
  animation: section-fade-in 0.28s ease forwards;
}

.tenant-section-title {
  background: linear-gradient(90deg, #eff6ff, #f8fafc);
  border-bottom: 1px solid #dbe2ee;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.section-title-toggle {
  cursor: pointer;
}

.tenant-section-title h3 {
  margin: 0;
  font-size: 13px;
}

.tenant-section-title span {
  color: #64748b;
  font-size: 12px;
}

.section-title-tools {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.section-toggle {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  border: 1px solid #cbd5e1;
  background: #ffffff;
  color: #475569;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.section-toggle:hover {
  background: #e2e8f0;
  color: #1e293b;
}

.ap-table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.ap-table {
  width: max-content;
  min-width: 100%;
  border-collapse: collapse;
}

.ap-table th,
.ap-table td {
  padding: 10px 12px;
  border-bottom: 1px solid #eef2f7;
  text-align: left;
  font-size: 12px;
  white-space: nowrap;
}

.ap-table th {
  color: #64748b;
  font-weight: 700;
  background: #fcfdff;
}

.ap-table .actions-col,
.ap-table .actions-cell {
  width: 96px;
  min-width: 96px;
  max-width: 96px;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
}

.status-badge.online {
  color: #14532d;
  background: #dcfce7;
}

.status-badge.offline {
  color: #7f1d1d;
  background: #fee2e2;
}

.status-badge.alert {
  color: #92400e;
  background: #fef3c7;
}

.status-badge.rebooting {
  color: #92400e;
  background: #fef3c7;
}

.status-badge.upgrading {
  color: #1d4ed8;
  background: #dbeafe;
}

.status-badge.resetting {
  color: #7c3aed;
  background: #ede9fe;
}

.status-badge.warning {
  color: #334155;
  background: #e2e8f0;
}

.actions-cell {
  white-space: nowrap;
}

.icon-action {
  width: 24px;
  height: 24px;
  padding: 0;
  margin-right: 4px;
  border-radius: 6px;
  border: 1px solid #dbe2ee;
  background: #f8fafc;
  color: #64748b;
}

.icon-action:last-child {
  margin-right: 0;
}

.icon-action[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
  color: #2563eb;
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
}

.back-link:hover {
  color: #1d4ed8;
}

.ap-detail-summary-panel {
  margin-top: 16px;
}

.ap-detail-summary-head,
.detail-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.ap-detail-summary-head h2,
.detail-section-head h2 {
  margin: 0;
}

.ap-detail-info-grid {
  margin-top: 14px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.detail-info-item,
.detail-count-card {
  min-width: 0;
  border: 1px solid #dbe2ee;
  border-radius: 10px;
  background: #f8fafc;
  padding: 10px 12px;
}

.detail-info-item span,
.detail-count-card span {
  display: block;
  color: #64748b;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.detail-info-item strong,
.detail-count-card strong {
  display: block;
  margin-top: 4px;
  color: #0f172a;
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.detail-count-card strong {
  font-size: 22px;
  line-height: 1.1;
}

.detail-tabs {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  border-bottom: 1px solid #dbe2ee;
  padding-bottom: 10px;
}

.detail-tab {
  width: auto;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #f8fafc;
  color: #475569;
  padding: 7px 10px;
  font-size: 12px;
}

.detail-tab.active {
  border-color: #bfdbfe;
  background: #eff6ff;
  color: #1d4ed8;
}

.detail-tab-panel {
  margin-top: 14px;
}

.detail-dpi-toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.detail-dpi-toolbar h2 {
  margin: 0;
}

.detail-dpi-window,
.detail-dpi-updated,
.detail-dpi-modal-subtitle {
  margin-top: 4px;
  color: #64748b;
  font-size: 12px;
}

.detail-dpi-timebar {
  margin-top: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.detail-dpi-timebar:empty {
  display: none;
}

.detail-dpi-timechip {
  flex: 0 0 auto;
  width: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #cbd5e1;
  border-radius: 999px;
  background: #ffffff;
  color: #475569;
  padding: 6px 10px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

.detail-dpi-timechip:hover {
  background: #f8fafc;
}

.detail-dpi-timechip.active {
  border-color: #bfdbfe;
  background: #eff6ff;
  color: #1d4ed8;
}

.detail-dpi-timechip:disabled {
  opacity: 0.65;
  cursor: default;
}

.detail-dpi-summary-grid {
  margin-top: 14px;
  display: grid;
  gap: 14px;
}

.detail-dpi-card {
  border: 1px solid #dbe2ee;
  border-radius: 12px;
  background: #ffffff;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.05);
  overflow: hidden;
}

.detail-dpi-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 14px;
  border-bottom: 1px solid #eef2f7;
}

.detail-dpi-card-title {
  margin: 0;
  color: #0f172a;
  font-size: 15px;
}

.detail-dpi-card-subtitle {
  margin-top: 4px;
  color: #64748b;
  font-size: 12px;
}

.detail-dpi-card-head-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.detail-dpi-card-value {
  color: #0f172a;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.detail-dpi-card-toggle {
  width: auto;
  min-width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #f8fafc;
  color: #475569;
}

.detail-dpi-card-toggle:hover {
  background: #eef2f7;
}

.detail-dpi-card-body {
  padding: 14px;
  display: grid;
  gap: 14px;
}

.detail-dpi-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.detail-dpi-metric {
  border: 1px solid #dbe2ee;
  border-radius: 10px;
  background: #f8fafc;
  padding: 10px;
  min-width: 0;
}

.detail-dpi-metric-label {
  color: #64748b;
  font-size: 11px;
  text-transform: uppercase;
}

.detail-dpi-metric-value {
  margin-top: 4px;
  color: #0f172a;
  font-size: 14px;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.detail-dpi-groups {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.detail-dpi-group {
  min-width: 0;
}

.detail-dpi-group-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.detail-dpi-group-title {
  color: #0f172a;
  font-size: 13px;
  font-weight: 700;
}

.detail-dpi-group-count {
  color: #64748b;
  font-size: 12px;
}

.detail-dpi-bar-list {
  display: grid;
  gap: 8px;
}

.detail-dpi-bar-row {
  display: grid;
  grid-template-columns: minmax(9rem, 1fr) minmax(8rem, 1.7fr) minmax(4rem, auto);
  gap: 8px;
  align-items: center;
  font-size: 12px;
}

.detail-dpi-bar-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #334155;
}

.detail-dpi-bar-track {
  height: 8px;
  border-radius: 999px;
  background: #e2e8f0;
  border: 1px solid #dbe2ee;
  overflow: hidden;
}

.detail-dpi-bar-fill {
  height: 100%;
  min-width: 2px;
  border-radius: 999px;
  background: linear-gradient(90deg, #1d4ed8, #0f766e);
}

.detail-dpi-bar-value {
  color: #64748b;
  text-align: right;
  white-space: nowrap;
}

.detail-dpi-toggle {
  width: auto;
  border: 0;
  background: transparent;
  color: #2563eb;
  padding: 0;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.detail-dpi-station-trigger {
  width: auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 0;
  background: transparent;
  color: #1d4ed8;
  padding: 0;
  font: inherit;
  cursor: pointer;
}

.detail-dpi-station-trigger:hover {
  color: #1e40af;
}

.detail-dpi-station-trigger i {
  font-size: 11px;
}

.detail-count-grid {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.detail-table-wrap {
  margin-top: 14px;
  border: 1px solid #dbe2ee;
  border-radius: 10px;
  background: #ffffff;
}

.detail-status-card-grid {
  margin-top: 14px;
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  gap: 12px;
}

.detail-status-section-stack {
  margin-top: 14px;
  display: grid;
  gap: 18px;
}

.detail-status-section-title {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #334155;
  font-size: 13px;
  font-weight: 700;
}

.detail-status-section-title i {
  color: #2563eb;
}

.detail-status-card {
  width: 360px;
  max-width: 100%;
  min-width: 0;
  border: 1px solid #dbe2ee;
  border-radius: 10px;
  background: #ffffff;
  padding: 12px;
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.05);
}

.detail-status-card.network-card {
  width: 420px;
}

.detail-status-card.port-card {
  width: 260px;
}

.detail-status-card.throughput-card {
  width: 320px;
}

.detail-status-card.system-card {
  width: 460px;
}

.detail-status-card.public-ip-card {
  width: 360px;
}

.detail-status-card-head,
.detail-status-title {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.detail-status-card-head {
  justify-content: space-between;
}

.detail-status-title {
  flex: 1;
}

.detail-status-icon {
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #eff6ff;
  color: #2563eb;
}

.detail-status-name,
.detail-status-sub {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.detail-status-name {
  color: #0f172a;
  font-size: 13px;
  font-weight: 700;
}

.detail-status-sub {
  margin-top: 2px;
  color: #64748b;
  font-size: 12px;
}

.detail-status-chip-row {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.detail-status-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  max-width: 100%;
  border-radius: 999px;
  background: #f1f5f9;
  color: #475569;
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 700;
}

.detail-kv-list {
  margin-top: 12px;
  display: grid;
  gap: 8px;
}

.detail-kv-row {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  border-bottom: 1px solid #eef2f7;
  padding-bottom: 7px;
}

.detail-kv-row:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.detail-kv-row span {
  color: #64748b;
  font-size: 12px;
}

.detail-kv-row strong {
  min-width: 0;
  color: #0f172a;
  font-size: 12px;
  font-weight: 600;
  text-align: right;
  word-break: break-word;
}

.detail-port-groups {
  margin-top: 10px;
  display: grid;
  gap: 8px;
}

.detail-port-group {
  display: grid;
  gap: 6px;
}

.detail-port-group > span {
  color: #64748b;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.detail-port-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.detail-port-list span {
  border-radius: 999px;
  background: #e2e8f0;
  color: #334155;
  padding: 3px 7px;
  font-size: 11px;
  font-weight: 700;
}

.detail-action-row {
  margin-top: 12px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.detail-action-row .tm-action-btn {
  width: 112px;
  min-width: 112px;
  justify-content: center;
  margin-right: 0;
}

.detail-speedtest-card {
  width: 396px;
  max-width: 100%;
  margin-top: 16px;
  border: 1px solid #dbe2ee;
  border-radius: 10px;
  background: #f8fafc;
  padding: 12px;
}

.detail-ssid-scan-card {
  width: min(760px, 100%);
}

.detail-ssid-scan-table {
  margin-top: 12px;
}

.detail-ssid-scan-table .ap-table {
  width: 100%;
}

.detail-speedtest-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.detail-speedtest-head h3 {
  margin: 0;
  color: #0f172a;
  font-size: 13px;
}

.detail-speedtest-head .tm-action-btn {
  width: 88px;
  min-width: 88px;
  justify-content: center;
  margin-right: 0;
}

.detail-speedtest-grid {
  margin-top: 12px;
  display: flex;
  align-items: stretch;
  flex-wrap: wrap;
  gap: 10px;
}

.detail-speedtest-metric {
  width: 180px;
  min-width: 180px;
  border: 1px solid #dbe2ee;
  border-radius: 8px;
  background: #ffffff;
  padding: 12px;
}

.detail-speedtest-metric span,
.detail-speedtest-metric small {
  display: block;
  color: #64748b;
  font-size: 12px;
}

.detail-speedtest-metric strong {
  display: block;
  margin-top: 4px;
  color: #0f172a;
  font-size: 24px;
  line-height: 1.1;
}

.ap-detail-modal-fields {
  margin-top: 12px;
}

.ap-detail-modal-fields .tm-field {
  margin-bottom: 10px;
}

.ap-detail-modal-fields input {
  padding: 9px 10px;
}

.detail-checkbox-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 2px 0 0;
  color: #334155;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
}

.detail-checkbox-row input {
  width: 14px;
  height: 14px;
  margin: 0;
  padding: 0;
}

#ap-detail-action-modal .tm-modal-actions button {
  width: 112px;
  justify-content: center;
  margin-right: 0;
}

.tenant-manage-panel {
  margin-top: 16px;
}

.tm-form-grid {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  align-items: end;
}

.tm-field label {
  font-size: 12px;
  margin-bottom: 6px;
}

.tm-field input {
  padding: 9px 10px;
}

.tm-form-actions {
  display: flex;
  justify-content: flex-start;
}

/* Firmware settings reuses the tenant-manage form styling but has only two
   (long) fields, so the 4-up tm-form-grid left the inputs cramped at 1/4 width
   with an empty 4th column and, with align-items:end, pushed the Base URL input
   below the taller API-key field. Two columns for the fields + a full-width
   action row, top-aligned. Mobile still collapses via the .tm-form-grid rule. */
.fw-settings-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: start;
}

.fw-settings-grid .tm-form-actions {
  grid-column: 1 / -1;
}

.tm-field-hint {
  display: block;
  margin-top: 6px;
  font-size: 11px;
  line-height: 1.4;
  color: #64748b;
}

.inline-note {
  margin-top: 10px;
  font-size: 12px;
  color: #475569;
  min-height: 18px;
}

.inline-note.success {
  color: #166534;
}

.inline-note.error {
  color: #b91c1c;
}

.tm-actions-cell {
  white-space: nowrap;
}

.tm-action-btn {
  width: auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  margin-right: 6px;
  border-radius: 8px;
  border: 1px solid #cbd5e1;
  background: #f8fafc;
  color: #334155;
  font-size: 12px;
  cursor: pointer;
}

.tm-action-btn:last-child {
  margin-right: 0;
}

.tm-action-btn:hover {
  background: #e2e8f0;
}

.tm-action-btn.warning {
  border-color: #facc15;
  background: #fef9c3;
  color: #854d0e;
}

.tm-action-btn.warning:hover {
  background: #fde68a;
}

.tm-action-btn.danger {
  border-color: #fecaca;
  background: #fee2e2;
  color: #991b1b;
}

.tm-action-btn.danger:hover {
  background: #fecaca;
}

.selected-pill {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  background: #eff6ff;
  color: #1e40af;
  font-size: 12px;
  font-weight: 600;
}

.ai-batch-grid {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  align-items: end;
}

.ai-batch-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-start;
}

.checkbox-col {
  width: 40px;
  min-width: 40px;
  max-width: 40px;
  text-align: center;
}

.checkbox-col input {
  width: 14px;
  height: 14px;
}

.sort-btn {
  width: auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 0;
  padding: 0;
  background: transparent;
  color: inherit;
  font-size: 12px;
  font-weight: 700;
}

.sort-btn i {
  font-size: 11px;
  color: #94a3b8;
}

.sort-btn:hover {
  background: transparent;
  color: inherit;
}

.ai-modal-card {
  max-width: 420px;
}

.tm-field input[type='file'] {
  padding: 8px 10px;
}

.tm-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
  padding: 16px;
  overflow-y: auto;
}

.tm-modal-card {
  width: 100%;
  max-width: 380px;
  background: #ffffff;
  border-radius: 12px;
  border: 1px solid #dbe2ee;
  box-shadow: 0 18px 38px rgba(15, 23, 42, 0.18);
  padding: 16px;
}

.tm-modal-card h3 {
  margin: 0 0 12px;
  font-size: 16px;
}

.tm-modal-actions {
  margin-top: 12px;
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.dashboard-action-modal-card {
  max-width: 560px;
}

.dashboard-action-modal-card.result-success {
  border-color: #bbf7d0;
}

.dashboard-action-modal-card.result-error {
  border-color: #fecaca;
}

.dashboard-action-modal-card.result-info {
  border-color: #bfdbfe;
}

.ap-detail-dpi-modal-card {
  max-width: 960px;
  max-height: calc(100vh - 32px);
  overflow-y: auto;
}

.detail-dpi-modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.dashboard-action-modal-message {
  margin: 0;
  color: #334155;
  font-size: 13px;
  line-height: 1.5;
  white-space: pre-line;
}

.dashboard-action-modal-details {
  margin: 10px 0 0;
  padding: 10px;
  border-radius: 8px;
  border: 1px solid #dbe2ee;
  background: #f8fafc;
  color: #334155;
  font-size: 12px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 240px;
  overflow: auto;
}

@keyframes section-fade-in {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes shimmer {
  to {
    transform: translateX(100%);
  }
}

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

  .sidebar {
    gap: 14px;
  }

  .menu {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .logout-btn {
    width: 100%;
  }

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

  .content-header-inline {
    flex-direction: column;
    align-items: flex-start;
  }

  .header-actions {
    width: 100%;
    flex-direction: column;
    align-items: stretch;
  }

  .ap-upgrade-inline {
    flex-direction: column;
    gap: 8px;
  }

  .ap-upgrade-row {
    width: 100%;
    justify-content: flex-start;
  }

  .ap-upgrade-tools select {
    min-width: 220px;
  }

  .ap-device-actions {
    justify-content: flex-start;
  }

  .auto-refresh-switch {
    justify-content: center;
  }

  .btn-refresh {
    width: 100%;
    justify-content: center;
  }

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

  .tm-form-actions {
    justify-content: stretch;
  }

  .ai-batch-grid {
    grid-template-columns: 1fr;
  }

  .ap-detail-info-grid,
  .detail-count-grid {
    grid-template-columns: 1fr 1fr;
  }

  .detail-dpi-metrics,
  .detail-dpi-groups {
    grid-template-columns: 1fr;
  }

  .detail-dpi-bar-row {
    grid-template-columns: minmax(0, 1fr);
  }

  .detail-dpi-bar-value {
    text-align: left;
  }

  .ai-batch-actions {
    flex-direction: column;
    align-items: stretch;
  }

}

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

  .content {
    padding: 20px 16px;
  }

  .filters-row {
    flex-direction: column;
    align-items: stretch;
  }

  .ap-detail-info-grid,
  .detail-count-grid {
    grid-template-columns: 1fr;
  }

  .filter-item,
  .filter-item.grow {
    min-width: 100%;
  }

  .ap-table th,
  .ap-table td {
    padding: 8px 10px;
  }

}

/* Running build, bottom of the sidebar. Deliberately quiet — it is reference
   information you go looking for, not something to read every visit. Empty
   until the fetch lands, and it collapses to nothing if the fetch fails, so a
   stale or placeholder version can never be shown. */
.app-version {
  font-size: 11px;
  line-height: 1;
  color: var(--muted);
  letter-spacing: 0.02em;
  text-align: center;
  cursor: default;
}

.app-version:empty {
  display: none;
}

/* The login page centres its card with `.page { display:flex; align-items:center;
   justify-content:center }`, so an extra child lands *beside* the card. Take it
   out of that flow and pin it to the bottom of the viewport instead — the card
   keeps centring exactly as before. */
.app-version--login {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
}
